2 * Written in 2013 by Gregor Pintar <grpintar@gmail.com>
4 * To the extent possible under law, the author(s) have dedicated
5 * all copyright and related and neighboring rights to this software
6 * to the public domain worldwide.
8 * This software is distributed without any warranty.
10 * You should have received a copy of the CC0 Public Domain Dedication.
11 * If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
16 #include <kripto/desc/block.h>
18 #include <kripto/block.h>
22 const kripto_block_desc
*desc
;
25 kripto_block
*kripto_block_create
27 const kripto_block_desc
*desc
,
38 assert(key_len
<= kripto_block_maxkey(desc
));
40 return desc
->create(rounds
, key
, key_len
);
43 kripto_block
*kripto_block_recreate
53 assert(s
->desc
->recreate
);
57 assert(key_len
<= kripto_block_maxkey(s
->desc
));
59 return s
->desc
->recreate(s
, rounds
, key
, key_len
);
62 void kripto_block_tweak
71 assert(s
->desc
->tweak
);
76 s
->desc
->tweak(s
, tweak
, len
);
79 void kripto_block_encrypt
81 const kripto_block
*s
,
88 assert(s
->desc
->encrypt
);
92 s
->desc
->encrypt(s
, pt
, ct
);
95 void kripto_block_decrypt
97 const kripto_block
*s
,
104 assert(s
->desc
->decrypt
);
108 s
->desc
->decrypt(s
, ct
, pt
);
111 void kripto_block_destroy(kripto_block
*s
)
115 assert(s
->desc
->destroy
);
120 const kripto_block_desc
*kripto_block_getdesc(const kripto_block
*s
)
128 unsigned int kripto_block_size(const kripto_block_desc
*desc
)
131 assert(desc
->blocksize
);
133 return desc
->blocksize
;
136 unsigned int kripto_block_maxkey(const kripto_block_desc
*desc
)
139 assert(desc
->maxkey
);