SWRU455M February 2017 – October 2020 CC3120 , CC3120MOD , CC3130 , CC3135 , CC3135MOD , CC3220MOD , CC3220MODA , CC3220R , CC3220S , CC3220SF , CC3230S , CC3230SF , CC3235MODAS , CC3235MODASF , CC3235MODS , CC3235MODSF , CC3235S , CC3235SF
This command is used to verify a digital signature using the ECDSA algorithm. The signature must be created with one of the key-pairs from the crypto-utilities key management mechanism. Verification of a buffer can be done by ECDSAwithSHA or ECDSAwithSHA256, where the buffer to digest is given by the API. If a predigested message is used, verification occurs when the digest is passed in the verify command, instead of the buffer.
The input buffer for signing must not exceed 1.5KB. If a larger buffer must be verified, predigest the buffer and pass it as the verify buffer with SL_NETUTIL_CRYPTO_SIG_DIGESTwECDSA sigType.
An example of sign and verify buffer:
_u16 configLen = 0;
_u8 buf[256];
_u8 verifyBuf[2048];
SlNetUtilCryptoCmdSignAttrib_t signAttrib;
SlNetUtilCryptoCmdVerifyAttrib_t verAttrib;
_i32 verifyResult;
_u16 resultLen;
_u8 messageBuf[1500];
_i16 Status;
signAttrib.Flags = 0;
signAttrib.ObjId = 3;
signAttrib.SigType = SL_NETUTIL_CRYPTO_SIG_SHAwECDSA; /* this is the only type supported */
configLen = 255;
Status = sl_NetUtilCmd(SL_NETUTIL_CRYPTO_CMD_SIGN_MSG, (_u8 *)&signAttrib,
sizeof(SlNetUtilCryptoCmdSignAttrib_t),
messageBuf, sizeof(messageBuf), buf, &configLen);
if(0 > Status)
{
/* error */
}
/* now verify the buffer */
memcpy(verifyBuf, messageBuf, sizeof(messageBuf));
memcpy(verifyBuf + sizeof(messageBuf), buf, configLen);
verAttrib.Flags = 0;
verAttrib.ObjId = 3;
verAttrib.SigType = SL_NETUTIL_CRYPTO_SIG_SHAwECDSA; /* this is the only type supported */
verAttrib.MsgLen = sizeof(messageBuf);
verAttrib.SigLen = configLen;
/* use the created keys to verify the signature from the previous step */
resultLen = 4;
Status = sl_NetUtilCmd(SL_NETUTIL_CRYPTO_CMD_VERIFY_MSG, (_u8 *)&verAttrib,
sizeof(SlNetUtilCryptoCmdVerifyAttrib_t),
verifyBuf, sizeof(messageBuf) + configLen,
(_u8 *)&verifyResult , &resultLen);
if(0 > Status)
{
/* error */
}