From ef188247c5ed92218d6b630eefa0a54929aec800 Mon Sep 17 00:00:00 2001 From: beck Date: Wed, 5 Jul 2023 16:17:19 +0000 Subject: [PATCH] Hide symbols in chacha ok jsing@ --- lib/libcrypto/Symbols.namespace | 6 ++++++ lib/libcrypto/chacha/chacha.c | 7 +++++- lib/libcrypto/hidden/openssl/chacha.h | 31 +++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 lib/libcrypto/hidden/openssl/chacha.h diff --git a/lib/libcrypto/Symbols.namespace b/lib/libcrypto/Symbols.namespace index 4320731af38..faee727cfd5 100644 --- a/lib/libcrypto/Symbols.namespace +++ b/lib/libcrypto/Symbols.namespace @@ -889,3 +889,9 @@ _libre_X509v3_addr_validate_path _libre_X509v3_asid_validate_resource_set _libre_X509v3_addr_validate_resource_set _libre_ERR_load_X509V3_strings +_libre_ChaCha_set_key +_libre_ChaCha_set_iv +_libre_ChaCha +_libre_CRYPTO_chacha_20 +_libre_CRYPTO_xchacha_20 +_libre_CRYPTO_hchacha_20 diff --git a/lib/libcrypto/chacha/chacha.c b/lib/libcrypto/chacha/chacha.c index 0ce4545186c..b60e3c4f275 100644 --- a/lib/libcrypto/chacha/chacha.c +++ b/lib/libcrypto/chacha/chacha.c @@ -1,4 +1,4 @@ -/* $OpenBSD: chacha.c,v 1.9 2022/08/20 18:44:58 jsing Exp $ */ +/* $OpenBSD: chacha.c,v 1.10 2023/07/05 16:17:20 beck Exp $ */ /* * Copyright (c) 2014 Joel Sing * @@ -27,6 +27,7 @@ ChaCha_set_key(ChaCha_ctx *ctx, const unsigned char *key, uint32_t keybits) chacha_keysetup((chacha_ctx *)ctx, key, keybits); ctx->unused = 0; } +LCRYPTO_ALIAS(ChaCha_set_key); void ChaCha_set_iv(ChaCha_ctx *ctx, const unsigned char *iv, @@ -35,6 +36,7 @@ ChaCha_set_iv(ChaCha_ctx *ctx, const unsigned char *iv, chacha_ivsetup((chacha_ctx *)ctx, iv, counter); ctx->unused = 0; } +LCRYPTO_ALIAS(ChaCha_set_iv); void ChaCha(ChaCha_ctx *ctx, unsigned char *out, const unsigned char *in, size_t len) @@ -64,6 +66,7 @@ ChaCha(ChaCha_ctx *ctx, unsigned char *out, const unsigned char *in, size_t len) len -= n; } } +LCRYPTO_ALIAS(ChaCha); void CRYPTO_chacha_20(unsigned char *out, const unsigned char *in, size_t len, @@ -95,6 +98,7 @@ CRYPTO_chacha_20(unsigned char *out, const unsigned char *in, size_t len, len -= n; } } +LCRYPTO_ALIAS(CRYPTO_chacha_20); void CRYPTO_xchacha_20(unsigned char *out, const unsigned char *in, size_t len, @@ -105,3 +109,4 @@ CRYPTO_xchacha_20(unsigned char *out, const unsigned char *in, size_t len, CRYPTO_hchacha_20(subkey, key, iv); CRYPTO_chacha_20(out, in, len, subkey, iv + 16, 0); } +LCRYPTO_ALIAS(CRYPTO_xchacha_20); diff --git a/lib/libcrypto/hidden/openssl/chacha.h b/lib/libcrypto/hidden/openssl/chacha.h new file mode 100644 index 00000000000..7b2f50baef2 --- /dev/null +++ b/lib/libcrypto/hidden/openssl/chacha.h @@ -0,0 +1,31 @@ +/* $OpenBSD: chacha.h,v 1.1 2023/07/05 16:17:20 beck Exp $ */ +/* + * Copyright (c) 2023 Bob Beck + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _LIBCRYPTO_CHACHA_H +#define _LIBCRYPTO_CHACHA_H + +#include_next +#include "crypto_namespace.h" + +LCRYPTO_USED(ChaCha_set_key); +LCRYPTO_USED(ChaCha_set_iv); +LCRYPTO_USED(ChaCha); +LCRYPTO_USED(CRYPTO_chacha_20); +LCRYPTO_USED(CRYPTO_xchacha_20); +LCRYPTO_USED(CRYPTO_hchacha_20); + +#endif /* _LIBCRYPTO_CHACHA_H */ -- 2.20.1