Skip to content

Commit 523ca0a

Browse files
ccli8adbridge
authored andcommitted
Fix parameter check for TMODE/OPMODE in DES alter.
1 parent acbc4e4 commit 523ca0a

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/des/des_alt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,8 @@ static int mbedtls_des_docrypt(uint16_t keyopt, uint8_t key[3][MBEDTLS_DES_KEY_S
323323
error("Enc/dec flag in DES alter. requires to be 0/1.");
324324
}
325325

326-
if ((tdes_opmode < DES_MODE_ECB) || (tdes_opmode > DES_MODE_CTR)) {
327-
error("Block cipher mode of operations in DES alter. requires to be ECB/CBC/CFB/OFB/CTR.");
326+
if (tdes_opmode & ~(CRPT_TDES_CTL_TMODE_Msk | CRPT_TDES_CTL_OPMODE_Msk)) {
327+
error("Invalid TMODE/OPMODE in DES alter.");
328328
}
329329

330330
if (length % 8) {

features/mbedtls/targets/TARGET_NUVOTON/TARGET_NUC472/des/des_alt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,8 @@ static int mbedtls_des_docrypt(uint16_t keyopt, uint8_t key[3][MBEDTLS_DES_KEY_S
323323
error("Enc/dec flag in DES alter. requires to be 0/1.");
324324
}
325325

326-
if ((tdes_opmode < DES_MODE_ECB) || (tdes_opmode > DES_MODE_CTR)) {
327-
error("Block cipher mode of operations in DES alter. requires to be ECB/CBC/CFB/OFB/CTR.");
326+
if (tdes_opmode & ~(CRPT_TDES_CTL_TMODE_Msk | CRPT_TDES_CTL_OPMODE_Msk)) {
327+
error("Invalid TMODE/OPMODE in DES alter.");
328328
}
329329

330330
if (length % 8) {

0 commit comments

Comments
 (0)