Namespace crypto/hrss's internal symbols. Leaving the asm-defined symbol alone for now - that's to be taken care of separately. Down from 986 to 984 unintended exported symbols. Bug: 42220000 Change-Id: Ie975cfcc6a4ac9581e2ee59a9e6bfdca177730ed Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/86267 Commit-Queue: Rudolf Polzer <rpolzer@google.com> Reviewed-by: Xiangfei Ding <xfding@google.com>
diff --git a/crypto/hrss/hrss.cc b/crypto/hrss/hrss.cc index 2818fe8..95da105 100644 --- a/crypto/hrss/hrss.cc +++ b/crypto/hrss/hrss.cc
@@ -38,6 +38,9 @@ #include <arm_neon.h> #endif + +using namespace bssl; + // This is an implementation of [HRSS], but with a KEM transformation based on // [SXY]. The primary references are: @@ -50,7 +53,6 @@ // NTRUCOMP: https://eprint.iacr.org/2018/1174 // SAFEGCD: https://gcd.cr.yp.to/papers.html#safegcd - // Vector operations. // // A couple of functions in this file can use vector operations to meaningful @@ -64,6 +66,7 @@ #if defined(OPENSSL_SSE2) && (defined(__clang__) || !defined(_MSC_VER)) #define HRSS_HAVE_VECTOR_UNIT + typedef __m128i vec_t; // vec_capable returns one iff the current platform supports SSE2. @@ -647,8 +650,8 @@ } // HRSS_poly3_mul sets |*out| to |x|×|y| mod Φ(N). -void HRSS_poly3_mul(struct poly3 *out, const struct poly3 *x, - const struct poly3 *y) { +void bssl::HRSS_poly3_mul(struct poly3 *out, const struct poly3 *x, + const struct poly3 *y) { crypto_word_t prod_s[WORDS_PER_POLY * 2]; crypto_word_t prod_a[WORDS_PER_POLY * 2]; crypto_word_t scratch_s[WORDS_PER_POLY * 2 + 2]; @@ -782,7 +785,7 @@ // HRSS_poly3_invert sets |*out| to |in|^-1, i.e. such that |out|×|in| == 1 mod // Φ(N). -void HRSS_poly3_invert(struct poly3 *out, const struct poly3 *in) { +void bssl::HRSS_poly3_invert(struct poly3 *out, const struct poly3 *in) { // The vector version of this function seems slightly slower on AArch64, but // is useful on ARMv7 and x86-64. #if defined(HRSS_HAVE_VECTOR_UNIT) && !defined(OPENSSL_AARCH64)
diff --git a/crypto/hrss/hrss_test.cc b/crypto/hrss/hrss_test.cc index fd67e45..0e8fac1 100644 --- a/crypto/hrss/hrss_test.cc +++ b/crypto/hrss/hrss_test.cc
@@ -23,6 +23,9 @@ #include "internal.h" +BSSL_NAMESPACE_BEGIN +namespace { + // poly3_rand sets |r| to a random value (albeit with bias). static void poly3_rand(poly3 *p) { RAND_bytes(reinterpret_cast<uint8_t *>(p), sizeof(poly3)); @@ -511,3 +514,6 @@ Bytes(kCanary)); } #endif // POLY_RQ_MUL_ASM && SUPPORTS_ABI_TEST + +} // namespace +BSSL_NAMESPACE_END
diff --git a/crypto/hrss/internal.h b/crypto/hrss/internal.h index 5cea961..78d385b 100644 --- a/crypto/hrss/internal.h +++ b/crypto/hrss/internal.h
@@ -18,10 +18,7 @@ #include <openssl/base.h> #include "../internal.h" -#if defined(__cplusplus) -extern "C" { -#endif - +BSSL_NAMESPACE_BEGIN #define HRSS_N 701 #define BITS_PER_WORD (sizeof(crypto_word_t) * 8) @@ -53,7 +50,7 @@ // poly_Rq_mul is defined in assembly. Inputs and outputs must be 16-byte- // aligned. -extern void poly_Rq_mul( +extern "C" void poly_Rq_mul( uint16_t r[HRSS_N + 3], const uint16_t a[HRSS_N + 3], const uint16_t b[HRSS_N + 3], // The following should be `scratch[POLY_MUL_RQ_SCRATCH_SPACE]` but @@ -61,9 +58,7 @@ uint8_t scratch[]); #endif +BSSL_NAMESPACE_END -#if defined(__cplusplus) -} // extern C -#endif #endif // !OPENSSL_HEADER_CRYPTO_HRSS_INTERNAL_H