Import libgcrypt 1.5.3.
This commit is contained in:
parent
c12936c5d1
commit
d1307d873a
72 changed files with 11732 additions and 2916 deletions
|
@ -45,7 +45,7 @@ do_encrypt_stream( ARCFOUR_context *ctx,
|
|||
register int i = ctx->idx_i;
|
||||
register int j = ctx->idx_j;
|
||||
register byte *sbox = ctx->sbox;
|
||||
register int t;
|
||||
register int t;
|
||||
|
||||
while ( length-- )
|
||||
{
|
||||
|
@ -56,7 +56,7 @@ do_encrypt_stream( ARCFOUR_context *ctx,
|
|||
t = sbox[i]; sbox[i] = sbox[j]; sbox[j] = t;
|
||||
*outbuf++ = *inbuf++ ^ sbox[(sbox[i] + sbox[j]) & 255];
|
||||
}
|
||||
|
||||
|
||||
ctx->idx_i = i;
|
||||
ctx->idx_j = j;
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ do_arcfour_setkey (void *context, const byte *key, unsigned int keylen)
|
|||
byte karr[256];
|
||||
ARCFOUR_context *ctx = (ARCFOUR_context *) context;
|
||||
|
||||
if (!initialized )
|
||||
if (!initialized )
|
||||
{
|
||||
initialized = 1;
|
||||
selftest_failed = selftest();
|
||||
|
@ -98,14 +98,14 @@ do_arcfour_setkey (void *context, const byte *key, unsigned int keylen)
|
|||
ctx->sbox[i] = i;
|
||||
for (i=0; i < 256; i++ )
|
||||
karr[i] = key[i%keylen];
|
||||
for (i=j=0; i < 256; i++ )
|
||||
for (i=j=0; i < 256; i++ )
|
||||
{
|
||||
int t;
|
||||
j = (j + ctx->sbox[i] + karr[i]) % 256;
|
||||
t = ctx->sbox[i];
|
||||
ctx->sbox[i] = ctx->sbox[j];
|
||||
ctx->sbox[j] = t;
|
||||
}
|
||||
}
|
||||
memset( karr, 0, 256 );
|
||||
|
||||
return GPG_ERR_NO_ERROR;
|
||||
|
@ -125,8 +125,8 @@ static const char*
|
|||
selftest(void)
|
||||
{
|
||||
ARCFOUR_context ctx;
|
||||
byte scratch[16];
|
||||
|
||||
byte scratch[16];
|
||||
|
||||
/* Test vector from Cryptlib labeled there: "from the
|
||||
State/Commerce Department". */
|
||||
static byte key_1[] =
|
||||
|
@ -153,4 +153,3 @@ gcry_cipher_spec_t _gcry_cipher_spec_arcfour =
|
|||
"ARCFOUR", NULL, NULL, 1, 128, sizeof (ARCFOUR_context),
|
||||
arcfour_setkey, NULL, NULL, encrypt_stream, encrypt_stream,
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue