Latest update.
This commit is contained in:
@@ -232,6 +232,10 @@ static int pkey_sm2_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
|
||||
static int pkey_sm2_ctrl_str(EVP_PKEY_CTX *ctx,
|
||||
const char *type, const char *value)
|
||||
{
|
||||
uint8_t *hex_id;
|
||||
long hex_len = 0;
|
||||
int ret = 0;
|
||||
|
||||
if (strcmp(type, "ec_paramgen_curve") == 0) {
|
||||
int nid = NID_undef;
|
||||
|
||||
@@ -255,6 +259,21 @@ static int pkey_sm2_ctrl_str(EVP_PKEY_CTX *ctx,
|
||||
} else if (strcmp(type, "sm2_id") == 0) {
|
||||
return pkey_sm2_ctrl(ctx, EVP_PKEY_CTRL_SET1_ID,
|
||||
(int)strlen(value), (void *)value);
|
||||
} else if (strcmp(type, "sm2_hex_id") == 0) {
|
||||
/*
|
||||
* TODO(3.0): reconsider the name "sm2_hex_id", OR change
|
||||
* OSSL_PARAM_construct_from_text() / OSSL_PARAM_allocate_from_text()
|
||||
* to handle infix "_hex_"
|
||||
*/
|
||||
hex_id = OPENSSL_hexstr2buf((const char *)value, &hex_len);
|
||||
if (hex_id == NULL) {
|
||||
SM2err(SM2_F_PKEY_SM2_CTRL_STR, ERR_R_PASSED_INVALID_ARGUMENT);
|
||||
return 0;
|
||||
}
|
||||
ret = pkey_sm2_ctrl(ctx, EVP_PKEY_CTRL_SET1_ID, (int)hex_len,
|
||||
(void *)hex_id);
|
||||
OPENSSL_free(hex_id);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return -2;
|
||||
|
||||
Reference in New Issue
Block a user