21.03.2013 Views

Problem - Kevin Tafuro

Problem - Kevin Tafuro

Problem - Kevin Tafuro

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

unsigned char c1[SPC_BLOCK_SZ]; /* L * u */<br />

unsigned char c2[SPC_BLOCK_SZ]; /* L / u */<br />

} SPC_OMAC_CTX;<br />

int spc_omac1_init(SPC_OMAC_CTX *ctx, unsigned char *key, int keylen) {<br />

int condition, i;<br />

unsigned char L[SPC_BLOCK_SZ] = {0,};<br />

if (keylen != 16 && keylen != 24 && keylen != 32) return 0;<br />

SPC_ENCRYPT_INIT(&(ctx->ks), key, keylen);<br />

SPC_DO_ENCRYPT(&(ctx->ks), L, L);<br />

spc_memset(ctx->iv, 0, SPC_BLOCK_SZ);<br />

ctx->ix = 0;<br />

/* Compute L * u */<br />

condition = L[0] & 0x80;<br />

ctx->c1[0] = L[0] c1[i - 1] |= L[i] >> 7;<br />

ctx->c1[i] = L[i] c1[SPC_BLOCK_SZ - 1] ^= 0x87;<br />

/* Compute L * u * u */<br />

condition = ctx->c1[0] & 0x80;<br />

ctx->c2[0] = ctx->c1[0] c2[i - 1] |= ctx->c1[i] >> 7;<br />

ctx->c2[i] = ctx->c1[i] c2[SPC_BLOCK_SZ - 1] ^= 0x87;<br />

spc_memset(L, 0, SPC_BLOCK_SZ);<br />

return 1;<br />

}<br />

int spc_omac2_init(SPC_OMAC_CTX *ctx, unsigned char *key, int keylen) {<br />

int condition, i;<br />

unsigned char L[SPC_BLOCK_SZ] = {0,};<br />

if (keylen != 16 && keylen != 24 && keylen != 32) return 0;<br />

SPC_ENCRYPT_INIT(&(ctx->ks), key, keylen);<br />

SPC_DO_ENCRYPT(&(ctx->ks), L, L);<br />

spc_memset(ctx->iv, 0, SPC_BLOCK_SZ);<br />

ctx->ix = 0;<br />

/* Compute L * u, storing it in c1 */<br />

condition = L[0] >> 7;<br />

ctx->c1[0] = L[0] c1[i - 1] |= L[i] >> 7;<br />

ctx->c1[i] = L[i]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!