diff options
author | Moritz Schulte <mo@g10code.com> | 2003-06-15 01:41:09 +0000 |
---|---|---|
committer | Moritz Schulte <mo@g10code.com> | 2003-06-15 01:41:09 +0000 |
commit | efebdc7da80139ee851d903447a67abb201dd367 (patch) | |
tree | adf6e683f71cfab64ca11d6d66a56bb656fe2b92 /cipher | |
parent | 2a205d1263b4a22ec322ccdd54a841501a154a28 (diff) | |
download | libgcrypt-efebdc7da80139ee851d903447a67abb201dd367.tar.gz |
2003-06-14 Moritz Schulte <moritz@g10code.com>
* des.c (des_setkey): Add selftest check.
(tripledes_set3keys): Likewise.
(do_tripledes_setkey): Remove selftest check.
(do_des_setkey): Likewise.
Diffstat (limited to 'cipher')
-rw-r--r-- | cipher/ChangeLog | 13 | ||||
-rw-r--r-- | cipher/des.c | 44 |
2 files changed, 36 insertions, 21 deletions
diff --git a/cipher/ChangeLog b/cipher/ChangeLog index 2debac88..4f496968 100644 --- a/cipher/ChangeLog +++ b/cipher/ChangeLog @@ -1,3 +1,16 @@ +2003-06-14 Moritz Schulte <moritz@g10code.com> + + * des.c (des_setkey): Add selftest check. + (tripledes_set3keys): Likewise. + (do_tripledes_setkey): Remove selftest check. + (do_des_setkey): Likewise. + +2003-06-11 Moritz Schulte <moritz@g10code.com> + + * md.c (_gcry_md_init): New function. + * cipher.c (_gcry_cipher_init): New function. + * pubkey.c (_gcry_pk_init): New function. + 2003-06-13 Werner Koch <wk@gnupg.org> * md.c (gcry_md_get_algo): Reverted to old API. This is a diff --git a/cipher/des.c b/cipher/des.c index 80d4661b..73e2290f 100644 --- a/cipher/des.c +++ b/cipher/des.c @@ -569,12 +569,19 @@ des_key_schedule (const byte * rawkey, u32 * subkey) static int des_setkey (struct _des_ctx *ctx, const byte * key) { + static const char *selftest_failed; int i; -#ifdef FIXME - if( selftest_failed ) + if (! initialized) + { + initialized = 1; + selftest_failed = selftest (); + + if (selftest_failed) + log_error ("%s\n", selftest_failed); + } + if (selftest_failed) return GPG_ERR_SELFTEST_FAILED; -#endif des_key_schedule (key, ctx->encrypt_subkeys); _gcry_burn_stack (32); @@ -669,8 +676,20 @@ tripledes_set3keys (struct _tripledes_ctx *ctx, const byte * key2, const byte * key3) { + static const char *selftest_failed; int i; + if (! initialized) + { + initialized = 1; + selftest_failed = selftest (); + + if (selftest_failed) + log_error ("%s\n", selftest_failed); + } + if (selftest_failed) + return GPG_ERR_SELFTEST_FAILED; + des_key_schedule (key1, ctx->encrypt_subkeys); des_key_schedule (key2, &(ctx->decrypt_subkeys[32])); des_key_schedule (key3, &(ctx->encrypt_subkeys[64])); @@ -686,7 +705,7 @@ tripledes_set3keys (struct _tripledes_ctx *ctx, ctx->decrypt_subkeys[i+64] = ctx->encrypt_subkeys[30-i]; ctx->decrypt_subkeys[i+65] = ctx->encrypt_subkeys[31-i]; - } + } return 0; } @@ -977,11 +996,6 @@ do_tripledes_setkey ( void *context, const byte *key, unsigned keylen ) { struct _tripledes_ctx *ctx = (struct _tripledes_ctx *) context; -#ifdef FIXME - if( selftest_failed ) - return GPG_ERR_SELFTEST_FAILED; -#endif - if( keylen != 24 ) return GPG_ERR_INV_KEYLEN; @@ -1018,18 +1032,6 @@ static gpg_err_code_t do_des_setkey (void *context, const byte *key, unsigned keylen) { struct _des_ctx *ctx = (struct _des_ctx *) context; - static const char *selftest_failed; - - if (! initialized) - { - initialized = 1; - selftest_failed = selftest (); - - if (selftest_failed) - log_error ("%s\n", selftest_failed); - } - if (selftest_failed) - return GPG_ERR_SELFTEST_FAILED; if (keylen != 8) return GPG_ERR_INV_KEYLEN; |