/* Setup EVP_PKEY using public, private or generation */
static int ecx_key_op(EVP_PKEY *pkey, int id, const X509_ALGOR *palg,
- const unsigned char *p, int plen, ecx_key_op_t op)
+ const unsigned char *p, int plen, ecx_key_op_t op,
+ OPENSSL_CTX *libctx, const char *propq)
{
ECX_KEY *key = NULL;
unsigned char *privkey, *pubkey;
X448_public_from_private(pubkey, privkey);
break;
case EVP_PKEY_ED448:
- /*
- * TODO(3.0): We set the library context to NULL for now. This will
- * need to change.
- */
- ED448_public_from_private(NULL, pubkey, privkey);
+ ED448_public_from_private(libctx, pubkey, privkey);
break;
}
}
if (!X509_PUBKEY_get0_param(NULL, &p, &pklen, &palg, pubkey))
return 0;
return ecx_key_op(pkey, pkey->ameth->pkey_id, palg, p, pklen,
- KEY_OP_PUBLIC);
+ KEY_OP_PUBLIC, NULL, NULL);
}
static int ecx_pub_cmp(const EVP_PKEY *a, const EVP_PKEY *b)
return CRYPTO_memcmp(akey->pubkey, bkey->pubkey, KEYLEN(a)) == 0;
}
-static int ecx_priv_decode(EVP_PKEY *pkey, const PKCS8_PRIV_KEY_INFO *p8)
+static int ecx_priv_decode_with_libctx(EVP_PKEY *pkey,
+ const PKCS8_PRIV_KEY_INFO *p8,
+ OPENSSL_CTX *libctx, const char *propq)
{
const unsigned char *p;
int plen;
plen = ASN1_STRING_length(oct);
}
- rv = ecx_key_op(pkey, pkey->ameth->pkey_id, palg, p, plen, KEY_OP_PRIVATE);
+ rv = ecx_key_op(pkey, pkey->ameth->pkey_id, palg, p, plen, KEY_OP_PRIVATE,
+ libctx, propq);
ASN1_STRING_clear_free(oct);
return rv;
}
case ASN1_PKEY_CTRL_SET1_TLS_ENCPT:
return ecx_key_op(pkey, pkey->ameth->pkey_id, NULL, arg2, arg1,
- KEY_OP_PUBLIC);
+ KEY_OP_PUBLIC, NULL, NULL);
case ASN1_PKEY_CTRL_GET1_TLS_ENCPT:
if (pkey->pkey.ecx != NULL) {
static int ecx_set_priv_key(EVP_PKEY *pkey, const unsigned char *priv,
size_t len)
{
+ /* TODO(3.0): We should pass a libctx here */
return ecx_key_op(pkey, pkey->ameth->pkey_id, NULL, priv, len,
- KEY_OP_PRIVATE);
+ KEY_OP_PRIVATE, NULL, NULL);
}
static int ecx_set_pub_key(EVP_PKEY *pkey, const unsigned char *pub, size_t len)
{
return ecx_key_op(pkey, pkey->ameth->pkey_id, NULL, pub, len,
- KEY_OP_PUBLIC);
+ KEY_OP_PUBLIC, NULL, NULL);
}
static int ecx_get_priv_key(const EVP_PKEY *pkey, unsigned char *priv,
ecx_pub_cmp,
ecx_pub_print,
- ecx_priv_decode,
+ NULL,
ecx_priv_encode,
ecx_priv_print,
ecx_get_pub_key,
ecx_pkey_dirty_cnt,
ecx_pkey_export_to,
- x25519_import_from
+ x25519_import_from,
+
+ ecx_priv_decode_with_libctx
};
static int x448_import_from(const OSSL_PARAM params[], void *key)
ecx_pub_cmp,
ecx_pub_print,
- ecx_priv_decode,
+ NULL,
ecx_priv_encode,
ecx_priv_print,
ecx_get_pub_key,
ecx_pkey_dirty_cnt,
ecx_pkey_export_to,
- x448_import_from
+ x448_import_from,
+
+ ecx_priv_decode_with_libctx
};
static int ecd_size25519(const EVP_PKEY *pkey)
ecx_pub_cmp,
ecx_pub_print,
- ecx_priv_decode,
+ NULL,
ecx_priv_encode,
ecx_priv_print,
ecx_get_pub_key,
ecx_pkey_dirty_cnt,
ecx_pkey_export_to,
- ed25519_import_from
+ ed25519_import_from,
+
+ ecx_priv_decode_with_libctx
};
static int ed448_import_from(const OSSL_PARAM params[], void *key)
ecx_pub_cmp,
ecx_pub_print,
- ecx_priv_decode,
+ NULL,
ecx_priv_encode,
ecx_priv_print,
ecx_get_pub_key,
ecx_pkey_dirty_cnt,
ecx_pkey_export_to,
- ed448_import_from
+ ed448_import_from,
+
+ ecx_priv_decode_with_libctx
};
static int pkey_ecx_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
{
- return ecx_key_op(pkey, ctx->pmeth->pkey_id, NULL, NULL, 0, KEY_OP_KEYGEN);
+ return ecx_key_op(pkey, ctx->pmeth->pkey_id, NULL, NULL, 0, KEY_OP_KEYGEN,
+ NULL, NULL);
}
static int validate_ecx_derive(EVP_PKEY_CTX *ctx, unsigned char *key,