From 93f18f112bc5f8d65df307f157c771eedc3c6038 Mon Sep 17 00:00:00 2001 From: beck Date: Fri, 7 Jul 2023 12:01:32 +0000 Subject: [PATCH] hide symbols in sm, rand, and poly1305 ok jsing@ --- lib/libcrypto/Symbols.namespace | 24 ++++++++++++++ lib/libcrypto/hidden/openssl/poly1305.h | 32 ++++++++++++++++++ lib/libcrypto/hidden/openssl/rand.h | 44 +++++++++++++++++++++++++ lib/libcrypto/hidden/openssl/sm3.h | 32 ++++++++++++++++++ lib/libcrypto/hidden/openssl/sm4.h | 32 ++++++++++++++++++ lib/libcrypto/poly1305/poly1305.c | 5 ++- lib/libcrypto/rand/rand_err.c | 3 +- lib/libcrypto/rand/rand_lib.c | 13 +++++++- lib/libcrypto/rand/randfile.c | 5 ++- lib/libcrypto/sm3/sm3.c | 3 +- lib/libcrypto/sm4/sm4.c | 5 ++- 11 files changed, 192 insertions(+), 6 deletions(-) create mode 100644 lib/libcrypto/hidden/openssl/poly1305.h create mode 100644 lib/libcrypto/hidden/openssl/rand.h create mode 100644 lib/libcrypto/hidden/openssl/sm3.h create mode 100644 lib/libcrypto/hidden/openssl/sm4.h diff --git a/lib/libcrypto/Symbols.namespace b/lib/libcrypto/Symbols.namespace index cbf06b4d236..74fe98cd7ae 100644 --- a/lib/libcrypto/Symbols.namespace +++ b/lib/libcrypto/Symbols.namespace @@ -1263,6 +1263,30 @@ _libre_BIO_vprintf _libre_BIO_snprintf _libre_BIO_vsnprintf _libre_ERR_load_BIO_strings +_libre_SM4_set_key +_libre_SM4_decrypt +_libre_SM4_encrypt +_libre_SM3_Init +_libre_SM3_Update +_libre_SM3_Final +_libre_RAND_set_rand_method +_libre_RAND_get_rand_method +_libre_RAND_set_rand_engine +_libre_RAND_SSLeay +_libre_RAND_cleanup +_libre_RAND_bytes +_libre_RAND_pseudo_bytes +_libre_RAND_seed +_libre_RAND_add +_libre_RAND_load_file +_libre_RAND_write_file +_libre_RAND_file_name +_libre_RAND_status +_libre_RAND_poll +_libre_ERR_load_RAND_strings +_libre_CRYPTO_poly1305_init +_libre_CRYPTO_poly1305_update +_libre_CRYPTO_poly1305_finish _libre_TS_REQ_new _libre_TS_REQ_free _libre_i2d_TS_REQ diff --git a/lib/libcrypto/hidden/openssl/poly1305.h b/lib/libcrypto/hidden/openssl/poly1305.h new file mode 100644 index 00000000000..0959c560ee8 --- /dev/null +++ b/lib/libcrypto/hidden/openssl/poly1305.h @@ -0,0 +1,32 @@ +/* $OpenBSD: poly1305.h,v 1.1 2023/07/07 12:01:32 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_POLY1305_H +#define _LIBCRYPTO_POLY1305_H + +#ifndef _MSC_VER +#include_next +#else +#include "../include/openssl/poly1305.h" +#endif +#include "crypto_namespace.h" + +LCRYPTO_USED(CRYPTO_poly1305_init); +LCRYPTO_USED(CRYPTO_poly1305_update); +LCRYPTO_USED(CRYPTO_poly1305_finish); + +#endif /* _LIBCRYPTO_POLY1305_H */ diff --git a/lib/libcrypto/hidden/openssl/rand.h b/lib/libcrypto/hidden/openssl/rand.h new file mode 100644 index 00000000000..0bec707a8af --- /dev/null +++ b/lib/libcrypto/hidden/openssl/rand.h @@ -0,0 +1,44 @@ +/* $OpenBSD: rand.h,v 1.1 2023/07/07 12:01:32 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_RAND_H +#define _LIBCRYPTO_RAND_H + +#ifndef _MSC_VER +#include_next +#else +#include "../include/openssl/rand.h" +#endif +#include "crypto_namespace.h" + +LCRYPTO_USED(RAND_set_rand_method); +LCRYPTO_USED(RAND_get_rand_method); +LCRYPTO_USED(RAND_set_rand_engine); +LCRYPTO_USED(RAND_SSLeay); +LCRYPTO_USED(RAND_cleanup); +LCRYPTO_USED(RAND_bytes); +LCRYPTO_USED(RAND_pseudo_bytes); +LCRYPTO_USED(RAND_seed); +LCRYPTO_USED(RAND_add); +LCRYPTO_USED(RAND_load_file); +LCRYPTO_USED(RAND_write_file); +LCRYPTO_USED(RAND_file_name); +LCRYPTO_USED(RAND_status); +LCRYPTO_USED(RAND_poll); +LCRYPTO_USED(ERR_load_RAND_strings); + +#endif /* _LIBCRYPTO_RAND_H */ diff --git a/lib/libcrypto/hidden/openssl/sm3.h b/lib/libcrypto/hidden/openssl/sm3.h new file mode 100644 index 00000000000..3d0a4cd2694 --- /dev/null +++ b/lib/libcrypto/hidden/openssl/sm3.h @@ -0,0 +1,32 @@ +/* $OpenBSD: sm3.h,v 1.1 2023/07/07 12:01:32 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_SM3_H +#define _LIBCRYPTO_SM3_H + +#ifndef _MSC_VER +#include_next +#else +#include "../include/openssl/sm3.h" +#endif +#include "crypto_namespace.h" + +LCRYPTO_USED(SM3_Init); +LCRYPTO_USED(SM3_Update); +LCRYPTO_USED(SM3_Final); + +#endif /* _LIBCRYPTO_SM3_H */ diff --git a/lib/libcrypto/hidden/openssl/sm4.h b/lib/libcrypto/hidden/openssl/sm4.h new file mode 100644 index 00000000000..cccb3cecbcf --- /dev/null +++ b/lib/libcrypto/hidden/openssl/sm4.h @@ -0,0 +1,32 @@ +/* $OpenBSD: sm4.h,v 1.1 2023/07/07 12:01:32 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_SM4_H +#define _LIBCRYPTO_SM4_H + +#ifndef _MSC_VER +#include_next +#else +#include "../include/openssl/sm4.h" +#endif +#include "crypto_namespace.h" + +LCRYPTO_USED(SM4_set_key); +LCRYPTO_USED(SM4_decrypt); +LCRYPTO_USED(SM4_encrypt); + +#endif /* _LIBCRYPTO_SM4_H */ diff --git a/lib/libcrypto/poly1305/poly1305.c b/lib/libcrypto/poly1305/poly1305.c index 75a34cc3e14..a34e8f8e88d 100644 --- a/lib/libcrypto/poly1305/poly1305.c +++ b/lib/libcrypto/poly1305/poly1305.c @@ -1,4 +1,4 @@ -/* $OpenBSD: poly1305.c,v 1.3 2014/06/12 15:49:30 deraadt Exp $ */ +/* $OpenBSD: poly1305.c,v 1.4 2023/07/07 12:01:32 beck Exp $ */ /* * Copyright (c) 2014 Joel Sing * @@ -23,6 +23,7 @@ CRYPTO_poly1305_init(poly1305_context *ctx, const unsigned char key[32]) { poly1305_init(ctx, key); } +LCRYPTO_ALIAS(CRYPTO_poly1305_init); void CRYPTO_poly1305_update(poly1305_context *ctx, const unsigned char *in, @@ -30,9 +31,11 @@ CRYPTO_poly1305_update(poly1305_context *ctx, const unsigned char *in, { poly1305_update(ctx, in, len); } +LCRYPTO_ALIAS(CRYPTO_poly1305_update); void CRYPTO_poly1305_finish(poly1305_context *ctx, unsigned char mac[16]) { poly1305_finish(ctx, mac); } +LCRYPTO_ALIAS(CRYPTO_poly1305_finish); diff --git a/lib/libcrypto/rand/rand_err.c b/lib/libcrypto/rand/rand_err.c index c57b9a8d63f..b156c0c87ce 100644 --- a/lib/libcrypto/rand/rand_err.c +++ b/lib/libcrypto/rand/rand_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rand_err.c,v 1.16 2022/07/12 14:42:50 kn Exp $ */ +/* $OpenBSD: rand_err.c,v 1.17 2023/07/07 12:01:32 beck Exp $ */ /* ==================================================================== * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. * @@ -91,3 +91,4 @@ ERR_load_RAND_strings(void) } #endif } +LCRYPTO_ALIAS(ERR_load_RAND_strings); diff --git a/lib/libcrypto/rand/rand_lib.c b/lib/libcrypto/rand/rand_lib.c index 8342a55f05d..b51db8acf6b 100644 --- a/lib/libcrypto/rand/rand_lib.c +++ b/lib/libcrypto/rand/rand_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rand_lib.c,v 1.20 2014/10/22 13:02:04 jsing Exp $ */ +/* $OpenBSD: rand_lib.c,v 1.21 2023/07/07 12:01:32 beck Exp $ */ /* * Copyright (c) 2014 Ted Unangst * @@ -29,18 +29,21 @@ RAND_set_rand_method(const RAND_METHOD *meth) { return 1; } +LCRYPTO_ALIAS(RAND_set_rand_method); const RAND_METHOD * RAND_get_rand_method(void) { return NULL; } +LCRYPTO_ALIAS(RAND_get_rand_method); RAND_METHOD * RAND_SSLeay(void) { return NULL; } +LCRYPTO_ALIAS(RAND_SSLeay); #ifndef OPENSSL_NO_ENGINE int @@ -48,6 +51,7 @@ RAND_set_rand_engine(ENGINE *engine) { return 1; } +LCRYPTO_ALIAS(RAND_set_rand_engine); #endif void @@ -55,30 +59,35 @@ RAND_cleanup(void) { } +LCRYPTO_ALIAS(RAND_cleanup); void RAND_seed(const void *buf, int num) { } +LCRYPTO_ALIAS(RAND_seed); void RAND_add(const void *buf, int num, double entropy) { } +LCRYPTO_ALIAS(RAND_add); int RAND_status(void) { return 1; } +LCRYPTO_ALIAS(RAND_status); int RAND_poll(void) { return 1; } +LCRYPTO_ALIAS(RAND_poll); /* * Hurray. You've made it to the good parts. @@ -90,6 +99,7 @@ RAND_bytes(unsigned char *buf, int num) arc4random_buf(buf, num); return 1; } +LCRYPTO_ALIAS(RAND_bytes); int RAND_pseudo_bytes(unsigned char *buf, int num) @@ -98,3 +108,4 @@ RAND_pseudo_bytes(unsigned char *buf, int num) arc4random_buf(buf, num); return 1; } +LCRYPTO_ALIAS(RAND_pseudo_bytes); diff --git a/lib/libcrypto/rand/randfile.c b/lib/libcrypto/rand/randfile.c index 72c065c48da..7384a657911 100644 --- a/lib/libcrypto/rand/randfile.c +++ b/lib/libcrypto/rand/randfile.c @@ -1,4 +1,4 @@ -/* $OpenBSD: randfile.c,v 1.42 2015/09/10 15:56:25 jsing Exp $ */ +/* $OpenBSD: randfile.c,v 1.43 2023/07/07 12:01:32 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -85,6 +85,7 @@ RAND_load_file(const char *file, long bytes) else return bytes; } +LCRYPTO_ALIAS(RAND_load_file); int RAND_write_file(const char *file) @@ -133,6 +134,7 @@ RAND_write_file(const char *file) explicit_bzero(buf, BUFSIZE); return ret; } +LCRYPTO_ALIAS(RAND_write_file); const char * RAND_file_name(char * buf, size_t size) @@ -141,3 +143,4 @@ RAND_file_name(char * buf, size_t size) return (NULL); return buf; } +LCRYPTO_ALIAS(RAND_file_name); diff --git a/lib/libcrypto/sm3/sm3.c b/lib/libcrypto/sm3/sm3.c index 1a96146807b..039a92201b1 100644 --- a/lib/libcrypto/sm3/sm3.c +++ b/lib/libcrypto/sm3/sm3.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sm3.c,v 1.2 2022/11/26 16:08:54 tb Exp $ */ +/* $OpenBSD: sm3.c,v 1.3 2023/07/07 12:01:32 beck Exp $ */ /* * Copyright (c) 2018, Ribose Inc * @@ -35,6 +35,7 @@ SM3_Init(SM3_CTX *c) c->H = SM3_H; return 1; } +LCRYPTO_ALIAS(SM3_Init); void SM3_block_data_order(SM3_CTX *ctx, const void *p, size_t num) diff --git a/lib/libcrypto/sm4/sm4.c b/lib/libcrypto/sm4/sm4.c index 009c780fb52..bd1689987e4 100644 --- a/lib/libcrypto/sm4/sm4.c +++ b/lib/libcrypto/sm4/sm4.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sm4.c,v 1.1 2019/03/17 17:42:37 tb Exp $ */ +/* $OpenBSD: sm4.c,v 1.2 2023/07/07 12:01:32 beck Exp $ */ /* * Copyright (c) 2017, 2019 Ribose Inc * @@ -199,6 +199,7 @@ SM4_set_key(const uint8_t *key, SM4_KEY *k) return 1; } +LCRYPTO_ALIAS(SM4_set_key); #define SM4_ROUNDS(k0, k1, k2, k3, F) \ do { \ @@ -235,6 +236,7 @@ SM4_encrypt(const uint8_t *in, uint8_t *out, const SM4_KEY *k) store_u32_be(B1, out + 8); store_u32_be(B0, out + 12); } +LCRYPTO_ALIAS(SM4_encrypt); void SM4_decrypt(const uint8_t *in, uint8_t *out, const SM4_KEY *k) @@ -259,5 +261,6 @@ SM4_decrypt(const uint8_t *in, uint8_t *out, const SM4_KEY *k) store_u32_be(B1, out + 8); store_u32_be(B0, out + 12); } +LCRYPTO_ALIAS(SM4_decrypt); #endif /* OPENSSL_NO_SM4 */ -- 2.20.1