- param_pub_key =
- OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PUB_KEY);
-
- if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0)
- param_priv_key =
- OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PRIV_KEY);
- /*
- * If a private key is present then a public key must also be present.
- * Alternatively we've just got a public key.
- */
- if (param_pub_key == NULL)
- return 0;
-
- if (param_priv_key != NULL
- && !OSSL_PARAM_get_octet_string(param_priv_key,
- (void **)&key->privkey, key->keylen,
- &privkeylen))
- return 0;
-
- pubkey = key->pubkey;
- if (!OSSL_PARAM_get_octet_string(param_pub_key,
- (void **)&pubkey,
- sizeof(key->pubkey), &pubkeylen))
- return 0;
-
- if (pubkeylen != key->keylen
- || (param_priv_key != NULL && privkeylen != key->keylen))
- return 0;
-
- key->haspubkey = 1;
+ include_private = ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0);
+ if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0)
+ ok = ok && ecx_key_fromdata(key, params, include_private);