diff --git a/crypto/evp/build.info b/crypto/evp/build.info index 95fea31226b09..870e1e40ec45e 100644 --- a/crypto/evp/build.info +++ b/crypto/evp/build.info @@ -14,7 +14,7 @@ SOURCE[../../libcrypto]=$COMMON\ c_allc.c c_alld.c bio_ok.c \ evp_pkey.c evp_pbe.c p5_crpt.c p5_crpt2.c pbe_scrypt.c \ e_aes_cbc_hmac_sha1.c e_aes_cbc_hmac_sha256.c e_rc4_hmac_md5.c \ - e_chacha20_poly1305.c \ + e_chacha20_poly1305.c e_null_hmac.c \ legacy_sha.c ctrl_params_translate.c \ cmeth_lib.c diff --git a/crypto/evp/c_allc.c b/crypto/evp/c_allc.c index c74b3dcd753a6..c212cc74dfb8a 100644 --- a/crypto/evp/c_allc.c +++ b/crypto/evp/c_allc.c @@ -265,4 +265,8 @@ void openssl_add_all_ciphers_int(void) EVP_add_cipher(EVP_chacha20_poly1305()); # endif #endif + +#ifndef OPENSSL_NO_INTEGRITY_ONLY_CIPHER + EVP_add_cipher(EVP_enc_null_hmac_sha256()); +#endif } diff --git a/crypto/evp/e_null_hmac.c b/crypto/evp/e_null_hmac.c new file mode 100644 index 0000000000000..9f97191ec9f0f --- /dev/null +++ b/crypto/evp/e_null_hmac.c @@ -0,0 +1,42 @@ +/* + * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include + +#ifndef OPENSSL_NO_INTEGRITY_ONLY_CIPHER + +# include +# include +# include "crypto/evp.h" +# include "evp_local.h" + +static EVP_CIPHER n_cipher = { + NID_enull_hmac_sha256, + 0, 0, 0, 0, + EVP_ORIG_GLOBAL, + NULL, + NULL, + NULL, + 0, + NULL, + NULL, + NULL, + NULL +}; + +/* + * dummy cipher just to populate the NID value. + * TODO: look for better way of doing it. + */ +const EVP_CIPHER *EVP_enc_null_hmac_sha256(void) +{ + return (&n_cipher); +} + +#endif diff --git a/include/openssl/evp.h b/include/openssl/evp.h index 4a0f21ad99387..10b83ca178089 100644 --- a/include/openssl/evp.h +++ b/include/openssl/evp.h @@ -1138,6 +1138,9 @@ const EVP_CIPHER *EVP_chacha20(void); const EVP_CIPHER *EVP_chacha20_poly1305(void); # endif # endif +# ifndef OPENSSL_NO_INTEGRITY_ONLY_CIPHER +const EVP_CIPHER *EVP_enc_null_hmac_sha256(void); +# endif # ifndef OPENSSL_NO_SEED const EVP_CIPHER *EVP_seed_ecb(void);