diff --git a/src/keymgmt.c b/src/keymgmt.c index f92e2574..3b1b8518 100644 --- a/src/keymgmt.c +++ b/src/keymgmt.c @@ -1590,6 +1590,27 @@ static int p11prov_ec_get_params(void *keydata, OSSL_PARAM params[]) p->data_size = pub_y->ulValueLen; } } + p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_ENCODED_PUBLIC_KEY); + if (p) { + CK_ATTRIBUTE *pub_key; + + if (p->data_type != OSSL_PARAM_OCTET_STRING) { + return RET_OSSL_ERR; + } + + pub_key = p11prov_obj_get_ec_public_raw(key); + if (!pub_key) { + return RET_OSSL_ERR; + } + + p->return_size = pub_key->ulValueLen; + if (p->data) { + if (p->data_size < pub_key->ulValueLen) { + return RET_OSSL_ERR; + } + memcpy(p->data, pub_key->pValue, pub_key->ulValueLen); + } + } return RET_OSSL_OK; } @@ -1604,8 +1625,8 @@ static const OSSL_PARAM *p11prov_ec_gettable_params(void *provctx) OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_DEFAULT_DIGEST, NULL, 0), OSSL_PARAM_BN(OSSL_PKEY_PARAM_EC_PUB_X, NULL, 0), OSSL_PARAM_BN(OSSL_PKEY_PARAM_EC_PUB_Y, NULL, 0), + OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_ENCODED_PUBLIC_KEY, NULL, 0), /* - * OSSL_PKEY_PARAM_ENCODED_PUBLIC_KEY * OSSL_PKEY_PARAM_EC_DECODED_FROM_EXPLICIT_PARAM * OSSL_PKEY_PARAM_EC_ENCODING * OSSL_PKEY_PARAM_EC_POINT_CONVERSION_FORMAT diff --git a/src/objects.c b/src/objects.c index f5ae10f5..d0f97f04 100644 --- a/src/objects.c +++ b/src/objects.c @@ -2180,17 +2180,17 @@ CK_ATTRIBUTE *p11prov_obj_get_ec_public_raw(P11PROV_OBJ *key) CK_ATTRIBUTE *pub_key; if (!key) { - return RET_OSSL_ERR; + return NULL; } if (key->data.key.type != CKK_EC) { P11PROV_raise(key->ctx, CKR_GENERAL_ERROR, "Unsupported key type"); - return RET_OSSL_ERR; + return NULL; } if (key->class != CKO_PRIVATE_KEY && key->class != CKO_PUBLIC_KEY) { P11PROV_raise(key->ctx, CKR_GENERAL_ERROR, "Invalid Object Class"); - return RET_OSSL_ERR; + return NULL; } pub_key = p11prov_obj_get_attr(key, CKA_P11PROV_PUB_KEY);