From 4d1810fa8b3c3b334f3dffda53e0ffaf875a3f29 Mon Sep 17 00:00:00 2001 From: beck Date: Sat, 8 Jul 2023 15:12:49 +0000 Subject: [PATCH] Hide symbols in curve22519 ok tb@ --- lib/libcrypto/Symbols.namespace | 5 ++++ lib/libcrypto/curve25519/curve25519.c | 7 ++++- lib/libcrypto/hidden/openssl/curve25519.h | 34 +++++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 lib/libcrypto/hidden/openssl/curve25519.h diff --git a/lib/libcrypto/Symbols.namespace b/lib/libcrypto/Symbols.namespace index a3aeb7fc757..4770e8f9d29 100644 --- a/lib/libcrypto/Symbols.namespace +++ b/lib/libcrypto/Symbols.namespace @@ -2701,3 +2701,8 @@ _libre_CRYPTO_ccm128_encrypt_ccm64 _libre_CRYPTO_ccm128_decrypt_ccm64 _libre_CRYPTO_ccm128_tag _libre_CRYPTO_xts128_encrypt +_libre_X25519_keypair +_libre_X25519 +_libre_ED25519_keypair +_libre_ED25519_sign +_libre_ED25519_verify diff --git a/lib/libcrypto/curve25519/curve25519.c b/lib/libcrypto/curve25519/curve25519.c index 4f85a81f47a..4e644c4280c 100644 --- a/lib/libcrypto/curve25519/curve25519.c +++ b/lib/libcrypto/curve25519/curve25519.c @@ -1,4 +1,4 @@ -/* $OpenBSD: curve25519.c,v 1.15 2023/04/02 15:36:53 tb Exp $ */ +/* $OpenBSD: curve25519.c,v 1.16 2023/07/08 15:12:49 beck Exp $ */ /* * Copyright (c) 2015, Google Inc. * @@ -4636,6 +4636,7 @@ void ED25519_keypair(uint8_t out_public_key[ED25519_PUBLIC_KEY_LENGTH], ED25519_public_from_private(out_public_key, out_private_key); } +LCRYPTO_ALIAS(ED25519_keypair); int ED25519_sign(uint8_t *out_sig, const uint8_t *message, size_t message_len, const uint8_t public_key[ED25519_PUBLIC_KEY_LENGTH], @@ -4671,6 +4672,7 @@ int ED25519_sign(uint8_t *out_sig, const uint8_t *message, size_t message_len, return 1; } +LCRYPTO_ALIAS(ED25519_sign); /* * Little endian representation of the order of edwards25519, @@ -4735,6 +4737,7 @@ int ED25519_verify(const uint8_t *message, size_t message_len, return timingsafe_memcmp(rcheck, rcopy, sizeof(rcheck)) == 0; } +LCRYPTO_ALIAS(ED25519_verify); /* Replace (f,g) with (g,f) if b == 1; * replace (f,g) with (f,g) if b == 0. @@ -4926,6 +4929,7 @@ X25519_keypair(uint8_t out_public_key[X25519_KEY_LENGTH], X25519_public_from_private(out_public_key, out_private_key); } +LCRYPTO_ALIAS(X25519_keypair); int X25519(uint8_t out_shared_key[X25519_KEY_LENGTH], @@ -4939,3 +4943,4 @@ X25519(uint8_t out_shared_key[X25519_KEY_LENGTH], /* The all-zero output results when the input is a point of small order. */ return timingsafe_memcmp(kZeros, out_shared_key, 32) != 0; } +LCRYPTO_ALIAS(X25519); diff --git a/lib/libcrypto/hidden/openssl/curve25519.h b/lib/libcrypto/hidden/openssl/curve25519.h new file mode 100644 index 00000000000..3afa324e0a2 --- /dev/null +++ b/lib/libcrypto/hidden/openssl/curve25519.h @@ -0,0 +1,34 @@ +/* $OpenBSD: curve25519.h,v 1.1 2023/07/08 15:12:49 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_CURVE25519_H +#define _LIBCRYPTO_CURVE25519_H + +#ifndef _MSC_VER +#include_next +#else +#include "../include/openssl/curve25519.h" +#endif +#include "crypto_namespace.h" + +LCRYPTO_USED(X25519_keypair); +LCRYPTO_USED(X25519); +LCRYPTO_USED(ED25519_keypair); +LCRYPTO_USED(ED25519_sign); +LCRYPTO_USED(ED25519_verify); + +#endif /* _LIBCRYPTO_CURVE25519_H */ -- 2.20.1