From 4db71d0175ed42586bcd4e6527caacbd18602adf Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Tue, 11 Aug 2020 15:28:07 +0100 Subject: [PATCH] Extend the provider MAC bridge for Poly1305 The previous commits added support for HMAC and SIPHASH into the provider MAC bridge. We now extend that for Poly1305 too. Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/12637) --- crypto/evp/pmeth_lib.c | 1 - providers/defltprov.c | 6 ++++++ providers/implementations/include/prov/implementations.h | 1 + providers/implementations/signature/mac_legacy.c | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/crypto/evp/pmeth_lib.c b/crypto/evp/pmeth_lib.c index db4b6f8fa1..dab1b15ab9 100644 --- a/crypto/evp/pmeth_lib.c +++ b/crypto/evp/pmeth_lib.c @@ -151,7 +151,6 @@ static int is_legacy_alg(int id, const char *keytype) */ case EVP_PKEY_SM2: case EVP_PKEY_CMAC: - case EVP_PKEY_POLY1305: return 1; default: return 0; diff --git a/providers/defltprov.c b/providers/defltprov.c index aaf1cfe6b0..34d2fb29f4 100644 --- a/providers/defltprov.c +++ b/providers/defltprov.c @@ -366,6 +366,9 @@ static const OSSL_ALGORITHM deflt_signature[] = { #endif { "HMAC", "provider=default", mac_hmac_signature_functions }, { "SIPHASH", "provider=default", mac_siphash_signature_functions }, +#ifndef OPENSSL_NO_POLY1305 + { "POLY1305", "provider=default", mac_poly1305_signature_functions }, +#endif { NULL, NULL, NULL } }; @@ -396,6 +399,9 @@ static const OSSL_ALGORITHM deflt_keymgmt[] = { { "SCRYPT:id-scrypt", "provider=default", kdf_keymgmt_functions }, { "HMAC", "provider=default", mac_keymgmt_functions }, { "SIPHASH", "provider=default", mac_keymgmt_functions }, +#ifndef OPENSSL_NO_POLY1305 + { "POLY1305", "provider=default", mac_keymgmt_functions }, +#endif { NULL, NULL, NULL } }; diff --git a/providers/implementations/include/prov/implementations.h b/providers/implementations/include/prov/implementations.h index 7c6412ceb5..fe5fbef57a 100644 --- a/providers/implementations/include/prov/implementations.h +++ b/providers/implementations/include/prov/implementations.h @@ -297,6 +297,7 @@ extern const OSSL_DISPATCH ed448_signature_functions[]; extern const OSSL_DISPATCH ecdsa_signature_functions[]; extern const OSSL_DISPATCH mac_hmac_signature_functions[]; extern const OSSL_DISPATCH mac_siphash_signature_functions[]; +extern const OSSL_DISPATCH mac_poly1305_signature_functions[]; /* Asym Cipher */ extern const OSSL_DISPATCH rsa_asym_cipher_functions[]; diff --git a/providers/implementations/signature/mac_legacy.c b/providers/implementations/signature/mac_legacy.c index bb3bf5b55d..cf440efc05 100644 --- a/providers/implementations/signature/mac_legacy.c +++ b/providers/implementations/signature/mac_legacy.c @@ -71,6 +71,7 @@ static void *mac_newctx(void *provctx, const char *propq, const char *macname) MAC_NEWCTX(hmac, "HMAC") MAC_NEWCTX(siphash, "SIPHASH") +MAC_NEWCTX(poly1305, "POLY1305") static int mac_digest_sign_init(void *vpmacctx, const char *mdname, void *vkey) { @@ -179,3 +180,4 @@ static void *mac_dupctx(void *vpmacctx) MAC_SIGNATURE_FUNCTIONS(hmac) MAC_SIGNATURE_FUNCTIONS(siphash) +MAC_SIGNATURE_FUNCTIONS(poly1305)