From: Richard Basch Date: Tue, 7 May 1996 23:22:02 +0000 (+0000) Subject: Don't do more than the necessary encryptions for a single cblock length X-Git-Tag: krb5-1.0-beta6~125 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a364eb5488daaa743980a21a5f3a7100232ee0dc;p=krb5.git Don't do more than the necessary encryptions for a single cblock length random key. Only the larger cblocks need a second wrap-around cbc encrypt to prevent leaking a codebook. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@7922 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/crypto/des/random_key.c b/src/lib/crypto/des/random_key.c index b24ec51ef..1dc4600b4 100644 --- a/src/lib/crypto/des/random_key.c +++ b/src/lib/crypto/des/random_key.c @@ -80,10 +80,11 @@ mit_des_generate_random_key(state, randkey) (* state->eblock.crypto_entry->encrypt_func) (state->sequence.data /*in*/, randkey->contents /*out*/, state->sequence.length, eblock, zero_ivec); - (* state->eblock.crypto_entry->encrypt_func) - (randkey->contents /*in*/, randkey->contents /*out*/, - randkey->length, eblock, - randkey->contents + randkey->length - sizeof(mit_des_cblock)); + if (state->sequence.length > sizeof(mit_des_cblock)) + (* state->eblock.crypto_entry->encrypt_func) + (randkey->contents /*in*/, randkey->contents /*out*/, + randkey->length, eblock, + randkey->contents + randkey->length - sizeof(mit_des_cblock)); /* Increment the sequence number, with wraparound (LSB) */ for (i = 0; i < state->sequence.length; i++) {