des: don't consider DES for CIPHER_ENCRYPT_ONLY
We only support ECB and CBC modes for DES. Those two modes require both encrypt and decrypt directions, so we don't consider DES with CIPHER_ENCRYPT_ONLY. Signed-off-by: Yanray Wang <yanray.wang@arm.com>
This commit is contained in:
parent
4f4822c553
commit
56e27b9938
2 changed files with 0 additions and 27 deletions
|
@ -182,7 +182,6 @@ int mbedtls_des_key_check_weak(const unsigned char key[MBEDTLS_DES_KEY_SIZE]);
|
|||
MBEDTLS_CHECK_RETURN_TYPICAL
|
||||
int mbedtls_des_setkey_enc(mbedtls_des_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE]);
|
||||
|
||||
#if !defined(MBEDTLS_CIPHER_ENCRYPT_ONLY)
|
||||
/**
|
||||
* \brief DES key schedule (56-bit, decryption)
|
||||
*
|
||||
|
@ -197,7 +196,6 @@ int mbedtls_des_setkey_enc(mbedtls_des_context *ctx, const unsigned char key[MBE
|
|||
*/
|
||||
MBEDTLS_CHECK_RETURN_TYPICAL
|
||||
int mbedtls_des_setkey_dec(mbedtls_des_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE]);
|
||||
#endif /* !MBEDTLS_CIPHER_ENCRYPT_ONLY */
|
||||
|
||||
/**
|
||||
* \brief Triple-DES key schedule (112-bit, encryption)
|
||||
|
@ -215,7 +213,6 @@ MBEDTLS_CHECK_RETURN_TYPICAL
|
|||
int mbedtls_des3_set2key_enc(mbedtls_des3_context *ctx,
|
||||
const unsigned char key[MBEDTLS_DES_KEY_SIZE * 2]);
|
||||
|
||||
#if !defined(MBEDTLS_CIPHER_ENCRYPT_ONLY)
|
||||
/**
|
||||
* \brief Triple-DES key schedule (112-bit, decryption)
|
||||
*
|
||||
|
@ -231,7 +228,6 @@ int mbedtls_des3_set2key_enc(mbedtls_des3_context *ctx,
|
|||
MBEDTLS_CHECK_RETURN_TYPICAL
|
||||
int mbedtls_des3_set2key_dec(mbedtls_des3_context *ctx,
|
||||
const unsigned char key[MBEDTLS_DES_KEY_SIZE * 2]);
|
||||
#endif /* !MBEDTLS_CIPHER_ENCRYPT_ONLY */
|
||||
|
||||
/**
|
||||
* \brief Triple-DES key schedule (168-bit, encryption)
|
||||
|
@ -249,7 +245,6 @@ MBEDTLS_CHECK_RETURN_TYPICAL
|
|||
int mbedtls_des3_set3key_enc(mbedtls_des3_context *ctx,
|
||||
const unsigned char key[MBEDTLS_DES_KEY_SIZE * 3]);
|
||||
|
||||
#if !defined(MBEDTLS_CIPHER_ENCRYPT_ONLY)
|
||||
/**
|
||||
* \brief Triple-DES key schedule (168-bit, decryption)
|
||||
*
|
||||
|
@ -265,7 +260,6 @@ int mbedtls_des3_set3key_enc(mbedtls_des3_context *ctx,
|
|||
MBEDTLS_CHECK_RETURN_TYPICAL
|
||||
int mbedtls_des3_set3key_dec(mbedtls_des3_context *ctx,
|
||||
const unsigned char key[MBEDTLS_DES_KEY_SIZE * 3]);
|
||||
#endif /* !MBEDTLS_CIPHER_ENCRYPT_ONLY */
|
||||
|
||||
/**
|
||||
* \brief DES-ECB block encryption/decryption
|
||||
|
|
|
@ -483,7 +483,6 @@ int mbedtls_des_setkey_enc(mbedtls_des_context *ctx, const unsigned char key[MBE
|
|||
/*
|
||||
* DES key schedule (56-bit, decryption)
|
||||
*/
|
||||
#if !defined(MBEDTLS_CIPHER_ENCRYPT_ONLY)
|
||||
int mbedtls_des_setkey_dec(mbedtls_des_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE])
|
||||
{
|
||||
int i;
|
||||
|
@ -497,7 +496,6 @@ int mbedtls_des_setkey_dec(mbedtls_des_context *ctx, const unsigned char key[MBE
|
|||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void des3_set2key(uint32_t esk[96],
|
||||
uint32_t dsk[96],
|
||||
|
@ -540,7 +538,6 @@ int mbedtls_des3_set2key_enc(mbedtls_des3_context *ctx,
|
|||
/*
|
||||
* Triple-DES key schedule (112-bit, decryption)
|
||||
*/
|
||||
#if !defined(MBEDTLS_CIPHER_ENCRYPT_ONLY)
|
||||
int mbedtls_des3_set2key_dec(mbedtls_des3_context *ctx,
|
||||
const unsigned char key[MBEDTLS_DES_KEY_SIZE * 2])
|
||||
{
|
||||
|
@ -551,7 +548,6 @@ int mbedtls_des3_set2key_dec(mbedtls_des3_context *ctx,
|
|||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void des3_set3key(uint32_t esk[96],
|
||||
uint32_t dsk[96],
|
||||
|
@ -592,7 +588,6 @@ int mbedtls_des3_set3key_enc(mbedtls_des3_context *ctx,
|
|||
/*
|
||||
* Triple-DES key schedule (168-bit, decryption)
|
||||
*/
|
||||
#if !defined(MBEDTLS_CIPHER_ENCRYPT_ONLY)
|
||||
int mbedtls_des3_set3key_dec(mbedtls_des3_context *ctx,
|
||||
const unsigned char key[MBEDTLS_DES_KEY_SIZE * 3])
|
||||
{
|
||||
|
@ -603,7 +598,6 @@ int mbedtls_des3_set3key_dec(mbedtls_des3_context *ctx,
|
|||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* DES-ECB block encryption/decryption
|
||||
|
@ -875,43 +869,28 @@ int mbedtls_des_self_test(int verbose)
|
|||
(v == MBEDTLS_DES_DECRYPT) ? "dec" : "enc");
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_ENCRYPT_ONLY)
|
||||
if (v == MBEDTLS_DES_DECRYPT) {
|
||||
if (verbose != 0) {
|
||||
mbedtls_printf("skipped\n");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
memcpy(buf, des3_test_buf, 8);
|
||||
|
||||
switch (i) {
|
||||
#if !defined(MBEDTLS_CIPHER_ENCRYPT_ONLY)
|
||||
case 0:
|
||||
ret = mbedtls_des_setkey_dec(&ctx, des3_test_keys);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case 1:
|
||||
ret = mbedtls_des_setkey_enc(&ctx, des3_test_keys);
|
||||
break;
|
||||
|
||||
#if !defined(MBEDTLS_CIPHER_ENCRYPT_ONLY)
|
||||
case 2:
|
||||
ret = mbedtls_des3_set2key_dec(&ctx3, des3_test_keys);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case 3:
|
||||
ret = mbedtls_des3_set2key_enc(&ctx3, des3_test_keys);
|
||||
break;
|
||||
|
||||
#if !defined(MBEDTLS_CIPHER_ENCRYPT_ONLY)
|
||||
case 4:
|
||||
ret = mbedtls_des3_set3key_dec(&ctx3, des3_test_keys);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case 5:
|
||||
ret = mbedtls_des3_set3key_enc(&ctx3, des3_test_keys);
|
||||
|
|
Loading…
Reference in a new issue