AnsweredAssumed Answered

ECDH_P256_GenerateKeys() invalid privateKey

Question asked by Nick McKendree on Mar 27, 2018
Latest reply on Apr 5, 2018 by Nick McKendree

I am having an issue with the SecLib found in the 802.15.4 stack for the KW41Z. I am using the ECDH_P256_GenerateKeys function and my issue is that it is returning a populated public key but the private key is invalid. The raw 8bit values of the private key is all 0 expect the first byte which is 1. 

 

SecLib is initialized through SecLib_Init and RNG is initialized through RNG_Init before calling the function. 

The function returns gSecSuccess_c

I did modify the SecLib ECDH_P256_GenerateKeys function to use a static buffer for pMultiplicationBuffer because the buffer size was too large for the MemManager default settings. 

uint8_t pMultiplicationBuffer[ gEcP256_MultiplicationBufferSize_c ];

 

 

PublicKey.raw

raw[0] uint8_t 150 '\226'
raw[1] uint8_t 194 'Â'
raw[2] uint8_t 152 '\230'
raw[3] uint8_t 216 'Ø'
raw[4] uint8_t 69 'E'
raw[5] uint8_t 57 '9'
raw[6] uint8_t 161 '¡'
raw[7] uint8_t 244 'ô'
raw[8] uint8_t 160 ' '
raw[9] uint8_t 51 '3'
raw[10] uint8_t 235 'ë'
raw[11] uint8_t 45 '-'
raw[12] uint8_t 129 '\201'
raw[13] uint8_t 125 '}'
raw[14] uint8_t 3 '\003'
raw[15] uint8_t 119 'w'
raw[16] uint8_t 242 'ò'
raw[17] uint8_t 64 '@'
raw[18] uint8_t 164 '¤'
raw[19] uint8_t 99 'c'
raw[20] uint8_t 229 'å'
raw[21] uint8_t 230 'æ'
raw[22] uint8_t 188 '¼'
raw[23] uint8_t 248 'ø'
raw[24] uint8_t 71 'G'
raw[25] uint8_t 66 'B'
raw[26] uint8_t 44 ','
raw[27] uint8_t 225 'á'
raw[28] uint8_t 242 'ò'
raw[29] uint8_t 209 'Ñ'
raw[30] uint8_t 23 '\027'
raw[31] uint8_t 107 'k'
raw[32] uint8_t 245 'õ'
raw[33] uint8_t 81 'Q'
raw[34] uint8_t 191 '¿'
raw[35] uint8_t 55 '7'
raw[36] uint8_t 104 'h'
raw[37] uint8_t 64 '@'
raw[38] uint8_t 182 '¶'
raw[39] uint8_t 203 'Ë'
raw[40] uint8_t 206 'Î'
raw[41] uint8_t 94 '^'
raw[42] uint8_t 49 '1'
raw[43] uint8_t 107 'k'
raw[44] uint8_t 87 'W'
raw[45] uint8_t 51 '3'
raw[46] uint8_t 206 'Î'
raw[47] uint8_t 43 '+'
raw[48] uint8_t 22 '\026'
raw[49] uint8_t 158 '\236'
raw[50] uint8_t 15 '\017'
raw[51] uint8_t 124 '|'
raw[52] uint8_t 74 'J'
raw[53] uint8_t 235 'ë'
raw[54] uint8_t 231 'ç'
raw[55] uint8_t 142 '\216'
raw[56] uint8_t 155 '\233'
raw[57] uint8_t 127 '\177'
raw[58] uint8_t 26 '\032'
raw[59] uint8_t 254 'þ'
raw[60] uint8_t 226 'â'
raw[61] uint8_t 66 'B'
raw[62] uint8_t 227 'ã'
raw[63] uint8_t 79 'O'

 

privateKey

raw_8bit[0] uint8_t 1 '\001'
raw_8bit[1] uint8_t 0 '\0'
raw_8bit[2] uint8_t 0 '\0'
raw_8bit[3] uint8_t 0 '\0'
raw_8bit[4] uint8_t 0 '\0'
raw_8bit[5] uint8_t 0 '\0'
raw_8bit[6] uint8_t 0 '\0'
raw_8bit[7] uint8_t 0 '\0'
raw_8bit[8] uint8_t 0 '\0'
raw_8bit[9] uint8_t 0 '\0'
raw_8bit[10] uint8_t 0 '\0'
raw_8bit[11] uint8_t 0 '\0'
raw_8bit[12] uint8_t 0 '\0'
raw_8bit[13] uint8_t 0 '\0'
raw_8bit[14] uint8_t 0 '\0'
raw_8bit[15] uint8_t 0 '\0'
raw_8bit[16] uint8_t 0 '\0'
raw_8bit[17] uint8_t 0 '\0'
raw_8bit[18] uint8_t 0 '\0'
raw_8bit[19] uint8_t 0 '\0'
raw_8bit[20] uint8_t 0 '\0'
raw_8bit[21] uint8_t 0 '\0'
raw_8bit[22] uint8_t 0 '\0'
raw_8bit[23] uint8_t 0 '\0'
raw_8bit[24] uint8_t 0 '\0'
raw_8bit[25] uint8_t 0 '\0'
raw_8bit[26] uint8_t 0 '\0'
raw_8bit[27] uint8_t 0 '\0'
raw_8bit[28] uint8_t 0 '\0'
raw_8bit[29] uint8_t 0 '\0'
raw_8bit[30] uint8_t 0 '\0'
raw_8bit[31] uint8_t 0 '\0'

Outcomes