Other Parts Discussed in Thread: UNIFLASH
Hi,
I would like to generate an ES256 signature on the CC3235SF. I have read this post here:
I would like to utilize the 0'th pre-programmed constant private ECC key to do so. I have verified that my SHA256 is valid. Is there somethign I am missing:
uint16_t ecc_signature_length = 0;
SlNetUtilCryptoCmdSignAttrib_t signAttrib;
uint8_t sha256_hash[32];
uint8_t ecc_buffer[512];
/* init crypto for SHA256 hashing of b64url(header).b64url(payload) */
memset(&hmac_params, 0, sizeof(CryptoCC32XX_HmacParams));
if (cryptoCC32XX_handle == NULL)
{
CryptoCC32XX_init();
cryptoCC32XX_handle = CryptoCC32XX_open(0, CryptoCC32XX_HMAC);
}
/* clear hash memory */
memset(&sha256_hash[0], 0, sizeof(sha256_hash));
CryptoCC32XX_HmacParams_init(&hmac_params);
hmac_params.moreData = 0;
/* generate the hash */
CryptoCC32XX_sign(cryptoCC32XX_handle,
CryptoCC32XX_HMAC_SHA256,
&encoded_header_and_encoded_payload[0],
strlen(&encoded_header_and_encoded_payload[0]),
&sha256_hash[0],
&hmac_params);
/* calculate ecc signature of hash */
signAttrib.Flags = 0;
signAttrib.ObjId = 0;
signAttrib.SigType = SL_NETUTIL_CRYPTO_SIG_SHA256wECDSA;
ecc_signature_length = 255;
memset(&ecc_buffer[0], 0, sizeof(ecc_buffer));
sl_NetUtilCmd(SL_NETUTIL_CRYPTO_CMD_SIGN_MSG,
(uint8_t *)&signAttrib,
sizeof(SlNetUtilCryptoCmdSignAttrib_t),
&sha256_hash[0],
sizeof(sha256_hash),
&ecc_buffer[0],
&ecc_signature_length);