diff --git a/apps/dhparam.c b/apps/dhparam.c index e2fb38d8c07f26a46360272dc3b0951302144144..58cdfd000d9a85a930e0a321004b625a8775c27e 100644 --- a/apps/dhparam.c +++ b/apps/dhparam.c @@ -325,7 +325,7 @@ int dhparam_main(int argc, char **argv) OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS, outformat == FORMAT_ASN1 ? "DER" : "PEM", - NULL, NULL, NULL); + NULL, NULL); if (ectx == NULL || !OSSL_ENCODER_to_bio(ectx, out)) { OSSL_ENCODER_CTX_free(ectx); diff --git a/apps/rsa.c b/apps/rsa.c index da1342b4c0b134ba05f873b12b386830db52d61b..058c2be2adc77f94ceba482fde8b1fd80797032d 100644 --- a/apps/rsa.c +++ b/apps/rsa.c @@ -323,7 +323,7 @@ int rsa_main(int argc, char **argv) /* Now, perform the encoding */ ectx = OSSL_ENCODER_CTX_new_by_EVP_PKEY(pkey, selection, output_type, output_structure, - NULL, NULL); + NULL); if (OSSL_ENCODER_CTX_get_num_encoders(ectx) == 0) { BIO_printf(bio_err, "%s format not supported\n", output_type); goto end; diff --git a/crypto/asn1/i2d_evp.c b/crypto/asn1/i2d_evp.c index d0468bf5c25297a695391fb562e8eab5e74579a8..da1d13618434e1c9b5075a13be32fd35210d89c1 100644 --- a/crypto/asn1/i2d_evp.c +++ b/crypto/asn1/i2d_evp.c @@ -42,8 +42,7 @@ static int i2d_provided(const EVP_PKEY *a, int selection, size_t len = INT_MAX; ctx = OSSL_ENCODER_CTX_new_by_EVP_PKEY(a, selection, "DER", - *output_structures, - NULL, NULL); + *output_structures, NULL); if (ctx == NULL) return -1; if (OSSL_ENCODER_to_data(ctx, pp, &len)) diff --git a/crypto/evp/evp_pkey.c b/crypto/evp/evp_pkey.c index b049420d0bafea1d64e7a26adda41454d89d9484..dd20a52e7abc681eb4b44149254199b3f67c464c 100644 --- a/crypto/evp/evp_pkey.c +++ b/crypto/evp/evp_pkey.c @@ -81,15 +81,13 @@ PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(const EVP_PKEY *pkey) */ if (evp_pkey_is_provided(pkey)) { int selection = OSSL_KEYMGMT_SELECT_ALL; - const OSSL_PROVIDER *prov = EVP_KEYMGMT_provider(pkey->keymgmt); - OSSL_LIB_CTX *libctx = ossl_provider_libctx(prov); unsigned char *der = NULL; size_t derlen = 0; const unsigned char *pp; if ((ctx = OSSL_ENCODER_CTX_new_by_EVP_PKEY(pkey, selection, "DER", "pkcs8", - libctx, NULL)) == NULL + NULL)) == NULL || !OSSL_ENCODER_to_data(ctx, &der, &derlen)) goto error; diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c index cf29071318600f311c495c7addacfecc4dcd896f..b8c623f90aa33fdf2d1614d5448239a141974e8c 100644 --- a/crypto/evp/p_lib.c +++ b/crypto/evp/p_lib.c @@ -1140,7 +1140,6 @@ static int unsup_alg(BIO *out, const EVP_PKEY *pkey, int indent, static int print_pkey(const EVP_PKEY *pkey, BIO *out, int indent, int selection /* For provided encoding */, - OSSL_LIB_CTX *libctx /* For provided encoding */, const char *propquery /* For provided encoding */, int (*legacy_print)(BIO *out, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx), @@ -1155,7 +1154,7 @@ static int print_pkey(const EVP_PKEY *pkey, BIO *out, int indent, return 0; ctx = OSSL_ENCODER_CTX_new_by_EVP_PKEY(pkey, selection, "TEXT", NULL, - libctx, propquery); + propquery); if (OSSL_ENCODER_CTX_get_num_encoders(ctx) != 0) ret = OSSL_ENCODER_to_bio(ctx, out); OSSL_ENCODER_CTX_free(ctx); @@ -1177,7 +1176,7 @@ static int print_pkey(const EVP_PKEY *pkey, BIO *out, int indent, int EVP_PKEY_print_public(BIO *out, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx) { - return print_pkey(pkey, out, indent, EVP_PKEY_PUBLIC_KEY, NULL, NULL, + return print_pkey(pkey, out, indent, EVP_PKEY_PUBLIC_KEY, NULL, (pkey->ameth != NULL ? pkey->ameth->pub_print : NULL), pctx); } @@ -1185,7 +1184,7 @@ int EVP_PKEY_print_public(BIO *out, const EVP_PKEY *pkey, int EVP_PKEY_print_private(BIO *out, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx) { - return print_pkey(pkey, out, indent, EVP_PKEY_KEYPAIR, NULL, NULL, + return print_pkey(pkey, out, indent, EVP_PKEY_KEYPAIR, NULL, (pkey->ameth != NULL ? pkey->ameth->priv_print : NULL), pctx); } @@ -1193,7 +1192,7 @@ int EVP_PKEY_print_private(BIO *out, const EVP_PKEY *pkey, int EVP_PKEY_print_params(BIO *out, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx) { - return print_pkey(pkey, out, indent, EVP_PKEY_KEY_PARAMETERS, NULL, NULL, + return print_pkey(pkey, out, indent, EVP_PKEY_KEY_PARAMETERS, NULL, (pkey->ameth != NULL ? pkey->ameth->param_print : NULL), pctx); } diff --git a/crypto/pem/pem_local.h b/crypto/pem/pem_local.h index 7de2a71045bf16c5536169d9665581a321f7a460..728fefb33af956786883275f796dade0e343cf0e 100644 --- a/crypto/pem/pem_local.h +++ b/crypto/pem/pem_local.h @@ -49,7 +49,7 @@ OSSL_ENCODER_CTX *ctx = \ OSSL_ENCODER_CTX_new_by_##type(x, PEM_SELECTION_##asn1, \ "PEM", PEM_STRUCTURE_##asn1, \ - NULL, NULL); \ + NULL); \ \ if (OSSL_ENCODER_CTX_get_num_encoders(ctx) == 0) { \ OSSL_ENCODER_CTX_free(ctx); \ diff --git a/crypto/pem/pem_pk8.c b/crypto/pem/pem_pk8.c index 560754007b2078356a8b775db6abfcc0d86db46e..09d38855b6c70bc5821b533abeeba6313ab60a15 100644 --- a/crypto/pem/pem_pk8.c +++ b/crypto/pem/pem_pk8.c @@ -22,14 +22,14 @@ static int do_pk8pkey(BIO *bp, const EVP_PKEY *x, int isder, int nid, const EVP_CIPHER *enc, const char *kstr, int klen, pem_password_cb *cb, void *u, - OSSL_LIB_CTX *libctx, const char *propq); + const char *propq); #ifndef OPENSSL_NO_STDIO static int do_pk8pkey_fp(FILE *bp, const EVP_PKEY *x, int isder, int nid, const EVP_CIPHER *enc, const char *kstr, int klen, pem_password_cb *cb, void *u, - OSSL_LIB_CTX *libctx, const char *propq); + const char *propq); #endif /* * These functions write a private key in PKCS#8 format: it is a "drop in" @@ -42,40 +42,39 @@ int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, const EVP_PKEY *x, int nid, const char *kstr, int klen, pem_password_cb *cb, void *u) { - return do_pk8pkey(bp, x, 0, nid, NULL, kstr, klen, cb, u, NULL, NULL); + return do_pk8pkey(bp, x, 0, nid, NULL, kstr, klen, cb, u, NULL); } int PEM_write_bio_PKCS8PrivateKey(BIO *bp, const EVP_PKEY *x, const EVP_CIPHER *enc, const char *kstr, int klen, pem_password_cb *cb, void *u) { - return do_pk8pkey(bp, x, 0, -1, enc, kstr, klen, cb, u, NULL, NULL); + return do_pk8pkey(bp, x, 0, -1, enc, kstr, klen, cb, u, NULL); } int i2d_PKCS8PrivateKey_bio(BIO *bp, const EVP_PKEY *x, const EVP_CIPHER *enc, const char *kstr, int klen, pem_password_cb *cb, void *u) { - return do_pk8pkey(bp, x, 1, -1, enc, kstr, klen, cb, u, NULL, NULL); + return do_pk8pkey(bp, x, 1, -1, enc, kstr, klen, cb, u, NULL); } int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, const EVP_PKEY *x, int nid, const char *kstr, int klen, pem_password_cb *cb, void *u) { - return do_pk8pkey(bp, x, 1, nid, NULL, kstr, klen, cb, u, NULL, NULL); + return do_pk8pkey(bp, x, 1, nid, NULL, kstr, klen, cb, u, NULL); } static int do_pk8pkey(BIO *bp, const EVP_PKEY *x, int isder, int nid, const EVP_CIPHER *enc, const char *kstr, int klen, - pem_password_cb *cb, void *u, - OSSL_LIB_CTX *libctx, const char *propq) + pem_password_cb *cb, void *u, const char *propq) { int ret = 0; const char *outtype = isder ? "DER" : "PEM"; OSSL_ENCODER_CTX *ctx = OSSL_ENCODER_CTX_new_by_EVP_PKEY(x, OSSL_KEYMGMT_SELECT_ALL, - outtype, "pkcs8", libctx, propq); + outtype, "pkcs8", propq); if (ctx == NULL) return 0; @@ -203,34 +202,33 @@ int i2d_PKCS8PrivateKey_fp(FILE *fp, const EVP_PKEY *x, const EVP_CIPHER *enc, const char *kstr, int klen, pem_password_cb *cb, void *u) { - return do_pk8pkey_fp(fp, x, 1, -1, enc, kstr, klen, cb, u, NULL, NULL); + return do_pk8pkey_fp(fp, x, 1, -1, enc, kstr, klen, cb, u, NULL); } int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, const EVP_PKEY *x, int nid, const char *kstr, int klen, pem_password_cb *cb, void *u) { - return do_pk8pkey_fp(fp, x, 1, nid, NULL, kstr, klen, cb, u, NULL, NULL); + return do_pk8pkey_fp(fp, x, 1, nid, NULL, kstr, klen, cb, u, NULL); } int PEM_write_PKCS8PrivateKey_nid(FILE *fp, const EVP_PKEY *x, int nid, const char *kstr, int klen, pem_password_cb *cb, void *u) { - return do_pk8pkey_fp(fp, x, 0, nid, NULL, kstr, klen, cb, u, NULL, NULL); + return do_pk8pkey_fp(fp, x, 0, nid, NULL, kstr, klen, cb, u, NULL); } int PEM_write_PKCS8PrivateKey(FILE *fp, const EVP_PKEY *x, const EVP_CIPHER *enc, const char *kstr, int klen, pem_password_cb *cb, void *u) { - return do_pk8pkey_fp(fp, x, 0, -1, enc, kstr, klen, cb, u, NULL, NULL); + return do_pk8pkey_fp(fp, x, 0, -1, enc, kstr, klen, cb, u, NULL); } static int do_pk8pkey_fp(FILE *fp, const EVP_PKEY *x, int isder, int nid, const EVP_CIPHER *enc, const char *kstr, int klen, - pem_password_cb *cb, void *u, - OSSL_LIB_CTX *libctx, const char *propq) + pem_password_cb *cb, void *u, const char *propq) { BIO *bp; int ret; @@ -239,7 +237,7 @@ static int do_pk8pkey_fp(FILE *fp, const EVP_PKEY *x, int isder, int nid, ERR_raise(ERR_LIB_PEM, ERR_R_BUF_LIB); return 0; } - ret = do_pk8pkey(bp, x, isder, nid, enc, kstr, klen, cb, u, libctx, propq); + ret = do_pk8pkey(bp, x, isder, nid, enc, kstr, klen, cb, u, propq); BIO_free(bp); return ret; } diff --git a/crypto/x509/x_pubkey.c b/crypto/x509/x_pubkey.c index 674b7d48cf0be2aecbb1325a96d4d2c63a743a00..9f5b5d3c3db571855f2aa2433b8eba3cef9cc4ee 100644 --- a/crypto/x509/x_pubkey.c +++ b/crypto/x509/x_pubkey.c @@ -98,14 +98,12 @@ int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey) goto error; } } else if (evp_pkey_is_provided(pkey)) { - const OSSL_PROVIDER *pkprov = EVP_KEYMGMT_provider(pkey->keymgmt); - OSSL_LIB_CTX *libctx = ossl_provider_libctx(pkprov); unsigned char *der = NULL; size_t derlen = 0; OSSL_ENCODER_CTX *ectx = OSSL_ENCODER_CTX_new_by_EVP_PKEY(pkey, EVP_PKEY_PUBLIC_KEY, "DER", "SubjectPublicKeyInfo", - libctx, NULL); + NULL); if (OSSL_ENCODER_to_data(ectx, &der, &derlen)) { const unsigned char *pder = der; @@ -306,12 +304,10 @@ int i2d_PUBKEY(const EVP_PKEY *a, unsigned char **pp) } X509_PUBKEY_free(xpk); } else if (a->keymgmt != NULL) { - const OSSL_PROVIDER *pkprov = EVP_KEYMGMT_provider(a->keymgmt); - OSSL_LIB_CTX *libctx = ossl_provider_libctx(pkprov); OSSL_ENCODER_CTX *ctx = OSSL_ENCODER_CTX_new_by_EVP_PKEY(a, EVP_PKEY_PUBLIC_KEY, "DER", "SubjectPublicKeyInfo", - libctx, NULL); + NULL); BIO *out = BIO_new(BIO_s_mem()); BUF_MEM *buf = NULL; diff --git a/test/endecode_test.c b/test/endecode_test.c index d7edd350a189437631df5abf5762a63208a4ee0e..f72f9aaac8433927a3c971e5ed6564b37ce1a650 100644 --- a/test/endecode_test.c +++ b/test/endecode_test.c @@ -195,7 +195,7 @@ static int encode_EVP_PKEY_prov(void **encoded, long *encoded_len, if (!TEST_ptr(ectx = OSSL_ENCODER_CTX_new_by_EVP_PKEY(pkey, selection, output_type, output_structure, - NULL, NULL)) + NULL)) || !TEST_int_gt(OSSL_ENCODER_CTX_get_num_encoders(ectx), 0) || (pass != NULL && !TEST_true(OSSL_ENCODER_CTX_set_passphrase(ectx, upass, diff --git a/test/endecoder_legacy_test.c b/test/endecoder_legacy_test.c index 467c072b3e82d24f41f5db38c73dd74f0d473a94..ffaa25da7bc6e6cee746e510ee74935213874383 100644 --- a/test/endecoder_legacy_test.c +++ b/test/endecoder_legacy_test.c @@ -319,7 +319,7 @@ static int test_protected_PEM(const char *keytype, int evp_type, if (!TEST_ptr(ectx = OSSL_ENCODER_CTX_new_by_EVP_PKEY(provided_pkey, selection, "PEM", structure, - NULL, NULL)) + NULL)) || !TEST_true(OSSL_ENCODER_to_bio(ectx, membio_provided)) || !TEST_true(pem_write_bio(membio_legacy, legacy_key, NULL, NULL, 0, NULL, NULL)) @@ -387,7 +387,7 @@ static int test_unprotected_PEM(const char *keytype, int evp_type, if (!TEST_ptr(ectx = OSSL_ENCODER_CTX_new_by_EVP_PKEY(provided_pkey, selection, "PEM", structure, - NULL, NULL)) + NULL)) || !TEST_true(OSSL_ENCODER_to_bio(ectx, membio_provided)) || !TEST_true(pem_write_bio(membio_legacy, legacy_key)) || !test_membio_str_eq(membio_provided, membio_legacy)) @@ -452,7 +452,7 @@ static int test_DER(const char *keytype, int evp_type, if (!TEST_ptr(ectx = OSSL_ENCODER_CTX_new_by_EVP_PKEY(provided_pkey, selection, "DER", structure, - NULL, NULL)) + NULL)) || !TEST_true(OSSL_ENCODER_to_data(ectx, &der_provided, &der_provided_len)) || !TEST_size_t_gt(der_legacy_len = i2d(legacy_key, &der_legacy), 0) diff --git a/test/evp_libctx_test.c b/test/evp_libctx_test.c index a1540dd4b98d9aaf5ccc9ef60814110bb4694e6b..cf39bf0871ef686c2f7ae8d7924f9addb4c4f93f 100644 --- a/test/evp_libctx_test.c +++ b/test/evp_libctx_test.c @@ -461,7 +461,7 @@ static int rsa_keygen(int bits, EVP_PKEY **pub, EVP_PKEY **priv) OSSL_ENCODER_CTX_new_by_EVP_PKEY(*priv, EVP_PKEY_PUBLIC_KEY, "DER", "type-specific", - libctx, NULL)) + NULL)) || !TEST_true(OSSL_ENCODER_to_data(ectx, &pub_der, &len))) goto err; pp = pub_der; diff --git a/test/evp_pkey_provided_test.c b/test/evp_pkey_provided_test.c index 7d12a919c1cceb8ee5af2e0b2d1e7eda2ba26bbc..a5604b4fdff2d5eaff8055f130851cf8c5e74815 100644 --- a/test/evp_pkey_provided_test.c +++ b/test/evp_pkey_provided_test.c @@ -217,7 +217,7 @@ static int test_print_key_type_using_encoder(const char *alg, int type, if (!TEST_ptr(ctx = OSSL_ENCODER_CTX_new_by_EVP_PKEY(pk, selection, output_type, output_structure, - NULL, NULL)) + NULL)) /* Check that this operation is supported */ || !TEST_int_ne(OSSL_ENCODER_CTX_get_num_encoders(ctx), 0)) goto err;