nuttx/crypto: export ecdsa sign and verify in SECP256R1 curve

Signed-off-by: makejian <makejian@xiaomi.com>
This commit is contained in:
makejian 2024-07-24 20:54:24 +08:00 committed by Xiang Xiao
parent cccdaf8f88
commit 882c09abb3
2 changed files with 64 additions and 19 deletions

View File

@ -569,27 +569,66 @@ int cryptodev_key(FAR struct crypt_kop *kop)
{
case CRK_MOD_EXP:
if (in == 3 && out == 1)
break;
{
break;
}
return -EINVAL;
case CRK_MOD_EXP_CRT:
if (in == 6 && out == 1)
break;
{
break;
}
return -EINVAL;
case CRK_DSA_SIGN:
if (in == 5 && out == 2)
break;
{
break;
}
return -EINVAL;
case CRK_DSA_VERIFY:
if (in == 7 && out == 0)
break;
{
break;
}
return -EINVAL;
case CRK_DH_COMPUTE_KEY:
if (in == 3 && out == 1)
break;
{
break;
}
return -EINVAL;
case CRK_RSA_PKCS15_VERIFY:
if (in == 5 && out == 0)
break;
{
break;
}
return -EINVAL;
case CRK_ECDSA_SECP256R1_SIGN:
if (in == 2 && out == 2)
{
break;
}
return -EINVAL;
case CRK_ECDSA_SECP256R1_VERIFY:
if (in == 6 && out == 0)
{
break;
}
return -EINVAL;
case CRK_ECDSA_SECP256R1_GENKEY:
if (in == 0 && out == 4)
{
break;
}
return -EINVAL;
default:
return -EINVAL;

View File

@ -249,20 +249,26 @@ struct crypt_kop
struct crparam crk_param[CRK_MAXPARAM];
};
#define CRK_MOD_EXP 0
#define CRK_MOD_EXP_CRT 1
#define CRK_DSA_SIGN 2
#define CRK_DSA_VERIFY 3
#define CRK_DH_COMPUTE_KEY 4
#define CRK_RSA_PKCS15_VERIFY 5
#define CRK_ALGORITHM_MAX 5 /* Keep updated */
#define CRK_MOD_EXP 0
#define CRK_MOD_EXP_CRT 1
#define CRK_DSA_SIGN 2
#define CRK_DSA_VERIFY 3
#define CRK_DH_COMPUTE_KEY 4
#define CRK_RSA_PKCS15_VERIFY 5
#define CRK_ECDSA_SECP256R1_SIGN 6
#define CRK_ECDSA_SECP256R1_VERIFY 7
#define CRK_ECDSA_SECP256R1_GENKEY 8
#define CRK_ALGORITHM_MAX 8 /* Keep updated */
#define CRF_MOD_EXP (1 << CRK_MOD_EXP)
#define CRF_MOD_EXP_CRT (1 << CRK_MOD_EXP_CRT)
#define CRF_DSA_SIGN (1 << CRK_DSA_SIGN)
#define CRF_DSA_VERIFY (1 << CRK_DSA_VERIFY)
#define CRF_DH_COMPUTE_KEY (1 << CRK_DH_COMPUTE_KEY)
#define CRF_RSA_PKCS15_VERIFY (1 << CRK_RSA_PKCS15_VERIFY)
#define CRF_MOD_EXP (1 << CRK_MOD_EXP)
#define CRF_MOD_EXP_CRT (1 << CRK_MOD_EXP_CRT)
#define CRF_DSA_SIGN (1 << CRK_DSA_SIGN)
#define CRF_DSA_VERIFY (1 << CRK_DSA_VERIFY)
#define CRF_DH_COMPUTE_KEY (1 << CRK_DH_COMPUTE_KEY)
#define CRF_RSA_PKCS15_VERIFY (1 << CRK_RSA_PKCS15_VERIFY)
#define CRF_ECDSA_SECP256R1_SIGN (1 << CRK_ECDSA_SECP256R1_SIGN)
#define CRF_ECDSA_SECP256R1_VERIFY (1 << CRK_ECDSA_SECP256R1_VERIFY)
#define CRF_ECDSA_SECP256R1_GENKEY (1 << CRK_ECDSA_SECP256R1_GENKEY)
struct cryptkop
{