23 #include "skinny64-cipher.h"
24 #include "skinny64-ctr-internal.h"
25 #include "skinny-internal.h"
64 static int skinny64_ctr_def_set_key
85 static int skinny64_ctr_def_set_tweaked_key
106 static int skinny64_ctr_def_set_tweak
125 static int skinny64_ctr_def_set_counter
148 static int skinny64_ctr_def_encrypt
149 (
void *output,
const void *input,
size_t size,
Skinny64CTR_t *ctr)
152 uint8_t *out = (uint8_t *)output;
153 const uint8_t *in = (
const uint8_t *)input;
156 if (!output || !input)
167 skinny64_inc_counter(ctx->
counter, 1);
171 skinny64_xor(out, in, ctx->
ecounter);
177 skinny_xor(out, in, ctx->
ecounter, size);
197 static Skinny64CTRVtable_t
const skinny64_ctr_def = {
198 skinny64_ctr_def_init,
199 skinny64_ctr_def_cleanup,
200 skinny64_ctr_def_set_key,
201 skinny64_ctr_def_set_tweaked_key,
202 skinny64_ctr_def_set_tweak,
203 skinny64_ctr_def_set_counter,
204 skinny64_ctr_def_encrypt
211 const Skinny64CTRVtable_t *vtable;
218 vtable = &skinny64_ctr_def;
219 if (_skinny_has_vec128())
220 vtable = &_skinny64_ctr_vec128;
224 return (*(vtable->init))(ctr);
230 const Skinny64CTRVtable_t *vtable = ctr->
vtable;
231 (*(vtable->cleanup))(ctr);
239 const Skinny64CTRVtable_t *vtable = ctr->
vtable;
240 return (*(vtable->set_key))(ctr, key, size);
249 const Skinny64CTRVtable_t *vtable = ctr->
vtable;
250 return (*(vtable->set_tweaked_key))(ctr, key, key_size);
259 const Skinny64CTRVtable_t *vtable = ctr->
vtable;
260 return (*(vtable->set_tweak))(ctr, tweak, tweak_size);
269 const Skinny64CTRVtable_t *vtable = ctr->
vtable;
270 return (*(vtable->set_counter))(ctr, counter, size);
279 const Skinny64CTRVtable_t *vtable = ctr->
vtable;
280 return (*(vtable->encrypt))(output, input, size, ctr);
unsigned char ecounter[SKINNY64_BLOCK_SIZE]
void skinny64_ctr_cleanup(Skinny64CTR_t *ctr)
Cleans up a CTR control block for Skinny-64.
int skinny64_set_tweak(Skinny64TweakedKey_t *ks, const void *tweak, unsigned tweak_size)
Changes the tweak value for a previously-initialized key schedule.
int skinny64_ctr_set_key(Skinny64CTR_t *ctr, const void *key, unsigned size)
Sets the key schedule for a Skinny64 block cipher in CTR mode.
int skinny64_set_key(Skinny64Key_t *ks, const void *key, unsigned size)
Sets the key schedule for a Skinny64 block cipher.
int skinny64_ctr_init(Skinny64CTR_t *ctr)
Initializes Skinny-64 in CTR mode.
int skinny64_ctr_encrypt(void *output, const void *input, size_t size, Skinny64CTR_t *ctr)
Encrypt a block of data using Skinny-64 in CTR mode.
int skinny64_set_tweaked_key(Skinny64TweakedKey_t *ks, const void *key, unsigned key_size)
Sets the key schedule for a Skinny64 block cipher, and prepare for tweaked encryption.
Key schedule for Skinny64 block ciphers when a tweak is in use.
void skinny64_ecb_encrypt(void *output, const void *input, const Skinny64Key_t *ks)
Encrypts a single block using the Skinny64 block cipher in ECB mode.
int skinny64_ctr_set_counter(Skinny64CTR_t *ctr, const void *counter, unsigned size)
Sets the counter value in a Skinny-64 CTR control block.
unsigned char counter[SKINNY64_BLOCK_SIZE]
#define SKINNY64_BLOCK_SIZE
Size of a block for Skinny64 block ciphers.
State information for Skinny-64 in CTR mode.
int skinny64_ctr_set_tweak(Skinny64CTR_t *ctr, const void *tweak, unsigned tweak_size)
Changes the tweak value for a previously-initialized key schedule.
int skinny64_ctr_set_tweaked_key(Skinny64CTR_t *ctr, const void *key, unsigned key_size)
Sets the key schedule for a Skinny64 block cipher in CTR mode, and prepare for tweaked encryption...