2 #include "omac_noekeon.h"
8 void omac_noekeon_init(omac_noekeon_ctx_t* ctx){
13 void omac_noekeon_tweak(uint8_t t, const void* key, omac_noekeon_ctx_t* ctx){
15 noekeon_enc(ctx, key);
18 void omac_noekeon_next(const void* buffer, const void* key, omac_noekeon_ctx_t* ctx){
19 memxor(ctx, buffer, 16);
20 noekeon_enc(ctx, key);
24 void omac_noekeon_comppad(uint8_t* pad, const void* key, uint8_t length_b){
27 noekeon_enc(pad, key);
28 r=(length_b==128)?1:2;
34 pad[15-j] = ((pad[15-j])<<1) | c2;
41 pad[(length_b)/8] ^= 0x80 >> (length_b%8);
45 void omac_noekeon_last(const void* buffer, uint8_t length_b, const void* key, omac_noekeon_ctx_t* ctx){
47 omac_noekeon_next(buffer, key, ctx);
48 buffer = (uint8_t*)buffer +16;
52 omac_noekeon_comppad(pad, key, length_b);
53 memxor(pad, buffer, (length_b+7)/8);
54 omac_noekeon_next(pad, key, ctx);
58 void omac_noekeon(void* dest, const void* msg, uint16_t msglength_b,
59 const void* key, uint8_t t){
60 omac_noekeon_init(dest);
62 omac_noekeon_tweak(t,key,dest);
63 while(msglength_b>128){
64 omac_noekeon_next(msg, key, dest);
65 msg = (uint8_t*)msg +16;
68 omac_noekeon_last(msg, msglength_b, key, dest);