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 install and uninstall a key-pair in one of the crypto utilities key-pair management mechanism. The key must be an ECC key-pair using the SECP256R1 curve, and already programmed to the file system in a DER format file. The install and uninstall operations are done using the sl_NetUtilsCmd API. The key installation is persistent without consideration of system-persistent configuration, and is not erased over the power cycle. If the wanted index is already occupied by a key-pair, the install operation fails. Installation of the certificate without a key pair is used to verify buffers.
An example of installing a key and then uninstalling it:
SlNetUtilCryptoCmdKeyMgnt_t keyAttrib;
SlNetUtilCryptoPubKeyInfo_t *pInfoKey;
_i16 Status;
_u8 buf[256];
_u16 resultLen;
keyAttrib.ObjId = 5; /* key index is 5 */
keyAttrib.SubCmd = SL_NETUTIL_CRYPTO_INSTALL_SUB_CMD;
pInfoKey->KeyAlgo = SL_NETUTIL_CRYPTO_PUB_KEY_ALGO_EC;
pInfoKey->KeyParams.EcParams.CurveType = SL_NETUTIL_CRYPTO_EC_CURVE_TYPE_NAMED;
pInfoKey->KeyParams.EcParams.CurveParams.NamedCurveParams = SL_NETUTIL_CRYPTO_EC_NAMED_CURVE_SECP256R1;
pInfoKey = (SlNetUtilCryptoPubKeyInfo_t *)buf;
name = ((_u8 *)pInfoKey) + sizeof(SlNetUtilCryptoPubKeyInfo_t);
pInfoKey->KeyAlgo = SL_NETUTIL_CRYPTO_PUB_KEY_ALGO_EC;
pInfoKey->KeyParams.EcParams.CurveType = SL_NETUTIL_CRYPTO_EC_CURVE_TYPE_NAMED;
pInfoKey->KeyParams.EcParams.CurveParams.NamedCurveParams = SL_NETUTIL_CRYPTO_EC_NAMED_CURVE_SECP256R1;
pInfoKey->CertFileNameLen = 0; /* unused */
name += pInfoKey->CertFileNameLen;
strcpy((char *)name, "extkey.der"); /* private key in the file system */
pInfoKey->KeyFileNameLen = strlen("extkey.der")+1;
Status = sl_NetUtilCmd(SL_NETUTIL_CRYPTO_CMD_INSTALL_OP,
(_u8 *)&keyAttrib, sizeof(SlNetUtilCryptoCmdKeyMgnt_t),
(_u8 *)pInfo,
sizeof(SlNetUtilCryptoPubKeyInfo_t) + pInfoKey->KeyFileNameLen,
NULL, &resultLen);
if(Status < 0)
{
/* error */
}
resultLen = 0;
keyAttrib.ObjId = 5;
keyAttrib.SubCmd = SL_NETUTIL_CRYPTO_UNINSTALL_SUB_CMD;
/* Uninstall the key */
Status = sl_NetUtilCmd(SL_NETUTIL_CRYPTO_CMD_INSTALL_OP, (_u8 *)&keyAttrib,
sizeof(SlNetUtilCryptoCmdKeyMgnt_t), NULL, 0 , NULL, &resultLen);
if(Status < 0)
{
/* error */
}