| { |
{ |
| u32 i, j; |
u32 i, j; |
| |
|
| |
#if (ECRYPT_VARIANT == 1) |
| |
u8* s = (u8*)ctx->s; |
| |
#else |
| |
u32* s = (u32*)ctx->s; |
| |
#endif |
| |
|
| for (i = 0; i < 256; ++i) |
for (i = 0; i < 256; ++i) |
| ctx->s[i] = i; |
s[i] = i; |
| |
|
| for (i = j = 0; i < 256; ++i) |
for (i = j = 0; i < 256; ++i) |
| { |
{ |
| u32 a; |
u32 a; |
| |
|
| j = (j + (a = ctx->s[i]) + ctx->key[i % ctx->keylen]) & 0xFF; |
j = (j + (a = s[i]) + ctx->key[i % ctx->keylen]) & 0xFF; |
| ctx->s[i] = ctx->s[j]; |
s[i] = s[j]; |
| ctx->s[j] = a; |
s[j] = a; |
| } |
} |
| |
|
| ctx->i = 0; |
ctx->i = 0; |
| u32 a, b; \ |
u32 a, b; \ |
| \ |
\ |
| i = (i + 1) & 0xFF; \ |
i = (i + 1) & 0xFF; \ |
| j = (j + (a = ctx->s[i])) & 0xFF; \ |
j = (j + (a = s[i])) & 0xFF; \ |
| \ |
\ |
| ctx->s[i] = b = ctx->s[j]; \ |
s[i] = b = s[j]; \ |
| output[n] = ctx->s[(b + (ctx->s[j] = a)) & 0xFF]; \ |
output[n] = s[(b + (s[j] = a)) & 0xFF]; \ |
| } while (0) |
} while (0) |
| |
|
| |
|
| u32 i = ctx->i; |
u32 i = ctx->i; |
| u32 j = ctx->j; |
u32 j = ctx->j; |
| |
|
| |
#if (ECRYPT_VARIANT == 1) |
| |
u8* s = (u8*)ctx->s; |
| |
#else |
| |
u32* s = (u32*)ctx->s; |
| |
#endif |
| |
|
| for ( ; (int)(msglen -= 16) >= 0; output += 16, input += 16) |
for ( ; (int)(msglen -= 16) >= 0; output += 16, input += 16) |
| { |
{ |
| ITERATE( 0); ITERATE( 1); ITERATE( 2); ITERATE( 3); |
ITERATE( 0); ITERATE( 1); ITERATE( 2); ITERATE( 3); |