third_party/boringssl-with-bazel/src/crypto/hrss/internal.h
Go to the documentation of this file.
1 /* Copyright (c) 2018, Google Inc.
2  *
3  * Permission to use, copy, modify, and/or distribute this software for any
4  * purpose with or without fee is hereby granted, provided that the above
5  * copyright notice and this permission notice appear in all copies.
6  *
7  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
14 
15 #ifndef OPENSSL_HEADER_HRSS_INTERNAL_H
16 #define OPENSSL_HEADER_HRSS_INTERNAL_H
17 
18 #include <openssl/base.h>
19 #include "../internal.h"
20 
21 #if defined(__cplusplus)
22 extern "C" {
23 #endif
24 
25 
26 #define N 701
27 #define BITS_PER_WORD (sizeof(crypto_word_t) * 8)
28 #define WORDS_PER_POLY ((N + BITS_PER_WORD - 1) / BITS_PER_WORD)
29 #define BITS_IN_LAST_WORD (N % BITS_PER_WORD)
30 
31 struct poly2 {
32  crypto_word_t v[WORDS_PER_POLY];
33 };
34 
35 struct poly3 {
36  struct poly2 s, a;
37 };
38 
39 OPENSSL_EXPORT void HRSS_poly3_mul(struct poly3 *out, const struct poly3 *x,
40  const struct poly3 *y);
42  const struct poly3 *in);
43 
44 // On x86-64, we can use the AVX2 code from [HRSS]. (The authors have given
45 // explicit permission for this and signed a CLA.) However it's 57KB of object
46 // code, so it's not used if |OPENSSL_SMALL| is defined.
47 #if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_SMALL) && \
48  defined(OPENSSL_X86_64) && defined(OPENSSL_LINUX)
49 #define POLY_RQ_MUL_ASM
50 // POLY_MUL_RQ_SCRATCH_SPACE is the number of bytes of scratch space needed
51 // by the assembly function poly_Rq_mul.
52 #define POLY_MUL_RQ_SCRATCH_SPACE (6144 + 6144 + 12288 + 512 + 9408 + 32)
53 
54 // poly_Rq_mul is defined in assembly. Inputs and outputs must be 16-byte-
55 // aligned.
56 extern void poly_Rq_mul(
57  uint16_t r[N + 3], const uint16_t a[N + 3], const uint16_t b[N + 3],
58  // The following should be `scratch[POLY_MUL_RQ_SCRATCH_SPACE]` but
59  // GCC 11.1 has a bug with unions that breaks that.
60  uint8_t scratch[]);
61 #endif
62 
63 
64 #if defined(__cplusplus)
65 } // extern "C"
66 #endif
67 
68 #endif // !OPENSSL_HEADER_HRSS_INTERNAL_H
HRSS_poly3_mul
OPENSSL_EXPORT void HRSS_poly3_mul(struct poly3 *out, const struct poly3 *x, const struct poly3 *y)
Definition: hrss.c:710
poly3
Definition: third_party/boringssl-with-bazel/src/crypto/hrss/internal.h:35
gen_build_yaml.out
dictionary out
Definition: src/benchmark/gen_build_yaml.py:24
uint16_t
unsigned short uint16_t
Definition: stdint-msvc2008.h:79
poly2::v
crypto_word_t v[WORDS_PER_POLY]
Definition: third_party/boringssl-with-bazel/src/crypto/hrss/internal.h:32
y
const double y
Definition: bloaty/third_party/googletest/googlemock/test/gmock-matchers_test.cc:3611
poly_Rq_mul
#define poly_Rq_mul
Definition: boringssl_prefix_symbols.h:3354
N
#define N
Definition: third_party/boringssl-with-bazel/src/crypto/hrss/internal.h:26
a
int a
Definition: abseil-cpp/absl/container/internal/hash_policy_traits_test.cc:88
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
base.h
in
const char * in
Definition: third_party/abseil-cpp/absl/strings/internal/str_format/parser_test.cc:391
x
int x
Definition: bloaty/third_party/googletest/googlemock/test/gmock-matchers_test.cc:3610
poly2
Definition: third_party/boringssl-with-bazel/src/crypto/hrss/internal.h:31
HRSS_poly3_invert
OPENSSL_EXPORT void HRSS_poly3_invert(struct poly3 *out, const struct poly3 *in)
Definition: hrss.c:844
WORDS_PER_POLY
#define WORDS_PER_POLY
Definition: third_party/boringssl-with-bazel/src/crypto/hrss/internal.h:28
poly3::a
struct poly2 s a
Definition: third_party/boringssl-with-bazel/src/crypto/hrss/internal.h:36
b
uint64_t b
Definition: abseil-cpp/absl/container/internal/layout_test.cc:53
scratch
static char scratch[256]
Definition: test-random.c:27
fix_build_deps.r
r
Definition: fix_build_deps.py:491
OPENSSL_EXPORT
#define OPENSSL_EXPORT
Definition: base.h:222


grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:07