diff options
author | Pauli <paul.dale@oracle.com> | 2020-08-05 13:23:32 +1000 |
---|---|---|
committer | Pauli <paul.dale@oracle.com> | 2020-08-07 08:02:14 +1000 |
commit | af5e1e852d4858860d4b7210cafe7bdf39e73f80 (patch) | |
tree | e2b5ea35d43150dcf9f1ff5e771e41daef4d891b | |
parent | 18ec26babc1da90befc0bf5671bc8072428c5bab (diff) |
gettables: provider changes to pass the provider context.
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/12581)
54 files changed, 122 insertions, 99 deletions
diff --git a/providers/implementations/asymciphers/rsa_enc.c b/providers/implementations/asymciphers/rsa_enc.c index 8a5cd5cdc3..2528cd2dc4 100644 --- a/providers/implementations/asymciphers/rsa_enc.c +++ b/providers/implementations/asymciphers/rsa_enc.c @@ -382,7 +382,7 @@ static const OSSL_PARAM known_gettable_ctx_params[] = { OSSL_PARAM_END }; -static const OSSL_PARAM *rsa_gettable_ctx_params(void) +static const OSSL_PARAM *rsa_gettable_ctx_params(void *provctx) { return known_gettable_ctx_params; } @@ -526,7 +526,7 @@ static const OSSL_PARAM known_settable_ctx_params[] = { OSSL_PARAM_END }; -static const OSSL_PARAM *rsa_settable_ctx_params(void) +static const OSSL_PARAM *rsa_settable_ctx_params(void *provctx) { return known_settable_ctx_params; } diff --git a/providers/implementations/ciphers/cipher_aes_cbc_hmac_sha.c b/providers/implementations/ciphers/cipher_aes_cbc_hmac_sha.c index 046a66c56d..6cf6a1b111 100644 --- a/providers/implementations/ciphers/cipher_aes_cbc_hmac_sha.c +++ b/providers/implementations/ciphers/cipher_aes_cbc_hmac_sha.c @@ -59,7 +59,7 @@ static const OSSL_PARAM cipher_aes_known_settable_ctx_params[] = { OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_KEYLEN, NULL), OSSL_PARAM_END }; -const OSSL_PARAM *aes_settable_ctx_params(void) +const OSSL_PARAM *aes_settable_ctx_params(void *provctx) { return cipher_aes_known_settable_ctx_params; } @@ -250,7 +250,7 @@ static const OSSL_PARAM cipher_aes_known_gettable_ctx_params[] = { OSSL_PARAM_octet_string(OSSL_CIPHER_PARAM_IV, NULL, 0), OSSL_PARAM_END }; -const OSSL_PARAM *aes_gettable_ctx_params(void) +const OSSL_PARAM *aes_gettable_ctx_params(void *provctx) { return cipher_aes_known_gettable_ctx_params; } diff --git a/providers/implementations/ciphers/cipher_aes_ocb.c b/providers/implementations/ciphers/cipher_aes_ocb.c index 230b353c50..162945f922 100644 --- a/providers/implementations/ciphers/cipher_aes_ocb.c +++ b/providers/implementations/ciphers/cipher_aes_ocb.c @@ -39,6 +39,8 @@ static OSSL_FUNC_cipher_freectx_fn aes_ocb_freectx; static OSSL_FUNC_cipher_dupctx_fn aes_ocb_dupctx; static OSSL_FUNC_cipher_get_ctx_params_fn aes_ocb_get_ctx_params; static OSSL_FUNC_cipher_set_ctx_params_fn aes_ocb_set_ctx_params; +static OSSL_FUNC_cipher_gettable_ctx_params_fn cipher_ocb_gettable_ctx_params; +static OSSL_FUNC_cipher_settable_ctx_params_fn cipher_ocb_settable_ctx_params; /* * The following methods could be moved into PROV_AES_OCB_HW if @@ -437,7 +439,7 @@ static const OSSL_PARAM cipher_ocb_known_gettable_ctx_params[] = { OSSL_PARAM_octet_string(OSSL_CIPHER_PARAM_AEAD_TAG, NULL, 0), OSSL_PARAM_END }; -static const OSSL_PARAM *cipher_ocb_gettable_ctx_params(void) +static const OSSL_PARAM *cipher_ocb_gettable_ctx_params(void *provctx) { return cipher_ocb_known_gettable_ctx_params; } @@ -448,7 +450,7 @@ static const OSSL_PARAM cipher_ocb_known_settable_ctx_params[] = { OSSL_PARAM_octet_string(OSSL_CIPHER_PARAM_AEAD_TAG, NULL, 0), OSSL_PARAM_END }; -static const OSSL_PARAM *cipher_ocb_settable_ctx_params(void) +static const OSSL_PARAM *cipher_ocb_settable_ctx_params(void *provctx) { return cipher_ocb_known_settable_ctx_params; } @@ -513,4 +515,3 @@ const OSSL_DISPATCH aes##kbits##mode##_functions[] = { \ IMPLEMENT_cipher(ocb, OCB, AES_OCB_FLAGS, 256, 128, OCB_DEFAULT_IV_LEN * 8); IMPLEMENT_cipher(ocb, OCB, AES_OCB_FLAGS, 192, 128, OCB_DEFAULT_IV_LEN * 8); IMPLEMENT_cipher(ocb, OCB, AES_OCB_FLAGS, 128, 128, OCB_DEFAULT_IV_LEN * 8); - diff --git a/providers/implementations/ciphers/cipher_aes_siv.c b/providers/implementations/ciphers/cipher_aes_siv.c index 84c078da82..2432c6a280 100644 --- a/providers/implementations/ciphers/cipher_aes_siv.c +++ b/providers/implementations/ciphers/cipher_aes_siv.c @@ -166,7 +166,7 @@ static const OSSL_PARAM aes_siv_known_gettable_ctx_params[] = { OSSL_PARAM_octet_string(OSSL_CIPHER_PARAM_AEAD_TAG, NULL, 0), OSSL_PARAM_END }; -static const OSSL_PARAM *aes_siv_gettable_ctx_params(void) +static const OSSL_PARAM *aes_siv_gettable_ctx_params(void *provctx) { return aes_siv_known_gettable_ctx_params; } @@ -216,19 +216,33 @@ static const OSSL_PARAM aes_siv_known_settable_ctx_params[] = { OSSL_PARAM_octet_string(OSSL_CIPHER_PARAM_AEAD_TAG, NULL, 0), OSSL_PARAM_END }; -static const OSSL_PARAM *aes_siv_settable_ctx_params(void) +static const OSSL_PARAM *aes_siv_settable_ctx_params(void *provctx) { return aes_siv_known_settable_ctx_params; } #define IMPLEMENT_cipher(alg, lc, UCMODE, flags, kbits, blkbits, ivbits) \ +static OSSL_FUNC_cipher_newctx_fn alg##kbits##lc##_newctx; \ +static OSSL_FUNC_cipher_freectx_fn alg##_##lc##_freectx; \ +static OSSL_FUNC_cipher_dupctx_fn lc##_dupctx; \ +static OSSL_FUNC_cipher_encrypt_init_fn lc##_einit; \ +static OSSL_FUNC_cipher_decrypt_init_fn lc##_dinit; \ +static OSSL_FUNC_cipher_update_fn lc##_stream_update; \ +static OSSL_FUNC_cipher_final_fn lc##_stream_final; \ +static OSSL_FUNC_cipher_cipher_fn lc##_cipher; \ static OSSL_FUNC_cipher_get_params_fn alg##_##kbits##_##lc##_get_params; \ +static OSSL_FUNC_cipher_gettable_params_fn alg##_##lc##_gettable_ctx_params; \ +static OSSL_FUNC_cipher_get_ctx_params_fn alg##_##lc##_get_ctx_params; \ +static OSSL_FUNC_cipher_gettable_ctx_params_fn \ + alg##_##lc##_gettable_ctx_params; \ +static OSSL_FUNC_cipher_set_ctx_params_fn alg##_##lc##_set_ctx_params; \ +static OSSL_FUNC_cipher_settable_ctx_params_fn \ + alg##_##lc##_settable_ctx_params; \ static int alg##_##kbits##_##lc##_get_params(OSSL_PARAM params[]) \ { \ return cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE, \ flags, 2*kbits, blkbits, ivbits); \ } \ -static OSSL_FUNC_cipher_newctx_fn alg##kbits##lc##_newctx; \ static void * alg##kbits##lc##_newctx(void *provctx) \ { \ return alg##_##lc##_newctx(provctx, 2*kbits, EVP_CIPH_##UCMODE##_MODE, \ diff --git a/providers/implementations/ciphers/cipher_aes_xts.c b/providers/implementations/ciphers/cipher_aes_xts.c index f564075abe..5430b6da1b 100644 --- a/providers/implementations/ciphers/cipher_aes_xts.c +++ b/providers/implementations/ciphers/cipher_aes_xts.c @@ -211,7 +211,7 @@ static const OSSL_PARAM aes_xts_known_settable_ctx_params[] = { OSSL_PARAM_END }; -static const OSSL_PARAM *aes_xts_settable_ctx_params(void) +static const OSSL_PARAM *aes_xts_settable_ctx_params(void *provctx) { return aes_xts_known_settable_ctx_params; } diff --git a/providers/implementations/ciphers/cipher_chacha20.c b/providers/implementations/ciphers/cipher_chacha20.c index 6759b0e0f9..5d5e62870d 100644 --- a/providers/implementations/ciphers/cipher_chacha20.c +++ b/providers/implementations/ciphers/cipher_chacha20.c @@ -91,7 +91,7 @@ static const OSSL_PARAM chacha20_known_gettable_ctx_params[] = { OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_IVLEN, NULL), OSSL_PARAM_END }; -const OSSL_PARAM *chacha20_gettable_ctx_params(void) +const OSSL_PARAM *chacha20_gettable_ctx_params(void *provctx) { return chacha20_known_gettable_ctx_params; } @@ -131,7 +131,7 @@ static const OSSL_PARAM chacha20_known_settable_ctx_params[] = { OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_IVLEN, NULL), OSSL_PARAM_END }; -const OSSL_PARAM *chacha20_settable_ctx_params(void) +const OSSL_PARAM *chacha20_settable_ctx_params(void *provctx) { return chacha20_known_settable_ctx_params; } diff --git a/providers/implementations/ciphers/cipher_chacha20_poly1305.c b/providers/implementations/ciphers/cipher_chacha20_poly1305.c index a93f722551..0174337c81 100644 --- a/providers/implementations/ciphers/cipher_chacha20_poly1305.c +++ b/providers/implementations/ciphers/cipher_chacha20_poly1305.c @@ -135,7 +135,7 @@ static const OSSL_PARAM chacha20_poly1305_known_gettable_ctx_params[] = { OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_AEAD_TLS1_AAD_PAD, NULL), OSSL_PARAM_END }; -static const OSSL_PARAM *chacha20_poly1305_gettable_ctx_params(void) +static const OSSL_PARAM *chacha20_poly1305_gettable_ctx_params(void *provctx) { return chacha20_poly1305_known_gettable_ctx_params; } diff --git a/providers/implementations/ciphers/cipher_null.c b/providers/implementations/ciphers/cipher_null.c index 713d29e3e8..c524a83f4a 100644 --- a/providers/implementations/ciphers/cipher_null.c +++ b/providers/implementations/ciphers/cipher_null.c @@ -95,7 +95,7 @@ static const OSSL_PARAM null_known_gettable_ctx_params[] = { }; static OSSL_FUNC_cipher_gettable_ctx_params_fn null_gettable_ctx_params; -static const OSSL_PARAM *null_gettable_ctx_params(void) +static const OSSL_PARAM *null_gettable_ctx_params(void *provctx) { return null_known_gettable_ctx_params; } @@ -131,7 +131,7 @@ static const OSSL_PARAM null_known_settable_ctx_params[] = { }; static OSSL_FUNC_cipher_settable_ctx_params_fn null_settable_ctx_params; -static const OSSL_PARAM *null_settable_ctx_params(void) +static const OSSL_PARAM *null_settable_ctx_params(void *provctx) { return null_known_settable_ctx_params; } diff --git a/providers/implementations/ciphers/cipher_rc4_hmac_md5.c b/providers/implementations/ciphers/cipher_rc4_hmac_md5.c index d9535e23ce..e17584a0ab 100644 --- a/providers/implementations/ciphers/cipher_rc4_hmac_md5.c +++ b/providers/implementations/ciphers/cipher_rc4_hmac_md5.c @@ -72,7 +72,7 @@ static const OSSL_PARAM rc4_hmac_md5_known_gettable_ctx_params[] = { OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_AEAD_TLS1_AAD_PAD, NULL), OSSL_PARAM_END }; -const OSSL_PARAM *rc4_hmac_md5_gettable_ctx_params(void) +const OSSL_PARAM *rc4_hmac_md5_gettable_ctx_params(void *provctx) { return rc4_hmac_md5_known_gettable_ctx_params; } @@ -107,7 +107,7 @@ static const OSSL_PARAM rc4_hmac_md5_known_settable_ctx_params[] = { OSSL_PARAM_octet_string(OSSL_CIPHER_PARAM_AEAD_TLS1_AAD, NULL, 0), OSSL_PARAM_END }; -const OSSL_PARAM *rc4_hmac_md5_settable_ctx_params(void) +const OSSL_PARAM *rc4_hmac_md5_settable_ctx_params(void *provctx) { return rc4_hmac_md5_known_settable_ctx_params; } diff --git a/providers/implementations/ciphers/ciphercommon.c b/providers/implementations/ciphers/ciphercommon.c index 2d119a7b39..dd25f00db4 100644 --- a/providers/implementations/ciphers/ciphercommon.c +++ b/providers/implementations/ciphers/ciphercommon.c @@ -29,7 +29,7 @@ static const OSSL_PARAM cipher_known_gettable_params[] = { { OSSL_CIPHER_PARAM_TLS_MAC, OSSL_PARAM_OCTET_PTR, NULL, 0, OSSL_PARAM_UNMODIFIED }, OSSL_PARAM_END }; -const OSSL_PARAM *cipher_generic_gettable_params(void) +const OSSL_PARAM *cipher_generic_gettable_params(void *provctx) { return cipher_known_gettable_params; } @@ -117,7 +117,7 @@ static const OSSL_PARAM cipher_aead_known_gettable_ctx_params[] = { OSSL_PARAM_octet_string(OSSL_CIPHER_PARAM_AEAD_TLS1_GET_IV_GEN, NULL, 0), OSSL_PARAM_END }; -const OSSL_PARAM *cipher_aead_gettable_ctx_params(void) +const OSSL_PARAM *cipher_aead_gettable_ctx_params(void *provctx) { return cipher_aead_known_gettable_ctx_params; } @@ -130,7 +130,7 @@ static const OSSL_PARAM cipher_aead_known_settable_ctx_params[] = { OSSL_PARAM_octet_string(OSSL_CIPHER_PARAM_AEAD_TLS1_SET_IV_INV, NULL, 0), OSSL_PARAM_END }; -const OSSL_PARAM *cipher_aead_settable_ctx_params(void) +const OSSL_PARAM *cipher_aead_settable_ctx_params(void *provctx) { return cipher_aead_known_settable_ctx_params; } diff --git a/providers/implementations/digests/digestcommon.c b/providers/implementations/digests/digestcommon.c index 9d30b2be2c..d4910e121d 100644 --- a/providers/implementations/digests/digestcommon.c +++ b/providers/implementations/digests/digestcommon.c @@ -40,7 +40,7 @@ static const OSSL_PARAM digest_default_known_gettable_params[] = { OSSL_PARAM_ulong(OSSL_DIGEST_PARAM_FLAGS, NULL), OSSL_PARAM_END }; -const OSSL_PARAM *digest_default_gettable_params(void) +const OSSL_PARAM *digest_default_gettable_params(void *provctx) { return digest_default_known_gettable_params; } diff --git a/providers/implementations/digests/md5_sha1_prov.c b/providers/implementations/digests/md5_sha1_prov.c index c5dc4a36ce..632fb4a8d0 100644 --- a/providers/implementations/digests/md5_sha1_prov.c +++ b/providers/implementations/digests/md5_sha1_prov.c @@ -30,7 +30,7 @@ static const OSSL_PARAM known_md5_sha1_settable_ctx_params[] = { OSSL_PARAM_END }; -static const OSSL_PARAM *md5_sha1_settable_ctx_params(void) +static const OSSL_PARAM *md5_sha1_settable_ctx_params(void *provctx) { return known_md5_sha1_settable_ctx_params; } diff --git a/providers/implementations/digests/mdc2_prov.c b/providers/implementations/digests/mdc2_prov.c index 51958f7cf7..b1d3b5c0ff 100644 --- a/providers/implementations/digests/mdc2_prov.c +++ b/providers/implementations/digests/mdc2_prov.c @@ -30,7 +30,7 @@ static const OSSL_PARAM known_mdc2_settable_ctx_params[] = { OSSL_PARAM_END }; -static const OSSL_PARAM *mdc2_settable_ctx_params(void) +static const OSSL_PARAM *mdc2_settable_ctx_params(void *provctx) { return known_mdc2_settable_ctx_params; } diff --git a/providers/implementations/digests/sha2_prov.c b/providers/implementations/digests/sha2_prov.c index 5a73940b87..94ec269728 100644 --- a/providers/implementations/digests/sha2_prov.c +++ b/providers/implementations/digests/sha2_prov.c @@ -31,7 +31,7 @@ static const OSSL_PARAM known_sha1_settable_ctx_params[] = { {OSSL_DIGEST_PARAM_SSL3_MS, OSSL_PARAM_OCTET_STRING, NULL, 0, 0}, OSSL_PARAM_END }; -static const OSSL_PARAM *sha1_settable_ctx_params(void) +static const OSSL_PARAM *sha1_settable_ctx_params(void *provctx) { return known_sha1_settable_ctx_params; } diff --git a/providers/implementations/digests/sha3_prov.c b/providers/implementations/digests/sha3_prov.c index d7c7e8e44b..0703dbe9e0 100644 --- a/providers/implementations/digests/sha3_prov.c +++ b/providers/implementations/digests/sha3_prov.c @@ -250,7 +250,7 @@ static const OSSL_PARAM known_shake_settable_ctx_params[] = { {OSSL_DIGEST_PARAM_XOFLEN, OSSL_PARAM_UNSIGNED_INTEGER, NULL, 0, 0}, OSSL_PARAM_END }; -static const OSSL_PARAM *shake_settable_ctx_params(void) +static const OSSL_PARAM *shake_settable_ctx_params(void *provctx) { return known_shake_settable_ctx_params; } diff --git a/providers/implementations/exchange/dh_exch.c b/providers/implementations/exchange/dh_exch.c index 765ab2e89a..c0cb378c12 100644 --- a/providers/implementations/exchange/dh_exch.c +++ b/providers/implementations/exchange/dh_exch.c @@ -163,7 +163,7 @@ static const OSSL_PARAM known_settable_ctx_params[] = { OSSL_PARAM_END }; -static const OSSL_PARAM *dh_settable_ctx_params(void) +static const OSSL_PARAM *dh_settable_ctx_params(void *provctx) { return known_settable_ctx_params; } diff --git a/providers/implementations/exchange/ecdh_exch.c b/providers/implementations/exchange/ecdh_exch.c index ba28d5102e..d2d7f7ed07 100644 --- a/providers/implementations/exchange/ecdh_exch.c +++ b/providers/implementations/exchange/ecdh_exch.c @@ -279,7 +279,7 @@ static const OSSL_PARAM known_settable_ctx_params[] = { }; static -const OSSL_PARAM *ecdh_settable_ctx_params(void) +const OSSL_PARAM *ecdh_settable_ctx_params(void *provctx) { return known_settable_ctx_params; } @@ -360,7 +360,7 @@ static const OSSL_PARAM known_gettable_ctx_params[] = { }; static -const OSSL_PARAM *ecdh_gettable_ctx_params(void) +const OSSL_PARAM *ecdh_gettable_ctx_params(void *provctx) { return known_gettable_ctx_params; } diff --git a/providers/implementations/include/prov/ciphercommon.h b/providers/implementations/include/prov/ciphercommon.h index 7e8143fae0..43cec3cc2b 100644 --- a/providers/implementations/include/prov/ciphercommon.h +++ b/providers/implementations/include/prov/ciphercommon.h @@ -319,7 +319,7 @@ static const OSSL_PARAM name##_known_gettable_ctx_params[] = { \ #define CIPHER_DEFAULT_GETTABLE_CTX_PARAMS_END(name) \ OSSL_PARAM_END \ }; \ -const OSSL_PARAM * name##_gettable_ctx_params(void) \ +const OSSL_PARAM * name##_gettable_ctx_params(void *provctx) \ { \ return name##_known_gettable_ctx_params; \ } @@ -331,7 +331,7 @@ static const OSSL_PARAM name##_known_settable_ctx_params[] = { \ #define CIPHER_DEFAULT_SETTABLE_CTX_PARAMS_END(name) \ OSSL_PARAM_END \ }; \ -const OSSL_PARAM * name##_settable_ctx_params(void) \ +const OSSL_PARAM * name##_settable_ctx_params(void *provctx) \ { \ return name##_known_settable_ctx_params; \ } diff --git a/providers/implementations/include/prov/digestcommon.h b/providers/implementations/include/prov/digestcommon.h index e6461d9d10..7d3d5f1e23 100644 --- a/providers/implementations/include/prov/digestcommon.h +++ b/providers/implementations/include/prov/digestcommon.h @@ -93,7 +93,7 @@ PROV_DISPATCH_FUNC_DIGEST_CONSTRUCT_START(name, CTX, blksize, dgstsize, flags, \ PROV_DISPATCH_FUNC_DIGEST_CONSTRUCT_END -const OSSL_PARAM *digest_default_gettable_params(void); +const OSSL_PARAM *digest_default_gettable_params(void *provctx); int digest_default_get_params(OSSL_PARAM params[], size_t blksz, size_t paramsz, unsigned long flags); diff --git a/providers/implementations/kdfs/hkdf.c b/providers/implementations/kdfs/hkdf.c index 0b1a6e9b7e..fa1e1bcad0 100644 --- a/providers/implementations/kdfs/hkdf.c +++ b/providers/implementations/kdfs/hkdf.c @@ -225,7 +225,7 @@ static int kdf_hkdf_set_ctx_params(void *vctx, const OSSL_PARAM params[]) return 1; } -static const OSSL_PARAM *kdf_hkdf_settable_ctx_params(void) +static const OSSL_PARAM *kdf_hkd |