Skip to content

Commit d105d3a

Browse files
committed
[#422] Fix magic number
1 parent ab83e91 commit d105d3a

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

include/crypto_config.h

+2-5
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
#define BYTE_LEN 8 /* bits */
138138
#define CRYPTOLIB_APPID 128
139139
#define MAX_IV_LEN 32 /* bytes */
140+
#define CBC_MAX_PAD 16 /* bytes */
140141

141142
// Monitoring and Control Defines
142143
#define EMV_SIZE 4 /* bytes */
@@ -198,6 +199,7 @@
198199
#define TC_SN_WINDOW 10 /* +/- value */
199200
#define TC_FRAME_DATA_SIZE 1019 /* bytes */ // 1024 - 5byte header
200201
#define TC_CADU_ASM_SIZE 4
202+
#define TC_BLOCK_SIZE 16
201203

202204
// CCSDS PUS Defines
203205
#define TLV_DATA_SIZE 494 /* bytes */
@@ -249,9 +251,4 @@
249251
*/
250252
#define CRYPTO_SA_SAVE "sa_save_file.bin"
251253

252-
/*
253-
** TC_BLOCK_SIZE
254-
*/
255-
#define TC_BLOCK_SIZE 16
256-
257254
#endif // CRYPTO_CONFIG_H

src/core/crypto_aos.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ int32_t Crypto_AOS_ApplySecurity(uint8_t *pTfBuffer, uint16_t len_ingest)
130130
}
131131
else if ((sa_ptr->ecs == CRYPTO_CIPHER_AES256_CBC) || (sa_ptr->ecs == CRYPTO_CIPHER_AES256_CBC_MAC))
132132
{
133-
if((current_managed_parameters_struct.max_frame_size - len_ingest) <= 16)
133+
if((current_managed_parameters_struct.max_frame_size - len_ingest) <= CBC_MAX_PAD)
134134
{
135135
cbc_padding = current_managed_parameters_struct.max_frame_size - len_ingest;
136136
}

src/core/crypto_tm.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ int32_t Crypto_TM_ApplySecurity(uint8_t *pTfBuffer, uint16_t len_ingest)
768768
}
769769
else if ((sa_ptr->ecs == CRYPTO_CIPHER_AES256_CBC) || (sa_ptr->ecs == CRYPTO_CIPHER_AES256_CBC_MAC))
770770
{
771-
if((current_managed_parameters_struct.max_frame_size - len_ingest) <= 16)
771+
if((current_managed_parameters_struct.max_frame_size - len_ingest) <= CBC_MAX_PAD)
772772
{
773773
cbc_padding = current_managed_parameters_struct.max_frame_size - len_ingest;
774774
}

0 commit comments

Comments
 (0)