@@ -45,7 +45,7 @@ int32_t Crypto_Key_OTAR(void)
45
45
int y ;
46
46
int32_t status = CRYPTO_LIB_SUCCESS ;
47
47
// uint16_t pdu_len = (uint16_t) sdls_frame.pdu.hdr.pdu_len[1] << 8 | sdls_frame.pdu.hdr.pdu_len[0];
48
- int pdu_keys = (sdls_frame .pdu .hdr .pdu_len - 30 ) / (2 + 32 );
48
+ int pdu_keys = (sdls_frame .pdu .hdr .pdu_len - SDLS_KEYID_LEN - SDLS_IV_LEN - MAC_SIZE ) / (SDLS_KEYID_LEN + SDLS_KEY_LEN );
49
49
int w ;
50
50
crypto_key_t * ekp = NULL ;
51
51
@@ -76,7 +76,7 @@ int32_t Crypto_Key_OTAR(void)
76
76
return status ;
77
77
}
78
78
79
- for (count = 2 ; count < (2 + 12 ); count ++ )
79
+ for (count = 2 ; count < (2 + SDLS_IV_LEN ); count ++ )
80
80
{ // Initialization Vector
81
81
packet .iv [count - 2 ] = sdls_frame .pdu .data [count ];
82
82
#ifdef DEBUG
@@ -85,7 +85,7 @@ int32_t Crypto_Key_OTAR(void)
85
85
}
86
86
87
87
count = sdls_frame .pdu .hdr .pdu_len - MAC_SIZE ;
88
- for (w = 0 ; w < 16 ; w ++ )
88
+ for (w = 0 ; w < MAC_SIZE ; w ++ )
89
89
{ // MAC
90
90
packet .mac [w ] = sdls_frame .pdu .data [count + w ];
91
91
#ifdef DEBUG
@@ -101,7 +101,7 @@ int32_t Crypto_Key_OTAR(void)
101
101
102
102
uint8_t ecs = CRYPTO_CIPHER_AES256_GCM ;
103
103
status = cryptography_if -> cryptography_aead_decrypt (& (sdls_frame .pdu .data [14 ]), // plaintext output
104
- (size_t )(pdu_keys * (2 + SDLS_KEY_LEN )), // length of data
104
+ (size_t )(pdu_keys * (SDLS_KEYID_LEN + SDLS_KEY_LEN )), // length of data
105
105
NULL , // in place decryption
106
106
0 , // in data length
107
107
& (ekp -> value [0 ]), // key
0 commit comments