Skip to content

Commit

Permalink
Fix DES and TDES key length.
Browse files Browse the repository at this point in the history
Although a DES key has only 56 effective bits, all 64 bits must be
considered, because the parity bits are spread over all 8 bytes of
the key.

Signed-off-by: Joerg Schmidbauer <jschmidb@de.ibm.com>
  • Loading branch information
jschmidb committed Mar 20, 2020
1 parent 58c1073 commit db1ad6f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/ica_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
#define DEFAULT2_CRYPT_DEVICE "/dev/z90crypt"
#define DEFAULT3_CRYPT_DEVICE "/dev/zcrypt"

#define DES_KEY_LEN64 (64/8)

#define MAX_VERSION_LENGTH 16

int ica_fallbacks_enabled = 1;
Expand Down Expand Up @@ -125,9 +127,9 @@ static unsigned int check_des_parms(unsigned int mode,

#ifdef ICA_FIPS
static unsigned int fips_check_3des_key(const ica_des_key_triple_t *key) {
if (!CRYPTO_memcmp(key->key1, key->key2, DES_KEY_LENGTH)
| !CRYPTO_memcmp(key->key1, key->key3, DES_KEY_LENGTH)
| !CRYPTO_memcmp(key->key2, key->key3, DES_KEY_LENGTH))
if (!CRYPTO_memcmp(key->key1, key->key2, DES_KEY_LEN64)
| !CRYPTO_memcmp(key->key1, key->key3, DES_KEY_LEN64)
| !CRYPTO_memcmp(key->key2, key->key3, DES_KEY_LEN64))
return EINVAL;

return 0;
Expand Down

0 comments on commit db1ad6f

Please sign in to comment.