Skip to content

Commit

Permalink
e_null_hmac.c, build.info, c_allc.c, evp.h: add dummy cipher EVP_enc_…
Browse files Browse the repository at this point in the history
…null_hmac_sha256, for populating NID.
  • Loading branch information
rajeev-0 committed Nov 30, 2023
1 parent b64635a commit 3d9287d
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crypto/evp/build.info
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions crypto/evp/c_allc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
42 changes: 42 additions & 0 deletions crypto/evp/e_null_hmac.c
Original file line number Diff line number Diff line change
@@ -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 <stdio.h>

#ifndef OPENSSL_NO_INTEGRITY_ONLY_CIPHER

# include <openssl/evp.h>
# include <openssl/objects.h>
# 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
3 changes: 3 additions & 0 deletions include/openssl/evp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 3d9287d

Please sign in to comment.