From 442e7215fb0b7455d31587bd6ad9ccb5d5a64dd7 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 2 Aug 2001 09:48:40 +0000 Subject: Made Arcfour work --- cipher/ChangeLog | 6 ++++++ cipher/arcfour.c | 9 +++------ 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'cipher') diff --git a/cipher/ChangeLog b/cipher/ChangeLog index fa42f7fa..e96ce481 100644 --- a/cipher/ChangeLog +++ b/cipher/ChangeLog @@ -1,3 +1,9 @@ +2001-08-02 Werner Koch + + * arcfour.c (arcfour_setkey): Check the minimim keylength against + bytes and not bits. + (selftest): Must reset the key before decryption. + 2001-05-31 Werner Koch * sha1.c (sha1_init): Made static. diff --git a/cipher/arcfour.c b/cipher/arcfour.c index a915cb79..c19d282d 100644 --- a/cipher/arcfour.c +++ b/cipher/arcfour.c @@ -78,8 +78,8 @@ arcfour_setkey( ARCFOUR_context *ctx, const byte *key, unsigned int keylen ) if( selftest_failed ) return GCRYERR_SELFTEST; - if( keylen < 40 ) - return GCRYERR_INV_KEYLEN; + if( keylen < 40/8 ) /* we want at least 40 bits */ + return GCRYERR_INV_KEYLEN; ctx->idx_i = ctx->idx_j = 0; for (i=0; i < 256; i++ ) @@ -118,6 +118,7 @@ selftest(void) encrypt_stream( &ctx, scratch, plaintext_1, sizeof(plaintext_1)); if (memcmp (scratch, ciphertext_1, sizeof (ciphertext_1))) return "Arcfour encryption test 1 failed."; + arcfour_setkey( &ctx, key_1, sizeof(key_1)); encrypt_stream(&ctx, scratch, scratch, sizeof(plaintext_1)); /* decrypt */ if ( memcmp (scratch, plaintext_1, sizeof (plaintext_1))) return "Arcfour decryption test 1 failed."; @@ -159,7 +160,3 @@ _gcry_arcfour_get_info( int algo, size_t *keylen, size_t *blocksize, return "ARCFOUR"; return NULL; } - - - - -- cgit v1.2.1