mirror of
https://github.com/apple/swift-crypto
synced 2026-11-22 04:30:39 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9b9d186860 | ||
|
|
0a0b1d50e9 | ||
|
|
cce48362a4 |
No files matched your search
+1
-1
@@ -1,5 +1,6 @@
|
||||
# file options
|
||||
|
||||
--swiftversion 5.0
|
||||
--exclude .build
|
||||
|
||||
# format options
|
||||
@@ -7,7 +8,6 @@
|
||||
--self insert
|
||||
--patternlet inline
|
||||
--stripunusedargs unnamed-only
|
||||
--comments ignore
|
||||
--ifdef no-indent
|
||||
|
||||
# rules
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
// Sources/CCryptoBoringSSL directory. The source repository is at
|
||||
// https://boringssl.googlesource.com/boringssl.
|
||||
//
|
||||
// BoringSSL Commit: 5298ef99bf2b2d77600b3bb74dd572027bf495be
|
||||
// BoringSSL Commit: 53a17f55247101105ae35767d5c5a6c311843a8e
|
||||
|
||||
import PackageDescription
|
||||
|
||||
|
||||
+1
-1
@@ -3937,7 +3937,7 @@ do_length_block:
|
||||
popq %rbp
|
||||
.cfi_adjust_cfa_offset -8
|
||||
.byte 0xf3,0xc3
|
||||
.cfi_adjust_cfa_offset (8 * 6) + 288 + 32
|
||||
.cfi_adjust_cfa_offset (8 * 7) + 288 + 32
|
||||
|
||||
seal_sse_128:
|
||||
movdqu .chacha20_consts(%rip),%xmm0
|
||||
|
||||
@@ -86,7 +86,7 @@ int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md,
|
||||
EVP_MD_CTX_init(&c);
|
||||
for (;;) {
|
||||
if (!EVP_DigestInit_ex(&c, md, NULL)) {
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
if (addmd++) {
|
||||
if (!EVP_DigestUpdate(&c, md_buf, mds)) {
|
||||
|
||||
@@ -146,11 +146,13 @@ extern uint32_t OPENSSL_armcap_P;
|
||||
static int g_has_broken_neon, g_needs_hwcap2_workaround;
|
||||
|
||||
void OPENSSL_cpuid_setup(void) {
|
||||
char *cpuinfo_data;
|
||||
size_t cpuinfo_len;
|
||||
if (!read_file(&cpuinfo_data, &cpuinfo_len, "/proc/cpuinfo")) {
|
||||
return;
|
||||
}
|
||||
// We ignore the return value of |read_file| and proceed with an empty
|
||||
// /proc/cpuinfo on error. If |getauxval| works, we will still detect
|
||||
// capabilities. There may be a false positive due to
|
||||
// |crypto_cpuinfo_has_broken_neon|, but this is now rare.
|
||||
char *cpuinfo_data = NULL;
|
||||
size_t cpuinfo_len = 0;
|
||||
read_file(&cpuinfo_data, &cpuinfo_len, "/proc/cpuinfo");
|
||||
STRING_PIECE cpuinfo;
|
||||
cpuinfo.data = cpuinfo_data;
|
||||
cpuinfo.len = cpuinfo_len;
|
||||
|
||||
@@ -123,7 +123,9 @@ static uint64_t OPENSSL_xgetbv(uint32_t xcr) {
|
||||
// and |out[1]|. See the comment in |OPENSSL_cpuid_setup| about this.
|
||||
static void handle_cpu_env(uint32_t *out, const char *in) {
|
||||
const int invert = in[0] == '~';
|
||||
const int hex = in[invert] == '0' && in[invert+1] == 'x';
|
||||
const int or = in[0] == '|';
|
||||
const int skip_first_byte = invert || or;
|
||||
const int hex = in[skip_first_byte] == '0' && in[skip_first_byte+1] == 'x';
|
||||
|
||||
int sscanf_result;
|
||||
uint64_t v;
|
||||
@@ -140,6 +142,9 @@ static void handle_cpu_env(uint32_t *out, const char *in) {
|
||||
if (invert) {
|
||||
out[0] &= ~v;
|
||||
out[1] &= ~(v >> 32);
|
||||
} else if (or) {
|
||||
out[0] |= v;
|
||||
out[1] |= (v >> 32);
|
||||
} else {
|
||||
out[0] = v;
|
||||
out[1] = v >> 32;
|
||||
@@ -264,10 +269,14 @@ void OPENSSL_cpuid_setup(void) {
|
||||
|
||||
// OPENSSL_ia32cap can contain zero, one or two values, separated with a ':'.
|
||||
// Each value is a 64-bit, unsigned value which may start with "0x" to
|
||||
// indicate a hex value. Prior to the 64-bit value, a '~' may be given.
|
||||
// indicate a hex value. Prior to the 64-bit value, a '~' or '|' may be given.
|
||||
//
|
||||
// If '~' isn't present, then the value is taken as the result of the CPUID.
|
||||
// Otherwise the value is inverted and ANDed with the probed CPUID result.
|
||||
// If the '~' prefix is present:
|
||||
// the value is inverted and ANDed with the probed CPUID result
|
||||
// If the '|' prefix is present:
|
||||
// the value is ORed with the probed CPUID result
|
||||
// Otherwise:
|
||||
// the value is taken as the result of the CPUID
|
||||
//
|
||||
// The first value determines OPENSSL_ia32cap_P[0] and [1]. The second [2]
|
||||
// and [3].
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
#include <CCryptoBoringSSL_cpu.h>
|
||||
|
||||
#include "fipsmodule/rand/fork_detect.h"
|
||||
#include "fipsmodule/rand/internal.h"
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
@@ -174,6 +176,15 @@ int CRYPTO_has_asm(void) {
|
||||
#endif
|
||||
}
|
||||
|
||||
void CRYPTO_pre_sandbox_init(void) {
|
||||
// Read from /proc/cpuinfo if needed.
|
||||
CRYPTO_library_init();
|
||||
// Open /dev/urandom if needed.
|
||||
CRYPTO_init_sysrand();
|
||||
// Set up MADV_WIPEONFORK state if needed.
|
||||
CRYPTO_get_fork_generation();
|
||||
}
|
||||
|
||||
const char *SSLeay_version(int which) { return OpenSSL_version(which); }
|
||||
|
||||
const char *OpenSSL_version(int which) {
|
||||
|
||||
+18
-26
@@ -1,29 +1,21 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015-2016 the fiat-crypto authors (see the AUTHORS file).
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
/* Copyright (c) 2020, Google Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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. */
|
||||
|
||||
// Some of this code is taken from the ref10 version of Ed25519 in SUPERCOP
|
||||
// 20141124 (http://bench.cr.yp.to/supercop.html). That code is released as
|
||||
// public domain but parts have been replaced with code generated by Fiat
|
||||
// (https://github.com/mit-plv/fiat-crypto), which is MIT licensed.
|
||||
// public domain. Other parts have been replaced to call into code generated by
|
||||
// Fiat (https://github.com/mit-plv/fiat-crypto) in //third_party/fiat.
|
||||
//
|
||||
// The field functions are shared by Ed25519 and X25519 where possible.
|
||||
|
||||
@@ -39,16 +31,16 @@
|
||||
#include <CCryptoBoringSSL_type_check.h>
|
||||
|
||||
#include "internal.h"
|
||||
#include "../../crypto/internal.h"
|
||||
#include "../internal.h"
|
||||
|
||||
|
||||
// Various pre-computed constants.
|
||||
#include "./curve25519_tables.h"
|
||||
|
||||
#if defined(BORINGSSL_CURVE25519_64BIT)
|
||||
#include "./curve25519_64.h"
|
||||
#include "../../third_party/fiat/curve25519_64.h"
|
||||
#else
|
||||
#include "./curve25519_32.h"
|
||||
#include "../../third_party/fiat/curve25519_32.h"
|
||||
#endif // BORINGSSL_CURVE25519_64BIT
|
||||
|
||||
|
||||
+13
-21
@@ -1,24 +1,16 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015-2016 the fiat-crypto authors (see the AUTHORS file).
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
/* Copyright (c) 2020, Google Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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. */
|
||||
|
||||
// This file is generated from
|
||||
// ./make_curve25519_tables.py > curve25519_tables.h
|
||||
+14
-22
@@ -1,24 +1,16 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015-2016 the fiat-crypto authors (see the AUTHORS file).
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
/* Copyright (c) 2020, Google Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 OPENSSL_HEADER_CURVE25519_INTERNAL_H
|
||||
#define OPENSSL_HEADER_CURVE25519_INTERNAL_H
|
||||
@@ -29,7 +21,7 @@ extern "C" {
|
||||
|
||||
#include <CCryptoBoringSSL_base.h>
|
||||
|
||||
#include "../../crypto/internal.h"
|
||||
#include "../internal.h"
|
||||
|
||||
|
||||
#if defined(OPENSSL_ARM) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_APPLE)
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <CCryptoBoringSSL_sha.h>
|
||||
|
||||
#include "../internal.h"
|
||||
#include "../../third_party/fiat/internal.h"
|
||||
#include "./internal.h"
|
||||
|
||||
|
||||
// The following precomputation tables are for the following
|
||||
|
||||
@@ -113,6 +113,16 @@ void DH_free(DH *dh) {
|
||||
OPENSSL_free(dh);
|
||||
}
|
||||
|
||||
const BIGNUM *DH_get0_pub_key(const DH *dh) { return dh->pub_key; }
|
||||
|
||||
const BIGNUM *DH_get0_priv_key(const DH *dh) { return dh->priv_key; }
|
||||
|
||||
const BIGNUM *DH_get0_p(const DH *dh) { return dh->p; }
|
||||
|
||||
const BIGNUM *DH_get0_q(const DH *dh) { return dh->q; }
|
||||
|
||||
const BIGNUM *DH_get0_g(const DH *dh) { return dh->g; }
|
||||
|
||||
void DH_get0_key(const DH *dh, const BIGNUM **out_pub_key,
|
||||
const BIGNUM **out_priv_key) {
|
||||
if (out_pub_key != NULL) {
|
||||
@@ -174,6 +184,11 @@ int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int DH_set_length(DH *dh, unsigned priv_length) {
|
||||
dh->priv_length = priv_length;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int DH_generate_parameters_ex(DH *dh, int prime_bits, int generator, BN_GENCB *cb) {
|
||||
// We generate DH parameters as follows
|
||||
// find a prime q which is prime_bits/2 bits long.
|
||||
|
||||
@@ -131,6 +131,16 @@ int DSA_up_ref(DSA *dsa) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
const BIGNUM *DSA_get0_pub_key(const DSA *dsa) { return dsa->pub_key; }
|
||||
|
||||
const BIGNUM *DSA_get0_priv_key(const DSA *dsa) { return dsa->priv_key; }
|
||||
|
||||
const BIGNUM *DSA_get0_p(const DSA *dsa) { return dsa->p; }
|
||||
|
||||
const BIGNUM *DSA_get0_q(const DSA *dsa) { return dsa->q; }
|
||||
|
||||
const BIGNUM *DSA_get0_g(const DSA *dsa) { return dsa->g; }
|
||||
|
||||
void DSA_get0_key(const DSA *dsa, const BIGNUM **out_pub_key,
|
||||
const BIGNUM **out_priv_key) {
|
||||
if (out_pub_key != NULL) {
|
||||
|
||||
@@ -0,0 +1,425 @@
|
||||
/* Copyright (c) 2020, Google Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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. */
|
||||
|
||||
#include <CCryptoBoringSSL_ec.h>
|
||||
|
||||
#include <CCryptoBoringSSL_digest.h>
|
||||
#include <CCryptoBoringSSL_err.h>
|
||||
#include <CCryptoBoringSSL_nid.h>
|
||||
#include <CCryptoBoringSSL_type_check.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "internal.h"
|
||||
#include "../fipsmodule/bn/internal.h"
|
||||
#include "../fipsmodule/ec/internal.h"
|
||||
#include "../internal.h"
|
||||
|
||||
|
||||
// This file implements hash-to-curve, as described in
|
||||
// draft-irtf-cfrg-hash-to-curve-07.
|
||||
//
|
||||
// This hash-to-curve implementation is written generically with the
|
||||
// expectation that we will eventually wish to support other curves. If it
|
||||
// becomes a performance bottleneck, some possible optimizations by
|
||||
// specializing it to the curve:
|
||||
//
|
||||
// - Rather than using a generic |felem_exp|, specialize the exponentation to
|
||||
// c2 with a faster addition chain.
|
||||
//
|
||||
// - |felem_mul| and |felem_sqr| are indirect calls to generic Montgomery
|
||||
// code. Given the few curves, we could specialize
|
||||
// |map_to_curve_simple_swu|. But doing this reasonably without duplicating
|
||||
// code in C is difficult. (C++ templates would be useful here.)
|
||||
//
|
||||
// - P-521's Z and c2 have small power-of-two absolute values. We could save
|
||||
// two multiplications in SSWU. (Other curves have reasonable values of Z
|
||||
// and inconvenient c2.) This is unlikely to be worthwhile without C++
|
||||
// templates to make specializing more convenient.
|
||||
|
||||
// expand_message_xmd implements the operation described in section 5.3.1 of
|
||||
// draft-irtf-cfrg-hash-to-curve-07. It returns one on success and zero on
|
||||
// allocation failure or if |out_len| was too large. If |is_draft06| is one, it
|
||||
// implements the operation from draft-irtf-cfrg-hash-to-curve-06 instead.
|
||||
static int expand_message_xmd(const EVP_MD *md, uint8_t *out, size_t out_len,
|
||||
const uint8_t *msg, size_t msg_len,
|
||||
const uint8_t *dst, size_t dst_len,
|
||||
int is_draft06) {
|
||||
int ret = 0;
|
||||
const size_t block_size = EVP_MD_block_size(md);
|
||||
const size_t md_size = EVP_MD_size(md);
|
||||
EVP_MD_CTX ctx;
|
||||
EVP_MD_CTX_init(&ctx);
|
||||
|
||||
// Long DSTs are hashed down to size. See section 5.3.3.
|
||||
OPENSSL_STATIC_ASSERT(EVP_MAX_MD_SIZE < 256, "hashed DST still too large");
|
||||
uint8_t dst_buf[EVP_MAX_MD_SIZE];
|
||||
if (dst_len >= 256) {
|
||||
static const char kPrefix[] = "H2C-OVERSIZE-DST-";
|
||||
if (!EVP_DigestInit_ex(&ctx, md, NULL) ||
|
||||
!EVP_DigestUpdate(&ctx, kPrefix, sizeof(kPrefix) - 1) ||
|
||||
!EVP_DigestUpdate(&ctx, dst, dst_len) ||
|
||||
!EVP_DigestFinal_ex(&ctx, dst_buf, NULL)) {
|
||||
goto err;
|
||||
}
|
||||
dst = dst_buf;
|
||||
dst_len = md_size;
|
||||
}
|
||||
uint8_t dst_len_u8 = (uint8_t)dst_len;
|
||||
|
||||
// Compute b_0.
|
||||
static const uint8_t kZeros[EVP_MAX_MD_BLOCK_SIZE] = {0};
|
||||
// If |out_len| exceeds 16 bits then |i| will wrap below causing an error to
|
||||
// be returned. This depends on the static assert above.
|
||||
uint8_t l_i_b_str_zero[3] = {out_len >> 8, out_len, 0};
|
||||
uint8_t b_0[EVP_MAX_MD_SIZE];
|
||||
if (!EVP_DigestInit_ex(&ctx, md, NULL) ||
|
||||
!EVP_DigestUpdate(&ctx, kZeros, block_size) ||
|
||||
!EVP_DigestUpdate(&ctx, msg, msg_len) ||
|
||||
!EVP_DigestUpdate(&ctx, l_i_b_str_zero, sizeof(l_i_b_str_zero)) ||
|
||||
(is_draft06 && !EVP_DigestUpdate(&ctx, &dst_len_u8, 1)) ||
|
||||
!EVP_DigestUpdate(&ctx, dst, dst_len) ||
|
||||
(!is_draft06 && !EVP_DigestUpdate(&ctx, &dst_len_u8, 1)) ||
|
||||
!EVP_DigestFinal_ex(&ctx, b_0, NULL)) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
uint8_t b_i[EVP_MAX_MD_SIZE];
|
||||
uint8_t i = 1;
|
||||
while (out_len > 0) {
|
||||
if (i == 0) {
|
||||
// Input was too large.
|
||||
OPENSSL_PUT_ERROR(EC, ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
if (i > 1) {
|
||||
for (size_t j = 0; j < md_size; j++) {
|
||||
b_i[j] ^= b_0[j];
|
||||
}
|
||||
} else {
|
||||
OPENSSL_memcpy(b_i, b_0, md_size);
|
||||
}
|
||||
|
||||
if (!EVP_DigestInit_ex(&ctx, md, NULL) ||
|
||||
!EVP_DigestUpdate(&ctx, b_i, md_size) ||
|
||||
!EVP_DigestUpdate(&ctx, &i, 1) ||
|
||||
(is_draft06 && !EVP_DigestUpdate(&ctx, &dst_len_u8, 1)) ||
|
||||
!EVP_DigestUpdate(&ctx, dst, dst_len) ||
|
||||
(!is_draft06 && !EVP_DigestUpdate(&ctx, &dst_len_u8, 1)) ||
|
||||
!EVP_DigestFinal_ex(&ctx, b_i, NULL)) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
size_t todo = out_len >= md_size ? md_size : out_len;
|
||||
OPENSSL_memcpy(out, b_i, todo);
|
||||
out += todo;
|
||||
out_len -= todo;
|
||||
i++;
|
||||
}
|
||||
|
||||
ret = 1;
|
||||
|
||||
err:
|
||||
EVP_MD_CTX_cleanup(&ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// num_bytes_to_derive determines the number of bytes to derive when hashing to
|
||||
// a number modulo |modulus|. See the hash_to_field operation defined in
|
||||
// section 5.2 of draft-irtf-cfrg-hash-to-curve-07.
|
||||
static int num_bytes_to_derive(size_t *out, const BIGNUM *modulus, unsigned k) {
|
||||
size_t bits = BN_num_bits(modulus);
|
||||
size_t L = (bits + k + 7) / 8;
|
||||
// We require 2^(8*L) < 2^(2*bits - 2) <= n^2 so to fit in bounds for
|
||||
// |felem_reduce| and |ec_scalar_reduce|. All defined hash-to-curve suites
|
||||
// define |k| to be well under this bound. (|k| is usually around half of
|
||||
// |p_bits|.)
|
||||
if (L * 8 >= 2 * bits - 2 ||
|
||||
L > 2 * EC_MAX_BYTES) {
|
||||
assert(0);
|
||||
OPENSSL_PUT_ERROR(EC, ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*out = L;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// big_endian_to_words decodes |in| as a big-endian integer and writes the
|
||||
// result to |out|. |num_words| must be large enough to contain the output.
|
||||
static void big_endian_to_words(BN_ULONG *out, size_t num_words,
|
||||
const uint8_t *in, size_t len) {
|
||||
assert(len <= num_words * sizeof(BN_ULONG));
|
||||
// Ensure any excess bytes are zeroed.
|
||||
OPENSSL_memset(out, 0, num_words * sizeof(BN_ULONG));
|
||||
uint8_t *out_u8 = (uint8_t *)out;
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
out_u8[len - 1 - i] = in[i];
|
||||
}
|
||||
}
|
||||
|
||||
// hash_to_field implements the operation described in section 5.2
|
||||
// of draft-irtf-cfrg-hash-to-curve-07, with count = 2. |k| is the security
|
||||
// factor.
|
||||
static int hash_to_field2(const EC_GROUP *group, const EVP_MD *md,
|
||||
EC_FELEM *out1, EC_FELEM *out2, const uint8_t *dst,
|
||||
size_t dst_len, unsigned k, const uint8_t *msg,
|
||||
size_t msg_len, int is_draft06) {
|
||||
size_t L;
|
||||
uint8_t buf[4 * EC_MAX_BYTES];
|
||||
if (!num_bytes_to_derive(&L, &group->field, k) ||
|
||||
!expand_message_xmd(md, buf, 2 * L, msg, msg_len, dst, dst_len,
|
||||
is_draft06)) {
|
||||
return 0;
|
||||
}
|
||||
BN_ULONG words[2 * EC_MAX_WORDS];
|
||||
size_t num_words = 2 * group->field.width;
|
||||
big_endian_to_words(words, num_words, buf, L);
|
||||
group->meth->felem_reduce(group, out1, words, num_words);
|
||||
big_endian_to_words(words, num_words, buf + L, L);
|
||||
group->meth->felem_reduce(group, out2, words, num_words);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// hash_to_scalar behaves like |hash_to_field2| but returns a value modulo the
|
||||
// group order rather than a field element. |k| is the security factor.
|
||||
static int hash_to_scalar(const EC_GROUP *group, const EVP_MD *md,
|
||||
EC_SCALAR *out, const uint8_t *dst, size_t dst_len,
|
||||
unsigned k, const uint8_t *msg, size_t msg_len,
|
||||
int is_draft06) {
|
||||
size_t L;
|
||||
uint8_t buf[EC_MAX_BYTES * 2];
|
||||
if (!num_bytes_to_derive(&L, &group->order, k) ||
|
||||
!expand_message_xmd(md, buf, L, msg, msg_len, dst, dst_len, is_draft06)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
BN_ULONG words[2 * EC_MAX_WORDS];
|
||||
size_t num_words = 2 * group->order.width;
|
||||
big_endian_to_words(words, num_words, buf, L);
|
||||
ec_scalar_reduce(group, out, words, num_words);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline void mul_A(const EC_GROUP *group, EC_FELEM *out,
|
||||
const EC_FELEM *in) {
|
||||
assert(group->a_is_minus3);
|
||||
EC_FELEM tmp;
|
||||
ec_felem_add(group, &tmp, in, in); // tmp = 2*in
|
||||
ec_felem_add(group, &tmp, &tmp, &tmp); // tmp = 4*in
|
||||
ec_felem_sub(group, out, in, &tmp); // out = -3*in
|
||||
}
|
||||
|
||||
static inline void mul_minus_A(const EC_GROUP *group, EC_FELEM *out,
|
||||
const EC_FELEM *in) {
|
||||
assert(group->a_is_minus3);
|
||||
EC_FELEM tmp;
|
||||
ec_felem_add(group, &tmp, in, in); // tmp = 2*in
|
||||
ec_felem_add(group, out, &tmp, in); // out = 3*in
|
||||
}
|
||||
|
||||
// sgn0_le implements the operation described in section 4.1.2 of
|
||||
// draft-irtf-cfrg-hash-to-curve-07.
|
||||
static BN_ULONG sgn0_le(const EC_GROUP *group, const EC_FELEM *a) {
|
||||
uint8_t buf[EC_MAX_BYTES];
|
||||
size_t len;
|
||||
ec_felem_to_bytes(group, buf, &len, a);
|
||||
return buf[len - 1] & 1;
|
||||
}
|
||||
|
||||
// map_to_curve_simple_swu implements the operation described in section 6.6.2
|
||||
// of draft-irtf-cfrg-hash-to-curve-07, using the optimization in appendix
|
||||
// D.2.1. It returns one on success and zero on error.
|
||||
static int map_to_curve_simple_swu(const EC_GROUP *group, const EC_FELEM *Z,
|
||||
const BN_ULONG *c1, size_t num_c1,
|
||||
const EC_FELEM *c2, EC_RAW_POINT *out,
|
||||
const EC_FELEM *u) {
|
||||
void (*const felem_mul)(const EC_GROUP *, EC_FELEM *r, const EC_FELEM *a,
|
||||
const EC_FELEM *b) = group->meth->felem_mul;
|
||||
void (*const felem_sqr)(const EC_GROUP *, EC_FELEM *r, const EC_FELEM *a) =
|
||||
group->meth->felem_sqr;
|
||||
|
||||
// This function requires the prime be 3 mod 4, and that A = -3.
|
||||
if (group->field.width == 0 || (group->field.d[0] & 3) != 3 ||
|
||||
!group->a_is_minus3) {
|
||||
OPENSSL_PUT_ERROR(EC, ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
EC_FELEM tv1, tv2, tv3, tv4, xd, x1n, x2n, tmp, gxd, gx1, y1, y2;
|
||||
felem_sqr(group, &tv1, u); // tv1 = u^2
|
||||
felem_mul(group, &tv3, Z, &tv1); // tv3 = Z * tv1
|
||||
felem_sqr(group, &tv2, &tv3); // tv2 = tv3^2
|
||||
ec_felem_add(group, &xd, &tv2, &tv3); // xd = tv2 + tv3
|
||||
ec_felem_add(group, &x1n, &xd, &group->one); // x1n = xd + 1
|
||||
felem_mul(group, &x1n, &x1n, &group->b); // x1n = x1n * B
|
||||
mul_minus_A(group, &xd, &xd); // xd = -A * xd
|
||||
BN_ULONG e1 = ec_felem_non_zero_mask(group, &xd); // e1 = xd == 0 [flipped]
|
||||
mul_A(group, &tmp, Z);
|
||||
ec_felem_select(group, &xd, e1, &xd, &tmp); // xd = CMOV(xd, Z * A, e1)
|
||||
felem_sqr(group, &tv2, &xd); // tv2 = xd^2
|
||||
felem_mul(group, &gxd, &tv2, &xd); // gxd = tv2 * xd = xd^3
|
||||
mul_A(group, &tv2, &tv2); // tv2 = A * tv2
|
||||
felem_sqr(group, &gx1, &x1n); // gx1 = x1n^2
|
||||
ec_felem_add(group, &gx1, &gx1, &tv2); // gx1 = gx1 + tv2
|
||||
felem_mul(group, &gx1, &gx1, &x1n); // gx1 = gx1 * x1n
|
||||
felem_mul(group, &tv2, &group->b, &gxd); // tv2 = B * gxd
|
||||
ec_felem_add(group, &gx1, &gx1, &tv2); // gx1 = gx1 + tv2
|
||||
felem_sqr(group, &tv4, &gxd); // tv4 = gxd^2
|
||||
felem_mul(group, &tv2, &gx1, &gxd); // tv2 = gx1 * gxd
|
||||
felem_mul(group, &tv4, &tv4, &tv2); // tv4 = tv4 * tv2
|
||||
group->meth->felem_exp(group, &y1, &tv4, c1, num_c1); // y1 = tv4^c1
|
||||
felem_mul(group, &y1, &y1, &tv2); // y1 = y1 * tv2
|
||||
felem_mul(group, &x2n, &tv3, &x1n); // x2n = tv3 * x1n
|
||||
felem_mul(group, &y2, &y1, c2); // y2 = y1 * c2
|
||||
felem_mul(group, &y2, &y2, &tv1); // y2 = y2 * tv1
|
||||
felem_mul(group, &y2, &y2, u); // y2 = y2 * u
|
||||
felem_sqr(group, &tv2, &y1); // tv2 = y1^2
|
||||
felem_mul(group, &tv2, &tv2, &gxd); // tv2 = tv2 * gxd
|
||||
ec_felem_sub(group, &tv3, &tv2, &gx1);
|
||||
BN_ULONG e2 =
|
||||
ec_felem_non_zero_mask(group, &tv3); // e2 = tv2 == gx1 [flipped]
|
||||
ec_felem_select(group, &x1n, e2, &x2n, &x1n); // xn = CMOV(x2n, x1n, e2)
|
||||
ec_felem_select(group, &y1, e2, &y2, &y1); // y = CMOV(y2, y1, e2)
|
||||
BN_ULONG sgn0_u = sgn0_le(group, u);
|
||||
BN_ULONG sgn0_y = sgn0_le(group, &y1);
|
||||
BN_ULONG e3 = sgn0_u ^ sgn0_y;
|
||||
e3 = ((BN_ULONG)0) - e3; // e3 = sgn0(u) == sgn0(y) [flipped]
|
||||
ec_felem_neg(group, &y2, &y1);
|
||||
ec_felem_select(group, &y1, e3, &y2, &y1); // y = CMOV(-y, y, e3)
|
||||
|
||||
// Appendix D.1 describes how to convert (x1n, xd, y1, 1) to Jacobian
|
||||
// coordinates. Note yd = 1. Also note that gxd computed above is xd^3.
|
||||
felem_mul(group, &out->X, &x1n, &xd); // X = xn * xd
|
||||
felem_mul(group, &out->Y, &y1, &gxd); // Y = yn * gxd = yn * xd^3
|
||||
out->Z = xd; // Z = xd
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int hash_to_curve(const EC_GROUP *group, const EVP_MD *md,
|
||||
const EC_FELEM *Z, const EC_FELEM *c2, unsigned k,
|
||||
EC_RAW_POINT *out, const uint8_t *dst, size_t dst_len,
|
||||
const uint8_t *msg, size_t msg_len, int is_draft06) {
|
||||
EC_FELEM u0, u1;
|
||||
if (!hash_to_field2(group, md, &u0, &u1, dst, dst_len, k, msg, msg_len,
|
||||
is_draft06)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Compute |c1| = (p - 3) / 4.
|
||||
BN_ULONG c1[EC_MAX_WORDS];
|
||||
size_t num_c1 = group->field.width;
|
||||
if (!bn_copy_words(c1, num_c1, &group->field)) {
|
||||
return 0;
|
||||
}
|
||||
bn_rshift_words(c1, c1, /*shift=*/2, /*num=*/num_c1);
|
||||
|
||||
EC_RAW_POINT Q0, Q1;
|
||||
if (!map_to_curve_simple_swu(group, Z, c1, num_c1, c2, &Q0, &u0) ||
|
||||
!map_to_curve_simple_swu(group, Z, c1, num_c1, c2, &Q1, &u1)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
group->meth->add(group, out, &Q0, &Q1); // R = Q0 + Q1
|
||||
// All our curves have cofactor one, so |clear_cofactor| is a no-op.
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int felem_from_u8(const EC_GROUP *group, EC_FELEM *out, uint8_t a) {
|
||||
uint8_t bytes[EC_MAX_BYTES] = {0};
|
||||
size_t len = BN_num_bytes(&group->field);
|
||||
bytes[len - 1] = a;
|
||||
return ec_felem_from_bytes(group, out, bytes, len);
|
||||
}
|
||||
|
||||
int ec_hash_to_curve_p384_xmd_sha512_sswu_draft07(
|
||||
const EC_GROUP *group, EC_RAW_POINT *out, const uint8_t *dst,
|
||||
size_t dst_len, const uint8_t *msg, size_t msg_len) {
|
||||
// See section 8.3 of draft-irtf-cfrg-hash-to-curve-07.
|
||||
if (EC_GROUP_get_curve_name(group) != NID_secp384r1) {
|
||||
OPENSSL_PUT_ERROR(EC, EC_R_GROUP_MISMATCH);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// kSqrt1728 was computed as follows in python3:
|
||||
//
|
||||
// p = 2**384 - 2**128 - 2**96 + 2**32 - 1
|
||||
// z3 = 12**3
|
||||
// c2 = pow(z3, (p+1)//4, p)
|
||||
// assert z3 == pow(c2, 2, p)
|
||||
// ", ".join("0x%02x" % b for b in c2.to_bytes(384//8, 'big')
|
||||
|
||||
static const uint8_t kSqrt1728[] = {
|
||||
0x01, 0x98, 0x77, 0xcc, 0x10, 0x41, 0xb7, 0x55, 0x57, 0x43, 0xc0, 0xae,
|
||||
0x2e, 0x3a, 0x3e, 0x61, 0xfb, 0x2a, 0xaa, 0x2e, 0x0e, 0x87, 0xea, 0x55,
|
||||
0x7a, 0x56, 0x3d, 0x8b, 0x59, 0x8a, 0x09, 0x40, 0xd0, 0xa6, 0x97, 0xa9,
|
||||
0xe0, 0xb9, 0xe9, 0x2c, 0xfa, 0xa3, 0x14, 0xf5, 0x83, 0xc9, 0xd0, 0x66
|
||||
};
|
||||
|
||||
// Z = -12, c2 = sqrt(1728)
|
||||
EC_FELEM Z, c2;
|
||||
if (!felem_from_u8(group, &Z, 12) ||
|
||||
!ec_felem_from_bytes(group, &c2, kSqrt1728, sizeof(kSqrt1728))) {
|
||||
return 0;
|
||||
}
|
||||
ec_felem_neg(group, &Z, &Z);
|
||||
|
||||
return hash_to_curve(group, EVP_sha512(), &Z, &c2, /*k=*/192, out, dst,
|
||||
dst_len, msg, msg_len, /*is_draft06=*/0);
|
||||
}
|
||||
|
||||
int ec_hash_to_scalar_p384_xmd_sha512_draft07(
|
||||
const EC_GROUP *group, EC_SCALAR *out, const uint8_t *dst, size_t dst_len,
|
||||
const uint8_t *msg, size_t msg_len) {
|
||||
if (EC_GROUP_get_curve_name(group) != NID_secp384r1) {
|
||||
OPENSSL_PUT_ERROR(EC, EC_R_GROUP_MISMATCH);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return hash_to_scalar(group, EVP_sha512(), out, dst, dst_len, /*k=*/192, msg,
|
||||
msg_len, /*is_draft06=*/0);
|
||||
}
|
||||
|
||||
int ec_hash_to_curve_p521_xmd_sha512_sswu_draft06(
|
||||
const EC_GROUP *group, EC_RAW_POINT *out, const uint8_t *dst,
|
||||
size_t dst_len, const uint8_t *msg, size_t msg_len) {
|
||||
// See section 8.3 of draft-irtf-cfrg-hash-to-curve-06.
|
||||
if (EC_GROUP_get_curve_name(group) != NID_secp521r1) {
|
||||
OPENSSL_PUT_ERROR(EC, EC_R_GROUP_MISMATCH);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Z = -4, c2 = 8.
|
||||
EC_FELEM Z, c2;
|
||||
if (!felem_from_u8(group, &Z, 4) ||
|
||||
!felem_from_u8(group, &c2, 8)) {
|
||||
return 0;
|
||||
}
|
||||
ec_felem_neg(group, &Z, &Z);
|
||||
|
||||
return hash_to_curve(group, EVP_sha512(), &Z, &c2, /*k=*/256, out, dst,
|
||||
dst_len, msg, msg_len, /*is_draft06=*/1);
|
||||
}
|
||||
|
||||
int ec_hash_to_scalar_p521_xmd_sha512_draft06(
|
||||
const EC_GROUP *group, EC_SCALAR *out, const uint8_t *dst, size_t dst_len,
|
||||
const uint8_t *msg, size_t msg_len) {
|
||||
if (EC_GROUP_get_curve_name(group) != NID_secp521r1) {
|
||||
OPENSSL_PUT_ERROR(EC, EC_R_GROUP_MISMATCH);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return hash_to_scalar(group, EVP_sha512(), out, dst, dst_len, /*k=*/256, msg,
|
||||
msg_len, /*is_draft06=*/1);
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/* Copyright (c) 2020, Google Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 OPENSSL_HEADER_EC_EXTRA_INTERNAL_H
|
||||
#define OPENSSL_HEADER_EC_EXTRA_INTERNAL_H
|
||||
|
||||
#include <CCryptoBoringSSL_ec.h>
|
||||
|
||||
#include "../fipsmodule/ec/internal.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
// Hash-to-curve.
|
||||
//
|
||||
// The following functions implement primitives from
|
||||
// draft-irtf-cfrg-hash-to-curve. The |dst| parameter in each function is the
|
||||
// domain separation tag and must be unique for each protocol and between the
|
||||
// |hash_to_curve| and |hash_to_scalar| variants. See section 3.1 of the spec
|
||||
// for additional guidance on this parameter.
|
||||
|
||||
// ec_hash_to_curve_p384_xmd_sha512_sswu_draft07 hashes |msg| to a point on
|
||||
// |group| and writes the result to |out|, implementing the
|
||||
// P384_XMD:SHA-512_SSWU_RO_ suite from draft-irtf-cfrg-hash-to-curve-07. It
|
||||
// returns one on success and zero on error.
|
||||
OPENSSL_EXPORT int ec_hash_to_curve_p384_xmd_sha512_sswu_draft07(
|
||||
const EC_GROUP *group, EC_RAW_POINT *out, const uint8_t *dst,
|
||||
size_t dst_len, const uint8_t *msg, size_t msg_len);
|
||||
|
||||
// ec_hash_to_scalar_p384_xmd_sha512_draft07 hashes |msg| to a scalar on |group|
|
||||
// and writes the result to |out|, using the hash_to_field operation from the
|
||||
// P384_XMD:SHA-512_SSWU_RO_ suite from draft-irtf-cfrg-hash-to-curve-07, but
|
||||
// generating a value modulo the group order rather than a field element.
|
||||
OPENSSL_EXPORT int ec_hash_to_scalar_p384_xmd_sha512_draft07(
|
||||
const EC_GROUP *group, EC_SCALAR *out, const uint8_t *dst, size_t dst_len,
|
||||
const uint8_t *msg, size_t msg_len);
|
||||
|
||||
// ec_hash_to_curve_p521_xmd_sha512_sswu_draft06 hashes |msg| to a point on
|
||||
// |group| and writes the result to |out|, implementing the
|
||||
// P521_XMD:SHA-512_SSWU_RO_ suite from draft-irtf-cfrg-hash-to-curve-06. It
|
||||
// returns one on success and zero on error.
|
||||
//
|
||||
// This function implements an older version of the draft and should not be used
|
||||
// in new code.
|
||||
OPENSSL_EXPORT int ec_hash_to_curve_p521_xmd_sha512_sswu_draft06(
|
||||
const EC_GROUP *group, EC_RAW_POINT *out, const uint8_t *dst,
|
||||
size_t dst_len, const uint8_t *msg, size_t msg_len);
|
||||
|
||||
// ec_hash_to_scalar_p521_xmd_sha512_draft06 hashes |msg| to a scalar on |group|
|
||||
// and writes the result to |out|, using the hash_to_field operation from the
|
||||
// P521_XMD:SHA-512_SSWU_RO_ suite from draft-irtf-cfrg-hash-to-curve-06, but
|
||||
// generating a value modulo the group order rather than a field element.
|
||||
//
|
||||
// This function implements an older version of the draft and should not be used
|
||||
// in new code.
|
||||
OPENSSL_EXPORT int ec_hash_to_scalar_p521_xmd_sha512_draft06(
|
||||
const EC_GROUP *group, EC_SCALAR *out, const uint8_t *dst, size_t dst_len,
|
||||
const uint8_t *msg, size_t msg_len);
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} // extern C
|
||||
#endif
|
||||
|
||||
#endif // OPENSSL_HEADER_EC_EXTRA_INTERNAL_H
|
||||
@@ -96,8 +96,8 @@ int ECDH_compute_key(void *out, size_t out_len, const EC_POINT *pub_key,
|
||||
uint8_t buf[EC_MAX_BYTES];
|
||||
size_t buf_len;
|
||||
if (!ec_point_mul_scalar(group, &shared_point, &pub_key->raw, priv) ||
|
||||
!ec_point_get_affine_coordinate_bytes(group, buf, NULL, &buf_len,
|
||||
sizeof(buf), &shared_point)) {
|
||||
!ec_get_x_coordinate_as_bytes(group, buf, &buf_len, sizeof(buf),
|
||||
&shared_point)) {
|
||||
OPENSSL_PUT_ERROR(ECDH, ECDH_R_POINT_ARITHMETIC_FAILURE);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -495,38 +495,39 @@ static const char *err_string_lookup(uint32_t lib, uint32_t key,
|
||||
|
||||
static const char *const kLibraryNames[ERR_NUM_LIBS] = {
|
||||
"invalid library (0)",
|
||||
"unknown library", // ERR_LIB_NONE
|
||||
"system library", // ERR_LIB_SYS
|
||||
"bignum routines", // ERR_LIB_BN
|
||||
"RSA routines", // ERR_LIB_RSA
|
||||
"Diffie-Hellman routines", // ERR_LIB_DH
|
||||
"public key routines", // ERR_LIB_EVP
|
||||
"memory buffer routines", // ERR_LIB_BUF
|
||||
"object identifier routines", // ERR_LIB_OBJ
|
||||
"PEM routines", // ERR_LIB_PEM
|
||||
"DSA routines", // ERR_LIB_DSA
|
||||
"X.509 certificate routines", // ERR_LIB_X509
|
||||
"ASN.1 encoding routines", // ERR_LIB_ASN1
|
||||
"configuration file routines", // ERR_LIB_CONF
|
||||
"common libcrypto routines", // ERR_LIB_CRYPTO
|
||||
"elliptic curve routines", // ERR_LIB_EC
|
||||
"SSL routines", // ERR_LIB_SSL
|
||||
"BIO routines", // ERR_LIB_BIO
|
||||
"PKCS7 routines", // ERR_LIB_PKCS7
|
||||
"PKCS8 routines", // ERR_LIB_PKCS8
|
||||
"X509 V3 routines", // ERR_LIB_X509V3
|
||||
"random number generator", // ERR_LIB_RAND
|
||||
"ENGINE routines", // ERR_LIB_ENGINE
|
||||
"OCSP routines", // ERR_LIB_OCSP
|
||||
"UI routines", // ERR_LIB_UI
|
||||
"COMP routines", // ERR_LIB_COMP
|
||||
"ECDSA routines", // ERR_LIB_ECDSA
|
||||
"ECDH routines", // ERR_LIB_ECDH
|
||||
"HMAC routines", // ERR_LIB_HMAC
|
||||
"Digest functions", // ERR_LIB_DIGEST
|
||||
"Cipher functions", // ERR_LIB_CIPHER
|
||||
"HKDF functions", // ERR_LIB_HKDF
|
||||
"User defined functions", // ERR_LIB_USER
|
||||
"unknown library", // ERR_LIB_NONE
|
||||
"system library", // ERR_LIB_SYS
|
||||
"bignum routines", // ERR_LIB_BN
|
||||
"RSA routines", // ERR_LIB_RSA
|
||||
"Diffie-Hellman routines", // ERR_LIB_DH
|
||||
"public key routines", // ERR_LIB_EVP
|
||||
"memory buffer routines", // ERR_LIB_BUF
|
||||
"object identifier routines", // ERR_LIB_OBJ
|
||||
"PEM routines", // ERR_LIB_PEM
|
||||
"DSA routines", // ERR_LIB_DSA
|
||||
"X.509 certificate routines", // ERR_LIB_X509
|
||||
"ASN.1 encoding routines", // ERR_LIB_ASN1
|
||||
"configuration file routines", // ERR_LIB_CONF
|
||||
"common libcrypto routines", // ERR_LIB_CRYPTO
|
||||
"elliptic curve routines", // ERR_LIB_EC
|
||||
"SSL routines", // ERR_LIB_SSL
|
||||
"BIO routines", // ERR_LIB_BIO
|
||||
"PKCS7 routines", // ERR_LIB_PKCS7
|
||||
"PKCS8 routines", // ERR_LIB_PKCS8
|
||||
"X509 V3 routines", // ERR_LIB_X509V3
|
||||
"random number generator", // ERR_LIB_RAND
|
||||
"ENGINE routines", // ERR_LIB_ENGINE
|
||||
"OCSP routines", // ERR_LIB_OCSP
|
||||
"UI routines", // ERR_LIB_UI
|
||||
"COMP routines", // ERR_LIB_COMP
|
||||
"ECDSA routines", // ERR_LIB_ECDSA
|
||||
"ECDH routines", // ERR_LIB_ECDH
|
||||
"HMAC routines", // ERR_LIB_HMAC
|
||||
"Digest functions", // ERR_LIB_DIGEST
|
||||
"Cipher functions", // ERR_LIB_CIPHER
|
||||
"HKDF functions", // ERR_LIB_HKDF
|
||||
"Trust Token functions", // ERR_LIB_TRUST_TOKEN
|
||||
"User defined functions", // ERR_LIB_USER
|
||||
};
|
||||
|
||||
const char *ERR_lib_error_string(uint32_t packed_error) {
|
||||
|
||||
@@ -50,8 +50,8 @@ OPENSSL_STATIC_ASSERT(ERR_LIB_HMAC == 28, "library value changed");
|
||||
OPENSSL_STATIC_ASSERT(ERR_LIB_DIGEST == 29, "library value changed");
|
||||
OPENSSL_STATIC_ASSERT(ERR_LIB_CIPHER == 30, "library value changed");
|
||||
OPENSSL_STATIC_ASSERT(ERR_LIB_HKDF == 31, "library value changed");
|
||||
OPENSSL_STATIC_ASSERT(ERR_LIB_USER == 32, "library value changed");
|
||||
OPENSSL_STATIC_ASSERT(ERR_LIB_TRUST_TOKEN == 33, "library value changed");
|
||||
OPENSSL_STATIC_ASSERT(ERR_LIB_TRUST_TOKEN == 32, "library value changed");
|
||||
OPENSSL_STATIC_ASSERT(ERR_LIB_USER == 33, "library value changed");
|
||||
OPENSSL_STATIC_ASSERT(ERR_NUM_LIBS == 34, "number of libraries changed");
|
||||
|
||||
const uint32_t kOpenSSLReasonValues[] = {
|
||||
@@ -191,44 +191,44 @@ const uint32_t kOpenSSLReasonValues[] = {
|
||||
0x283480ac,
|
||||
0x283500ea,
|
||||
0x28358c6c,
|
||||
0x2c322f1d,
|
||||
0x2c323012,
|
||||
0x2c3292e8,
|
||||
0x2c332f2b,
|
||||
0x2c33af3d,
|
||||
0x2c342f51,
|
||||
0x2c34af63,
|
||||
0x2c352f7e,
|
||||
0x2c35af90,
|
||||
0x2c362fa3,
|
||||
0x2c333020,
|
||||
0x2c33b032,
|
||||
0x2c343046,
|
||||
0x2c34b058,
|
||||
0x2c353073,
|
||||
0x2c35b085,
|
||||
0x2c363098,
|
||||
0x2c36832d,
|
||||
0x2c372fb0,
|
||||
0x2c37afc2,
|
||||
0x2c382fe7,
|
||||
0x2c38affe,
|
||||
0x2c39300c,
|
||||
0x2c39b01c,
|
||||
0x2c3a302e,
|
||||
0x2c3ab042,
|
||||
0x2c3b3053,
|
||||
0x2c3bb072,
|
||||
0x2c3730a5,
|
||||
0x2c37b0b7,
|
||||
0x2c3830dc,
|
||||
0x2c38b0f3,
|
||||
0x2c393101,
|
||||
0x2c39b111,
|
||||
0x2c3a3123,
|
||||
0x2c3ab137,
|
||||
0x2c3b3148,
|
||||
0x2c3bb167,
|
||||
0x2c3c12fa,
|
||||
0x2c3c9310,
|
||||
0x2c3d3086,
|
||||
0x2c3d317b,
|
||||
0x2c3d9329,
|
||||
0x2c3e30a3,
|
||||
0x2c3eb0b1,
|
||||
0x2c3f30c9,
|
||||
0x2c3fb0e1,
|
||||
0x2c40310b,
|
||||
0x2c3e3198,
|
||||
0x2c3eb1a6,
|
||||
0x2c3f31be,
|
||||
0x2c3fb1d6,
|
||||
0x2c403200,
|
||||
0x2c4091fb,
|
||||
0x2c41311c,
|
||||
0x2c41b12f,
|
||||
0x2c413211,
|
||||
0x2c41b224,
|
||||
0x2c4211c1,
|
||||
0x2c42b140,
|
||||
0x2c42b235,
|
||||
0x2c430722,
|
||||
0x2c43b064,
|
||||
0x2c442fd5,
|
||||
0x2c44b0ee,
|
||||
0x2c43b159,
|
||||
0x2c4430ca,
|
||||
0x2c44b1e3,
|
||||
0x30320000,
|
||||
0x30328015,
|
||||
0x3033001f,
|
||||
@@ -460,61 +460,61 @@ const uint32_t kOpenSSLReasonValues[] = {
|
||||
0x4061a454,
|
||||
0x4062246b,
|
||||
0x4062a47c,
|
||||
0x406324a1,
|
||||
0x4063a4b6,
|
||||
0x406424cd,
|
||||
0x4064a4f9,
|
||||
0x40652514,
|
||||
0x4065a52b,
|
||||
0x40662543,
|
||||
0x4066a56d,
|
||||
0x40672598,
|
||||
0x4067a5dd,
|
||||
0x40682625,
|
||||
0x4068a646,
|
||||
0x40692678,
|
||||
0x4069a6a6,
|
||||
0x406a26c7,
|
||||
0x406aa6e7,
|
||||
0x406b286f,
|
||||
0x406ba892,
|
||||
0x406c28a8,
|
||||
0x406cab4b,
|
||||
0x406d2b7a,
|
||||
0x406daba2,
|
||||
0x406e2bd0,
|
||||
0x406eac1d,
|
||||
0x406f2c58,
|
||||
0x406fac90,
|
||||
0x40702ca3,
|
||||
0x4070acc0,
|
||||
0x406324c9,
|
||||
0x4063a4de,
|
||||
0x406424f5,
|
||||
0x4064a521,
|
||||
0x4065253c,
|
||||
0x4065a553,
|
||||
0x4066256b,
|
||||
0x4066a595,
|
||||
0x406725c0,
|
||||
0x4067a605,
|
||||
0x4068264d,
|
||||
0x4068a66e,
|
||||
0x406926a0,
|
||||
0x4069a6ce,
|
||||
0x406a26ef,
|
||||
0x406aa70f,
|
||||
0x406b2897,
|
||||
0x406ba8ba,
|
||||
0x406c28d0,
|
||||
0x406cab73,
|
||||
0x406d2ba2,
|
||||
0x406dabca,
|
||||
0x406e2bf8,
|
||||
0x406eac45,
|
||||
0x406f2c80,
|
||||
0x406facb8,
|
||||
0x40702ccb,
|
||||
0x4070ace8,
|
||||
0x40710802,
|
||||
0x4071acd2,
|
||||
0x40722ce5,
|
||||
0x4072ad1b,
|
||||
0x40732d33,
|
||||
0x4071acfa,
|
||||
0x40722d0d,
|
||||
0x4072ad43,
|
||||
0x40732d5b,
|
||||
0x407394fa,
|
||||
0x40742d47,
|
||||
0x4074ad61,
|
||||
0x40752d72,
|
||||
0x4075ad86,
|
||||
0x40762d94,
|
||||
0x40742d6f,
|
||||
0x4074ad89,
|
||||
0x40752d9a,
|
||||
0x4075adae,
|
||||
0x40762dbc,
|
||||
0x407692be,
|
||||
0x40772db9,
|
||||
0x4077addb,
|
||||
0x40782df6,
|
||||
0x4078ae2f,
|
||||
0x40792e46,
|
||||
0x4079ae5c,
|
||||
0x407a2e88,
|
||||
0x407aae9b,
|
||||
0x407b2eb0,
|
||||
0x407baec2,
|
||||
0x407c2ef3,
|
||||
0x407caefc,
|
||||
0x407d2661,
|
||||
0x40772de1,
|
||||
0x4077ae03,
|
||||
0x40782e1e,
|
||||
0x4078ae57,
|
||||
0x40792e6e,
|
||||
0x4079ae84,
|
||||
0x407a2eb0,
|
||||
0x407aaec3,
|
||||
0x407b2ed8,
|
||||
0x407baeea,
|
||||
0x407c2f1b,
|
||||
0x407caf24,
|
||||
0x407d2689,
|
||||
0x407d9ff5,
|
||||
0x407e2e0b,
|
||||
0x407e2e33,
|
||||
0x407ea202,
|
||||
0x407f1d53,
|
||||
0x407f9e9f,
|
||||
@@ -522,83 +522,84 @@ const uint32_t kOpenSSLReasonValues[] = {
|
||||
0x40809d7b,
|
||||
0x408120a5,
|
||||
0x40819f89,
|
||||
0x40822bbb,
|
||||
0x40822be3,
|
||||
0x40829ae4,
|
||||
0x408321dd,
|
||||
0x4083a4de,
|
||||
0x4083a506,
|
||||
0x40841d8f,
|
||||
0x4084a23a,
|
||||
0x408522bf,
|
||||
0x4085a3e3,
|
||||
0x4086233f,
|
||||
0x4086a00f,
|
||||
0x40872c01,
|
||||
0x40872c29,
|
||||
0x4087a431,
|
||||
0x40881b22,
|
||||
0x4088a5f0,
|
||||
0x4088a618,
|
||||
0x40891b71,
|
||||
0x40899afe,
|
||||
0x408a28e0,
|
||||
0x408a2908,
|
||||
0x408a9912,
|
||||
0x408b2ed7,
|
||||
0x408bac6d,
|
||||
0x408b2eff,
|
||||
0x408bac95,
|
||||
0x408c22cf,
|
||||
0x408c992e,
|
||||
0x408d1df0,
|
||||
0x408d9dc1,
|
||||
0x408e1f20,
|
||||
0x408ea145,
|
||||
0x408f2604,
|
||||
0x408f262c,
|
||||
0x408fa3ff,
|
||||
0x409025b9,
|
||||
0x409025e1,
|
||||
0x4090a311,
|
||||
0x409128c8,
|
||||
0x409128f0,
|
||||
0x40919954,
|
||||
0x40921bbe,
|
||||
0x4092ac3c,
|
||||
0x40932cfe,
|
||||
0x4092ac64,
|
||||
0x40932d26,
|
||||
0x4093a020,
|
||||
0x40941da3,
|
||||
0x4094a8f9,
|
||||
0x4094a921,
|
||||
0x4095248d,
|
||||
0x4095ae68,
|
||||
0x40962be8,
|
||||
0x4095ae90,
|
||||
0x40962c10,
|
||||
0x40969fc8,
|
||||
0x4097206b,
|
||||
0x40979f6f,
|
||||
0x40981c1e,
|
||||
0x41f4279a,
|
||||
0x41f9282c,
|
||||
0x41fe271f,
|
||||
0x41fea93c,
|
||||
0x41ff2a2d,
|
||||
0x420327b3,
|
||||
0x420827d5,
|
||||
0x4208a811,
|
||||
0x42092703,
|
||||
0x4209a84b,
|
||||
0x420a275a,
|
||||
0x420aa73a,
|
||||
0x420b277a,
|
||||
0x420ba7f3,
|
||||
0x420c2a49,
|
||||
0x420ca909,
|
||||
0x420d2923,
|
||||
0x420da95a,
|
||||
0x42122974,
|
||||
0x42172a10,
|
||||
0x4217a9b6,
|
||||
0x421c29d8,
|
||||
0x421f2993,
|
||||
0x42212a60,
|
||||
0x422629f3,
|
||||
0x422b2b2f,
|
||||
0x422baadd,
|
||||
0x422c2b17,
|
||||
0x422caa9c,
|
||||
0x422d2a7b,
|
||||
0x422daafc,
|
||||
0x422e2ac2,
|
||||
0x4098a4a1,
|
||||
0x41f427c2,
|
||||
0x41f92854,
|
||||
0x41fe2747,
|
||||
0x41fea964,
|
||||
0x41ff2a55,
|
||||
0x420327db,
|
||||
0x420827fd,
|
||||
0x4208a839,
|
||||
0x4209272b,
|
||||
0x4209a873,
|
||||
0x420a2782,
|
||||
0x420aa762,
|
||||
0x420b27a2,
|
||||
0x420ba81b,
|
||||
0x420c2a71,
|
||||
0x420ca931,
|
||||
0x420d294b,
|
||||
0x420da982,
|
||||
0x4212299c,
|
||||
0x42172a38,
|
||||
0x4217a9de,
|
||||
0x421c2a00,
|
||||
0x421f29bb,
|
||||
0x42212a88,
|
||||
0x42262a1b,
|
||||
0x422b2b57,
|
||||
0x422bab05,
|
||||
0x422c2b3f,
|
||||
0x422caac4,
|
||||
0x422d2aa3,
|
||||
0x422dab24,
|
||||
0x422e2aea,
|
||||
0x4432072d,
|
||||
0x4432873c,
|
||||
0x44330748,
|
||||
@@ -653,69 +654,69 @@ const uint32_t kOpenSSLReasonValues[] = {
|
||||
0x4c411557,
|
||||
0x4c4193da,
|
||||
0x4c421543,
|
||||
0x50323152,
|
||||
0x5032b161,
|
||||
0x5033316c,
|
||||
0x5033b17c,
|
||||
0x50343195,
|
||||
0x5034b1af,
|
||||
0x503531bd,
|
||||
0x5035b1d3,
|
||||
0x503631e5,
|
||||
0x5036b1fb,
|
||||
0x50373214,
|
||||
0x5037b227,
|
||||
0x5038323f,
|
||||
0x5038b250,
|
||||
0x50393265,
|
||||
0x5039b279,
|
||||
0x503a3299,
|
||||
0x503ab2af,
|
||||
0x503b32c7,
|
||||
0x503bb2d9,
|
||||
0x503c32f5,
|
||||
0x503cb30c,
|
||||
0x503d3325,
|
||||
0x503db33b,
|
||||
0x503e3348,
|
||||
0x503eb35e,
|
||||
0x503f3370,
|
||||
0x50323247,
|
||||
0x5032b256,
|
||||
0x50333261,
|
||||
0x5033b271,
|
||||
0x5034328a,
|
||||
0x5034b2a4,
|
||||
0x503532b2,
|
||||
0x5035b2c8,
|
||||
0x503632da,
|
||||
0x5036b2f0,
|
||||
0x50373309,
|
||||
0x5037b31c,
|
||||
0x50383334,
|
||||
0x5038b345,
|
||||
0x5039335a,
|
||||
0x5039b36e,
|
||||
0x503a338e,
|
||||
0x503ab3a4,
|
||||
0x503b33bc,
|
||||
0x503bb3ce,
|
||||
0x503c33ea,
|
||||
0x503cb401,
|
||||
0x503d341a,
|
||||
0x503db430,
|
||||
0x503e343d,
|
||||
0x503eb453,
|
||||
0x503f3465,
|
||||
0x503f837b,
|
||||
0x50403383,
|
||||
0x5040b393,
|
||||
0x504133ad,
|
||||
0x5041b3bc,
|
||||
0x504233d6,
|
||||
0x5042b3f3,
|
||||
0x50433403,
|
||||
0x5043b413,
|
||||
0x50443422,
|
||||
0x50403478,
|
||||
0x5040b488,
|
||||
0x504134a2,
|
||||
0x5041b4b1,
|
||||
0x504234cb,
|
||||
0x5042b4e8,
|
||||
0x504334f8,
|
||||
0x5043b508,
|
||||
0x50443517,
|
||||
0x50448431,
|
||||
0x50453436,
|
||||
0x5045b454,
|
||||
0x50463467,
|
||||
0x5046b47d,
|
||||
0x5047348f,
|
||||
0x5047b4a4,
|
||||
0x504834ca,
|
||||
0x5048b4d8,
|
||||
0x504934eb,
|
||||
0x5049b500,
|
||||
0x504a3516,
|
||||
0x504ab526,
|
||||
0x504b3546,
|
||||
0x504bb559,
|
||||
0x504c357c,
|
||||
0x504cb5aa,
|
||||
0x504d35bc,
|
||||
0x504db5d9,
|
||||
0x504e35f4,
|
||||
0x504eb610,
|
||||
0x504f3622,
|
||||
0x504fb639,
|
||||
0x50503648,
|
||||
0x5045352b,
|
||||
0x5045b549,
|
||||
0x5046355c,
|
||||
0x5046b572,
|
||||
0x50473584,
|
||||
0x5047b599,
|
||||
0x504835bf,
|
||||
0x5048b5cd,
|
||||
0x504935e0,
|
||||
0x5049b5f5,
|
||||
0x504a360b,
|
||||
0x504ab61b,
|
||||
0x504b363b,
|
||||
0x504bb64e,
|
||||
0x504c3671,
|
||||
0x504cb69f,
|
||||
0x504d36b1,
|
||||
0x504db6ce,
|
||||
0x504e36e9,
|
||||
0x504eb705,
|
||||
0x504f3717,
|
||||
0x504fb72e,
|
||||
0x5050373d,
|
||||
0x505086f1,
|
||||
0x5051365b,
|
||||
0x50513750,
|
||||
0x58320f65,
|
||||
0x68320f27,
|
||||
0x68328c7f,
|
||||
@@ -757,8 +758,21 @@ const uint32_t kOpenSSLReasonValues[] = {
|
||||
0x783e0aa2,
|
||||
0x783e8a54,
|
||||
0x7c3211d7,
|
||||
0x843213ed,
|
||||
0x84328083,
|
||||
0x803213ed,
|
||||
0x80328083,
|
||||
0x80332fe1,
|
||||
0x803380ac,
|
||||
0x80342ff0,
|
||||
0x8034af58,
|
||||
0x80352f76,
|
||||
0x8035b004,
|
||||
0x80362fb8,
|
||||
0x8036af67,
|
||||
0x80372faa,
|
||||
0x8037af45,
|
||||
0x80382fcb,
|
||||
0x8038af87,
|
||||
0x80392f9c,
|
||||
};
|
||||
|
||||
const size_t kOpenSSLReasonValuesLen = sizeof(kOpenSSLReasonValues) / sizeof(kOpenSSLReasonValues[0]);
|
||||
@@ -1220,6 +1234,7 @@ const char kOpenSSLReasonStringData[] =
|
||||
"PSK_NO_CLIENT_CB\0"
|
||||
"PSK_NO_SERVER_CB\0"
|
||||
"QUIC_INTERNAL_ERROR\0"
|
||||
"QUIC_TRANSPORT_PARAMETERS_MISCONFIGURED\0"
|
||||
"READ_TIMEOUT_EXPIRED\0"
|
||||
"RECORD_LENGTH_MISMATCH\0"
|
||||
"RECORD_TOO_LARGE\0"
|
||||
@@ -1318,6 +1333,18 @@ const char kOpenSSLReasonStringData[] =
|
||||
"WRONG_VERSION_ON_EARLY_DATA\0"
|
||||
"X509_LIB\0"
|
||||
"X509_VERIFICATION_SETUP_PROBLEMS\0"
|
||||
"BAD_VALIDITY_CHECK\0"
|
||||
"DECODE_FAILURE\0"
|
||||
"INVALID_KEY_ID\0"
|
||||
"INVALID_METADATA\0"
|
||||
"INVALID_METADATA_KEY\0"
|
||||
"INVALID_PROOF\0"
|
||||
"INVALID_TOKEN\0"
|
||||
"NO_KEYS_CONFIGURED\0"
|
||||
"NO_SRR_KEY_CONFIGURED\0"
|
||||
"OVER_BATCHSIZE\0"
|
||||
"SRR_SIGNATURE_ERROR\0"
|
||||
"TOO_MANY_KEYS\0"
|
||||
"AKID_MISMATCH\0"
|
||||
"BAD_X509_FILETYPE\0"
|
||||
"BASE64_DECODE_ERROR\0"
|
||||
|
||||
@@ -57,7 +57,23 @@
|
||||
void AES_ctr128_encrypt(const uint8_t *in, uint8_t *out, size_t len,
|
||||
const AES_KEY *key, uint8_t ivec[AES_BLOCK_SIZE],
|
||||
uint8_t ecount_buf[AES_BLOCK_SIZE], unsigned int *num) {
|
||||
CRYPTO_ctr128_encrypt(in, out, len, key, ivec, ecount_buf, num, AES_encrypt);
|
||||
if (hwaes_capable()) {
|
||||
CRYPTO_ctr128_encrypt_ctr32(in, out, len, key, ivec, ecount_buf, num,
|
||||
aes_hw_ctr32_encrypt_blocks);
|
||||
} else if (vpaes_capable()) {
|
||||
#if defined(VPAES_CTR32)
|
||||
// TODO(davidben): On ARM, where |BSAES| is additionally defined, this could
|
||||
// use |vpaes_ctr32_encrypt_blocks_with_bsaes|.
|
||||
CRYPTO_ctr128_encrypt_ctr32(in, out, len, key, ivec, ecount_buf, num,
|
||||
vpaes_ctr32_encrypt_blocks);
|
||||
#else
|
||||
CRYPTO_ctr128_encrypt(in, out, len, key, ivec, ecount_buf, num,
|
||||
vpaes_encrypt);
|
||||
#endif
|
||||
} else {
|
||||
CRYPTO_ctr128_encrypt_ctr32(in, out, len, key, ivec, ecount_buf, num,
|
||||
aes_nohw_ctr32_encrypt_blocks);
|
||||
}
|
||||
}
|
||||
|
||||
void AES_ecb_encrypt(const uint8_t *in, uint8_t *out, const AES_KEY *key,
|
||||
|
||||
@@ -732,7 +732,7 @@ void bn_mod_exp_mont_small(BN_ULONG *r, const BN_ULONG *a, size_t num,
|
||||
num_p--;
|
||||
}
|
||||
if (num_p == 0) {
|
||||
bn_from_montgomery_small(r, mont->RR.d, num, mont);
|
||||
bn_from_montgomery_small(r, num, mont->RR.d, num, mont);
|
||||
return;
|
||||
}
|
||||
unsigned bits = BN_num_bits_word(p[num_p - 1]) + (num_p - 1) * BN_BITS2;
|
||||
@@ -809,8 +809,8 @@ void bn_mod_exp_mont_small(BN_ULONG *r, const BN_ULONG *a, size_t num,
|
||||
OPENSSL_cleanse(val, sizeof(val));
|
||||
}
|
||||
|
||||
void bn_mod_inverse_prime_mont_small(BN_ULONG *r, const BN_ULONG *a, size_t num,
|
||||
const BN_MONT_CTX *mont) {
|
||||
void bn_mod_inverse0_prime_mont_small(BN_ULONG *r, const BN_ULONG *a,
|
||||
size_t num, const BN_MONT_CTX *mont) {
|
||||
if (num != (size_t)mont->N.width || num > BN_SMALL_MAX_WORDS) {
|
||||
abort();
|
||||
}
|
||||
|
||||
@@ -647,10 +647,13 @@ void bn_to_montgomery_small(BN_ULONG *r, const BN_ULONG *a, size_t num,
|
||||
const BN_MONT_CTX *mont);
|
||||
|
||||
// bn_from_montgomery_small sets |r| to |a| translated out of the Montgomery
|
||||
// domain. |r| and |a| are |num| words long, which must be |mont->N.width|. |a|
|
||||
// must be fully-reduced and may alias |r|.
|
||||
void bn_from_montgomery_small(BN_ULONG *r, const BN_ULONG *a, size_t num,
|
||||
const BN_MONT_CTX *mont);
|
||||
// domain. |r| and |a| are |num_r| and |num_a| words long, respectively. |num_r|
|
||||
// must be |mont->N.width|. |a| must be at most |mont->N|^2 and may alias |r|.
|
||||
//
|
||||
// Unlike most of these functions, only |num_r| is bounded by
|
||||
// |BN_SMALL_MAX_WORDS|. |num_a| may exceed it, but must be at most 2 * |num_r|.
|
||||
void bn_from_montgomery_small(BN_ULONG *r, size_t num_r, const BN_ULONG *a,
|
||||
size_t num_a, const BN_MONT_CTX *mont);
|
||||
|
||||
// bn_mod_mul_montgomery_small sets |r| to |a| * |b| mod |mont->N|. Both inputs
|
||||
// and outputs are in the Montgomery domain. Each array is |num| words long,
|
||||
@@ -675,13 +678,13 @@ void bn_mod_exp_mont_small(BN_ULONG *r, const BN_ULONG *a, size_t num,
|
||||
const BN_ULONG *p, size_t num_p,
|
||||
const BN_MONT_CTX *mont);
|
||||
|
||||
// bn_mod_inverse_prime_mont_small sets |r| to |a|^-1 mod |mont->N|. |mont->N|
|
||||
// must be a prime. |r| and |a| are |num| words long, which must be
|
||||
// |mont->N.width| and at most |BN_SMALL_MAX_WORDS|. |a| must be fully-reduced
|
||||
// and may alias |r|. This function runs in time independent of |a|, but
|
||||
// |mont->N| is a public value.
|
||||
void bn_mod_inverse_prime_mont_small(BN_ULONG *r, const BN_ULONG *a, size_t num,
|
||||
const BN_MONT_CTX *mont);
|
||||
// bn_mod_inverse0_prime_mont_small sets |r| to |a|^-1 mod |mont->N|. If |a| is
|
||||
// zero, |r| is set to zero. |mont->N| must be a prime. |r| and |a| are |num|
|
||||
// words long, which must be |mont->N.width| and at most |BN_SMALL_MAX_WORDS|.
|
||||
// |a| must be fully-reduced and may alias |r|. This function runs in time
|
||||
// independent of |a|, but |mont->N| is a public value.
|
||||
void bn_mod_inverse0_prime_mont_small(BN_ULONG *r, const BN_ULONG *a,
|
||||
size_t num, const BN_MONT_CTX *mont);
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
@@ -455,18 +455,18 @@ void bn_to_montgomery_small(BN_ULONG *r, const BN_ULONG *a, size_t num,
|
||||
bn_mod_mul_montgomery_small(r, a, mont->RR.d, num, mont);
|
||||
}
|
||||
|
||||
void bn_from_montgomery_small(BN_ULONG *r, const BN_ULONG *a, size_t num,
|
||||
const BN_MONT_CTX *mont) {
|
||||
if (num != (size_t)mont->N.width || num > BN_SMALL_MAX_WORDS) {
|
||||
void bn_from_montgomery_small(BN_ULONG *r, size_t num_r, const BN_ULONG *a,
|
||||
size_t num_a, const BN_MONT_CTX *mont) {
|
||||
if (num_r != (size_t)mont->N.width || num_r > BN_SMALL_MAX_WORDS ||
|
||||
num_a > 2 * num_r) {
|
||||
abort();
|
||||
}
|
||||
BN_ULONG tmp[BN_SMALL_MAX_WORDS * 2];
|
||||
OPENSSL_memcpy(tmp, a, num * sizeof(BN_ULONG));
|
||||
OPENSSL_memset(tmp + num, 0, num * sizeof(BN_ULONG));
|
||||
if (!bn_from_montgomery_in_place(r, num, tmp, 2 * num, mont)) {
|
||||
BN_ULONG tmp[BN_SMALL_MAX_WORDS * 2] = {0};
|
||||
OPENSSL_memcpy(tmp, a, num_a * sizeof(BN_ULONG));
|
||||
if (!bn_from_montgomery_in_place(r, num_r, tmp, 2 * num_r, mont)) {
|
||||
abort();
|
||||
}
|
||||
OPENSSL_cleanse(tmp, 2 * num * sizeof(BN_ULONG));
|
||||
OPENSSL_cleanse(tmp, 2 * num_r * sizeof(BN_ULONG));
|
||||
}
|
||||
|
||||
void bn_mod_mul_montgomery_small(BN_ULONG *r, const BN_ULONG *a,
|
||||
|
||||
@@ -119,23 +119,20 @@ static void bn_mul_normal(BN_ULONG *r, const BN_ULONG *a, size_t na,
|
||||
}
|
||||
}
|
||||
|
||||
// Here follows specialised variants of bn_add_words() and bn_sub_words(). They
|
||||
// have the property performing operations on arrays of different sizes. The
|
||||
// sizes of those arrays is expressed through cl, which is the common length (
|
||||
// basicall, min(len(a),len(b)) ), and dl, which is the delta between the two
|
||||
// lengths, calculated as len(a)-len(b). All lengths are the number of
|
||||
// BN_ULONGs... For the operations that require a result array as parameter,
|
||||
// it must have the length cl+abs(dl).
|
||||
|
||||
// bn_sub_part_words sets |r| to |a| - |b|. It returns the borrow bit, which is
|
||||
// one if the operation underflowed and zero otherwise. |cl| is the common
|
||||
// length, that is, the shorter of len(a) or len(b). |dl| is the delta length,
|
||||
// that is, len(a) - len(b). |r|'s length matches the larger of |a| and |b|, or
|
||||
// cl + abs(dl).
|
||||
//
|
||||
// TODO(davidben): Make this take |size_t|. The |cl| + |dl| calling convention
|
||||
// is confusing.
|
||||
static BN_ULONG bn_sub_part_words(BN_ULONG *r, const BN_ULONG *a,
|
||||
const BN_ULONG *b, int cl, int dl) {
|
||||
BN_ULONG c, t;
|
||||
|
||||
assert(cl >= 0);
|
||||
c = bn_sub_words(r, a, b, cl);
|
||||
|
||||
BN_ULONG borrow = bn_sub_words(r, a, b, cl);
|
||||
if (dl == 0) {
|
||||
return c;
|
||||
return borrow;
|
||||
}
|
||||
|
||||
r += cl;
|
||||
@@ -143,141 +140,25 @@ static BN_ULONG bn_sub_part_words(BN_ULONG *r, const BN_ULONG *a,
|
||||
b += cl;
|
||||
|
||||
if (dl < 0) {
|
||||
for (;;) {
|
||||
t = b[0];
|
||||
r[0] = 0 - t - c;
|
||||
if (t != 0) {
|
||||
c = 1;
|
||||
}
|
||||
if (++dl >= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
t = b[1];
|
||||
r[1] = 0 - t - c;
|
||||
if (t != 0) {
|
||||
c = 1;
|
||||
}
|
||||
if (++dl >= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
t = b[2];
|
||||
r[2] = 0 - t - c;
|
||||
if (t != 0) {
|
||||
c = 1;
|
||||
}
|
||||
if (++dl >= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
t = b[3];
|
||||
r[3] = 0 - t - c;
|
||||
if (t != 0) {
|
||||
c = 1;
|
||||
}
|
||||
if (++dl >= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
b += 4;
|
||||
r += 4;
|
||||
// |a| is shorter than |b|. Complete the subtraction as if the excess words
|
||||
// in |a| were zeros.
|
||||
dl = -dl;
|
||||
for (int i = 0; i < dl; i++) {
|
||||
r[i] = 0u - b[i] - borrow;
|
||||
borrow |= r[i] != 0;
|
||||
}
|
||||
} else {
|
||||
int save_dl = dl;
|
||||
while (c) {
|
||||
t = a[0];
|
||||
r[0] = t - c;
|
||||
if (t != 0) {
|
||||
c = 0;
|
||||
}
|
||||
if (--dl <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
t = a[1];
|
||||
r[1] = t - c;
|
||||
if (t != 0) {
|
||||
c = 0;
|
||||
}
|
||||
if (--dl <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
t = a[2];
|
||||
r[2] = t - c;
|
||||
if (t != 0) {
|
||||
c = 0;
|
||||
}
|
||||
if (--dl <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
t = a[3];
|
||||
r[3] = t - c;
|
||||
if (t != 0) {
|
||||
c = 0;
|
||||
}
|
||||
if (--dl <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
save_dl = dl;
|
||||
a += 4;
|
||||
r += 4;
|
||||
}
|
||||
if (dl > 0) {
|
||||
if (save_dl > dl) {
|
||||
switch (save_dl - dl) {
|
||||
case 1:
|
||||
r[1] = a[1];
|
||||
if (--dl <= 0) {
|
||||
break;
|
||||
}
|
||||
OPENSSL_FALLTHROUGH;
|
||||
case 2:
|
||||
r[2] = a[2];
|
||||
if (--dl <= 0) {
|
||||
break;
|
||||
}
|
||||
OPENSSL_FALLTHROUGH;
|
||||
case 3:
|
||||
r[3] = a[3];
|
||||
if (--dl <= 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
a += 4;
|
||||
r += 4;
|
||||
}
|
||||
}
|
||||
|
||||
if (dl > 0) {
|
||||
for (;;) {
|
||||
r[0] = a[0];
|
||||
if (--dl <= 0) {
|
||||
break;
|
||||
}
|
||||
r[1] = a[1];
|
||||
if (--dl <= 0) {
|
||||
break;
|
||||
}
|
||||
r[2] = a[2];
|
||||
if (--dl <= 0) {
|
||||
break;
|
||||
}
|
||||
r[3] = a[3];
|
||||
if (--dl <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
a += 4;
|
||||
r += 4;
|
||||
}
|
||||
// |b| is shorter than |a|. Complete the subtraction as if the excess words
|
||||
// in |b| were zeros.
|
||||
for (int i = 0; i < dl; i++) {
|
||||
// |r| and |a| may alias, so use a temporary.
|
||||
BN_ULONG tmp = a[i];
|
||||
r[i] = a[i] - borrow;
|
||||
borrow = tmp < r[i];
|
||||
}
|
||||
}
|
||||
|
||||
return c;
|
||||
return borrow;
|
||||
}
|
||||
|
||||
// bn_abs_sub_part_words computes |r| = |a| - |b|, storing the absolute value
|
||||
@@ -574,7 +455,7 @@ static int bn_mul_impl(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
static const int kMulNormalSize = 16;
|
||||
if (al >= kMulNormalSize && bl >= kMulNormalSize) {
|
||||
if (-1 <= i && i <= 1) {
|
||||
// Find the larger power of two less than or equal to the larger length.
|
||||
// Find the largest power of two less than or equal to the larger length.
|
||||
int j;
|
||||
if (i >= 0) {
|
||||
j = BN_num_bits_word((BN_ULONG)al);
|
||||
@@ -590,6 +471,10 @@ static int bn_mul_impl(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
if (al > j || bl > j) {
|
||||
// We know |al| and |bl| are at most one from each other, so if al > j,
|
||||
// bl >= j, and vice versa. Thus we can use |bn_mul_part_recursive|.
|
||||
//
|
||||
// TODO(davidben): This codepath is almost unused in standard
|
||||
// algorithms. Is this optimization necessary? See notes in
|
||||
// https://boringssl-review.googlesource.com/q/I0bd604e2cd6a75c266f64476c23a730ca1721ea6
|
||||
assert(al >= j && bl >= j);
|
||||
if (!bn_wexpand(t, j * 8) ||
|
||||
!bn_wexpand(rr, j * 4)) {
|
||||
|
||||
@@ -243,6 +243,22 @@ DEFINE_METHOD_FUNCTION(EVP_MD, EVP_sha512) {
|
||||
}
|
||||
|
||||
|
||||
static void sha512_256_init(EVP_MD_CTX *ctx) {
|
||||
CHECK(SHA512_256_Init(ctx->md_data));
|
||||
}
|
||||
|
||||
DEFINE_METHOD_FUNCTION(EVP_MD, EVP_sha512_256) {
|
||||
out->type = NID_sha512_256;
|
||||
out->md_size = SHA512_256_DIGEST_LENGTH;
|
||||
out->flags = 0;
|
||||
out->init = sha512_256_init;
|
||||
out->update = sha512_update;
|
||||
out->final = sha512_final;
|
||||
out->block_size = 128;
|
||||
out->ctx_size = sizeof(SHA512_CTX);
|
||||
}
|
||||
|
||||
|
||||
typedef struct {
|
||||
MD5_CTX md5;
|
||||
SHA_CTX sha1;
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
static void ec_point_free(EC_POINT *point, int free_group);
|
||||
|
||||
static const uint8_t kP224Params[6 * 28] = {
|
||||
// p
|
||||
// p = 2^224 - 2^96 + 1
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x01,
|
||||
@@ -111,7 +111,7 @@ static const uint8_t kP224Params[6 * 28] = {
|
||||
};
|
||||
|
||||
static const uint8_t kP256Params[6 * 32] = {
|
||||
// p
|
||||
// p = 2^256 - 2^224 + 2^192 + 2^96 - 1
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
@@ -138,7 +138,7 @@ static const uint8_t kP256Params[6 * 32] = {
|
||||
};
|
||||
|
||||
static const uint8_t kP384Params[6 * 48] = {
|
||||
// p
|
||||
// p = 2^384 - 2^128 - 2^96 + 2^32 - 1
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
@@ -171,7 +171,7 @@ static const uint8_t kP384Params[6 * 48] = {
|
||||
};
|
||||
|
||||
static const uint8_t kP521Params[6 * 66] = {
|
||||
// p
|
||||
// p = 2^521 - 1
|
||||
0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
@@ -301,17 +301,49 @@ EC_GROUP *ec_group_new(const EC_METHOD *meth) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void ec_group_set0_generator(EC_GROUP *group, EC_POINT *generator) {
|
||||
static int ec_group_set_generator(EC_GROUP *group, const EC_AFFINE *generator,
|
||||
const BIGNUM *order) {
|
||||
assert(group->generator == NULL);
|
||||
assert(group == generator->group);
|
||||
|
||||
if (!BN_copy(&group->order, order)) {
|
||||
return 0;
|
||||
}
|
||||
// Store the order in minimal form, so it can be used with |BN_ULONG| arrays.
|
||||
bn_set_minimal_width(&group->order);
|
||||
|
||||
BN_MONT_CTX_free(group->order_mont);
|
||||
group->order_mont = BN_MONT_CTX_new_for_modulus(&group->order, NULL);
|
||||
if (group->order_mont == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
group->field_greater_than_order = BN_cmp(&group->field, order) > 0;
|
||||
if (group->field_greater_than_order) {
|
||||
BIGNUM tmp;
|
||||
BN_init(&tmp);
|
||||
int ok =
|
||||
BN_sub(&tmp, &group->field, order) &&
|
||||
bn_copy_words(group->field_minus_order.words, group->field.width, &tmp);
|
||||
BN_free(&tmp);
|
||||
if (!ok) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
group->generator = EC_POINT_new(group);
|
||||
if (group->generator == NULL) {
|
||||
return 0;
|
||||
}
|
||||
ec_affine_to_jacobian(group, &group->generator->raw, generator);
|
||||
assert(ec_felem_equal(group, &group->one, &group->generator->raw.Z));
|
||||
|
||||
// Avoid a reference cycle. |group->generator| does not maintain an owning
|
||||
// pointer to |group|.
|
||||
group->generator = generator;
|
||||
int is_zero = CRYPTO_refcount_dec_and_test_zero(&group->references);
|
||||
|
||||
assert(!is_zero);
|
||||
(void)is_zero;
|
||||
return 1;
|
||||
}
|
||||
|
||||
EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a,
|
||||
@@ -321,20 +353,37 @@ EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EC_GROUP *ret = ec_group_new(EC_GFp_mont_method());
|
||||
if (ret == NULL) {
|
||||
return NULL;
|
||||
BN_CTX *new_ctx = NULL;
|
||||
if (ctx == NULL) {
|
||||
ctx = new_ctx = BN_CTX_new();
|
||||
if (ctx == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (ret->meth->group_set_curve == NULL) {
|
||||
OPENSSL_PUT_ERROR(EC, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
||||
EC_GROUP_free(ret);
|
||||
return NULL;
|
||||
// Historically, |a| and |b| were not required to be fully reduced.
|
||||
// TODO(davidben): Can this be removed?
|
||||
EC_GROUP *ret = NULL;
|
||||
BN_CTX_start(ctx);
|
||||
BIGNUM *a_reduced = BN_CTX_get(ctx);
|
||||
BIGNUM *b_reduced = BN_CTX_get(ctx);
|
||||
if (a_reduced == NULL || b_reduced == NULL ||
|
||||
!BN_nnmod(a_reduced, a, p, ctx) ||
|
||||
!BN_nnmod(b_reduced, b, p, ctx)) {
|
||||
goto err;
|
||||
}
|
||||
if (!ret->meth->group_set_curve(ret, p, a, b, ctx)) {
|
||||
|
||||
ret = ec_group_new(EC_GFp_mont_method());
|
||||
if (ret == NULL ||
|
||||
!ret->meth->group_set_curve(ret, p, a_reduced, b_reduced, ctx)) {
|
||||
EC_GROUP_free(ret);
|
||||
return NULL;
|
||||
ret = NULL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
BN_CTX_free(new_ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -367,7 +416,6 @@ int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator,
|
||||
// tiny prime (less than 17). See the proof in |field_element_to_scalar| in
|
||||
// the ECDSA implementation.
|
||||
int ret = 0;
|
||||
EC_POINT *copy = NULL;
|
||||
BIGNUM *tmp = BN_new();
|
||||
if (tmp == NULL ||
|
||||
!BN_lshift1(tmp, order)) {
|
||||
@@ -378,44 +426,22 @@ int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator,
|
||||
goto err;
|
||||
}
|
||||
|
||||
copy = EC_POINT_new(group);
|
||||
if (copy == NULL ||
|
||||
!EC_POINT_copy(copy, generator) ||
|
||||
!BN_copy(&group->order, order)) {
|
||||
goto err;
|
||||
}
|
||||
// Store the order in minimal form, so it can be used with |BN_ULONG| arrays.
|
||||
bn_set_minimal_width(&group->order);
|
||||
|
||||
BN_MONT_CTX_free(group->order_mont);
|
||||
group->order_mont = BN_MONT_CTX_new_for_modulus(&group->order, NULL);
|
||||
if (group->order_mont == NULL) {
|
||||
EC_AFFINE affine;
|
||||
if (!ec_jacobian_to_affine(group, &affine, &generator->raw) ||
|
||||
!ec_group_set_generator(group, &affine, order)) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
group->field_greater_than_order = BN_cmp(&group->field, &group->order) > 0;
|
||||
if (group->field_greater_than_order) {
|
||||
if (!BN_sub(tmp, &group->field, &group->order) ||
|
||||
!bn_copy_words(group->field_minus_order.words, group->field.width,
|
||||
tmp)) {
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
ec_group_set0_generator(group, copy);
|
||||
copy = NULL;
|
||||
ret = 1;
|
||||
|
||||
err:
|
||||
EC_POINT_free(copy);
|
||||
BN_free(tmp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static EC_GROUP *ec_group_new_from_data(const struct built_in_curve *curve) {
|
||||
EC_GROUP *group = NULL;
|
||||
EC_POINT *P = NULL;
|
||||
BIGNUM *p = NULL, *a = NULL, *b = NULL, *x = NULL, *y = NULL;
|
||||
BIGNUM *p = NULL, *a = NULL, *b = NULL, *order = NULL;
|
||||
int ok = 0;
|
||||
|
||||
BN_CTX *ctx = BN_CTX_new();
|
||||
@@ -429,7 +455,8 @@ static EC_GROUP *ec_group_new_from_data(const struct built_in_curve *curve) {
|
||||
|
||||
if (!(p = BN_bin2bn(params + 0 * param_len, param_len, NULL)) ||
|
||||
!(a = BN_bin2bn(params + 1 * param_len, param_len, NULL)) ||
|
||||
!(b = BN_bin2bn(params + 2 * param_len, param_len, NULL))) {
|
||||
!(b = BN_bin2bn(params + 2 * param_len, param_len, NULL)) ||
|
||||
!(order = BN_bin2bn(params + 5 * param_len, param_len, NULL))) {
|
||||
OPENSSL_PUT_ERROR(EC, ERR_R_BN_LIB);
|
||||
goto err;
|
||||
}
|
||||
@@ -441,42 +468,18 @@ static EC_GROUP *ec_group_new_from_data(const struct built_in_curve *curve) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
if ((P = EC_POINT_new(group)) == NULL) {
|
||||
OPENSSL_PUT_ERROR(EC, ERR_R_EC_LIB);
|
||||
EC_AFFINE G;
|
||||
EC_FELEM x, y;
|
||||
if (!ec_felem_from_bytes(group, &x, params + 3 * param_len, param_len) ||
|
||||
!ec_felem_from_bytes(group, &y, params + 4 * param_len, param_len) ||
|
||||
!ec_point_set_affine_coordinates(group, &G, &x, &y)) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!(x = BN_bin2bn(params + 3 * param_len, param_len, NULL)) ||
|
||||
!(y = BN_bin2bn(params + 4 * param_len, param_len, NULL))) {
|
||||
OPENSSL_PUT_ERROR(EC, ERR_R_BN_LIB);
|
||||
if (!ec_group_set_generator(group, &G, order)) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!EC_POINT_set_affine_coordinates_GFp(group, P, x, y, ctx)) {
|
||||
OPENSSL_PUT_ERROR(EC, ERR_R_EC_LIB);
|
||||
goto err;
|
||||
}
|
||||
if (!BN_bin2bn(params + 5 * param_len, param_len, &group->order)) {
|
||||
OPENSSL_PUT_ERROR(EC, ERR_R_BN_LIB);
|
||||
goto err;
|
||||
}
|
||||
|
||||
group->field_greater_than_order = BN_cmp(&group->field, &group->order) > 0;
|
||||
if (group->field_greater_than_order) {
|
||||
if (!BN_sub(p, &group->field, &group->order) ||
|
||||
!bn_copy_words(group->field_minus_order.words, group->field.width, p)) {
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
group->order_mont = BN_MONT_CTX_new_for_modulus(&group->order, ctx);
|
||||
if (group->order_mont == NULL) {
|
||||
OPENSSL_PUT_ERROR(EC, ERR_R_BN_LIB);
|
||||
goto err;
|
||||
}
|
||||
|
||||
ec_group_set0_generator(group, P);
|
||||
P = NULL;
|
||||
ok = 1;
|
||||
|
||||
err:
|
||||
@@ -484,13 +487,11 @@ err:
|
||||
EC_GROUP_free(group);
|
||||
group = NULL;
|
||||
}
|
||||
EC_POINT_free(P);
|
||||
BN_CTX_free(ctx);
|
||||
BN_free(p);
|
||||
BN_free(a);
|
||||
BN_free(b);
|
||||
BN_free(x);
|
||||
BN_free(y);
|
||||
BN_free(order);
|
||||
return group;
|
||||
}
|
||||
|
||||
@@ -606,7 +607,7 @@ int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ignored) {
|
||||
BN_cmp(&a->field, &b->field) != 0 ||
|
||||
!ec_felem_equal(a, &a->a, &b->a) ||
|
||||
!ec_felem_equal(a, &a->b, &b->b) ||
|
||||
ec_GFp_simple_cmp(a, &a->generator->raw, &b->generator->raw) != 0;
|
||||
!ec_GFp_simple_points_equal(a, &a->generator->raw, &b->generator->raw);
|
||||
}
|
||||
|
||||
const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group) {
|
||||
@@ -769,7 +770,9 @@ int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b,
|
||||
OPENSSL_PUT_ERROR(EC, EC_R_INCOMPATIBLE_OBJECTS);
|
||||
return -1;
|
||||
}
|
||||
return ec_GFp_simple_cmp(group, &a->raw, &b->raw);
|
||||
|
||||
// Note |EC_POINT_cmp| returns zero for equality and non-zero for inequality.
|
||||
return ec_GFp_simple_points_equal(group, &a->raw, &b->raw) ? 0 : 1;
|
||||
}
|
||||
|
||||
int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,
|
||||
@@ -787,13 +790,67 @@ int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,
|
||||
if (!group->meth->point_get_affine_coordinates(group, &point->raw,
|
||||
x == NULL ? NULL : &x_felem,
|
||||
y == NULL ? NULL : &y_felem) ||
|
||||
(x != NULL && !bn_set_words(x, x_felem.words, group->field.width)) ||
|
||||
(y != NULL && !bn_set_words(y, y_felem.words, group->field.width))) {
|
||||
(x != NULL && !ec_felem_to_bignum(group, x, &x_felem)) ||
|
||||
(y != NULL && !ec_felem_to_bignum(group, y, &y_felem))) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ec_affine_to_jacobian(const EC_GROUP *group, EC_RAW_POINT *out,
|
||||
const EC_AFFINE *p) {
|
||||
out->X = p->X;
|
||||
out->Y = p->Y;
|
||||
out->Z = group->one;
|
||||
}
|
||||
|
||||
int ec_jacobian_to_affine(const EC_GROUP *group, EC_AFFINE *out,
|
||||
const EC_RAW_POINT *p) {
|
||||
return group->meth->point_get_affine_coordinates(group, p, &out->X, &out->Y);
|
||||
}
|
||||
|
||||
int ec_jacobian_to_affine_batch(const EC_GROUP *group, EC_AFFINE *out,
|
||||
const EC_RAW_POINT *in, size_t num) {
|
||||
if (group->meth->jacobian_to_affine_batch == NULL) {
|
||||
OPENSSL_PUT_ERROR(EC, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
||||
return 0;
|
||||
}
|
||||
return group->meth->jacobian_to_affine_batch(group, out, in, num);
|
||||
}
|
||||
|
||||
int ec_point_set_affine_coordinates(const EC_GROUP *group, EC_AFFINE *out,
|
||||
const EC_FELEM *x, const EC_FELEM *y) {
|
||||
void (*const felem_mul)(const EC_GROUP *, EC_FELEM *r, const EC_FELEM *a,
|
||||
const EC_FELEM *b) = group->meth->felem_mul;
|
||||
void (*const felem_sqr)(const EC_GROUP *, EC_FELEM *r, const EC_FELEM *a) =
|
||||
group->meth->felem_sqr;
|
||||
|
||||
// Check if the point is on the curve.
|
||||
EC_FELEM lhs, rhs;
|
||||
felem_sqr(group, &lhs, y); // lhs = y^2
|
||||
felem_sqr(group, &rhs, x); // rhs = x^2
|
||||
ec_felem_add(group, &rhs, &rhs, &group->a); // rhs = x^2 + a
|
||||
felem_mul(group, &rhs, &rhs, x); // rhs = x^3 + ax
|
||||
ec_felem_add(group, &rhs, &rhs, &group->b); // rhs = x^3 + ax + b
|
||||
if (!ec_felem_equal(group, &lhs, &rhs)) {
|
||||
OPENSSL_PUT_ERROR(EC, EC_R_POINT_IS_NOT_ON_CURVE);
|
||||
// In the event of an error, defend against the caller not checking the
|
||||
// return value by setting a known safe value. Note this may not be possible
|
||||
// if the caller is in the process of constructing an arbitrary group and
|
||||
// the generator is missing.
|
||||
if (group->generator != NULL) {
|
||||
assert(ec_felem_equal(group, &group->one, &group->generator->raw.Z));
|
||||
out->X = group->generator->raw.X;
|
||||
out->Y = group->generator->raw.Y;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
out->X = *x;
|
||||
out->Y = *y;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *point,
|
||||
const BIGNUM *x, const BIGNUM *y,
|
||||
BN_CTX *ctx) {
|
||||
@@ -801,24 +858,24 @@ int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *point,
|
||||
OPENSSL_PUT_ERROR(EC, EC_R_INCOMPATIBLE_OBJECTS);
|
||||
return 0;
|
||||
}
|
||||
if (!ec_GFp_simple_point_set_affine_coordinates(group, &point->raw, x, y)) {
|
||||
|
||||
if (x == NULL || y == NULL) {
|
||||
OPENSSL_PUT_ERROR(EC, ERR_R_PASSED_NULL_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!EC_POINT_is_on_curve(group, point, ctx)) {
|
||||
EC_FELEM x_felem, y_felem;
|
||||
EC_AFFINE affine;
|
||||
if (!ec_bignum_to_felem(group, &x_felem, x) ||
|
||||
!ec_bignum_to_felem(group, &y_felem, y) ||
|
||||
!ec_point_set_affine_coordinates(group, &affine, &x_felem, &y_felem)) {
|
||||
// In the event of an error, defend against the caller not checking the
|
||||
// return value by setting a known safe value: the base point.
|
||||
const EC_POINT *generator = EC_GROUP_get0_generator(group);
|
||||
// The generator can be missing if the caller is in the process of
|
||||
// constructing an arbitrary group. In this, we give up and hope they're
|
||||
// checking the return value.
|
||||
if (generator) {
|
||||
ec_GFp_simple_point_copy(&point->raw, &generator->raw);
|
||||
}
|
||||
OPENSSL_PUT_ERROR(EC, EC_R_POINT_IS_NOT_ON_CURVE);
|
||||
// return value by setting a known safe value.
|
||||
ec_set_to_safe_point(group, &point->raw);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ec_affine_to_jacobian(group, &point->raw, &affine);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -949,10 +1006,27 @@ int ec_point_mul_scalar_public(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (group->meth->mul_public == NULL) {
|
||||
return group->meth->mul_public_batch(group, r, g_scalar, p, p_scalar, 1);
|
||||
}
|
||||
|
||||
group->meth->mul_public(group, r, g_scalar, p, p_scalar);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ec_point_mul_scalar_public_batch(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
const EC_SCALAR *g_scalar,
|
||||
const EC_RAW_POINT *points,
|
||||
const EC_SCALAR *scalars, size_t num) {
|
||||
if (group->meth->mul_public_batch == NULL) {
|
||||
OPENSSL_PUT_ERROR(EC, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return group->meth->mul_public_batch(group, r, g_scalar, points, scalars,
|
||||
num);
|
||||
}
|
||||
|
||||
int ec_point_mul_scalar(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
const EC_RAW_POINT *p, const EC_SCALAR *scalar) {
|
||||
if (p == NULL || scalar == NULL) {
|
||||
@@ -961,6 +1035,14 @@ int ec_point_mul_scalar(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
}
|
||||
|
||||
group->meth->mul(group, r, p, scalar);
|
||||
|
||||
// Check the result is on the curve to defend against fault attacks or bugs.
|
||||
// This has negligible cost compared to the multiplication.
|
||||
if (!ec_GFp_simple_is_on_curve(group, r)) {
|
||||
OPENSSL_PUT_ERROR(EC, ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -972,9 +1054,93 @@ int ec_point_mul_scalar_base(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
}
|
||||
|
||||
group->meth->mul_base(group, r, scalar);
|
||||
|
||||
// Check the result is on the curve to defend against fault attacks or bugs.
|
||||
// This has negligible cost compared to the multiplication.
|
||||
if (!ec_GFp_simple_is_on_curve(group, r)) {
|
||||
OPENSSL_PUT_ERROR(EC, ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ec_point_mul_scalar_batch(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
const EC_RAW_POINT *p0, const EC_SCALAR *scalar0,
|
||||
const EC_RAW_POINT *p1, const EC_SCALAR *scalar1,
|
||||
const EC_RAW_POINT *p2,
|
||||
const EC_SCALAR *scalar2) {
|
||||
if (group->meth->mul_batch == NULL) {
|
||||
OPENSSL_PUT_ERROR(EC, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
group->meth->mul_batch(group, r, p0, scalar0, p1, scalar1, p2, scalar2);
|
||||
|
||||
// Check the result is on the curve to defend against fault attacks or bugs.
|
||||
// This has negligible cost compared to the multiplication.
|
||||
if (!ec_GFp_simple_is_on_curve(group, r)) {
|
||||
OPENSSL_PUT_ERROR(EC, ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ec_init_precomp(const EC_GROUP *group, EC_PRECOMP *out,
|
||||
const EC_RAW_POINT *p) {
|
||||
if (group->meth->init_precomp == NULL) {
|
||||
OPENSSL_PUT_ERROR(EC, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return group->meth->init_precomp(group, out, p);
|
||||
}
|
||||
|
||||
int ec_point_mul_scalar_precomp(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
const EC_PRECOMP *p0, const EC_SCALAR *scalar0,
|
||||
const EC_PRECOMP *p1, const EC_SCALAR *scalar1,
|
||||
const EC_PRECOMP *p2,
|
||||
const EC_SCALAR *scalar2) {
|
||||
if (group->meth->mul_precomp == NULL) {
|
||||
OPENSSL_PUT_ERROR(EC, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
group->meth->mul_precomp(group, r, p0, scalar0, p1, scalar1, p2, scalar2);
|
||||
|
||||
// Check the result is on the curve to defend against fault attacks or bugs.
|
||||
// This has negligible cost compared to the multiplication.
|
||||
if (!ec_GFp_simple_is_on_curve(group, r)) {
|
||||
OPENSSL_PUT_ERROR(EC, ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ec_point_select(const EC_GROUP *group, EC_RAW_POINT *out, BN_ULONG mask,
|
||||
const EC_RAW_POINT *a, const EC_RAW_POINT *b) {
|
||||
ec_felem_select(group, &out->X, mask, &a->X, &b->X);
|
||||
ec_felem_select(group, &out->Y, mask, &a->Y, &b->Y);
|
||||
ec_felem_select(group, &out->Z, mask, &a->Z, &b->Z);
|
||||
}
|
||||
|
||||
void ec_affine_select(const EC_GROUP *group, EC_AFFINE *out, BN_ULONG mask,
|
||||
const EC_AFFINE *a, const EC_AFFINE *b) {
|
||||
ec_felem_select(group, &out->X, mask, &a->X, &b->X);
|
||||
ec_felem_select(group, &out->Y, mask, &a->Y, &b->Y);
|
||||
}
|
||||
|
||||
void ec_precomp_select(const EC_GROUP *group, EC_PRECOMP *out, BN_ULONG mask,
|
||||
const EC_PRECOMP *a, const EC_PRECOMP *b) {
|
||||
OPENSSL_STATIC_ASSERT(sizeof(out->comb) == sizeof(*out),
|
||||
"out->comb does not span the entire structure");
|
||||
for (size_t i = 0; i < OPENSSL_ARRAY_SIZE(out->comb); i++) {
|
||||
ec_affine_select(group, &out->comb[i], mask, &a->comb[i], &b->comb[i]);
|
||||
}
|
||||
}
|
||||
|
||||
int ec_cmp_x_coordinate(const EC_GROUP *group, const EC_RAW_POINT *p,
|
||||
const EC_SCALAR *r) {
|
||||
return group->meth->cmp_x_coordinate(group, p, r);
|
||||
@@ -982,14 +1148,19 @@ int ec_cmp_x_coordinate(const EC_GROUP *group, const EC_RAW_POINT *p,
|
||||
|
||||
int ec_get_x_coordinate_as_scalar(const EC_GROUP *group, EC_SCALAR *out,
|
||||
const EC_RAW_POINT *p) {
|
||||
EC_FELEM x;
|
||||
// For simplicity, in case of width mismatches between |group->field| and
|
||||
// |group->order|, zero any untouched words in |x|.
|
||||
OPENSSL_memset(&x, 0, sizeof(x));
|
||||
if (!group->meth->point_get_affine_coordinates(group, p, &x, NULL)) {
|
||||
uint8_t bytes[EC_MAX_BYTES];
|
||||
size_t len;
|
||||
if (!ec_get_x_coordinate_as_bytes(group, bytes, &len, sizeof(bytes), p)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// For simplicity, in case of width mismatches between |group->field| and
|
||||
// |group->order|, zero any untouched words in |out|.
|
||||
OPENSSL_memset(out, 0, sizeof(EC_SCALAR));
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
out->bytes[len - i - 1] = bytes[i];
|
||||
}
|
||||
|
||||
// We must have p < 2×order, assuming p is not tiny (p >= 17). Thus rather we
|
||||
// can reduce by performing at most one subtraction.
|
||||
//
|
||||
@@ -1008,17 +1179,17 @@ int ec_get_x_coordinate_as_scalar(const EC_GROUP *group, EC_SCALAR *out,
|
||||
|
||||
// The above does not guarantee |group->field| is not one word larger than
|
||||
// |group->order|, so read one extra carry word.
|
||||
BN_ULONG tmp[EC_MAX_WORDS];
|
||||
BN_ULONG carry =
|
||||
group->order.width < EC_MAX_WORDS ? x.words[group->order.width] : 0;
|
||||
bn_reduce_once(out->words, x.words, carry, group->order.d,
|
||||
group->order.width);
|
||||
group->order.width < EC_MAX_WORDS ? out->words[group->order.width] : 0;
|
||||
bn_reduce_once_in_place(out->words, carry, group->order.d, tmp,
|
||||
group->order.width);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ec_point_get_affine_coordinate_bytes(const EC_GROUP *group, uint8_t *out_x,
|
||||
uint8_t *out_y, size_t *out_len,
|
||||
size_t max_out,
|
||||
const EC_RAW_POINT *p) {
|
||||
int ec_get_x_coordinate_as_bytes(const EC_GROUP *group, uint8_t *out,
|
||||
size_t *out_len, size_t max_out,
|
||||
const EC_RAW_POINT *p) {
|
||||
size_t len = BN_num_bytes(&group->field);
|
||||
assert(len <= EC_MAX_BYTES);
|
||||
if (max_out < len) {
|
||||
@@ -1026,26 +1197,27 @@ int ec_point_get_affine_coordinate_bytes(const EC_GROUP *group, uint8_t *out_x,
|
||||
return 0;
|
||||
}
|
||||
|
||||
EC_FELEM x, y;
|
||||
if (!group->meth->point_get_affine_coordinates(
|
||||
group, p, out_x == NULL ? NULL : &x, out_y == NULL ? NULL : &y)) {
|
||||
EC_FELEM x;
|
||||
if (!group->meth->point_get_affine_coordinates(group, p, &x, NULL)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (out_x != NULL) {
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
out_x[i] = x.bytes[len - i - 1];
|
||||
}
|
||||
}
|
||||
if (out_y != NULL) {
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
out_y[i] = y.bytes[len - i - 1];
|
||||
}
|
||||
}
|
||||
ec_felem_to_bytes(group, out, out_len, &x);
|
||||
*out_len = len;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ec_set_to_safe_point(const EC_GROUP *group, EC_RAW_POINT *out) {
|
||||
if (group->generator != NULL) {
|
||||
ec_GFp_simple_point_copy(out, &group->generator->raw);
|
||||
} else {
|
||||
// The generator can be missing if the caller is in the process of
|
||||
// constructing an arbitrary group. In this case, we give up and use the
|
||||
// point at infinity.
|
||||
ec_GFp_simple_point_set_to_infinity(group, out);
|
||||
}
|
||||
}
|
||||
|
||||
void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag) {}
|
||||
|
||||
const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group) {
|
||||
|
||||
@@ -292,10 +292,6 @@ void EC_KEY_set_conv_form(EC_KEY *key, point_conversion_form_t cform) {
|
||||
}
|
||||
|
||||
int EC_KEY_check_key(const EC_KEY *eckey) {
|
||||
int ok = 0;
|
||||
BN_CTX *ctx = NULL;
|
||||
EC_POINT *point = NULL;
|
||||
|
||||
if (!eckey || !eckey->group || !eckey->pub_key) {
|
||||
OPENSSL_PUT_ERROR(EC, ERR_R_PASSED_NULL_PARAMETER);
|
||||
return 0;
|
||||
@@ -303,41 +299,31 @@ int EC_KEY_check_key(const EC_KEY *eckey) {
|
||||
|
||||
if (EC_POINT_is_at_infinity(eckey->group, eckey->pub_key)) {
|
||||
OPENSSL_PUT_ERROR(EC, EC_R_POINT_AT_INFINITY);
|
||||
goto err;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ctx = BN_CTX_new();
|
||||
|
||||
if (ctx == NULL) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
// testing whether the pub_key is on the elliptic curve
|
||||
if (!EC_POINT_is_on_curve(eckey->group, eckey->pub_key, ctx)) {
|
||||
// Test whether the public key is on the elliptic curve.
|
||||
if (!EC_POINT_is_on_curve(eckey->group, eckey->pub_key, NULL)) {
|
||||
OPENSSL_PUT_ERROR(EC, EC_R_POINT_IS_NOT_ON_CURVE);
|
||||
goto err;
|
||||
return 0;
|
||||
}
|
||||
// in case the priv_key is present :
|
||||
// check if generator * priv_key == pub_key
|
||||
|
||||
// Check the public and private keys match.
|
||||
if (eckey->priv_key != NULL) {
|
||||
point = EC_POINT_new(eckey->group);
|
||||
if (point == NULL ||
|
||||
!ec_point_mul_scalar_base(eckey->group, &point->raw,
|
||||
EC_RAW_POINT point;
|
||||
if (!ec_point_mul_scalar_base(eckey->group, &point,
|
||||
&eckey->priv_key->scalar)) {
|
||||
OPENSSL_PUT_ERROR(EC, ERR_R_EC_LIB);
|
||||
goto err;
|
||||
return 0;
|
||||
}
|
||||
if (EC_POINT_cmp(eckey->group, point, eckey->pub_key, ctx) != 0) {
|
||||
if (!ec_GFp_simple_points_equal(eckey->group, &point,
|
||||
&eckey->pub_key->raw)) {
|
||||
OPENSSL_PUT_ERROR(EC, EC_R_INVALID_PRIVATE_KEY);
|
||||
goto err;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
ok = 1;
|
||||
|
||||
err:
|
||||
BN_CTX_free(ctx);
|
||||
EC_POINT_free(point);
|
||||
return ok;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int EC_KEY_check_fips(const EC_KEY *key) {
|
||||
|
||||
@@ -92,35 +92,20 @@ void ec_GFp_mont_group_finish(EC_GROUP *group) {
|
||||
|
||||
int ec_GFp_mont_group_set_curve(EC_GROUP *group, const BIGNUM *p,
|
||||
const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) {
|
||||
BN_CTX *new_ctx = NULL;
|
||||
int ret = 0;
|
||||
|
||||
BN_MONT_CTX_free(group->mont);
|
||||
group->mont = NULL;
|
||||
|
||||
if (ctx == NULL) {
|
||||
ctx = new_ctx = BN_CTX_new();
|
||||
if (ctx == NULL) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
group->mont = BN_MONT_CTX_new_for_modulus(p, ctx);
|
||||
if (group->mont == NULL) {
|
||||
OPENSSL_PUT_ERROR(EC, ERR_R_BN_LIB);
|
||||
goto err;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = ec_GFp_simple_group_set_curve(group, p, a, b, ctx);
|
||||
|
||||
if (!ret) {
|
||||
if (!ec_GFp_simple_group_set_curve(group, p, a, b, ctx)) {
|
||||
BN_MONT_CTX_free(group->mont);
|
||||
group->mont = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
err:
|
||||
BN_CTX_free(new_ctx);
|
||||
return ret;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void ec_GFp_mont_felem_to_montgomery(const EC_GROUP *group,
|
||||
@@ -132,14 +117,14 @@ static void ec_GFp_mont_felem_to_montgomery(const EC_GROUP *group,
|
||||
static void ec_GFp_mont_felem_from_montgomery(const EC_GROUP *group,
|
||||
EC_FELEM *out,
|
||||
const EC_FELEM *in) {
|
||||
bn_from_montgomery_small(out->words, in->words, group->field.width,
|
||||
group->mont);
|
||||
bn_from_montgomery_small(out->words, group->field.width, in->words,
|
||||
group->field.width, group->mont);
|
||||
}
|
||||
|
||||
static void ec_GFp_mont_felem_inv(const EC_GROUP *group, EC_FELEM *out,
|
||||
const EC_FELEM *a) {
|
||||
bn_mod_inverse_prime_mont_small(out->words, a->words, group->field.width,
|
||||
group->mont);
|
||||
static void ec_GFp_mont_felem_inv0(const EC_GROUP *group, EC_FELEM *out,
|
||||
const EC_FELEM *a) {
|
||||
bn_mod_inverse0_prime_mont_small(out->words, a->words, group->field.width,
|
||||
group->mont);
|
||||
}
|
||||
|
||||
void ec_GFp_mont_felem_mul(const EC_GROUP *group, EC_FELEM *r,
|
||||
@@ -154,30 +139,39 @@ void ec_GFp_mont_felem_sqr(const EC_GROUP *group, EC_FELEM *r,
|
||||
group->mont);
|
||||
}
|
||||
|
||||
int ec_GFp_mont_bignum_to_felem(const EC_GROUP *group, EC_FELEM *out,
|
||||
const BIGNUM *in) {
|
||||
if (group->mont == NULL) {
|
||||
OPENSSL_PUT_ERROR(EC, EC_R_NOT_INITIALIZED);
|
||||
void ec_GFp_mont_felem_to_bytes(const EC_GROUP *group, uint8_t *out,
|
||||
size_t *out_len, const EC_FELEM *in) {
|
||||
EC_FELEM tmp;
|
||||
ec_GFp_mont_felem_from_montgomery(group, &tmp, in);
|
||||
ec_GFp_simple_felem_to_bytes(group, out, out_len, &tmp);
|
||||
}
|
||||
|
||||
int ec_GFp_mont_felem_from_bytes(const EC_GROUP *group, EC_FELEM *out,
|
||||
const uint8_t *in, size_t len) {
|
||||
if (!ec_GFp_simple_felem_from_bytes(group, out, in, len)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!bn_copy_words(out->words, group->field.width, in)) {
|
||||
return 0;
|
||||
}
|
||||
ec_GFp_mont_felem_to_montgomery(group, out, out);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ec_GFp_mont_felem_to_bignum(const EC_GROUP *group, BIGNUM *out,
|
||||
const EC_FELEM *in) {
|
||||
if (group->mont == NULL) {
|
||||
OPENSSL_PUT_ERROR(EC, EC_R_NOT_INITIALIZED);
|
||||
return 0;
|
||||
}
|
||||
static void ec_GFp_mont_felem_reduce(const EC_GROUP *group, EC_FELEM *out,
|
||||
const BN_ULONG *words, size_t num) {
|
||||
// Convert "from" Montgomery form so the value is reduced mod p.
|
||||
bn_from_montgomery_small(out->words, group->field.width, words, num,
|
||||
group->mont);
|
||||
// Convert "to" Montgomery form to remove the R^-1 factor added.
|
||||
ec_GFp_mont_felem_to_montgomery(group, out, out);
|
||||
// Convert to Montgomery form to match this implementation's representation.
|
||||
ec_GFp_mont_felem_to_montgomery(group, out, out);
|
||||
}
|
||||
|
||||
EC_FELEM tmp;
|
||||
ec_GFp_mont_felem_from_montgomery(group, &tmp, in);
|
||||
return bn_set_words(out, tmp.words, group->field.width);
|
||||
static void ec_GFp_mont_felem_exp(const EC_GROUP *group, EC_FELEM *out,
|
||||
const EC_FELEM *a, const BN_ULONG *exp,
|
||||
size_t num_exp) {
|
||||
bn_mod_exp_mont_small(out->words, a->words, group->field.width, exp, num_exp,
|
||||
group->mont);
|
||||
}
|
||||
|
||||
static int ec_GFp_mont_point_get_affine_coordinates(const EC_GROUP *group,
|
||||
@@ -188,18 +182,12 @@ static int ec_GFp_mont_point_get_affine_coordinates(const EC_GROUP *group,
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Transform (X, Y, Z) into (x, y) := (X/Z^2, Y/Z^3).
|
||||
|
||||
// Transform (X, Y, Z) into (x, y) := (X/Z^2, Y/Z^3). Note the check above
|
||||
// ensures |point->Z| is non-zero, so the inverse always exists.
|
||||
EC_FELEM z1, z2;
|
||||
ec_GFp_mont_felem_inv(group, &z2, &point->Z);
|
||||
ec_GFp_mont_felem_inv0(group, &z2, &point->Z);
|
||||
ec_GFp_mont_felem_sqr(group, &z1, &z2);
|
||||
|
||||
// Instead of using |ec_GFp_mont_felem_from_montgomery| to convert the |x|
|
||||
// coordinate and then calling |ec_GFp_mont_felem_from_montgomery| again to
|
||||
// convert the |y| coordinate below, convert the common factor |z1| once now,
|
||||
// saving one reduction.
|
||||
ec_GFp_mont_felem_from_montgomery(group, &z1, &z1);
|
||||
|
||||
if (x != NULL) {
|
||||
ec_GFp_mont_felem_mul(group, x, &point->X, &z1);
|
||||
}
|
||||
@@ -212,6 +200,52 @@ static int ec_GFp_mont_point_get_affine_coordinates(const EC_GROUP *group,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ec_GFp_mont_jacobian_to_affine_batch(const EC_GROUP *group,
|
||||
EC_AFFINE *out,
|
||||
const EC_RAW_POINT *in,
|
||||
size_t num) {
|
||||
if (num == 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Compute prefix products of all Zs. Use |out[i].X| as scratch space
|
||||
// to store these values.
|
||||
out[0].X = in[0].Z;
|
||||
for (size_t i = 1; i < num; i++) {
|
||||
ec_GFp_mont_felem_mul(group, &out[i].X, &out[i - 1].X, &in[i].Z);
|
||||
}
|
||||
|
||||
// Some input was infinity iff the product of all Zs is zero.
|
||||
if (ec_felem_non_zero_mask(group, &out[num - 1].X) == 0) {
|
||||
OPENSSL_PUT_ERROR(EC, EC_R_POINT_AT_INFINITY);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Invert the product of all Zs.
|
||||
EC_FELEM zinvprod;
|
||||
ec_GFp_mont_felem_inv0(group, &zinvprod, &out[num - 1].X);
|
||||
for (size_t i = num - 1; i < num; i--) {
|
||||
// Our loop invariant is that |zinvprod| is Z0^-1 * Z1^-1 * ... * Zi^-1.
|
||||
// Recover Zi^-1 by multiplying by the previous product.
|
||||
EC_FELEM zinv, zinv2;
|
||||
if (i == 0) {
|
||||
zinv = zinvprod;
|
||||
} else {
|
||||
ec_GFp_mont_felem_mul(group, &zinv, &zinvprod, &out[i - 1].X);
|
||||
// Maintain the loop invariant for the next iteration.
|
||||
ec_GFp_mont_felem_mul(group, &zinvprod, &zinvprod, &in[i].Z);
|
||||
}
|
||||
|
||||
// Compute affine coordinates: x = X * Z^-2 and y = Y * Z^-3.
|
||||
ec_GFp_mont_felem_sqr(group, &zinv2, &zinv);
|
||||
ec_GFp_mont_felem_mul(group, &out[i].X, &in[i].X, &zinv2);
|
||||
ec_GFp_mont_felem_mul(group, &out[i].Y, &in[i].Y, &zinv2);
|
||||
ec_GFp_mont_felem_mul(group, &out[i].Y, &out[i].Y, &zinv);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ec_GFp_mont_add(const EC_GROUP *group, EC_RAW_POINT *out,
|
||||
const EC_RAW_POINT *a, const EC_RAW_POINT *b) {
|
||||
if (a == b) {
|
||||
@@ -468,16 +502,23 @@ DEFINE_METHOD_FUNCTION(EC_METHOD, EC_GFp_mont_method) {
|
||||
out->group_finish = ec_GFp_mont_group_finish;
|
||||
out->group_set_curve = ec_GFp_mont_group_set_curve;
|
||||
out->point_get_affine_coordinates = ec_GFp_mont_point_get_affine_coordinates;
|
||||
out->jacobian_to_affine_batch = ec_GFp_mont_jacobian_to_affine_batch;
|
||||
out->add = ec_GFp_mont_add;
|
||||
out->dbl = ec_GFp_mont_dbl;
|
||||
out->mul = ec_GFp_mont_mul;
|
||||
out->mul_base = ec_GFp_mont_mul_base;
|
||||
out->mul_public = ec_GFp_mont_mul_public;
|
||||
out->mul_batch = ec_GFp_mont_mul_batch;
|
||||
out->mul_public_batch = ec_GFp_mont_mul_public_batch;
|
||||
out->init_precomp = ec_GFp_mont_init_precomp;
|
||||
out->mul_precomp = ec_GFp_mont_mul_precomp;
|
||||
out->felem_mul = ec_GFp_mont_felem_mul;
|
||||
out->felem_sqr = ec_GFp_mont_felem_sqr;
|
||||
out->bignum_to_felem = ec_GFp_mont_bignum_to_felem;
|
||||
out->felem_to_bignum = ec_GFp_mont_felem_to_bignum;
|
||||
out->scalar_inv_montgomery = ec_simple_scalar_inv_montgomery;
|
||||
out->scalar_inv_montgomery_vartime = ec_GFp_simple_mont_inv_mod_ord_vartime;
|
||||
out->felem_to_bytes = ec_GFp_mont_felem_to_bytes;
|
||||
out->felem_from_bytes = ec_GFp_mont_felem_from_bytes;
|
||||
out->felem_reduce = ec_GFp_mont_felem_reduce;
|
||||
out->felem_exp = ec_GFp_mont_felem_exp;
|
||||
out->scalar_inv0_montgomery = ec_simple_scalar_inv0_montgomery;
|
||||
out->scalar_to_montgomery_inv_vartime =
|
||||
ec_simple_scalar_to_montgomery_inv_vartime;
|
||||
out->cmp_x_coordinate = ec_GFp_mont_cmp_x_coordinate;
|
||||
}
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include <CCryptoBoringSSL_ec.h>
|
||||
#include <CCryptoBoringSSL_err.h>
|
||||
#include <CCryptoBoringSSL_mem.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
@@ -23,15 +24,34 @@
|
||||
|
||||
|
||||
int ec_bignum_to_felem(const EC_GROUP *group, EC_FELEM *out, const BIGNUM *in) {
|
||||
if (BN_is_negative(in) || BN_cmp(in, &group->field) >= 0) {
|
||||
uint8_t bytes[EC_MAX_BYTES];
|
||||
size_t len = BN_num_bytes(&group->field);
|
||||
assert(sizeof(bytes) >= len);
|
||||
if (BN_is_negative(in) ||
|
||||
BN_cmp(in, &group->field) >= 0 ||
|
||||
!BN_bn2bin_padded(bytes, len, in)) {
|
||||
OPENSSL_PUT_ERROR(EC, EC_R_COORDINATES_OUT_OF_RANGE);
|
||||
return 0;
|
||||
}
|
||||
return group->meth->bignum_to_felem(group, out, in);
|
||||
|
||||
return ec_felem_from_bytes(group, out, bytes, len);
|
||||
}
|
||||
|
||||
int ec_felem_to_bignum(const EC_GROUP *group, BIGNUM *out, const EC_FELEM *in) {
|
||||
return group->meth->felem_to_bignum(group, out, in);
|
||||
uint8_t bytes[EC_MAX_BYTES];
|
||||
size_t len;
|
||||
ec_felem_to_bytes(group, bytes, &len, in);
|
||||
return BN_bin2bn(bytes, len, out) != NULL;
|
||||
}
|
||||
|
||||
void ec_felem_to_bytes(const EC_GROUP *group, uint8_t *out, size_t *out_len,
|
||||
const EC_FELEM *in) {
|
||||
group->meth->felem_to_bytes(group, out, out_len, in);
|
||||
}
|
||||
|
||||
int ec_felem_from_bytes(const EC_GROUP *group, EC_FELEM *out, const uint8_t *in,
|
||||
size_t len) {
|
||||
return group->meth->felem_from_bytes(group, out, in, len);
|
||||
}
|
||||
|
||||
void ec_felem_neg(const EC_GROUP *group, EC_FELEM *out, const EC_FELEM *a) {
|
||||
@@ -75,8 +95,6 @@ void ec_felem_select(const EC_GROUP *group, EC_FELEM *out, BN_ULONG mask,
|
||||
|
||||
int ec_felem_equal(const EC_GROUP *group, const EC_FELEM *a,
|
||||
const EC_FELEM *b) {
|
||||
// Note this function is variable-time. Constant-time operations should use
|
||||
// |ec_felem_non_zero_mask|.
|
||||
return OPENSSL_memcmp(a->words, b->words,
|
||||
group->field.width * sizeof(BN_ULONG)) == 0;
|
||||
return CRYPTO_memcmp(a->words, b->words,
|
||||
group->field.width * sizeof(BN_ULONG)) == 0;
|
||||
}
|
||||
@@ -71,8 +71,8 @@
|
||||
#include <CCryptoBoringSSL_base.h>
|
||||
|
||||
#include <CCryptoBoringSSL_bn.h>
|
||||
#include <CCryptoBoringSSL_ec.h>
|
||||
#include <CCryptoBoringSSL_ex_data.h>
|
||||
#include <CCryptoBoringSSL_thread.h>
|
||||
#include <CCryptoBoringSSL_type_check.h>
|
||||
|
||||
#include "../bn/internal.h"
|
||||
@@ -82,6 +82,9 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
// EC internals.
|
||||
|
||||
|
||||
// Cap the size of all field elements and scalars, including custom curves, to
|
||||
// 66 bytes, large enough to fit secp521r1 and brainpoolP512r1, which appear to
|
||||
// be the largest fields anyone plausibly uses.
|
||||
@@ -91,6 +94,9 @@ extern "C" {
|
||||
OPENSSL_STATIC_ASSERT(EC_MAX_WORDS <= BN_SMALL_MAX_WORDS,
|
||||
"bn_*_small functions not usable");
|
||||
|
||||
|
||||
// Scalars.
|
||||
|
||||
// An EC_SCALAR is an integer fully reduced modulo the order. Only the first
|
||||
// |order->width| words are used. An |EC_SCALAR| is specific to an |EC_GROUP|
|
||||
// and must not be mixed between groups.
|
||||
@@ -100,6 +106,88 @@ typedef union {
|
||||
BN_ULONG words[EC_MAX_WORDS];
|
||||
} EC_SCALAR;
|
||||
|
||||
// ec_bignum_to_scalar converts |in| to an |EC_SCALAR| and writes it to
|
||||
// |*out|. It returns one on success and zero if |in| is out of range.
|
||||
OPENSSL_EXPORT int ec_bignum_to_scalar(const EC_GROUP *group, EC_SCALAR *out,
|
||||
const BIGNUM *in);
|
||||
|
||||
// ec_scalar_to_bytes serializes |in| as a big-endian bytestring to |out| and
|
||||
// sets |*out_len| to the number of bytes written. The number of bytes written
|
||||
// is |BN_num_bytes(&group->order)|, which is at most |EC_MAX_BYTES|.
|
||||
OPENSSL_EXPORT void ec_scalar_to_bytes(const EC_GROUP *group, uint8_t *out,
|
||||
size_t *out_len, const EC_SCALAR *in);
|
||||
|
||||
// ec_scalar_from_bytes deserializes |in| and stores the resulting scalar over
|
||||
// group |group| to |out|. It returns one on success and zero if |in| is
|
||||
// invalid.
|
||||
int ec_scalar_from_bytes(const EC_GROUP *group, EC_SCALAR *out,
|
||||
const uint8_t *in, size_t len);
|
||||
|
||||
// ec_scalar_reduce sets |out| to |words|, reduced modulo the group order.
|
||||
// |words| must be less than order^2. |num| must be at most twice the width of
|
||||
// group order. This function treats |words| as secret.
|
||||
void ec_scalar_reduce(const EC_GROUP *group, EC_SCALAR *out,
|
||||
const BN_ULONG *words, size_t num);
|
||||
|
||||
// ec_random_nonzero_scalar sets |out| to a uniformly selected random value from
|
||||
// 1 to |group->order| - 1. It returns one on success and zero on error.
|
||||
int ec_random_nonzero_scalar(const EC_GROUP *group, EC_SCALAR *out,
|
||||
const uint8_t additional_data[32]);
|
||||
|
||||
// ec_scalar_equal_vartime returns one if |a| and |b| are equal and zero
|
||||
// otherwise. Both values are treated as public.
|
||||
int ec_scalar_equal_vartime(const EC_GROUP *group, const EC_SCALAR *a,
|
||||
const EC_SCALAR *b);
|
||||
|
||||
// ec_scalar_is_zero returns one if |a| is zero and zero otherwise.
|
||||
int ec_scalar_is_zero(const EC_GROUP *group, const EC_SCALAR *a);
|
||||
|
||||
// ec_scalar_add sets |r| to |a| + |b|.
|
||||
void ec_scalar_add(const EC_GROUP *group, EC_SCALAR *r, const EC_SCALAR *a,
|
||||
const EC_SCALAR *b);
|
||||
|
||||
// ec_scalar_sub sets |r| to |a| - |b|.
|
||||
void ec_scalar_sub(const EC_GROUP *group, EC_SCALAR *r, const EC_SCALAR *a,
|
||||
const EC_SCALAR *b);
|
||||
|
||||
// ec_scalar_neg sets |r| to -|a|.
|
||||
void ec_scalar_neg(const EC_GROUP *group, EC_SCALAR *r, const EC_SCALAR *a);
|
||||
|
||||
// ec_scalar_to_montgomery sets |r| to |a| in Montgomery form.
|
||||
void ec_scalar_to_montgomery(const EC_GROUP *group, EC_SCALAR *r,
|
||||
const EC_SCALAR *a);
|
||||
|
||||
// ec_scalar_to_montgomery sets |r| to |a| converted from Montgomery form.
|
||||
void ec_scalar_from_montgomery(const EC_GROUP *group, EC_SCALAR *r,
|
||||
const EC_SCALAR *a);
|
||||
|
||||
// ec_scalar_mul_montgomery sets |r| to |a| * |b| where inputs and outputs are
|
||||
// in Montgomery form.
|
||||
void ec_scalar_mul_montgomery(const EC_GROUP *group, EC_SCALAR *r,
|
||||
const EC_SCALAR *a, const EC_SCALAR *b);
|
||||
|
||||
// ec_scalar_inv0_montgomery sets |r| to |a|^-1 where inputs and outputs are in
|
||||
// Montgomery form. If |a| is zero, |r| is set to zero.
|
||||
void ec_scalar_inv0_montgomery(const EC_GROUP *group, EC_SCALAR *r,
|
||||
const EC_SCALAR *a);
|
||||
|
||||
// ec_scalar_to_montgomery_inv_vartime sets |r| to |a|^-1 R. That is, it takes
|
||||
// in |a| not in Montgomery form and computes the inverse in Montgomery form. It
|
||||
// returns one on success and zero if |a| has no inverse. This function assumes
|
||||
// |a| is public and may leak information about it via timing.
|
||||
//
|
||||
// Note this is not the same operation as |ec_scalar_inv0_montgomery|.
|
||||
int ec_scalar_to_montgomery_inv_vartime(const EC_GROUP *group, EC_SCALAR *r,
|
||||
const EC_SCALAR *a);
|
||||
|
||||
// ec_scalar_select, in constant time, sets |out| to |a| if |mask| is all ones
|
||||
// and |b| if |mask| is all zeros.
|
||||
void ec_scalar_select(const EC_GROUP *group, EC_SCALAR *out, BN_ULONG mask,
|
||||
const EC_SCALAR *a, const EC_SCALAR *b);
|
||||
|
||||
|
||||
// Field elements.
|
||||
|
||||
// An EC_FELEM represents a field element. Only the first |field->width| words
|
||||
// are used. An |EC_FELEM| is specific to an |EC_GROUP| and must not be mixed
|
||||
// between groups. Additionally, the representation (whether or not elements are
|
||||
@@ -110,15 +198,268 @@ typedef union {
|
||||
BN_ULONG words[EC_MAX_WORDS];
|
||||
} EC_FELEM;
|
||||
|
||||
// An EC_RAW_POINT represents an elliptic curve point. Unlike |EC_POINT|, it is
|
||||
// a plain struct which can be stack-allocated and needs no cleanup. It is
|
||||
// specific to an |EC_GROUP| and must not be mixed between groups.
|
||||
// ec_bignum_to_felem converts |in| to an |EC_FELEM|. It returns one on success
|
||||
// and zero if |in| is out of range.
|
||||
int ec_bignum_to_felem(const EC_GROUP *group, EC_FELEM *out, const BIGNUM *in);
|
||||
|
||||
// ec_felem_to_bignum converts |in| to a |BIGNUM|. It returns one on success and
|
||||
// zero on allocation failure.
|
||||
int ec_felem_to_bignum(const EC_GROUP *group, BIGNUM *out, const EC_FELEM *in);
|
||||
|
||||
// ec_felem_to_bytes serializes |in| as a big-endian bytestring to |out| and
|
||||
// sets |*out_len| to the number of bytes written. The number of bytes written
|
||||
// is |BN_num_bytes(&group->order)|, which is at most |EC_MAX_BYTES|.
|
||||
void ec_felem_to_bytes(const EC_GROUP *group, uint8_t *out, size_t *out_len,
|
||||
const EC_FELEM *in);
|
||||
|
||||
// ec_felem_from_bytes deserializes |in| and stores the resulting field element
|
||||
// to |out|. It returns one on success and zero if |in| is invalid.
|
||||
int ec_felem_from_bytes(const EC_GROUP *group, EC_FELEM *out, const uint8_t *in,
|
||||
size_t len);
|
||||
|
||||
// ec_felem_neg sets |out| to -|a|.
|
||||
void ec_felem_neg(const EC_GROUP *group, EC_FELEM *out, const EC_FELEM *a);
|
||||
|
||||
// ec_felem_add sets |out| to |a| + |b|.
|
||||
void ec_felem_add(const EC_GROUP *group, EC_FELEM *out, const EC_FELEM *a,
|
||||
const EC_FELEM *b);
|
||||
|
||||
// ec_felem_add sets |out| to |a| - |b|.
|
||||
void ec_felem_sub(const EC_GROUP *group, EC_FELEM *out, const EC_FELEM *a,
|
||||
const EC_FELEM *b);
|
||||
|
||||
// ec_felem_non_zero_mask returns all ones if |a| is non-zero and all zeros
|
||||
// otherwise.
|
||||
BN_ULONG ec_felem_non_zero_mask(const EC_GROUP *group, const EC_FELEM *a);
|
||||
|
||||
// ec_felem_select, in constant time, sets |out| to |a| if |mask| is all ones
|
||||
// and |b| if |mask| is all zeros.
|
||||
void ec_felem_select(const EC_GROUP *group, EC_FELEM *out, BN_ULONG mask,
|
||||
const EC_FELEM *a, const EC_FELEM *b);
|
||||
|
||||
// ec_felem_equal returns one if |a| and |b| are equal and zero otherwise.
|
||||
int ec_felem_equal(const EC_GROUP *group, const EC_FELEM *a, const EC_FELEM *b);
|
||||
|
||||
|
||||
// Points.
|
||||
//
|
||||
// Points may represented in affine coordinates as |EC_AFFINE| or Jacobian
|
||||
// coordinates as |EC_RAW_POINT|. Affine coordinates directly represent a
|
||||
// point on the curve, but point addition over affine coordinates requires
|
||||
// costly field inversions, so arithmetic is done in Jacobian coordinates.
|
||||
// Converting from affine to Jacobian is cheap, while converting from Jacobian
|
||||
// to affine costs a field inversion. (Jacobian coordinates amortize the field
|
||||
// inversions needed in a sequence of point operations.)
|
||||
//
|
||||
// TODO(davidben): Rename |EC_RAW_POINT| to |EC_JACOBIAN|.
|
||||
|
||||
// An EC_RAW_POINT represents an elliptic curve point in Jacobian coordinates.
|
||||
// Unlike |EC_POINT|, it is a plain struct which can be stack-allocated and
|
||||
// needs no cleanup. It is specific to an |EC_GROUP| and must not be mixed
|
||||
// between groups.
|
||||
typedef struct {
|
||||
EC_FELEM X, Y, Z;
|
||||
// X, Y, and Z are Jacobian projective coordinates. They represent
|
||||
// (X/Z^2, Y/Z^3) if Z != 0 and the point at infinity otherwise.
|
||||
EC_FELEM X, Y, Z;
|
||||
} EC_RAW_POINT;
|
||||
|
||||
// An EC_AFFINE represents an elliptic curve point in affine coordinates.
|
||||
// coordinates. Note the point at infinity cannot be represented in affine
|
||||
// coordinates.
|
||||
typedef struct {
|
||||
EC_FELEM X, Y;
|
||||
} EC_AFFINE;
|
||||
|
||||
// ec_affine_to_jacobian converts |p| to Jacobian form and writes the result to
|
||||
// |*out|. This operation is very cheap and only costs a few copies.
|
||||
void ec_affine_to_jacobian(const EC_GROUP *group, EC_RAW_POINT *out,
|
||||
const EC_AFFINE *p);
|
||||
|
||||
// ec_jacobian_to_affine converts |p| to affine form and writes the result to
|
||||
// |*out|. It returns one on success and zero if |p| was the point at infinity.
|
||||
// This operation performs a field inversion and should only be done once per
|
||||
// point.
|
||||
//
|
||||
// If only extracting the x-coordinate, use |ec_get_x_coordinate_*| which is
|
||||
// slightly faster.
|
||||
int ec_jacobian_to_affine(const EC_GROUP *group, EC_AFFINE *out,
|
||||
const EC_RAW_POINT *p);
|
||||
|
||||
// ec_jacobian_to_affine_batch converts |num| points in |in| from Jacobian
|
||||
// coordinates to affine coordinates and writes the results to |out|. It returns
|
||||
// one on success and zero if any of the input points were infinity.
|
||||
//
|
||||
// This function is not implemented for all curves. Add implementations as
|
||||
// needed.
|
||||
int ec_jacobian_to_affine_batch(const EC_GROUP *group, EC_AFFINE *out,
|
||||
const EC_RAW_POINT *in, size_t num);
|
||||
|
||||
// ec_point_set_affine_coordinates sets |out|'s to a point with affine
|
||||
// coordinates |x| and |y|. It returns one if the point is on the curve and
|
||||
// zero otherwise. If the point is not on the curve, the value of |out| is
|
||||
// undefined.
|
||||
int ec_point_set_affine_coordinates(const EC_GROUP *group, EC_AFFINE *out,
|
||||
const EC_FELEM *x, const EC_FELEM *y);
|
||||
|
||||
// ec_point_mul_scalar sets |r| to |p| * |scalar|. Both inputs are considered
|
||||
// secret.
|
||||
int ec_point_mul_scalar(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
const EC_RAW_POINT *p, const EC_SCALAR *scalar);
|
||||
|
||||
// ec_point_mul_scalar_base sets |r| to generator * |scalar|. |scalar| is
|
||||
// treated as secret.
|
||||
int ec_point_mul_scalar_base(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
const EC_SCALAR *scalar);
|
||||
|
||||
// ec_point_mul_scalar_batch sets |r| to |p0| * |scalar0| + |p1| * |scalar1| +
|
||||
// |p2| * |scalar2|. |p2| may be NULL to skip that term.
|
||||
//
|
||||
// The inputs are treated as secret, however, this function leaks information
|
||||
// about whether intermediate computations add a point to itself. Callers must
|
||||
// ensure that discrete logs between |p0|, |p1|, and |p2| are uniformly
|
||||
// distributed and independent of the scalars, which should be uniformly
|
||||
// selected and not under the attackers control. This ensures the doubling case
|
||||
// will occur with negligible probability.
|
||||
//
|
||||
// This function is not implemented for all curves. Add implementations as
|
||||
// needed.
|
||||
//
|
||||
// TODO(davidben): This function does not use base point tables. For now, it is
|
||||
// only used with the generic |EC_GFp_mont_method| implementation which has
|
||||
// none. If generalizing to tuned curves, this may be useful. However, we still
|
||||
// must double up to the least efficient input, so precomputed tables can only
|
||||
// save table setup and allow a wider window size.
|
||||
int ec_point_mul_scalar_batch(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
const EC_RAW_POINT *p0, const EC_SCALAR *scalar0,
|
||||
const EC_RAW_POINT *p1, const EC_SCALAR *scalar1,
|
||||
const EC_RAW_POINT *p2, const EC_SCALAR *scalar2);
|
||||
|
||||
#define EC_MONT_PRECOMP_COMB_SIZE 5
|
||||
|
||||
// An |EC_PRECOMP| stores precomputed information about a point, to optimize
|
||||
// repeated multiplications involving it. It is a union so different
|
||||
// |EC_METHOD|s can store different information in it.
|
||||
typedef union {
|
||||
EC_AFFINE comb[(1 << EC_MONT_PRECOMP_COMB_SIZE) - 1];
|
||||
} EC_PRECOMP;
|
||||
|
||||
// ec_init_precomp precomputes multiples of |p| and writes the result to |out|.
|
||||
// It returns one on success and zero on error. The resulting table may be used
|
||||
// with |ec_point_mul_scalar_precomp|. This function will fail if |p| is the
|
||||
// point at infinity.
|
||||
//
|
||||
// This function is not implemented for all curves. Add implementations as
|
||||
// needed.
|
||||
int ec_init_precomp(const EC_GROUP *group, EC_PRECOMP *out,
|
||||
const EC_RAW_POINT *p);
|
||||
|
||||
// ec_point_mul_scalar_precomp sets |r| to |p0| * |scalar0| + |p1| * |scalar1| +
|
||||
// |p2| * |scalar2|. |p1| or |p2| may be NULL to skip the corresponding term.
|
||||
// The points are represented as |EC_PRECOMP| and must be initialized with
|
||||
// |ec_init_precomp|. This function runs faster than |ec_point_mul_scalar_batch|
|
||||
// but requires setup work per input point, so it is only appropriate for points
|
||||
// which are used frequently.
|
||||
//
|
||||
// The inputs are treated as secret, however, this function leaks information
|
||||
// about whether intermediate computations add a point to itself. Callers must
|
||||
// ensure that discrete logs between |p0|, |p1|, and |p2| are uniformly
|
||||
// distributed and independent of the scalars, which should be uniformly
|
||||
// selected and not under the attackers control. This ensures the doubling case
|
||||
// will occur with negligible probability.
|
||||
//
|
||||
// This function is not implemented for all curves. Add implementations as
|
||||
// needed.
|
||||
//
|
||||
// TODO(davidben): This function does not use base point tables. For now, it is
|
||||
// only used with the generic |EC_GFp_mont_method| implementation which has
|
||||
// none. If generalizing to tuned curves, we should add a parameter for the base
|
||||
// point and arrange for the generic implementation to have base point tables
|
||||
// available.
|
||||
int ec_point_mul_scalar_precomp(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
const EC_PRECOMP *p0, const EC_SCALAR *scalar0,
|
||||
const EC_PRECOMP *p1, const EC_SCALAR *scalar1,
|
||||
const EC_PRECOMP *p2, const EC_SCALAR *scalar2);
|
||||
|
||||
// ec_point_mul_scalar_public sets |r| to
|
||||
// generator * |g_scalar| + |p| * |p_scalar|. It assumes that the inputs are
|
||||
// public so there is no concern about leaking their values through timing.
|
||||
OPENSSL_EXPORT int ec_point_mul_scalar_public(const EC_GROUP *group,
|
||||
EC_RAW_POINT *r,
|
||||
const EC_SCALAR *g_scalar,
|
||||
const EC_RAW_POINT *p,
|
||||
const EC_SCALAR *p_scalar);
|
||||
|
||||
// ec_point_mul_scalar_public_batch sets |r| to the sum of generator *
|
||||
// |g_scalar| and |points[i]| * |scalars[i]| where |points| and |scalars| have
|
||||
// |num| elements. It assumes that the inputs are public so there is no concern
|
||||
// about leaking their values through timing. |g_scalar| may be NULL to skip
|
||||
// that term.
|
||||
//
|
||||
// This function is not implemented for all curves. Add implementations as
|
||||
// needed.
|
||||
int ec_point_mul_scalar_public_batch(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
const EC_SCALAR *g_scalar,
|
||||
const EC_RAW_POINT *points,
|
||||
const EC_SCALAR *scalars, size_t num);
|
||||
|
||||
// ec_point_select, in constant time, sets |out| to |a| if |mask| is all ones
|
||||
// and |b| if |mask| is all zeros.
|
||||
void ec_point_select(const EC_GROUP *group, EC_RAW_POINT *out, BN_ULONG mask,
|
||||
const EC_RAW_POINT *a, const EC_RAW_POINT *b);
|
||||
|
||||
// ec_affine_select behaves like |ec_point_select| but acts on affine points.
|
||||
void ec_affine_select(const EC_GROUP *group, EC_AFFINE *out, BN_ULONG mask,
|
||||
const EC_AFFINE *a, const EC_AFFINE *b);
|
||||
|
||||
// ec_precomp_select behaves like |ec_point_select| but acts on |EC_PRECOMP|.
|
||||
void ec_precomp_select(const EC_GROUP *group, EC_PRECOMP *out, BN_ULONG mask,
|
||||
const EC_PRECOMP *a, const EC_PRECOMP *b);
|
||||
|
||||
// ec_cmp_x_coordinate compares the x (affine) coordinate of |p|, mod the group
|
||||
// order, with |r|. It returns one if the values match and zero if |p| is the
|
||||
// point at infinity of the values do not match.
|
||||
int ec_cmp_x_coordinate(const EC_GROUP *group, const EC_RAW_POINT *p,
|
||||
const EC_SCALAR *r);
|
||||
|
||||
// ec_get_x_coordinate_as_scalar sets |*out| to |p|'s x-coordinate, modulo
|
||||
// |group->order|. It returns one on success and zero if |p| is the point at
|
||||
// infinity.
|
||||
int ec_get_x_coordinate_as_scalar(const EC_GROUP *group, EC_SCALAR *out,
|
||||
const EC_RAW_POINT *p);
|
||||
|
||||
// ec_get_x_coordinate_as_bytes writes |p|'s affine x-coordinate to |out|, which
|
||||
// must have at must |max_out| bytes. It sets |*out_len| to the number of bytes
|
||||
// written. The value is written big-endian and zero-padded to the size of the
|
||||
// field. This function returns one on success and zero on failure.
|
||||
int ec_get_x_coordinate_as_bytes(const EC_GROUP *group, uint8_t *out,
|
||||
size_t *out_len, size_t max_out,
|
||||
const EC_RAW_POINT *p);
|
||||
|
||||
// ec_point_to_bytes behaves like |EC_POINT_point2oct| but takes an
|
||||
// |EC_AFFINE|.
|
||||
size_t ec_point_to_bytes(const EC_GROUP *group, const EC_AFFINE *point,
|
||||
point_conversion_form_t form, uint8_t *buf,
|
||||
size_t len);
|
||||
|
||||
// ec_point_from_uncompressed parses |in| as a point in uncompressed form and
|
||||
// sets the result to |out|. It returns one on success and zero if the input was
|
||||
// invalid.
|
||||
int ec_point_from_uncompressed(const EC_GROUP *group, EC_AFFINE *out,
|
||||
const uint8_t *in, size_t len);
|
||||
|
||||
// ec_set_to_safe_point sets |out| to an arbitrary point on |group|, either the
|
||||
// generator or the point at infinity. This is used to guard against callers of
|
||||
// external APIs not checking the return value.
|
||||
void ec_set_to_safe_point(const EC_GROUP *group, EC_RAW_POINT *out);
|
||||
|
||||
// ec_affine_jacobian_equal returns one if |a| and |b| represent the same point
|
||||
// and zero otherwise. It treats both inputs as secret.
|
||||
int ec_affine_jacobian_equal(const EC_GROUP *group, const EC_AFFINE *a,
|
||||
const EC_RAW_POINT *b);
|
||||
|
||||
|
||||
// Implementation details.
|
||||
|
||||
struct ec_method_st {
|
||||
int (*group_init)(EC_GROUP *);
|
||||
void (*group_finish)(EC_GROUP *);
|
||||
@@ -128,12 +469,13 @@ struct ec_method_st {
|
||||
// point_get_affine_coordinates sets |*x| and |*y| to the affine coordinates
|
||||
// of |p|. Either |x| or |y| may be NULL to omit it. It returns one on success
|
||||
// and zero if |p| is the point at infinity.
|
||||
//
|
||||
// Note: unlike |EC_FELEM|s used as intermediate values internal to the
|
||||
// |EC_METHOD|, |*x| and |*y| are not encoded in Montgomery form.
|
||||
int (*point_get_affine_coordinates)(const EC_GROUP *, const EC_RAW_POINT *p,
|
||||
EC_FELEM *x, EC_FELEM *y);
|
||||
|
||||
// jacobian_to_affine_batch implements |ec_jacobian_to_affine_batch|.
|
||||
int (*jacobian_to_affine_batch)(const EC_GROUP *group, EC_AFFINE *out,
|
||||
const EC_RAW_POINT *in, size_t num);
|
||||
|
||||
// add sets |r| to |a| + |b|.
|
||||
void (*add)(const EC_GROUP *group, EC_RAW_POINT *r, const EC_RAW_POINT *a,
|
||||
const EC_RAW_POINT *b);
|
||||
@@ -146,12 +488,32 @@ struct ec_method_st {
|
||||
// mul_base sets |r| to |scalar|*generator.
|
||||
void (*mul_base)(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
const EC_SCALAR *scalar);
|
||||
// mul_batch implements |ec_mul_scalar_batch|.
|
||||
void (*mul_batch)(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
const EC_RAW_POINT *p0, const EC_SCALAR *scalar0,
|
||||
const EC_RAW_POINT *p1, const EC_SCALAR *scalar1,
|
||||
const EC_RAW_POINT *p2, const EC_SCALAR *scalar2);
|
||||
// mul_public sets |r| to |g_scalar|*generator + |p_scalar|*|p|. It assumes
|
||||
// that the inputs are public so there is no concern about leaking their
|
||||
// values through timing.
|
||||
//
|
||||
// This function may be omitted if |mul_public_batch| is provided.
|
||||
void (*mul_public)(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
const EC_SCALAR *g_scalar, const EC_RAW_POINT *p,
|
||||
const EC_SCALAR *p_scalar);
|
||||
// mul_public_batch implements |ec_point_mul_scalar_public_batch|.
|
||||
int (*mul_public_batch)(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
const EC_SCALAR *g_scalar, const EC_RAW_POINT *points,
|
||||
const EC_SCALAR *scalars, size_t num);
|
||||
|
||||
// init_precomp implements |ec_init_precomp|.
|
||||
int (*init_precomp)(const EC_GROUP *group, EC_PRECOMP *out,
|
||||
const EC_RAW_POINT *p);
|
||||
// mul_precomp implements |ec_point_mul_scalar_precomp|.
|
||||
void (*mul_precomp)(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
const EC_PRECOMP *p0, const EC_SCALAR *scalar0,
|
||||
const EC_PRECOMP *p1, const EC_SCALAR *scalar1,
|
||||
const EC_PRECOMP *p2, const EC_SCALAR *scalar2);
|
||||
|
||||
// felem_mul and felem_sqr implement multiplication and squaring,
|
||||
// respectively, so that the generic |EC_POINT_add| and |EC_POINT_dbl|
|
||||
@@ -168,21 +530,36 @@ struct ec_method_st {
|
||||
const EC_FELEM *b);
|
||||
void (*felem_sqr)(const EC_GROUP *, EC_FELEM *r, const EC_FELEM *a);
|
||||
|
||||
int (*bignum_to_felem)(const EC_GROUP *group, EC_FELEM *out,
|
||||
const BIGNUM *in);
|
||||
int (*felem_to_bignum)(const EC_GROUP *group, BIGNUM *out,
|
||||
void (*felem_to_bytes)(const EC_GROUP *group, uint8_t *out, size_t *out_len,
|
||||
const EC_FELEM *in);
|
||||
int (*felem_from_bytes)(const EC_GROUP *group, EC_FELEM *out,
|
||||
const uint8_t *in, size_t len);
|
||||
|
||||
// scalar_inv_montgomery sets |out| to |in|^-1, where both input and output
|
||||
// are in Montgomery form.
|
||||
void (*scalar_inv_montgomery)(const EC_GROUP *group, EC_SCALAR *out,
|
||||
const EC_SCALAR *in);
|
||||
// felem_reduce sets |out| to |words|, reduced modulo the field size, p.
|
||||
// |words| must be less than p^2. |num| must be at most twice the width of p.
|
||||
// This function treats |words| as secret.
|
||||
//
|
||||
// This function is only used in hash-to-curve and may be omitted in curves
|
||||
// that do not support it.
|
||||
void (*felem_reduce)(const EC_GROUP *group, EC_FELEM *out,
|
||||
const BN_ULONG *words, size_t num);
|
||||
|
||||
// scalar_inv_montgomery_vartime performs the same computation as
|
||||
// |scalar_inv_montgomery|. It further assumes that the inputs are public so
|
||||
// there is no concern about leaking their values through timing.
|
||||
int (*scalar_inv_montgomery_vartime)(const EC_GROUP *group, EC_SCALAR *out,
|
||||
const EC_SCALAR *in);
|
||||
// felem_exp sets |out| to |a|^|exp|. It treats |a| is secret but |exp| as
|
||||
// public.
|
||||
//
|
||||
// This function is used in hash-to-curve and may be NULL in curves not used
|
||||
// with hash-to-curve.
|
||||
void (*felem_exp)(const EC_GROUP *group, EC_FELEM *out, const EC_FELEM *a,
|
||||
const BN_ULONG *exp, size_t num_exp);
|
||||
|
||||
// scalar_inv0_montgomery implements |ec_scalar_inv0_montgomery|.
|
||||
void (*scalar_inv0_montgomery)(const EC_GROUP *group, EC_SCALAR *out,
|
||||
const EC_SCALAR *in);
|
||||
|
||||
// scalar_to_montgomery_inv_vartime implements
|
||||
// |ec_scalar_to_montgomery_inv_vartime|.
|
||||
int (*scalar_to_montgomery_inv_vartime)(const EC_GROUP *group, EC_SCALAR *out,
|
||||
const EC_SCALAR *in);
|
||||
|
||||
// cmp_x_coordinate compares the x (affine) coordinate of |p|, mod the group
|
||||
// order, with |r|. It returns one if the values match and zero if |p| is the
|
||||
@@ -197,7 +574,8 @@ struct ec_group_st {
|
||||
const EC_METHOD *meth;
|
||||
|
||||
// Unlike all other |EC_POINT|s, |generator| does not own |generator->group|
|
||||
// to avoid a reference cycle.
|
||||
// to avoid a reference cycle. Additionally, Z is guaranteed to be one, so X
|
||||
// and Y are suitable for use as an |EC_AFFINE|.
|
||||
EC_POINT *generator;
|
||||
BIGNUM order;
|
||||
|
||||
@@ -247,145 +625,20 @@ struct ec_point_st {
|
||||
|
||||
EC_GROUP *ec_group_new(const EC_METHOD *meth);
|
||||
|
||||
// ec_bignum_to_felem converts |in| to an |EC_FELEM|. It returns one on success
|
||||
// and zero if |in| is out of range.
|
||||
int ec_bignum_to_felem(const EC_GROUP *group, EC_FELEM *out, const BIGNUM *in);
|
||||
|
||||
// ec_felem_to_bignum converts |in| to a |BIGNUM|. It returns one on success and
|
||||
// zero on allocation failure.
|
||||
int ec_felem_to_bignum(const EC_GROUP *group, BIGNUM *out, const EC_FELEM *in);
|
||||
|
||||
// ec_felem_neg sets |out| to -|a|.
|
||||
void ec_felem_neg(const EC_GROUP *group, EC_FELEM *out, const EC_FELEM *a);
|
||||
|
||||
// ec_felem_add sets |out| to |a| + |b|.
|
||||
void ec_felem_add(const EC_GROUP *group, EC_FELEM *out, const EC_FELEM *a,
|
||||
const EC_FELEM *b);
|
||||
|
||||
// ec_felem_add sets |out| to |a| - |b|.
|
||||
void ec_felem_sub(const EC_GROUP *group, EC_FELEM *out, const EC_FELEM *a,
|
||||
const EC_FELEM *b);
|
||||
|
||||
// ec_felem_non_zero_mask returns all ones if |a| is non-zero and all zeros
|
||||
// otherwise.
|
||||
BN_ULONG ec_felem_non_zero_mask(const EC_GROUP *group, const EC_FELEM *a);
|
||||
|
||||
// ec_felem_select, in constant time, sets |out| to |a| if |mask| is all ones
|
||||
// and |b| if |mask| is all zeros.
|
||||
void ec_felem_select(const EC_GROUP *group, EC_FELEM *out, BN_ULONG mask,
|
||||
const EC_FELEM *a, const EC_FELEM *b);
|
||||
|
||||
// ec_felem_equal returns one if |a| and |b| are equal and zero otherwise. It
|
||||
// treats |a| and |b| as public and does *not* run in constant time.
|
||||
int ec_felem_equal(const EC_GROUP *group, const EC_FELEM *a, const EC_FELEM *b);
|
||||
|
||||
// ec_bignum_to_scalar converts |in| to an |EC_SCALAR| and writes it to
|
||||
// |*out|. It returns one on success and zero if |in| is out of range.
|
||||
OPENSSL_EXPORT int ec_bignum_to_scalar(const EC_GROUP *group, EC_SCALAR *out,
|
||||
const BIGNUM *in);
|
||||
|
||||
// ec_scalar_to_bytes serializes |in| as a big-endian bytestring to |out| and
|
||||
// sets |*out_len| to the number of bytes written. The number of bytes written
|
||||
// is |BN_num_bytes(&group->order)|, which is at most |EC_MAX_BYTES|.
|
||||
void ec_scalar_to_bytes(const EC_GROUP *group, uint8_t *out, size_t *out_len,
|
||||
const EC_SCALAR *in);
|
||||
|
||||
// ec_scalar_from_bytes deserializes |in| and stores the resulting scalar over
|
||||
// group |group| to |out|. It returns one on success and zero if |in| is
|
||||
// invalid.
|
||||
int ec_scalar_from_bytes(const EC_GROUP *group, EC_SCALAR *out,
|
||||
const uint8_t *in, size_t len);
|
||||
|
||||
// ec_random_nonzero_scalar sets |out| to a uniformly selected random value from
|
||||
// 1 to |group->order| - 1. It returns one on success and zero on error.
|
||||
int ec_random_nonzero_scalar(const EC_GROUP *group, EC_SCALAR *out,
|
||||
const uint8_t additional_data[32]);
|
||||
|
||||
// ec_scalar_equal_vartime returns one if |a| and |b| are equal and zero
|
||||
// otherwise. Both values are treated as public.
|
||||
int ec_scalar_equal_vartime(const EC_GROUP *group, const EC_SCALAR *a,
|
||||
const EC_SCALAR *b);
|
||||
|
||||
// ec_scalar_is_zero returns one if |a| is zero and zero otherwise.
|
||||
int ec_scalar_is_zero(const EC_GROUP *group, const EC_SCALAR *a);
|
||||
|
||||
// ec_scalar_add sets |r| to |a| + |b|.
|
||||
void ec_scalar_add(const EC_GROUP *group, EC_SCALAR *r, const EC_SCALAR *a,
|
||||
const EC_SCALAR *b);
|
||||
|
||||
// ec_scalar_to_montgomery sets |r| to |a| in Montgomery form.
|
||||
void ec_scalar_to_montgomery(const EC_GROUP *group, EC_SCALAR *r,
|
||||
const EC_SCALAR *a);
|
||||
|
||||
// ec_scalar_to_montgomery sets |r| to |a| converted from Montgomery form.
|
||||
void ec_scalar_from_montgomery(const EC_GROUP *group, EC_SCALAR *r,
|
||||
const EC_SCALAR *a);
|
||||
|
||||
// ec_scalar_mul_montgomery sets |r| to |a| * |b| where inputs and outputs are
|
||||
// in Montgomery form.
|
||||
void ec_scalar_mul_montgomery(const EC_GROUP *group, EC_SCALAR *r,
|
||||
const EC_SCALAR *a, const EC_SCALAR *b);
|
||||
|
||||
// ec_scalar_mul_montgomery sets |r| to |a|^-1 where inputs and outputs are in
|
||||
// Montgomery form.
|
||||
void ec_scalar_inv_montgomery(const EC_GROUP *group, EC_SCALAR *r,
|
||||
const EC_SCALAR *a);
|
||||
|
||||
// ec_scalar_inv_montgomery_vartime performs the same actions as
|
||||
// |ec_scalar_inv_montgomery|, but in variable time.
|
||||
int ec_scalar_inv_montgomery_vartime(const EC_GROUP *group, EC_SCALAR *r,
|
||||
const EC_SCALAR *a);
|
||||
|
||||
// ec_point_mul_scalar sets |r| to |p| * |scalar|. Both inputs are considered
|
||||
// secret.
|
||||
int ec_point_mul_scalar(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
const EC_RAW_POINT *p, const EC_SCALAR *scalar);
|
||||
|
||||
// ec_point_mul_scalar_base sets |r| to generator * |scalar|. |scalar| is
|
||||
// treated as secret.
|
||||
int ec_point_mul_scalar_base(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
const EC_SCALAR *scalar);
|
||||
|
||||
// ec_point_mul_scalar_public sets |r| to
|
||||
// generator * |g_scalar| + |p| * |p_scalar|. It assumes that the inputs are
|
||||
// public so there is no concern about leaking their values through timing.
|
||||
OPENSSL_EXPORT int ec_point_mul_scalar_public(const EC_GROUP *group,
|
||||
EC_RAW_POINT *r,
|
||||
const EC_SCALAR *g_scalar,
|
||||
const EC_RAW_POINT *p,
|
||||
const EC_SCALAR *p_scalar);
|
||||
|
||||
// ec_cmp_x_coordinate compares the x (affine) coordinate of |p|, mod the group
|
||||
// order, with |r|. It returns one if the values match and zero if |p| is the
|
||||
// point at infinity of the values do not match.
|
||||
int ec_cmp_x_coordinate(const EC_GROUP *group, const EC_RAW_POINT *p,
|
||||
const EC_SCALAR *r);
|
||||
|
||||
// ec_get_x_coordinate_as_scalar sets |*out| to |p|'s x-coordinate, modulo
|
||||
// |group->order|. It returns one on success and zero if |p| is the point at
|
||||
// infinity.
|
||||
int ec_get_x_coordinate_as_scalar(const EC_GROUP *group, EC_SCALAR *out,
|
||||
const EC_RAW_POINT *p);
|
||||
|
||||
// ec_point_get_affine_coordinate_bytes writes |p|'s affine coordinates to
|
||||
// |out_x| and |out_y|, each of which must have at must |max_out| bytes. It sets
|
||||
// |*out_len| to the number of bytes written in each buffer. Coordinates are
|
||||
// written big-endian and zero-padded to the size of the field.
|
||||
//
|
||||
// Either of |out_x| or |out_y| may be NULL to omit that coordinate. This
|
||||
// function returns one on success and zero on failure.
|
||||
int ec_point_get_affine_coordinate_bytes(const EC_GROUP *group, uint8_t *out_x,
|
||||
uint8_t *out_y, size_t *out_len,
|
||||
size_t max_out, const EC_RAW_POINT *p);
|
||||
|
||||
// ec_field_element_to_scalar reduces |r| modulo |group->order|. |r| must
|
||||
// previously have been reduced modulo |group->field|.
|
||||
int ec_field_element_to_scalar(const EC_GROUP *group, BIGNUM *r);
|
||||
|
||||
void ec_GFp_mont_mul(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
const EC_RAW_POINT *p, const EC_SCALAR *scalar);
|
||||
void ec_GFp_mont_mul_base(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
const EC_SCALAR *scalar);
|
||||
void ec_GFp_mont_mul_batch(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
const EC_RAW_POINT *p0, const EC_SCALAR *scalar0,
|
||||
const EC_RAW_POINT *p1, const EC_SCALAR *scalar1,
|
||||
const EC_RAW_POINT *p2, const EC_SCALAR *scalar2);
|
||||
int ec_GFp_mont_init_precomp(const EC_GROUP *group, EC_PRECOMP *out,
|
||||
const EC_RAW_POINT *p);
|
||||
void ec_GFp_mont_mul_precomp(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
const EC_PRECOMP *p0, const EC_SCALAR *scalar0,
|
||||
const EC_PRECOMP *p1, const EC_SCALAR *scalar1,
|
||||
const EC_PRECOMP *p2, const EC_SCALAR *scalar2);
|
||||
|
||||
// ec_compute_wNAF writes the modified width-(w+1) Non-Adjacent Form (wNAF) of
|
||||
// |scalar| to |out|. |out| must have room for |bits| + 1 elements, each of
|
||||
@@ -398,9 +651,10 @@ void ec_GFp_mont_mul_base(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
void ec_compute_wNAF(const EC_GROUP *group, int8_t *out,
|
||||
const EC_SCALAR *scalar, size_t bits, int w);
|
||||
|
||||
void ec_GFp_mont_mul_public(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
const EC_SCALAR *g_scalar, const EC_RAW_POINT *p,
|
||||
const EC_SCALAR *p_scalar);
|
||||
int ec_GFp_mont_mul_public_batch(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
const EC_SCALAR *g_scalar,
|
||||
const EC_RAW_POINT *points,
|
||||
const EC_SCALAR *scalars, size_t num);
|
||||
|
||||
// method functions in simple.c
|
||||
int ec_GFp_simple_group_init(EC_GROUP *);
|
||||
@@ -412,26 +666,29 @@ int ec_GFp_simple_group_get_curve(const EC_GROUP *, BIGNUM *p, BIGNUM *a,
|
||||
void ec_GFp_simple_point_init(EC_RAW_POINT *);
|
||||
void ec_GFp_simple_point_copy(EC_RAW_POINT *, const EC_RAW_POINT *);
|
||||
void ec_GFp_simple_point_set_to_infinity(const EC_GROUP *, EC_RAW_POINT *);
|
||||
int ec_GFp_simple_point_set_affine_coordinates(const EC_GROUP *, EC_RAW_POINT *,
|
||||
const BIGNUM *x,
|
||||
const BIGNUM *y);
|
||||
void ec_GFp_mont_add(const EC_GROUP *, EC_RAW_POINT *r, const EC_RAW_POINT *a,
|
||||
const EC_RAW_POINT *b);
|
||||
void ec_GFp_mont_dbl(const EC_GROUP *, EC_RAW_POINT *r, const EC_RAW_POINT *a);
|
||||
void ec_GFp_simple_invert(const EC_GROUP *, EC_RAW_POINT *);
|
||||
int ec_GFp_simple_is_at_infinity(const EC_GROUP *, const EC_RAW_POINT *);
|
||||
int ec_GFp_simple_is_on_curve(const EC_GROUP *, const EC_RAW_POINT *);
|
||||
int ec_GFp_simple_cmp(const EC_GROUP *, const EC_RAW_POINT *a,
|
||||
const EC_RAW_POINT *b);
|
||||
void ec_simple_scalar_inv_montgomery(const EC_GROUP *group, EC_SCALAR *r,
|
||||
const EC_SCALAR *a);
|
||||
int ec_GFp_simple_points_equal(const EC_GROUP *, const EC_RAW_POINT *a,
|
||||
const EC_RAW_POINT *b);
|
||||
void ec_simple_scalar_inv0_montgomery(const EC_GROUP *group, EC_SCALAR *r,
|
||||
const EC_SCALAR *a);
|
||||
|
||||
int ec_GFp_simple_mont_inv_mod_ord_vartime(const EC_GROUP *group, EC_SCALAR *r,
|
||||
const EC_SCALAR *a);
|
||||
int ec_simple_scalar_to_montgomery_inv_vartime(const EC_GROUP *group,
|
||||
EC_SCALAR *r,
|
||||
const EC_SCALAR *a);
|
||||
|
||||
int ec_GFp_simple_cmp_x_coordinate(const EC_GROUP *group, const EC_RAW_POINT *p,
|
||||
const EC_SCALAR *r);
|
||||
|
||||
void ec_GFp_simple_felem_to_bytes(const EC_GROUP *group, uint8_t *out,
|
||||
size_t *out_len, const EC_FELEM *in);
|
||||
int ec_GFp_simple_felem_from_bytes(const EC_GROUP *group, EC_FELEM *out,
|
||||
const uint8_t *in, size_t len);
|
||||
|
||||
// method functions in montgomery.c
|
||||
int ec_GFp_mont_group_init(EC_GROUP *);
|
||||
int ec_GFp_mont_group_set_curve(EC_GROUP *, const BIGNUM *p, const BIGNUM *a,
|
||||
@@ -441,10 +698,10 @@ void ec_GFp_mont_felem_mul(const EC_GROUP *, EC_FELEM *r, const EC_FELEM *a,
|
||||
const EC_FELEM *b);
|
||||
void ec_GFp_mont_felem_sqr(const EC_GROUP *, EC_FELEM *r, const EC_FELEM *a);
|
||||
|
||||
int ec_GFp_mont_bignum_to_felem(const EC_GROUP *group, EC_FELEM *out,
|
||||
const BIGNUM *in);
|
||||
int ec_GFp_mont_felem_to_bignum(const EC_GROUP *group, BIGNUM *out,
|
||||
const EC_FELEM *in);
|
||||
void ec_GFp_mont_felem_to_bytes(const EC_GROUP *group, uint8_t *out,
|
||||
size_t *out_len, const EC_FELEM *in);
|
||||
int ec_GFp_mont_felem_from_bytes(const EC_GROUP *group, EC_FELEM *out,
|
||||
const uint8_t *in, size_t len);
|
||||
|
||||
void ec_GFp_nistp_recode_scalar_bits(uint8_t *sign, uint8_t *digit, uint8_t in);
|
||||
|
||||
@@ -465,6 +722,9 @@ typedef struct {
|
||||
struct ec_key_st {
|
||||
EC_GROUP *group;
|
||||
|
||||
// Ideally |pub_key| would be an |EC_AFFINE| so serializing it does not pay an
|
||||
// inversion each time, but the |EC_KEY_get0_public_key| API implies public
|
||||
// keys are stored in an |EC_POINT|-compatible form.
|
||||
EC_POINT *pub_key;
|
||||
EC_WRAPPED_SCALAR *priv_key;
|
||||
|
||||
|
||||
@@ -73,21 +73,15 @@
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
static size_t ec_GFp_simple_point2oct(const EC_GROUP *group,
|
||||
const EC_RAW_POINT *point,
|
||||
point_conversion_form_t form,
|
||||
uint8_t *buf, size_t len) {
|
||||
size_t ec_point_to_bytes(const EC_GROUP *group, const EC_AFFINE *point,
|
||||
point_conversion_form_t form, uint8_t *buf,
|
||||
size_t len) {
|
||||
if (form != POINT_CONVERSION_COMPRESSED &&
|
||||
form != POINT_CONVERSION_UNCOMPRESSED) {
|
||||
OPENSSL_PUT_ERROR(EC, EC_R_INVALID_FORM);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ec_GFp_simple_is_at_infinity(group, point)) {
|
||||
OPENSSL_PUT_ERROR(EC, EC_R_POINT_AT_INFINITY);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const size_t field_len = BN_num_bytes(&group->field);
|
||||
size_t output_len = 1 /* type byte */ + field_len;
|
||||
if (form == POINT_CONVERSION_UNCOMPRESSED) {
|
||||
@@ -102,79 +96,89 @@ static size_t ec_GFp_simple_point2oct(const EC_GROUP *group,
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t y_buf[EC_MAX_BYTES];
|
||||
size_t field_len_out;
|
||||
if (!ec_point_get_affine_coordinate_bytes(
|
||||
group, buf + 1 /* x */,
|
||||
form == POINT_CONVERSION_COMPRESSED ? y_buf : buf + 1 + field_len,
|
||||
&field_len_out, field_len, point)) {
|
||||
return 0;
|
||||
}
|
||||
ec_felem_to_bytes(group, buf + 1, &field_len_out, &point->X);
|
||||
assert(field_len_out == field_len);
|
||||
|
||||
if (field_len_out != field_len) {
|
||||
OPENSSL_PUT_ERROR(EC, ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (form == POINT_CONVERSION_COMPRESSED) {
|
||||
buf[0] = form + (y_buf[field_len - 1] & 1);
|
||||
} else {
|
||||
if (form == POINT_CONVERSION_UNCOMPRESSED) {
|
||||
ec_felem_to_bytes(group, buf + 1 + field_len, &field_len_out, &point->Y);
|
||||
assert(field_len_out == field_len);
|
||||
buf[0] = form;
|
||||
} else {
|
||||
uint8_t y_buf[EC_MAX_BYTES];
|
||||
ec_felem_to_bytes(group, y_buf, &field_len_out, &point->Y);
|
||||
buf[0] = form + (y_buf[field_len_out - 1] & 1);
|
||||
}
|
||||
}
|
||||
|
||||
return output_len;
|
||||
}
|
||||
|
||||
int ec_point_from_uncompressed(const EC_GROUP *group, EC_AFFINE *out,
|
||||
const uint8_t *in, size_t len) {
|
||||
const size_t field_len = BN_num_bytes(&group->field);
|
||||
if (len != 1 + 2 * field_len || in[0] != POINT_CONVERSION_UNCOMPRESSED) {
|
||||
OPENSSL_PUT_ERROR(EC, EC_R_INVALID_ENCODING);
|
||||
return 0;
|
||||
}
|
||||
|
||||
EC_FELEM x, y;
|
||||
if (!ec_felem_from_bytes(group, &x, in + 1, field_len) ||
|
||||
!ec_felem_from_bytes(group, &y, in + 1 + field_len, field_len) ||
|
||||
!ec_point_set_affine_coordinates(group, out, &x, &y)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ec_GFp_simple_oct2point(const EC_GROUP *group, EC_POINT *point,
|
||||
const uint8_t *buf, size_t len,
|
||||
BN_CTX *ctx) {
|
||||
BN_CTX *new_ctx = NULL;
|
||||
int ret = 0, used_ctx = 0;
|
||||
|
||||
if (len == 0) {
|
||||
OPENSSL_PUT_ERROR(EC, EC_R_BUFFER_TOO_SMALL);
|
||||
goto err;
|
||||
return 0;
|
||||
}
|
||||
|
||||
point_conversion_form_t form = buf[0];
|
||||
const int y_bit = form & 1;
|
||||
form = form & ~1U;
|
||||
if ((form != POINT_CONVERSION_COMPRESSED &&
|
||||
form != POINT_CONVERSION_UNCOMPRESSED) ||
|
||||
(form == POINT_CONVERSION_UNCOMPRESSED && y_bit)) {
|
||||
OPENSSL_PUT_ERROR(EC, EC_R_INVALID_ENCODING);
|
||||
goto err;
|
||||
}
|
||||
|
||||
const size_t field_len = BN_num_bytes(&group->field);
|
||||
size_t enc_len = 1 /* type byte */ + field_len;
|
||||
if (form == POINT_CONVERSION_UNCOMPRESSED) {
|
||||
// Uncompressed points have a second coordinate.
|
||||
enc_len += field_len;
|
||||
EC_AFFINE affine;
|
||||
if (!ec_point_from_uncompressed(group, &affine, buf, len)) {
|
||||
// In the event of an error, defend against the caller not checking the
|
||||
// return value by setting a known safe value.
|
||||
ec_set_to_safe_point(group, &point->raw);
|
||||
return 0;
|
||||
}
|
||||
ec_affine_to_jacobian(group, &point->raw, &affine);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (len != enc_len) {
|
||||
const int y_bit = form & 1;
|
||||
const size_t field_len = BN_num_bytes(&group->field);
|
||||
form = form & ~1u;
|
||||
if (form != POINT_CONVERSION_COMPRESSED ||
|
||||
len != 1 /* type byte */ + field_len) {
|
||||
OPENSSL_PUT_ERROR(EC, EC_R_INVALID_ENCODING);
|
||||
goto err;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// TODO(davidben): Integrate compressed coordinates with the lower-level EC
|
||||
// abstractions. This requires a way to compute square roots, which is tricky
|
||||
// for primes which are not 3 (mod 4), namely P-224 and custom curves. P-224's
|
||||
// prime is particularly inconvenient for compressed coordinates. See
|
||||
// https://cr.yp.to/papers/sqroot.pdf
|
||||
BN_CTX *new_ctx = NULL;
|
||||
if (ctx == NULL) {
|
||||
ctx = new_ctx = BN_CTX_new();
|
||||
if (ctx == NULL) {
|
||||
goto err;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ret = 0;
|
||||
BN_CTX_start(ctx);
|
||||
used_ctx = 1;
|
||||
BIGNUM *x = BN_CTX_get(ctx);
|
||||
BIGNUM *y = BN_CTX_get(ctx);
|
||||
if (x == NULL || y == NULL) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!BN_bin2bn(buf + 1, field_len, x)) {
|
||||
if (x == NULL || !BN_bin2bn(buf + 1, field_len, x)) {
|
||||
goto err;
|
||||
}
|
||||
if (BN_ucmp(x, &group->field) >= 0) {
|
||||
@@ -182,30 +186,14 @@ static int ec_GFp_simple_oct2point(const EC_GROUP *group, EC_POINT *point,
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (form == POINT_CONVERSION_COMPRESSED) {
|
||||
if (!EC_POINT_set_compressed_coordinates_GFp(group, point, x, y_bit, ctx)) {
|
||||
goto err;
|
||||
}
|
||||
} else {
|
||||
if (!BN_bin2bn(buf + 1 + field_len, field_len, y)) {
|
||||
goto err;
|
||||
}
|
||||
if (BN_ucmp(y, &group->field) >= 0) {
|
||||
OPENSSL_PUT_ERROR(EC, EC_R_INVALID_ENCODING);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!EC_POINT_set_affine_coordinates_GFp(group, point, x, y, ctx)) {
|
||||
goto err;
|
||||
}
|
||||
if (!EC_POINT_set_compressed_coordinates_GFp(group, point, x, y_bit, ctx)) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = 1;
|
||||
|
||||
err:
|
||||
if (used_ctx) {
|
||||
BN_CTX_end(ctx);
|
||||
}
|
||||
BN_CTX_end(ctx);
|
||||
BN_CTX_free(new_ctx);
|
||||
return ret;
|
||||
}
|
||||
@@ -226,7 +214,11 @@ size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *point,
|
||||
OPENSSL_PUT_ERROR(EC, EC_R_INCOMPATIBLE_OBJECTS);
|
||||
return 0;
|
||||
}
|
||||
return ec_GFp_simple_point2oct(group, &point->raw, form, buf, len);
|
||||
EC_AFFINE affine;
|
||||
if (!ec_jacobian_to_affine(group, &affine, &point->raw)) {
|
||||
return 0;
|
||||
}
|
||||
return ec_point_to_bytes(group, &affine, form, buf, len);
|
||||
}
|
||||
|
||||
int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group,
|
||||
|
||||
@@ -1154,16 +1154,6 @@ static void ec_GFp_nistp224_felem_sqr(const EC_GROUP *group, EC_FELEM *r,
|
||||
p224_felem_to_generic(r, felem);
|
||||
}
|
||||
|
||||
static int ec_GFp_nistp224_bignum_to_felem(const EC_GROUP *group, EC_FELEM *out,
|
||||
const BIGNUM *in) {
|
||||
return bn_copy_words(out->words, group->field.width, in);
|
||||
}
|
||||
|
||||
static int ec_GFp_nistp224_felem_to_bignum(const EC_GROUP *group, BIGNUM *out,
|
||||
const EC_FELEM *in) {
|
||||
return bn_set_words(out, in->words, group->field.width);
|
||||
}
|
||||
|
||||
DEFINE_METHOD_FUNCTION(EC_METHOD, EC_GFp_nistp224_method) {
|
||||
out->group_init = ec_GFp_simple_group_init;
|
||||
out->group_finish = ec_GFp_simple_group_finish;
|
||||
@@ -1177,10 +1167,11 @@ DEFINE_METHOD_FUNCTION(EC_METHOD, EC_GFp_nistp224_method) {
|
||||
out->mul_public = ec_GFp_nistp224_point_mul_public;
|
||||
out->felem_mul = ec_GFp_nistp224_felem_mul;
|
||||
out->felem_sqr = ec_GFp_nistp224_felem_sqr;
|
||||
out->bignum_to_felem = ec_GFp_nistp224_bignum_to_felem;
|
||||
out->felem_to_bignum = ec_GFp_nistp224_felem_to_bignum;
|
||||
out->scalar_inv_montgomery = ec_simple_scalar_inv_montgomery;
|
||||
out->scalar_inv_montgomery_vartime = ec_GFp_simple_mont_inv_mod_ord_vartime;
|
||||
out->felem_to_bytes = ec_GFp_simple_felem_to_bytes;
|
||||
out->felem_from_bytes = ec_GFp_simple_felem_from_bytes;
|
||||
out->scalar_inv0_montgomery = ec_simple_scalar_inv0_montgomery;
|
||||
out->scalar_to_montgomery_inv_vartime =
|
||||
ec_simple_scalar_to_montgomery_inv_vartime;
|
||||
out->cmp_x_coordinate = ec_GFp_simple_cmp_x_coordinate;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -119,86 +119,73 @@ static BN_ULONG is_not_zero(BN_ULONG in) {
|
||||
return in;
|
||||
}
|
||||
|
||||
// ecp_nistz256_mod_inverse_mont sets |r| to (|in| * 2^-256)^-1 * 2^256 mod p.
|
||||
// That is, |r| is the modular inverse of |in| for input and output in the
|
||||
// Montgomery domain.
|
||||
static void ecp_nistz256_mod_inverse_mont(BN_ULONG r[P256_LIMBS],
|
||||
const BN_ULONG in[P256_LIMBS]) {
|
||||
/* The poly is ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff
|
||||
ffffffff
|
||||
We use FLT and used poly-2 as exponent */
|
||||
BN_ULONG p2[P256_LIMBS];
|
||||
BN_ULONG p4[P256_LIMBS];
|
||||
BN_ULONG p8[P256_LIMBS];
|
||||
BN_ULONG p16[P256_LIMBS];
|
||||
BN_ULONG p32[P256_LIMBS];
|
||||
BN_ULONG res[P256_LIMBS];
|
||||
int i;
|
||||
// ecp_nistz256_mod_inverse_sqr_mont sets |r| to (|in| * 2^-256)^-2 * 2^256 mod
|
||||
// p. That is, |r| is the modular inverse square of |in| for input and output in
|
||||
// the Montgomery domain.
|
||||
static void ecp_nistz256_mod_inverse_sqr_mont(BN_ULONG r[P256_LIMBS],
|
||||
const BN_ULONG in[P256_LIMBS]) {
|
||||
// This implements the addition chain described in
|
||||
// https://briansmith.org/ecc-inversion-addition-chains-01#p256_field_inversion
|
||||
BN_ULONG x2[P256_LIMBS], x3[P256_LIMBS], x6[P256_LIMBS], x12[P256_LIMBS],
|
||||
x15[P256_LIMBS], x30[P256_LIMBS], x32[P256_LIMBS];
|
||||
ecp_nistz256_sqr_mont(x2, in); // 2^2 - 2^1
|
||||
ecp_nistz256_mul_mont(x2, x2, in); // 2^2 - 2^0
|
||||
|
||||
ecp_nistz256_sqr_mont(res, in);
|
||||
ecp_nistz256_mul_mont(p2, res, in); // 3*p
|
||||
ecp_nistz256_sqr_mont(x3, x2); // 2^3 - 2^1
|
||||
ecp_nistz256_mul_mont(x3, x3, in); // 2^3 - 2^0
|
||||
|
||||
ecp_nistz256_sqr_mont(res, p2);
|
||||
ecp_nistz256_sqr_mont(res, res);
|
||||
ecp_nistz256_mul_mont(p4, res, p2); // f*p
|
||||
ecp_nistz256_sqr_mont(x6, x3);
|
||||
for (int i = 1; i < 3; i++) {
|
||||
ecp_nistz256_sqr_mont(x6, x6);
|
||||
} // 2^6 - 2^3
|
||||
ecp_nistz256_mul_mont(x6, x6, x3); // 2^6 - 2^0
|
||||
|
||||
ecp_nistz256_sqr_mont(res, p4);
|
||||
ecp_nistz256_sqr_mont(res, res);
|
||||
ecp_nistz256_sqr_mont(res, res);
|
||||
ecp_nistz256_sqr_mont(res, res);
|
||||
ecp_nistz256_mul_mont(p8, res, p4); // ff*p
|
||||
ecp_nistz256_sqr_mont(x12, x6);
|
||||
for (int i = 1; i < 6; i++) {
|
||||
ecp_nistz256_sqr_mont(x12, x12);
|
||||
} // 2^12 - 2^6
|
||||
ecp_nistz256_mul_mont(x12, x12, x6); // 2^12 - 2^0
|
||||
|
||||
ecp_nistz256_sqr_mont(res, p8);
|
||||
for (i = 0; i < 7; i++) {
|
||||
ecp_nistz256_sqr_mont(res, res);
|
||||
}
|
||||
ecp_nistz256_mul_mont(p16, res, p8); // ffff*p
|
||||
ecp_nistz256_sqr_mont(x15, x12);
|
||||
for (int i = 1; i < 3; i++) {
|
||||
ecp_nistz256_sqr_mont(x15, x15);
|
||||
} // 2^15 - 2^3
|
||||
ecp_nistz256_mul_mont(x15, x15, x3); // 2^15 - 2^0
|
||||
|
||||
ecp_nistz256_sqr_mont(res, p16);
|
||||
for (i = 0; i < 15; i++) {
|
||||
ecp_nistz256_sqr_mont(res, res);
|
||||
}
|
||||
ecp_nistz256_mul_mont(p32, res, p16); // ffffffff*p
|
||||
ecp_nistz256_sqr_mont(x30, x15);
|
||||
for (int i = 1; i < 15; i++) {
|
||||
ecp_nistz256_sqr_mont(x30, x30);
|
||||
} // 2^30 - 2^15
|
||||
ecp_nistz256_mul_mont(x30, x30, x15); // 2^30 - 2^0
|
||||
|
||||
ecp_nistz256_sqr_mont(res, p32);
|
||||
for (i = 0; i < 31; i++) {
|
||||
ecp_nistz256_sqr_mont(res, res);
|
||||
}
|
||||
ecp_nistz256_mul_mont(res, res, in);
|
||||
ecp_nistz256_sqr_mont(x32, x30);
|
||||
ecp_nistz256_sqr_mont(x32, x32); // 2^32 - 2^2
|
||||
ecp_nistz256_mul_mont(x32, x32, x2); // 2^32 - 2^0
|
||||
|
||||
for (i = 0; i < 32 * 4; i++) {
|
||||
ecp_nistz256_sqr_mont(res, res);
|
||||
}
|
||||
ecp_nistz256_mul_mont(res, res, p32);
|
||||
BN_ULONG ret[P256_LIMBS];
|
||||
ecp_nistz256_sqr_mont(ret, x32);
|
||||
for (int i = 1; i < 31 + 1; i++) {
|
||||
ecp_nistz256_sqr_mont(ret, ret);
|
||||
} // 2^64 - 2^32
|
||||
ecp_nistz256_mul_mont(ret, ret, in); // 2^64 - 2^32 + 2^0
|
||||
|
||||
for (i = 0; i < 32; i++) {
|
||||
ecp_nistz256_sqr_mont(res, res);
|
||||
}
|
||||
ecp_nistz256_mul_mont(res, res, p32);
|
||||
for (int i = 0; i < 96 + 32; i++) {
|
||||
ecp_nistz256_sqr_mont(ret, ret);
|
||||
} // 2^192 - 2^160 + 2^128
|
||||
ecp_nistz256_mul_mont(ret, ret, x32); // 2^192 - 2^160 + 2^128 + 2^32 - 2^0
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
ecp_nistz256_sqr_mont(res, res);
|
||||
}
|
||||
ecp_nistz256_mul_mont(res, res, p16);
|
||||
for (int i = 0; i < 32; i++) {
|
||||
ecp_nistz256_sqr_mont(ret, ret);
|
||||
} // 2^224 - 2^192 + 2^160 + 2^64 - 2^32
|
||||
ecp_nistz256_mul_mont(ret, ret, x32); // 2^224 - 2^192 + 2^160 + 2^64 - 2^0
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
ecp_nistz256_sqr_mont(res, res);
|
||||
}
|
||||
ecp_nistz256_mul_mont(res, res, p8);
|
||||
for (int i = 0; i < 30; i++) {
|
||||
ecp_nistz256_sqr_mont(ret, ret);
|
||||
} // 2^254 - 2^222 + 2^190 + 2^94 - 2^30
|
||||
ecp_nistz256_mul_mont(ret, ret, x30); // 2^254 - 2^222 + 2^190 + 2^94 - 2^0
|
||||
|
||||
ecp_nistz256_sqr_mont(res, res);
|
||||
ecp_nistz256_sqr_mont(res, res);
|
||||
ecp_nistz256_sqr_mont(res, res);
|
||||
ecp_nistz256_sqr_mont(res, res);
|
||||
ecp_nistz256_mul_mont(res, res, p4);
|
||||
|
||||
ecp_nistz256_sqr_mont(res, res);
|
||||
ecp_nistz256_sqr_mont(res, res);
|
||||
ecp_nistz256_mul_mont(res, res, p2);
|
||||
|
||||
ecp_nistz256_sqr_mont(res, res);
|
||||
ecp_nistz256_sqr_mont(res, res);
|
||||
ecp_nistz256_mul_mont(r, res, in);
|
||||
ecp_nistz256_sqr_mont(ret, ret);
|
||||
ecp_nistz256_sqr_mont(r, ret); // 2^256 - 2^224 + 2^192 + 2^96 - 2^2
|
||||
}
|
||||
|
||||
// r = p * p_scalar
|
||||
@@ -442,24 +429,17 @@ static int ecp_nistz256_get_affine(const EC_GROUP *group,
|
||||
}
|
||||
|
||||
BN_ULONG z_inv2[P256_LIMBS];
|
||||
BN_ULONG z_inv3[P256_LIMBS];
|
||||
assert(group->field.width == P256_LIMBS);
|
||||
ecp_nistz256_mod_inverse_mont(z_inv3, point->Z.words);
|
||||
ecp_nistz256_sqr_mont(z_inv2, z_inv3);
|
||||
|
||||
// Instead of using |ecp_nistz256_from_mont| to convert the |x| coordinate
|
||||
// and then calling |ecp_nistz256_from_mont| again to convert the |y|
|
||||
// coordinate below, convert the common factor |z_inv2| once now, saving one
|
||||
// reduction.
|
||||
ecp_nistz256_from_mont(z_inv2, z_inv2);
|
||||
ecp_nistz256_mod_inverse_sqr_mont(z_inv2, point->Z.words);
|
||||
|
||||
if (x != NULL) {
|
||||
ecp_nistz256_mul_mont(x->words, z_inv2, point->X.words);
|
||||
}
|
||||
|
||||
if (y != NULL) {
|
||||
ecp_nistz256_mul_mont(z_inv3, z_inv3, z_inv2);
|
||||
ecp_nistz256_mul_mont(y->words, z_inv3, point->Y.words);
|
||||
ecp_nistz256_sqr_mont(z_inv2, z_inv2); // z^-4
|
||||
ecp_nistz256_mul_mont(y->words, point->Y.words, point->Z.words); // y * z
|
||||
ecp_nistz256_mul_mont(y->words, y->words, z_inv2); // y * z^-3
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -492,8 +472,8 @@ static void ecp_nistz256_dbl(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
OPENSSL_memcpy(r->Z.words, a.Z, P256_LIMBS * sizeof(BN_ULONG));
|
||||
}
|
||||
|
||||
static void ecp_nistz256_inv_mod_ord(const EC_GROUP *group, EC_SCALAR *out,
|
||||
const EC_SCALAR *in) {
|
||||
static void ecp_nistz256_inv0_mod_ord(const EC_GROUP *group, EC_SCALAR *out,
|
||||
const EC_SCALAR *in) {
|
||||
// table[i] stores a power of |in| corresponding to the matching enum value.
|
||||
enum {
|
||||
// The following indices specify the power in binary.
|
||||
@@ -573,12 +553,12 @@ static void ecp_nistz256_inv_mod_ord(const EC_GROUP *group, EC_SCALAR *out,
|
||||
}
|
||||
}
|
||||
|
||||
static int ecp_nistz256_mont_inv_mod_ord_vartime(const EC_GROUP *group,
|
||||
static int ecp_nistz256_scalar_to_montgomery_inv_vartime(const EC_GROUP *group,
|
||||
EC_SCALAR *out,
|
||||
const EC_SCALAR *in) {
|
||||
if ((OPENSSL_ia32cap_get()[1] & (1 << 28)) == 0) {
|
||||
// No AVX support; fallback to generic code.
|
||||
return ec_GFp_simple_mont_inv_mod_ord_vartime(group, out, in);
|
||||
return ec_simple_scalar_to_montgomery_inv_vartime(group, out, in);
|
||||
}
|
||||
|
||||
assert(group->order.width == P256_LIMBS);
|
||||
@@ -642,10 +622,11 @@ DEFINE_METHOD_FUNCTION(EC_METHOD, EC_GFp_nistz256_method) {
|
||||
out->mul_public = ecp_nistz256_points_mul_public;
|
||||
out->felem_mul = ec_GFp_mont_felem_mul;
|
||||
out->felem_sqr = ec_GFp_mont_felem_sqr;
|
||||
out->bignum_to_felem = ec_GFp_mont_bignum_to_felem;
|
||||
out->felem_to_bignum = ec_GFp_mont_felem_to_bignum;
|
||||
out->scalar_inv_montgomery = ecp_nistz256_inv_mod_ord;
|
||||
out->scalar_inv_montgomery_vartime = ecp_nistz256_mont_inv_mod_ord_vartime;
|
||||
out->felem_to_bytes = ec_GFp_mont_felem_to_bytes;
|
||||
out->felem_from_bytes = ec_GFp_mont_felem_from_bytes;
|
||||
out->scalar_inv0_montgomery = ecp_nistz256_inv0_mod_ord;
|
||||
out->scalar_to_montgomery_inv_vartime =
|
||||
ecp_nistz256_scalar_to_montgomery_inv_vartime;
|
||||
out->cmp_x_coordinate = ecp_nistz256_cmp_x_coordinate;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,736 @@
|
||||
/* Copyright (c) 2020, Google Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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. */
|
||||
|
||||
// An implementation of the NIST P-256 elliptic curve point multiplication.
|
||||
// 256-bit Montgomery form for 64 and 32-bit. Field operations are generated by
|
||||
// Fiat, which lives in //third_party/fiat.
|
||||
|
||||
#include <CCryptoBoringSSL_base.h>
|
||||
|
||||
#include <CCryptoBoringSSL_bn.h>
|
||||
#include <CCryptoBoringSSL_ec.h>
|
||||
#include <CCryptoBoringSSL_err.h>
|
||||
#include <CCryptoBoringSSL_mem.h>
|
||||
#include <CCryptoBoringSSL_type_check.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../../internal.h"
|
||||
#include "../delocate.h"
|
||||
#include "./internal.h"
|
||||
|
||||
|
||||
// MSVC does not implement uint128_t, and crashes with intrinsics
|
||||
#if defined(BORINGSSL_HAS_UINT128)
|
||||
#define BORINGSSL_NISTP256_64BIT 1
|
||||
#include "../../../third_party/fiat/p256_64.h"
|
||||
#else
|
||||
#include "../../../third_party/fiat/p256_32.h"
|
||||
#endif
|
||||
|
||||
|
||||
// utility functions, handwritten
|
||||
|
||||
#if defined(BORINGSSL_NISTP256_64BIT)
|
||||
#define FIAT_P256_NLIMBS 4
|
||||
typedef uint64_t fiat_p256_limb_t;
|
||||
typedef uint64_t fiat_p256_felem[FIAT_P256_NLIMBS];
|
||||
static const fiat_p256_felem fiat_p256_one = {0x1, 0xffffffff00000000,
|
||||
0xffffffffffffffff, 0xfffffffe};
|
||||
#else // 64BIT; else 32BIT
|
||||
#define FIAT_P256_NLIMBS 8
|
||||
typedef uint32_t fiat_p256_limb_t;
|
||||
typedef uint32_t fiat_p256_felem[FIAT_P256_NLIMBS];
|
||||
static const fiat_p256_felem fiat_p256_one = {
|
||||
0x1, 0x0, 0x0, 0xffffffff, 0xffffffff, 0xffffffff, 0xfffffffe, 0x0};
|
||||
#endif // 64BIT
|
||||
|
||||
|
||||
static fiat_p256_limb_t fiat_p256_nz(
|
||||
const fiat_p256_limb_t in1[FIAT_P256_NLIMBS]) {
|
||||
fiat_p256_limb_t ret;
|
||||
fiat_p256_nonzero(&ret, in1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void fiat_p256_copy(fiat_p256_limb_t out[FIAT_P256_NLIMBS],
|
||||
const fiat_p256_limb_t in1[FIAT_P256_NLIMBS]) {
|
||||
for (int i = 0; i < FIAT_P256_NLIMBS; i++) {
|
||||
out[i] = in1[i];
|
||||
}
|
||||
}
|
||||
|
||||
static void fiat_p256_cmovznz(fiat_p256_limb_t out[FIAT_P256_NLIMBS],
|
||||
fiat_p256_limb_t t,
|
||||
const fiat_p256_limb_t z[FIAT_P256_NLIMBS],
|
||||
const fiat_p256_limb_t nz[FIAT_P256_NLIMBS]) {
|
||||
fiat_p256_selectznz(out, !!t, z, nz);
|
||||
}
|
||||
|
||||
static void fiat_p256_from_generic(fiat_p256_felem out, const EC_FELEM *in) {
|
||||
fiat_p256_from_bytes(out, in->bytes);
|
||||
}
|
||||
|
||||
static void fiat_p256_to_generic(EC_FELEM *out, const fiat_p256_felem in) {
|
||||
// This works because 256 is a multiple of 64, so there are no excess bytes to
|
||||
// zero when rounding up to |BN_ULONG|s.
|
||||
OPENSSL_STATIC_ASSERT(
|
||||
256 / 8 == sizeof(BN_ULONG) * ((256 + BN_BITS2 - 1) / BN_BITS2),
|
||||
"fiat_p256_to_bytes leaves bytes uninitialized");
|
||||
fiat_p256_to_bytes(out->bytes, in);
|
||||
}
|
||||
|
||||
// fiat_p256_inv_square calculates |out| = |in|^{-2}
|
||||
//
|
||||
// Based on Fermat's Little Theorem:
|
||||
// a^p = a (mod p)
|
||||
// a^{p-1} = 1 (mod p)
|
||||
// a^{p-3} = a^{-2} (mod p)
|
||||
static void fiat_p256_inv_square(fiat_p256_felem out,
|
||||
const fiat_p256_felem in) {
|
||||
// This implements the addition chain described in
|
||||
// https://briansmith.org/ecc-inversion-addition-chains-01#p256_field_inversion
|
||||
fiat_p256_felem x2, x3, x6, x12, x15, x30, x32;
|
||||
fiat_p256_square(x2, in); // 2^2 - 2^1
|
||||
fiat_p256_mul(x2, x2, in); // 2^2 - 2^0
|
||||
|
||||
fiat_p256_square(x3, x2); // 2^3 - 2^1
|
||||
fiat_p256_mul(x3, x3, in); // 2^3 - 2^0
|
||||
|
||||
fiat_p256_square(x6, x3);
|
||||
for (int i = 1; i < 3; i++) {
|
||||
fiat_p256_square(x6, x6);
|
||||
} // 2^6 - 2^3
|
||||
fiat_p256_mul(x6, x6, x3); // 2^6 - 2^0
|
||||
|
||||
fiat_p256_square(x12, x6);
|
||||
for (int i = 1; i < 6; i++) {
|
||||
fiat_p256_square(x12, x12);
|
||||
} // 2^12 - 2^6
|
||||
fiat_p256_mul(x12, x12, x6); // 2^12 - 2^0
|
||||
|
||||
fiat_p256_square(x15, x12);
|
||||
for (int i = 1; i < 3; i++) {
|
||||
fiat_p256_square(x15, x15);
|
||||
} // 2^15 - 2^3
|
||||
fiat_p256_mul(x15, x15, x3); // 2^15 - 2^0
|
||||
|
||||
fiat_p256_square(x30, x15);
|
||||
for (int i = 1; i < 15; i++) {
|
||||
fiat_p256_square(x30, x30);
|
||||
} // 2^30 - 2^15
|
||||
fiat_p256_mul(x30, x30, x15); // 2^30 - 2^0
|
||||
|
||||
fiat_p256_square(x32, x30);
|
||||
fiat_p256_square(x32, x32); // 2^32 - 2^2
|
||||
fiat_p256_mul(x32, x32, x2); // 2^32 - 2^0
|
||||
|
||||
fiat_p256_felem ret;
|
||||
fiat_p256_square(ret, x32);
|
||||
for (int i = 1; i < 31 + 1; i++) {
|
||||
fiat_p256_square(ret, ret);
|
||||
} // 2^64 - 2^32
|
||||
fiat_p256_mul(ret, ret, in); // 2^64 - 2^32 + 2^0
|
||||
|
||||
for (int i = 0; i < 96 + 32; i++) {
|
||||
fiat_p256_square(ret, ret);
|
||||
} // 2^192 - 2^160 + 2^128
|
||||
fiat_p256_mul(ret, ret, x32); // 2^192 - 2^160 + 2^128 + 2^32 - 2^0
|
||||
|
||||
for (int i = 0; i < 32; i++) {
|
||||
fiat_p256_square(ret, ret);
|
||||
} // 2^224 - 2^192 + 2^160 + 2^64 - 2^32
|
||||
fiat_p256_mul(ret, ret, x32); // 2^224 - 2^192 + 2^160 + 2^64 - 2^0
|
||||
|
||||
for (int i = 0; i < 30; i++) {
|
||||
fiat_p256_square(ret, ret);
|
||||
} // 2^254 - 2^222 + 2^190 + 2^94 - 2^30
|
||||
fiat_p256_mul(ret, ret, x30); // 2^254 - 2^222 + 2^190 + 2^94 - 2^0
|
||||
|
||||
fiat_p256_square(ret, ret);
|
||||
fiat_p256_square(out, ret); // 2^256 - 2^224 + 2^192 + 2^96 - 2^2
|
||||
}
|
||||
|
||||
// Group operations
|
||||
// ----------------
|
||||
//
|
||||
// Building on top of the field operations we have the operations on the
|
||||
// elliptic curve group itself. Points on the curve are represented in Jacobian
|
||||
// coordinates.
|
||||
//
|
||||
// Both operations were transcribed to Coq and proven to correspond to naive
|
||||
// implementations using Affine coordinates, for all suitable fields. In the
|
||||
// Coq proofs, issues of constant-time execution and memory layout (aliasing)
|
||||
// conventions were not considered. Specification of affine coordinates:
|
||||
// <https://github.com/mit-plv/fiat-crypto/blob/79f8b5f39ed609339f0233098dee1a3c4e6b3080/src/Spec/WeierstrassCurve.v#L28>
|
||||
// As a sanity check, a proof that these points form a commutative group:
|
||||
// <https://github.com/mit-plv/fiat-crypto/blob/79f8b5f39ed609339f0233098dee1a3c4e6b3080/src/Curves/Weierstrass/AffineProofs.v#L33>
|
||||
|
||||
// fiat_p256_point_double calculates 2*(x_in, y_in, z_in)
|
||||
//
|
||||
// The method is taken from:
|
||||
// http://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b
|
||||
//
|
||||
// Coq transcription and correctness proof:
|
||||
// <https://github.com/mit-plv/fiat-crypto/blob/79f8b5f39ed609339f0233098dee1a3c4e6b3080/src/Curves/Weierstrass/Jacobian.v#L93>
|
||||
// <https://github.com/mit-plv/fiat-crypto/blob/79f8b5f39ed609339f0233098dee1a3c4e6b3080/src/Curves/Weierstrass/Jacobian.v#L201>
|
||||
//
|
||||
// Outputs can equal corresponding inputs, i.e., x_out == x_in is allowed.
|
||||
// while x_out == y_in is not (maybe this works, but it's not tested).
|
||||
static void fiat_p256_point_double(fiat_p256_felem x_out, fiat_p256_felem y_out,
|
||||
fiat_p256_felem z_out,
|
||||
const fiat_p256_felem x_in,
|
||||
const fiat_p256_felem y_in,
|
||||
const fiat_p256_felem z_in) {
|
||||
fiat_p256_felem delta, gamma, beta, ftmp, ftmp2, tmptmp, alpha, fourbeta;
|
||||
// delta = z^2
|
||||
fiat_p256_square(delta, z_in);
|
||||
// gamma = y^2
|
||||
fiat_p256_square(gamma, y_in);
|
||||
// beta = x*gamma
|
||||
fiat_p256_mul(beta, x_in, gamma);
|
||||
|
||||
// alpha = 3*(x-delta)*(x+delta)
|
||||
fiat_p256_sub(ftmp, x_in, delta);
|
||||
fiat_p256_add(ftmp2, x_in, delta);
|
||||
|
||||
fiat_p256_add(tmptmp, ftmp2, ftmp2);
|
||||
fiat_p256_add(ftmp2, ftmp2, tmptmp);
|
||||
fiat_p256_mul(alpha, ftmp, ftmp2);
|
||||
|
||||
// x' = alpha^2 - 8*beta
|
||||
fiat_p256_square(x_out, alpha);
|
||||
fiat_p256_add(fourbeta, beta, beta);
|
||||
fiat_p256_add(fourbeta, fourbeta, fourbeta);
|
||||
fiat_p256_add(tmptmp, fourbeta, fourbeta);
|
||||
fiat_p256_sub(x_out, x_out, tmptmp);
|
||||
|
||||
// z' = (y + z)^2 - gamma - delta
|
||||
fiat_p256_add(delta, gamma, delta);
|
||||
fiat_p256_add(ftmp, y_in, z_in);
|
||||
fiat_p256_square(z_out, ftmp);
|
||||
fiat_p256_sub(z_out, z_out, delta);
|
||||
|
||||
// y' = alpha*(4*beta - x') - 8*gamma^2
|
||||
fiat_p256_sub(y_out, fourbeta, x_out);
|
||||
fiat_p256_add(gamma, gamma, gamma);
|
||||
fiat_p256_square(gamma, gamma);
|
||||
fiat_p256_mul(y_out, alpha, y_out);
|
||||
fiat_p256_add(gamma, gamma, gamma);
|
||||
fiat_p256_sub(y_out, y_out, gamma);
|
||||
}
|
||||
|
||||
// fiat_p256_point_add calculates (x1, y1, z1) + (x2, y2, z2)
|
||||
//
|
||||
// The method is taken from:
|
||||
// http://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#addition-add-2007-bl,
|
||||
// adapted for mixed addition (z2 = 1, or z2 = 0 for the point at infinity).
|
||||
//
|
||||
// Coq transcription and correctness proof:
|
||||
// <https://github.com/mit-plv/fiat-crypto/blob/79f8b5f39ed609339f0233098dee1a3c4e6b3080/src/Curves/Weierstrass/Jacobian.v#L135>
|
||||
// <https://github.com/mit-plv/fiat-crypto/blob/79f8b5f39ed609339f0233098dee1a3c4e6b3080/src/Curves/Weierstrass/Jacobian.v#L205>
|
||||
//
|
||||
// This function includes a branch for checking whether the two input points
|
||||
// are equal, (while not equal to the point at infinity). This case never
|
||||
// happens during single point multiplication, so there is no timing leak for
|
||||
// ECDH or ECDSA signing.
|
||||
static void fiat_p256_point_add(fiat_p256_felem x3, fiat_p256_felem y3,
|
||||
fiat_p256_felem z3, const fiat_p256_felem x1,
|
||||
const fiat_p256_felem y1,
|
||||
const fiat_p256_felem z1, const int mixed,
|
||||
const fiat_p256_felem x2,
|
||||
const fiat_p256_felem y2,
|
||||
const fiat_p256_felem z2) {
|
||||
fiat_p256_felem x_out, y_out, z_out;
|
||||
fiat_p256_limb_t z1nz = fiat_p256_nz(z1);
|
||||
fiat_p256_limb_t z2nz = fiat_p256_nz(z2);
|
||||
|
||||
// z1z1 = z1z1 = z1**2
|
||||
fiat_p256_felem z1z1;
|
||||
fiat_p256_square(z1z1, z1);
|
||||
|
||||
fiat_p256_felem u1, s1, two_z1z2;
|
||||
if (!mixed) {
|
||||
// z2z2 = z2**2
|
||||
fiat_p256_felem z2z2;
|
||||
fiat_p256_square(z2z2, z2);
|
||||
|
||||
// u1 = x1*z2z2
|
||||
fiat_p256_mul(u1, x1, z2z2);
|
||||
|
||||
// two_z1z2 = (z1 + z2)**2 - (z1z1 + z2z2) = 2z1z2
|
||||
fiat_p256_add(two_z1z2, z1, z2);
|
||||
fiat_p256_square(two_z1z2, two_z1z2);
|
||||
fiat_p256_sub(two_z1z2, two_z1z2, z1z1);
|
||||
fiat_p256_sub(two_z1z2, two_z1z2, z2z2);
|
||||
|
||||
// s1 = y1 * z2**3
|
||||
fiat_p256_mul(s1, z2, z2z2);
|
||||
fiat_p256_mul(s1, s1, y1);
|
||||
} else {
|
||||
// We'll assume z2 = 1 (special case z2 = 0 is handled later).
|
||||
|
||||
// u1 = x1*z2z2
|
||||
fiat_p256_copy(u1, x1);
|
||||
// two_z1z2 = 2z1z2
|
||||
fiat_p256_add(two_z1z2, z1, z1);
|
||||
// s1 = y1 * z2**3
|
||||
fiat_p256_copy(s1, y1);
|
||||
}
|
||||
|
||||
// u2 = x2*z1z1
|
||||
fiat_p256_felem u2;
|
||||
fiat_p256_mul(u2, x2, z1z1);
|
||||
|
||||
// h = u2 - u1
|
||||
fiat_p256_felem h;
|
||||
fiat_p256_sub(h, u2, u1);
|
||||
|
||||
fiat_p256_limb_t xneq = fiat_p256_nz(h);
|
||||
|
||||
// z_out = two_z1z2 * h
|
||||
fiat_p256_mul(z_out, h, two_z1z2);
|
||||
|
||||
// z1z1z1 = z1 * z1z1
|
||||
fiat_p256_felem z1z1z1;
|
||||
fiat_p256_mul(z1z1z1, z1, z1z1);
|
||||
|
||||
// s2 = y2 * z1**3
|
||||
fiat_p256_felem s2;
|
||||
fiat_p256_mul(s2, y2, z1z1z1);
|
||||
|
||||
// r = (s2 - s1)*2
|
||||
fiat_p256_felem r;
|
||||
fiat_p256_sub(r, s2, s1);
|
||||
fiat_p256_add(r, r, r);
|
||||
|
||||
fiat_p256_limb_t yneq = fiat_p256_nz(r);
|
||||
|
||||
fiat_p256_limb_t is_nontrivial_double = constant_time_is_zero_w(xneq | yneq) &
|
||||
~constant_time_is_zero_w(z1nz) &
|
||||
~constant_time_is_zero_w(z2nz);
|
||||
if (is_nontrivial_double) {
|
||||
fiat_p256_point_double(x3, y3, z3, x1, y1, z1);
|
||||
return;
|
||||
}
|
||||
|
||||
// I = (2h)**2
|
||||
fiat_p256_felem i;
|
||||
fiat_p256_add(i, h, h);
|
||||
fiat_p256_square(i, i);
|
||||
|
||||
// J = h * I
|
||||
fiat_p256_felem j;
|
||||
fiat_p256_mul(j, h, i);
|
||||
|
||||
// V = U1 * I
|
||||
fiat_p256_felem v;
|
||||
fiat_p256_mul(v, u1, i);
|
||||
|
||||
// x_out = r**2 - J - 2V
|
||||
fiat_p256_square(x_out, r);
|
||||
fiat_p256_sub(x_out, x_out, j);
|
||||
fiat_p256_sub(x_out, x_out, v);
|
||||
fiat_p256_sub(x_out, x_out, v);
|
||||
|
||||
// y_out = r(V-x_out) - 2 * s1 * J
|
||||
fiat_p256_sub(y_out, v, x_out);
|
||||
fiat_p256_mul(y_out, y_out, r);
|
||||
fiat_p256_felem s1j;
|
||||
fiat_p256_mul(s1j, s1, j);
|
||||
fiat_p256_sub(y_out, y_out, s1j);
|
||||
fiat_p256_sub(y_out, y_out, s1j);
|
||||
|
||||
fiat_p256_cmovznz(x_out, z1nz, x2, x_out);
|
||||
fiat_p256_cmovznz(x3, z2nz, x1, x_out);
|
||||
fiat_p256_cmovznz(y_out, z1nz, y2, y_out);
|
||||
fiat_p256_cmovznz(y3, z2nz, y1, y_out);
|
||||
fiat_p256_cmovznz(z_out, z1nz, z2, z_out);
|
||||
fiat_p256_cmovznz(z3, z2nz, z1, z_out);
|
||||
}
|
||||
|
||||
#include "./p256_table.h"
|
||||
|
||||
// fiat_p256_select_point_affine selects the |idx-1|th point from a
|
||||
// precomputation table and copies it to out. If |idx| is zero, the output is
|
||||
// the point at infinity.
|
||||
static void fiat_p256_select_point_affine(
|
||||
const fiat_p256_limb_t idx, size_t size,
|
||||
const fiat_p256_felem pre_comp[/*size*/][2], fiat_p256_felem out[3]) {
|
||||
OPENSSL_memset(out, 0, sizeof(fiat_p256_felem) * 3);
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
fiat_p256_limb_t mismatch = i ^ (idx - 1);
|
||||
fiat_p256_cmovznz(out[0], mismatch, pre_comp[i][0], out[0]);
|
||||
fiat_p256_cmovznz(out[1], mismatch, pre_comp[i][1], out[1]);
|
||||
}
|
||||
fiat_p256_cmovznz(out[2], idx, out[2], fiat_p256_one);
|
||||
}
|
||||
|
||||
// fiat_p256_select_point selects the |idx|th point from a precomputation table
|
||||
// and copies it to out.
|
||||
static void fiat_p256_select_point(const fiat_p256_limb_t idx, size_t size,
|
||||
const fiat_p256_felem pre_comp[/*size*/][3],
|
||||
fiat_p256_felem out[3]) {
|
||||
OPENSSL_memset(out, 0, sizeof(fiat_p256_felem) * 3);
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
fiat_p256_limb_t mismatch = i ^ idx;
|
||||
fiat_p256_cmovznz(out[0], mismatch, pre_comp[i][0], out[0]);
|
||||
fiat_p256_cmovznz(out[1], mismatch, pre_comp[i][1], out[1]);
|
||||
fiat_p256_cmovznz(out[2], mismatch, pre_comp[i][2], out[2]);
|
||||
}
|
||||
}
|
||||
|
||||
// fiat_p256_get_bit returns the |i|th bit in |in|
|
||||
static char fiat_p256_get_bit(const uint8_t *in, int i) {
|
||||
if (i < 0 || i >= 256) {
|
||||
return 0;
|
||||
}
|
||||
return (in[i >> 3] >> (i & 7)) & 1;
|
||||
}
|
||||
|
||||
// OPENSSL EC_METHOD FUNCTIONS
|
||||
|
||||
// Takes the Jacobian coordinates (X, Y, Z) of a point and returns (X', Y') =
|
||||
// (X/Z^2, Y/Z^3).
|
||||
static int ec_GFp_nistp256_point_get_affine_coordinates(
|
||||
const EC_GROUP *group, const EC_RAW_POINT *point, EC_FELEM *x_out,
|
||||
EC_FELEM *y_out) {
|
||||
if (ec_GFp_simple_is_at_infinity(group, point)) {
|
||||
OPENSSL_PUT_ERROR(EC, EC_R_POINT_AT_INFINITY);
|
||||
return 0;
|
||||
}
|
||||
|
||||
fiat_p256_felem z1, z2;
|
||||
fiat_p256_from_generic(z1, &point->Z);
|
||||
fiat_p256_inv_square(z2, z1);
|
||||
|
||||
if (x_out != NULL) {
|
||||
fiat_p256_felem x;
|
||||
fiat_p256_from_generic(x, &point->X);
|
||||
fiat_p256_mul(x, x, z2);
|
||||
fiat_p256_to_generic(x_out, x);
|
||||
}
|
||||
|
||||
if (y_out != NULL) {
|
||||
fiat_p256_felem y;
|
||||
fiat_p256_from_generic(y, &point->Y);
|
||||
fiat_p256_square(z2, z2); // z^-4
|
||||
fiat_p256_mul(y, y, z1); // y * z
|
||||
fiat_p256_mul(y, y, z2); // y * z^-3
|
||||
fiat_p256_to_generic(y_out, y);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void ec_GFp_nistp256_add(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
const EC_RAW_POINT *a, const EC_RAW_POINT *b) {
|
||||
fiat_p256_felem x1, y1, z1, x2, y2, z2;
|
||||
fiat_p256_from_generic(x1, &a->X);
|
||||
fiat_p256_from_generic(y1, &a->Y);
|
||||
fiat_p256_from_generic(z1, &a->Z);
|
||||
fiat_p256_from_generic(x2, &b->X);
|
||||
fiat_p256_from_generic(y2, &b->Y);
|
||||
fiat_p256_from_generic(z2, &b->Z);
|
||||
fiat_p256_point_add(x1, y1, z1, x1, y1, z1, 0 /* both Jacobian */, x2, y2,
|
||||
z2);
|
||||
fiat_p256_to_generic(&r->X, x1);
|
||||
fiat_p256_to_generic(&r->Y, y1);
|
||||
fiat_p256_to_generic(&r->Z, z1);
|
||||
}
|
||||
|
||||
static void ec_GFp_nistp256_dbl(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
const EC_RAW_POINT *a) {
|
||||
fiat_p256_felem x, y, z;
|
||||
fiat_p256_from_generic(x, &a->X);
|
||||
fiat_p256_from_generic(y, &a->Y);
|
||||
fiat_p256_from_generic(z, &a->Z);
|
||||
fiat_p256_point_double(x, y, z, x, y, z);
|
||||
fiat_p256_to_generic(&r->X, x);
|
||||
fiat_p256_to_generic(&r->Y, y);
|
||||
fiat_p256_to_generic(&r->Z, z);
|
||||
}
|
||||
|
||||
static void ec_GFp_nistp256_point_mul(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
const EC_RAW_POINT *p,
|
||||
const EC_SCALAR *scalar) {
|
||||
fiat_p256_felem p_pre_comp[17][3];
|
||||
OPENSSL_memset(&p_pre_comp, 0, sizeof(p_pre_comp));
|
||||
// Precompute multiples.
|
||||
fiat_p256_from_generic(p_pre_comp[1][0], &p->X);
|
||||
fiat_p256_from_generic(p_pre_comp[1][1], &p->Y);
|
||||
fiat_p256_from_generic(p_pre_comp[1][2], &p->Z);
|
||||
for (size_t j = 2; j <= 16; ++j) {
|
||||
if (j & 1) {
|
||||
fiat_p256_point_add(p_pre_comp[j][0], p_pre_comp[j][1], p_pre_comp[j][2],
|
||||
p_pre_comp[1][0], p_pre_comp[1][1], p_pre_comp[1][2],
|
||||
0, p_pre_comp[j - 1][0], p_pre_comp[j - 1][1],
|
||||
p_pre_comp[j - 1][2]);
|
||||
} else {
|
||||
fiat_p256_point_double(p_pre_comp[j][0], p_pre_comp[j][1],
|
||||
p_pre_comp[j][2], p_pre_comp[j / 2][0],
|
||||
p_pre_comp[j / 2][1], p_pre_comp[j / 2][2]);
|
||||
}
|
||||
}
|
||||
|
||||
// Set nq to the point at infinity.
|
||||
fiat_p256_felem nq[3] = {{0}, {0}, {0}}, ftmp, tmp[3];
|
||||
|
||||
// Loop over |scalar| msb-to-lsb, incorporating |p_pre_comp| every 5th round.
|
||||
int skip = 1; // Save two point operations in the first round.
|
||||
for (size_t i = 255; i < 256; i--) {
|
||||
// double
|
||||
if (!skip) {
|
||||
fiat_p256_point_double(nq[0], nq[1], nq[2], nq[0], nq[1], nq[2]);
|
||||
}
|
||||
|
||||
// do other additions every 5 doublings
|
||||
if (i % 5 == 0) {
|
||||
uint64_t bits = fiat_p256_get_bit(scalar->bytes, i + 4) << 5;
|
||||
bits |= fiat_p256_get_bit(scalar->bytes, i + 3) << 4;
|
||||
bits |= fiat_p256_get_bit(scalar->bytes, i + 2) << 3;
|
||||
bits |= fiat_p256_get_bit(scalar->bytes, i + 1) << 2;
|
||||
bits |= fiat_p256_get_bit(scalar->bytes, i) << 1;
|
||||
bits |= fiat_p256_get_bit(scalar->bytes, i - 1);
|
||||
uint8_t sign, digit;
|
||||
ec_GFp_nistp_recode_scalar_bits(&sign, &digit, bits);
|
||||
|
||||
// select the point to add or subtract, in constant time.
|
||||
fiat_p256_select_point(digit, 17, (const fiat_p256_felem(*)[3])p_pre_comp,
|
||||
tmp);
|
||||
fiat_p256_opp(ftmp, tmp[1]); // (X, -Y, Z) is the negative point.
|
||||
fiat_p256_cmovznz(tmp[1], sign, tmp[1], ftmp);
|
||||
|
||||
if (!skip) {
|
||||
fiat_p256_point_add(nq[0], nq[1], nq[2], nq[0], nq[1], nq[2],
|
||||
0 /* mixed */, tmp[0], tmp[1], tmp[2]);
|
||||
} else {
|
||||
fiat_p256_copy(nq[0], tmp[0]);
|
||||
fiat_p256_copy(nq[1], tmp[1]);
|
||||
fiat_p256_copy(nq[2], tmp[2]);
|
||||
skip = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fiat_p256_to_generic(&r->X, nq[0]);
|
||||
fiat_p256_to_generic(&r->Y, nq[1]);
|
||||
fiat_p256_to_generic(&r->Z, nq[2]);
|
||||
}
|
||||
|
||||
static void ec_GFp_nistp256_point_mul_base(const EC_GROUP *group,
|
||||
EC_RAW_POINT *r,
|
||||
const EC_SCALAR *scalar) {
|
||||
// Set nq to the point at infinity.
|
||||
fiat_p256_felem nq[3] = {{0}, {0}, {0}}, tmp[3];
|
||||
|
||||
int skip = 1; // Save two point operations in the first round.
|
||||
for (size_t i = 31; i < 32; i--) {
|
||||
if (!skip) {
|
||||
fiat_p256_point_double(nq[0], nq[1], nq[2], nq[0], nq[1], nq[2]);
|
||||
}
|
||||
|
||||
// First, look 32 bits upwards.
|
||||
uint64_t bits = fiat_p256_get_bit(scalar->bytes, i + 224) << 3;
|
||||
bits |= fiat_p256_get_bit(scalar->bytes, i + 160) << 2;
|
||||
bits |= fiat_p256_get_bit(scalar->bytes, i + 96) << 1;
|
||||
bits |= fiat_p256_get_bit(scalar->bytes, i + 32);
|
||||
// Select the point to add, in constant time.
|
||||
fiat_p256_select_point_affine(bits, 15, fiat_p256_g_pre_comp[1], tmp);
|
||||
|
||||
if (!skip) {
|
||||
fiat_p256_point_add(nq[0], nq[1], nq[2], nq[0], nq[1], nq[2],
|
||||
1 /* mixed */, tmp[0], tmp[1], tmp[2]);
|
||||
} else {
|
||||
fiat_p256_copy(nq[0], tmp[0]);
|
||||
fiat_p256_copy(nq[1], tmp[1]);
|
||||
fiat_p256_copy(nq[2], tmp[2]);
|
||||
skip = 0;
|
||||
}
|
||||
|
||||
// Second, look at the current position.
|
||||
bits = fiat_p256_get_bit(scalar->bytes, i + 192) << 3;
|
||||
bits |= fiat_p256_get_bit(scalar->bytes, i + 128) << 2;
|
||||
bits |= fiat_p256_get_bit(scalar->bytes, i + 64) << 1;
|
||||
bits |= fiat_p256_get_bit(scalar->bytes, i);
|
||||
// Select the point to add, in constant time.
|
||||
fiat_p256_select_point_affine(bits, 15, fiat_p256_g_pre_comp[0], tmp);
|
||||
fiat_p256_point_add(nq[0], nq[1], nq[2], nq[0], nq[1], nq[2], 1 /* mixed */,
|
||||
tmp[0], tmp[1], tmp[2]);
|
||||
}
|
||||
|
||||
fiat_p256_to_generic(&r->X, nq[0]);
|
||||
fiat_p256_to_generic(&r->Y, nq[1]);
|
||||
fiat_p256_to_generic(&r->Z, nq[2]);
|
||||
}
|
||||
|
||||
static void ec_GFp_nistp256_point_mul_public(const EC_GROUP *group,
|
||||
EC_RAW_POINT *r,
|
||||
const EC_SCALAR *g_scalar,
|
||||
const EC_RAW_POINT *p,
|
||||
const EC_SCALAR *p_scalar) {
|
||||
#define P256_WSIZE_PUBLIC 4
|
||||
// Precompute multiples of |p|. p_pre_comp[i] is (2*i+1) * |p|.
|
||||
fiat_p256_felem p_pre_comp[1 << (P256_WSIZE_PUBLIC - 1)][3];
|
||||
fiat_p256_from_generic(p_pre_comp[0][0], &p->X);
|
||||
fiat_p256_from_generic(p_pre_comp[0][1], &p->Y);
|
||||
fiat_p256_from_generic(p_pre_comp[0][2], &p->Z);
|
||||
fiat_p256_felem p2[3];
|
||||
fiat_p256_point_double(p2[0], p2[1], p2[2], p_pre_comp[0][0],
|
||||
p_pre_comp[0][1], p_pre_comp[0][2]);
|
||||
for (size_t i = 1; i < OPENSSL_ARRAY_SIZE(p_pre_comp); i++) {
|
||||
fiat_p256_point_add(p_pre_comp[i][0], p_pre_comp[i][1], p_pre_comp[i][2],
|
||||
p_pre_comp[i - 1][0], p_pre_comp[i - 1][1],
|
||||
p_pre_comp[i - 1][2], 0 /* not mixed */, p2[0], p2[1],
|
||||
p2[2]);
|
||||
}
|
||||
|
||||
// Set up the coefficients for |p_scalar|.
|
||||
int8_t p_wNAF[257];
|
||||
ec_compute_wNAF(group, p_wNAF, p_scalar, 256, P256_WSIZE_PUBLIC);
|
||||
|
||||
// Set |ret| to the point at infinity.
|
||||
int skip = 1; // Save some point operations.
|
||||
fiat_p256_felem ret[3] = {{0}, {0}, {0}};
|
||||
for (int i = 256; i >= 0; i--) {
|
||||
if (!skip) {
|
||||
fiat_p256_point_double(ret[0], ret[1], ret[2], ret[0], ret[1], ret[2]);
|
||||
}
|
||||
|
||||
// For the |g_scalar|, we use the precomputed table without the
|
||||
// constant-time lookup.
|
||||
if (i <= 31) {
|
||||
// First, look 32 bits upwards.
|
||||
uint64_t bits = fiat_p256_get_bit(g_scalar->bytes, i + 224) << 3;
|
||||
bits |= fiat_p256_get_bit(g_scalar->bytes, i + 160) << 2;
|
||||
bits |= fiat_p256_get_bit(g_scalar->bytes, i + 96) << 1;
|
||||
bits |= fiat_p256_get_bit(g_scalar->bytes, i + 32);
|
||||
if (bits != 0) {
|
||||
fiat_p256_point_add(ret[0], ret[1], ret[2], ret[0], ret[1], ret[2],
|
||||
1 /* mixed */, fiat_p256_g_pre_comp[1][bits - 1][0],
|
||||
fiat_p256_g_pre_comp[1][bits - 1][1],
|
||||
fiat_p256_one);
|
||||
skip = 0;
|
||||
}
|
||||
|
||||
// Second, look at the current position.
|
||||
bits = fiat_p256_get_bit(g_scalar->bytes, i + 192) << 3;
|
||||
bits |= fiat_p256_get_bit(g_scalar->bytes, i + 128) << 2;
|
||||
bits |= fiat_p256_get_bit(g_scalar->bytes, i + 64) << 1;
|
||||
bits |= fiat_p256_get_bit(g_scalar->bytes, i);
|
||||
if (bits != 0) {
|
||||
fiat_p256_point_add(ret[0], ret[1], ret[2], ret[0], ret[1], ret[2],
|
||||
1 /* mixed */, fiat_p256_g_pre_comp[0][bits - 1][0],
|
||||
fiat_p256_g_pre_comp[0][bits - 1][1],
|
||||
fiat_p256_one);
|
||||
skip = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int digit = p_wNAF[i];
|
||||
if (digit != 0) {
|
||||
assert(digit & 1);
|
||||
int idx = digit < 0 ? (-digit) >> 1 : digit >> 1;
|
||||
fiat_p256_felem *y = &p_pre_comp[idx][1], tmp;
|
||||
if (digit < 0) {
|
||||
fiat_p256_opp(tmp, p_pre_comp[idx][1]);
|
||||
y = &tmp;
|
||||
}
|
||||
if (!skip) {
|
||||
fiat_p256_point_add(ret[0], ret[1], ret[2], ret[0], ret[1], ret[2],
|
||||
0 /* not mixed */, p_pre_comp[idx][0], *y,
|
||||
p_pre_comp[idx][2]);
|
||||
} else {
|
||||
fiat_p256_copy(ret[0], p_pre_comp[idx][0]);
|
||||
fiat_p256_copy(ret[1], *y);
|
||||
fiat_p256_copy(ret[2], p_pre_comp[idx][2]);
|
||||
skip = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fiat_p256_to_generic(&r->X, ret[0]);
|
||||
fiat_p256_to_generic(&r->Y, ret[1]);
|
||||
fiat_p256_to_generic(&r->Z, ret[2]);
|
||||
}
|
||||
|
||||
static int ec_GFp_nistp256_cmp_x_coordinate(const EC_GROUP *group,
|
||||
const EC_RAW_POINT *p,
|
||||
const EC_SCALAR *r) {
|
||||
if (ec_GFp_simple_is_at_infinity(group, p)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// We wish to compare X/Z^2 with r. This is equivalent to comparing X with
|
||||
// r*Z^2. Note that X and Z are represented in Montgomery form, while r is
|
||||
// not.
|
||||
fiat_p256_felem Z2_mont;
|
||||
fiat_p256_from_generic(Z2_mont, &p->Z);
|
||||
fiat_p256_mul(Z2_mont, Z2_mont, Z2_mont);
|
||||
|
||||
fiat_p256_felem r_Z2;
|
||||
fiat_p256_from_bytes(r_Z2, r->bytes); // r < order < p, so this is valid.
|
||||
fiat_p256_mul(r_Z2, r_Z2, Z2_mont);
|
||||
|
||||
fiat_p256_felem X;
|
||||
fiat_p256_from_generic(X, &p->X);
|
||||
fiat_p256_from_montgomery(X, X);
|
||||
|
||||
if (OPENSSL_memcmp(&r_Z2, &X, sizeof(r_Z2)) == 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// During signing the x coefficient is reduced modulo the group order.
|
||||
// Therefore there is a small possibility, less than 1/2^128, that group_order
|
||||
// < p.x < P. in that case we need not only to compare against |r| but also to
|
||||
// compare against r+group_order.
|
||||
assert(group->field.width == group->order.width);
|
||||
if (bn_less_than_words(r->words, group->field_minus_order.words,
|
||||
group->field.width)) {
|
||||
// We can ignore the carry because: r + group_order < p < 2^256.
|
||||
EC_FELEM tmp;
|
||||
bn_add_words(tmp.words, r->words, group->order.d, group->order.width);
|
||||
fiat_p256_from_generic(r_Z2, &tmp);
|
||||
fiat_p256_mul(r_Z2, r_Z2, Z2_mont);
|
||||
if (OPENSSL_memcmp(&r_Z2, &X, sizeof(r_Z2)) == 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_METHOD_FUNCTION(EC_METHOD, EC_GFp_nistp256_method) {
|
||||
out->group_init = ec_GFp_mont_group_init;
|
||||
out->group_finish = ec_GFp_mont_group_finish;
|
||||
out->group_set_curve = ec_GFp_mont_group_set_curve;
|
||||
out->point_get_affine_coordinates =
|
||||
ec_GFp_nistp256_point_get_affine_coordinates;
|
||||
out->add = ec_GFp_nistp256_add;
|
||||
out->dbl = ec_GFp_nistp256_dbl;
|
||||
out->mul = ec_GFp_nistp256_point_mul;
|
||||
out->mul_base = ec_GFp_nistp256_point_mul_base;
|
||||
out->mul_public = ec_GFp_nistp256_point_mul_public;
|
||||
out->felem_mul = ec_GFp_mont_felem_mul;
|
||||
out->felem_sqr = ec_GFp_mont_felem_sqr;
|
||||
out->felem_to_bytes = ec_GFp_mont_felem_to_bytes;
|
||||
out->felem_from_bytes = ec_GFp_mont_felem_from_bytes;
|
||||
out->scalar_inv0_montgomery = ec_simple_scalar_inv0_montgomery;
|
||||
out->scalar_to_montgomery_inv_vartime =
|
||||
ec_simple_scalar_to_montgomery_inv_vartime;
|
||||
out->cmp_x_coordinate = ec_GFp_nistp256_cmp_x_coordinate;
|
||||
}
|
||||
|
||||
#undef BORINGSSL_NISTP256_64BIT
|
||||
@@ -0,0 +1,297 @@
|
||||
/* Copyright (c) 2020, Google Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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. */
|
||||
|
||||
// This file is generated by make_tables.go.
|
||||
|
||||
// Base point pre computation
|
||||
// --------------------------
|
||||
//
|
||||
// Two different sorts of precomputed tables are used in the following code.
|
||||
// Each contain various points on the curve, where each point is three field
|
||||
// elements (x, y, z).
|
||||
//
|
||||
// For the base point table, z is usually 1 (0 for the point at infinity).
|
||||
// This table has 2 * 16 elements, starting with the following:
|
||||
// index | bits | point
|
||||
// ------+---------+------------------------------
|
||||
// 0 | 0 0 0 0 | 0G
|
||||
// 1 | 0 0 0 1 | 1G
|
||||
// 2 | 0 0 1 0 | 2^64G
|
||||
// 3 | 0 0 1 1 | (2^64 + 1)G
|
||||
// 4 | 0 1 0 0 | 2^128G
|
||||
// 5 | 0 1 0 1 | (2^128 + 1)G
|
||||
// 6 | 0 1 1 0 | (2^128 + 2^64)G
|
||||
// 7 | 0 1 1 1 | (2^128 + 2^64 + 1)G
|
||||
// 8 | 1 0 0 0 | 2^192G
|
||||
// 9 | 1 0 0 1 | (2^192 + 1)G
|
||||
// 10 | 1 0 1 0 | (2^192 + 2^64)G
|
||||
// 11 | 1 0 1 1 | (2^192 + 2^64 + 1)G
|
||||
// 12 | 1 1 0 0 | (2^192 + 2^128)G
|
||||
// 13 | 1 1 0 1 | (2^192 + 2^128 + 1)G
|
||||
// 14 | 1 1 1 0 | (2^192 + 2^128 + 2^64)G
|
||||
// 15 | 1 1 1 1 | (2^192 + 2^128 + 2^64 + 1)G
|
||||
// followed by a copy of this with each element multiplied by 2^32.
|
||||
//
|
||||
// The reason for this is so that we can clock bits into four different
|
||||
// locations when doing simple scalar multiplies against the base point,
|
||||
// and then another four locations using the second 16 elements.
|
||||
//
|
||||
// Tables for other points have table[i] = iG for i in 0 .. 16.
|
||||
|
||||
// fiat_p256_g_pre_comp is the table of precomputed base points
|
||||
#if defined(BORINGSSL_NISTP256_64BIT)
|
||||
static const fiat_p256_felem fiat_p256_g_pre_comp[2][15][2] = {
|
||||
{{{0x79e730d418a9143c, 0x75ba95fc5fedb601, 0x79fb732b77622510,
|
||||
0x18905f76a53755c6},
|
||||
{0xddf25357ce95560a, 0x8b4ab8e4ba19e45c, 0xd2e88688dd21f325,
|
||||
0x8571ff1825885d85}},
|
||||
{{0x4f922fc516a0d2bb, 0x0d5cc16c1a623499, 0x9241cf3a57c62c8b,
|
||||
0x2f5e6961fd1b667f},
|
||||
{0x5c15c70bf5a01797, 0x3d20b44d60956192, 0x04911b37071fdb52,
|
||||
0xf648f9168d6f0f7b}},
|
||||
{{0x9e566847e137bbbc, 0xe434469e8a6a0bec, 0xb1c4276179d73463,
|
||||
0x5abe0285133d0015},
|
||||
{0x92aa837cc04c7dab, 0x573d9f4c43260c07, 0x0c93156278e6cc37,
|
||||
0x94bb725b6b6f7383}},
|
||||
{{0x62a8c244bfe20925, 0x91c19ac38fdce867, 0x5a96a5d5dd387063,
|
||||
0x61d587d421d324f6},
|
||||
{0xe87673a2a37173ea, 0x2384800853778b65, 0x10f8441e05bab43e,
|
||||
0xfa11fe124621efbe}},
|
||||
{{0x1c891f2b2cb19ffd, 0x01ba8d5bb1923c23, 0xb6d03d678ac5ca8e,
|
||||
0x586eb04c1f13bedc},
|
||||
{0x0c35c6e527e8ed09, 0x1e81a33c1819ede2, 0x278fd6c056c652fa,
|
||||
0x19d5ac0870864f11}},
|
||||
{{0x62577734d2b533d5, 0x673b8af6a1bdddc0, 0x577e7c9aa79ec293,
|
||||
0xbb6de651c3b266b1},
|
||||
{0xe7e9303ab65259b3, 0xd6a0afd3d03a7480, 0xc5ac83d19b3cfc27,
|
||||
0x60b4619a5d18b99b}},
|
||||
{{0xbd6a38e11ae5aa1c, 0xb8b7652b49e73658, 0x0b130014ee5f87ed,
|
||||
0x9d0f27b2aeebffcd},
|
||||
{0xca9246317a730a55, 0x9c955b2fddbbc83a, 0x07c1dfe0ac019a71,
|
||||
0x244a566d356ec48d}},
|
||||
{{0x56f8410ef4f8b16a, 0x97241afec47b266a, 0x0a406b8e6d9c87c1,
|
||||
0x803f3e02cd42ab1b},
|
||||
{0x7f0309a804dbec69, 0xa83b85f73bbad05f, 0xc6097273ad8e197f,
|
||||
0xc097440e5067adc1}},
|
||||
{{0x846a56f2c379ab34, 0xa8ee068b841df8d1, 0x20314459176c68ef,
|
||||
0xf1af32d5915f1f30},
|
||||
{0x99c375315d75bd50, 0x837cffbaf72f67bc, 0x0613a41848d7723f,
|
||||
0x23d0f130e2d41c8b}},
|
||||
{{0xed93e225d5be5a2b, 0x6fe799835934f3c6, 0x4314092622626ffc,
|
||||
0x50bbb4d97990216a},
|
||||
{0x378191c6e57ec63e, 0x65422c40181dcdb2, 0x41a8099b0236e0f6,
|
||||
0x2b10011801fe49c3}},
|
||||
{{0xfc68b5c59b391593, 0xc385f5a2598270fc, 0x7144f3aad19adcbb,
|
||||
0xdd55899983fbae0c},
|
||||
{0x93b88b8e74b82ff4, 0xd2e03c4071e734c9, 0x9a7a9eaf43c0322a,
|
||||
0xe6e4c551149d6041}},
|
||||
{{0x5fe14bfe80ec21fe, 0xf6ce116ac255be82, 0x98bc5a072f4a5d67,
|
||||
0xfad27148db7e63af},
|
||||
{0x90c0b6ac29ab05b3, 0x37a9a83c4e251ae6, 0x0a7dc875c2aade7d,
|
||||
0x77387de39f0e1a84}},
|
||||
{{0x1e9ecc49a56c0dd7, 0xa5cffcd846086c74, 0x8f7a1408f505aece,
|
||||
0xb37b85c0bef0c47e},
|
||||
{0x3596b6e4cc0e6a8f, 0xfd6d4bbf6b388f23, 0xaba453fac39cef4e,
|
||||
0x9c135ac8f9f628d5}},
|
||||
{{0x0a1c729495c8f8be, 0x2961c4803bf362bf, 0x9e418403df63d4ac,
|
||||
0xc109f9cb91ece900},
|
||||
{0xc2d095d058945705, 0xb9083d96ddeb85c0, 0x84692b8d7a40449b,
|
||||
0x9bc3344f2eee1ee1}},
|
||||
{{0x0d5ae35642913074, 0x55491b2748a542b1, 0x469ca665b310732a,
|
||||
0x29591d525f1a4cc1},
|
||||
{0xe76f5b6bb84f983f, 0xbe7eef419f5f84e1, 0x1200d49680baa189,
|
||||
0x6376551f18ef332c}}},
|
||||
{{{0x202886024147519a, 0xd0981eac26b372f0, 0xa9d4a7caa785ebc8,
|
||||
0xd953c50ddbdf58e9},
|
||||
{0x9d6361ccfd590f8f, 0x72e9626b44e6c917, 0x7fd9611022eb64cf,
|
||||
0x863ebb7e9eb288f3}},
|
||||
{{0x4fe7ee31b0e63d34, 0xf4600572a9e54fab, 0xc0493334d5e7b5a4,
|
||||
0x8589fb9206d54831},
|
||||
{0xaa70f5cc6583553a, 0x0879094ae25649e5, 0xcc90450710044652,
|
||||
0xebb0696d02541c4f}},
|
||||
{{0xabbaa0c03b89da99, 0xa6f2d79eb8284022, 0x27847862b81c05e8,
|
||||
0x337a4b5905e54d63},
|
||||
{0x3c67500d21f7794a, 0x207005b77d6d7f61, 0x0a5a378104cfd6e8,
|
||||
0x0d65e0d5f4c2fbd6}},
|
||||
{{0xd433e50f6d3549cf, 0x6f33696ffacd665e, 0x695bfdacce11fcb4,
|
||||
0x810ee252af7c9860},
|
||||
{0x65450fe17159bb2c, 0xf7dfbebe758b357b, 0x2b057e74d69fea72,
|
||||
0xd485717a92731745}},
|
||||
{{0xce1f69bbe83f7669, 0x09f8ae8272877d6b, 0x9548ae543244278d,
|
||||
0x207755dee3c2c19c},
|
||||
{0x87bd61d96fef1945, 0x18813cefb12d28c3, 0x9fbcd1d672df64aa,
|
||||
0x48dc5ee57154b00d}},
|
||||
{{0xef0f469ef49a3154, 0x3e85a5956e2b2e9a, 0x45aaec1eaa924a9c,
|
||||
0xaa12dfc8a09e4719},
|
||||
{0x26f272274df69f1d, 0xe0e4c82ca2ff5e73, 0xb9d8ce73b7a9dd44,
|
||||
0x6c036e73e48ca901}},
|
||||
{{0xe1e421e1a47153f0, 0xb86c3b79920418c9, 0x93bdce87705d7672,
|
||||
0xf25ae793cab79a77},
|
||||
{0x1f3194a36d869d0c, 0x9d55c8824986c264, 0x49fb5ea3096e945e,
|
||||
0x39b8e65313db0a3e}},
|
||||
{{0xe3417bc035d0b34a, 0x440b386b8327c0a7, 0x8fb7262dac0362d1,
|
||||
0x2c41114ce0cdf943},
|
||||
{0x2ba5cef1ad95a0b1, 0xc09b37a867d54362, 0x26d6cdd201e486c9,
|
||||
0x20477abf42ff9297}},
|
||||
{{0x0f121b41bc0a67d2, 0x62d4760a444d248a, 0x0e044f1d659b4737,
|
||||
0x08fde365250bb4a8},
|
||||
{0xaceec3da848bf287, 0xc2a62182d3369d6e, 0x3582dfdc92449482,
|
||||
0x2f7e2fd2565d6cd7}},
|
||||
{{0x0a0122b5178a876b, 0x51ff96ff085104b4, 0x050b31ab14f29f76,
|
||||
0x84abb28b5f87d4e6},
|
||||
{0xd5ed439f8270790a, 0x2d6cb59d85e3f46b, 0x75f55c1b6c1e2212,
|
||||
0xe5436f6717655640}},
|
||||
{{0xc2965ecc9aeb596d, 0x01ea03e7023c92b4, 0x4704b4b62e013961,
|
||||
0x0ca8fd3f905ea367},
|
||||
{0x92523a42551b2b61, 0x1eb7a89c390fcd06, 0xe7f1d2be0392a63e,
|
||||
0x96dca2644ddb0c33}},
|
||||
{{0x231c210e15339848, 0xe87a28e870778c8d, 0x9d1de6616956e170,
|
||||
0x4ac3c9382bb09c0b},
|
||||
{0x19be05516998987d, 0x8b2376c4ae09f4d6, 0x1de0b7651a3f933d,
|
||||
0x380d94c7e39705f4}},
|
||||
{{0x3685954b8c31c31d, 0x68533d005bf21a0c, 0x0bd7626e75c79ec9,
|
||||
0xca17754742c69d54},
|
||||
{0xcc6edafff6d2dbb2, 0xfd0d8cbd174a9d18, 0x875e8793aa4578e8,
|
||||
0xa976a7139cab2ce6}},
|
||||
{{0xce37ab11b43ea1db, 0x0a7ff1a95259d292, 0x851b02218f84f186,
|
||||
0xa7222beadefaad13},
|
||||
{0xa2ac78ec2b0a9144, 0x5a024051f2fa59c5, 0x91d1eca56147ce38,
|
||||
0xbe94d523bc2ac690}},
|
||||
{{0x2d8daefd79ec1a0f, 0x3bbcd6fdceb39c97, 0xf5575ffc58f61a95,
|
||||
0xdbd986c4adf7b420},
|
||||
{0x81aa881415f39eb7, 0x6ee2fcf5b98d976c, 0x5465475dcf2f717d,
|
||||
0x8e24d3c46860bbd0}}}};
|
||||
#else
|
||||
static const fiat_p256_felem fiat_p256_g_pre_comp[2][15][2] = {
|
||||
{{{0x18a9143c, 0x79e730d4, 0x5fedb601, 0x75ba95fc, 0x77622510, 0x79fb732b,
|
||||
0xa53755c6, 0x18905f76},
|
||||
{0xce95560a, 0xddf25357, 0xba19e45c, 0x8b4ab8e4, 0xdd21f325, 0xd2e88688,
|
||||
0x25885d85, 0x8571ff18}},
|
||||
{{0x16a0d2bb, 0x4f922fc5, 0x1a623499, 0x0d5cc16c, 0x57c62c8b, 0x9241cf3a,
|
||||
0xfd1b667f, 0x2f5e6961},
|
||||
{0xf5a01797, 0x5c15c70b, 0x60956192, 0x3d20b44d, 0x071fdb52, 0x04911b37,
|
||||
0x8d6f0f7b, 0xf648f916}},
|
||||
{{0xe137bbbc, 0x9e566847, 0x8a6a0bec, 0xe434469e, 0x79d73463, 0xb1c42761,
|
||||
0x133d0015, 0x5abe0285},
|
||||
{0xc04c7dab, 0x92aa837c, 0x43260c07, 0x573d9f4c, 0x78e6cc37, 0x0c931562,
|
||||
0x6b6f7383, 0x94bb725b}},
|
||||
{{0xbfe20925, 0x62a8c244, 0x8fdce867, 0x91c19ac3, 0xdd387063, 0x5a96a5d5,
|
||||
0x21d324f6, 0x61d587d4},
|
||||
{0xa37173ea, 0xe87673a2, 0x53778b65, 0x23848008, 0x05bab43e, 0x10f8441e,
|
||||
0x4621efbe, 0xfa11fe12}},
|
||||
{{0x2cb19ffd, 0x1c891f2b, 0xb1923c23, 0x01ba8d5b, 0x8ac5ca8e, 0xb6d03d67,
|
||||
0x1f13bedc, 0x586eb04c},
|
||||
{0x27e8ed09, 0x0c35c6e5, 0x1819ede2, 0x1e81a33c, 0x56c652fa, 0x278fd6c0,
|
||||
0x70864f11, 0x19d5ac08}},
|
||||
{{0xd2b533d5, 0x62577734, 0xa1bdddc0, 0x673b8af6, 0xa79ec293, 0x577e7c9a,
|
||||
0xc3b266b1, 0xbb6de651},
|
||||
{0xb65259b3, 0xe7e9303a, 0xd03a7480, 0xd6a0afd3, 0x9b3cfc27, 0xc5ac83d1,
|
||||
0x5d18b99b, 0x60b4619a}},
|
||||
{{0x1ae5aa1c, 0xbd6a38e1, 0x49e73658, 0xb8b7652b, 0xee5f87ed, 0x0b130014,
|
||||
0xaeebffcd, 0x9d0f27b2},
|
||||
{0x7a730a55, 0xca924631, 0xddbbc83a, 0x9c955b2f, 0xac019a71, 0x07c1dfe0,
|
||||
0x356ec48d, 0x244a566d}},
|
||||
{{0xf4f8b16a, 0x56f8410e, 0xc47b266a, 0x97241afe, 0x6d9c87c1, 0x0a406b8e,
|
||||
0xcd42ab1b, 0x803f3e02},
|
||||
{0x04dbec69, 0x7f0309a8, 0x3bbad05f, 0xa83b85f7, 0xad8e197f, 0xc6097273,
|
||||
0x5067adc1, 0xc097440e}},
|
||||
{{0xc379ab34, 0x846a56f2, 0x841df8d1, 0xa8ee068b, 0x176c68ef, 0x20314459,
|
||||
0x915f1f30, 0xf1af32d5},
|
||||
{0x5d75bd50, 0x99c37531, 0xf72f67bc, 0x837cffba, 0x48d7723f, 0x0613a418,
|
||||
0xe2d41c8b, 0x23d0f130}},
|
||||
{{0xd5be5a2b, 0xed93e225, 0x5934f3c6, 0x6fe79983, 0x22626ffc, 0x43140926,
|
||||
0x7990216a, 0x50bbb4d9},
|
||||
{0xe57ec63e, 0x378191c6, 0x181dcdb2, 0x65422c40, 0x0236e0f6, 0x41a8099b,
|
||||
0x01fe49c3, 0x2b100118}},
|
||||
{{0x9b391593, 0xfc68b5c5, 0x598270fc, 0xc385f5a2, 0xd19adcbb, 0x7144f3aa,
|
||||
0x83fbae0c, 0xdd558999},
|
||||
{0x74b82ff4, 0x93b88b8e, 0x71e734c9, 0xd2e03c40, 0x43c0322a, 0x9a7a9eaf,
|
||||
0x149d6041, 0xe6e4c551}},
|
||||
{{0x80ec21fe, 0x5fe14bfe, 0xc255be82, 0xf6ce116a, 0x2f4a5d67, 0x98bc5a07,
|
||||
0xdb7e63af, 0xfad27148},
|
||||
{0x29ab05b3, 0x90c0b6ac, 0x4e251ae6, 0x37a9a83c, 0xc2aade7d, 0x0a7dc875,
|
||||
0x9f0e1a84, 0x77387de3}},
|
||||
{{0xa56c0dd7, 0x1e9ecc49, 0x46086c74, 0xa5cffcd8, 0xf505aece, 0x8f7a1408,
|
||||
0xbef0c47e, 0xb37b85c0},
|
||||
{0xcc0e6a8f, 0x3596b6e4, 0x6b388f23, 0xfd6d4bbf, 0xc39cef4e, 0xaba453fa,
|
||||
0xf9f628d5, 0x9c135ac8}},
|
||||
{{0x95c8f8be, 0x0a1c7294, 0x3bf362bf, 0x2961c480, 0xdf63d4ac, 0x9e418403,
|
||||
0x91ece900, 0xc109f9cb},
|
||||
{0x58945705, 0xc2d095d0, 0xddeb85c0, 0xb9083d96, 0x7a40449b, 0x84692b8d,
|
||||
0x2eee1ee1, 0x9bc3344f}},
|
||||
{{0x42913074, 0x0d5ae356, 0x48a542b1, 0x55491b27, 0xb310732a, 0x469ca665,
|
||||
0x5f1a4cc1, 0x29591d52},
|
||||
{0xb84f983f, 0xe76f5b6b, 0x9f5f84e1, 0xbe7eef41, 0x80baa189, 0x1200d496,
|
||||
0x18ef332c, 0x6376551f}}},
|
||||
{{{0x4147519a, 0x20288602, 0x26b372f0, 0xd0981eac, 0xa785ebc8, 0xa9d4a7ca,
|
||||
0xdbdf58e9, 0xd953c50d},
|
||||
{0xfd590f8f, 0x9d6361cc, 0x44e6c917, 0x72e9626b, 0x22eb64cf, 0x7fd96110,
|
||||
0x9eb288f3, 0x863ebb7e}},
|
||||
{{0xb0e63d34, 0x4fe7ee31, 0xa9e54fab, 0xf4600572, 0xd5e7b5a4, 0xc0493334,
|
||||
0x06d54831, 0x8589fb92},
|
||||
{0x6583553a, 0xaa70f5cc, 0xe25649e5, 0x0879094a, 0x10044652, 0xcc904507,
|
||||
0x02541c4f, 0xebb0696d}},
|
||||
{{0x3b89da99, 0xabbaa0c0, 0xb8284022, 0xa6f2d79e, 0xb81c05e8, 0x27847862,
|
||||
0x05e54d63, 0x337a4b59},
|
||||
{0x21f7794a, 0x3c67500d, 0x7d6d7f61, 0x207005b7, 0x04cfd6e8, 0x0a5a3781,
|
||||
0xf4c2fbd6, 0x0d65e0d5}},
|
||||
{{0x6d3549cf, 0xd433e50f, 0xfacd665e, 0x6f33696f, 0xce11fcb4, 0x695bfdac,
|
||||
0xaf7c9860, 0x810ee252},
|
||||
{0x7159bb2c, 0x65450fe1, 0x758b357b, 0xf7dfbebe, 0xd69fea72, 0x2b057e74,
|
||||
0x92731745, 0xd485717a}},
|
||||
{{0xe83f7669, 0xce1f69bb, 0x72877d6b, 0x09f8ae82, 0x3244278d, 0x9548ae54,
|
||||
0xe3c2c19c, 0x207755de},
|
||||
{0x6fef1945, 0x87bd61d9, 0xb12d28c3, 0x18813cef, 0x72df64aa, 0x9fbcd1d6,
|
||||
0x7154b00d, 0x48dc5ee5}},
|
||||
{{0xf49a3154, 0xef0f469e, 0x6e2b2e9a, 0x3e85a595, 0xaa924a9c, 0x45aaec1e,
|
||||
0xa09e4719, 0xaa12dfc8},
|
||||
{0x4df69f1d, 0x26f27227, 0xa2ff5e73, 0xe0e4c82c, 0xb7a9dd44, 0xb9d8ce73,
|
||||
0xe48ca901, 0x6c036e73}},
|
||||
{{0xa47153f0, 0xe1e421e1, 0x920418c9, 0xb86c3b79, 0x705d7672, 0x93bdce87,
|
||||
0xcab79a77, 0xf25ae793},
|
||||
{0x6d869d0c, 0x1f3194a3, 0x4986c264, 0x9d55c882, 0x096e945e, 0x49fb5ea3,
|
||||
0x13db0a3e, 0x39b8e653}},
|
||||
{{0x35d0b34a, 0xe3417bc0, 0x8327c0a7, 0x440b386b, 0xac0362d1, 0x8fb7262d,
|
||||
0xe0cdf943, 0x2c41114c},
|
||||
{0xad95a0b1, 0x2ba5cef1, 0x67d54362, 0xc09b37a8, 0x01e486c9, 0x26d6cdd2,
|
||||
0x42ff9297, 0x20477abf}},
|
||||
{{0xbc0a67d2, 0x0f121b41, 0x444d248a, 0x62d4760a, 0x659b4737, 0x0e044f1d,
|
||||
0x250bb4a8, 0x08fde365},
|
||||
{0x848bf287, 0xaceec3da, 0xd3369d6e, 0xc2a62182, 0x92449482, 0x3582dfdc,
|
||||
0x565d6cd7, 0x2f7e2fd2}},
|
||||
{{0x178a876b, 0x0a0122b5, 0x085104b4, 0x51ff96ff, 0x14f29f76, 0x050b31ab,
|
||||
0x5f87d4e6, 0x84abb28b},
|
||||
{0x8270790a, 0xd5ed439f, 0x85e3f46b, 0x2d6cb59d, 0x6c1e2212, 0x75f55c1b,
|
||||
0x17655640, 0xe5436f67}},
|
||||
{{0x9aeb596d, 0xc2965ecc, 0x023c92b4, 0x01ea03e7, 0x2e013961, 0x4704b4b6,
|
||||
0x905ea367, 0x0ca8fd3f},
|
||||
{0x551b2b61, 0x92523a42, 0x390fcd06, 0x1eb7a89c, 0x0392a63e, 0xe7f1d2be,
|
||||
0x4ddb0c33, 0x96dca264}},
|
||||
{{0x15339848, 0x231c210e, 0x70778c8d, 0xe87a28e8, 0x6956e170, 0x9d1de661,
|
||||
0x2bb09c0b, 0x4ac3c938},
|
||||
{0x6998987d, 0x19be0551, 0xae09f4d6, 0x8b2376c4, 0x1a3f933d, 0x1de0b765,
|
||||
0xe39705f4, 0x380d94c7}},
|
||||
{{0x8c31c31d, 0x3685954b, 0x5bf21a0c, 0x68533d00, 0x75c79ec9, 0x0bd7626e,
|
||||
0x42c69d54, 0xca177547},
|
||||
{0xf6d2dbb2, 0xcc6edaff, 0x174a9d18, 0xfd0d8cbd, 0xaa4578e8, 0x875e8793,
|
||||
0x9cab2ce6, 0xa976a713}},
|
||||
{{0xb43ea1db, 0xce37ab11, 0x5259d292, 0x0a7ff1a9, 0x8f84f186, 0x851b0221,
|
||||
0xdefaad13, 0xa7222bea},
|
||||
{0x2b0a9144, 0xa2ac78ec, 0xf2fa59c5, 0x5a024051, 0x6147ce38, 0x91d1eca5,
|
||||
0xbc2ac690, 0xbe94d523}},
|
||||
{{0x79ec1a0f, 0x2d8daefd, 0xceb39c97, 0x3bbcd6fd, 0x58f61a95, 0xf5575ffc,
|
||||
0xadf7b420, 0xdbd986c4},
|
||||
{0x15f39eb7, 0x81aa8814, 0xb98d976c, 0x6ee2fcf5, 0xcf2f717d, 0x5465475d,
|
||||
0x6860bbd0, 0x8e24d3c4}}}};
|
||||
#endif
|
||||
@@ -81,6 +81,15 @@ int ec_scalar_from_bytes(const EC_GROUP *group, EC_SCALAR *out,
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ec_scalar_reduce(const EC_GROUP *group, EC_SCALAR *out,
|
||||
const BN_ULONG *words, size_t num) {
|
||||
// Convert "from" Montgomery form so the value is reduced modulo the order.
|
||||
bn_from_montgomery_small(out->words, group->order.width, words, num,
|
||||
group->order_mont);
|
||||
// Convert "to" Montgomery form to remove the R^-1 factor added.
|
||||
ec_scalar_to_montgomery(group, out, out);
|
||||
}
|
||||
|
||||
void ec_scalar_add(const EC_GROUP *group, EC_SCALAR *r, const EC_SCALAR *a,
|
||||
const EC_SCALAR *b) {
|
||||
const BIGNUM *order = &group->order;
|
||||
@@ -89,6 +98,26 @@ void ec_scalar_add(const EC_GROUP *group, EC_SCALAR *r, const EC_SCALAR *a,
|
||||
OPENSSL_cleanse(tmp, sizeof(tmp));
|
||||
}
|
||||
|
||||
void ec_scalar_sub(const EC_GROUP *group, EC_SCALAR *r, const EC_SCALAR *a,
|
||||
const EC_SCALAR *b) {
|
||||
const BIGNUM *order = &group->order;
|
||||
BN_ULONG tmp[EC_MAX_WORDS];
|
||||
bn_mod_sub_words(r->words, a->words, b->words, order->d, tmp, order->width);
|
||||
OPENSSL_cleanse(tmp, sizeof(tmp));
|
||||
}
|
||||
|
||||
void ec_scalar_neg(const EC_GROUP *group, EC_SCALAR *r, const EC_SCALAR *a) {
|
||||
EC_SCALAR zero;
|
||||
OPENSSL_memset(&zero, 0, sizeof(EC_SCALAR));
|
||||
ec_scalar_sub(group, r, &zero, a);
|
||||
}
|
||||
|
||||
void ec_scalar_select(const EC_GROUP *group, EC_SCALAR *out, BN_ULONG mask,
|
||||
const EC_SCALAR *a, const EC_SCALAR *b) {
|
||||
const BIGNUM *order = &group->order;
|
||||
bn_select_words(out->words, mask, a->words, b->words, order->width);
|
||||
}
|
||||
|
||||
void ec_scalar_to_montgomery(const EC_GROUP *group, EC_SCALAR *r,
|
||||
const EC_SCALAR *a) {
|
||||
const BIGNUM *order = &group->order;
|
||||
@@ -98,7 +127,8 @@ void ec_scalar_to_montgomery(const EC_GROUP *group, EC_SCALAR *r,
|
||||
void ec_scalar_from_montgomery(const EC_GROUP *group, EC_SCALAR *r,
|
||||
const EC_SCALAR *a) {
|
||||
const BIGNUM *order = &group->order;
|
||||
bn_from_montgomery_small(r->words, a->words, order->width, group->order_mont);
|
||||
bn_from_montgomery_small(r->words, order->width, a->words, order->width,
|
||||
group->order_mont);
|
||||
}
|
||||
|
||||
void ec_scalar_mul_montgomery(const EC_GROUP *group, EC_SCALAR *r,
|
||||
@@ -108,19 +138,38 @@ void ec_scalar_mul_montgomery(const EC_GROUP *group, EC_SCALAR *r,
|
||||
group->order_mont);
|
||||
}
|
||||
|
||||
void ec_simple_scalar_inv_montgomery(const EC_GROUP *group, EC_SCALAR *r,
|
||||
const EC_SCALAR *a) {
|
||||
void ec_simple_scalar_inv0_montgomery(const EC_GROUP *group, EC_SCALAR *r,
|
||||
const EC_SCALAR *a) {
|
||||
const BIGNUM *order = &group->order;
|
||||
bn_mod_inverse_prime_mont_small(r->words, a->words, order->width,
|
||||
group->order_mont);
|
||||
bn_mod_inverse0_prime_mont_small(r->words, a->words, order->width,
|
||||
group->order_mont);
|
||||
}
|
||||
|
||||
void ec_scalar_inv_montgomery(const EC_GROUP *group, EC_SCALAR *r,
|
||||
const EC_SCALAR *a) {
|
||||
group->meth->scalar_inv_montgomery(group, r, a);
|
||||
int ec_simple_scalar_to_montgomery_inv_vartime(const EC_GROUP *group,
|
||||
EC_SCALAR *r,
|
||||
const EC_SCALAR *a) {
|
||||
if (ec_scalar_is_zero(group, a)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// This implementation (in fact) runs in constant time,
|
||||
// even though for this interface it is not mandatory.
|
||||
|
||||
// r = a^-1 in the Montgomery domain. This is
|
||||
// |ec_scalar_to_montgomery| followed by |ec_scalar_inv0_montgomery|, but
|
||||
// |ec_scalar_inv0_montgomery| followed by |ec_scalar_from_montgomery| is
|
||||
// equivalent and slightly more efficient.
|
||||
ec_scalar_inv0_montgomery(group, r, a);
|
||||
ec_scalar_from_montgomery(group, r, r);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ec_scalar_inv_montgomery_vartime(const EC_GROUP *group, EC_SCALAR *r,
|
||||
const EC_SCALAR *a) {
|
||||
return group->meth->scalar_inv_montgomery_vartime(group, r, a);
|
||||
void ec_scalar_inv0_montgomery(const EC_GROUP *group, EC_SCALAR *r,
|
||||
const EC_SCALAR *a) {
|
||||
group->meth->scalar_inv0_montgomery(group, r, a);
|
||||
}
|
||||
|
||||
int ec_scalar_to_montgomery_inv_vartime(const EC_GROUP *group, EC_SCALAR *r,
|
||||
const EC_SCALAR *a) {
|
||||
return group->meth->scalar_to_montgomery_inv_vartime(group, r, a);
|
||||
}
|
||||
@@ -101,22 +101,13 @@ void ec_GFp_simple_group_finish(EC_GROUP *group) {
|
||||
int ec_GFp_simple_group_set_curve(EC_GROUP *group, const BIGNUM *p,
|
||||
const BIGNUM *a, const BIGNUM *b,
|
||||
BN_CTX *ctx) {
|
||||
int ret = 0;
|
||||
BN_CTX *new_ctx = NULL;
|
||||
|
||||
// p must be a prime > 3
|
||||
if (BN_num_bits(p) <= 2 || !BN_is_odd(p)) {
|
||||
OPENSSL_PUT_ERROR(EC, EC_R_INVALID_FIELD);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ctx == NULL) {
|
||||
ctx = new_ctx = BN_CTX_new();
|
||||
if (ctx == NULL) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int ret = 0;
|
||||
BN_CTX_start(ctx);
|
||||
BIGNUM *tmp = BN_CTX_get(ctx);
|
||||
if (tmp == NULL) {
|
||||
@@ -131,33 +122,23 @@ int ec_GFp_simple_group_set_curve(EC_GROUP *group, const BIGNUM *p,
|
||||
// Store the field in minimal form, so it can be used with |BN_ULONG| arrays.
|
||||
bn_set_minimal_width(&group->field);
|
||||
|
||||
// group->a
|
||||
if (!BN_nnmod(tmp, a, &group->field, ctx) ||
|
||||
!ec_bignum_to_felem(group, &group->a, tmp)) {
|
||||
if (!ec_bignum_to_felem(group, &group->a, a) ||
|
||||
!ec_bignum_to_felem(group, &group->b, b) ||
|
||||
!ec_bignum_to_felem(group, &group->one, BN_value_one())) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
// group->a_is_minus3
|
||||
if (!BN_add_word(tmp, 3)) {
|
||||
if (!BN_copy(tmp, a) ||
|
||||
!BN_add_word(tmp, 3)) {
|
||||
goto err;
|
||||
}
|
||||
group->a_is_minus3 = (0 == BN_cmp(tmp, &group->field));
|
||||
|
||||
// group->b
|
||||
if (!BN_nnmod(tmp, b, &group->field, ctx) ||
|
||||
!ec_bignum_to_felem(group, &group->b, tmp)) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!ec_bignum_to_felem(group, &group->one, BN_value_one())) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = 1;
|
||||
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
BN_CTX_free(new_ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -190,24 +171,6 @@ void ec_GFp_simple_point_set_to_infinity(const EC_GROUP *group,
|
||||
ec_GFp_simple_point_init(point);
|
||||
}
|
||||
|
||||
int ec_GFp_simple_point_set_affine_coordinates(const EC_GROUP *group,
|
||||
EC_RAW_POINT *point,
|
||||
const BIGNUM *x,
|
||||
const BIGNUM *y) {
|
||||
if (x == NULL || y == NULL) {
|
||||
OPENSSL_PUT_ERROR(EC, ERR_R_PASSED_NULL_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!ec_bignum_to_felem(group, &point->X, x) ||
|
||||
!ec_bignum_to_felem(group, &point->Y, y)) {
|
||||
return 0;
|
||||
}
|
||||
OPENSSL_memcpy(&point->Z, &group->one, sizeof(EC_FELEM));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ec_GFp_simple_invert(const EC_GROUP *group, EC_RAW_POINT *point) {
|
||||
ec_felem_neg(group, &point->Y, &point->Y);
|
||||
}
|
||||
@@ -219,10 +182,6 @@ int ec_GFp_simple_is_at_infinity(const EC_GROUP *group,
|
||||
|
||||
int ec_GFp_simple_is_on_curve(const EC_GROUP *group,
|
||||
const EC_RAW_POINT *point) {
|
||||
if (ec_GFp_simple_is_at_infinity(group, point)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// We have a curve defined by a Weierstrass equation
|
||||
// y^2 = x^3 + a*x + b.
|
||||
// The point to consider is given in Jacobian projective coordinates
|
||||
@@ -231,6 +190,9 @@ int ec_GFp_simple_is_on_curve(const EC_GROUP *group,
|
||||
// into
|
||||
// Y^2 = X^3 + a*X*Z^4 + b*Z^6.
|
||||
// To test this, we add up the right-hand side in 'rh'.
|
||||
//
|
||||
// This function may be used when double-checking the secret result of a point
|
||||
// multiplication, so we proceed in constant-time.
|
||||
|
||||
void (*const felem_mul)(const EC_GROUP *, EC_FELEM *r, const EC_FELEM *a,
|
||||
const EC_FELEM *b) = group->meth->felem_mul;
|
||||
@@ -242,128 +204,114 @@ int ec_GFp_simple_is_on_curve(const EC_GROUP *group,
|
||||
felem_sqr(group, &rh, &point->X);
|
||||
|
||||
EC_FELEM tmp, Z4, Z6;
|
||||
if (!ec_felem_equal(group, &point->Z, &group->one)) {
|
||||
felem_sqr(group, &tmp, &point->Z);
|
||||
felem_sqr(group, &Z4, &tmp);
|
||||
felem_mul(group, &Z6, &Z4, &tmp);
|
||||
felem_sqr(group, &tmp, &point->Z);
|
||||
felem_sqr(group, &Z4, &tmp);
|
||||
felem_mul(group, &Z6, &Z4, &tmp);
|
||||
|
||||
// rh := (rh + a*Z^4)*X
|
||||
if (group->a_is_minus3) {
|
||||
ec_felem_add(group, &tmp, &Z4, &Z4);
|
||||
ec_felem_add(group, &tmp, &tmp, &Z4);
|
||||
ec_felem_sub(group, &rh, &rh, &tmp);
|
||||
felem_mul(group, &rh, &rh, &point->X);
|
||||
} else {
|
||||
felem_mul(group, &tmp, &Z4, &group->a);
|
||||
ec_felem_add(group, &rh, &rh, &tmp);
|
||||
felem_mul(group, &rh, &rh, &point->X);
|
||||
}
|
||||
|
||||
// rh := rh + b*Z^6
|
||||
felem_mul(group, &tmp, &group->b, &Z6);
|
||||
ec_felem_add(group, &rh, &rh, &tmp);
|
||||
// rh := rh + a*Z^4
|
||||
if (group->a_is_minus3) {
|
||||
ec_felem_add(group, &tmp, &Z4, &Z4);
|
||||
ec_felem_add(group, &tmp, &tmp, &Z4);
|
||||
ec_felem_sub(group, &rh, &rh, &tmp);
|
||||
} else {
|
||||
// rh := (rh + a)*X
|
||||
ec_felem_add(group, &rh, &rh, &group->a);
|
||||
felem_mul(group, &rh, &rh, &point->X);
|
||||
// rh := rh + b
|
||||
ec_felem_add(group, &rh, &rh, &group->b);
|
||||
felem_mul(group, &tmp, &Z4, &group->a);
|
||||
ec_felem_add(group, &rh, &rh, &tmp);
|
||||
}
|
||||
|
||||
// rh := (rh + a*Z^4)*X
|
||||
felem_mul(group, &rh, &rh, &point->X);
|
||||
|
||||
// rh := rh + b*Z^6
|
||||
felem_mul(group, &tmp, &group->b, &Z6);
|
||||
ec_felem_add(group, &rh, &rh, &tmp);
|
||||
|
||||
// 'lh' := Y^2
|
||||
felem_sqr(group, &tmp, &point->Y);
|
||||
return ec_felem_equal(group, &tmp, &rh);
|
||||
|
||||
ec_felem_sub(group, &tmp, &tmp, &rh);
|
||||
BN_ULONG not_equal = ec_felem_non_zero_mask(group, &tmp);
|
||||
|
||||
// If Z = 0, the point is infinity, which is always on the curve.
|
||||
BN_ULONG not_infinity = ec_felem_non_zero_mask(group, &point->Z);
|
||||
|
||||
return 1 & ~(not_infinity & not_equal);
|
||||
}
|
||||
|
||||
int ec_GFp_simple_cmp(const EC_GROUP *group, const EC_RAW_POINT *a,
|
||||
const EC_RAW_POINT *b) {
|
||||
// Note this function returns zero if |a| and |b| are equal and 1 if they are
|
||||
// not equal.
|
||||
if (ec_GFp_simple_is_at_infinity(group, a)) {
|
||||
return ec_GFp_simple_is_at_infinity(group, b) ? 0 : 1;
|
||||
}
|
||||
int ec_GFp_simple_points_equal(const EC_GROUP *group, const EC_RAW_POINT *a,
|
||||
const EC_RAW_POINT *b) {
|
||||
// This function is implemented in constant-time for two reasons. First,
|
||||
// although EC points are usually public, their Jacobian Z coordinates may be
|
||||
// secret, or at least are not obviously public. Second, more complex
|
||||
// protocols will sometimes manipulate secret points.
|
||||
//
|
||||
// This does mean that we pay a 6M+2S Jacobian comparison when comparing two
|
||||
// publicly affine points costs no field operations at all. If needed, we can
|
||||
// restore this optimization by keeping better track of affine vs. Jacobian
|
||||
// forms. See https://crbug.com/boringssl/326.
|
||||
|
||||
if (ec_GFp_simple_is_at_infinity(group, b)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int a_Z_is_one = ec_felem_equal(group, &a->Z, &group->one);
|
||||
int b_Z_is_one = ec_felem_equal(group, &b->Z, &group->one);
|
||||
|
||||
if (a_Z_is_one && b_Z_is_one) {
|
||||
return !ec_felem_equal(group, &a->X, &b->X) ||
|
||||
!ec_felem_equal(group, &a->Y, &b->Y);
|
||||
}
|
||||
// If neither |a| or |b| is infinity, we have to decide whether
|
||||
// (X_a/Z_a^2, Y_a/Z_a^3) = (X_b/Z_b^2, Y_b/Z_b^3),
|
||||
// or equivalently, whether
|
||||
// (X_a*Z_b^2, Y_a*Z_b^3) = (X_b*Z_a^2, Y_b*Z_a^3).
|
||||
|
||||
void (*const felem_mul)(const EC_GROUP *, EC_FELEM *r, const EC_FELEM *a,
|
||||
const EC_FELEM *b) = group->meth->felem_mul;
|
||||
void (*const felem_sqr)(const EC_GROUP *, EC_FELEM *r, const EC_FELEM *a) =
|
||||
group->meth->felem_sqr;
|
||||
|
||||
// We have to decide whether
|
||||
// (X_a/Z_a^2, Y_a/Z_a^3) = (X_b/Z_b^2, Y_b/Z_b^3),
|
||||
// or equivalently, whether
|
||||
// (X_a*Z_b^2, Y_a*Z_b^3) = (X_b*Z_a^2, Y_b*Z_a^3).
|
||||
|
||||
EC_FELEM tmp1, tmp2, Za23, Zb23;
|
||||
const EC_FELEM *tmp1_, *tmp2_;
|
||||
if (!b_Z_is_one) {
|
||||
felem_sqr(group, &Zb23, &b->Z);
|
||||
felem_mul(group, &tmp1, &a->X, &Zb23);
|
||||
tmp1_ = &tmp1;
|
||||
} else {
|
||||
tmp1_ = &a->X;
|
||||
}
|
||||
if (!a_Z_is_one) {
|
||||
felem_sqr(group, &Za23, &a->Z);
|
||||
felem_mul(group, &tmp2, &b->X, &Za23);
|
||||
tmp2_ = &tmp2;
|
||||
} else {
|
||||
tmp2_ = &b->X;
|
||||
}
|
||||
felem_sqr(group, &Zb23, &b->Z); // Zb23 = Z_b^2
|
||||
felem_mul(group, &tmp1, &a->X, &Zb23); // tmp1 = X_a * Z_b^2
|
||||
felem_sqr(group, &Za23, &a->Z); // Za23 = Z_a^2
|
||||
felem_mul(group, &tmp2, &b->X, &Za23); // tmp2 = X_b * Z_a^2
|
||||
ec_felem_sub(group, &tmp1, &tmp1, &tmp2);
|
||||
const BN_ULONG x_not_equal = ec_felem_non_zero_mask(group, &tmp1);
|
||||
|
||||
// Compare X_a*Z_b^2 with X_b*Z_a^2.
|
||||
if (!ec_felem_equal(group, tmp1_, tmp2_)) {
|
||||
return 1; // The points differ.
|
||||
}
|
||||
felem_mul(group, &Zb23, &Zb23, &b->Z); // Zb23 = Z_b^3
|
||||
felem_mul(group, &tmp1, &a->Y, &Zb23); // tmp1 = Y_a * Z_b^3
|
||||
felem_mul(group, &Za23, &Za23, &a->Z); // Za23 = Z_a^3
|
||||
felem_mul(group, &tmp2, &b->Y, &Za23); // tmp2 = Y_b * Z_a^3
|
||||
ec_felem_sub(group, &tmp1, &tmp1, &tmp2);
|
||||
const BN_ULONG y_not_equal = ec_felem_non_zero_mask(group, &tmp1);
|
||||
const BN_ULONG x_and_y_equal = ~(x_not_equal | y_not_equal);
|
||||
|
||||
if (!b_Z_is_one) {
|
||||
felem_mul(group, &Zb23, &Zb23, &b->Z);
|
||||
felem_mul(group, &tmp1, &a->Y, &Zb23);
|
||||
// tmp1_ = &tmp1
|
||||
} else {
|
||||
tmp1_ = &a->Y;
|
||||
}
|
||||
if (!a_Z_is_one) {
|
||||
felem_mul(group, &Za23, &Za23, &a->Z);
|
||||
felem_mul(group, &tmp2, &b->Y, &Za23);
|
||||
// tmp2_ = &tmp2
|
||||
} else {
|
||||
tmp2_ = &b->Y;
|
||||
}
|
||||
const BN_ULONG a_not_infinity = ec_felem_non_zero_mask(group, &a->Z);
|
||||
const BN_ULONG b_not_infinity = ec_felem_non_zero_mask(group, &b->Z);
|
||||
const BN_ULONG a_and_b_infinity = ~(a_not_infinity | b_not_infinity);
|
||||
|
||||
// Compare Y_a*Z_b^3 with Y_b*Z_a^3.
|
||||
if (!ec_felem_equal(group, tmp1_, tmp2_)) {
|
||||
return 1; // The points differ.
|
||||
}
|
||||
|
||||
// The points are equal.
|
||||
return 0;
|
||||
const BN_ULONG equal =
|
||||
a_and_b_infinity | (a_not_infinity & b_not_infinity & x_and_y_equal);
|
||||
return equal & 1;
|
||||
}
|
||||
|
||||
int ec_GFp_simple_mont_inv_mod_ord_vartime(const EC_GROUP *group,
|
||||
EC_SCALAR *out,
|
||||
const EC_SCALAR *in) {
|
||||
// This implementation (in fact) runs in constant time,
|
||||
// even though for this interface it is not mandatory.
|
||||
int ec_affine_jacobian_equal(const EC_GROUP *group, const EC_AFFINE *a,
|
||||
const EC_RAW_POINT *b) {
|
||||
// If |b| is not infinity, we have to decide whether
|
||||
// (X_a, Y_a) = (X_b/Z_b^2, Y_b/Z_b^3),
|
||||
// or equivalently, whether
|
||||
// (X_a*Z_b^2, Y_a*Z_b^3) = (X_b, Y_b).
|
||||
|
||||
// out = in^-1 in the Montgomery domain. This is
|
||||
// |ec_scalar_to_montgomery| followed by |ec_scalar_inv_montgomery|, but
|
||||
// |ec_scalar_inv_montgomery| followed by |ec_scalar_from_montgomery| is
|
||||
// equivalent and slightly more efficient.
|
||||
ec_scalar_inv_montgomery(group, out, in);
|
||||
ec_scalar_from_montgomery(group, out, out);
|
||||
return 1;
|
||||
void (*const felem_mul)(const EC_GROUP *, EC_FELEM *r, const EC_FELEM *a,
|
||||
const EC_FELEM *b) = group->meth->felem_mul;
|
||||
void (*const felem_sqr)(const EC_GROUP *, EC_FELEM *r, const EC_FELEM *a) =
|
||||
group->meth->felem_sqr;
|
||||
|
||||
EC_FELEM tmp, Zb2;
|
||||
felem_sqr(group, &Zb2, &b->Z); // Zb2 = Z_b^2
|
||||
felem_mul(group, &tmp, &a->X, &Zb2); // tmp = X_a * Z_b^2
|
||||
ec_felem_sub(group, &tmp, &tmp, &b->X);
|
||||
const BN_ULONG x_not_equal = ec_felem_non_zero_mask(group, &tmp);
|
||||
|
||||
felem_mul(group, &tmp, &a->Y, &Zb2); // tmp = Y_a * Z_b^2
|
||||
felem_mul(group, &tmp, &tmp, &b->Z); // tmp = Y_a * Z_b^3
|
||||
ec_felem_sub(group, &tmp, &tmp, &b->Y);
|
||||
const BN_ULONG y_not_equal = ec_felem_non_zero_mask(group, &tmp);
|
||||
const BN_ULONG x_and_y_equal = ~(x_not_equal | y_not_equal);
|
||||
|
||||
const BN_ULONG b_not_infinity = ec_felem_non_zero_mask(group, &b->Z);
|
||||
|
||||
const BN_ULONG equal = b_not_infinity & x_and_y_equal;
|
||||
return equal & 1;
|
||||
}
|
||||
|
||||
int ec_GFp_simple_cmp_x_coordinate(const EC_GROUP *group, const EC_RAW_POINT *p,
|
||||
@@ -378,3 +326,32 @@ int ec_GFp_simple_cmp_x_coordinate(const EC_GROUP *group, const EC_RAW_POINT *p,
|
||||
return ec_get_x_coordinate_as_scalar(group, &x, p) &&
|
||||
ec_scalar_equal_vartime(group, &x, r);
|
||||
}
|
||||
|
||||
void ec_GFp_simple_felem_to_bytes(const EC_GROUP *group, uint8_t *out,
|
||||
size_t *out_len, const EC_FELEM *in) {
|
||||
size_t len = BN_num_bytes(&group->field);
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
out[i] = in->bytes[len - 1 - i];
|
||||
}
|
||||
*out_len = len;
|
||||
}
|
||||
|
||||
int ec_GFp_simple_felem_from_bytes(const EC_GROUP *group, EC_FELEM *out,
|
||||
const uint8_t *in, size_t len) {
|
||||
if (len != BN_num_bytes(&group->field)) {
|
||||
OPENSSL_PUT_ERROR(EC, EC_R_DECODE_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
OPENSSL_memset(out, 0, sizeof(EC_FELEM));
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
out->bytes[i] = in[len - 1 - i];
|
||||
}
|
||||
|
||||
if (!bn_less_than_words(out->words, group->field.d, group->field.width)) {
|
||||
OPENSSL_PUT_ERROR(EC, EC_R_DECODE_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -60,9 +60,7 @@ void ec_GFp_mont_mul(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
OPENSSL_memset(&tmp, 0, sizeof(EC_RAW_POINT));
|
||||
for (size_t j = 0; j < OPENSSL_ARRAY_SIZE(precomp); j++) {
|
||||
BN_ULONG mask = constant_time_eq_w(j, window);
|
||||
ec_felem_select(group, &tmp.X, mask, &precomp[j].X, &tmp.X);
|
||||
ec_felem_select(group, &tmp.Y, mask, &precomp[j].Y, &tmp.Y);
|
||||
ec_felem_select(group, &tmp.Z, mask, &precomp[j].Z, &tmp.Z);
|
||||
ec_point_select(group, &tmp, mask, &precomp[j], &tmp);
|
||||
}
|
||||
|
||||
if (r_is_at_infinity) {
|
||||
@@ -82,3 +80,191 @@ void ec_GFp_mont_mul_base(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
const EC_SCALAR *scalar) {
|
||||
ec_GFp_mont_mul(group, r, &group->generator->raw, scalar);
|
||||
}
|
||||
|
||||
static void ec_GFp_mont_batch_precomp(const EC_GROUP *group, EC_RAW_POINT *out,
|
||||
size_t num, const EC_RAW_POINT *p) {
|
||||
assert(num > 1);
|
||||
ec_GFp_simple_point_set_to_infinity(group, &out[0]);
|
||||
ec_GFp_simple_point_copy(&out[1], p);
|
||||
for (size_t j = 2; j < num; j++) {
|
||||
if (j & 1) {
|
||||
ec_GFp_mont_add(group, &out[j], &out[1], &out[j - 1]);
|
||||
} else {
|
||||
ec_GFp_mont_dbl(group, &out[j], &out[j / 2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ec_GFp_mont_batch_get_window(const EC_GROUP *group,
|
||||
EC_RAW_POINT *out,
|
||||
const EC_RAW_POINT precomp[17],
|
||||
const EC_SCALAR *scalar, unsigned i) {
|
||||
const size_t width = group->order.width;
|
||||
uint8_t window = bn_is_bit_set_words(scalar->words, width, i + 4) << 5;
|
||||
window |= bn_is_bit_set_words(scalar->words, width, i + 3) << 4;
|
||||
window |= bn_is_bit_set_words(scalar->words, width, i + 2) << 3;
|
||||
window |= bn_is_bit_set_words(scalar->words, width, i + 1) << 2;
|
||||
window |= bn_is_bit_set_words(scalar->words, width, i) << 1;
|
||||
if (i > 0) {
|
||||
window |= bn_is_bit_set_words(scalar->words, width, i - 1);
|
||||
}
|
||||
uint8_t sign, digit;
|
||||
ec_GFp_nistp_recode_scalar_bits(&sign, &digit, window);
|
||||
|
||||
// Select the entry in constant-time.
|
||||
OPENSSL_memset(out, 0, sizeof(EC_RAW_POINT));
|
||||
for (size_t j = 0; j < 17; j++) {
|
||||
BN_ULONG mask = constant_time_eq_w(j, digit);
|
||||
ec_point_select(group, out, mask, &precomp[j], out);
|
||||
}
|
||||
|
||||
// Negate if necessary.
|
||||
EC_FELEM neg_Y;
|
||||
ec_felem_neg(group, &neg_Y, &out->Y);
|
||||
BN_ULONG sign_mask = sign;
|
||||
sign_mask = 0u - sign_mask;
|
||||
ec_felem_select(group, &out->Y, sign_mask, &neg_Y, &out->Y);
|
||||
}
|
||||
|
||||
void ec_GFp_mont_mul_batch(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
const EC_RAW_POINT *p0, const EC_SCALAR *scalar0,
|
||||
const EC_RAW_POINT *p1, const EC_SCALAR *scalar1,
|
||||
const EC_RAW_POINT *p2, const EC_SCALAR *scalar2) {
|
||||
EC_RAW_POINT precomp[3][17];
|
||||
ec_GFp_mont_batch_precomp(group, precomp[0], 17, p0);
|
||||
ec_GFp_mont_batch_precomp(group, precomp[1], 17, p1);
|
||||
if (p2 != NULL) {
|
||||
ec_GFp_mont_batch_precomp(group, precomp[2], 17, p2);
|
||||
}
|
||||
|
||||
// Divide bits in |scalar| into windows.
|
||||
unsigned bits = BN_num_bits(&group->order);
|
||||
int r_is_at_infinity = 1;
|
||||
for (unsigned i = bits; i <= bits; i--) {
|
||||
if (!r_is_at_infinity) {
|
||||
ec_GFp_mont_dbl(group, r, r);
|
||||
}
|
||||
if (i % 5 == 0) {
|
||||
EC_RAW_POINT tmp;
|
||||
ec_GFp_mont_batch_get_window(group, &tmp, precomp[0], scalar0, i);
|
||||
if (r_is_at_infinity) {
|
||||
ec_GFp_simple_point_copy(r, &tmp);
|
||||
r_is_at_infinity = 0;
|
||||
} else {
|
||||
ec_GFp_mont_add(group, r, r, &tmp);
|
||||
}
|
||||
|
||||
ec_GFp_mont_batch_get_window(group, &tmp, precomp[1], scalar1, i);
|
||||
ec_GFp_mont_add(group, r, r, &tmp);
|
||||
|
||||
if (p2 != NULL) {
|
||||
ec_GFp_mont_batch_get_window(group, &tmp, precomp[2], scalar2, i);
|
||||
ec_GFp_mont_add(group, r, r, &tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (r_is_at_infinity) {
|
||||
ec_GFp_simple_point_set_to_infinity(group, r);
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned ec_GFp_mont_comb_stride(const EC_GROUP *group) {
|
||||
return (BN_num_bits(&group->field) + EC_MONT_PRECOMP_COMB_SIZE - 1) /
|
||||
EC_MONT_PRECOMP_COMB_SIZE;
|
||||
}
|
||||
|
||||
int ec_GFp_mont_init_precomp(const EC_GROUP *group, EC_PRECOMP *out,
|
||||
const EC_RAW_POINT *p) {
|
||||
// comb[i - 1] stores the ith element of the comb. That is, if i is
|
||||
// b4 * 2^4 + b3 * 2^3 + ... + b0 * 2^0, it stores k * |p|, where k is
|
||||
// b4 * 2^(4*stride) + b3 * 2^(3*stride) + ... + b0 * 2^(0*stride). stride
|
||||
// here is |ec_GFp_mont_comb_stride|. We store at index i - 1 because the 0th
|
||||
// comb entry is always infinity.
|
||||
EC_RAW_POINT comb[(1 << EC_MONT_PRECOMP_COMB_SIZE) - 1];
|
||||
unsigned stride = ec_GFp_mont_comb_stride(group);
|
||||
|
||||
// We compute the comb sequentially by the highest set bit. Initially, all
|
||||
// entries up to 2^0 are filled.
|
||||
comb[(1 << 0) - 1] = *p;
|
||||
for (unsigned i = 1; i < EC_MONT_PRECOMP_COMB_SIZE; i++) {
|
||||
// Compute entry 2^i by doubling the entry for 2^(i-1) |stride| times.
|
||||
unsigned bit = 1 << i;
|
||||
ec_GFp_mont_dbl(group, &comb[bit - 1], &comb[bit / 2 - 1]);
|
||||
for (unsigned j = 1; j < stride; j++) {
|
||||
ec_GFp_mont_dbl(group, &comb[bit - 1], &comb[bit - 1]);
|
||||
}
|
||||
// Compute entries from 2^i + 1 to 2^i + (2^i - 1) by adding entry 2^i to
|
||||
// a previous entry.
|
||||
for (unsigned j = 1; j < bit; j++) {
|
||||
ec_GFp_mont_add(group, &comb[bit + j - 1], &comb[bit - 1], &comb[j - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
// Store the comb in affine coordinates to shrink the table. (This reduces
|
||||
// cache pressure and makes the constant-time selects faster.)
|
||||
OPENSSL_STATIC_ASSERT(
|
||||
OPENSSL_ARRAY_SIZE(comb) == OPENSSL_ARRAY_SIZE(out->comb),
|
||||
"comb sizes did not match");
|
||||
return ec_jacobian_to_affine_batch(group, out->comb, comb,
|
||||
OPENSSL_ARRAY_SIZE(comb));
|
||||
}
|
||||
|
||||
static void ec_GFp_mont_get_comb_window(const EC_GROUP *group,
|
||||
EC_RAW_POINT *out,
|
||||
const EC_PRECOMP *precomp,
|
||||
const EC_SCALAR *scalar, unsigned i) {
|
||||
const size_t width = group->order.width;
|
||||
unsigned stride = ec_GFp_mont_comb_stride(group);
|
||||
// Select the bits corresponding to the comb shifted up by |i|.
|
||||
unsigned window = 0;
|
||||
for (unsigned j = 0; j < EC_MONT_PRECOMP_COMB_SIZE; j++) {
|
||||
window |= bn_is_bit_set_words(scalar->words, width, j * stride + i)
|
||||
<< j;
|
||||
}
|
||||
|
||||
// Select precomp->comb[window - 1]. If |window| is zero, |match| will always
|
||||
// be zero, which will leave |out| at infinity.
|
||||
OPENSSL_memset(out, 0, sizeof(EC_RAW_POINT));
|
||||
for (unsigned j = 0; j < OPENSSL_ARRAY_SIZE(precomp->comb); j++) {
|
||||
BN_ULONG match = constant_time_eq_w(window, j + 1);
|
||||
ec_felem_select(group, &out->X, match, &precomp->comb[j].X, &out->X);
|
||||
ec_felem_select(group, &out->Y, match, &precomp->comb[j].Y, &out->Y);
|
||||
}
|
||||
BN_ULONG is_infinity = constant_time_is_zero_w(window);
|
||||
ec_felem_select(group, &out->Z, is_infinity, &out->Z, &group->one);
|
||||
}
|
||||
|
||||
void ec_GFp_mont_mul_precomp(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
const EC_PRECOMP *p0, const EC_SCALAR *scalar0,
|
||||
const EC_PRECOMP *p1, const EC_SCALAR *scalar1,
|
||||
const EC_PRECOMP *p2, const EC_SCALAR *scalar2) {
|
||||
unsigned stride = ec_GFp_mont_comb_stride(group);
|
||||
int r_is_at_infinity = 1;
|
||||
for (unsigned i = stride - 1; i < stride; i--) {
|
||||
if (!r_is_at_infinity) {
|
||||
ec_GFp_mont_dbl(group, r, r);
|
||||
}
|
||||
|
||||
EC_RAW_POINT tmp;
|
||||
ec_GFp_mont_get_comb_window(group, &tmp, p0, scalar0, i);
|
||||
if (r_is_at_infinity) {
|
||||
ec_GFp_simple_point_copy(r, &tmp);
|
||||
r_is_at_infinity = 0;
|
||||
} else {
|
||||
ec_GFp_mont_add(group, r, r, &tmp);
|
||||
}
|
||||
|
||||
if (p1 != NULL) {
|
||||
ec_GFp_mont_get_comb_window(group, &tmp, p1, scalar1, i);
|
||||
ec_GFp_mont_add(group, r, r, &tmp);
|
||||
}
|
||||
|
||||
if (p2 != NULL) {
|
||||
ec_GFp_mont_get_comb_window(group, &tmp, p2, scalar2, i);
|
||||
ec_GFp_mont_add(group, r, r, &tmp);
|
||||
}
|
||||
}
|
||||
if (r_is_at_infinity) {
|
||||
ec_GFp_simple_point_set_to_infinity(group, r);
|
||||
}
|
||||
}
|
||||
@@ -72,6 +72,7 @@
|
||||
|
||||
#include <CCryptoBoringSSL_bn.h>
|
||||
#include <CCryptoBoringSSL_err.h>
|
||||
#include <CCryptoBoringSSL_mem.h>
|
||||
#include <CCryptoBoringSSL_thread.h>
|
||||
|
||||
#include "internal.h"
|
||||
@@ -174,24 +175,57 @@ static void lookup_precomp(const EC_GROUP *group, EC_RAW_POINT *out,
|
||||
// EC_WNAF_TABLE_SIZE is the table size to use for |ec_GFp_mont_mul_public|.
|
||||
#define EC_WNAF_TABLE_SIZE (1 << (EC_WNAF_WINDOW_BITS - 1))
|
||||
|
||||
void ec_GFp_mont_mul_public(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
const EC_SCALAR *g_scalar, const EC_RAW_POINT *p,
|
||||
const EC_SCALAR *p_scalar) {
|
||||
// EC_WNAF_STACK is the number of points worth of data to stack-allocate and
|
||||
// avoid a malloc.
|
||||
#define EC_WNAF_STACK 3
|
||||
|
||||
int ec_GFp_mont_mul_public_batch(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
const EC_SCALAR *g_scalar,
|
||||
const EC_RAW_POINT *points,
|
||||
const EC_SCALAR *scalars, size_t num) {
|
||||
size_t bits = BN_num_bits(&group->order);
|
||||
size_t wNAF_len = bits + 1;
|
||||
|
||||
int ret = 0;
|
||||
int8_t wNAF_stack[EC_WNAF_STACK][EC_MAX_BYTES * 8 + 1];
|
||||
int8_t (*wNAF_alloc)[EC_MAX_BYTES * 8 + 1] = NULL;
|
||||
int8_t (*wNAF)[EC_MAX_BYTES * 8 + 1];
|
||||
EC_RAW_POINT precomp_stack[EC_WNAF_STACK][EC_WNAF_TABLE_SIZE];
|
||||
EC_RAW_POINT (*precomp_alloc)[EC_WNAF_TABLE_SIZE] = NULL;
|
||||
EC_RAW_POINT (*precomp)[EC_WNAF_TABLE_SIZE];
|
||||
if (num <= EC_WNAF_STACK) {
|
||||
wNAF = wNAF_stack;
|
||||
precomp = precomp_stack;
|
||||
} else {
|
||||
if (num >= ((size_t)-1) / sizeof(wNAF_alloc[0]) ||
|
||||
num >= ((size_t)-1) / sizeof(precomp_alloc[0])) {
|
||||
OPENSSL_PUT_ERROR(EC, ERR_R_OVERFLOW);
|
||||
goto err;
|
||||
}
|
||||
wNAF_alloc = OPENSSL_malloc(num * sizeof(wNAF_alloc[0]));
|
||||
precomp_alloc = OPENSSL_malloc(num * sizeof(precomp_alloc[0]));
|
||||
if (wNAF_alloc == NULL || precomp_alloc == NULL) {
|
||||
OPENSSL_PUT_ERROR(EC, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
wNAF = wNAF_alloc;
|
||||
precomp = precomp_alloc;
|
||||
}
|
||||
|
||||
int8_t g_wNAF[EC_MAX_BYTES * 8 + 1];
|
||||
EC_RAW_POINT g_precomp[EC_WNAF_TABLE_SIZE];
|
||||
assert(wNAF_len <= OPENSSL_ARRAY_SIZE(g_wNAF));
|
||||
const EC_RAW_POINT *g = &group->generator->raw;
|
||||
ec_compute_wNAF(group, g_wNAF, g_scalar, bits, EC_WNAF_WINDOW_BITS);
|
||||
compute_precomp(group, g_precomp, g, EC_WNAF_TABLE_SIZE);
|
||||
if (g_scalar != NULL) {
|
||||
ec_compute_wNAF(group, g_wNAF, g_scalar, bits, EC_WNAF_WINDOW_BITS);
|
||||
compute_precomp(group, g_precomp, g, EC_WNAF_TABLE_SIZE);
|
||||
}
|
||||
|
||||
int8_t p_wNAF[EC_MAX_BYTES * 8 + 1];
|
||||
EC_RAW_POINT p_precomp[EC_WNAF_TABLE_SIZE];
|
||||
assert(wNAF_len <= OPENSSL_ARRAY_SIZE(p_wNAF));
|
||||
ec_compute_wNAF(group, p_wNAF, p_scalar, bits, EC_WNAF_WINDOW_BITS);
|
||||
compute_precomp(group, p_precomp, p, EC_WNAF_TABLE_SIZE);
|
||||
for (size_t i = 0; i < num; i++) {
|
||||
assert(wNAF_len <= OPENSSL_ARRAY_SIZE(wNAF[i]));
|
||||
ec_compute_wNAF(group, wNAF[i], &scalars[i], bits, EC_WNAF_WINDOW_BITS);
|
||||
compute_precomp(group, precomp[i], &points[i], EC_WNAF_TABLE_SIZE);
|
||||
}
|
||||
|
||||
EC_RAW_POINT tmp;
|
||||
int r_is_at_infinity = 1;
|
||||
@@ -200,7 +234,7 @@ void ec_GFp_mont_mul_public(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
ec_GFp_mont_dbl(group, r, r);
|
||||
}
|
||||
|
||||
if (g_wNAF[k] != 0) {
|
||||
if (g_scalar != NULL && g_wNAF[k] != 0) {
|
||||
lookup_precomp(group, &tmp, g_precomp, g_wNAF[k]);
|
||||
if (r_is_at_infinity) {
|
||||
ec_GFp_simple_point_copy(r, &tmp);
|
||||
@@ -210,13 +244,15 @@ void ec_GFp_mont_mul_public(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
}
|
||||
}
|
||||
|
||||
if (p_wNAF[k] != 0) {
|
||||
lookup_precomp(group, &tmp, p_precomp, p_wNAF[k]);
|
||||
if (r_is_at_infinity) {
|
||||
ec_GFp_simple_point_copy(r, &tmp);
|
||||
r_is_at_infinity = 0;
|
||||
} else {
|
||||
ec_GFp_mont_add(group, r, r, &tmp);
|
||||
for (size_t i = 0; i < num; i++) {
|
||||
if (wNAF[i][k] != 0) {
|
||||
lookup_precomp(group, &tmp, precomp[i], wNAF[i][k]);
|
||||
if (r_is_at_infinity) {
|
||||
ec_GFp_simple_point_copy(r, &tmp);
|
||||
r_is_at_infinity = 0;
|
||||
} else {
|
||||
ec_GFp_mont_add(group, r, r, &tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -224,4 +260,11 @@ void ec_GFp_mont_mul_public(const EC_GROUP *group, EC_RAW_POINT *r,
|
||||
if (r_is_at_infinity) {
|
||||
ec_GFp_simple_point_set_to_infinity(group, r);
|
||||
}
|
||||
|
||||
ret = 1;
|
||||
|
||||
err:
|
||||
OPENSSL_free(wNAF_alloc);
|
||||
OPENSSL_free(precomp_alloc);
|
||||
return ret;
|
||||
}
|
||||
@@ -94,8 +94,8 @@ int ECDH_compute_key_fips(uint8_t *out, size_t out_len, const EC_POINT *pub_key,
|
||||
uint8_t buf[EC_MAX_BYTES];
|
||||
size_t buflen;
|
||||
if (!ec_point_mul_scalar(group, &shared_point, &pub_key->raw, priv) ||
|
||||
!ec_point_get_affine_coordinate_bytes(group, buf, NULL, &buflen,
|
||||
sizeof(buf), &shared_point)) {
|
||||
!ec_get_x_coordinate_as_bytes(group, buf, &buflen, sizeof(buf),
|
||||
&shared_point)) {
|
||||
OPENSSL_PUT_ERROR(ECDH, ECDH_R_POINT_ARITHMETIC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -169,8 +169,11 @@ int ECDSA_do_verify(const uint8_t *digest, size_t digest_len,
|
||||
return 0;
|
||||
}
|
||||
|
||||
// s_inv_mont = s^-1 in the Montgomery domain. This is
|
||||
ec_scalar_inv_montgomery_vartime(group, &s_inv_mont, &s);
|
||||
// s_inv_mont = s^-1 in the Montgomery domain.
|
||||
if (!ec_scalar_to_montgomery_inv_vartime(group, &s_inv_mont, &s)) {
|
||||
OPENSSL_PUT_ERROR(ECDSA, ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// u1 = m * s^-1 mod order
|
||||
// u2 = r * s^-1 mod order
|
||||
@@ -216,6 +219,10 @@ static int ecdsa_sign_setup(const EC_KEY *eckey, EC_SCALAR *out_kinv_mont,
|
||||
if (!ec_bignum_to_scalar(group, &k, eckey->fixed_k)) {
|
||||
goto err;
|
||||
}
|
||||
if (ec_scalar_is_zero(group, &k)) {
|
||||
OPENSSL_PUT_ERROR(ECDSA, ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
} else {
|
||||
// Pass a SHA512 hash of the private key and digest as additional data
|
||||
// into the RBG. This is a hardening measure against entropy failure.
|
||||
@@ -233,10 +240,10 @@ static int ecdsa_sign_setup(const EC_KEY *eckey, EC_SCALAR *out_kinv_mont,
|
||||
}
|
||||
|
||||
// Compute k^-1 in the Montgomery domain. This is |ec_scalar_to_montgomery|
|
||||
// followed by |ec_scalar_inv_montgomery|, but |ec_scalar_inv_montgomery|
|
||||
// followed by |ec_scalar_inv0_montgomery|, but |ec_scalar_inv0_montgomery|
|
||||
// followed by |ec_scalar_from_montgomery| is equivalent and slightly more
|
||||
// efficient.
|
||||
ec_scalar_inv_montgomery(group, out_kinv_mont, &k);
|
||||
// efficient. Note k is non-zero, so the inverse must exist.
|
||||
ec_scalar_inv0_montgomery(group, out_kinv_mont, &k);
|
||||
ec_scalar_from_montgomery(group, out_kinv_mont, out_kinv_mont);
|
||||
|
||||
// Compute r, the x-coordinate of generator * k.
|
||||
|
||||
@@ -1121,8 +1121,6 @@ gcm_ghash_avx:
|
||||
.byte 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0xc2
|
||||
.L7_mask:
|
||||
.long 7,0,7,0
|
||||
.L7_mask_poly:
|
||||
.long 7,0,450,0
|
||||
.align 64
|
||||
|
||||
.byte 71,72,65,83,72,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0
|
||||
|
||||
@@ -1120,8 +1120,6 @@ L$0x1c2_polynomial:
|
||||
.byte 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0xc2
|
||||
L$7_mask:
|
||||
.long 7,0,7,0
|
||||
L$7_mask_poly:
|
||||
.long 7,0,450,0
|
||||
.p2align 6
|
||||
|
||||
.byte 71,72,65,83,72,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
/* Copyright (c) 2020, Google Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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. */
|
||||
|
||||
#if !defined(_GNU_SOURCE)
|
||||
#define _GNU_SOURCE // needed for madvise() and MAP_ANONYMOUS on Linux.
|
||||
#endif
|
||||
|
||||
#include <CCryptoBoringSSL_base.h>
|
||||
|
||||
#include "fork_detect.h"
|
||||
|
||||
#if defined(OPENSSL_LINUX)
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <CCryptoBoringSSL_type_check.h>
|
||||
|
||||
#include "../delocate.h"
|
||||
#include "../../internal.h"
|
||||
|
||||
|
||||
#if defined(MADV_WIPEONFORK)
|
||||
OPENSSL_STATIC_ASSERT(MADV_WIPEONFORK == 18, "MADV_WIPEONFORK is not 18");
|
||||
#else
|
||||
#define MADV_WIPEONFORK 18
|
||||
#endif
|
||||
|
||||
DEFINE_STATIC_ONCE(g_fork_detect_once);
|
||||
DEFINE_STATIC_MUTEX(g_fork_detect_lock);
|
||||
DEFINE_BSS_GET(volatile char *, g_fork_detect_addr);
|
||||
DEFINE_BSS_GET(uint64_t, g_fork_generation);
|
||||
DEFINE_BSS_GET(int, g_ignore_madv_wipeonfork);
|
||||
|
||||
static void init_fork_detect(void) {
|
||||
if (*g_ignore_madv_wipeonfork_bss_get()) {
|
||||
return;
|
||||
}
|
||||
|
||||
long page_size = sysconf(_SC_PAGESIZE);
|
||||
if (page_size <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
void *addr = mmap(NULL, (size_t)page_size, PROT_READ | PROT_WRITE,
|
||||
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||
if (addr == MAP_FAILED) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Some versions of qemu (up to at least 5.0.0-rc4, see linux-user/syscall.c)
|
||||
// ignore |madvise| calls and just return zero (i.e. success). But we need to
|
||||
// know whether MADV_WIPEONFORK actually took effect. Therefore try an invalid
|
||||
// call to check that the implementation of |madvise| is actually rejecting
|
||||
// unknown |advice| values.
|
||||
if (madvise(addr, (size_t)page_size, -1) == 0 ||
|
||||
madvise(addr, (size_t)page_size, MADV_WIPEONFORK) != 0) {
|
||||
munmap(addr, (size_t)page_size);
|
||||
return;
|
||||
}
|
||||
|
||||
*((volatile char *) addr) = 1;
|
||||
*g_fork_detect_addr_bss_get() = addr;
|
||||
*g_fork_generation_bss_get() = 1;
|
||||
}
|
||||
|
||||
uint64_t CRYPTO_get_fork_generation(void) {
|
||||
// In a single-threaded process, there are obviously no races because there's
|
||||
// only a single mutator in the address space.
|
||||
//
|
||||
// In a multi-threaded environment, |CRYPTO_once| ensures that the flag byte
|
||||
// is initialised atomically, even if multiple threads enter this function
|
||||
// concurrently.
|
||||
//
|
||||
// In the limit, the kernel may clear WIPEONFORK pages while a multi-threaded
|
||||
// process is running. (For example, because a VM was cloned.) Therefore a
|
||||
// lock is used below to synchronise the potentially multiple threads that may
|
||||
// concurrently observe the cleared flag.
|
||||
|
||||
CRYPTO_once(g_fork_detect_once_bss_get(), init_fork_detect);
|
||||
// This pointer is |volatile| because the value pointed to may be changed by
|
||||
// external forces (i.e. the kernel wiping the page) thus the compiler must
|
||||
// not assume that it has exclusive access to it.
|
||||
volatile char *const flag_ptr = *g_fork_detect_addr_bss_get();
|
||||
if (flag_ptr == NULL) {
|
||||
// Our kernel is too old to support |MADV_WIPEONFORK|.
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct CRYPTO_STATIC_MUTEX *const lock = g_fork_detect_lock_bss_get();
|
||||
uint64_t *const generation_ptr = g_fork_generation_bss_get();
|
||||
|
||||
CRYPTO_STATIC_MUTEX_lock_read(lock);
|
||||
uint64_t current_generation = *generation_ptr;
|
||||
if (*flag_ptr) {
|
||||
CRYPTO_STATIC_MUTEX_unlock_read(lock);
|
||||
return current_generation;
|
||||
}
|
||||
|
||||
CRYPTO_STATIC_MUTEX_unlock_read(lock);
|
||||
CRYPTO_STATIC_MUTEX_lock_write(lock);
|
||||
current_generation = *generation_ptr;
|
||||
if (*flag_ptr == 0) {
|
||||
// A fork has occurred.
|
||||
*flag_ptr = 1;
|
||||
|
||||
current_generation++;
|
||||
if (current_generation == 0) {
|
||||
current_generation = 1;
|
||||
}
|
||||
*generation_ptr = current_generation;
|
||||
}
|
||||
CRYPTO_STATIC_MUTEX_unlock_write(lock);
|
||||
|
||||
return current_generation;
|
||||
}
|
||||
|
||||
void CRYPTO_fork_detect_ignore_madv_wipeonfork_for_testing(void) {
|
||||
*g_ignore_madv_wipeonfork_bss_get() = 1;
|
||||
}
|
||||
|
||||
#else // !OPENSSL_LINUX
|
||||
|
||||
uint64_t CRYPTO_get_fork_generation(void) { return 0; }
|
||||
|
||||
#endif // OPENSSL_LINUX
|
||||
@@ -0,0 +1,49 @@
|
||||
/* Copyright (c) 2020, Google Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 OPENSSL_HEADER_CRYPTO_FORK_DETECT_H
|
||||
#define OPENSSL_HEADER_CRYPTO_FORK_DETECT_H
|
||||
|
||||
#include <CCryptoBoringSSL_base.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
// crypto_get_fork_generation returns the fork generation number for the current
|
||||
// process, or zero if not supported on the platform. The fork generation number
|
||||
// is a non-zero, strictly-monotonic counter with the property that, if queried
|
||||
// in an address space and then again in a subsequently forked copy, the forked
|
||||
// address space will observe a greater value.
|
||||
//
|
||||
// This function may be used to clear cached values across a fork. When
|
||||
// initializing a cache, record the fork generation. Before using the cache,
|
||||
// check if the fork generation has changed. If so, drop the cache and update
|
||||
// the save fork generation. Note this logic transparently handles platforms
|
||||
// which always return zero.
|
||||
//
|
||||
// This is not reliably supported on all platforms which implement |fork|, so it
|
||||
// should only be used as a hardening measure.
|
||||
OPENSSL_EXPORT uint64_t CRYPTO_get_fork_generation(void);
|
||||
|
||||
// CRYPTO_fork_detect_ignore_madv_wipeonfork_for_testing is an internal detail
|
||||
// used for testing purposes.
|
||||
OPENSSL_EXPORT void CRYPTO_fork_detect_ignore_madv_wipeonfork_for_testing(void);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} // extern C
|
||||
#endif
|
||||
|
||||
#endif // OPENSSL_HEADER_CRYPTO_FORK_DETECT_H
|
||||
@@ -40,17 +40,33 @@ void RAND_bytes_with_additional_data(uint8_t *out, size_t out_len,
|
||||
// system.
|
||||
void CRYPTO_sysrand(uint8_t *buf, size_t len);
|
||||
|
||||
#if defined(OPENSSL_URANDOM) || defined(BORINGSSL_UNSAFE_DETERMINISTIC_MODE)
|
||||
#if defined(OPENSSL_URANDOM)
|
||||
// CRYPTO_init_sysrand initializes long-lived resources needed to draw entropy
|
||||
// from the operating system.
|
||||
void CRYPTO_init_sysrand(void);
|
||||
|
||||
// CRYPTO_sysrand_for_seed fills |len| bytes at |buf| with entropy from the
|
||||
// operating system. It may draw from the |GRND_RANDOM| pool on Android,
|
||||
// depending on the vendor's configuration.
|
||||
void CRYPTO_sysrand_for_seed(uint8_t *buf, size_t len);
|
||||
|
||||
// CRYPTO_sysrand_if_available fills |len| bytes at |buf| with entropy from the
|
||||
// operating system, if the entropy pool is initialized. If it is uninitialized,
|
||||
// it will not block and will instead fill |buf| with all zeros or early
|
||||
// /dev/urandom output.
|
||||
void CRYPTO_sysrand_if_available(uint8_t *buf, size_t len);
|
||||
// operating system, or early /dev/urandom data, and returns 1, _if_ the entropy
|
||||
// pool is initialized or if getrandom() is not available and not in FIPS mode.
|
||||
// Otherwise it will not block and will instead fill |buf| with all zeros and
|
||||
// return 0.
|
||||
int CRYPTO_sysrand_if_available(uint8_t *buf, size_t len);
|
||||
#else
|
||||
OPENSSL_INLINE void CRYPTO_init_sysrand(void) {}
|
||||
|
||||
OPENSSL_INLINE void CRYPTO_sysrand_for_seed(uint8_t *buf, size_t len) {
|
||||
CRYPTO_sysrand(buf, len);
|
||||
}
|
||||
|
||||
OPENSSL_INLINE int CRYPTO_sysrand_if_available(uint8_t *buf, size_t len) {
|
||||
CRYPTO_sysrand(buf, len);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
// rand_fork_unsafe_buffering_enabled returns whether fork-unsafe buffering has
|
||||
@@ -105,10 +121,19 @@ OPENSSL_EXPORT void CTR_DRBG_clear(CTR_DRBG_STATE *drbg);
|
||||
|
||||
|
||||
#if defined(OPENSSL_X86_64) && !defined(OPENSSL_NO_ASM)
|
||||
|
||||
OPENSSL_INLINE int have_rdrand(void) {
|
||||
return (OPENSSL_ia32cap_get()[1] & (1u << 30)) != 0;
|
||||
}
|
||||
|
||||
// have_fast_rdrand returns true if RDRAND is supported and it's reasonably
|
||||
// fast. Concretely the latter is defined by whether the chip is Intel (fast) or
|
||||
// not (assumed slow).
|
||||
OPENSSL_INLINE int have_fast_rdrand(void) {
|
||||
const uint32_t *const ia32cap = OPENSSL_ia32cap_get();
|
||||
return (ia32cap[1] & (1u << 30)) && (ia32cap[0] & (1u << 30));
|
||||
}
|
||||
|
||||
// CRYPTO_rdrand writes eight bytes of random data from the hardware RNG to
|
||||
// |out|. It returns one on success or zero on hardware failure.
|
||||
int CRYPTO_rdrand(uint8_t out[8]);
|
||||
@@ -117,6 +142,17 @@ int CRYPTO_rdrand(uint8_t out[8]);
|
||||
// the hardware RNG. The |len| argument must be a multiple of eight. It returns
|
||||
// one on success and zero on hardware failure.
|
||||
int CRYPTO_rdrand_multiple8_buf(uint8_t *buf, size_t len);
|
||||
|
||||
#else // OPENSSL_X86_64 && !OPENSSL_NO_ASM
|
||||
|
||||
OPENSSL_INLINE int have_rdrand(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
OPENSSL_INLINE int have_fast_rdrand(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // OPENSSL_X86_64 && !OPENSSL_NO_ASM
|
||||
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <CCryptoBoringSSL_mem.h>
|
||||
|
||||
#include "internal.h"
|
||||
#include "fork_detect.h"
|
||||
#include "../../internal.h"
|
||||
#include "../delocate.h"
|
||||
|
||||
@@ -57,6 +58,7 @@ static const unsigned kReseedInterval = 4096;
|
||||
// rand_thread_state contains the per-thread state for the RNG.
|
||||
struct rand_thread_state {
|
||||
CTR_DRBG_STATE drbg;
|
||||
uint64_t fork_generation;
|
||||
// calls is the number of generate calls made on |drbg| since it was last
|
||||
// (re)seeded. This is bound by |kReseedInterval|.
|
||||
unsigned calls;
|
||||
@@ -125,11 +127,9 @@ static void rand_thread_state_free(void *state_in) {
|
||||
|
||||
#if defined(OPENSSL_X86_64) && !defined(OPENSSL_NO_ASM) && \
|
||||
!defined(BORINGSSL_UNSAFE_DETERMINISTIC_MODE)
|
||||
static int hwrand(uint8_t *buf, const size_t len) {
|
||||
if (!have_rdrand()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// rdrand should only be called if either |have_rdrand| or |have_fast_rdrand|
|
||||
// returned true.
|
||||
static int rdrand(uint8_t *buf, const size_t len) {
|
||||
const size_t len_multiple8 = len & ~7;
|
||||
if (!CRYPTO_rdrand_multiple8_buf(buf, len_multiple8)) {
|
||||
return 0;
|
||||
@@ -157,7 +157,7 @@ static int hwrand(uint8_t *buf, const size_t len) {
|
||||
|
||||
#else
|
||||
|
||||
static int hwrand(uint8_t *buf, size_t len) {
|
||||
static int rdrand(uint8_t *buf, size_t len) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -168,7 +168,8 @@ static int hwrand(uint8_t *buf, size_t len) {
|
||||
static void rand_get_seed(struct rand_thread_state *state,
|
||||
uint8_t seed[CTR_DRBG_ENTROPY_LEN]) {
|
||||
if (!state->last_block_valid) {
|
||||
if (!hwrand(state->last_block, sizeof(state->last_block))) {
|
||||
if (!have_rdrand() ||
|
||||
!rdrand(state->last_block, sizeof(state->last_block))) {
|
||||
CRYPTO_sysrand_for_seed(state->last_block, sizeof(state->last_block));
|
||||
}
|
||||
state->last_block_valid = 1;
|
||||
@@ -179,8 +180,8 @@ static void rand_get_seed(struct rand_thread_state *state,
|
||||
#define FIPS_OVERREAD 10
|
||||
uint8_t entropy[CTR_DRBG_ENTROPY_LEN * FIPS_OVERREAD];
|
||||
|
||||
int used_hwrand = hwrand(entropy, sizeof(entropy));
|
||||
if (!used_hwrand) {
|
||||
int used_rdrand = have_rdrand() && rdrand(entropy, sizeof(entropy));
|
||||
if (!used_rdrand) {
|
||||
CRYPTO_sysrand_for_seed(entropy, sizeof(entropy));
|
||||
}
|
||||
|
||||
@@ -215,7 +216,7 @@ static void rand_get_seed(struct rand_thread_state *state,
|
||||
#if defined(OPENSSL_URANDOM)
|
||||
// If we used RDRAND, also opportunistically read from the system. This avoids
|
||||
// solely relying on the hardware once the entropy pool has been initialized.
|
||||
if (used_hwrand) {
|
||||
if (used_rdrand) {
|
||||
CRYPTO_sysrand_if_available(entropy, CTR_DRBG_ENTROPY_LEN);
|
||||
for (size_t i = 0; i < CTR_DRBG_ENTROPY_LEN; i++) {
|
||||
seed[i] ^= entropy[i];
|
||||
@@ -241,20 +242,31 @@ void RAND_bytes_with_additional_data(uint8_t *out, size_t out_len,
|
||||
return;
|
||||
}
|
||||
|
||||
const uint64_t fork_generation = CRYPTO_get_fork_generation();
|
||||
|
||||
// Additional data is mixed into every CTR-DRBG call to protect, as best we
|
||||
// can, against forks & VM clones. We do not over-read this information and
|
||||
// don't reseed with it so, from the point of view of FIPS, this doesn't
|
||||
// provide “prediction resistance”. But, in practice, it does.
|
||||
uint8_t additional_data[32];
|
||||
if (!hwrand(additional_data, sizeof(additional_data))) {
|
||||
// Intel chips have fast RDRAND instructions while, in other cases, RDRAND can
|
||||
// be _slower_ than a system call.
|
||||
if (!have_fast_rdrand() ||
|
||||
!rdrand(additional_data, sizeof(additional_data))) {
|
||||
// Without a hardware RNG to save us from address-space duplication, the OS
|
||||
// entropy is used. This can be expensive (one read per |RAND_bytes| call)
|
||||
// and so can be disabled by applications that we have ensured don't fork
|
||||
// and aren't at risk of VM cloning.
|
||||
if (!rand_fork_unsafe_buffering_enabled()) {
|
||||
CRYPTO_sysrand(additional_data, sizeof(additional_data));
|
||||
} else {
|
||||
// and so is disabled when we have fork detection, or if the application has
|
||||
// promised not to fork.
|
||||
if (fork_generation != 0 || rand_fork_unsafe_buffering_enabled()) {
|
||||
OPENSSL_memset(additional_data, 0, sizeof(additional_data));
|
||||
} else if (!have_rdrand()) {
|
||||
// No alternative so block for OS entropy.
|
||||
CRYPTO_sysrand(additional_data, sizeof(additional_data));
|
||||
} else if (!CRYPTO_sysrand_if_available(additional_data,
|
||||
sizeof(additional_data)) &&
|
||||
!rdrand(additional_data, sizeof(additional_data))) {
|
||||
// RDRAND failed: block for OS entropy.
|
||||
CRYPTO_sysrand(additional_data, sizeof(additional_data));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,6 +295,7 @@ void RAND_bytes_with_additional_data(uint8_t *out, size_t out_len,
|
||||
abort();
|
||||
}
|
||||
state->calls = 0;
|
||||
state->fork_generation = fork_generation;
|
||||
|
||||
#if defined(BORINGSSL_FIPS)
|
||||
if (state != &stack_state) {
|
||||
@@ -299,7 +312,8 @@ void RAND_bytes_with_additional_data(uint8_t *out, size_t out_len,
|
||||
#endif
|
||||
}
|
||||
|
||||
if (state->calls >= kReseedInterval) {
|
||||
if (state->calls >= kReseedInterval ||
|
||||
state->fork_generation != fork_generation) {
|
||||
uint8_t seed[CTR_DRBG_ENTROPY_LEN];
|
||||
rand_get_seed(state, seed);
|
||||
#if defined(BORINGSSL_FIPS)
|
||||
@@ -317,6 +331,7 @@ void RAND_bytes_with_additional_data(uint8_t *out, size_t out_len,
|
||||
abort();
|
||||
}
|
||||
state->calls = 0;
|
||||
state->fork_generation = fork_generation;
|
||||
} else {
|
||||
#if defined(BORINGSSL_FIPS)
|
||||
CRYPTO_STATIC_MUTEX_lock_read(thread_states_list_lock_bss_get());
|
||||
|
||||
@@ -95,17 +95,10 @@ static ssize_t boringssl_getrandom(void *buf, size_t buf_len, unsigned flags) {
|
||||
|
||||
#endif // USE_NR_getrandom
|
||||
|
||||
// rand_lock is used to protect the |*_requested| variables.
|
||||
DEFINE_STATIC_MUTEX(rand_lock)
|
||||
|
||||
// The following constants are magic values of |urandom_fd|.
|
||||
static const int kUnset = 0;
|
||||
// kHaveGetrandom in |urandom_fd| signals that |getrandom| or |getentropy| is
|
||||
// available and should be used instead.
|
||||
static const int kHaveGetrandom = -3;
|
||||
|
||||
// urandom_fd_requested is set by |RAND_set_urandom_fd|. It's protected by
|
||||
// |rand_lock|.
|
||||
DEFINE_BSS_GET(int, urandom_fd_requested)
|
||||
|
||||
// urandom_fd is a file descriptor to /dev/urandom. It's protected by |once|.
|
||||
DEFINE_BSS_GET(int, urandom_fd)
|
||||
|
||||
@@ -144,14 +137,9 @@ static void maybe_set_extra_getrandom_flags(void) {
|
||||
DEFINE_STATIC_ONCE(rand_once)
|
||||
|
||||
// init_once initializes the state of this module to values previously
|
||||
// requested. This is the only function that modifies |urandom_fd| and
|
||||
// |urandom_buffering|, whose values may be read safely after calling the
|
||||
// once.
|
||||
// requested. This is the only function that modifies |urandom_fd|, which may be
|
||||
// read safely after calling the once.
|
||||
static void init_once(void) {
|
||||
CRYPTO_STATIC_MUTEX_lock_read(rand_lock_bss_get());
|
||||
int fd = *urandom_fd_requested_bss_get();
|
||||
CRYPTO_STATIC_MUTEX_unlock_read(rand_lock_bss_get());
|
||||
|
||||
#if defined(USE_NR_getrandom)
|
||||
int have_getrandom;
|
||||
uint8_t dummy;
|
||||
@@ -194,31 +182,16 @@ static void init_once(void) {
|
||||
abort();
|
||||
#endif
|
||||
|
||||
if (fd == kUnset) {
|
||||
do {
|
||||
fd = open("/dev/urandom", O_RDONLY);
|
||||
} while (fd == -1 && errno == EINTR);
|
||||
}
|
||||
int fd;
|
||||
do {
|
||||
fd = open("/dev/urandom", O_RDONLY);
|
||||
} while (fd == -1 && errno == EINTR);
|
||||
|
||||
if (fd < 0) {
|
||||
perror("failed to open /dev/urandom");
|
||||
abort();
|
||||
}
|
||||
|
||||
assert(kUnset == 0);
|
||||
if (fd == kUnset) {
|
||||
// Because we want to keep |urandom_fd| in the BSS, we have to initialise
|
||||
// it to zero. But zero is a valid file descriptor too. Thus if open
|
||||
// returns zero for /dev/urandom, we dup it to get a non-zero number.
|
||||
fd = dup(fd);
|
||||
close(kUnset);
|
||||
|
||||
if (fd <= 0) {
|
||||
perror("failed to dup /dev/urandom fd");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
int flags = fcntl(fd, F_GETFD);
|
||||
if (flags == -1) {
|
||||
// Native Client doesn't implement |fcntl|.
|
||||
@@ -307,40 +280,6 @@ static void wait_for_entropy(void) {
|
||||
#endif // BORINGSSL_FIPS
|
||||
}
|
||||
|
||||
void RAND_set_urandom_fd(int fd) {
|
||||
fd = dup(fd);
|
||||
if (fd < 0) {
|
||||
perror("failed to dup supplied urandom fd");
|
||||
abort();
|
||||
}
|
||||
|
||||
assert(kUnset == 0);
|
||||
if (fd == kUnset) {
|
||||
// Because we want to keep |urandom_fd| in the BSS, we have to initialise
|
||||
// it to zero. But zero is a valid file descriptor too. Thus if dup
|
||||
// returned zero we dup it again to get a non-zero number.
|
||||
fd = dup(fd);
|
||||
close(kUnset);
|
||||
|
||||
if (fd <= 0) {
|
||||
perror("failed to dup supplied urandom fd");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
CRYPTO_STATIC_MUTEX_lock_write(rand_lock_bss_get());
|
||||
*urandom_fd_requested_bss_get() = fd;
|
||||
CRYPTO_STATIC_MUTEX_unlock_write(rand_lock_bss_get());
|
||||
|
||||
CRYPTO_once(rand_once_bss_get(), init_once);
|
||||
if (*urandom_fd_bss_get() == kHaveGetrandom) {
|
||||
close(fd);
|
||||
} else if (*urandom_fd_bss_get() != fd) {
|
||||
fprintf(stderr, "RAND_set_urandom_fd called after initialisation.\n");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
// fill_with_entropy writes |len| bytes of entropy into |out|. It returns one
|
||||
// on success and zero on error. If |block| is one, this function will block
|
||||
// until the entropy pool is initialized. Otherwise, this function may fail,
|
||||
@@ -362,7 +301,7 @@ static int fill_with_entropy(uint8_t *out, size_t len, int block, int seed) {
|
||||
}
|
||||
#endif
|
||||
|
||||
CRYPTO_once(rand_once_bss_get(), init_once);
|
||||
CRYPTO_init_sysrand();
|
||||
if (block) {
|
||||
CRYPTO_once(wait_for_entropy_once_bss_get(), wait_for_entropy);
|
||||
}
|
||||
@@ -417,6 +356,10 @@ void CRYPTO_sysrand(uint8_t *out, size_t requested) {
|
||||
}
|
||||
}
|
||||
|
||||
void CRYPTO_init_sysrand(void) {
|
||||
CRYPTO_once(rand_once_bss_get(), init_once);
|
||||
}
|
||||
|
||||
#if defined(BORINGSSL_FIPS)
|
||||
void CRYPTO_sysrand_for_seed(uint8_t *out, size_t requested) {
|
||||
if (!fill_with_entropy(out, requested, /*block=*/1, /*seed=*/1)) {
|
||||
@@ -431,16 +374,18 @@ void CRYPTO_sysrand_for_seed(uint8_t *out, size_t requested) {
|
||||
#endif
|
||||
}
|
||||
|
||||
void CRYPTO_sysrand_if_available(uint8_t *out, size_t requested) {
|
||||
// Return all zeros if |fill_with_entropy| fails.
|
||||
OPENSSL_memset(out, 0, requested);
|
||||
#endif // BORINGSSL_FIPS
|
||||
|
||||
if (!fill_with_entropy(out, requested, /*block=*/0, /*seed=*/0) &&
|
||||
errno != EAGAIN) {
|
||||
int CRYPTO_sysrand_if_available(uint8_t *out, size_t requested) {
|
||||
if (fill_with_entropy(out, requested, /*block=*/0, /*seed=*/0)) {
|
||||
return 1;
|
||||
} else if (errno == EAGAIN) {
|
||||
OPENSSL_memset(out, 0, requested);
|
||||
return 0;
|
||||
} else {
|
||||
perror("opportunistic entropy fill failed");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
#endif // BORINGSSL_FIPS
|
||||
|
||||
#endif // OPENSSL_URANDOM
|
||||
@@ -167,6 +167,10 @@ void BN_BLINDING_free(BN_BLINDING *r) {
|
||||
OPENSSL_free(r);
|
||||
}
|
||||
|
||||
void BN_BLINDING_invalidate(BN_BLINDING *b) {
|
||||
b->counter = BN_BLINDING_COUNTER - 1;
|
||||
}
|
||||
|
||||
static int bn_blinding_update(BN_BLINDING *b, const BIGNUM *e,
|
||||
const BN_MONT_CTX *mont, BN_CTX *ctx) {
|
||||
if (++b->counter == BN_BLINDING_COUNTER) {
|
||||
|
||||
@@ -83,6 +83,7 @@ int rsa_default_private_transform(RSA *rsa, uint8_t *out, const uint8_t *in,
|
||||
|
||||
BN_BLINDING *BN_BLINDING_new(void);
|
||||
void BN_BLINDING_free(BN_BLINDING *b);
|
||||
void BN_BLINDING_invalidate(BN_BLINDING *b);
|
||||
int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, const BIGNUM *e,
|
||||
const BN_MONT_CTX *mont_ctx, BN_CTX *ctx);
|
||||
int BN_BLINDING_invert(BIGNUM *n, const BN_BLINDING *b, BN_MONT_CTX *mont_ctx,
|
||||
|
||||
@@ -655,7 +655,12 @@ err:
|
||||
}
|
||||
|
||||
static int check_mod_inverse(int *out_ok, const BIGNUM *a, const BIGNUM *ainv,
|
||||
const BIGNUM *m, int check_reduced, BN_CTX *ctx) {
|
||||
const BIGNUM *m, BN_CTX *ctx) {
|
||||
if (BN_is_negative(ainv) || BN_cmp(ainv, m) >= 0) {
|
||||
*out_ok = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
BIGNUM *tmp = BN_CTX_get(ctx);
|
||||
int ret = tmp != NULL &&
|
||||
@@ -663,19 +668,12 @@ static int check_mod_inverse(int *out_ok, const BIGNUM *a, const BIGNUM *ainv,
|
||||
bn_div_consttime(NULL, tmp, tmp, m, ctx);
|
||||
if (ret) {
|
||||
*out_ok = BN_is_one(tmp);
|
||||
if (check_reduced && (BN_is_negative(ainv) || BN_cmp(ainv, m) >= 0)) {
|
||||
*out_ok = 0;
|
||||
}
|
||||
}
|
||||
BN_CTX_end(ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int RSA_check_key(const RSA *key) {
|
||||
BIGNUM n, pm1, qm1, lcm, dmp1, dmq1, iqmp_times_q;
|
||||
BN_CTX *ctx;
|
||||
int ok = 0, has_crt_values;
|
||||
|
||||
if (RSA_is_opaque(key)) {
|
||||
// Opaque keys can't be checked.
|
||||
return 1;
|
||||
@@ -697,50 +695,53 @@ int RSA_check_key(const RSA *key) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
ctx = BN_CTX_new();
|
||||
BN_CTX *ctx = BN_CTX_new();
|
||||
if (ctx == NULL) {
|
||||
OPENSSL_PUT_ERROR(RSA, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
BN_init(&n);
|
||||
BIGNUM tmp, de, pm1, qm1, dmp1, dmq1;
|
||||
int ok = 0;
|
||||
BN_init(&tmp);
|
||||
BN_init(&de);
|
||||
BN_init(&pm1);
|
||||
BN_init(&qm1);
|
||||
BN_init(&lcm);
|
||||
BN_init(&dmp1);
|
||||
BN_init(&dmq1);
|
||||
BN_init(&iqmp_times_q);
|
||||
|
||||
int d_ok;
|
||||
if (!bn_mul_consttime(&n, key->p, key->q, ctx) ||
|
||||
// lcm = lcm(p, q)
|
||||
!bn_usub_consttime(&pm1, key->p, BN_value_one()) ||
|
||||
!bn_usub_consttime(&qm1, key->q, BN_value_one()) ||
|
||||
!bn_lcm_consttime(&lcm, &pm1, &qm1, ctx) ||
|
||||
// Other implementations use the Euler totient rather than the Carmichael
|
||||
// totient, so allow unreduced |key->d|.
|
||||
!check_mod_inverse(&d_ok, key->e, key->d, &lcm,
|
||||
0 /* don't require reduced */, ctx)) {
|
||||
if (!bn_mul_consttime(&tmp, key->p, key->q, ctx)) {
|
||||
OPENSSL_PUT_ERROR(RSA, ERR_LIB_BN);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (BN_cmp(&n, key->n) != 0) {
|
||||
if (BN_cmp(&tmp, key->n) != 0) {
|
||||
OPENSSL_PUT_ERROR(RSA, RSA_R_N_NOT_EQUAL_P_Q);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!d_ok) {
|
||||
OPENSSL_PUT_ERROR(RSA, RSA_R_D_E_NOT_CONGRUENT_TO_1);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (BN_is_negative(key->d) || BN_cmp(key->d, key->n) >= 0) {
|
||||
OPENSSL_PUT_ERROR(RSA, RSA_R_D_OUT_OF_RANGE);
|
||||
goto out;
|
||||
}
|
||||
|
||||
has_crt_values = key->dmp1 != NULL;
|
||||
// d must be an inverse of e mod the Carmichael totient, lcm(p-1, q-1), but it
|
||||
// may be unreduced because other implementations use the Euler totient. We
|
||||
// simply check that d * e is one mod p-1 and mod q-1.
|
||||
if (!bn_usub_consttime(&pm1, key->p, BN_value_one()) ||
|
||||
!bn_usub_consttime(&qm1, key->q, BN_value_one()) ||
|
||||
!bn_mul_consttime(&de, key->d, key->e, ctx) ||
|
||||
!bn_div_consttime(NULL, &tmp, &de, &pm1, ctx) ||
|
||||
!bn_div_consttime(NULL, &de, &de, &qm1, ctx)) {
|
||||
OPENSSL_PUT_ERROR(RSA, ERR_LIB_BN);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!BN_is_one(&tmp) || !BN_is_one(&de)) {
|
||||
OPENSSL_PUT_ERROR(RSA, RSA_R_D_E_NOT_CONGRUENT_TO_1);
|
||||
goto out;
|
||||
}
|
||||
|
||||
int has_crt_values = key->dmp1 != NULL;
|
||||
if (has_crt_values != (key->dmq1 != NULL) ||
|
||||
has_crt_values != (key->iqmp != NULL)) {
|
||||
OPENSSL_PUT_ERROR(RSA, RSA_R_INCONSISTENT_SET_OF_CRT_VALUES);
|
||||
@@ -749,12 +750,9 @@ int RSA_check_key(const RSA *key) {
|
||||
|
||||
if (has_crt_values) {
|
||||
int dmp1_ok, dmq1_ok, iqmp_ok;
|
||||
if (!check_mod_inverse(&dmp1_ok, key->e, key->dmp1, &pm1,
|
||||
1 /* check reduced */, ctx) ||
|
||||
!check_mod_inverse(&dmq1_ok, key->e, key->dmq1, &qm1,
|
||||
1 /* check reduced */, ctx) ||
|
||||
!check_mod_inverse(&iqmp_ok, key->q, key->iqmp, key->p,
|
||||
1 /* check reduced */, ctx)) {
|
||||
if (!check_mod_inverse(&dmp1_ok, key->e, key->dmp1, &pm1, ctx) ||
|
||||
!check_mod_inverse(&dmq1_ok, key->e, key->dmq1, &qm1, ctx) ||
|
||||
!check_mod_inverse(&iqmp_ok, key->q, key->iqmp, key->p, ctx)) {
|
||||
OPENSSL_PUT_ERROR(RSA, ERR_LIB_BN);
|
||||
goto out;
|
||||
}
|
||||
@@ -768,13 +766,12 @@ int RSA_check_key(const RSA *key) {
|
||||
ok = 1;
|
||||
|
||||
out:
|
||||
BN_free(&n);
|
||||
BN_free(&tmp);
|
||||
BN_free(&de);
|
||||
BN_free(&pm1);
|
||||
BN_free(&qm1);
|
||||
BN_free(&lcm);
|
||||
BN_free(&dmp1);
|
||||
BN_free(&dmq1);
|
||||
BN_free(&iqmp_times_q);
|
||||
BN_CTX_free(ctx);
|
||||
|
||||
return ok;
|
||||
|
||||
@@ -70,6 +70,7 @@
|
||||
#include "../bn/internal.h"
|
||||
#include "../../internal.h"
|
||||
#include "../delocate.h"
|
||||
#include "../rand/fork_detect.h"
|
||||
|
||||
|
||||
static int check_modulus_and_exponent_sizes(const RSA *rsa) {
|
||||
@@ -345,7 +346,7 @@ err:
|
||||
// MAX_BLINDINGS_PER_RSA defines the maximum number of cached BN_BLINDINGs per
|
||||
// RSA*. Then this limit is exceeded, BN_BLINDING objects will be created and
|
||||
// destroyed as needed.
|
||||
#if defined(OPNESSL_TSAN)
|
||||
#if defined(OPENSSL_TSAN)
|
||||
// Smaller under TSAN so that the edge case can be hit with fewer threads.
|
||||
#define MAX_BLINDINGS_PER_RSA 2
|
||||
#else
|
||||
@@ -365,8 +366,21 @@ static BN_BLINDING *rsa_blinding_get(RSA *rsa, unsigned *index_used,
|
||||
assert(rsa->mont_n != NULL);
|
||||
|
||||
BN_BLINDING *ret = NULL;
|
||||
const uint64_t fork_generation = CRYPTO_get_fork_generation();
|
||||
CRYPTO_MUTEX_lock_write(&rsa->lock);
|
||||
|
||||
// Wipe the blinding cache on |fork|.
|
||||
if (rsa->blinding_fork_generation != fork_generation) {
|
||||
for (unsigned i = 0; i < rsa->num_blindings; i++) {
|
||||
// The inuse flag must be zero unless we were forked from a
|
||||
// multi-threaded process, in which case calling back into BoringSSL is
|
||||
// forbidden.
|
||||
assert(rsa->blindings_inuse[i] == 0);
|
||||
BN_BLINDING_invalidate(rsa->blindings[i]);
|
||||
}
|
||||
rsa->blinding_fork_generation = fork_generation;
|
||||
}
|
||||
|
||||
uint8_t *const free_inuse_flag =
|
||||
OPENSSL_memchr(rsa->blindings_inuse, 0, rsa->num_blindings);
|
||||
if (free_inuse_flag != NULL) {
|
||||
|
||||
@@ -105,6 +105,23 @@ int SHA512_Init(SHA512_CTX *sha) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int SHA512_256_Init(SHA512_CTX *sha) {
|
||||
sha->h[0] = UINT64_C(0x22312194fc2bf72c);
|
||||
sha->h[1] = UINT64_C(0x9f555fa3c84c64c2);
|
||||
sha->h[2] = UINT64_C(0x2393b86b6f53b151);
|
||||
sha->h[3] = UINT64_C(0x963877195940eabd);
|
||||
sha->h[4] = UINT64_C(0x96283ee2a88effe3);
|
||||
sha->h[5] = UINT64_C(0xbe5e1e2553863992);
|
||||
sha->h[6] = UINT64_C(0x2b0199fc2c85b8aa);
|
||||
sha->h[7] = UINT64_C(0x0eb72ddc81c52ca2);
|
||||
|
||||
sha->Nl = 0;
|
||||
sha->Nh = 0;
|
||||
sha->num = 0;
|
||||
sha->md_len = SHA512_256_DIGEST_LENGTH;
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t *SHA384(const uint8_t *data, size_t len,
|
||||
uint8_t out[SHA384_DIGEST_LENGTH]) {
|
||||
SHA512_CTX ctx;
|
||||
@@ -125,6 +142,16 @@ uint8_t *SHA512(const uint8_t *data, size_t len,
|
||||
return out;
|
||||
}
|
||||
|
||||
uint8_t *SHA512_256(const uint8_t *data, size_t len,
|
||||
uint8_t out[SHA512_256_DIGEST_LENGTH]) {
|
||||
SHA512_CTX ctx;
|
||||
SHA512_256_Init(&ctx);
|
||||
SHA512_Update(&ctx, data, len);
|
||||
SHA512_Final(out, &ctx);
|
||||
OPENSSL_cleanse(&ctx, sizeof(ctx));
|
||||
return out;
|
||||
}
|
||||
|
||||
#if !defined(SHA512_ASM)
|
||||
static void sha512_block_data_order(uint64_t *state, const uint8_t *in,
|
||||
size_t num_blocks);
|
||||
@@ -141,6 +168,17 @@ int SHA384_Update(SHA512_CTX *sha, const void *data, size_t len) {
|
||||
return SHA512_Update(sha, data, len);
|
||||
}
|
||||
|
||||
int SHA512_256_Update(SHA512_CTX *sha, const void *data, size_t len) {
|
||||
return SHA512_Update(sha, data, len);
|
||||
}
|
||||
|
||||
int SHA512_256_Final(uint8_t out[SHA512_256_DIGEST_LENGTH],
|
||||
SHA512_CTX *sha) {
|
||||
// |SHA512_256_Init| sets |sha->md_len| to |SHA512_256_DIGEST_LENGTH|, so this
|
||||
// has a |smaller output.
|
||||
return SHA512_Final(out, sha);
|
||||
}
|
||||
|
||||
void SHA512_Transform(SHA512_CTX *c, const uint8_t block[SHA512_CBLOCK]) {
|
||||
sha512_block_data_order(c->h, block, 1);
|
||||
}
|
||||
@@ -231,41 +269,12 @@ int SHA512_Final(uint8_t out[SHA512_DIGEST_LENGTH], SHA512_CTX *sha) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (sha->md_len) {
|
||||
// Let compiler decide if it's appropriate to unroll...
|
||||
case SHA384_DIGEST_LENGTH:
|
||||
for (n = 0; n < SHA384_DIGEST_LENGTH / 8; n++) {
|
||||
uint64_t t = sha->h[n];
|
||||
|
||||
*(out++) = (uint8_t)(t >> 56);
|
||||
*(out++) = (uint8_t)(t >> 48);
|
||||
*(out++) = (uint8_t)(t >> 40);
|
||||
*(out++) = (uint8_t)(t >> 32);
|
||||
*(out++) = (uint8_t)(t >> 24);
|
||||
*(out++) = (uint8_t)(t >> 16);
|
||||
*(out++) = (uint8_t)(t >> 8);
|
||||
*(out++) = (uint8_t)(t);
|
||||
}
|
||||
break;
|
||||
case SHA512_DIGEST_LENGTH:
|
||||
for (n = 0; n < SHA512_DIGEST_LENGTH / 8; n++) {
|
||||
uint64_t t = sha->h[n];
|
||||
|
||||
*(out++) = (uint8_t)(t >> 56);
|
||||
*(out++) = (uint8_t)(t >> 48);
|
||||
*(out++) = (uint8_t)(t >> 40);
|
||||
*(out++) = (uint8_t)(t >> 32);
|
||||
*(out++) = (uint8_t)(t >> 24);
|
||||
*(out++) = (uint8_t)(t >> 16);
|
||||
*(out++) = (uint8_t)(t >> 8);
|
||||
*(out++) = (uint8_t)(t);
|
||||
}
|
||||
break;
|
||||
// ... as well as make sure md_len is not abused.
|
||||
default:
|
||||
// TODO(davidben): This bad |md_len| case is one of the few places a
|
||||
// low-level hash 'final' function can fail. This should never happen.
|
||||
return 0;
|
||||
assert(sha->md_len % 8 == 0);
|
||||
const size_t out_words = sha->md_len / 8;
|
||||
for (size_t i = 0; i < out_words; i++) {
|
||||
const uint64_t t = CRYPTO_bswap8(sha->h[i]);
|
||||
memcpy(out, &t, sizeof(t));
|
||||
out += sizeof(t);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -84,28 +84,28 @@ static void __asan_unpoison_memory_region(const void *addr, size_t size) {}
|
||||
// Windows doesn't really support weak symbols as of May 2019, and Clang on
|
||||
// Windows will emit strong symbols instead. See
|
||||
// https://bugs.llvm.org/show_bug.cgi?id=37598
|
||||
#if defined(__ELF__) && defined(__GNUC__)
|
||||
#define WEAK_SYMBOL_FUNC(rettype, name, args) \
|
||||
rettype name args __attribute__((weak));
|
||||
#else
|
||||
#define WEAK_SYMBOL_FUNC(rettype, name, args) static rettype(*name) args = NULL;
|
||||
#endif
|
||||
|
||||
// Swift Crypto disables this for compatibility with weird libraries. See
|
||||
// https://github.com/apple/swift-nio-ssl/issues/189
|
||||
#if 0
|
||||
// sdallocx is a sized |free| function. By passing the size (which we happen to
|
||||
// always know in BoringSSL), the malloc implementation can save work. We cannot
|
||||
// depend on |sdallocx| being available so we declare a wrapper that falls back
|
||||
// to |free| as a weak symbol.
|
||||
// depend on |sdallocx| being available, however, so it's a weak symbol.
|
||||
//
|
||||
// This will always be safe, but will only be overridden if the malloc
|
||||
// implementation is statically linked with BoringSSL. So, if |sdallocx| is
|
||||
// provided in, say, libc.so, we still won't use it because that's dynamically
|
||||
// linked. This isn't an ideal result, but its helps in some cases.
|
||||
void sdallocx(void *ptr, size_t size, int flags);
|
||||
WEAK_SYMBOL_FUNC(void, sdallocx, (void *ptr, size_t size, int flags));
|
||||
|
||||
__attribute((weak, noinline))
|
||||
#else
|
||||
static
|
||||
#endif
|
||||
void sdallocx(void *ptr, size_t size, int flags) {
|
||||
free(ptr);
|
||||
}
|
||||
// The following two functions are for memory tracking. They are no-ops by
|
||||
// default but can be overridden at link time if the application needs to
|
||||
// observe heap operations.
|
||||
WEAK_SYMBOL_FUNC(void, OPENSSL_track_memory_alloc, (void *ptr, size_t size));
|
||||
WEAK_SYMBOL_FUNC(void, OPENSSL_track_memory_free, (void *ptr, size_t size));
|
||||
|
||||
void *OPENSSL_malloc(size_t size) {
|
||||
if (size + OPENSSL_MALLOC_PREFIX < size) {
|
||||
@@ -120,6 +120,9 @@ void *OPENSSL_malloc(size_t size) {
|
||||
*(size_t *)ptr = size;
|
||||
|
||||
__asan_poison_memory_region(ptr, OPENSSL_MALLOC_PREFIX);
|
||||
if (OPENSSL_track_memory_alloc) {
|
||||
OPENSSL_track_memory_alloc(ptr, size + OPENSSL_MALLOC_PREFIX);
|
||||
}
|
||||
return ((uint8_t *)ptr) + OPENSSL_MALLOC_PREFIX;
|
||||
}
|
||||
|
||||
@@ -132,8 +135,15 @@ void OPENSSL_free(void *orig_ptr) {
|
||||
__asan_unpoison_memory_region(ptr, OPENSSL_MALLOC_PREFIX);
|
||||
|
||||
size_t size = *(size_t *)ptr;
|
||||
if (OPENSSL_track_memory_free) {
|
||||
OPENSSL_track_memory_free(ptr, size + OPENSSL_MALLOC_PREFIX);
|
||||
}
|
||||
OPENSSL_cleanse(ptr, size + OPENSSL_MALLOC_PREFIX);
|
||||
sdallocx(ptr, size + OPENSSL_MALLOC_PREFIX, 0 /* flags */);
|
||||
if (sdallocx) {
|
||||
sdallocx(ptr, size + OPENSSL_MALLOC_PREFIX, 0 /* flags */);
|
||||
} else {
|
||||
free(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
void *OPENSSL_realloc(void *orig_ptr, size_t new_size) {
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
/* This file is generated by crypto/obj/objects.go. */
|
||||
|
||||
|
||||
#define NUM_NID 962
|
||||
#define NUM_NID 963
|
||||
|
||||
static const uint8_t kObjectData[] = {
|
||||
/* NID_rsadsi */
|
||||
@@ -7127,6 +7127,16 @@ static const uint8_t kObjectData[] = {
|
||||
0x2b,
|
||||
0x65,
|
||||
0x6f,
|
||||
/* NID_sha512_256 */
|
||||
0x60,
|
||||
0x86,
|
||||
0x48,
|
||||
0x01,
|
||||
0x65,
|
||||
0x03,
|
||||
0x04,
|
||||
0x02,
|
||||
0x06,
|
||||
};
|
||||
|
||||
static const ASN1_OBJECT kObjects[NUM_NID] = {
|
||||
@@ -8770,6 +8780,7 @@ static const ASN1_OBJECT kObjects[NUM_NID] = {
|
||||
{"CECPQ2", "CECPQ2", NID_CECPQ2, 0, NULL, 0},
|
||||
{"ED448", "ED448", NID_ED448, 3, &kObjectData[6181], 0},
|
||||
{"X448", "X448", NID_X448, 3, &kObjectData[6184], 0},
|
||||
{"SHA512-256", "sha512-256", NID_sha512_256, 9, &kObjectData[6187], 0},
|
||||
};
|
||||
|
||||
static const uint16_t kNIDsInShortNameOrder[] = {
|
||||
@@ -8959,6 +8970,7 @@ static const uint16_t kNIDsInShortNameOrder[] = {
|
||||
672 /* SHA256 */,
|
||||
673 /* SHA384 */,
|
||||
674 /* SHA512 */,
|
||||
962 /* SHA512-256 */,
|
||||
188 /* SMIME */,
|
||||
167 /* SMIME-CAPS */,
|
||||
100 /* SN */,
|
||||
@@ -10632,6 +10644,7 @@ static const uint16_t kNIDsInLongNameOrder[] = {
|
||||
673 /* sha384 */,
|
||||
669 /* sha384WithRSAEncryption */,
|
||||
674 /* sha512 */,
|
||||
962 /* sha512-256 */,
|
||||
670 /* sha512WithRSAEncryption */,
|
||||
42 /* shaWithRSAEncryption */,
|
||||
52 /* signingTime */,
|
||||
@@ -11391,6 +11404,7 @@ static const uint16_t kNIDsInOIDOrder[] = {
|
||||
673 /* 2.16.840.1.101.3.4.2.2 (OBJ_sha384) */,
|
||||
674 /* 2.16.840.1.101.3.4.2.3 (OBJ_sha512) */,
|
||||
675 /* 2.16.840.1.101.3.4.2.4 (OBJ_sha224) */,
|
||||
962 /* 2.16.840.1.101.3.4.2.6 (OBJ_sha512_256) */,
|
||||
802 /* 2.16.840.1.101.3.4.3.1 (OBJ_dsa_with_SHA224) */,
|
||||
803 /* 2.16.840.1.101.3.4.3.2 (OBJ_dsa_with_SHA256) */,
|
||||
71 /* 2.16.840.1.113730.1.1 (OBJ_netscape_cert_type) */,
|
||||
|
||||
@@ -30,27 +30,23 @@
|
||||
// multi-threaded program, replace this with a thread-local. (A mutex would not
|
||||
// be deterministic.)
|
||||
static uint64_t g_num_calls = 0;
|
||||
static struct CRYPTO_STATIC_MUTEX g_num_calls_lock = CRYPTO_STATIC_MUTEX_INIT;
|
||||
|
||||
void RAND_reset_for_fuzzing(void) { g_num_calls = 0; }
|
||||
|
||||
void CRYPTO_sysrand(uint8_t *out, size_t requested) {
|
||||
static const uint8_t kZeroKey[32];
|
||||
|
||||
CRYPTO_STATIC_MUTEX_lock_write(&g_num_calls_lock);
|
||||
uint64_t num_calls = g_num_calls++;
|
||||
CRYPTO_STATIC_MUTEX_unlock_write(&g_num_calls_lock);
|
||||
|
||||
uint8_t nonce[12];
|
||||
OPENSSL_memset(nonce, 0, sizeof(nonce));
|
||||
OPENSSL_memcpy(nonce, &g_num_calls, sizeof(g_num_calls));
|
||||
OPENSSL_memcpy(nonce, &num_calls, sizeof(num_calls));
|
||||
|
||||
OPENSSL_memset(out, 0, requested);
|
||||
CRYPTO_chacha_20(out, out, requested, kZeroKey, nonce, 0);
|
||||
g_num_calls++;
|
||||
}
|
||||
|
||||
void CRYPTO_sysrand_for_seed(uint8_t *out, size_t requested) {
|
||||
CRYPTO_sysrand(out, requested);
|
||||
}
|
||||
|
||||
void CRYPTO_sysrand_if_available(uint8_t *out, size_t requested) {
|
||||
CRYPTO_sysrand(out, requested);
|
||||
}
|
||||
|
||||
#endif // BORINGSSL_UNSAFE_DETERMINISTIC_MODE
|
||||
@@ -26,6 +26,10 @@
|
||||
|
||||
OPENSSL_STATIC_ASSERT(sizeof(CRYPTO_MUTEX) >= sizeof(pthread_rwlock_t),
|
||||
"CRYPTO_MUTEX is too small");
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
OPENSSL_STATIC_ASSERT(alignof(CRYPTO_MUTEX) >= alignof(pthread_rwlock_t),
|
||||
"CRYPTO_MUTEX has insufficient alignment");
|
||||
#endif
|
||||
|
||||
void CRYPTO_MUTEX_init(CRYPTO_MUTEX *lock) {
|
||||
if (pthread_rwlock_init((pthread_rwlock_t *) lock, NULL) != 0) {
|
||||
|
||||
@@ -29,6 +29,10 @@ OPENSSL_MSVC_PRAGMA(warning(pop))
|
||||
|
||||
OPENSSL_STATIC_ASSERT(sizeof(CRYPTO_MUTEX) >= sizeof(SRWLOCK),
|
||||
"CRYPTO_MUTEX is too small");
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
OPENSSL_STATIC_ASSERT(alignof(CRYPTO_MUTEX) >= alignof(SRWLOCK),
|
||||
"CRYPTO_MUTEX has insufficient alignment");
|
||||
#endif
|
||||
|
||||
static BOOL CALLBACK call_once_init(INIT_ONCE *once, void *arg, void **out) {
|
||||
void (**init)(void) = (void (**)(void))arg;
|
||||
|
||||
@@ -0,0 +1,278 @@
|
||||
/* Copyright (c) 2019, Google Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 OPENSSL_HEADER_TRUST_TOKEN_INTERNAL_H
|
||||
#define OPENSSL_HEADER_TRUST_TOKEN_INTERNAL_H
|
||||
|
||||
#include <CCryptoBoringSSL_base.h>
|
||||
#include <CCryptoBoringSSL_ec.h>
|
||||
#include <CCryptoBoringSSL_ec_key.h>
|
||||
#include <CCryptoBoringSSL_nid.h>
|
||||
|
||||
#include "../fipsmodule/ec/internal.h"
|
||||
|
||||
#include <CCryptoBoringSSL_trust_token.h>
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
// PMBTokens.
|
||||
//
|
||||
// PMBTokens is described in https://eprint.iacr.org/2020/072/20200324:214215
|
||||
// and provides anonymous tokens with private metadata. We implement the
|
||||
// construction with validity verification, described in appendix H,
|
||||
// construction 6.
|
||||
|
||||
// PMBTOKEN_NONCE_SIZE is the size of nonces used as part of the PMBToken
|
||||
// protocol.
|
||||
#define PMBTOKEN_NONCE_SIZE 64
|
||||
|
||||
typedef struct {
|
||||
// TODO(https://crbug.com/boringssl/334): These should store |EC_PRECOMP| so
|
||||
// that |TRUST_TOKEN_finish_issuance| can use |ec_point_mul_scalar_precomp|.
|
||||
EC_AFFINE pub0;
|
||||
EC_AFFINE pub1;
|
||||
EC_AFFINE pubs;
|
||||
} PMBTOKEN_CLIENT_KEY;
|
||||
|
||||
typedef struct {
|
||||
EC_SCALAR x0;
|
||||
EC_SCALAR y0;
|
||||
EC_SCALAR x1;
|
||||
EC_SCALAR y1;
|
||||
EC_SCALAR xs;
|
||||
EC_SCALAR ys;
|
||||
EC_AFFINE pub0;
|
||||
EC_PRECOMP pub0_precomp;
|
||||
EC_AFFINE pub1;
|
||||
EC_PRECOMP pub1_precomp;
|
||||
EC_AFFINE pubs;
|
||||
EC_PRECOMP pubs_precomp;
|
||||
} PMBTOKEN_ISSUER_KEY;
|
||||
|
||||
// PMBTOKEN_PRETOKEN represents the intermediate state a client keeps during a
|
||||
// PMBToken issuance operation.
|
||||
typedef struct pmb_pretoken_st {
|
||||
uint8_t t[PMBTOKEN_NONCE_SIZE];
|
||||
EC_SCALAR r;
|
||||
EC_AFFINE Tp;
|
||||
} PMBTOKEN_PRETOKEN;
|
||||
|
||||
// PMBTOKEN_PRETOKEN_free releases the memory associated with |token|.
|
||||
OPENSSL_EXPORT void PMBTOKEN_PRETOKEN_free(PMBTOKEN_PRETOKEN *token);
|
||||
|
||||
DEFINE_STACK_OF(PMBTOKEN_PRETOKEN)
|
||||
|
||||
// The following functions implement the corresponding |TRUST_TOKENS_METHOD|
|
||||
// functions for |TRUST_TOKENS_experiment_v0|'s PMBTokens construction which
|
||||
// uses P-521.
|
||||
int pmbtoken_exp0_generate_key(CBB *out_private, CBB *out_public);
|
||||
int pmbtoken_exp0_client_key_from_bytes(PMBTOKEN_CLIENT_KEY *key,
|
||||
const uint8_t *in, size_t len);
|
||||
int pmbtoken_exp0_issuer_key_from_bytes(PMBTOKEN_ISSUER_KEY *key,
|
||||
const uint8_t *in, size_t len);
|
||||
STACK_OF(PMBTOKEN_PRETOKEN) * pmbtoken_exp0_blind(CBB *cbb, size_t count);
|
||||
int pmbtoken_exp0_sign(const PMBTOKEN_ISSUER_KEY *key, CBB *cbb, CBS *cbs,
|
||||
size_t num_requested, size_t num_to_issue,
|
||||
uint8_t private_metadata);
|
||||
STACK_OF(TRUST_TOKEN) *
|
||||
pmbtoken_exp0_unblind(const PMBTOKEN_CLIENT_KEY *key,
|
||||
const STACK_OF(PMBTOKEN_PRETOKEN) * pretokens,
|
||||
CBS *cbs, size_t count, uint32_t key_id);
|
||||
int pmbtoken_exp0_read(const PMBTOKEN_ISSUER_KEY *key,
|
||||
uint8_t out_nonce[PMBTOKEN_NONCE_SIZE],
|
||||
uint8_t *out_private_metadata, const uint8_t *token,
|
||||
size_t token_len);
|
||||
|
||||
// The following functions implement the corresponding |TRUST_TOKENS_METHOD|
|
||||
// functions for |TRUST_TOKENS_experiment_v1|'s PMBTokens construction which
|
||||
// uses P-384.
|
||||
//
|
||||
// We use P-384 instead of our usual choice of P-256. See Appendix I which
|
||||
// describes two attacks which may affect smaller curves. In particular, p-1 for
|
||||
// P-256 is smooth, giving a low complexity for the p-1 attack. P-384's p-1 has
|
||||
// a 281-bit prime factor,
|
||||
// 3055465788140352002733946906144561090641249606160407884365391979704929268480326390471.
|
||||
// This lower-bounds the p-1 attack at O(2^140). The p+1 attack is lower-bounded
|
||||
// by O(p^(1/3)) or O(2^128), so we do not need to check the smoothness of p+1.
|
||||
int pmbtoken_exp1_generate_key(CBB *out_private, CBB *out_public);
|
||||
int pmbtoken_exp1_client_key_from_bytes(PMBTOKEN_CLIENT_KEY *key,
|
||||
const uint8_t *in, size_t len);
|
||||
int pmbtoken_exp1_issuer_key_from_bytes(PMBTOKEN_ISSUER_KEY *key,
|
||||
const uint8_t *in, size_t len);
|
||||
STACK_OF(PMBTOKEN_PRETOKEN) * pmbtoken_exp1_blind(CBB *cbb, size_t count);
|
||||
int pmbtoken_exp1_sign(const PMBTOKEN_ISSUER_KEY *key, CBB *cbb, CBS *cbs,
|
||||
size_t num_requested, size_t num_to_issue,
|
||||
uint8_t private_metadata);
|
||||
STACK_OF(TRUST_TOKEN) *
|
||||
pmbtoken_exp1_unblind(const PMBTOKEN_CLIENT_KEY *key,
|
||||
const STACK_OF(PMBTOKEN_PRETOKEN) * pretokens,
|
||||
CBS *cbs, size_t count, uint32_t key_id);
|
||||
int pmbtoken_exp1_read(const PMBTOKEN_ISSUER_KEY *key,
|
||||
uint8_t out_nonce[PMBTOKEN_NONCE_SIZE],
|
||||
uint8_t *out_private_metadata, const uint8_t *token,
|
||||
size_t token_len);
|
||||
|
||||
// pmbtoken_exp1_get_h_for_testing returns H in uncompressed coordinates. This
|
||||
// function is used to confirm H was computed as expected.
|
||||
OPENSSL_EXPORT int pmbtoken_exp1_get_h_for_testing(uint8_t out[97]);
|
||||
|
||||
|
||||
// Trust Tokens internals.
|
||||
|
||||
struct trust_token_method_st {
|
||||
// generate_key generates a fresh keypair and writes their serialized
|
||||
// forms into |out_private| and |out_public|. It returns one on success and
|
||||
// zero on failure.
|
||||
int (*generate_key)(CBB *out_private, CBB *out_public);
|
||||
|
||||
// client_key_from_bytes decodes a client key from |in| and sets |key|
|
||||
// to the resulting key. It returns one on success and zero
|
||||
// on failure.
|
||||
int (*client_key_from_bytes)(PMBTOKEN_CLIENT_KEY *key, const uint8_t *in,
|
||||
size_t len);
|
||||
|
||||
// issuer_key_from_bytes decodes a issuer key from |in| and sets |key|
|
||||
// to the resulting key. It returns one on success and zero
|
||||
// on failure.
|
||||
int (*issuer_key_from_bytes)(PMBTOKEN_ISSUER_KEY *key, const uint8_t *in,
|
||||
size_t len);
|
||||
|
||||
// blind generates a new issuance request for |count| tokens. On
|
||||
// success, it returns a newly-allocated |STACK_OF(PMBTOKEN_PRETOKEN)| and
|
||||
// writes a request to the issuer to |cbb|. On failure, it returns NULL. The
|
||||
// |STACK_OF(PMBTOKEN_PRETOKEN)|s should be passed to |pmbtoken_unblind| when
|
||||
// the server responds.
|
||||
//
|
||||
// This function implements the AT.Usr0 operation.
|
||||
STACK_OF(PMBTOKEN_PRETOKEN) *(*blind)(CBB *cbb, size_t count);
|
||||
|
||||
// sign parses a request for |num_requested| tokens from |cbs| and
|
||||
// issues |num_to_issue| tokens with |key| and a private metadata value of
|
||||
// |private_metadata|. It then writes the response to |cbb|. It returns one on
|
||||
// success and zero on failure.
|
||||
//
|
||||
// This function implements the AT.Sig operation.
|
||||
int (*sign)(const PMBTOKEN_ISSUER_KEY *key, CBB *cbb, CBS *cbs,
|
||||
size_t num_requested, size_t num_to_issue,
|
||||
uint8_t private_metadata);
|
||||
|
||||
// unblind processes an issuance response for |count| tokens from |cbs|
|
||||
// and unblinds the signed tokens. |pretokens| are the pre-tokens returned
|
||||
// from the corresponding |blind| call. On success, the function returns a
|
||||
// newly-allocated |STACK_OF(TRUST_TOKEN)| containing the resulting tokens.
|
||||
// Each token's serialization will have |key_id| prepended. Otherwise, it
|
||||
// returns NULL.
|
||||
//
|
||||
// This function implements the AT.Usr1 operation.
|
||||
STACK_OF(TRUST_TOKEN) *
|
||||
(*unblind)(const PMBTOKEN_CLIENT_KEY *key,
|
||||
const STACK_OF(PMBTOKEN_PRETOKEN) * pretokens, CBS *cbs,
|
||||
size_t count, uint32_t key_id);
|
||||
|
||||
// read parses a PMBToken from |token| and verifies it using |key|. On
|
||||
// success, it returns one and stores the nonce and private metadata bit in
|
||||
// |out_nonce| and |*out_private_metadata|. Otherwise, it returns zero. Note
|
||||
// that, unlike the output of |unblind|, |token| does not have a
|
||||
// four-byte key ID prepended.
|
||||
int (*read)(const PMBTOKEN_ISSUER_KEY *key,
|
||||
uint8_t out_nonce[PMBTOKEN_NONCE_SIZE],
|
||||
uint8_t *out_private_metadata, const uint8_t *token,
|
||||
size_t token_len);
|
||||
|
||||
// use_token_hash determines whether to include the token hash in the SRR and
|
||||
// private metadata encryption.
|
||||
int use_token_hash : 1;
|
||||
|
||||
// batched_proof determines whether PMBToken uses a batched DLEQOR proof when
|
||||
// signing tokens.
|
||||
int batched_proof : 1;
|
||||
};
|
||||
|
||||
// Structure representing a single Trust Token public key with the specified ID.
|
||||
struct trust_token_client_key_st {
|
||||
uint32_t id;
|
||||
PMBTOKEN_CLIENT_KEY key;
|
||||
};
|
||||
|
||||
// Structure representing a single Trust Token private key with the specified
|
||||
// ID.
|
||||
struct trust_token_issuer_key_st {
|
||||
uint32_t id;
|
||||
PMBTOKEN_ISSUER_KEY key;
|
||||
};
|
||||
|
||||
struct trust_token_client_st {
|
||||
const TRUST_TOKEN_METHOD *method;
|
||||
|
||||
// max_batchsize is the maximum supported batchsize.
|
||||
uint16_t max_batchsize;
|
||||
|
||||
// keys is the set of public keys that are supported by the client for
|
||||
// issuance/redemptions.
|
||||
struct trust_token_client_key_st keys[3];
|
||||
|
||||
// num_keys is the number of keys currently configured.
|
||||
size_t num_keys;
|
||||
|
||||
// pretokens is the intermediate state during an active issuance.
|
||||
STACK_OF(PMBTOKEN_PRETOKEN)* pretokens;
|
||||
|
||||
// srr_key is the public key used to verify the signature of the SRR.
|
||||
EVP_PKEY *srr_key;
|
||||
};
|
||||
|
||||
|
||||
struct trust_token_issuer_st {
|
||||
const TRUST_TOKEN_METHOD *method;
|
||||
|
||||
// max_batchsize is the maximum supported batchsize.
|
||||
uint16_t max_batchsize;
|
||||
|
||||
// keys is the set of private keys that are supported by the issuer for
|
||||
// issuance/redemptions. The public metadata is an index into this list of
|
||||
// keys.
|
||||
struct trust_token_issuer_key_st keys[3];
|
||||
|
||||
// num_keys is the number of keys currently configured.
|
||||
size_t num_keys;
|
||||
|
||||
// srr_key is the private key used to sign the SRR.
|
||||
EVP_PKEY *srr_key;
|
||||
|
||||
// metadata_key is the secret material used to encode the private metadata bit
|
||||
// in the SRR.
|
||||
uint8_t *metadata_key;
|
||||
size_t metadata_key_len;
|
||||
};
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} // extern C
|
||||
|
||||
extern "C++" {
|
||||
|
||||
BSSL_NAMESPACE_BEGIN
|
||||
|
||||
BORINGSSL_MAKE_DELETER(PMBTOKEN_PRETOKEN, PMBTOKEN_PRETOKEN_free)
|
||||
|
||||
BSSL_NAMESPACE_END
|
||||
|
||||
} // extern C++
|
||||
#endif
|
||||
|
||||
#endif // OPENSSL_HEADER_TRUST_TOKEN_INTERNAL_H
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,238 +0,0 @@
|
||||
/* Copyright (c) 2020, Google Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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. */
|
||||
|
||||
#include <CCryptoBoringSSL_bn.h>
|
||||
#include <CCryptoBoringSSL_bytestring.h>
|
||||
#include <CCryptoBoringSSL_ec.h>
|
||||
#include <CCryptoBoringSSL_err.h>
|
||||
#include <CCryptoBoringSSL_mem.h>
|
||||
#include <CCryptoBoringSSL_nid.h>
|
||||
#include <CCryptoBoringSSL_trust_token.h>
|
||||
|
||||
#include "../fipsmodule/bn/internal.h"
|
||||
#include "../fipsmodule/ec/internal.h"
|
||||
|
||||
|
||||
// Privacy Pass uses a custom elliptic curve construction described in
|
||||
// https://eprint.iacr.org/2020/072.pdf (section 7, construction 4). Ths
|
||||
// construction provides anonymous tokens with private metadata and validity
|
||||
// verification.
|
||||
|
||||
// get_h returns a randomly selected point for the Privacy Pass protocol.
|
||||
//
|
||||
// x: 66591746412783875033873351891229753622964683369847172829242944646280287810
|
||||
// 81195403447871073952234683395256591180452378091073292247502091640572714366
|
||||
// 588045092
|
||||
// y: 12347430519393087872533727997980072129796839266949808299436682045034861065
|
||||
// 18810630511924722292325611253427311923464047364545304196431830383014967865
|
||||
// 162306253
|
||||
//
|
||||
// This point was generated with the following Python code.
|
||||
|
||||
/*
|
||||
import hashlib
|
||||
|
||||
SEED_H = 'PrivacyPass H'
|
||||
|
||||
A = -3
|
||||
B = 0x051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00
|
||||
P = 2**521 - 1
|
||||
|
||||
def get_y(x):
|
||||
y2 = (x**3 + A*x + B) % P
|
||||
y = pow(y2, (P+1)/4, P)
|
||||
if (y*y) % P != y2:
|
||||
raise ValueError("point not on curve")
|
||||
return y
|
||||
|
||||
def bit(h,i):
|
||||
return (ord(h[i/8]) >> (i%8)) & 1
|
||||
|
||||
b = 521
|
||||
def decode_point(so):
|
||||
s = hashlib.sha256(so + '0').digest() + hashlib.sha256(so + '1').digest() + \
|
||||
hashlib.sha256(so + '2').digest()
|
||||
|
||||
x = 0
|
||||
for i in range(0,b):
|
||||
x = x + (long(bit(s,i))<<i)
|
||||
if x >= P:
|
||||
raise ValueError("x out of range")
|
||||
y = get_y(x)
|
||||
if y & 1 != bit(s,b-1): y = P-y
|
||||
return (x, y)
|
||||
|
||||
|
||||
def gen_point(seed):
|
||||
v = hashlib.sha256(seed).digest()
|
||||
it = 1
|
||||
while True:
|
||||
try:
|
||||
x,y = decode_point(v)
|
||||
except Exception, e:
|
||||
print e
|
||||
it += 1
|
||||
v = hashlib.sha256(v).digest()
|
||||
continue
|
||||
print "Found in %d iterations:" % it
|
||||
print " x = %d" % x
|
||||
print " y = %d" % y
|
||||
print " Encoded (hex): (%x, %x)" % (x, y)
|
||||
return (x, y)
|
||||
|
||||
if __name__ == "__main__":
|
||||
gen_point(SEED_H)
|
||||
*/
|
||||
|
||||
static EC_POINT *get_h(void) {
|
||||
EC_GROUP *group = EC_GROUP_new_by_curve_name(NID_secp521r1);
|
||||
if (group == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const BN_ULONG kHGenX[] = {
|
||||
TOBN(0x3d01749f, 0xc51e4724),
|
||||
TOBN(0x31c28621, 0xf95c98b9),
|
||||
TOBN(0x6dc5392a, 0xd4ce846e),
|
||||
TOBN(0xda645354, 0x4ef9760d),
|
||||
TOBN(0x5945d13e, 0x25337e4c),
|
||||
TOBN(0xeb0f6bc0, 0x5c0ecefe),
|
||||
TOBN(0xab291003, 0x6f4ef5bd),
|
||||
TOBN(0xa9f79ebc, 0x126cefd1),
|
||||
0x000001f0,
|
||||
};
|
||||
static const BIGNUM kX = STATIC_BIGNUM(kHGenX);
|
||||
|
||||
static const BN_ULONG kHGenY[] = {
|
||||
TOBN(0xffa6a0ea, 0x966792cd),
|
||||
TOBN(0x6e783d17, 0x08e3df3c),
|
||||
TOBN(0xb5617012, 0x72ac6ab0),
|
||||
TOBN(0xe0bcf350, 0x5c7e6641),
|
||||
TOBN(0x53bc55ea, 0xad8f261d),
|
||||
TOBN(0xbba93b9d, 0x70491eb4),
|
||||
TOBN(0x5214756f, 0x36d9c7fa),
|
||||
TOBN(0x1762517d, 0x325e29ac),
|
||||
0x0000005c,
|
||||
};
|
||||
static const BIGNUM kY = STATIC_BIGNUM(kHGenY);
|
||||
|
||||
EC_POINT *h = EC_POINT_new(group);
|
||||
if (h == NULL ||
|
||||
!EC_POINT_set_affine_coordinates_GFp(group, h, &kX, &kY, NULL)) {
|
||||
EC_POINT_free(h);
|
||||
return NULL;
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
// generate_keypair generates a keypair for the Private Metadata construction.
|
||||
// |out_x| and |out_y| are set to the secret half of the keypair, while
|
||||
// |*out_pub| is set to the public half of the keypair. It returns one on
|
||||
// success and zero on failure.
|
||||
static int generate_keypair(EC_SCALAR *out_x, EC_SCALAR *out_y,
|
||||
EC_POINT **out_pub, const EC_GROUP *group) {
|
||||
EC_POINT *h = get_h();
|
||||
if (h == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const uint8_t kDefaultAdditionalData[32] = {0};
|
||||
EC_RAW_POINT tmp1, tmp2;
|
||||
EC_POINT *pub = EC_POINT_new(group);
|
||||
if (pub == NULL ||
|
||||
!ec_random_nonzero_scalar(group, out_x, kDefaultAdditionalData) ||
|
||||
!ec_random_nonzero_scalar(group, out_y, kDefaultAdditionalData) ||
|
||||
!ec_point_mul_scalar_base(group, &tmp1, out_x) ||
|
||||
!ec_point_mul_scalar(group, &tmp2, &h->raw, out_y)) {
|
||||
EC_POINT_free(h);
|
||||
EC_POINT_free(pub);
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
group->meth->add(group, &pub->raw, &tmp1, &tmp2);
|
||||
*out_pub = pub;
|
||||
|
||||
EC_POINT_free(h);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int TRUST_TOKEN_generate_key(uint8_t *out_priv_key, size_t *out_priv_key_len,
|
||||
size_t max_priv_key_len, uint8_t *out_pub_key,
|
||||
size_t *out_pub_key_len, size_t max_pub_key_len,
|
||||
uint32_t id) {
|
||||
int ok = 0;
|
||||
EC_POINT *pub0 = NULL, *pub1 = NULL, *pubs = NULL;
|
||||
CBB cbb;
|
||||
CBB_zero(&cbb);
|
||||
uint8_t *buf = NULL;
|
||||
EC_GROUP *group = EC_GROUP_new_by_curve_name(NID_secp521r1);
|
||||
if (group == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
EC_SCALAR x0, y0, x1, y1, xs, ys;
|
||||
if (!generate_keypair(&x0, &y0, &pub0, group) ||
|
||||
!generate_keypair(&x1, &y1, &pub1, group) ||
|
||||
!generate_keypair(&xs, &ys, &pubs, group)) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_KEYGEN_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
size_t scalar_len = BN_num_bytes(&group->order);
|
||||
if (!CBB_init_fixed(&cbb, out_priv_key, max_priv_key_len) ||
|
||||
!CBB_add_u32(&cbb, id)) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_BUFFER_TOO_SMALL);
|
||||
goto err;
|
||||
}
|
||||
|
||||
const EC_SCALAR *scalars[] = {&x0, &y0, &x1, &y1, &xs, &ys};
|
||||
for (size_t i = 0; i < OPENSSL_ARRAY_SIZE(scalars); i++) {
|
||||
if (!CBB_add_space(&cbb, &buf, scalar_len)) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_BUFFER_TOO_SMALL);
|
||||
goto err;
|
||||
}
|
||||
ec_scalar_to_bytes(group, buf, &scalar_len, scalars[i]);
|
||||
}
|
||||
|
||||
if (!CBB_finish(&cbb, NULL, out_priv_key_len)) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_BUFFER_TOO_SMALL);
|
||||
goto err;
|
||||
}
|
||||
|
||||
CBB pub_cbb;
|
||||
if (!CBB_init_fixed(&cbb, out_pub_key, max_pub_key_len) ||
|
||||
!CBB_add_u32(&cbb, id) ||
|
||||
!CBB_add_u16_length_prefixed(&cbb, &pub_cbb) ||
|
||||
!EC_POINT_point2cbb(&pub_cbb, group, pub0, POINT_CONVERSION_UNCOMPRESSED,
|
||||
NULL) ||
|
||||
!CBB_add_u16_length_prefixed(&cbb, &pub_cbb) ||
|
||||
!EC_POINT_point2cbb(&pub_cbb, group, pub1, POINT_CONVERSION_UNCOMPRESSED,
|
||||
NULL) ||
|
||||
!CBB_add_u16_length_prefixed(&cbb, &pub_cbb) ||
|
||||
!EC_POINT_point2cbb(&pub_cbb, group, pubs, POINT_CONVERSION_UNCOMPRESSED,
|
||||
NULL) ||
|
||||
!CBB_finish(&cbb, NULL, out_pub_key_len)) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_BUFFER_TOO_SMALL);
|
||||
goto err;
|
||||
}
|
||||
|
||||
ok = 1;
|
||||
|
||||
err:
|
||||
CBB_cleanup(&cbb);
|
||||
EC_POINT_free(pub0);
|
||||
EC_POINT_free(pub1);
|
||||
EC_POINT_free(pubs);
|
||||
return ok;
|
||||
}
|
||||
@@ -0,0 +1,720 @@
|
||||
/* Copyright (c) 2019, Google Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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. */
|
||||
|
||||
#include <CCryptoBoringSSL_bytestring.h>
|
||||
#include <CCryptoBoringSSL_err.h>
|
||||
#include <CCryptoBoringSSL_evp.h>
|
||||
#include <CCryptoBoringSSL_mem.h>
|
||||
#include <CCryptoBoringSSL_sha.h>
|
||||
#include <CCryptoBoringSSL_trust_token.h>
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
// The Trust Token API is described in
|
||||
// https://github.com/WICG/trust-token-api/blob/master/README.md and provides a
|
||||
// protocol for issuing and redeeming tokens built on top of the PMBTokens
|
||||
// construction.
|
||||
|
||||
const TRUST_TOKEN_METHOD *TRUST_TOKEN_experiment_v0(void) {
|
||||
static const TRUST_TOKEN_METHOD kMethod = {
|
||||
pmbtoken_exp0_generate_key,
|
||||
pmbtoken_exp0_client_key_from_bytes,
|
||||
pmbtoken_exp0_issuer_key_from_bytes,
|
||||
pmbtoken_exp0_blind,
|
||||
pmbtoken_exp0_sign,
|
||||
pmbtoken_exp0_unblind,
|
||||
pmbtoken_exp0_read,
|
||||
0 /* don't use token hash */,
|
||||
0 /* don't use batched proof */,
|
||||
};
|
||||
return &kMethod;
|
||||
}
|
||||
|
||||
const TRUST_TOKEN_METHOD *TRUST_TOKEN_experiment_v1(void) {
|
||||
static const TRUST_TOKEN_METHOD kMethod = {
|
||||
pmbtoken_exp1_generate_key,
|
||||
pmbtoken_exp1_client_key_from_bytes,
|
||||
pmbtoken_exp1_issuer_key_from_bytes,
|
||||
pmbtoken_exp1_blind,
|
||||
pmbtoken_exp1_sign,
|
||||
pmbtoken_exp1_unblind,
|
||||
pmbtoken_exp1_read,
|
||||
1 /* use token hash */,
|
||||
1 /* use batched proof */,
|
||||
};
|
||||
return &kMethod;
|
||||
}
|
||||
|
||||
TRUST_TOKEN *TRUST_TOKEN_new(const uint8_t *data, size_t len) {
|
||||
TRUST_TOKEN *ret = OPENSSL_malloc(sizeof(TRUST_TOKEN));
|
||||
if (ret == NULL) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
OPENSSL_memset(ret, 0, sizeof(TRUST_TOKEN));
|
||||
ret->data = OPENSSL_memdup(data, len);
|
||||
if (len != 0 && ret->data == NULL) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, ERR_R_MALLOC_FAILURE);
|
||||
OPENSSL_free(ret);
|
||||
return NULL;
|
||||
}
|
||||
ret->len = len;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void TRUST_TOKEN_free(TRUST_TOKEN *token) {
|
||||
if (token == NULL) {
|
||||
return;
|
||||
}
|
||||
OPENSSL_free(token->data);
|
||||
OPENSSL_free(token);
|
||||
}
|
||||
|
||||
int TRUST_TOKEN_generate_key(const TRUST_TOKEN_METHOD *method,
|
||||
uint8_t *out_priv_key, size_t *out_priv_key_len,
|
||||
size_t max_priv_key_len, uint8_t *out_pub_key,
|
||||
size_t *out_pub_key_len, size_t max_pub_key_len,
|
||||
uint32_t id) {
|
||||
// Prepend the key ID in front of the PMBTokens format.
|
||||
int ret = 0;
|
||||
CBB priv_cbb, pub_cbb;
|
||||
CBB_zero(&priv_cbb);
|
||||
CBB_zero(&pub_cbb);
|
||||
if (!CBB_init_fixed(&priv_cbb, out_priv_key, max_priv_key_len) ||
|
||||
!CBB_init_fixed(&pub_cbb, out_pub_key, max_pub_key_len) ||
|
||||
!CBB_add_u32(&priv_cbb, id) ||
|
||||
!CBB_add_u32(&pub_cbb, id)) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_BUFFER_TOO_SMALL);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!method->generate_key(&priv_cbb, &pub_cbb)) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!CBB_finish(&priv_cbb, NULL, out_priv_key_len) ||
|
||||
!CBB_finish(&pub_cbb, NULL, out_pub_key_len)) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_BUFFER_TOO_SMALL);
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = 1;
|
||||
|
||||
err:
|
||||
CBB_cleanup(&priv_cbb);
|
||||
CBB_cleanup(&pub_cbb);
|
||||
return ret;
|
||||
}
|
||||
|
||||
TRUST_TOKEN_CLIENT *TRUST_TOKEN_CLIENT_new(const TRUST_TOKEN_METHOD *method,
|
||||
size_t max_batchsize) {
|
||||
if (max_batchsize > 0xffff) {
|
||||
// The protocol supports only two-byte token counts.
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, ERR_R_OVERFLOW);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TRUST_TOKEN_CLIENT *ret = OPENSSL_malloc(sizeof(TRUST_TOKEN_CLIENT));
|
||||
if (ret == NULL) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
OPENSSL_memset(ret, 0, sizeof(TRUST_TOKEN_CLIENT));
|
||||
ret->method = method;
|
||||
ret->max_batchsize = (uint16_t)max_batchsize;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void TRUST_TOKEN_CLIENT_free(TRUST_TOKEN_CLIENT *ctx) {
|
||||
if (ctx == NULL) {
|
||||
return;
|
||||
}
|
||||
EVP_PKEY_free(ctx->srr_key);
|
||||
sk_PMBTOKEN_PRETOKEN_pop_free(ctx->pretokens, PMBTOKEN_PRETOKEN_free);
|
||||
OPENSSL_free(ctx);
|
||||
}
|
||||
|
||||
int TRUST_TOKEN_CLIENT_add_key(TRUST_TOKEN_CLIENT *ctx, size_t *out_key_index,
|
||||
const uint8_t *key, size_t key_len) {
|
||||
if (ctx->num_keys == OPENSSL_ARRAY_SIZE(ctx->keys)) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_TOO_MANY_KEYS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct trust_token_client_key_st *key_s = &ctx->keys[ctx->num_keys];
|
||||
CBS cbs;
|
||||
CBS_init(&cbs, key, key_len);
|
||||
uint32_t key_id;
|
||||
if (!CBS_get_u32(&cbs, &key_id) ||
|
||||
!ctx->method->client_key_from_bytes(&key_s->key, CBS_data(&cbs),
|
||||
CBS_len(&cbs))) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_DECODE_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
key_s->id = key_id;
|
||||
*out_key_index = ctx->num_keys;
|
||||
ctx->num_keys += 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int TRUST_TOKEN_CLIENT_set_srr_key(TRUST_TOKEN_CLIENT *ctx, EVP_PKEY *key) {
|
||||
EVP_PKEY_free(ctx->srr_key);
|
||||
EVP_PKEY_up_ref(key);
|
||||
ctx->srr_key = key;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int TRUST_TOKEN_CLIENT_begin_issuance(TRUST_TOKEN_CLIENT *ctx, uint8_t **out,
|
||||
size_t *out_len, size_t count) {
|
||||
if (count > ctx->max_batchsize) {
|
||||
count = ctx->max_batchsize;
|
||||
}
|
||||
|
||||
int ret = 0;
|
||||
CBB request;
|
||||
STACK_OF(PMBTOKEN_PRETOKEN) *pretokens = NULL;
|
||||
if (!CBB_init(&request, 0) ||
|
||||
!CBB_add_u16(&request, count)) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
pretokens = ctx->method->blind(&request, count);
|
||||
if (pretokens == NULL) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!CBB_finish(&request, out, out_len)) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
sk_PMBTOKEN_PRETOKEN_pop_free(ctx->pretokens, PMBTOKEN_PRETOKEN_free);
|
||||
ctx->pretokens = pretokens;
|
||||
pretokens = NULL;
|
||||
ret = 1;
|
||||
|
||||
err:
|
||||
CBB_cleanup(&request);
|
||||
sk_PMBTOKEN_PRETOKEN_pop_free(pretokens, PMBTOKEN_PRETOKEN_free);
|
||||
return ret;
|
||||
}
|
||||
|
||||
STACK_OF(TRUST_TOKEN) *
|
||||
TRUST_TOKEN_CLIENT_finish_issuance(TRUST_TOKEN_CLIENT *ctx,
|
||||
size_t *out_key_index,
|
||||
const uint8_t *response,
|
||||
size_t response_len) {
|
||||
CBS in;
|
||||
CBS_init(&in, response, response_len);
|
||||
uint16_t count;
|
||||
uint32_t key_id;
|
||||
if (!CBS_get_u16(&in, &count) ||
|
||||
!CBS_get_u32(&in, &key_id)) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_DECODE_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t key_index = 0;
|
||||
const struct trust_token_client_key_st *key = NULL;
|
||||
for (size_t i = 0; i < ctx->num_keys; i++) {
|
||||
if (ctx->keys[i].id == key_id) {
|
||||
key_index = i;
|
||||
key = &ctx->keys[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (key == NULL) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_INVALID_KEY_ID);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (count > sk_PMBTOKEN_PRETOKEN_num(ctx->pretokens)) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_DECODE_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
STACK_OF(TRUST_TOKEN) *tokens =
|
||||
ctx->method->unblind(&key->key, ctx->pretokens, &in, count, key_id);
|
||||
if (tokens == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (CBS_len(&in) != 0) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_DECODE_FAILURE);
|
||||
sk_TRUST_TOKEN_pop_free(tokens, TRUST_TOKEN_free);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sk_PMBTOKEN_PRETOKEN_pop_free(ctx->pretokens, PMBTOKEN_PRETOKEN_free);
|
||||
ctx->pretokens = NULL;
|
||||
|
||||
*out_key_index = key_index;
|
||||
return tokens;
|
||||
}
|
||||
|
||||
int TRUST_TOKEN_CLIENT_begin_redemption(TRUST_TOKEN_CLIENT *ctx, uint8_t **out,
|
||||
size_t *out_len,
|
||||
const TRUST_TOKEN *token,
|
||||
const uint8_t *data, size_t data_len,
|
||||
uint64_t time) {
|
||||
CBB request, token_inner, inner;
|
||||
if (!CBB_init(&request, 0) ||
|
||||
!CBB_add_u16_length_prefixed(&request, &token_inner) ||
|
||||
!CBB_add_bytes(&token_inner, token->data, token->len) ||
|
||||
!CBB_add_u16_length_prefixed(&request, &inner) ||
|
||||
!CBB_add_bytes(&inner, data, data_len) ||
|
||||
!CBB_add_u64(&request, time) ||
|
||||
!CBB_finish(&request, out, out_len)) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, ERR_R_MALLOC_FAILURE);
|
||||
CBB_cleanup(&request);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int TRUST_TOKEN_CLIENT_finish_redemption(TRUST_TOKEN_CLIENT *ctx,
|
||||
uint8_t **out_srr, size_t *out_srr_len,
|
||||
uint8_t **out_sig, size_t *out_sig_len,
|
||||
const uint8_t *response,
|
||||
size_t response_len) {
|
||||
if (ctx->srr_key == NULL) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_NO_SRR_KEY_CONFIGURED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
CBS in, srr, sig;
|
||||
CBS_init(&in, response, response_len);
|
||||
if (!CBS_get_u16_length_prefixed(&in, &srr) ||
|
||||
!CBS_get_u16_length_prefixed(&in, &sig)) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_DECODE_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
EVP_MD_CTX md_ctx;
|
||||
EVP_MD_CTX_init(&md_ctx);
|
||||
int sig_ok = EVP_DigestVerifyInit(&md_ctx, NULL, NULL, NULL, ctx->srr_key) &&
|
||||
EVP_DigestVerify(&md_ctx, CBS_data(&sig), CBS_len(&sig),
|
||||
CBS_data(&srr), CBS_len(&srr));
|
||||
EVP_MD_CTX_cleanup(&md_ctx);
|
||||
|
||||
if (!sig_ok) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_SRR_SIGNATURE_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t *srr_buf = NULL, *sig_buf = NULL;
|
||||
size_t srr_len, sig_len;
|
||||
if (!CBS_stow(&srr, &srr_buf, &srr_len) ||
|
||||
!CBS_stow(&sig, &sig_buf, &sig_len)) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, ERR_R_MALLOC_FAILURE);
|
||||
OPENSSL_free(srr_buf);
|
||||
OPENSSL_free(sig_buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*out_srr = srr_buf;
|
||||
*out_srr_len = srr_len;
|
||||
*out_sig = sig_buf;
|
||||
*out_sig_len = sig_len;
|
||||
return 1;
|
||||
}
|
||||
|
||||
TRUST_TOKEN_ISSUER *TRUST_TOKEN_ISSUER_new(const TRUST_TOKEN_METHOD *method,
|
||||
size_t max_batchsize) {
|
||||
if (max_batchsize > 0xffff) {
|
||||
// The protocol supports only two-byte token counts.
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, ERR_R_OVERFLOW);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TRUST_TOKEN_ISSUER *ret = OPENSSL_malloc(sizeof(TRUST_TOKEN_ISSUER));
|
||||
if (ret == NULL) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
OPENSSL_memset(ret, 0, sizeof(TRUST_TOKEN_ISSUER));
|
||||
ret->method = method;
|
||||
ret->max_batchsize = (uint16_t)max_batchsize;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void TRUST_TOKEN_ISSUER_free(TRUST_TOKEN_ISSUER *ctx) {
|
||||
if (ctx == NULL) {
|
||||
return;
|
||||
}
|
||||
EVP_PKEY_free(ctx->srr_key);
|
||||
OPENSSL_free(ctx->metadata_key);
|
||||
OPENSSL_free(ctx);
|
||||
}
|
||||
|
||||
int TRUST_TOKEN_ISSUER_add_key(TRUST_TOKEN_ISSUER *ctx, const uint8_t *key,
|
||||
size_t key_len) {
|
||||
if (ctx->num_keys == OPENSSL_ARRAY_SIZE(ctx->keys)) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_TOO_MANY_KEYS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct trust_token_issuer_key_st *key_s = &ctx->keys[ctx->num_keys];
|
||||
CBS cbs;
|
||||
CBS_init(&cbs, key, key_len);
|
||||
uint32_t key_id;
|
||||
if (!CBS_get_u32(&cbs, &key_id) ||
|
||||
!ctx->method->issuer_key_from_bytes(&key_s->key, CBS_data(&cbs),
|
||||
CBS_len(&cbs))) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_DECODE_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
key_s->id = key_id;
|
||||
ctx->num_keys += 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int TRUST_TOKEN_ISSUER_set_srr_key(TRUST_TOKEN_ISSUER *ctx, EVP_PKEY *key) {
|
||||
EVP_PKEY_free(ctx->srr_key);
|
||||
EVP_PKEY_up_ref(key);
|
||||
ctx->srr_key = key;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int TRUST_TOKEN_ISSUER_set_metadata_key(TRUST_TOKEN_ISSUER *ctx,
|
||||
const uint8_t *key, size_t len) {
|
||||
if (len < 32) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_INVALID_METADATA_KEY);
|
||||
}
|
||||
OPENSSL_free(ctx->metadata_key);
|
||||
ctx->metadata_key_len = 0;
|
||||
ctx->metadata_key = OPENSSL_memdup(key, len);
|
||||
if (ctx->metadata_key == NULL) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
ctx->metadata_key_len = len;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const struct trust_token_issuer_key_st *trust_token_issuer_get_key(
|
||||
const TRUST_TOKEN_ISSUER *ctx, uint32_t key_id) {
|
||||
for (size_t i = 0; i < ctx->num_keys; i++) {
|
||||
if (ctx->keys[i].id == key_id) {
|
||||
return &ctx->keys[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int TRUST_TOKEN_ISSUER_issue(const TRUST_TOKEN_ISSUER *ctx, uint8_t **out,
|
||||
size_t *out_len, size_t *out_tokens_issued,
|
||||
const uint8_t *request, size_t request_len,
|
||||
uint32_t public_metadata, uint8_t private_metadata,
|
||||
size_t max_issuance) {
|
||||
if (max_issuance > ctx->max_batchsize) {
|
||||
max_issuance = ctx->max_batchsize;
|
||||
}
|
||||
|
||||
const struct trust_token_issuer_key_st *key =
|
||||
trust_token_issuer_get_key(ctx, public_metadata);
|
||||
if (key == NULL || private_metadata > 1) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_INVALID_METADATA);
|
||||
return 0;
|
||||
}
|
||||
|
||||
CBS in;
|
||||
uint16_t num_requested;
|
||||
CBS_init(&in, request, request_len);
|
||||
if (!CBS_get_u16(&in, &num_requested)) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_DECODE_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t num_to_issue = num_requested;
|
||||
if (num_to_issue > max_issuance) {
|
||||
num_to_issue = max_issuance;
|
||||
}
|
||||
|
||||
int ret = 0;
|
||||
CBB response;
|
||||
if (!CBB_init(&response, 0) ||
|
||||
!CBB_add_u16(&response, num_to_issue) ||
|
||||
!CBB_add_u32(&response, public_metadata)) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!ctx->method->sign(&key->key, &response, &in, num_requested, num_to_issue,
|
||||
private_metadata)) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (CBS_len(&in) != 0) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_DECODE_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!CBB_finish(&response, out, out_len)) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
*out_tokens_issued = num_to_issue;
|
||||
ret = 1;
|
||||
|
||||
err:
|
||||
CBB_cleanup(&response);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// https://tools.ietf.org/html/rfc7049#section-2.1
|
||||
static int add_cbor_int_with_type(CBB *cbb, uint8_t major_type,
|
||||
uint64_t value) {
|
||||
if (value <= 23) {
|
||||
return CBB_add_u8(cbb, value | major_type);
|
||||
}
|
||||
if (value <= 0xff) {
|
||||
return CBB_add_u8(cbb, 0x18 | major_type) && CBB_add_u8(cbb, value);
|
||||
}
|
||||
if (value <= 0xffff) {
|
||||
return CBB_add_u8(cbb, 0x19 | major_type) && CBB_add_u16(cbb, value);
|
||||
}
|
||||
if (value <= 0xffffffff) {
|
||||
return CBB_add_u8(cbb, 0x1a | major_type) && CBB_add_u32(cbb, value);
|
||||
}
|
||||
if (value <= 0xffffffffffffffff) {
|
||||
return CBB_add_u8(cbb, 0x1b | major_type) && CBB_add_u64(cbb, value);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// https://tools.ietf.org/html/rfc7049#section-2.1
|
||||
static int add_cbor_int(CBB *cbb, uint64_t value) {
|
||||
return add_cbor_int_with_type(cbb, 0, value);
|
||||
}
|
||||
|
||||
// https://tools.ietf.org/html/rfc7049#section-2.1
|
||||
static int add_cbor_bytes(CBB *cbb, const uint8_t *data, size_t len) {
|
||||
return add_cbor_int_with_type(cbb, 0x40, len) &&
|
||||
CBB_add_bytes(cbb, data, len);
|
||||
}
|
||||
|
||||
// https://tools.ietf.org/html/rfc7049#section-2.1
|
||||
static int add_cbor_text(CBB *cbb, const char *data, size_t len) {
|
||||
return add_cbor_int_with_type(cbb, 0x60, len) &&
|
||||
CBB_add_bytes(cbb, (const uint8_t *)data, len);
|
||||
}
|
||||
|
||||
// https://tools.ietf.org/html/rfc7049#section-2.1
|
||||
static int add_cbor_map(CBB *cbb, uint8_t size) {
|
||||
return add_cbor_int_with_type(cbb, 0xa0, size);
|
||||
}
|
||||
|
||||
static uint8_t get_metadata_obfuscator(const uint8_t *key, size_t key_len,
|
||||
const uint8_t *client_data,
|
||||
size_t client_data_len) {
|
||||
uint8_t metadata_obfuscator[SHA256_DIGEST_LENGTH];
|
||||
SHA256_CTX sha_ctx;
|
||||
SHA256_Init(&sha_ctx);
|
||||
SHA256_Update(&sha_ctx, key, key_len);
|
||||
SHA256_Update(&sha_ctx, client_data, client_data_len);
|
||||
SHA256_Final(metadata_obfuscator, &sha_ctx);
|
||||
return metadata_obfuscator[0] >> 7;
|
||||
}
|
||||
|
||||
int TRUST_TOKEN_ISSUER_redeem(const TRUST_TOKEN_ISSUER *ctx, uint8_t **out,
|
||||
size_t *out_len, TRUST_TOKEN **out_token,
|
||||
uint8_t **out_client_data,
|
||||
size_t *out_client_data_len,
|
||||
uint64_t *out_redemption_time,
|
||||
const uint8_t *request, size_t request_len,
|
||||
uint64_t lifetime) {
|
||||
CBS request_cbs, token_cbs;
|
||||
CBS_init(&request_cbs, request, request_len);
|
||||
if (!CBS_get_u16_length_prefixed(&request_cbs, &token_cbs)) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_DECODE_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t public_metadata = 0;
|
||||
uint8_t private_metadata = 0;
|
||||
|
||||
CBS token_copy = token_cbs;
|
||||
|
||||
// Parse the token. If there is an error, treat it as an invalid token.
|
||||
if (!CBS_get_u32(&token_cbs, &public_metadata)) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_INVALID_TOKEN);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct trust_token_issuer_key_st *key =
|
||||
trust_token_issuer_get_key(ctx, public_metadata);
|
||||
uint8_t nonce[PMBTOKEN_NONCE_SIZE];
|
||||
if (key == NULL ||
|
||||
!ctx->method->read(&key->key, nonce, &private_metadata,
|
||||
CBS_data(&token_cbs), CBS_len(&token_cbs))) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_INVALID_TOKEN);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ok = 0;
|
||||
CBB response, srr;
|
||||
uint8_t *srr_buf = NULL, *sig_buf = NULL, *client_data_buf = NULL;
|
||||
size_t srr_len = 0, sig_len = 0, client_data_len = 0;
|
||||
EVP_MD_CTX md_ctx;
|
||||
EVP_MD_CTX_init(&md_ctx);
|
||||
CBB_zero(&srr);
|
||||
if (!CBB_init(&response, 0)) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
CBS client_data;
|
||||
uint64_t redemption_time;
|
||||
if (!CBS_get_u16_length_prefixed(&request_cbs, &client_data) ||
|
||||
!CBS_get_u64(&request_cbs, &redemption_time)) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_DECODE_ERROR);
|
||||
goto err;
|
||||
}
|
||||
|
||||
const uint8_t kTokenHashDSTLabel[] = "TrustTokenV0 TokenHash";
|
||||
uint8_t token_hash[SHA256_DIGEST_LENGTH];
|
||||
SHA256_CTX sha_ctx;
|
||||
SHA256_Init(&sha_ctx);
|
||||
SHA256_Update(&sha_ctx, kTokenHashDSTLabel, sizeof(kTokenHashDSTLabel));
|
||||
SHA256_Update(&sha_ctx, CBS_data(&token_copy), CBS_len(&token_copy));
|
||||
SHA256_Final(token_hash, &sha_ctx);
|
||||
|
||||
uint8_t metadata_obfuscator;
|
||||
if (ctx->method->use_token_hash) {
|
||||
metadata_obfuscator =
|
||||
get_metadata_obfuscator(ctx->metadata_key, ctx->metadata_key_len,
|
||||
token_hash, sizeof(token_hash));
|
||||
} else {
|
||||
metadata_obfuscator =
|
||||
get_metadata_obfuscator(ctx->metadata_key, ctx->metadata_key_len,
|
||||
CBS_data(&client_data), CBS_len(&client_data));
|
||||
}
|
||||
|
||||
// The SRR is constructed as per the format described in
|
||||
// https://docs.google.com/document/d/1TNnya6B8pyomDK2F1R9CL3dY10OAmqWlnCxsWyOBDVQ/edit#heading=h.7mkzvhpqb8l5
|
||||
|
||||
static const char kClientDataLabel[] = "client-data";
|
||||
static const char kExpiryTimestampLabel[] = "expiry-timestamp";
|
||||
static const char kMetadataLabel[] = "metadata";
|
||||
static const char kPrivateLabel[] = "private";
|
||||
static const char kPublicLabel[] = "public";
|
||||
static const char kTokenHashLabel[] = "token-hash";
|
||||
|
||||
// CBOR requires map keys to be sorted by length then sorted lexically.
|
||||
// https://tools.ietf.org/html/rfc7049#section-3.9
|
||||
assert(strlen(kMetadataLabel) < strlen(kTokenHashLabel));
|
||||
assert(strlen(kTokenHashLabel) < strlen(kClientDataLabel));
|
||||
assert(strlen(kClientDataLabel) < strlen(kExpiryTimestampLabel));
|
||||
assert(strlen(kPublicLabel) < strlen(kPrivateLabel));
|
||||
|
||||
size_t map_entries = 3;
|
||||
if (ctx->method->use_token_hash) {
|
||||
map_entries = 4;
|
||||
}
|
||||
|
||||
if (!CBB_init(&srr, 0) ||
|
||||
!add_cbor_map(&srr, map_entries) || // SRR map
|
||||
!add_cbor_text(&srr, kMetadataLabel, strlen(kMetadataLabel)) ||
|
||||
!add_cbor_map(&srr, 2) || // Metadata map
|
||||
!add_cbor_text(&srr, kPublicLabel, strlen(kPublicLabel)) ||
|
||||
!add_cbor_int(&srr, public_metadata) ||
|
||||
!add_cbor_text(&srr, kPrivateLabel, strlen(kPrivateLabel)) ||
|
||||
!add_cbor_int(&srr, private_metadata ^ metadata_obfuscator)) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (ctx->method->use_token_hash) {
|
||||
if (!add_cbor_text(&srr, kTokenHashLabel, strlen(kTokenHashLabel)) ||
|
||||
!add_cbor_bytes(&srr, token_hash, sizeof(token_hash))) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
if (!add_cbor_text(&srr, kClientDataLabel, strlen(kClientDataLabel)) ||
|
||||
!CBB_add_bytes(&srr, CBS_data(&client_data), CBS_len(&client_data)) ||
|
||||
!add_cbor_text(&srr, kExpiryTimestampLabel,
|
||||
strlen(kExpiryTimestampLabel)) ||
|
||||
!add_cbor_int(&srr, redemption_time + lifetime) ||
|
||||
!CBB_finish(&srr, &srr_buf, &srr_len)) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!EVP_DigestSignInit(&md_ctx, NULL, NULL, NULL, ctx->srr_key) ||
|
||||
!EVP_DigestSign(&md_ctx, NULL, &sig_len, srr_buf, srr_len)) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_SRR_SIGNATURE_ERROR);
|
||||
goto err;
|
||||
}
|
||||
|
||||
CBB child;
|
||||
uint8_t *ptr;
|
||||
if (!CBB_add_u16_length_prefixed(&response, &child) ||
|
||||
!CBB_add_bytes(&child, srr_buf, srr_len) ||
|
||||
!CBB_add_u16_length_prefixed(&response, &child) ||
|
||||
!CBB_reserve(&child, &ptr, sig_len) ||
|
||||
!EVP_DigestSign(&md_ctx, ptr, &sig_len, srr_buf, srr_len) ||
|
||||
!CBB_did_write(&child, sig_len)) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!CBS_stow(&client_data, &client_data_buf, &client_data_len) ||
|
||||
!CBB_finish(&response, out, out_len)) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
TRUST_TOKEN *token = TRUST_TOKEN_new(nonce, PMBTOKEN_NONCE_SIZE);
|
||||
if (token == NULL) {
|
||||
OPENSSL_PUT_ERROR(TRUST_TOKEN, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
*out_token = token;
|
||||
*out_client_data = client_data_buf;
|
||||
*out_client_data_len = client_data_len;
|
||||
*out_redemption_time = redemption_time;
|
||||
|
||||
ok = 1;
|
||||
|
||||
err:
|
||||
CBB_cleanup(&response);
|
||||
CBB_cleanup(&srr);
|
||||
OPENSSL_free(srr_buf);
|
||||
OPENSSL_free(sig_buf);
|
||||
EVP_MD_CTX_cleanup(&md_ctx);
|
||||
if (!ok) {
|
||||
OPENSSL_free(client_data_buf);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
int TRUST_TOKEN_decode_private_metadata(const TRUST_TOKEN_METHOD *method,
|
||||
uint8_t *out_value, const uint8_t *key,
|
||||
size_t key_len, const uint8_t *nonce,
|
||||
size_t nonce_len,
|
||||
uint8_t encrypted_bit) {
|
||||
uint8_t metadata_obfuscator =
|
||||
get_metadata_obfuscator(key, key_len, nonce, nonce_len);
|
||||
*out_value = encrypted_bit ^ metadata_obfuscator;
|
||||
return 1;
|
||||
}
|
||||
@@ -2148,6 +2148,11 @@ STACK_OF(X509) *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx)
|
||||
return ctx->chain;
|
||||
}
|
||||
|
||||
STACK_OF(X509) *X509_STORE_CTX_get0_chain(X509_STORE_CTX *ctx)
|
||||
{
|
||||
return ctx->chain;
|
||||
}
|
||||
|
||||
STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx)
|
||||
{
|
||||
if (!ctx->chain)
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
This directory is derived from BoringSSL cloned from https://boringssl.googlesource.com/boringssl at revision 5298ef99bf2b2d77600b3bb74dd572027bf495be
|
||||
This directory is derived from BoringSSL cloned from https://boringssl.googlesource.com/boringssl at revision 53a17f55247101105ae35767d5c5a6c311843a8e
|
||||
@@ -427,6 +427,10 @@ typedef struct ssl_session_st SSL_SESSION;
|
||||
typedef struct ssl_st SSL;
|
||||
typedef struct ssl_ticket_aead_method_st SSL_TICKET_AEAD_METHOD;
|
||||
typedef struct st_ERR_FNS ERR_FNS;
|
||||
typedef struct trust_token_st TRUST_TOKEN;
|
||||
typedef struct trust_token_client_st TRUST_TOKEN_CLIENT;
|
||||
typedef struct trust_token_issuer_st TRUST_TOKEN_ISSUER;
|
||||
typedef struct trust_token_method_st TRUST_TOKEN_METHOD;
|
||||
typedef struct v3_ext_ctx X509V3_CTX;
|
||||
typedef struct x509_attributes_st X509_ATTRIBUTE;
|
||||
typedef struct x509_cert_aux_st X509_CERT_AUX;
|
||||
|
||||
@@ -306,6 +306,7 @@
|
||||
#define BIO_write_filename BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, BIO_write_filename)
|
||||
#define BN_BLINDING_convert BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, BN_BLINDING_convert)
|
||||
#define BN_BLINDING_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, BN_BLINDING_free)
|
||||
#define BN_BLINDING_invalidate BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, BN_BLINDING_invalidate)
|
||||
#define BN_BLINDING_invert BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, BN_BLINDING_invert)
|
||||
#define BN_BLINDING_new BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, BN_BLINDING_new)
|
||||
#define BN_CTX_end BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, BN_CTX_end)
|
||||
@@ -569,6 +570,7 @@
|
||||
#define CRYPTO_cleanup_all_ex_data BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_cleanup_all_ex_data)
|
||||
#define CRYPTO_ctr128_encrypt BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_ctr128_encrypt)
|
||||
#define CRYPTO_ctr128_encrypt_ctr32 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_ctr128_encrypt_ctr32)
|
||||
#define CRYPTO_fork_detect_ignore_madv_wipeonfork_for_testing BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_fork_detect_ignore_madv_wipeonfork_for_testing)
|
||||
#define CRYPTO_free_ex_data BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_free_ex_data)
|
||||
#define CRYPTO_gcm128_aad BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_gcm128_aad)
|
||||
#define CRYPTO_gcm128_decrypt BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_gcm128_decrypt)
|
||||
@@ -584,12 +586,14 @@
|
||||
#define CRYPTO_get_dynlock_lock_callback BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_get_dynlock_lock_callback)
|
||||
#define CRYPTO_get_ex_data BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_get_ex_data)
|
||||
#define CRYPTO_get_ex_new_index BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_get_ex_new_index)
|
||||
#define CRYPTO_get_fork_generation BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_get_fork_generation)
|
||||
#define CRYPTO_get_lock_name BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_get_lock_name)
|
||||
#define CRYPTO_get_locking_callback BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_get_locking_callback)
|
||||
#define CRYPTO_get_thread_local BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_get_thread_local)
|
||||
#define CRYPTO_ghash_init BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_ghash_init)
|
||||
#define CRYPTO_has_asm BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_has_asm)
|
||||
#define CRYPTO_hchacha20 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_hchacha20)
|
||||
#define CRYPTO_init_sysrand BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_init_sysrand)
|
||||
#define CRYPTO_is_ARMv8_AES_capable BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_is_ARMv8_AES_capable)
|
||||
#define CRYPTO_is_ARMv8_PMULL_capable BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_is_ARMv8_PMULL_capable)
|
||||
#define CRYPTO_is_NEON_capable_at_runtime BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_is_NEON_capable_at_runtime)
|
||||
@@ -604,6 +608,7 @@
|
||||
#define CRYPTO_poly1305_finish BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_poly1305_finish)
|
||||
#define CRYPTO_poly1305_init BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_poly1305_init)
|
||||
#define CRYPTO_poly1305_update BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_poly1305_update)
|
||||
#define CRYPTO_pre_sandbox_init BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_pre_sandbox_init)
|
||||
#define CRYPTO_rdrand BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_rdrand)
|
||||
#define CRYPTO_rdrand_multiple8_buf BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_rdrand_multiple8_buf)
|
||||
#define CRYPTO_refcount_dec_and_test_zero BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_refcount_dec_and_test_zero)
|
||||
@@ -617,6 +622,7 @@
|
||||
#define CRYPTO_set_locking_callback BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_set_locking_callback)
|
||||
#define CRYPTO_set_thread_local BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_set_thread_local)
|
||||
#define CRYPTO_sysrand BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_sysrand)
|
||||
#define CRYPTO_sysrand_if_available BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_sysrand_if_available)
|
||||
#define CRYPTO_tls1_prf BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_tls1_prf)
|
||||
#define CTR_DRBG_clear BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CTR_DRBG_clear)
|
||||
#define CTR_DRBG_generate BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CTR_DRBG_generate)
|
||||
@@ -639,8 +645,13 @@
|
||||
#define DH_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_free)
|
||||
#define DH_generate_key BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_generate_key)
|
||||
#define DH_generate_parameters_ex BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_generate_parameters_ex)
|
||||
#define DH_get0_g BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_get0_g)
|
||||
#define DH_get0_key BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_get0_key)
|
||||
#define DH_get0_p BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_get0_p)
|
||||
#define DH_get0_pqg BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_get0_pqg)
|
||||
#define DH_get0_priv_key BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_get0_priv_key)
|
||||
#define DH_get0_pub_key BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_get0_pub_key)
|
||||
#define DH_get0_q BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_get0_q)
|
||||
#define DH_get_ex_data BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_get_ex_data)
|
||||
#define DH_get_ex_new_index BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_get_ex_new_index)
|
||||
#define DH_marshal_parameters BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_marshal_parameters)
|
||||
@@ -650,6 +661,7 @@
|
||||
#define DH_set0_key BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_set0_key)
|
||||
#define DH_set0_pqg BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_set0_pqg)
|
||||
#define DH_set_ex_data BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_set_ex_data)
|
||||
#define DH_set_length BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_set_length)
|
||||
#define DH_size BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_size)
|
||||
#define DH_up_ref BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_up_ref)
|
||||
#define DHparams_dup BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DHparams_dup)
|
||||
@@ -678,8 +690,13 @@
|
||||
#define DSA_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DSA_free)
|
||||
#define DSA_generate_key BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DSA_generate_key)
|
||||
#define DSA_generate_parameters_ex BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DSA_generate_parameters_ex)
|
||||
#define DSA_get0_g BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DSA_get0_g)
|
||||
#define DSA_get0_key BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DSA_get0_key)
|
||||
#define DSA_get0_p BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DSA_get0_p)
|
||||
#define DSA_get0_pqg BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DSA_get0_pqg)
|
||||
#define DSA_get0_priv_key BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DSA_get0_priv_key)
|
||||
#define DSA_get0_pub_key BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DSA_get0_pub_key)
|
||||
#define DSA_get0_q BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DSA_get0_q)
|
||||
#define DSA_get_ex_data BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DSA_get_ex_data)
|
||||
#define DSA_get_ex_new_index BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DSA_get_ex_new_index)
|
||||
#define DSA_marshal_parameters BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DSA_marshal_parameters)
|
||||
@@ -1108,6 +1125,7 @@
|
||||
#define EVP_sha256 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_sha256)
|
||||
#define EVP_sha384 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_sha384)
|
||||
#define EVP_sha512 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_sha512)
|
||||
#define EVP_sha512_256 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_sha512_256)
|
||||
#define EVP_tls_cbc_copy_mac BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_tls_cbc_copy_mac)
|
||||
#define EVP_tls_cbc_digest_record BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_tls_cbc_digest_record)
|
||||
#define EVP_tls_cbc_record_digest_supported BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_tls_cbc_record_digest_supported)
|
||||
@@ -1386,6 +1404,7 @@
|
||||
#define PKEY_USAGE_PERIOD_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, PKEY_USAGE_PERIOD_free)
|
||||
#define PKEY_USAGE_PERIOD_it BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, PKEY_USAGE_PERIOD_it)
|
||||
#define PKEY_USAGE_PERIOD_new BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, PKEY_USAGE_PERIOD_new)
|
||||
#define PMBTOKEN_PRETOKEN_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, PMBTOKEN_PRETOKEN_free)
|
||||
#define POLICYINFO_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, POLICYINFO_free)
|
||||
#define POLICYINFO_it BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, POLICYINFO_it)
|
||||
#define POLICYINFO_new BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, POLICYINFO_new)
|
||||
@@ -1419,7 +1438,6 @@
|
||||
#define RAND_pseudo_bytes BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, RAND_pseudo_bytes)
|
||||
#define RAND_seed BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, RAND_seed)
|
||||
#define RAND_set_rand_method BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, RAND_set_rand_method)
|
||||
#define RAND_set_urandom_fd BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, RAND_set_urandom_fd)
|
||||
#define RAND_status BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, RAND_status)
|
||||
#define RC4 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, RC4)
|
||||
#define RC4_set_key BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, RC4_set_key)
|
||||
@@ -1512,6 +1530,10 @@
|
||||
#define SHA384_Init BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, SHA384_Init)
|
||||
#define SHA384_Update BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, SHA384_Update)
|
||||
#define SHA512 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, SHA512)
|
||||
#define SHA512_256 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, SHA512_256)
|
||||
#define SHA512_256_Final BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, SHA512_256_Final)
|
||||
#define SHA512_256_Init BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, SHA512_256_Init)
|
||||
#define SHA512_256_Update BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, SHA512_256_Update)
|
||||
#define SHA512_Final BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, SHA512_Final)
|
||||
#define SHA512_Init BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, SHA512_Init)
|
||||
#define SHA512_Transform BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, SHA512_Transform)
|
||||
@@ -1535,7 +1557,27 @@
|
||||
#define SXNET_get_id_ulong BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, SXNET_get_id_ulong)
|
||||
#define SXNET_it BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, SXNET_it)
|
||||
#define SXNET_new BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, SXNET_new)
|
||||
#define TRUST_TOKEN_CLIENT_add_key BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, TRUST_TOKEN_CLIENT_add_key)
|
||||
#define TRUST_TOKEN_CLIENT_begin_issuance BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, TRUST_TOKEN_CLIENT_begin_issuance)
|
||||
#define TRUST_TOKEN_CLIENT_begin_redemption BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, TRUST_TOKEN_CLIENT_begin_redemption)
|
||||
#define TRUST_TOKEN_CLIENT_finish_issuance BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, TRUST_TOKEN_CLIENT_finish_issuance)
|
||||
#define TRUST_TOKEN_CLIENT_finish_redemption BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, TRUST_TOKEN_CLIENT_finish_redemption)
|
||||
#define TRUST_TOKEN_CLIENT_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, TRUST_TOKEN_CLIENT_free)
|
||||
#define TRUST_TOKEN_CLIENT_new BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, TRUST_TOKEN_CLIENT_new)
|
||||
#define TRUST_TOKEN_CLIENT_set_srr_key BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, TRUST_TOKEN_CLIENT_set_srr_key)
|
||||
#define TRUST_TOKEN_ISSUER_add_key BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, TRUST_TOKEN_ISSUER_add_key)
|
||||
#define TRUST_TOKEN_ISSUER_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, TRUST_TOKEN_ISSUER_free)
|
||||
#define TRUST_TOKEN_ISSUER_issue BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, TRUST_TOKEN_ISSUER_issue)
|
||||
#define TRUST_TOKEN_ISSUER_new BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, TRUST_TOKEN_ISSUER_new)
|
||||
#define TRUST_TOKEN_ISSUER_redeem BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, TRUST_TOKEN_ISSUER_redeem)
|
||||
#define TRUST_TOKEN_ISSUER_set_metadata_key BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, TRUST_TOKEN_ISSUER_set_metadata_key)
|
||||
#define TRUST_TOKEN_ISSUER_set_srr_key BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, TRUST_TOKEN_ISSUER_set_srr_key)
|
||||
#define TRUST_TOKEN_decode_private_metadata BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, TRUST_TOKEN_decode_private_metadata)
|
||||
#define TRUST_TOKEN_experiment_v0 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, TRUST_TOKEN_experiment_v0)
|
||||
#define TRUST_TOKEN_experiment_v1 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, TRUST_TOKEN_experiment_v1)
|
||||
#define TRUST_TOKEN_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, TRUST_TOKEN_free)
|
||||
#define TRUST_TOKEN_generate_key BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, TRUST_TOKEN_generate_key)
|
||||
#define TRUST_TOKEN_new BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, TRUST_TOKEN_new)
|
||||
#define USERNOTICE_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, USERNOTICE_free)
|
||||
#define USERNOTICE_it BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, USERNOTICE_it)
|
||||
#define USERNOTICE_new BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, USERNOTICE_new)
|
||||
@@ -1811,6 +1853,7 @@
|
||||
#define X509_STORE_CTX_cleanup BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_STORE_CTX_cleanup)
|
||||
#define X509_STORE_CTX_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_STORE_CTX_free)
|
||||
#define X509_STORE_CTX_get0_cert BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_STORE_CTX_get0_cert)
|
||||
#define X509_STORE_CTX_get0_chain BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_STORE_CTX_get0_chain)
|
||||
#define X509_STORE_CTX_get0_current_crl BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_STORE_CTX_get0_current_crl)
|
||||
#define X509_STORE_CTX_get0_current_issuer BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_STORE_CTX_get0_current_issuer)
|
||||
#define X509_STORE_CTX_get0_param BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_STORE_CTX_get0_param)
|
||||
@@ -2142,9 +2185,9 @@
|
||||
#define bn_mod_add_words BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mod_add_words)
|
||||
#define bn_mod_exp_base_2_consttime BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mod_exp_base_2_consttime)
|
||||
#define bn_mod_exp_mont_small BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mod_exp_mont_small)
|
||||
#define bn_mod_inverse0_prime_mont_small BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mod_inverse0_prime_mont_small)
|
||||
#define bn_mod_inverse_consttime BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mod_inverse_consttime)
|
||||
#define bn_mod_inverse_prime BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mod_inverse_prime)
|
||||
#define bn_mod_inverse_prime_mont_small BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mod_inverse_prime_mont_small)
|
||||
#define bn_mod_inverse_secret_prime BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mod_inverse_secret_prime)
|
||||
#define bn_mod_lshift1_consttime BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mod_lshift1_consttime)
|
||||
#define bn_mod_lshift_consttime BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mod_lshift_consttime)
|
||||
@@ -2329,20 +2372,24 @@
|
||||
#define d2i_X509_fp BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, d2i_X509_fp)
|
||||
#define dsa_asn1_meth BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, dsa_asn1_meth)
|
||||
#define ec_GFp_mont_add BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_mont_add)
|
||||
#define ec_GFp_mont_bignum_to_felem BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_mont_bignum_to_felem)
|
||||
#define ec_GFp_mont_dbl BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_mont_dbl)
|
||||
#define ec_GFp_mont_felem_from_bytes BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_mont_felem_from_bytes)
|
||||
#define ec_GFp_mont_felem_mul BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_mont_felem_mul)
|
||||
#define ec_GFp_mont_felem_sqr BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_mont_felem_sqr)
|
||||
#define ec_GFp_mont_felem_to_bignum BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_mont_felem_to_bignum)
|
||||
#define ec_GFp_mont_felem_to_bytes BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_mont_felem_to_bytes)
|
||||
#define ec_GFp_mont_group_finish BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_mont_group_finish)
|
||||
#define ec_GFp_mont_group_init BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_mont_group_init)
|
||||
#define ec_GFp_mont_group_set_curve BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_mont_group_set_curve)
|
||||
#define ec_GFp_mont_init_precomp BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_mont_init_precomp)
|
||||
#define ec_GFp_mont_mul BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_mont_mul)
|
||||
#define ec_GFp_mont_mul_base BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_mont_mul_base)
|
||||
#define ec_GFp_mont_mul_public BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_mont_mul_public)
|
||||
#define ec_GFp_mont_mul_batch BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_mont_mul_batch)
|
||||
#define ec_GFp_mont_mul_precomp BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_mont_mul_precomp)
|
||||
#define ec_GFp_mont_mul_public_batch BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_mont_mul_public_batch)
|
||||
#define ec_GFp_nistp_recode_scalar_bits BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_nistp_recode_scalar_bits)
|
||||
#define ec_GFp_simple_cmp BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_simple_cmp)
|
||||
#define ec_GFp_simple_cmp_x_coordinate BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_simple_cmp_x_coordinate)
|
||||
#define ec_GFp_simple_felem_from_bytes BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_simple_felem_from_bytes)
|
||||
#define ec_GFp_simple_felem_to_bytes BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_simple_felem_to_bytes)
|
||||
#define ec_GFp_simple_group_finish BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_simple_group_finish)
|
||||
#define ec_GFp_simple_group_get_curve BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_simple_group_get_curve)
|
||||
#define ec_GFp_simple_group_init BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_simple_group_init)
|
||||
@@ -2350,11 +2397,13 @@
|
||||
#define ec_GFp_simple_invert BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_simple_invert)
|
||||
#define ec_GFp_simple_is_at_infinity BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_simple_is_at_infinity)
|
||||
#define ec_GFp_simple_is_on_curve BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_simple_is_on_curve)
|
||||
#define ec_GFp_simple_mont_inv_mod_ord_vartime BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_simple_mont_inv_mod_ord_vartime)
|
||||
#define ec_GFp_simple_point_copy BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_simple_point_copy)
|
||||
#define ec_GFp_simple_point_init BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_simple_point_init)
|
||||
#define ec_GFp_simple_point_set_affine_coordinates BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_simple_point_set_affine_coordinates)
|
||||
#define ec_GFp_simple_point_set_to_infinity BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_simple_point_set_to_infinity)
|
||||
#define ec_GFp_simple_points_equal BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_simple_points_equal)
|
||||
#define ec_affine_jacobian_equal BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_affine_jacobian_equal)
|
||||
#define ec_affine_select BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_affine_select)
|
||||
#define ec_affine_to_jacobian BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_affine_to_jacobian)
|
||||
#define ec_asn1_meth BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_asn1_meth)
|
||||
#define ec_bignum_to_felem BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_bignum_to_felem)
|
||||
#define ec_bignum_to_scalar BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_bignum_to_scalar)
|
||||
@@ -2362,30 +2411,53 @@
|
||||
#define ec_compute_wNAF BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_compute_wNAF)
|
||||
#define ec_felem_add BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_felem_add)
|
||||
#define ec_felem_equal BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_felem_equal)
|
||||
#define ec_felem_from_bytes BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_felem_from_bytes)
|
||||
#define ec_felem_neg BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_felem_neg)
|
||||
#define ec_felem_non_zero_mask BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_felem_non_zero_mask)
|
||||
#define ec_felem_select BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_felem_select)
|
||||
#define ec_felem_sub BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_felem_sub)
|
||||
#define ec_felem_to_bignum BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_felem_to_bignum)
|
||||
#define ec_felem_to_bytes BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_felem_to_bytes)
|
||||
#define ec_get_x_coordinate_as_bytes BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_get_x_coordinate_as_bytes)
|
||||
#define ec_get_x_coordinate_as_scalar BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_get_x_coordinate_as_scalar)
|
||||
#define ec_group_new BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_group_new)
|
||||
#define ec_hash_to_curve_p384_xmd_sha512_sswu_draft07 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_hash_to_curve_p384_xmd_sha512_sswu_draft07)
|
||||
#define ec_hash_to_curve_p521_xmd_sha512_sswu_draft06 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_hash_to_curve_p521_xmd_sha512_sswu_draft06)
|
||||
#define ec_hash_to_scalar_p384_xmd_sha512_draft07 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_hash_to_scalar_p384_xmd_sha512_draft07)
|
||||
#define ec_hash_to_scalar_p521_xmd_sha512_draft06 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_hash_to_scalar_p521_xmd_sha512_draft06)
|
||||
#define ec_init_precomp BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_init_precomp)
|
||||
#define ec_jacobian_to_affine BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_jacobian_to_affine)
|
||||
#define ec_jacobian_to_affine_batch BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_jacobian_to_affine_batch)
|
||||
#define ec_pkey_meth BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_pkey_meth)
|
||||
#define ec_point_get_affine_coordinate_bytes BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_point_get_affine_coordinate_bytes)
|
||||
#define ec_point_from_uncompressed BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_point_from_uncompressed)
|
||||
#define ec_point_mul_scalar BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_point_mul_scalar)
|
||||
#define ec_point_mul_scalar_base BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_point_mul_scalar_base)
|
||||
#define ec_point_mul_scalar_batch BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_point_mul_scalar_batch)
|
||||
#define ec_point_mul_scalar_precomp BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_point_mul_scalar_precomp)
|
||||
#define ec_point_mul_scalar_public BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_point_mul_scalar_public)
|
||||
#define ec_point_mul_scalar_public_batch BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_point_mul_scalar_public_batch)
|
||||
#define ec_point_select BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_point_select)
|
||||
#define ec_point_set_affine_coordinates BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_point_set_affine_coordinates)
|
||||
#define ec_point_to_bytes BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_point_to_bytes)
|
||||
#define ec_precomp_select BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_precomp_select)
|
||||
#define ec_random_nonzero_scalar BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_random_nonzero_scalar)
|
||||
#define ec_scalar_add BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_scalar_add)
|
||||
#define ec_scalar_equal_vartime BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_scalar_equal_vartime)
|
||||
#define ec_scalar_from_bytes BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_scalar_from_bytes)
|
||||
#define ec_scalar_from_montgomery BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_scalar_from_montgomery)
|
||||
#define ec_scalar_inv_montgomery BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_scalar_inv_montgomery)
|
||||
#define ec_scalar_inv_montgomery_vartime BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_scalar_inv_montgomery_vartime)
|
||||
#define ec_scalar_inv0_montgomery BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_scalar_inv0_montgomery)
|
||||
#define ec_scalar_is_zero BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_scalar_is_zero)
|
||||
#define ec_scalar_mul_montgomery BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_scalar_mul_montgomery)
|
||||
#define ec_scalar_neg BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_scalar_neg)
|
||||
#define ec_scalar_reduce BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_scalar_reduce)
|
||||
#define ec_scalar_select BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_scalar_select)
|
||||
#define ec_scalar_sub BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_scalar_sub)
|
||||
#define ec_scalar_to_bytes BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_scalar_to_bytes)
|
||||
#define ec_scalar_to_montgomery BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_scalar_to_montgomery)
|
||||
#define ec_simple_scalar_inv_montgomery BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_simple_scalar_inv_montgomery)
|
||||
#define ec_scalar_to_montgomery_inv_vartime BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_scalar_to_montgomery_inv_vartime)
|
||||
#define ec_set_to_safe_point BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_set_to_safe_point)
|
||||
#define ec_simple_scalar_inv0_montgomery BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_simple_scalar_inv0_montgomery)
|
||||
#define ec_simple_scalar_to_montgomery_inv_vartime BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_simple_scalar_to_montgomery_inv_vartime)
|
||||
#define ecp_nistz256_avx2_select_w7 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ecp_nistz256_avx2_select_w7)
|
||||
#define ecp_nistz256_mul_mont BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ecp_nistz256_mul_mont)
|
||||
#define ecp_nistz256_neg BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ecp_nistz256_neg)
|
||||
@@ -2587,6 +2659,21 @@
|
||||
#define pkcs7_bundle BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, pkcs7_bundle)
|
||||
#define pkcs7_parse_header BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, pkcs7_parse_header)
|
||||
#define pkcs8_pbe_decrypt BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, pkcs8_pbe_decrypt)
|
||||
#define pmbtoken_exp0_blind BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, pmbtoken_exp0_blind)
|
||||
#define pmbtoken_exp0_client_key_from_bytes BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, pmbtoken_exp0_client_key_from_bytes)
|
||||
#define pmbtoken_exp0_generate_key BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, pmbtoken_exp0_generate_key)
|
||||
#define pmbtoken_exp0_issuer_key_from_bytes BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, pmbtoken_exp0_issuer_key_from_bytes)
|
||||
#define pmbtoken_exp0_read BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, pmbtoken_exp0_read)
|
||||
#define pmbtoken_exp0_sign BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, pmbtoken_exp0_sign)
|
||||
#define pmbtoken_exp0_unblind BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, pmbtoken_exp0_unblind)
|
||||
#define pmbtoken_exp1_blind BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, pmbtoken_exp1_blind)
|
||||
#define pmbtoken_exp1_client_key_from_bytes BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, pmbtoken_exp1_client_key_from_bytes)
|
||||
#define pmbtoken_exp1_generate_key BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, pmbtoken_exp1_generate_key)
|
||||
#define pmbtoken_exp1_get_h_for_testing BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, pmbtoken_exp1_get_h_for_testing)
|
||||
#define pmbtoken_exp1_issuer_key_from_bytes BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, pmbtoken_exp1_issuer_key_from_bytes)
|
||||
#define pmbtoken_exp1_read BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, pmbtoken_exp1_read)
|
||||
#define pmbtoken_exp1_sign BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, pmbtoken_exp1_sign)
|
||||
#define pmbtoken_exp1_unblind BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, pmbtoken_exp1_unblind)
|
||||
#define policy_cache_find_data BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, policy_cache_find_data)
|
||||
#define policy_cache_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, policy_cache_free)
|
||||
#define policy_cache_set BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, policy_cache_set)
|
||||
@@ -2719,6 +2806,29 @@
|
||||
#define sk_ASN1_STRING_TABLE_is_sorted BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_ASN1_STRING_TABLE_is_sorted)
|
||||
#define sk_ASN1_STRING_TABLE_set_cmp_func BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_ASN1_STRING_TABLE_set_cmp_func)
|
||||
#define sk_ASN1_STRING_TABLE_deep_copy BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_ASN1_STRING_TABLE_deep_copy)
|
||||
#define sk_PMBTOKEN_PRETOKEN_call_free_func BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_PMBTOKEN_PRETOKEN_call_free_func)
|
||||
#define sk_PMBTOKEN_PRETOKEN_call_copy_func BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_PMBTOKEN_PRETOKEN_call_copy_func)
|
||||
#define sk_PMBTOKEN_PRETOKEN_call_cmp_func BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_PMBTOKEN_PRETOKEN_call_cmp_func)
|
||||
#define sk_PMBTOKEN_PRETOKEN_new BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_PMBTOKEN_PRETOKEN_new)
|
||||
#define sk_PMBTOKEN_PRETOKEN_new_null BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_PMBTOKEN_PRETOKEN_new_null)
|
||||
#define sk_PMBTOKEN_PRETOKEN_num BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_PMBTOKEN_PRETOKEN_num)
|
||||
#define sk_PMBTOKEN_PRETOKEN_zero BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_PMBTOKEN_PRETOKEN_zero)
|
||||
#define sk_PMBTOKEN_PRETOKEN_value BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_PMBTOKEN_PRETOKEN_value)
|
||||
#define sk_PMBTOKEN_PRETOKEN_set BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_PMBTOKEN_PRETOKEN_set)
|
||||
#define sk_PMBTOKEN_PRETOKEN_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_PMBTOKEN_PRETOKEN_free)
|
||||
#define sk_PMBTOKEN_PRETOKEN_pop_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_PMBTOKEN_PRETOKEN_pop_free)
|
||||
#define sk_PMBTOKEN_PRETOKEN_insert BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_PMBTOKEN_PRETOKEN_insert)
|
||||
#define sk_PMBTOKEN_PRETOKEN_delete BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_PMBTOKEN_PRETOKEN_delete)
|
||||
#define sk_PMBTOKEN_PRETOKEN_delete_ptr BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_PMBTOKEN_PRETOKEN_delete_ptr)
|
||||
#define sk_PMBTOKEN_PRETOKEN_find BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_PMBTOKEN_PRETOKEN_find)
|
||||
#define sk_PMBTOKEN_PRETOKEN_shift BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_PMBTOKEN_PRETOKEN_shift)
|
||||
#define sk_PMBTOKEN_PRETOKEN_push BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_PMBTOKEN_PRETOKEN_push)
|
||||
#define sk_PMBTOKEN_PRETOKEN_pop BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_PMBTOKEN_PRETOKEN_pop)
|
||||
#define sk_PMBTOKEN_PRETOKEN_dup BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_PMBTOKEN_PRETOKEN_dup)
|
||||
#define sk_PMBTOKEN_PRETOKEN_sort BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_PMBTOKEN_PRETOKEN_sort)
|
||||
#define sk_PMBTOKEN_PRETOKEN_is_sorted BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_PMBTOKEN_PRETOKEN_is_sorted)
|
||||
#define sk_PMBTOKEN_PRETOKEN_set_cmp_func BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_PMBTOKEN_PRETOKEN_set_cmp_func)
|
||||
#define sk_PMBTOKEN_PRETOKEN_deep_copy BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_PMBTOKEN_PRETOKEN_deep_copy)
|
||||
#define sk_CRYPTO_EX_DATA_FUNCS_call_free_func BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_CRYPTO_EX_DATA_FUNCS_call_free_func)
|
||||
#define sk_CRYPTO_EX_DATA_FUNCS_call_copy_func BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_CRYPTO_EX_DATA_FUNCS_call_copy_func)
|
||||
#define sk_CRYPTO_EX_DATA_FUNCS_call_cmp_func BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_CRYPTO_EX_DATA_FUNCS_call_cmp_func)
|
||||
@@ -3616,6 +3726,29 @@
|
||||
#define sk_OPENSSL_STRING_is_sorted BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_OPENSSL_STRING_is_sorted)
|
||||
#define sk_OPENSSL_STRING_set_cmp_func BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_OPENSSL_STRING_set_cmp_func)
|
||||
#define sk_OPENSSL_STRING_deep_copy BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_OPENSSL_STRING_deep_copy)
|
||||
#define sk_TRUST_TOKEN_call_free_func BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_TRUST_TOKEN_call_free_func)
|
||||
#define sk_TRUST_TOKEN_call_copy_func BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_TRUST_TOKEN_call_copy_func)
|
||||
#define sk_TRUST_TOKEN_call_cmp_func BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_TRUST_TOKEN_call_cmp_func)
|
||||
#define sk_TRUST_TOKEN_new BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_TRUST_TOKEN_new)
|
||||
#define sk_TRUST_TOKEN_new_null BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_TRUST_TOKEN_new_null)
|
||||
#define sk_TRUST_TOKEN_num BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_TRUST_TOKEN_num)
|
||||
#define sk_TRUST_TOKEN_zero BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_TRUST_TOKEN_zero)
|
||||
#define sk_TRUST_TOKEN_value BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_TRUST_TOKEN_value)
|
||||
#define sk_TRUST_TOKEN_set BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_TRUST_TOKEN_set)
|
||||
#define sk_TRUST_TOKEN_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_TRUST_TOKEN_free)
|
||||
#define sk_TRUST_TOKEN_pop_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_TRUST_TOKEN_pop_free)
|
||||
#define sk_TRUST_TOKEN_insert BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_TRUST_TOKEN_insert)
|
||||
#define sk_TRUST_TOKEN_delete BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_TRUST_TOKEN_delete)
|
||||
#define sk_TRUST_TOKEN_delete_ptr BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_TRUST_TOKEN_delete_ptr)
|
||||
#define sk_TRUST_TOKEN_find BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_TRUST_TOKEN_find)
|
||||
#define sk_TRUST_TOKEN_shift BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_TRUST_TOKEN_shift)
|
||||
#define sk_TRUST_TOKEN_push BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_TRUST_TOKEN_push)
|
||||
#define sk_TRUST_TOKEN_pop BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_TRUST_TOKEN_pop)
|
||||
#define sk_TRUST_TOKEN_dup BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_TRUST_TOKEN_dup)
|
||||
#define sk_TRUST_TOKEN_sort BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_TRUST_TOKEN_sort)
|
||||
#define sk_TRUST_TOKEN_is_sorted BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_TRUST_TOKEN_is_sorted)
|
||||
#define sk_TRUST_TOKEN_set_cmp_func BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_TRUST_TOKEN_set_cmp_func)
|
||||
#define sk_TRUST_TOKEN_deep_copy BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_TRUST_TOKEN_deep_copy)
|
||||
#define sk_ASN1_VALUE_call_free_func BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_ASN1_VALUE_call_free_func)
|
||||
#define sk_ASN1_VALUE_call_copy_func BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_ASN1_VALUE_call_copy_func)
|
||||
#define sk_ASN1_VALUE_call_cmp_func BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_ASN1_VALUE_call_cmp_func)
|
||||
|
||||
@@ -311,6 +311,7 @@
|
||||
#define _BIO_write_filename BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, BIO_write_filename)
|
||||
#define _BN_BLINDING_convert BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, BN_BLINDING_convert)
|
||||
#define _BN_BLINDING_free BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, BN_BLINDING_free)
|
||||
#define _BN_BLINDING_invalidate BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, BN_BLINDING_invalidate)
|
||||
#define _BN_BLINDING_invert BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, BN_BLINDING_invert)
|
||||
#define _BN_BLINDING_new BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, BN_BLINDING_new)
|
||||
#define _BN_CTX_end BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, BN_CTX_end)
|
||||
@@ -574,6 +575,7 @@
|
||||
#define _CRYPTO_cleanup_all_ex_data BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_cleanup_all_ex_data)
|
||||
#define _CRYPTO_ctr128_encrypt BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_ctr128_encrypt)
|
||||
#define _CRYPTO_ctr128_encrypt_ctr32 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_ctr128_encrypt_ctr32)
|
||||
#define _CRYPTO_fork_detect_ignore_madv_wipeonfork_for_testing BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_fork_detect_ignore_madv_wipeonfork_for_testing)
|
||||
#define _CRYPTO_free_ex_data BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_free_ex_data)
|
||||
#define _CRYPTO_gcm128_aad BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_gcm128_aad)
|
||||
#define _CRYPTO_gcm128_decrypt BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_gcm128_decrypt)
|
||||
@@ -589,12 +591,14 @@
|
||||
#define _CRYPTO_get_dynlock_lock_callback BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_get_dynlock_lock_callback)
|
||||
#define _CRYPTO_get_ex_data BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_get_ex_data)
|
||||
#define _CRYPTO_get_ex_new_index BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_get_ex_new_index)
|
||||
#define _CRYPTO_get_fork_generation BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_get_fork_generation)
|
||||
#define _CRYPTO_get_lock_name BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_get_lock_name)
|
||||
#define _CRYPTO_get_locking_callback BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_get_locking_callback)
|
||||
#define _CRYPTO_get_thread_local BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_get_thread_local)
|
||||
#define _CRYPTO_ghash_init BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_ghash_init)
|
||||
#define _CRYPTO_has_asm BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_has_asm)
|
||||
#define _CRYPTO_hchacha20 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_hchacha20)
|
||||
#define _CRYPTO_init_sysrand BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_init_sysrand)
|
||||
#define _CRYPTO_is_ARMv8_AES_capable BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_is_ARMv8_AES_capable)
|
||||
#define _CRYPTO_is_ARMv8_PMULL_capable BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_is_ARMv8_PMULL_capable)
|
||||
#define _CRYPTO_is_NEON_capable_at_runtime BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_is_NEON_capable_at_runtime)
|
||||
@@ -609,6 +613,7 @@
|
||||
#define _CRYPTO_poly1305_finish BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_poly1305_finish)
|
||||
#define _CRYPTO_poly1305_init BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_poly1305_init)
|
||||
#define _CRYPTO_poly1305_update BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_poly1305_update)
|
||||
#define _CRYPTO_pre_sandbox_init BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_pre_sandbox_init)
|
||||
#define _CRYPTO_rdrand BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_rdrand)
|
||||
#define _CRYPTO_rdrand_multiple8_buf BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_rdrand_multiple8_buf)
|
||||
#define _CRYPTO_refcount_dec_and_test_zero BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_refcount_dec_and_test_zero)
|
||||
@@ -622,6 +627,7 @@
|
||||
#define _CRYPTO_set_locking_callback BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_set_locking_callback)
|
||||
#define _CRYPTO_set_thread_local BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_set_thread_local)
|
||||
#define _CRYPTO_sysrand BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_sysrand)
|
||||
#define _CRYPTO_sysrand_if_available BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_sysrand_if_available)
|
||||
#define _CRYPTO_tls1_prf BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_tls1_prf)
|
||||
#define _CTR_DRBG_clear BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CTR_DRBG_clear)
|
||||
#define _CTR_DRBG_generate BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CTR_DRBG_generate)
|
||||
@@ -644,8 +650,13 @@
|
||||
#define _DH_free BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_free)
|
||||
#define _DH_generate_key BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_generate_key)
|
||||
#define _DH_generate_parameters_ex BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_generate_parameters_ex)
|
||||
#define _DH_get0_g BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_get0_g)
|
||||
#define _DH_get0_key BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_get0_key)
|
||||
#define _DH_get0_p BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_get0_p)
|
||||
#define _DH_get0_pqg BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_get0_pqg)
|
||||
#define _DH_get0_priv_key BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_get0_priv_key)
|
||||
#define _DH_get0_pub_key BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_get0_pub_key)
|
||||
#define _DH_get0_q BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_get0_q)
|
||||
#define _DH_get_ex_data BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_get_ex_data)
|
||||
#define _DH_get_ex_new_index BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_get_ex_new_index)
|
||||
#define _DH_marshal_parameters BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_marshal_parameters)
|
||||
@@ -655,6 +666,7 @@
|
||||
#define _DH_set0_key BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_set0_key)
|
||||
#define _DH_set0_pqg BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_set0_pqg)
|
||||
#define _DH_set_ex_data BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_set_ex_data)
|
||||
#define _DH_set_length BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_set_length)
|
||||
#define _DH_size BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_size)
|
||||
#define _DH_up_ref BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_up_ref)
|
||||
#define _DHparams_dup BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DHparams_dup)
|
||||
@@ -683,8 +695,13 @@
|
||||
#define _DSA_free BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DSA_free)
|
||||
#define _DSA_generate_key BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DSA_generate_key)
|
||||
#define _DSA_generate_parameters_ex BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DSA_generate_parameters_ex)
|
||||
#define _DSA_get0_g BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DSA_get0_g)
|
||||
#define _DSA_get0_key BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DSA_get0_key)
|
||||
#define _DSA_get0_p BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DSA_get0_p)
|
||||
#define _DSA_get0_pqg BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DSA_get0_pqg)
|
||||
#define _DSA_get0_priv_key BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DSA_get0_priv_key)
|
||||
#define _DSA_get0_pub_key BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DSA_get0_pub_key)
|
||||
#define _DSA_get0_q BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DSA_get0_q)
|
||||
#define _DSA_get_ex_data BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DSA_get_ex_data)
|
||||
#define _DSA_get_ex_new_index BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DSA_get_ex_new_index)
|
||||
#define _DSA_marshal_parameters BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DSA_marshal_parameters)
|
||||
@@ -1113,6 +1130,7 @@
|
||||
#define _EVP_sha256 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_sha256)
|
||||
#define _EVP_sha384 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_sha384)
|
||||
#define _EVP_sha512 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_sha512)
|
||||
#define _EVP_sha512_256 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_sha512_256)
|
||||
#define _EVP_tls_cbc_copy_mac BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_tls_cbc_copy_mac)
|
||||
#define _EVP_tls_cbc_digest_record BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_tls_cbc_digest_record)
|
||||
#define _EVP_tls_cbc_record_digest_supported BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_tls_cbc_record_digest_supported)
|
||||
@@ -1391,6 +1409,7 @@
|
||||
#define _PKEY_USAGE_PERIOD_free BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, PKEY_USAGE_PERIOD_free)
|
||||
#define _PKEY_USAGE_PERIOD_it BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, PKEY_USAGE_PERIOD_it)
|
||||
#define _PKEY_USAGE_PERIOD_new BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, PKEY_USAGE_PERIOD_new)
|
||||
#define _PMBTOKEN_PRETOKEN_free BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, PMBTOKEN_PRETOKEN_free)
|
||||
#define _POLICYINFO_free BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, POLICYINFO_free)
|
||||
#define _POLICYINFO_it BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, POLICYINFO_it)
|
||||
#define _POLICYINFO_new BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, POLICYINFO_new)
|
||||
@@ -1424,7 +1443,6 @@
|
||||
#define _RAND_pseudo_bytes BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, RAND_pseudo_bytes)
|
||||
#define _RAND_seed BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, RAND_seed)
|
||||
#define _RAND_set_rand_method BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, RAND_set_rand_method)
|
||||
#define _RAND_set_urandom_fd BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, RAND_set_urandom_fd)
|
||||
#define _RAND_status BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, RAND_status)
|
||||
#define _RC4 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, RC4)
|
||||
#define _RC4_set_key BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, RC4_set_key)
|
||||
@@ -1517,6 +1535,10 @@
|
||||
#define _SHA384_Init BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, SHA384_Init)
|
||||
#define _SHA384_Update BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, SHA384_Update)
|
||||
#define _SHA512 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, SHA512)
|
||||
#define _SHA512_256 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, SHA512_256)
|
||||
#define _SHA512_256_Final BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, SHA512_256_Final)
|
||||
#define _SHA512_256_Init BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, SHA512_256_Init)
|
||||
#define _SHA512_256_Update BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, SHA512_256_Update)
|
||||
#define _SHA512_Final BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, SHA512_Final)
|
||||
#define _SHA512_Init BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, SHA512_Init)
|
||||
#define _SHA512_Transform BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, SHA512_Transform)
|
||||
@@ -1540,7 +1562,27 @@
|
||||
#define _SXNET_get_id_ulong BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, SXNET_get_id_ulong)
|
||||
#define _SXNET_it BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, SXNET_it)
|
||||
#define _SXNET_new BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, SXNET_new)
|
||||
#define _TRUST_TOKEN_CLIENT_add_key BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, TRUST_TOKEN_CLIENT_add_key)
|
||||
#define _TRUST_TOKEN_CLIENT_begin_issuance BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, TRUST_TOKEN_CLIENT_begin_issuance)
|
||||
#define _TRUST_TOKEN_CLIENT_begin_redemption BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, TRUST_TOKEN_CLIENT_begin_redemption)
|
||||
#define _TRUST_TOKEN_CLIENT_finish_issuance BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, TRUST_TOKEN_CLIENT_finish_issuance)
|
||||
#define _TRUST_TOKEN_CLIENT_finish_redemption BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, TRUST_TOKEN_CLIENT_finish_redemption)
|
||||
#define _TRUST_TOKEN_CLIENT_free BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, TRUST_TOKEN_CLIENT_free)
|
||||
#define _TRUST_TOKEN_CLIENT_new BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, TRUST_TOKEN_CLIENT_new)
|
||||
#define _TRUST_TOKEN_CLIENT_set_srr_key BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, TRUST_TOKEN_CLIENT_set_srr_key)
|
||||
#define _TRUST_TOKEN_ISSUER_add_key BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, TRUST_TOKEN_ISSUER_add_key)
|
||||
#define _TRUST_TOKEN_ISSUER_free BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, TRUST_TOKEN_ISSUER_free)
|
||||
#define _TRUST_TOKEN_ISSUER_issue BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, TRUST_TOKEN_ISSUER_issue)
|
||||
#define _TRUST_TOKEN_ISSUER_new BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, TRUST_TOKEN_ISSUER_new)
|
||||
#define _TRUST_TOKEN_ISSUER_redeem BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, TRUST_TOKEN_ISSUER_redeem)
|
||||
#define _TRUST_TOKEN_ISSUER_set_metadata_key BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, TRUST_TOKEN_ISSUER_set_metadata_key)
|
||||
#define _TRUST_TOKEN_ISSUER_set_srr_key BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, TRUST_TOKEN_ISSUER_set_srr_key)
|
||||
#define _TRUST_TOKEN_decode_private_metadata BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, TRUST_TOKEN_decode_private_metadata)
|
||||
#define _TRUST_TOKEN_experiment_v0 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, TRUST_TOKEN_experiment_v0)
|
||||
#define _TRUST_TOKEN_experiment_v1 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, TRUST_TOKEN_experiment_v1)
|
||||
#define _TRUST_TOKEN_free BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, TRUST_TOKEN_free)
|
||||
#define _TRUST_TOKEN_generate_key BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, TRUST_TOKEN_generate_key)
|
||||
#define _TRUST_TOKEN_new BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, TRUST_TOKEN_new)
|
||||
#define _USERNOTICE_free BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, USERNOTICE_free)
|
||||
#define _USERNOTICE_it BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, USERNOTICE_it)
|
||||
#define _USERNOTICE_new BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, USERNOTICE_new)
|
||||
@@ -1816,6 +1858,7 @@
|
||||
#define _X509_STORE_CTX_cleanup BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_STORE_CTX_cleanup)
|
||||
#define _X509_STORE_CTX_free BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_STORE_CTX_free)
|
||||
#define _X509_STORE_CTX_get0_cert BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_STORE_CTX_get0_cert)
|
||||
#define _X509_STORE_CTX_get0_chain BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_STORE_CTX_get0_chain)
|
||||
#define _X509_STORE_CTX_get0_current_crl BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_STORE_CTX_get0_current_crl)
|
||||
#define _X509_STORE_CTX_get0_current_issuer BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_STORE_CTX_get0_current_issuer)
|
||||
#define _X509_STORE_CTX_get0_param BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_STORE_CTX_get0_param)
|
||||
@@ -2147,9 +2190,9 @@
|
||||
#define _bn_mod_add_words BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mod_add_words)
|
||||
#define _bn_mod_exp_base_2_consttime BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mod_exp_base_2_consttime)
|
||||
#define _bn_mod_exp_mont_small BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mod_exp_mont_small)
|
||||
#define _bn_mod_inverse0_prime_mont_small BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mod_inverse0_prime_mont_small)
|
||||
#define _bn_mod_inverse_consttime BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mod_inverse_consttime)
|
||||
#define _bn_mod_inverse_prime BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mod_inverse_prime)
|
||||
#define _bn_mod_inverse_prime_mont_small BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mod_inverse_prime_mont_small)
|
||||
#define _bn_mod_inverse_secret_prime BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mod_inverse_secret_prime)
|
||||
#define _bn_mod_lshift1_consttime BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mod_lshift1_consttime)
|
||||
#define _bn_mod_lshift_consttime BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mod_lshift_consttime)
|
||||
@@ -2334,20 +2377,24 @@
|
||||
#define _d2i_X509_fp BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, d2i_X509_fp)
|
||||
#define _dsa_asn1_meth BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, dsa_asn1_meth)
|
||||
#define _ec_GFp_mont_add BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_mont_add)
|
||||
#define _ec_GFp_mont_bignum_to_felem BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_mont_bignum_to_felem)
|
||||
#define _ec_GFp_mont_dbl BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_mont_dbl)
|
||||
#define _ec_GFp_mont_felem_from_bytes BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_mont_felem_from_bytes)
|
||||
#define _ec_GFp_mont_felem_mul BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_mont_felem_mul)
|
||||
#define _ec_GFp_mont_felem_sqr BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_mont_felem_sqr)
|
||||
#define _ec_GFp_mont_felem_to_bignum BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_mont_felem_to_bignum)
|
||||
#define _ec_GFp_mont_felem_to_bytes BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_mont_felem_to_bytes)
|
||||
#define _ec_GFp_mont_group_finish BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_mont_group_finish)
|
||||
#define _ec_GFp_mont_group_init BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_mont_group_init)
|
||||
#define _ec_GFp_mont_group_set_curve BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_mont_group_set_curve)
|
||||
#define _ec_GFp_mont_init_precomp BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_mont_init_precomp)
|
||||
#define _ec_GFp_mont_mul BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_mont_mul)
|
||||
#define _ec_GFp_mont_mul_base BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_mont_mul_base)
|
||||
#define _ec_GFp_mont_mul_public BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_mont_mul_public)
|
||||
#define _ec_GFp_mont_mul_batch BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_mont_mul_batch)
|
||||
#define _ec_GFp_mont_mul_precomp BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_mont_mul_precomp)
|
||||
#define _ec_GFp_mont_mul_public_batch BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_mont_mul_public_batch)
|
||||
#define _ec_GFp_nistp_recode_scalar_bits BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_nistp_recode_scalar_bits)
|
||||
#define _ec_GFp_simple_cmp BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_simple_cmp)
|
||||
#define _ec_GFp_simple_cmp_x_coordinate BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_simple_cmp_x_coordinate)
|
||||
#define _ec_GFp_simple_felem_from_bytes BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_simple_felem_from_bytes)
|
||||
#define _ec_GFp_simple_felem_to_bytes BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_simple_felem_to_bytes)
|
||||
#define _ec_GFp_simple_group_finish BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_simple_group_finish)
|
||||
#define _ec_GFp_simple_group_get_curve BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_simple_group_get_curve)
|
||||
#define _ec_GFp_simple_group_init BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_simple_group_init)
|
||||
@@ -2355,11 +2402,13 @@
|
||||
#define _ec_GFp_simple_invert BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_simple_invert)
|
||||
#define _ec_GFp_simple_is_at_infinity BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_simple_is_at_infinity)
|
||||
#define _ec_GFp_simple_is_on_curve BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_simple_is_on_curve)
|
||||
#define _ec_GFp_simple_mont_inv_mod_ord_vartime BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_simple_mont_inv_mod_ord_vartime)
|
||||
#define _ec_GFp_simple_point_copy BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_simple_point_copy)
|
||||
#define _ec_GFp_simple_point_init BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_simple_point_init)
|
||||
#define _ec_GFp_simple_point_set_affine_coordinates BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_simple_point_set_affine_coordinates)
|
||||
#define _ec_GFp_simple_point_set_to_infinity BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_simple_point_set_to_infinity)
|
||||
#define _ec_GFp_simple_points_equal BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_simple_points_equal)
|
||||
#define _ec_affine_jacobian_equal BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_affine_jacobian_equal)
|
||||
#define _ec_affine_select BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_affine_select)
|
||||
#define _ec_affine_to_jacobian BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_affine_to_jacobian)
|
||||
#define _ec_asn1_meth BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_asn1_meth)
|
||||
#define _ec_bignum_to_felem BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_bignum_to_felem)
|
||||
#define _ec_bignum_to_scalar BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_bignum_to_scalar)
|
||||
@@ -2367,30 +2416,53 @@
|
||||
#define _ec_compute_wNAF BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_compute_wNAF)
|
||||
#define _ec_felem_add BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_felem_add)
|
||||
#define _ec_felem_equal BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_felem_equal)
|
||||
#define _ec_felem_from_bytes BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_felem_from_bytes)
|
||||
#define _ec_felem_neg BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_felem_neg)
|
||||
#define _ec_felem_non_zero_mask BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_felem_non_zero_mask)
|
||||
#define _ec_felem_select BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_felem_select)
|
||||
#define _ec_felem_sub BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_felem_sub)
|
||||
#define _ec_felem_to_bignum BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_felem_to_bignum)
|
||||
#define _ec_felem_to_bytes BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_felem_to_bytes)
|
||||
#define _ec_get_x_coordinate_as_bytes BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_get_x_coordinate_as_bytes)
|
||||
#define _ec_get_x_coordinate_as_scalar BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_get_x_coordinate_as_scalar)
|
||||
#define _ec_group_new BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_group_new)
|
||||
#define _ec_hash_to_curve_p384_xmd_sha512_sswu_draft07 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_hash_to_curve_p384_xmd_sha512_sswu_draft07)
|
||||
#define _ec_hash_to_curve_p521_xmd_sha512_sswu_draft06 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_hash_to_curve_p521_xmd_sha512_sswu_draft06)
|
||||
#define _ec_hash_to_scalar_p384_xmd_sha512_draft07 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_hash_to_scalar_p384_xmd_sha512_draft07)
|
||||
#define _ec_hash_to_scalar_p521_xmd_sha512_draft06 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_hash_to_scalar_p521_xmd_sha512_draft06)
|
||||
#define _ec_init_precomp BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_init_precomp)
|
||||
#define _ec_jacobian_to_affine BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_jacobian_to_affine)
|
||||
#define _ec_jacobian_to_affine_batch BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_jacobian_to_affine_batch)
|
||||
#define _ec_pkey_meth BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_pkey_meth)
|
||||
#define _ec_point_get_affine_coordinate_bytes BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_point_get_affine_coordinate_bytes)
|
||||
#define _ec_point_from_uncompressed BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_point_from_uncompressed)
|
||||
#define _ec_point_mul_scalar BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_point_mul_scalar)
|
||||
#define _ec_point_mul_scalar_base BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_point_mul_scalar_base)
|
||||
#define _ec_point_mul_scalar_batch BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_point_mul_scalar_batch)
|
||||
#define _ec_point_mul_scalar_precomp BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_point_mul_scalar_precomp)
|
||||
#define _ec_point_mul_scalar_public BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_point_mul_scalar_public)
|
||||
#define _ec_point_mul_scalar_public_batch BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_point_mul_scalar_public_batch)
|
||||
#define _ec_point_select BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_point_select)
|
||||
#define _ec_point_set_affine_coordinates BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_point_set_affine_coordinates)
|
||||
#define _ec_point_to_bytes BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_point_to_bytes)
|
||||
#define _ec_precomp_select BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_precomp_select)
|
||||
#define _ec_random_nonzero_scalar BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_random_nonzero_scalar)
|
||||
#define _ec_scalar_add BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_scalar_add)
|
||||
#define _ec_scalar_equal_vartime BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_scalar_equal_vartime)
|
||||
#define _ec_scalar_from_bytes BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_scalar_from_bytes)
|
||||
#define _ec_scalar_from_montgomery BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_scalar_from_montgomery)
|
||||
#define _ec_scalar_inv_montgomery BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_scalar_inv_montgomery)
|
||||
#define _ec_scalar_inv_montgomery_vartime BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_scalar_inv_montgomery_vartime)
|
||||
#define _ec_scalar_inv0_montgomery BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_scalar_inv0_montgomery)
|
||||
#define _ec_scalar_is_zero BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_scalar_is_zero)
|
||||
#define _ec_scalar_mul_montgomery BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_scalar_mul_montgomery)
|
||||
#define _ec_scalar_neg BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_scalar_neg)
|
||||
#define _ec_scalar_reduce BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_scalar_reduce)
|
||||
#define _ec_scalar_select BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_scalar_select)
|
||||
#define _ec_scalar_sub BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_scalar_sub)
|
||||
#define _ec_scalar_to_bytes BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_scalar_to_bytes)
|
||||
#define _ec_scalar_to_montgomery BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_scalar_to_montgomery)
|
||||
#define _ec_simple_scalar_inv_montgomery BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_simple_scalar_inv_montgomery)
|
||||
#define _ec_scalar_to_montgomery_inv_vartime BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_scalar_to_montgomery_inv_vartime)
|
||||
#define _ec_set_to_safe_point BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_set_to_safe_point)
|
||||
#define _ec_simple_scalar_inv0_montgomery BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_simple_scalar_inv0_montgomery)
|
||||
#define _ec_simple_scalar_to_montgomery_inv_vartime BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_simple_scalar_to_montgomery_inv_vartime)
|
||||
#define _ecp_nistz256_avx2_select_w7 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ecp_nistz256_avx2_select_w7)
|
||||
#define _ecp_nistz256_mul_mont BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ecp_nistz256_mul_mont)
|
||||
#define _ecp_nistz256_neg BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ecp_nistz256_neg)
|
||||
@@ -2592,6 +2664,21 @@
|
||||
#define _pkcs7_bundle BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, pkcs7_bundle)
|
||||
#define _pkcs7_parse_header BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, pkcs7_parse_header)
|
||||
#define _pkcs8_pbe_decrypt BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, pkcs8_pbe_decrypt)
|
||||
#define _pmbtoken_exp0_blind BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, pmbtoken_exp0_blind)
|
||||
#define _pmbtoken_exp0_client_key_from_bytes BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, pmbtoken_exp0_client_key_from_bytes)
|
||||
#define _pmbtoken_exp0_generate_key BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, pmbtoken_exp0_generate_key)
|
||||
#define _pmbtoken_exp0_issuer_key_from_bytes BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, pmbtoken_exp0_issuer_key_from_bytes)
|
||||
#define _pmbtoken_exp0_read BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, pmbtoken_exp0_read)
|
||||
#define _pmbtoken_exp0_sign BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, pmbtoken_exp0_sign)
|
||||
#define _pmbtoken_exp0_unblind BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, pmbtoken_exp0_unblind)
|
||||
#define _pmbtoken_exp1_blind BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, pmbtoken_exp1_blind)
|
||||
#define _pmbtoken_exp1_client_key_from_bytes BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, pmbtoken_exp1_client_key_from_bytes)
|
||||
#define _pmbtoken_exp1_generate_key BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, pmbtoken_exp1_generate_key)
|
||||
#define _pmbtoken_exp1_get_h_for_testing BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, pmbtoken_exp1_get_h_for_testing)
|
||||
#define _pmbtoken_exp1_issuer_key_from_bytes BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, pmbtoken_exp1_issuer_key_from_bytes)
|
||||
#define _pmbtoken_exp1_read BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, pmbtoken_exp1_read)
|
||||
#define _pmbtoken_exp1_sign BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, pmbtoken_exp1_sign)
|
||||
#define _pmbtoken_exp1_unblind BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, pmbtoken_exp1_unblind)
|
||||
#define _policy_cache_find_data BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, policy_cache_find_data)
|
||||
#define _policy_cache_free BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, policy_cache_free)
|
||||
#define _policy_cache_set BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, policy_cache_set)
|
||||
|
||||
@@ -63,6 +63,14 @@ OPENSSL_EXPORT int FIPS_mode(void);
|
||||
// success and zero on error.
|
||||
OPENSSL_EXPORT int BORINGSSL_self_test(void);
|
||||
|
||||
// CRYPTO_pre_sandbox_init initializes the crypto library, pre-acquiring some
|
||||
// unusual resources to aid running in sandboxed environments. It is safe to
|
||||
// call this function multiple times and concurrently from multiple threads.
|
||||
//
|
||||
// For more details on using BoringSSL in a sandboxed environment, see
|
||||
// SANDBOXING.md in the source tree.
|
||||
OPENSSL_EXPORT void CRYPTO_pre_sandbox_init(void);
|
||||
|
||||
|
||||
// Deprecated functions.
|
||||
|
||||
|
||||
@@ -86,6 +86,21 @@ OPENSSL_EXPORT int DH_up_ref(DH *dh);
|
||||
|
||||
// Properties.
|
||||
|
||||
// DH_get0_pub_key returns |dh|'s public key.
|
||||
OPENSSL_EXPORT const BIGNUM *DH_get0_pub_key(const DH *dh);
|
||||
|
||||
// DH_get0_priv_key returns |dh|'s private key, or NULL if |dh| is a public key.
|
||||
OPENSSL_EXPORT const BIGNUM *DH_get0_priv_key(const DH *dh);
|
||||
|
||||
// DH_get0_p returns |dh|'s group modulus.
|
||||
OPENSSL_EXPORT const BIGNUM *DH_get0_p(const DH *dh);
|
||||
|
||||
// DH_get0_q returns the size of |dh|'s subgroup, or NULL if it is unset.
|
||||
OPENSSL_EXPORT const BIGNUM *DH_get0_q(const DH *dh);
|
||||
|
||||
// DH_get0_g returns |dh|'s group generator.
|
||||
OPENSSL_EXPORT const BIGNUM *DH_get0_g(const DH *dh);
|
||||
|
||||
// DH_get0_key sets |*out_pub_key| and |*out_priv_key|, if non-NULL, to |dh|'s
|
||||
// public and private key, respectively. If |dh| is a public key, the private
|
||||
// key will be set to NULL.
|
||||
@@ -108,6 +123,11 @@ OPENSSL_EXPORT void DH_get0_pqg(const DH *dh, const BIGNUM **out_p,
|
||||
// |p| and |g| must either be specified or already configured on |dh|.
|
||||
OPENSSL_EXPORT int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g);
|
||||
|
||||
// DH_set_length sets the number of bits to use for the secret exponent when
|
||||
// calling |DH_generate_key| on |dh| and returns one. If unset,
|
||||
// |DH_generate_key| will use the bit length of p.
|
||||
OPENSSL_EXPORT int DH_set_length(DH *dh, unsigned priv_length);
|
||||
|
||||
|
||||
// Standard parameters.
|
||||
|
||||
|
||||
@@ -83,6 +83,7 @@ OPENSSL_EXPORT const EVP_MD *EVP_sha224(void);
|
||||
OPENSSL_EXPORT const EVP_MD *EVP_sha256(void);
|
||||
OPENSSL_EXPORT const EVP_MD *EVP_sha384(void);
|
||||
OPENSSL_EXPORT const EVP_MD *EVP_sha512(void);
|
||||
OPENSSL_EXPORT const EVP_MD *EVP_sha512_256(void);
|
||||
|
||||
// EVP_md5_sha1 is a TLS-specific |EVP_MD| which computes the concatenation of
|
||||
// MD5 and SHA-1, as used in TLS 1.1 and below.
|
||||
|
||||
@@ -94,6 +94,22 @@ OPENSSL_EXPORT int DSA_up_ref(DSA *dsa);
|
||||
|
||||
// Properties.
|
||||
|
||||
// DSA_get0_pub_key returns |dsa|'s public key.
|
||||
OPENSSL_EXPORT const BIGNUM *DSA_get0_pub_key(const DSA *dsa);
|
||||
|
||||
// DSA_get0_priv_key returns |dsa|'s private key, or NULL if |dsa| is a public
|
||||
// key.
|
||||
OPENSSL_EXPORT const BIGNUM *DSA_get0_priv_key(const DSA *dsa);
|
||||
|
||||
// DSA_get0_p returns |dsa|'s group modulus.
|
||||
OPENSSL_EXPORT const BIGNUM *DSA_get0_p(const DSA *dsa);
|
||||
|
||||
// DSA_get0_q returns the size of |dsa|'s subgroup.
|
||||
OPENSSL_EXPORT const BIGNUM *DSA_get0_q(const DSA *dsa);
|
||||
|
||||
// DSA_get0_g returns |dsa|'s group generator.
|
||||
OPENSSL_EXPORT const BIGNUM *DSA_get0_g(const DSA *dsa);
|
||||
|
||||
// DSA_get0_key sets |*out_pub_key| and |*out_priv_key|, if non-NULL, to |dsa|'s
|
||||
// public and private key, respectively. If |dsa| is a public key, the private
|
||||
// key will be set to NULL.
|
||||
|
||||
@@ -319,8 +319,8 @@ enum {
|
||||
ERR_LIB_DIGEST,
|
||||
ERR_LIB_CIPHER,
|
||||
ERR_LIB_HKDF,
|
||||
ERR_LIB_USER,
|
||||
ERR_LIB_TRUST_TOKEN,
|
||||
ERR_LIB_USER,
|
||||
ERR_NUM_LIBS
|
||||
};
|
||||
|
||||
@@ -363,6 +363,7 @@ enum {
|
||||
#define ERR_R_DIGEST_LIB ERR_LIB_DIGEST
|
||||
#define ERR_R_CIPHER_LIB ERR_LIB_CIPHER
|
||||
#define ERR_R_HKDF_LIB ERR_LIB_HKDF
|
||||
#define ERR_R_TRUST_TOKEN_LIB ERR_LIB_TRUST_TOKEN
|
||||
|
||||
// The following values are global reason codes. They may occur in any library.
|
||||
#define ERR_R_FATAL 64
|
||||
|
||||
@@ -4246,6 +4246,11 @@ extern "C" {
|
||||
#define NID_X448 961
|
||||
#define OBJ_X448 1L, 3L, 101L, 111L
|
||||
|
||||
#define SN_sha512_256 "SHA512-256"
|
||||
#define LN_sha512_256 "sha512-256"
|
||||
#define NID_sha512_256 962
|
||||
#define OBJ_sha512_256 2L, 16L, 840L, 1L, 101L, 3L, 4L, 2L, 6L
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} /* extern C */
|
||||
|
||||
@@ -36,26 +36,12 @@ OPENSSL_EXPORT void RAND_cleanup(void);
|
||||
// Obscure functions.
|
||||
|
||||
#if !defined(OPENSSL_WINDOWS)
|
||||
// RAND_set_urandom_fd causes the module to use a copy of |fd| for system
|
||||
// randomness rather opening /dev/urandom internally. The caller retains
|
||||
// ownership of |fd| and is at liberty to close it at any time. This is useful
|
||||
// if, due to a sandbox, /dev/urandom isn't available. If used, it must be
|
||||
// called before the first call to |RAND_bytes|, and it is mutually exclusive
|
||||
// with |RAND_enable_fork_unsafe_buffering|.
|
||||
//
|
||||
// |RAND_set_urandom_fd| does not buffer any entropy, so it is safe to call
|
||||
// |fork| at any time after calling |RAND_set_urandom_fd|.
|
||||
OPENSSL_EXPORT void RAND_set_urandom_fd(int fd);
|
||||
|
||||
// RAND_enable_fork_unsafe_buffering enables efficient buffered reading of
|
||||
// /dev/urandom. It adds an overhead of a few KB of memory per thread. It must
|
||||
// be called before the first call to |RAND_bytes| and it is mutually exclusive
|
||||
// with calls to |RAND_set_urandom_fd|.
|
||||
// be called before the first call to |RAND_bytes|.
|
||||
//
|
||||
// If |fd| is non-negative then a copy of |fd| will be used rather than opening
|
||||
// /dev/urandom internally. Like |RAND_set_urandom_fd|, the caller retains
|
||||
// ownership of |fd|. If |fd| is negative then /dev/urandom will be opened and
|
||||
// any error from open(2) crashes the address space.
|
||||
// |fd| must be -1. We no longer support setting the file descriptor with this
|
||||
// function.
|
||||
//
|
||||
// It has an unusual name because the buffer is unsafe across calls to |fork|.
|
||||
// Hence, this function should never be called by libraries.
|
||||
|
||||
@@ -741,6 +741,7 @@ struct rsa_st {
|
||||
// |blindings_inuse| from 0 to 1.
|
||||
BN_BLINDING **blindings;
|
||||
unsigned char *blindings_inuse;
|
||||
uint64_t blinding_fork_generation;
|
||||
|
||||
// private_key_frozen is one if the key has been used for a private key
|
||||
// operation and may no longer be mutated.
|
||||
|
||||
@@ -261,6 +261,32 @@ struct sha512_state_st {
|
||||
};
|
||||
|
||||
|
||||
// SHA-512-256
|
||||
//
|
||||
// See https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf section 5.3.6
|
||||
|
||||
#define SHA512_256_DIGEST_LENGTH 32
|
||||
|
||||
// SHA512_256_Init initialises |sha| and returns 1.
|
||||
OPENSSL_EXPORT int SHA512_256_Init(SHA512_CTX *sha);
|
||||
|
||||
// SHA512_256_Update adds |len| bytes from |data| to |sha| and returns 1.
|
||||
OPENSSL_EXPORT int SHA512_256_Update(SHA512_CTX *sha, const void *data,
|
||||
size_t len);
|
||||
|
||||
// SHA512_256_Final adds the final padding to |sha| and writes the resulting
|
||||
// digest to |out|, which must have at least |SHA512_256_DIGEST_LENGTH| bytes of
|
||||
// space. It returns one on success and zero on programmer error.
|
||||
OPENSSL_EXPORT int SHA512_256_Final(uint8_t out[SHA512_256_DIGEST_LENGTH],
|
||||
SHA512_CTX *sha);
|
||||
|
||||
// SHA512_256 writes the digest of |len| bytes from |data| to |out| and returns
|
||||
// |out|. There must be at least |SHA512_256_DIGEST_LENGTH| bytes of space in
|
||||
// |out|.
|
||||
OPENSSL_EXPORT uint8_t *SHA512_256(const uint8_t *data, size_t len,
|
||||
uint8_t out[SHA512_256_DIGEST_LENGTH]);
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} // extern C
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2019, Google Inc.
|
||||
/* Copyright (c) 2020, Google Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -36,6 +36,32 @@ extern "C" {
|
||||
//
|
||||
// WARNING: This API is unstable and subject to change.
|
||||
|
||||
// TRUST_TOKEN_experiment_v0 is an experimental Trust Tokens protocol using
|
||||
// PMBTokens and P-521.
|
||||
OPENSSL_EXPORT const TRUST_TOKEN_METHOD *TRUST_TOKEN_experiment_v0(void);
|
||||
|
||||
// TRUST_TOKEN_experiment_v1 is an experimental Trust Tokens protocol using
|
||||
// PMBTokens and P-384. This version is still under developement and should not
|
||||
// be used yet.
|
||||
OPENSSL_EXPORT const TRUST_TOKEN_METHOD *TRUST_TOKEN_experiment_v1(void);
|
||||
|
||||
// trust_token_st represents a single-use token for the Trust Token protocol.
|
||||
// For the client, this is the token and its corresponding signature. For the
|
||||
// issuer, this is the token itself.
|
||||
struct trust_token_st {
|
||||
uint8_t *data;
|
||||
size_t len;
|
||||
};
|
||||
|
||||
DEFINE_STACK_OF(TRUST_TOKEN)
|
||||
|
||||
// TRUST_TOKEN_new creates a newly-allocated |TRUST_TOKEN| with value |data| or
|
||||
// NULL on allocation failure.
|
||||
OPENSSL_EXPORT TRUST_TOKEN *TRUST_TOKEN_new(const uint8_t *data, size_t len);
|
||||
|
||||
// TRUST_TOKEN_free releases memory associated with |token|.
|
||||
OPENSSL_EXPORT void TRUST_TOKEN_free(TRUST_TOKEN *token);
|
||||
|
||||
#define TRUST_TOKEN_MAX_PRIVATE_KEY_SIZE 512
|
||||
#define TRUST_TOKEN_MAX_PUBLIC_KEY_SIZE 512
|
||||
|
||||
@@ -54,16 +80,212 @@ extern "C" {
|
||||
//
|
||||
// This function returns one on success or zero on error.
|
||||
OPENSSL_EXPORT int TRUST_TOKEN_generate_key(
|
||||
uint8_t *out_priv_key, size_t *out_priv_key_len, size_t max_priv_key_len,
|
||||
uint8_t *out_pub_key, size_t *out_pub_key_len, size_t max_pub_key_len,
|
||||
uint32_t id);
|
||||
const TRUST_TOKEN_METHOD *method, uint8_t *out_priv_key,
|
||||
size_t *out_priv_key_len, size_t max_priv_key_len, uint8_t *out_pub_key,
|
||||
size_t *out_pub_key_len, size_t max_pub_key_len, uint32_t id);
|
||||
|
||||
|
||||
// Trust Token client implementation.
|
||||
//
|
||||
// These functions implements the client half of the Trust Token protocol. A
|
||||
// single |TRUST_TOKEN_CLIENT| can perform a single protocol operation.
|
||||
|
||||
// TRUST_TOKEN_CLIENT_new returns a newly-allocated |TRUST_TOKEN_CLIENT|
|
||||
// configured to use a max batchsize of |max_batchsize| or NULL on error.
|
||||
// Issuance requests must be made in batches smaller than |max_batchsize|. This
|
||||
// function will return an error if |max_batchsize| is too large for Trust
|
||||
// Tokens.
|
||||
OPENSSL_EXPORT TRUST_TOKEN_CLIENT *TRUST_TOKEN_CLIENT_new(
|
||||
const TRUST_TOKEN_METHOD *method, size_t max_batchsize);
|
||||
|
||||
// TRUST_TOKEN_CLIENT_free releases memory associated with |ctx|.
|
||||
OPENSSL_EXPORT void TRUST_TOKEN_CLIENT_free(TRUST_TOKEN_CLIENT *ctx);
|
||||
|
||||
// TRUST_TOKEN_CLIENT_add_key configures the |ctx| to support the public key
|
||||
// |key|. It sets |*out_key_index| to the index this key has been configured to.
|
||||
// It returns one on success or zero on error if the |key| can't be parsed or
|
||||
// too many keys have been configured.
|
||||
OPENSSL_EXPORT int TRUST_TOKEN_CLIENT_add_key(TRUST_TOKEN_CLIENT *ctx,
|
||||
size_t *out_key_index,
|
||||
const uint8_t *key,
|
||||
size_t key_len);
|
||||
|
||||
// TRUST_TOKEN_CLIENT_set_srr_key sets the public key used to verify the SRR. It
|
||||
// returns one on success and zero on error.
|
||||
OPENSSL_EXPORT int TRUST_TOKEN_CLIENT_set_srr_key(TRUST_TOKEN_CLIENT *ctx,
|
||||
EVP_PKEY *key);
|
||||
|
||||
// TRUST_TOKEN_CLIENT_begin_issuance produces a request for |count| trust tokens
|
||||
// and serializes the request into a newly-allocated buffer, setting |*out| to
|
||||
// that buffer and |*out_len| to its length. The caller takes ownership of the
|
||||
// buffer and must call |OPENSSL_free| when done. It returns one on success and
|
||||
// zero on error.
|
||||
OPENSSL_EXPORT int TRUST_TOKEN_CLIENT_begin_issuance(TRUST_TOKEN_CLIENT *ctx,
|
||||
uint8_t **out,
|
||||
size_t *out_len,
|
||||
size_t count);
|
||||
|
||||
// TRUST_TOKEN_CLIENT_finish_issuance consumes |response| from the issuer and
|
||||
// extracts the tokens, returning a list of tokens and the index of the key used
|
||||
// to sign the tokens in |*out_key_index|. The caller can use this to determine
|
||||
// what key was used in an issuance and to drop tokens if a new key commitment
|
||||
// arrives without the specified key present. The caller takes ownership of the
|
||||
// list and must call |sk_TRUST_TOKEN_pop_free| when done. The list is empty if
|
||||
// issuance fails.
|
||||
OPENSSL_EXPORT STACK_OF(TRUST_TOKEN) *
|
||||
TRUST_TOKEN_CLIENT_finish_issuance(TRUST_TOKEN_CLIENT *ctx,
|
||||
size_t *out_key_index,
|
||||
const uint8_t *response,
|
||||
size_t response_len);
|
||||
|
||||
|
||||
// TRUST_TOKEN_CLIENT_begin_redemption produces a request to redeem a token
|
||||
// |token| and receive a signature over |data| and serializes the request into
|
||||
// a newly-allocated buffer, setting |*out| to that buffer and |*out_len| to
|
||||
// its length. |time| is the number of seconds since the UNIX epoch and used to
|
||||
// verify the validity of the issuer's response. The caller takes ownership of
|
||||
// the buffer and must call |OPENSSL_free| when done. It returns one on success
|
||||
// or zero on error.
|
||||
OPENSSL_EXPORT int TRUST_TOKEN_CLIENT_begin_redemption(
|
||||
TRUST_TOKEN_CLIENT *ctx, uint8_t **out, size_t *out_len,
|
||||
const TRUST_TOKEN *token, const uint8_t *data, size_t data_len,
|
||||
uint64_t time);
|
||||
|
||||
// TRUST_TOKEN_CLIENT_finish_redemption consumes |response| from the issuer and
|
||||
// verifies the SRR. If valid, it returns one and sets |*out_srr| and
|
||||
// |*out_srr_len| (respectively, |*out_sig| and |*out_sig_len|) to a
|
||||
// newly-allocated buffer containing the SRR (respectively, the SRR signature).
|
||||
// Otherwise, it returns zero.
|
||||
OPENSSL_EXPORT int TRUST_TOKEN_CLIENT_finish_redemption(
|
||||
TRUST_TOKEN_CLIENT *ctx, uint8_t **out_srr, size_t *out_srr_len,
|
||||
uint8_t **out_sig, size_t *out_sig_len, const uint8_t *response,
|
||||
size_t response_len);
|
||||
|
||||
|
||||
// Trust Token issuer implementation.
|
||||
//
|
||||
// These functions implement the issuer half of the Trust Token protocol. A
|
||||
// |TRUST_TOKEN_ISSUER| can be reused across multiple protocol operations. It
|
||||
// may be used concurrently on multiple threads by non-mutating functions,
|
||||
// provided no other thread is concurrently calling a mutating function.
|
||||
// Functions which take a |const| pointer are non-mutating and functions which
|
||||
// take a non-|const| pointer are mutating.
|
||||
|
||||
// TRUST_TOKEN_ISSUER_new returns a newly-allocated |TRUST_TOKEN_ISSUER|
|
||||
// configured to use a max batchsize of |max_batchsize| or NULL on error.
|
||||
// Issuance requests must be made in batches smaller than |max_batchsize|. This
|
||||
// function will return an error if |max_batchsize| is too large for Trust
|
||||
// Tokens.
|
||||
OPENSSL_EXPORT TRUST_TOKEN_ISSUER *TRUST_TOKEN_ISSUER_new(
|
||||
const TRUST_TOKEN_METHOD *method, size_t max_batchsize);
|
||||
|
||||
// TRUST_TOKEN_ISSUER_free releases memory associated with |ctx|.
|
||||
OPENSSL_EXPORT void TRUST_TOKEN_ISSUER_free(TRUST_TOKEN_ISSUER *ctx);
|
||||
|
||||
// TRUST_TOKEN_ISSUER_add_key configures the |ctx| to support the private key
|
||||
// |key|. It must be a private key returned by |TRUST_TOKEN_generate_key|. It
|
||||
// returns one on success or zero on error. This function may fail if the |key|
|
||||
// can't be parsed or too many keys have been configured.
|
||||
OPENSSL_EXPORT int TRUST_TOKEN_ISSUER_add_key(TRUST_TOKEN_ISSUER *ctx,
|
||||
const uint8_t *key,
|
||||
size_t key_len);
|
||||
|
||||
// TRUST_TOKEN_ISSUER_set_srr_key sets the private key used to sign the SRR. It
|
||||
// returns one on success and zero on error.
|
||||
OPENSSL_EXPORT int TRUST_TOKEN_ISSUER_set_srr_key(TRUST_TOKEN_ISSUER *ctx,
|
||||
EVP_PKEY *key);
|
||||
|
||||
// TRUST_TOKEN_ISSUER_set_metadata_key sets the key used to encrypt the private
|
||||
// metadata. The key is a randomly generated bytestring of at least 32 bytes
|
||||
// used to encode the private metadata bit in the SRR. It returns one on success
|
||||
// and zero on error.
|
||||
OPENSSL_EXPORT int TRUST_TOKEN_ISSUER_set_metadata_key(TRUST_TOKEN_ISSUER *ctx,
|
||||
const uint8_t *key,
|
||||
size_t len);
|
||||
|
||||
// TRUST_TOKEN_ISSUER_issue ingests |request| for token issuance
|
||||
// and generates up to |max_issuance| valid tokens, producing a list of blinded
|
||||
// tokens and storing the response into a newly-allocated buffer and setting
|
||||
// |*out| to that buffer, |*out_len| to its length, and |*out_tokens_issued| to
|
||||
// the number of tokens issued. The tokens are issued with public metadata of
|
||||
// |public_metadata| and a private metadata value of |private_metadata|.
|
||||
// |public_metadata| must be one of the previously configured key IDs.
|
||||
// |private_metadata| must be 0 or 1. The caller takes ownership of the buffer
|
||||
// and must call |OPENSSL_free| when done. It returns one on success or zero on
|
||||
// error.
|
||||
OPENSSL_EXPORT int TRUST_TOKEN_ISSUER_issue(
|
||||
const TRUST_TOKEN_ISSUER *ctx, uint8_t **out, size_t *out_len,
|
||||
size_t *out_tokens_issued, const uint8_t *request, size_t request_len,
|
||||
uint32_t public_metadata, uint8_t private_metadata, size_t max_issuance);
|
||||
|
||||
// TRUST_TOKEN_ISSUER_redeem ingests a |request| for token redemption and
|
||||
// verifies the token. If the token is valid, a SRR is produced with a lifetime
|
||||
// of |lifetime| (in seconds), signing over the requested data from the request
|
||||
// and the value of the token, storing the result into a newly-allocated buffer
|
||||
// and setting |*out| to that buffer and |*out_len| to its length. The extracted
|
||||
// |TRUST_TOKEN| is stored into a newly-allocated buffer and stored in
|
||||
// |*out_token|. The extracted client data is stored into a newly-allocated
|
||||
// buffer and stored in |*out_client_data|. The extracted redemption time is
|
||||
// stored in |*out_redemption_time|. The caller takes ownership of each output
|
||||
// buffer and must call |OPENSSL_free| when done. It returns one on success or
|
||||
// zero on error.
|
||||
//
|
||||
// The caller must keep track of all values of |*out_token| seen globally before
|
||||
// returning the SRR to the client. If the value has been reused, the caller
|
||||
// must discard the SRR and report an error to the caller. Returning an SRR with
|
||||
// replayed values allows an attacker to double-spend tokens.
|
||||
//
|
||||
// The private metadata construction in |TRUST_TOKEN_experiment_v0| does not
|
||||
// keep the value secret and should not be used when secrecy is required.
|
||||
OPENSSL_EXPORT int TRUST_TOKEN_ISSUER_redeem(
|
||||
const TRUST_TOKEN_ISSUER *ctx, uint8_t **out, size_t *out_len,
|
||||
TRUST_TOKEN **out_token, uint8_t **out_client_data,
|
||||
size_t *out_client_data_len, uint64_t *out_redemption_time,
|
||||
const uint8_t *request, size_t request_len, uint64_t lifetime);
|
||||
|
||||
// TRUST_TOKEN_decode_private_metadata decodes |encrypted_bit| using the
|
||||
// private metadata key specified by a |key| buffer of length |key_len| and the
|
||||
// nonce by a |nonce| buffer of length |nonce_len|. The nonce in
|
||||
// |TRUST_TOKEN_experiment_v0| is the client-data field of the SRR. The nonce in
|
||||
// |TRUST_TOKEN_experiment_v1| is the token-hash field of the SRR. |*out_value|
|
||||
// is set to the decrypted value, either zero or one. It returns one on success
|
||||
// and zero on error.
|
||||
OPENSSL_EXPORT int TRUST_TOKEN_decode_private_metadata(
|
||||
const TRUST_TOKEN_METHOD *method, uint8_t *out_value, const uint8_t *key,
|
||||
size_t key_len, const uint8_t *nonce, size_t nonce_len,
|
||||
uint8_t encrypted_bit);
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} // extern C
|
||||
|
||||
extern "C++" {
|
||||
|
||||
BSSL_NAMESPACE_BEGIN
|
||||
|
||||
BORINGSSL_MAKE_DELETER(TRUST_TOKEN, TRUST_TOKEN_free)
|
||||
BORINGSSL_MAKE_DELETER(TRUST_TOKEN_CLIENT, TRUST_TOKEN_CLIENT_free)
|
||||
BORINGSSL_MAKE_DELETER(TRUST_TOKEN_ISSUER, TRUST_TOKEN_ISSUER_free)
|
||||
|
||||
BSSL_NAMESPACE_END
|
||||
|
||||
} // extern C++
|
||||
#endif
|
||||
|
||||
#define TRUST_TOKEN_R_KEYGEN_FAILURE 100
|
||||
#define TRUST_TOKEN_R_BUFFER_TOO_SMALL 101
|
||||
#define TRUST_TOKEN_R_OVER_BATCHSIZE 102
|
||||
#define TRUST_TOKEN_R_DECODE_ERROR 103
|
||||
#define TRUST_TOKEN_R_SRR_SIGNATURE_ERROR 104
|
||||
#define TRUST_TOKEN_R_DECODE_FAILURE 105
|
||||
#define TRUST_TOKEN_R_INVALID_METADATA 106
|
||||
#define TRUST_TOKEN_R_TOO_MANY_KEYS 107
|
||||
#define TRUST_TOKEN_R_NO_KEYS_CONFIGURED 108
|
||||
#define TRUST_TOKEN_R_INVALID_KEY_ID 109
|
||||
#define TRUST_TOKEN_R_INVALID_TOKEN 110
|
||||
#define TRUST_TOKEN_R_BAD_VALIDITY_CHECK 111
|
||||
#define TRUST_TOKEN_R_NO_SRR_KEY_CONFIGURED 112
|
||||
#define TRUST_TOKEN_R_INVALID_METADATA_KEY 113
|
||||
#define TRUST_TOKEN_R_INVALID_PROOF 114
|
||||
|
||||
#endif // OPENSSL_HEADER_TRUST_TOKEN_H
|
||||
@@ -578,6 +578,7 @@ OPENSSL_EXPORT X509 *X509_STORE_CTX_get0_current_issuer(X509_STORE_CTX *ctx);
|
||||
OPENSSL_EXPORT X509_CRL *X509_STORE_CTX_get0_current_crl(X509_STORE_CTX *ctx);
|
||||
OPENSSL_EXPORT X509_STORE_CTX *X509_STORE_CTX_get0_parent_ctx(X509_STORE_CTX *ctx);
|
||||
OPENSSL_EXPORT STACK_OF(X509) *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx);
|
||||
OPENSSL_EXPORT STACK_OF(X509) *X509_STORE_CTX_get0_chain(X509_STORE_CTX *ctx);
|
||||
OPENSSL_EXPORT STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx);
|
||||
OPENSSL_EXPORT void X509_STORE_CTX_set_cert(X509_STORE_CTX *c,X509 *x);
|
||||
OPENSSL_EXPORT void X509_STORE_CTX_set_chain(X509_STORE_CTX *c,STACK_OF(X509) *sk);
|
||||
|
||||
@@ -303,6 +303,7 @@
|
||||
%xdefine _BIO_write_filename _ %+ BORINGSSL_PREFIX %+ _BIO_write_filename
|
||||
%xdefine _BN_BLINDING_convert _ %+ BORINGSSL_PREFIX %+ _BN_BLINDING_convert
|
||||
%xdefine _BN_BLINDING_free _ %+ BORINGSSL_PREFIX %+ _BN_BLINDING_free
|
||||
%xdefine _BN_BLINDING_invalidate _ %+ BORINGSSL_PREFIX %+ _BN_BLINDING_invalidate
|
||||
%xdefine _BN_BLINDING_invert _ %+ BORINGSSL_PREFIX %+ _BN_BLINDING_invert
|
||||
%xdefine _BN_BLINDING_new _ %+ BORINGSSL_PREFIX %+ _BN_BLINDING_new
|
||||
%xdefine _BN_CTX_end _ %+ BORINGSSL_PREFIX %+ _BN_CTX_end
|
||||
@@ -566,6 +567,7 @@
|
||||
%xdefine _CRYPTO_cleanup_all_ex_data _ %+ BORINGSSL_PREFIX %+ _CRYPTO_cleanup_all_ex_data
|
||||
%xdefine _CRYPTO_ctr128_encrypt _ %+ BORINGSSL_PREFIX %+ _CRYPTO_ctr128_encrypt
|
||||
%xdefine _CRYPTO_ctr128_encrypt_ctr32 _ %+ BORINGSSL_PREFIX %+ _CRYPTO_ctr128_encrypt_ctr32
|
||||
%xdefine _CRYPTO_fork_detect_ignore_madv_wipeonfork_for_testing _ %+ BORINGSSL_PREFIX %+ _CRYPTO_fork_detect_ignore_madv_wipeonfork_for_testing
|
||||
%xdefine _CRYPTO_free_ex_data _ %+ BORINGSSL_PREFIX %+ _CRYPTO_free_ex_data
|
||||
%xdefine _CRYPTO_gcm128_aad _ %+ BORINGSSL_PREFIX %+ _CRYPTO_gcm128_aad
|
||||
%xdefine _CRYPTO_gcm128_decrypt _ %+ BORINGSSL_PREFIX %+ _CRYPTO_gcm128_decrypt
|
||||
@@ -581,12 +583,14 @@
|
||||
%xdefine _CRYPTO_get_dynlock_lock_callback _ %+ BORINGSSL_PREFIX %+ _CRYPTO_get_dynlock_lock_callback
|
||||
%xdefine _CRYPTO_get_ex_data _ %+ BORINGSSL_PREFIX %+ _CRYPTO_get_ex_data
|
||||
%xdefine _CRYPTO_get_ex_new_index _ %+ BORINGSSL_PREFIX %+ _CRYPTO_get_ex_new_index
|
||||
%xdefine _CRYPTO_get_fork_generation _ %+ BORINGSSL_PREFIX %+ _CRYPTO_get_fork_generation
|
||||
%xdefine _CRYPTO_get_lock_name _ %+ BORINGSSL_PREFIX %+ _CRYPTO_get_lock_name
|
||||
%xdefine _CRYPTO_get_locking_callback _ %+ BORINGSSL_PREFIX %+ _CRYPTO_get_locking_callback
|
||||
%xdefine _CRYPTO_get_thread_local _ %+ BORINGSSL_PREFIX %+ _CRYPTO_get_thread_local
|
||||
%xdefine _CRYPTO_ghash_init _ %+ BORINGSSL_PREFIX %+ _CRYPTO_ghash_init
|
||||
%xdefine _CRYPTO_has_asm _ %+ BORINGSSL_PREFIX %+ _CRYPTO_has_asm
|
||||
%xdefine _CRYPTO_hchacha20 _ %+ BORINGSSL_PREFIX %+ _CRYPTO_hchacha20
|
||||
%xdefine _CRYPTO_init_sysrand _ %+ BORINGSSL_PREFIX %+ _CRYPTO_init_sysrand
|
||||
%xdefine _CRYPTO_is_ARMv8_AES_capable _ %+ BORINGSSL_PREFIX %+ _CRYPTO_is_ARMv8_AES_capable
|
||||
%xdefine _CRYPTO_is_ARMv8_PMULL_capable _ %+ BORINGSSL_PREFIX %+ _CRYPTO_is_ARMv8_PMULL_capable
|
||||
%xdefine _CRYPTO_is_NEON_capable_at_runtime _ %+ BORINGSSL_PREFIX %+ _CRYPTO_is_NEON_capable_at_runtime
|
||||
@@ -601,6 +605,7 @@
|
||||
%xdefine _CRYPTO_poly1305_finish _ %+ BORINGSSL_PREFIX %+ _CRYPTO_poly1305_finish
|
||||
%xdefine _CRYPTO_poly1305_init _ %+ BORINGSSL_PREFIX %+ _CRYPTO_poly1305_init
|
||||
%xdefine _CRYPTO_poly1305_update _ %+ BORINGSSL_PREFIX %+ _CRYPTO_poly1305_update
|
||||
%xdefine _CRYPTO_pre_sandbox_init _ %+ BORINGSSL_PREFIX %+ _CRYPTO_pre_sandbox_init
|
||||
%xdefine _CRYPTO_rdrand _ %+ BORINGSSL_PREFIX %+ _CRYPTO_rdrand
|
||||
%xdefine _CRYPTO_rdrand_multiple8_buf _ %+ BORINGSSL_PREFIX %+ _CRYPTO_rdrand_multiple8_buf
|
||||
%xdefine _CRYPTO_refcount_dec_and_test_zero _ %+ BORINGSSL_PREFIX %+ _CRYPTO_refcount_dec_and_test_zero
|
||||
@@ -614,6 +619,7 @@
|
||||
%xdefine _CRYPTO_set_locking_callback _ %+ BORINGSSL_PREFIX %+ _CRYPTO_set_locking_callback
|
||||
%xdefine _CRYPTO_set_thread_local _ %+ BORINGSSL_PREFIX %+ _CRYPTO_set_thread_local
|
||||
%xdefine _CRYPTO_sysrand _ %+ BORINGSSL_PREFIX %+ _CRYPTO_sysrand
|
||||
%xdefine _CRYPTO_sysrand_if_available _ %+ BORINGSSL_PREFIX %+ _CRYPTO_sysrand_if_available
|
||||
%xdefine _CRYPTO_tls1_prf _ %+ BORINGSSL_PREFIX %+ _CRYPTO_tls1_prf
|
||||
%xdefine _CTR_DRBG_clear _ %+ BORINGSSL_PREFIX %+ _CTR_DRBG_clear
|
||||
%xdefine _CTR_DRBG_generate _ %+ BORINGSSL_PREFIX %+ _CTR_DRBG_generate
|
||||
@@ -636,8 +642,13 @@
|
||||
%xdefine _DH_free _ %+ BORINGSSL_PREFIX %+ _DH_free
|
||||
%xdefine _DH_generate_key _ %+ BORINGSSL_PREFIX %+ _DH_generate_key
|
||||
%xdefine _DH_generate_parameters_ex _ %+ BORINGSSL_PREFIX %+ _DH_generate_parameters_ex
|
||||
%xdefine _DH_get0_g _ %+ BORINGSSL_PREFIX %+ _DH_get0_g
|
||||
%xdefine _DH_get0_key _ %+ BORINGSSL_PREFIX %+ _DH_get0_key
|
||||
%xdefine _DH_get0_p _ %+ BORINGSSL_PREFIX %+ _DH_get0_p
|
||||
%xdefine _DH_get0_pqg _ %+ BORINGSSL_PREFIX %+ _DH_get0_pqg
|
||||
%xdefine _DH_get0_priv_key _ %+ BORINGSSL_PREFIX %+ _DH_get0_priv_key
|
||||
%xdefine _DH_get0_pub_key _ %+ BORINGSSL_PREFIX %+ _DH_get0_pub_key
|
||||
%xdefine _DH_get0_q _ %+ BORINGSSL_PREFIX %+ _DH_get0_q
|
||||
%xdefine _DH_get_ex_data _ %+ BORINGSSL_PREFIX %+ _DH_get_ex_data
|
||||
%xdefine _DH_get_ex_new_index _ %+ BORINGSSL_PREFIX %+ _DH_get_ex_new_index
|
||||
%xdefine _DH_marshal_parameters _ %+ BORINGSSL_PREFIX %+ _DH_marshal_parameters
|
||||
@@ -647,6 +658,7 @@
|
||||
%xdefine _DH_set0_key _ %+ BORINGSSL_PREFIX %+ _DH_set0_key
|
||||
%xdefine _DH_set0_pqg _ %+ BORINGSSL_PREFIX %+ _DH_set0_pqg
|
||||
%xdefine _DH_set_ex_data _ %+ BORINGSSL_PREFIX %+ _DH_set_ex_data
|
||||
%xdefine _DH_set_length _ %+ BORINGSSL_PREFIX %+ _DH_set_length
|
||||
%xdefine _DH_size _ %+ BORINGSSL_PREFIX %+ _DH_size
|
||||
%xdefine _DH_up_ref _ %+ BORINGSSL_PREFIX %+ _DH_up_ref
|
||||
%xdefine _DHparams_dup _ %+ BORINGSSL_PREFIX %+ _DHparams_dup
|
||||
@@ -675,8 +687,13 @@
|
||||
%xdefine _DSA_free _ %+ BORINGSSL_PREFIX %+ _DSA_free
|
||||
%xdefine _DSA_generate_key _ %+ BORINGSSL_PREFIX %+ _DSA_generate_key
|
||||
%xdefine _DSA_generate_parameters_ex _ %+ BORINGSSL_PREFIX %+ _DSA_generate_parameters_ex
|
||||
%xdefine _DSA_get0_g _ %+ BORINGSSL_PREFIX %+ _DSA_get0_g
|
||||
%xdefine _DSA_get0_key _ %+ BORINGSSL_PREFIX %+ _DSA_get0_key
|
||||
%xdefine _DSA_get0_p _ %+ BORINGSSL_PREFIX %+ _DSA_get0_p
|
||||
%xdefine _DSA_get0_pqg _ %+ BORINGSSL_PREFIX %+ _DSA_get0_pqg
|
||||
%xdefine _DSA_get0_priv_key _ %+ BORINGSSL_PREFIX %+ _DSA_get0_priv_key
|
||||
%xdefine _DSA_get0_pub_key _ %+ BORINGSSL_PREFIX %+ _DSA_get0_pub_key
|
||||
%xdefine _DSA_get0_q _ %+ BORINGSSL_PREFIX %+ _DSA_get0_q
|
||||
%xdefine _DSA_get_ex_data _ %+ BORINGSSL_PREFIX %+ _DSA_get_ex_data
|
||||
%xdefine _DSA_get_ex_new_index _ %+ BORINGSSL_PREFIX %+ _DSA_get_ex_new_index
|
||||
%xdefine _DSA_marshal_parameters _ %+ BORINGSSL_PREFIX %+ _DSA_marshal_parameters
|
||||
@@ -1105,6 +1122,7 @@
|
||||
%xdefine _EVP_sha256 _ %+ BORINGSSL_PREFIX %+ _EVP_sha256
|
||||
%xdefine _EVP_sha384 _ %+ BORINGSSL_PREFIX %+ _EVP_sha384
|
||||
%xdefine _EVP_sha512 _ %+ BORINGSSL_PREFIX %+ _EVP_sha512
|
||||
%xdefine _EVP_sha512_256 _ %+ BORINGSSL_PREFIX %+ _EVP_sha512_256
|
||||
%xdefine _EVP_tls_cbc_copy_mac _ %+ BORINGSSL_PREFIX %+ _EVP_tls_cbc_copy_mac
|
||||
%xdefine _EVP_tls_cbc_digest_record _ %+ BORINGSSL_PREFIX %+ _EVP_tls_cbc_digest_record
|
||||
%xdefine _EVP_tls_cbc_record_digest_supported _ %+ BORINGSSL_PREFIX %+ _EVP_tls_cbc_record_digest_supported
|
||||
@@ -1383,6 +1401,7 @@
|
||||
%xdefine _PKEY_USAGE_PERIOD_free _ %+ BORINGSSL_PREFIX %+ _PKEY_USAGE_PERIOD_free
|
||||
%xdefine _PKEY_USAGE_PERIOD_it _ %+ BORINGSSL_PREFIX %+ _PKEY_USAGE_PERIOD_it
|
||||
%xdefine _PKEY_USAGE_PERIOD_new _ %+ BORINGSSL_PREFIX %+ _PKEY_USAGE_PERIOD_new
|
||||
%xdefine _PMBTOKEN_PRETOKEN_free _ %+ BORINGSSL_PREFIX %+ _PMBTOKEN_PRETOKEN_free
|
||||
%xdefine _POLICYINFO_free _ %+ BORINGSSL_PREFIX %+ _POLICYINFO_free
|
||||
%xdefine _POLICYINFO_it _ %+ BORINGSSL_PREFIX %+ _POLICYINFO_it
|
||||
%xdefine _POLICYINFO_new _ %+ BORINGSSL_PREFIX %+ _POLICYINFO_new
|
||||
@@ -1416,7 +1435,6 @@
|
||||
%xdefine _RAND_pseudo_bytes _ %+ BORINGSSL_PREFIX %+ _RAND_pseudo_bytes
|
||||
%xdefine _RAND_seed _ %+ BORINGSSL_PREFIX %+ _RAND_seed
|
||||
%xdefine _RAND_set_rand_method _ %+ BORINGSSL_PREFIX %+ _RAND_set_rand_method
|
||||
%xdefine _RAND_set_urandom_fd _ %+ BORINGSSL_PREFIX %+ _RAND_set_urandom_fd
|
||||
%xdefine _RAND_status _ %+ BORINGSSL_PREFIX %+ _RAND_status
|
||||
%xdefine _RC4 _ %+ BORINGSSL_PREFIX %+ _RC4
|
||||
%xdefine _RC4_set_key _ %+ BORINGSSL_PREFIX %+ _RC4_set_key
|
||||
@@ -1509,6 +1527,10 @@
|
||||
%xdefine _SHA384_Init _ %+ BORINGSSL_PREFIX %+ _SHA384_Init
|
||||
%xdefine _SHA384_Update _ %+ BORINGSSL_PREFIX %+ _SHA384_Update
|
||||
%xdefine _SHA512 _ %+ BORINGSSL_PREFIX %+ _SHA512
|
||||
%xdefine _SHA512_256 _ %+ BORINGSSL_PREFIX %+ _SHA512_256
|
||||
%xdefine _SHA512_256_Final _ %+ BORINGSSL_PREFIX %+ _SHA512_256_Final
|
||||
%xdefine _SHA512_256_Init _ %+ BORINGSSL_PREFIX %+ _SHA512_256_Init
|
||||
%xdefine _SHA512_256_Update _ %+ BORINGSSL_PREFIX %+ _SHA512_256_Update
|
||||
%xdefine _SHA512_Final _ %+ BORINGSSL_PREFIX %+ _SHA512_Final
|
||||
%xdefine _SHA512_Init _ %+ BORINGSSL_PREFIX %+ _SHA512_Init
|
||||
%xdefine _SHA512_Transform _ %+ BORINGSSL_PREFIX %+ _SHA512_Transform
|
||||
@@ -1532,7 +1554,27 @@
|
||||
%xdefine _SXNET_get_id_ulong _ %+ BORINGSSL_PREFIX %+ _SXNET_get_id_ulong
|
||||
%xdefine _SXNET_it _ %+ BORINGSSL_PREFIX %+ _SXNET_it
|
||||
%xdefine _SXNET_new _ %+ BORINGSSL_PREFIX %+ _SXNET_new
|
||||
%xdefine _TRUST_TOKEN_CLIENT_add_key _ %+ BORINGSSL_PREFIX %+ _TRUST_TOKEN_CLIENT_add_key
|
||||
%xdefine _TRUST_TOKEN_CLIENT_begin_issuance _ %+ BORINGSSL_PREFIX %+ _TRUST_TOKEN_CLIENT_begin_issuance
|
||||
%xdefine _TRUST_TOKEN_CLIENT_begin_redemption _ %+ BORINGSSL_PREFIX %+ _TRUST_TOKEN_CLIENT_begin_redemption
|
||||
%xdefine _TRUST_TOKEN_CLIENT_finish_issuance _ %+ BORINGSSL_PREFIX %+ _TRUST_TOKEN_CLIENT_finish_issuance
|
||||
%xdefine _TRUST_TOKEN_CLIENT_finish_redemption _ %+ BORINGSSL_PREFIX %+ _TRUST_TOKEN_CLIENT_finish_redemption
|
||||
%xdefine _TRUST_TOKEN_CLIENT_free _ %+ BORINGSSL_PREFIX %+ _TRUST_TOKEN_CLIENT_free
|
||||
%xdefine _TRUST_TOKEN_CLIENT_new _ %+ BORINGSSL_PREFIX %+ _TRUST_TOKEN_CLIENT_new
|
||||
%xdefine _TRUST_TOKEN_CLIENT_set_srr_key _ %+ BORINGSSL_PREFIX %+ _TRUST_TOKEN_CLIENT_set_srr_key
|
||||
%xdefine _TRUST_TOKEN_ISSUER_add_key _ %+ BORINGSSL_PREFIX %+ _TRUST_TOKEN_ISSUER_add_key
|
||||
%xdefine _TRUST_TOKEN_ISSUER_free _ %+ BORINGSSL_PREFIX %+ _TRUST_TOKEN_ISSUER_free
|
||||
%xdefine _TRUST_TOKEN_ISSUER_issue _ %+ BORINGSSL_PREFIX %+ _TRUST_TOKEN_ISSUER_issue
|
||||
%xdefine _TRUST_TOKEN_ISSUER_new _ %+ BORINGSSL_PREFIX %+ _TRUST_TOKEN_ISSUER_new
|
||||
%xdefine _TRUST_TOKEN_ISSUER_redeem _ %+ BORINGSSL_PREFIX %+ _TRUST_TOKEN_ISSUER_redeem
|
||||
%xdefine _TRUST_TOKEN_ISSUER_set_metadata_key _ %+ BORINGSSL_PREFIX %+ _TRUST_TOKEN_ISSUER_set_metadata_key
|
||||
%xdefine _TRUST_TOKEN_ISSUER_set_srr_key _ %+ BORINGSSL_PREFIX %+ _TRUST_TOKEN_ISSUER_set_srr_key
|
||||
%xdefine _TRUST_TOKEN_decode_private_metadata _ %+ BORINGSSL_PREFIX %+ _TRUST_TOKEN_decode_private_metadata
|
||||
%xdefine _TRUST_TOKEN_experiment_v0 _ %+ BORINGSSL_PREFIX %+ _TRUST_TOKEN_experiment_v0
|
||||
%xdefine _TRUST_TOKEN_experiment_v1 _ %+ BORINGSSL_PREFIX %+ _TRUST_TOKEN_experiment_v1
|
||||
%xdefine _TRUST_TOKEN_free _ %+ BORINGSSL_PREFIX %+ _TRUST_TOKEN_free
|
||||
%xdefine _TRUST_TOKEN_generate_key _ %+ BORINGSSL_PREFIX %+ _TRUST_TOKEN_generate_key
|
||||
%xdefine _TRUST_TOKEN_new _ %+ BORINGSSL_PREFIX %+ _TRUST_TOKEN_new
|
||||
%xdefine _USERNOTICE_free _ %+ BORINGSSL_PREFIX %+ _USERNOTICE_free
|
||||
%xdefine _USERNOTICE_it _ %+ BORINGSSL_PREFIX %+ _USERNOTICE_it
|
||||
%xdefine _USERNOTICE_new _ %+ BORINGSSL_PREFIX %+ _USERNOTICE_new
|
||||
@@ -1808,6 +1850,7 @@
|
||||
%xdefine _X509_STORE_CTX_cleanup _ %+ BORINGSSL_PREFIX %+ _X509_STORE_CTX_cleanup
|
||||
%xdefine _X509_STORE_CTX_free _ %+ BORINGSSL_PREFIX %+ _X509_STORE_CTX_free
|
||||
%xdefine _X509_STORE_CTX_get0_cert _ %+ BORINGSSL_PREFIX %+ _X509_STORE_CTX_get0_cert
|
||||
%xdefine _X509_STORE_CTX_get0_chain _ %+ BORINGSSL_PREFIX %+ _X509_STORE_CTX_get0_chain
|
||||
%xdefine _X509_STORE_CTX_get0_current_crl _ %+ BORINGSSL_PREFIX %+ _X509_STORE_CTX_get0_current_crl
|
||||
%xdefine _X509_STORE_CTX_get0_current_issuer _ %+ BORINGSSL_PREFIX %+ _X509_STORE_CTX_get0_current_issuer
|
||||
%xdefine _X509_STORE_CTX_get0_param _ %+ BORINGSSL_PREFIX %+ _X509_STORE_CTX_get0_param
|
||||
@@ -2139,9 +2182,9 @@
|
||||
%xdefine _bn_mod_add_words _ %+ BORINGSSL_PREFIX %+ _bn_mod_add_words
|
||||
%xdefine _bn_mod_exp_base_2_consttime _ %+ BORINGSSL_PREFIX %+ _bn_mod_exp_base_2_consttime
|
||||
%xdefine _bn_mod_exp_mont_small _ %+ BORINGSSL_PREFIX %+ _bn_mod_exp_mont_small
|
||||
%xdefine _bn_mod_inverse0_prime_mont_small _ %+ BORINGSSL_PREFIX %+ _bn_mod_inverse0_prime_mont_small
|
||||
%xdefine _bn_mod_inverse_consttime _ %+ BORINGSSL_PREFIX %+ _bn_mod_inverse_consttime
|
||||
%xdefine _bn_mod_inverse_prime _ %+ BORINGSSL_PREFIX %+ _bn_mod_inverse_prime
|
||||
%xdefine _bn_mod_inverse_prime_mont_small _ %+ BORINGSSL_PREFIX %+ _bn_mod_inverse_prime_mont_small
|
||||
%xdefine _bn_mod_inverse_secret_prime _ %+ BORINGSSL_PREFIX %+ _bn_mod_inverse_secret_prime
|
||||
%xdefine _bn_mod_lshift1_consttime _ %+ BORINGSSL_PREFIX %+ _bn_mod_lshift1_consttime
|
||||
%xdefine _bn_mod_lshift_consttime _ %+ BORINGSSL_PREFIX %+ _bn_mod_lshift_consttime
|
||||
@@ -2326,20 +2369,24 @@
|
||||
%xdefine _d2i_X509_fp _ %+ BORINGSSL_PREFIX %+ _d2i_X509_fp
|
||||
%xdefine _dsa_asn1_meth _ %+ BORINGSSL_PREFIX %+ _dsa_asn1_meth
|
||||
%xdefine _ec_GFp_mont_add _ %+ BORINGSSL_PREFIX %+ _ec_GFp_mont_add
|
||||
%xdefine _ec_GFp_mont_bignum_to_felem _ %+ BORINGSSL_PREFIX %+ _ec_GFp_mont_bignum_to_felem
|
||||
%xdefine _ec_GFp_mont_dbl _ %+ BORINGSSL_PREFIX %+ _ec_GFp_mont_dbl
|
||||
%xdefine _ec_GFp_mont_felem_from_bytes _ %+ BORINGSSL_PREFIX %+ _ec_GFp_mont_felem_from_bytes
|
||||
%xdefine _ec_GFp_mont_felem_mul _ %+ BORINGSSL_PREFIX %+ _ec_GFp_mont_felem_mul
|
||||
%xdefine _ec_GFp_mont_felem_sqr _ %+ BORINGSSL_PREFIX %+ _ec_GFp_mont_felem_sqr
|
||||
%xdefine _ec_GFp_mont_felem_to_bignum _ %+ BORINGSSL_PREFIX %+ _ec_GFp_mont_felem_to_bignum
|
||||
%xdefine _ec_GFp_mont_felem_to_bytes _ %+ BORINGSSL_PREFIX %+ _ec_GFp_mont_felem_to_bytes
|
||||
%xdefine _ec_GFp_mont_group_finish _ %+ BORINGSSL_PREFIX %+ _ec_GFp_mont_group_finish
|
||||
%xdefine _ec_GFp_mont_group_init _ %+ BORINGSSL_PREFIX %+ _ec_GFp_mont_group_init
|
||||
%xdefine _ec_GFp_mont_group_set_curve _ %+ BORINGSSL_PREFIX %+ _ec_GFp_mont_group_set_curve
|
||||
%xdefine _ec_GFp_mont_init_precomp _ %+ BORINGSSL_PREFIX %+ _ec_GFp_mont_init_precomp
|
||||
%xdefine _ec_GFp_mont_mul _ %+ BORINGSSL_PREFIX %+ _ec_GFp_mont_mul
|
||||
%xdefine _ec_GFp_mont_mul_base _ %+ BORINGSSL_PREFIX %+ _ec_GFp_mont_mul_base
|
||||
%xdefine _ec_GFp_mont_mul_public _ %+ BORINGSSL_PREFIX %+ _ec_GFp_mont_mul_public
|
||||
%xdefine _ec_GFp_mont_mul_batch _ %+ BORINGSSL_PREFIX %+ _ec_GFp_mont_mul_batch
|
||||
%xdefine _ec_GFp_mont_mul_precomp _ %+ BORINGSSL_PREFIX %+ _ec_GFp_mont_mul_precomp
|
||||
%xdefine _ec_GFp_mont_mul_public_batch _ %+ BORINGSSL_PREFIX %+ _ec_GFp_mont_mul_public_batch
|
||||
%xdefine _ec_GFp_nistp_recode_scalar_bits _ %+ BORINGSSL_PREFIX %+ _ec_GFp_nistp_recode_scalar_bits
|
||||
%xdefine _ec_GFp_simple_cmp _ %+ BORINGSSL_PREFIX %+ _ec_GFp_simple_cmp
|
||||
%xdefine _ec_GFp_simple_cmp_x_coordinate _ %+ BORINGSSL_PREFIX %+ _ec_GFp_simple_cmp_x_coordinate
|
||||
%xdefine _ec_GFp_simple_felem_from_bytes _ %+ BORINGSSL_PREFIX %+ _ec_GFp_simple_felem_from_bytes
|
||||
%xdefine _ec_GFp_simple_felem_to_bytes _ %+ BORINGSSL_PREFIX %+ _ec_GFp_simple_felem_to_bytes
|
||||
%xdefine _ec_GFp_simple_group_finish _ %+ BORINGSSL_PREFIX %+ _ec_GFp_simple_group_finish
|
||||
%xdefine _ec_GFp_simple_group_get_curve _ %+ BORINGSSL_PREFIX %+ _ec_GFp_simple_group_get_curve
|
||||
%xdefine _ec_GFp_simple_group_init _ %+ BORINGSSL_PREFIX %+ _ec_GFp_simple_group_init
|
||||
@@ -2347,11 +2394,13 @@
|
||||
%xdefine _ec_GFp_simple_invert _ %+ BORINGSSL_PREFIX %+ _ec_GFp_simple_invert
|
||||
%xdefine _ec_GFp_simple_is_at_infinity _ %+ BORINGSSL_PREFIX %+ _ec_GFp_simple_is_at_infinity
|
||||
%xdefine _ec_GFp_simple_is_on_curve _ %+ BORINGSSL_PREFIX %+ _ec_GFp_simple_is_on_curve
|
||||
%xdefine _ec_GFp_simple_mont_inv_mod_ord_vartime _ %+ BORINGSSL_PREFIX %+ _ec_GFp_simple_mont_inv_mod_ord_vartime
|
||||
%xdefine _ec_GFp_simple_point_copy _ %+ BORINGSSL_PREFIX %+ _ec_GFp_simple_point_copy
|
||||
%xdefine _ec_GFp_simple_point_init _ %+ BORINGSSL_PREFIX %+ _ec_GFp_simple_point_init
|
||||
%xdefine _ec_GFp_simple_point_set_affine_coordinates _ %+ BORINGSSL_PREFIX %+ _ec_GFp_simple_point_set_affine_coordinates
|
||||
%xdefine _ec_GFp_simple_point_set_to_infinity _ %+ BORINGSSL_PREFIX %+ _ec_GFp_simple_point_set_to_infinity
|
||||
%xdefine _ec_GFp_simple_points_equal _ %+ BORINGSSL_PREFIX %+ _ec_GFp_simple_points_equal
|
||||
%xdefine _ec_affine_jacobian_equal _ %+ BORINGSSL_PREFIX %+ _ec_affine_jacobian_equal
|
||||
%xdefine _ec_affine_select _ %+ BORINGSSL_PREFIX %+ _ec_affine_select
|
||||
%xdefine _ec_affine_to_jacobian _ %+ BORINGSSL_PREFIX %+ _ec_affine_to_jacobian
|
||||
%xdefine _ec_asn1_meth _ %+ BORINGSSL_PREFIX %+ _ec_asn1_meth
|
||||
%xdefine _ec_bignum_to_felem _ %+ BORINGSSL_PREFIX %+ _ec_bignum_to_felem
|
||||
%xdefine _ec_bignum_to_scalar _ %+ BORINGSSL_PREFIX %+ _ec_bignum_to_scalar
|
||||
@@ -2359,30 +2408,53 @@
|
||||
%xdefine _ec_compute_wNAF _ %+ BORINGSSL_PREFIX %+ _ec_compute_wNAF
|
||||
%xdefine _ec_felem_add _ %+ BORINGSSL_PREFIX %+ _ec_felem_add
|
||||
%xdefine _ec_felem_equal _ %+ BORINGSSL_PREFIX %+ _ec_felem_equal
|
||||
%xdefine _ec_felem_from_bytes _ %+ BORINGSSL_PREFIX %+ _ec_felem_from_bytes
|
||||
%xdefine _ec_felem_neg _ %+ BORINGSSL_PREFIX %+ _ec_felem_neg
|
||||
%xdefine _ec_felem_non_zero_mask _ %+ BORINGSSL_PREFIX %+ _ec_felem_non_zero_mask
|
||||
%xdefine _ec_felem_select _ %+ BORINGSSL_PREFIX %+ _ec_felem_select
|
||||
%xdefine _ec_felem_sub _ %+ BORINGSSL_PREFIX %+ _ec_felem_sub
|
||||
%xdefine _ec_felem_to_bignum _ %+ BORINGSSL_PREFIX %+ _ec_felem_to_bignum
|
||||
%xdefine _ec_felem_to_bytes _ %+ BORINGSSL_PREFIX %+ _ec_felem_to_bytes
|
||||
%xdefine _ec_get_x_coordinate_as_bytes _ %+ BORINGSSL_PREFIX %+ _ec_get_x_coordinate_as_bytes
|
||||
%xdefine _ec_get_x_coordinate_as_scalar _ %+ BORINGSSL_PREFIX %+ _ec_get_x_coordinate_as_scalar
|
||||
%xdefine _ec_group_new _ %+ BORINGSSL_PREFIX %+ _ec_group_new
|
||||
%xdefine _ec_hash_to_curve_p384_xmd_sha512_sswu_draft07 _ %+ BORINGSSL_PREFIX %+ _ec_hash_to_curve_p384_xmd_sha512_sswu_draft07
|
||||
%xdefine _ec_hash_to_curve_p521_xmd_sha512_sswu_draft06 _ %+ BORINGSSL_PREFIX %+ _ec_hash_to_curve_p521_xmd_sha512_sswu_draft06
|
||||
%xdefine _ec_hash_to_scalar_p384_xmd_sha512_draft07 _ %+ BORINGSSL_PREFIX %+ _ec_hash_to_scalar_p384_xmd_sha512_draft07
|
||||
%xdefine _ec_hash_to_scalar_p521_xmd_sha512_draft06 _ %+ BORINGSSL_PREFIX %+ _ec_hash_to_scalar_p521_xmd_sha512_draft06
|
||||
%xdefine _ec_init_precomp _ %+ BORINGSSL_PREFIX %+ _ec_init_precomp
|
||||
%xdefine _ec_jacobian_to_affine _ %+ BORINGSSL_PREFIX %+ _ec_jacobian_to_affine
|
||||
%xdefine _ec_jacobian_to_affine_batch _ %+ BORINGSSL_PREFIX %+ _ec_jacobian_to_affine_batch
|
||||
%xdefine _ec_pkey_meth _ %+ BORINGSSL_PREFIX %+ _ec_pkey_meth
|
||||
%xdefine _ec_point_get_affine_coordinate_bytes _ %+ BORINGSSL_PREFIX %+ _ec_point_get_affine_coordinate_bytes
|
||||
%xdefine _ec_point_from_uncompressed _ %+ BORINGSSL_PREFIX %+ _ec_point_from_uncompressed
|
||||
%xdefine _ec_point_mul_scalar _ %+ BORINGSSL_PREFIX %+ _ec_point_mul_scalar
|
||||
%xdefine _ec_point_mul_scalar_base _ %+ BORINGSSL_PREFIX %+ _ec_point_mul_scalar_base
|
||||
%xdefine _ec_point_mul_scalar_batch _ %+ BORINGSSL_PREFIX %+ _ec_point_mul_scalar_batch
|
||||
%xdefine _ec_point_mul_scalar_precomp _ %+ BORINGSSL_PREFIX %+ _ec_point_mul_scalar_precomp
|
||||
%xdefine _ec_point_mul_scalar_public _ %+ BORINGSSL_PREFIX %+ _ec_point_mul_scalar_public
|
||||
%xdefine _ec_point_mul_scalar_public_batch _ %+ BORINGSSL_PREFIX %+ _ec_point_mul_scalar_public_batch
|
||||
%xdefine _ec_point_select _ %+ BORINGSSL_PREFIX %+ _ec_point_select
|
||||
%xdefine _ec_point_set_affine_coordinates _ %+ BORINGSSL_PREFIX %+ _ec_point_set_affine_coordinates
|
||||
%xdefine _ec_point_to_bytes _ %+ BORINGSSL_PREFIX %+ _ec_point_to_bytes
|
||||
%xdefine _ec_precomp_select _ %+ BORINGSSL_PREFIX %+ _ec_precomp_select
|
||||
%xdefine _ec_random_nonzero_scalar _ %+ BORINGSSL_PREFIX %+ _ec_random_nonzero_scalar
|
||||
%xdefine _ec_scalar_add _ %+ BORINGSSL_PREFIX %+ _ec_scalar_add
|
||||
%xdefine _ec_scalar_equal_vartime _ %+ BORINGSSL_PREFIX %+ _ec_scalar_equal_vartime
|
||||
%xdefine _ec_scalar_from_bytes _ %+ BORINGSSL_PREFIX %+ _ec_scalar_from_bytes
|
||||
%xdefine _ec_scalar_from_montgomery _ %+ BORINGSSL_PREFIX %+ _ec_scalar_from_montgomery
|
||||
%xdefine _ec_scalar_inv_montgomery _ %+ BORINGSSL_PREFIX %+ _ec_scalar_inv_montgomery
|
||||
%xdefine _ec_scalar_inv_montgomery_vartime _ %+ BORINGSSL_PREFIX %+ _ec_scalar_inv_montgomery_vartime
|
||||
%xdefine _ec_scalar_inv0_montgomery _ %+ BORINGSSL_PREFIX %+ _ec_scalar_inv0_montgomery
|
||||
%xdefine _ec_scalar_is_zero _ %+ BORINGSSL_PREFIX %+ _ec_scalar_is_zero
|
||||
%xdefine _ec_scalar_mul_montgomery _ %+ BORINGSSL_PREFIX %+ _ec_scalar_mul_montgomery
|
||||
%xdefine _ec_scalar_neg _ %+ BORINGSSL_PREFIX %+ _ec_scalar_neg
|
||||
%xdefine _ec_scalar_reduce _ %+ BORINGSSL_PREFIX %+ _ec_scalar_reduce
|
||||
%xdefine _ec_scalar_select _ %+ BORINGSSL_PREFIX %+ _ec_scalar_select
|
||||
%xdefine _ec_scalar_sub _ %+ BORINGSSL_PREFIX %+ _ec_scalar_sub
|
||||
%xdefine _ec_scalar_to_bytes _ %+ BORINGSSL_PREFIX %+ _ec_scalar_to_bytes
|
||||
%xdefine _ec_scalar_to_montgomery _ %+ BORINGSSL_PREFIX %+ _ec_scalar_to_montgomery
|
||||
%xdefine _ec_simple_scalar_inv_montgomery _ %+ BORINGSSL_PREFIX %+ _ec_simple_scalar_inv_montgomery
|
||||
%xdefine _ec_scalar_to_montgomery_inv_vartime _ %+ BORINGSSL_PREFIX %+ _ec_scalar_to_montgomery_inv_vartime
|
||||
%xdefine _ec_set_to_safe_point _ %+ BORINGSSL_PREFIX %+ _ec_set_to_safe_point
|
||||
%xdefine _ec_simple_scalar_inv0_montgomery _ %+ BORINGSSL_PREFIX %+ _ec_simple_scalar_inv0_montgomery
|
||||
%xdefine _ec_simple_scalar_to_montgomery_inv_vartime _ %+ BORINGSSL_PREFIX %+ _ec_simple_scalar_to_montgomery_inv_vartime
|
||||
%xdefine _ecp_nistz256_avx2_select_w7 _ %+ BORINGSSL_PREFIX %+ _ecp_nistz256_avx2_select_w7
|
||||
%xdefine _ecp_nistz256_mul_mont _ %+ BORINGSSL_PREFIX %+ _ecp_nistz256_mul_mont
|
||||
%xdefine _ecp_nistz256_neg _ %+ BORINGSSL_PREFIX %+ _ecp_nistz256_neg
|
||||
@@ -2584,6 +2656,21 @@
|
||||
%xdefine _pkcs7_bundle _ %+ BORINGSSL_PREFIX %+ _pkcs7_bundle
|
||||
%xdefine _pkcs7_parse_header _ %+ BORINGSSL_PREFIX %+ _pkcs7_parse_header
|
||||
%xdefine _pkcs8_pbe_decrypt _ %+ BORINGSSL_PREFIX %+ _pkcs8_pbe_decrypt
|
||||
%xdefine _pmbtoken_exp0_blind _ %+ BORINGSSL_PREFIX %+ _pmbtoken_exp0_blind
|
||||
%xdefine _pmbtoken_exp0_client_key_from_bytes _ %+ BORINGSSL_PREFIX %+ _pmbtoken_exp0_client_key_from_bytes
|
||||
%xdefine _pmbtoken_exp0_generate_key _ %+ BORINGSSL_PREFIX %+ _pmbtoken_exp0_generate_key
|
||||
%xdefine _pmbtoken_exp0_issuer_key_from_bytes _ %+ BORINGSSL_PREFIX %+ _pmbtoken_exp0_issuer_key_from_bytes
|
||||
%xdefine _pmbtoken_exp0_read _ %+ BORINGSSL_PREFIX %+ _pmbtoken_exp0_read
|
||||
%xdefine _pmbtoken_exp0_sign _ %+ BORINGSSL_PREFIX %+ _pmbtoken_exp0_sign
|
||||
%xdefine _pmbtoken_exp0_unblind _ %+ BORINGSSL_PREFIX %+ _pmbtoken_exp0_unblind
|
||||
%xdefine _pmbtoken_exp1_blind _ %+ BORINGSSL_PREFIX %+ _pmbtoken_exp1_blind
|
||||
%xdefine _pmbtoken_exp1_client_key_from_bytes _ %+ BORINGSSL_PREFIX %+ _pmbtoken_exp1_client_key_from_bytes
|
||||
%xdefine _pmbtoken_exp1_generate_key _ %+ BORINGSSL_PREFIX %+ _pmbtoken_exp1_generate_key
|
||||
%xdefine _pmbtoken_exp1_get_h_for_testing _ %+ BORINGSSL_PREFIX %+ _pmbtoken_exp1_get_h_for_testing
|
||||
%xdefine _pmbtoken_exp1_issuer_key_from_bytes _ %+ BORINGSSL_PREFIX %+ _pmbtoken_exp1_issuer_key_from_bytes
|
||||
%xdefine _pmbtoken_exp1_read _ %+ BORINGSSL_PREFIX %+ _pmbtoken_exp1_read
|
||||
%xdefine _pmbtoken_exp1_sign _ %+ BORINGSSL_PREFIX %+ _pmbtoken_exp1_sign
|
||||
%xdefine _pmbtoken_exp1_unblind _ %+ BORINGSSL_PREFIX %+ _pmbtoken_exp1_unblind
|
||||
%xdefine _policy_cache_find_data _ %+ BORINGSSL_PREFIX %+ _policy_cache_find_data
|
||||
%xdefine _policy_cache_free _ %+ BORINGSSL_PREFIX %+ _policy_cache_free
|
||||
%xdefine _policy_cache_set _ %+ BORINGSSL_PREFIX %+ _policy_cache_set
|
||||
@@ -2983,6 +3070,7 @@
|
||||
%xdefine BIO_write_filename BORINGSSL_PREFIX %+ _BIO_write_filename
|
||||
%xdefine BN_BLINDING_convert BORINGSSL_PREFIX %+ _BN_BLINDING_convert
|
||||
%xdefine BN_BLINDING_free BORINGSSL_PREFIX %+ _BN_BLINDING_free
|
||||
%xdefine BN_BLINDING_invalidate BORINGSSL_PREFIX %+ _BN_BLINDING_invalidate
|
||||
%xdefine BN_BLINDING_invert BORINGSSL_PREFIX %+ _BN_BLINDING_invert
|
||||
%xdefine BN_BLINDING_new BORINGSSL_PREFIX %+ _BN_BLINDING_new
|
||||
%xdefine BN_CTX_end BORINGSSL_PREFIX %+ _BN_CTX_end
|
||||
@@ -3246,6 +3334,7 @@
|
||||
%xdefine CRYPTO_cleanup_all_ex_data BORINGSSL_PREFIX %+ _CRYPTO_cleanup_all_ex_data
|
||||
%xdefine CRYPTO_ctr128_encrypt BORINGSSL_PREFIX %+ _CRYPTO_ctr128_encrypt
|
||||
%xdefine CRYPTO_ctr128_encrypt_ctr32 BORINGSSL_PREFIX %+ _CRYPTO_ctr128_encrypt_ctr32
|
||||
%xdefine CRYPTO_fork_detect_ignore_madv_wipeonfork_for_testing BORINGSSL_PREFIX %+ _CRYPTO_fork_detect_ignore_madv_wipeonfork_for_testing
|
||||
%xdefine CRYPTO_free_ex_data BORINGSSL_PREFIX %+ _CRYPTO_free_ex_data
|
||||
%xdefine CRYPTO_gcm128_aad BORINGSSL_PREFIX %+ _CRYPTO_gcm128_aad
|
||||
%xdefine CRYPTO_gcm128_decrypt BORINGSSL_PREFIX %+ _CRYPTO_gcm128_decrypt
|
||||
@@ -3261,12 +3350,14 @@
|
||||
%xdefine CRYPTO_get_dynlock_lock_callback BORINGSSL_PREFIX %+ _CRYPTO_get_dynlock_lock_callback
|
||||
%xdefine CRYPTO_get_ex_data BORINGSSL_PREFIX %+ _CRYPTO_get_ex_data
|
||||
%xdefine CRYPTO_get_ex_new_index BORINGSSL_PREFIX %+ _CRYPTO_get_ex_new_index
|
||||
%xdefine CRYPTO_get_fork_generation BORINGSSL_PREFIX %+ _CRYPTO_get_fork_generation
|
||||
%xdefine CRYPTO_get_lock_name BORINGSSL_PREFIX %+ _CRYPTO_get_lock_name
|
||||
%xdefine CRYPTO_get_locking_callback BORINGSSL_PREFIX %+ _CRYPTO_get_locking_callback
|
||||
%xdefine CRYPTO_get_thread_local BORINGSSL_PREFIX %+ _CRYPTO_get_thread_local
|
||||
%xdefine CRYPTO_ghash_init BORINGSSL_PREFIX %+ _CRYPTO_ghash_init
|
||||
%xdefine CRYPTO_has_asm BORINGSSL_PREFIX %+ _CRYPTO_has_asm
|
||||
%xdefine CRYPTO_hchacha20 BORINGSSL_PREFIX %+ _CRYPTO_hchacha20
|
||||
%xdefine CRYPTO_init_sysrand BORINGSSL_PREFIX %+ _CRYPTO_init_sysrand
|
||||
%xdefine CRYPTO_is_ARMv8_AES_capable BORINGSSL_PREFIX %+ _CRYPTO_is_ARMv8_AES_capable
|
||||
%xdefine CRYPTO_is_ARMv8_PMULL_capable BORINGSSL_PREFIX %+ _CRYPTO_is_ARMv8_PMULL_capable
|
||||
%xdefine CRYPTO_is_NEON_capable_at_runtime BORINGSSL_PREFIX %+ _CRYPTO_is_NEON_capable_at_runtime
|
||||
@@ -3281,6 +3372,7 @@
|
||||
%xdefine CRYPTO_poly1305_finish BORINGSSL_PREFIX %+ _CRYPTO_poly1305_finish
|
||||
%xdefine CRYPTO_poly1305_init BORINGSSL_PREFIX %+ _CRYPTO_poly1305_init
|
||||
%xdefine CRYPTO_poly1305_update BORINGSSL_PREFIX %+ _CRYPTO_poly1305_update
|
||||
%xdefine CRYPTO_pre_sandbox_init BORINGSSL_PREFIX %+ _CRYPTO_pre_sandbox_init
|
||||
%xdefine CRYPTO_rdrand BORINGSSL_PREFIX %+ _CRYPTO_rdrand
|
||||
%xdefine CRYPTO_rdrand_multiple8_buf BORINGSSL_PREFIX %+ _CRYPTO_rdrand_multiple8_buf
|
||||
%xdefine CRYPTO_refcount_dec_and_test_zero BORINGSSL_PREFIX %+ _CRYPTO_refcount_dec_and_test_zero
|
||||
@@ -3294,6 +3386,7 @@
|
||||
%xdefine CRYPTO_set_locking_callback BORINGSSL_PREFIX %+ _CRYPTO_set_locking_callback
|
||||
%xdefine CRYPTO_set_thread_local BORINGSSL_PREFIX %+ _CRYPTO_set_thread_local
|
||||
%xdefine CRYPTO_sysrand BORINGSSL_PREFIX %+ _CRYPTO_sysrand
|
||||
%xdefine CRYPTO_sysrand_if_available BORINGSSL_PREFIX %+ _CRYPTO_sysrand_if_available
|
||||
%xdefine CRYPTO_tls1_prf BORINGSSL_PREFIX %+ _CRYPTO_tls1_prf
|
||||
%xdefine CTR_DRBG_clear BORINGSSL_PREFIX %+ _CTR_DRBG_clear
|
||||
%xdefine CTR_DRBG_generate BORINGSSL_PREFIX %+ _CTR_DRBG_generate
|
||||
@@ -3316,8 +3409,13 @@
|
||||
%xdefine DH_free BORINGSSL_PREFIX %+ _DH_free
|
||||
%xdefine DH_generate_key BORINGSSL_PREFIX %+ _DH_generate_key
|
||||
%xdefine DH_generate_parameters_ex BORINGSSL_PREFIX %+ _DH_generate_parameters_ex
|
||||
%xdefine DH_get0_g BORINGSSL_PREFIX %+ _DH_get0_g
|
||||
%xdefine DH_get0_key BORINGSSL_PREFIX %+ _DH_get0_key
|
||||
%xdefine DH_get0_p BORINGSSL_PREFIX %+ _DH_get0_p
|
||||
%xdefine DH_get0_pqg BORINGSSL_PREFIX %+ _DH_get0_pqg
|
||||
%xdefine DH_get0_priv_key BORINGSSL_PREFIX %+ _DH_get0_priv_key
|
||||
%xdefine DH_get0_pub_key BORINGSSL_PREFIX %+ _DH_get0_pub_key
|
||||
%xdefine DH_get0_q BORINGSSL_PREFIX %+ _DH_get0_q
|
||||
%xdefine DH_get_ex_data BORINGSSL_PREFIX %+ _DH_get_ex_data
|
||||
%xdefine DH_get_ex_new_index BORINGSSL_PREFIX %+ _DH_get_ex_new_index
|
||||
%xdefine DH_marshal_parameters BORINGSSL_PREFIX %+ _DH_marshal_parameters
|
||||
@@ -3327,6 +3425,7 @@
|
||||
%xdefine DH_set0_key BORINGSSL_PREFIX %+ _DH_set0_key
|
||||
%xdefine DH_set0_pqg BORINGSSL_PREFIX %+ _DH_set0_pqg
|
||||
%xdefine DH_set_ex_data BORINGSSL_PREFIX %+ _DH_set_ex_data
|
||||
%xdefine DH_set_length BORINGSSL_PREFIX %+ _DH_set_length
|
||||
%xdefine DH_size BORINGSSL_PREFIX %+ _DH_size
|
||||
%xdefine DH_up_ref BORINGSSL_PREFIX %+ _DH_up_ref
|
||||
%xdefine DHparams_dup BORINGSSL_PREFIX %+ _DHparams_dup
|
||||
@@ -3355,8 +3454,13 @@
|
||||
%xdefine DSA_free BORINGSSL_PREFIX %+ _DSA_free
|
||||
%xdefine DSA_generate_key BORINGSSL_PREFIX %+ _DSA_generate_key
|
||||
%xdefine DSA_generate_parameters_ex BORINGSSL_PREFIX %+ _DSA_generate_parameters_ex
|
||||
%xdefine DSA_get0_g BORINGSSL_PREFIX %+ _DSA_get0_g
|
||||
%xdefine DSA_get0_key BORINGSSL_PREFIX %+ _DSA_get0_key
|
||||
%xdefine DSA_get0_p BORINGSSL_PREFIX %+ _DSA_get0_p
|
||||
%xdefine DSA_get0_pqg BORINGSSL_PREFIX %+ _DSA_get0_pqg
|
||||
%xdefine DSA_get0_priv_key BORINGSSL_PREFIX %+ _DSA_get0_priv_key
|
||||
%xdefine DSA_get0_pub_key BORINGSSL_PREFIX %+ _DSA_get0_pub_key
|
||||
%xdefine DSA_get0_q BORINGSSL_PREFIX %+ _DSA_get0_q
|
||||
%xdefine DSA_get_ex_data BORINGSSL_PREFIX %+ _DSA_get_ex_data
|
||||
%xdefine DSA_get_ex_new_index BORINGSSL_PREFIX %+ _DSA_get_ex_new_index
|
||||
%xdefine DSA_marshal_parameters BORINGSSL_PREFIX %+ _DSA_marshal_parameters
|
||||
@@ -3785,6 +3889,7 @@
|
||||
%xdefine EVP_sha256 BORINGSSL_PREFIX %+ _EVP_sha256
|
||||
%xdefine EVP_sha384 BORINGSSL_PREFIX %+ _EVP_sha384
|
||||
%xdefine EVP_sha512 BORINGSSL_PREFIX %+ _EVP_sha512
|
||||
%xdefine EVP_sha512_256 BORINGSSL_PREFIX %+ _EVP_sha512_256
|
||||
%xdefine EVP_tls_cbc_copy_mac BORINGSSL_PREFIX %+ _EVP_tls_cbc_copy_mac
|
||||
%xdefine EVP_tls_cbc_digest_record BORINGSSL_PREFIX %+ _EVP_tls_cbc_digest_record
|
||||
%xdefine EVP_tls_cbc_record_digest_supported BORINGSSL_PREFIX %+ _EVP_tls_cbc_record_digest_supported
|
||||
@@ -4063,6 +4168,7 @@
|
||||
%xdefine PKEY_USAGE_PERIOD_free BORINGSSL_PREFIX %+ _PKEY_USAGE_PERIOD_free
|
||||
%xdefine PKEY_USAGE_PERIOD_it BORINGSSL_PREFIX %+ _PKEY_USAGE_PERIOD_it
|
||||
%xdefine PKEY_USAGE_PERIOD_new BORINGSSL_PREFIX %+ _PKEY_USAGE_PERIOD_new
|
||||
%xdefine PMBTOKEN_PRETOKEN_free BORINGSSL_PREFIX %+ _PMBTOKEN_PRETOKEN_free
|
||||
%xdefine POLICYINFO_free BORINGSSL_PREFIX %+ _POLICYINFO_free
|
||||
%xdefine POLICYINFO_it BORINGSSL_PREFIX %+ _POLICYINFO_it
|
||||
%xdefine POLICYINFO_new BORINGSSL_PREFIX %+ _POLICYINFO_new
|
||||
@@ -4096,7 +4202,6 @@
|
||||
%xdefine RAND_pseudo_bytes BORINGSSL_PREFIX %+ _RAND_pseudo_bytes
|
||||
%xdefine RAND_seed BORINGSSL_PREFIX %+ _RAND_seed
|
||||
%xdefine RAND_set_rand_method BORINGSSL_PREFIX %+ _RAND_set_rand_method
|
||||
%xdefine RAND_set_urandom_fd BORINGSSL_PREFIX %+ _RAND_set_urandom_fd
|
||||
%xdefine RAND_status BORINGSSL_PREFIX %+ _RAND_status
|
||||
%xdefine RC4 BORINGSSL_PREFIX %+ _RC4
|
||||
%xdefine RC4_set_key BORINGSSL_PREFIX %+ _RC4_set_key
|
||||
@@ -4189,6 +4294,10 @@
|
||||
%xdefine SHA384_Init BORINGSSL_PREFIX %+ _SHA384_Init
|
||||
%xdefine SHA384_Update BORINGSSL_PREFIX %+ _SHA384_Update
|
||||
%xdefine SHA512 BORINGSSL_PREFIX %+ _SHA512
|
||||
%xdefine SHA512_256 BORINGSSL_PREFIX %+ _SHA512_256
|
||||
%xdefine SHA512_256_Final BORINGSSL_PREFIX %+ _SHA512_256_Final
|
||||
%xdefine SHA512_256_Init BORINGSSL_PREFIX %+ _SHA512_256_Init
|
||||
%xdefine SHA512_256_Update BORINGSSL_PREFIX %+ _SHA512_256_Update
|
||||
%xdefine SHA512_Final BORINGSSL_PREFIX %+ _SHA512_Final
|
||||
%xdefine SHA512_Init BORINGSSL_PREFIX %+ _SHA512_Init
|
||||
%xdefine SHA512_Transform BORINGSSL_PREFIX %+ _SHA512_Transform
|
||||
@@ -4212,7 +4321,27 @@
|
||||
%xdefine SXNET_get_id_ulong BORINGSSL_PREFIX %+ _SXNET_get_id_ulong
|
||||
%xdefine SXNET_it BORINGSSL_PREFIX %+ _SXNET_it
|
||||
%xdefine SXNET_new BORINGSSL_PREFIX %+ _SXNET_new
|
||||
%xdefine TRUST_TOKEN_CLIENT_add_key BORINGSSL_PREFIX %+ _TRUST_TOKEN_CLIENT_add_key
|
||||
%xdefine TRUST_TOKEN_CLIENT_begin_issuance BORINGSSL_PREFIX %+ _TRUST_TOKEN_CLIENT_begin_issuance
|
||||
%xdefine TRUST_TOKEN_CLIENT_begin_redemption BORINGSSL_PREFIX %+ _TRUST_TOKEN_CLIENT_begin_redemption
|
||||
%xdefine TRUST_TOKEN_CLIENT_finish_issuance BORINGSSL_PREFIX %+ _TRUST_TOKEN_CLIENT_finish_issuance
|
||||
%xdefine TRUST_TOKEN_CLIENT_finish_redemption BORINGSSL_PREFIX %+ _TRUST_TOKEN_CLIENT_finish_redemption
|
||||
%xdefine TRUST_TOKEN_CLIENT_free BORINGSSL_PREFIX %+ _TRUST_TOKEN_CLIENT_free
|
||||
%xdefine TRUST_TOKEN_CLIENT_new BORINGSSL_PREFIX %+ _TRUST_TOKEN_CLIENT_new
|
||||
%xdefine TRUST_TOKEN_CLIENT_set_srr_key BORINGSSL_PREFIX %+ _TRUST_TOKEN_CLIENT_set_srr_key
|
||||
%xdefine TRUST_TOKEN_ISSUER_add_key BORINGSSL_PREFIX %+ _TRUST_TOKEN_ISSUER_add_key
|
||||
%xdefine TRUST_TOKEN_ISSUER_free BORINGSSL_PREFIX %+ _TRUST_TOKEN_ISSUER_free
|
||||
%xdefine TRUST_TOKEN_ISSUER_issue BORINGSSL_PREFIX %+ _TRUST_TOKEN_ISSUER_issue
|
||||
%xdefine TRUST_TOKEN_ISSUER_new BORINGSSL_PREFIX %+ _TRUST_TOKEN_ISSUER_new
|
||||
%xdefine TRUST_TOKEN_ISSUER_redeem BORINGSSL_PREFIX %+ _TRUST_TOKEN_ISSUER_redeem
|
||||
%xdefine TRUST_TOKEN_ISSUER_set_metadata_key BORINGSSL_PREFIX %+ _TRUST_TOKEN_ISSUER_set_metadata_key
|
||||
%xdefine TRUST_TOKEN_ISSUER_set_srr_key BORINGSSL_PREFIX %+ _TRUST_TOKEN_ISSUER_set_srr_key
|
||||
%xdefine TRUST_TOKEN_decode_private_metadata BORINGSSL_PREFIX %+ _TRUST_TOKEN_decode_private_metadata
|
||||
%xdefine TRUST_TOKEN_experiment_v0 BORINGSSL_PREFIX %+ _TRUST_TOKEN_experiment_v0
|
||||
%xdefine TRUST_TOKEN_experiment_v1 BORINGSSL_PREFIX %+ _TRUST_TOKEN_experiment_v1
|
||||
%xdefine TRUST_TOKEN_free BORINGSSL_PREFIX %+ _TRUST_TOKEN_free
|
||||
%xdefine TRUST_TOKEN_generate_key BORINGSSL_PREFIX %+ _TRUST_TOKEN_generate_key
|
||||
%xdefine TRUST_TOKEN_new BORINGSSL_PREFIX %+ _TRUST_TOKEN_new
|
||||
%xdefine USERNOTICE_free BORINGSSL_PREFIX %+ _USERNOTICE_free
|
||||
%xdefine USERNOTICE_it BORINGSSL_PREFIX %+ _USERNOTICE_it
|
||||
%xdefine USERNOTICE_new BORINGSSL_PREFIX %+ _USERNOTICE_new
|
||||
@@ -4488,6 +4617,7 @@
|
||||
%xdefine X509_STORE_CTX_cleanup BORINGSSL_PREFIX %+ _X509_STORE_CTX_cleanup
|
||||
%xdefine X509_STORE_CTX_free BORINGSSL_PREFIX %+ _X509_STORE_CTX_free
|
||||
%xdefine X509_STORE_CTX_get0_cert BORINGSSL_PREFIX %+ _X509_STORE_CTX_get0_cert
|
||||
%xdefine X509_STORE_CTX_get0_chain BORINGSSL_PREFIX %+ _X509_STORE_CTX_get0_chain
|
||||
%xdefine X509_STORE_CTX_get0_current_crl BORINGSSL_PREFIX %+ _X509_STORE_CTX_get0_current_crl
|
||||
%xdefine X509_STORE_CTX_get0_current_issuer BORINGSSL_PREFIX %+ _X509_STORE_CTX_get0_current_issuer
|
||||
%xdefine X509_STORE_CTX_get0_param BORINGSSL_PREFIX %+ _X509_STORE_CTX_get0_param
|
||||
@@ -4819,9 +4949,9 @@
|
||||
%xdefine bn_mod_add_words BORINGSSL_PREFIX %+ _bn_mod_add_words
|
||||
%xdefine bn_mod_exp_base_2_consttime BORINGSSL_PREFIX %+ _bn_mod_exp_base_2_consttime
|
||||
%xdefine bn_mod_exp_mont_small BORINGSSL_PREFIX %+ _bn_mod_exp_mont_small
|
||||
%xdefine bn_mod_inverse0_prime_mont_small BORINGSSL_PREFIX %+ _bn_mod_inverse0_prime_mont_small
|
||||
%xdefine bn_mod_inverse_consttime BORINGSSL_PREFIX %+ _bn_mod_inverse_consttime
|
||||
%xdefine bn_mod_inverse_prime BORINGSSL_PREFIX %+ _bn_mod_inverse_prime
|
||||
%xdefine bn_mod_inverse_prime_mont_small BORINGSSL_PREFIX %+ _bn_mod_inverse_prime_mont_small
|
||||
%xdefine bn_mod_inverse_secret_prime BORINGSSL_PREFIX %+ _bn_mod_inverse_secret_prime
|
||||
%xdefine bn_mod_lshift1_consttime BORINGSSL_PREFIX %+ _bn_mod_lshift1_consttime
|
||||
%xdefine bn_mod_lshift_consttime BORINGSSL_PREFIX %+ _bn_mod_lshift_consttime
|
||||
@@ -5006,20 +5136,24 @@
|
||||
%xdefine d2i_X509_fp BORINGSSL_PREFIX %+ _d2i_X509_fp
|
||||
%xdefine dsa_asn1_meth BORINGSSL_PREFIX %+ _dsa_asn1_meth
|
||||
%xdefine ec_GFp_mont_add BORINGSSL_PREFIX %+ _ec_GFp_mont_add
|
||||
%xdefine ec_GFp_mont_bignum_to_felem BORINGSSL_PREFIX %+ _ec_GFp_mont_bignum_to_felem
|
||||
%xdefine ec_GFp_mont_dbl BORINGSSL_PREFIX %+ _ec_GFp_mont_dbl
|
||||
%xdefine ec_GFp_mont_felem_from_bytes BORINGSSL_PREFIX %+ _ec_GFp_mont_felem_from_bytes
|
||||
%xdefine ec_GFp_mont_felem_mul BORINGSSL_PREFIX %+ _ec_GFp_mont_felem_mul
|
||||
%xdefine ec_GFp_mont_felem_sqr BORINGSSL_PREFIX %+ _ec_GFp_mont_felem_sqr
|
||||
%xdefine ec_GFp_mont_felem_to_bignum BORINGSSL_PREFIX %+ _ec_GFp_mont_felem_to_bignum
|
||||
%xdefine ec_GFp_mont_felem_to_bytes BORINGSSL_PREFIX %+ _ec_GFp_mont_felem_to_bytes
|
||||
%xdefine ec_GFp_mont_group_finish BORINGSSL_PREFIX %+ _ec_GFp_mont_group_finish
|
||||
%xdefine ec_GFp_mont_group_init BORINGSSL_PREFIX %+ _ec_GFp_mont_group_init
|
||||
%xdefine ec_GFp_mont_group_set_curve BORINGSSL_PREFIX %+ _ec_GFp_mont_group_set_curve
|
||||
%xdefine ec_GFp_mont_init_precomp BORINGSSL_PREFIX %+ _ec_GFp_mont_init_precomp
|
||||
%xdefine ec_GFp_mont_mul BORINGSSL_PREFIX %+ _ec_GFp_mont_mul
|
||||
%xdefine ec_GFp_mont_mul_base BORINGSSL_PREFIX %+ _ec_GFp_mont_mul_base
|
||||
%xdefine ec_GFp_mont_mul_public BORINGSSL_PREFIX %+ _ec_GFp_mont_mul_public
|
||||
%xdefine ec_GFp_mont_mul_batch BORINGSSL_PREFIX %+ _ec_GFp_mont_mul_batch
|
||||
%xdefine ec_GFp_mont_mul_precomp BORINGSSL_PREFIX %+ _ec_GFp_mont_mul_precomp
|
||||
%xdefine ec_GFp_mont_mul_public_batch BORINGSSL_PREFIX %+ _ec_GFp_mont_mul_public_batch
|
||||
%xdefine ec_GFp_nistp_recode_scalar_bits BORINGSSL_PREFIX %+ _ec_GFp_nistp_recode_scalar_bits
|
||||
%xdefine ec_GFp_simple_cmp BORINGSSL_PREFIX %+ _ec_GFp_simple_cmp
|
||||
%xdefine ec_GFp_simple_cmp_x_coordinate BORINGSSL_PREFIX %+ _ec_GFp_simple_cmp_x_coordinate
|
||||
%xdefine ec_GFp_simple_felem_from_bytes BORINGSSL_PREFIX %+ _ec_GFp_simple_felem_from_bytes
|
||||
%xdefine ec_GFp_simple_felem_to_bytes BORINGSSL_PREFIX %+ _ec_GFp_simple_felem_to_bytes
|
||||
%xdefine ec_GFp_simple_group_finish BORINGSSL_PREFIX %+ _ec_GFp_simple_group_finish
|
||||
%xdefine ec_GFp_simple_group_get_curve BORINGSSL_PREFIX %+ _ec_GFp_simple_group_get_curve
|
||||
%xdefine ec_GFp_simple_group_init BORINGSSL_PREFIX %+ _ec_GFp_simple_group_init
|
||||
@@ -5027,11 +5161,13 @@
|
||||
%xdefine ec_GFp_simple_invert BORINGSSL_PREFIX %+ _ec_GFp_simple_invert
|
||||
%xdefine ec_GFp_simple_is_at_infinity BORINGSSL_PREFIX %+ _ec_GFp_simple_is_at_infinity
|
||||
%xdefine ec_GFp_simple_is_on_curve BORINGSSL_PREFIX %+ _ec_GFp_simple_is_on_curve
|
||||
%xdefine ec_GFp_simple_mont_inv_mod_ord_vartime BORINGSSL_PREFIX %+ _ec_GFp_simple_mont_inv_mod_ord_vartime
|
||||
%xdefine ec_GFp_simple_point_copy BORINGSSL_PREFIX %+ _ec_GFp_simple_point_copy
|
||||
%xdefine ec_GFp_simple_point_init BORINGSSL_PREFIX %+ _ec_GFp_simple_point_init
|
||||
%xdefine ec_GFp_simple_point_set_affine_coordinates BORINGSSL_PREFIX %+ _ec_GFp_simple_point_set_affine_coordinates
|
||||
%xdefine ec_GFp_simple_point_set_to_infinity BORINGSSL_PREFIX %+ _ec_GFp_simple_point_set_to_infinity
|
||||
%xdefine ec_GFp_simple_points_equal BORINGSSL_PREFIX %+ _ec_GFp_simple_points_equal
|
||||
%xdefine ec_affine_jacobian_equal BORINGSSL_PREFIX %+ _ec_affine_jacobian_equal
|
||||
%xdefine ec_affine_select BORINGSSL_PREFIX %+ _ec_affine_select
|
||||
%xdefine ec_affine_to_jacobian BORINGSSL_PREFIX %+ _ec_affine_to_jacobian
|
||||
%xdefine ec_asn1_meth BORINGSSL_PREFIX %+ _ec_asn1_meth
|
||||
%xdefine ec_bignum_to_felem BORINGSSL_PREFIX %+ _ec_bignum_to_felem
|
||||
%xdefine ec_bignum_to_scalar BORINGSSL_PREFIX %+ _ec_bignum_to_scalar
|
||||
@@ -5039,30 +5175,53 @@
|
||||
%xdefine ec_compute_wNAF BORINGSSL_PREFIX %+ _ec_compute_wNAF
|
||||
%xdefine ec_felem_add BORINGSSL_PREFIX %+ _ec_felem_add
|
||||
%xdefine ec_felem_equal BORINGSSL_PREFIX %+ _ec_felem_equal
|
||||
%xdefine ec_felem_from_bytes BORINGSSL_PREFIX %+ _ec_felem_from_bytes
|
||||
%xdefine ec_felem_neg BORINGSSL_PREFIX %+ _ec_felem_neg
|
||||
%xdefine ec_felem_non_zero_mask BORINGSSL_PREFIX %+ _ec_felem_non_zero_mask
|
||||
%xdefine ec_felem_select BORINGSSL_PREFIX %+ _ec_felem_select
|
||||
%xdefine ec_felem_sub BORINGSSL_PREFIX %+ _ec_felem_sub
|
||||
%xdefine ec_felem_to_bignum BORINGSSL_PREFIX %+ _ec_felem_to_bignum
|
||||
%xdefine ec_felem_to_bytes BORINGSSL_PREFIX %+ _ec_felem_to_bytes
|
||||
%xdefine ec_get_x_coordinate_as_bytes BORINGSSL_PREFIX %+ _ec_get_x_coordinate_as_bytes
|
||||
%xdefine ec_get_x_coordinate_as_scalar BORINGSSL_PREFIX %+ _ec_get_x_coordinate_as_scalar
|
||||
%xdefine ec_group_new BORINGSSL_PREFIX %+ _ec_group_new
|
||||
%xdefine ec_hash_to_curve_p384_xmd_sha512_sswu_draft07 BORINGSSL_PREFIX %+ _ec_hash_to_curve_p384_xmd_sha512_sswu_draft07
|
||||
%xdefine ec_hash_to_curve_p521_xmd_sha512_sswu_draft06 BORINGSSL_PREFIX %+ _ec_hash_to_curve_p521_xmd_sha512_sswu_draft06
|
||||
%xdefine ec_hash_to_scalar_p384_xmd_sha512_draft07 BORINGSSL_PREFIX %+ _ec_hash_to_scalar_p384_xmd_sha512_draft07
|
||||
%xdefine ec_hash_to_scalar_p521_xmd_sha512_draft06 BORINGSSL_PREFIX %+ _ec_hash_to_scalar_p521_xmd_sha512_draft06
|
||||
%xdefine ec_init_precomp BORINGSSL_PREFIX %+ _ec_init_precomp
|
||||
%xdefine ec_jacobian_to_affine BORINGSSL_PREFIX %+ _ec_jacobian_to_affine
|
||||
%xdefine ec_jacobian_to_affine_batch BORINGSSL_PREFIX %+ _ec_jacobian_to_affine_batch
|
||||
%xdefine ec_pkey_meth BORINGSSL_PREFIX %+ _ec_pkey_meth
|
||||
%xdefine ec_point_get_affine_coordinate_bytes BORINGSSL_PREFIX %+ _ec_point_get_affine_coordinate_bytes
|
||||
%xdefine ec_point_from_uncompressed BORINGSSL_PREFIX %+ _ec_point_from_uncompressed
|
||||
%xdefine ec_point_mul_scalar BORINGSSL_PREFIX %+ _ec_point_mul_scalar
|
||||
%xdefine ec_point_mul_scalar_base BORINGSSL_PREFIX %+ _ec_point_mul_scalar_base
|
||||
%xdefine ec_point_mul_scalar_batch BORINGSSL_PREFIX %+ _ec_point_mul_scalar_batch
|
||||
%xdefine ec_point_mul_scalar_precomp BORINGSSL_PREFIX %+ _ec_point_mul_scalar_precomp
|
||||
%xdefine ec_point_mul_scalar_public BORINGSSL_PREFIX %+ _ec_point_mul_scalar_public
|
||||
%xdefine ec_point_mul_scalar_public_batch BORINGSSL_PREFIX %+ _ec_point_mul_scalar_public_batch
|
||||
%xdefine ec_point_select BORINGSSL_PREFIX %+ _ec_point_select
|
||||
%xdefine ec_point_set_affine_coordinates BORINGSSL_PREFIX %+ _ec_point_set_affine_coordinates
|
||||
%xdefine ec_point_to_bytes BORINGSSL_PREFIX %+ _ec_point_to_bytes
|
||||
%xdefine ec_precomp_select BORINGSSL_PREFIX %+ _ec_precomp_select
|
||||
%xdefine ec_random_nonzero_scalar BORINGSSL_PREFIX %+ _ec_random_nonzero_scalar
|
||||
%xdefine ec_scalar_add BORINGSSL_PREFIX %+ _ec_scalar_add
|
||||
%xdefine ec_scalar_equal_vartime BORINGSSL_PREFIX %+ _ec_scalar_equal_vartime
|
||||
%xdefine ec_scalar_from_bytes BORINGSSL_PREFIX %+ _ec_scalar_from_bytes
|
||||
%xdefine ec_scalar_from_montgomery BORINGSSL_PREFIX %+ _ec_scalar_from_montgomery
|
||||
%xdefine ec_scalar_inv_montgomery BORINGSSL_PREFIX %+ _ec_scalar_inv_montgomery
|
||||
%xdefine ec_scalar_inv_montgomery_vartime BORINGSSL_PREFIX %+ _ec_scalar_inv_montgomery_vartime
|
||||
%xdefine ec_scalar_inv0_montgomery BORINGSSL_PREFIX %+ _ec_scalar_inv0_montgomery
|
||||
%xdefine ec_scalar_is_zero BORINGSSL_PREFIX %+ _ec_scalar_is_zero
|
||||
%xdefine ec_scalar_mul_montgomery BORINGSSL_PREFIX %+ _ec_scalar_mul_montgomery
|
||||
%xdefine ec_scalar_neg BORINGSSL_PREFIX %+ _ec_scalar_neg
|
||||
%xdefine ec_scalar_reduce BORINGSSL_PREFIX %+ _ec_scalar_reduce
|
||||
%xdefine ec_scalar_select BORINGSSL_PREFIX %+ _ec_scalar_select
|
||||
%xdefine ec_scalar_sub BORINGSSL_PREFIX %+ _ec_scalar_sub
|
||||
%xdefine ec_scalar_to_bytes BORINGSSL_PREFIX %+ _ec_scalar_to_bytes
|
||||
%xdefine ec_scalar_to_montgomery BORINGSSL_PREFIX %+ _ec_scalar_to_montgomery
|
||||
%xdefine ec_simple_scalar_inv_montgomery BORINGSSL_PREFIX %+ _ec_simple_scalar_inv_montgomery
|
||||
%xdefine ec_scalar_to_montgomery_inv_vartime BORINGSSL_PREFIX %+ _ec_scalar_to_montgomery_inv_vartime
|
||||
%xdefine ec_set_to_safe_point BORINGSSL_PREFIX %+ _ec_set_to_safe_point
|
||||
%xdefine ec_simple_scalar_inv0_montgomery BORINGSSL_PREFIX %+ _ec_simple_scalar_inv0_montgomery
|
||||
%xdefine ec_simple_scalar_to_montgomery_inv_vartime BORINGSSL_PREFIX %+ _ec_simple_scalar_to_montgomery_inv_vartime
|
||||
%xdefine ecp_nistz256_avx2_select_w7 BORINGSSL_PREFIX %+ _ecp_nistz256_avx2_select_w7
|
||||
%xdefine ecp_nistz256_mul_mont BORINGSSL_PREFIX %+ _ecp_nistz256_mul_mont
|
||||
%xdefine ecp_nistz256_neg BORINGSSL_PREFIX %+ _ecp_nistz256_neg
|
||||
@@ -5264,6 +5423,21 @@
|
||||
%xdefine pkcs7_bundle BORINGSSL_PREFIX %+ _pkcs7_bundle
|
||||
%xdefine pkcs7_parse_header BORINGSSL_PREFIX %+ _pkcs7_parse_header
|
||||
%xdefine pkcs8_pbe_decrypt BORINGSSL_PREFIX %+ _pkcs8_pbe_decrypt
|
||||
%xdefine pmbtoken_exp0_blind BORINGSSL_PREFIX %+ _pmbtoken_exp0_blind
|
||||
%xdefine pmbtoken_exp0_client_key_from_bytes BORINGSSL_PREFIX %+ _pmbtoken_exp0_client_key_from_bytes
|
||||
%xdefine pmbtoken_exp0_generate_key BORINGSSL_PREFIX %+ _pmbtoken_exp0_generate_key
|
||||
%xdefine pmbtoken_exp0_issuer_key_from_bytes BORINGSSL_PREFIX %+ _pmbtoken_exp0_issuer_key_from_bytes
|
||||
%xdefine pmbtoken_exp0_read BORINGSSL_PREFIX %+ _pmbtoken_exp0_read
|
||||
%xdefine pmbtoken_exp0_sign BORINGSSL_PREFIX %+ _pmbtoken_exp0_sign
|
||||
%xdefine pmbtoken_exp0_unblind BORINGSSL_PREFIX %+ _pmbtoken_exp0_unblind
|
||||
%xdefine pmbtoken_exp1_blind BORINGSSL_PREFIX %+ _pmbtoken_exp1_blind
|
||||
%xdefine pmbtoken_exp1_client_key_from_bytes BORINGSSL_PREFIX %+ _pmbtoken_exp1_client_key_from_bytes
|
||||
%xdefine pmbtoken_exp1_generate_key BORINGSSL_PREFIX %+ _pmbtoken_exp1_generate_key
|
||||
%xdefine pmbtoken_exp1_get_h_for_testing BORINGSSL_PREFIX %+ _pmbtoken_exp1_get_h_for_testing
|
||||
%xdefine pmbtoken_exp1_issuer_key_from_bytes BORINGSSL_PREFIX %+ _pmbtoken_exp1_issuer_key_from_bytes
|
||||
%xdefine pmbtoken_exp1_read BORINGSSL_PREFIX %+ _pmbtoken_exp1_read
|
||||
%xdefine pmbtoken_exp1_sign BORINGSSL_PREFIX %+ _pmbtoken_exp1_sign
|
||||
%xdefine pmbtoken_exp1_unblind BORINGSSL_PREFIX %+ _pmbtoken_exp1_unblind
|
||||
%xdefine policy_cache_find_data BORINGSSL_PREFIX %+ _policy_cache_find_data
|
||||
%xdefine policy_cache_free BORINGSSL_PREFIX %+ _policy_cache_free
|
||||
%xdefine policy_cache_set BORINGSSL_PREFIX %+ _policy_cache_set
|
||||
|
||||
+245
-175
@@ -1,17 +1,28 @@
|
||||
/* Autogenerated */
|
||||
/* Autogenerated: src/ExtractionOCaml/unsaturated_solinas --static 25519 10 '2^255 - 19' 32 carry_mul carry_square carry add sub opp selectznz to_bytes from_bytes carry_scmul121666 */
|
||||
/* curve description: 25519 */
|
||||
/* requested operations: carry_mul, carry_square, carry_scmul121666, carry, add, sub, opp, selectznz, to_bytes, from_bytes */
|
||||
/* requested operations: carry_mul, carry_square, carry, add, sub, opp, selectznz, to_bytes, from_bytes, carry_scmul121666 */
|
||||
/* n = 10 (from "10") */
|
||||
/* s = 0x8000000000000000000000000000000000000000000000000000000000000000 (from "2^255") */
|
||||
/* c = [(1, 19)] (from "1,19") */
|
||||
/* s-c = 2^255 - [(1, 19)] (from "2^255 - 19") */
|
||||
/* machine_wordsize = 32 (from "32") */
|
||||
|
||||
/* Computed values: */
|
||||
/* carry_chain = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1] */
|
||||
|
||||
#include <stdint.h>
|
||||
typedef unsigned char fiat_25519_uint1;
|
||||
typedef signed char fiat_25519_int1;
|
||||
|
||||
#if (-1 & 3) != 3
|
||||
#error "This code only works on a two's complement system"
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* The function fiat_25519_addcarryx_u26 is an addition with carry.
|
||||
* Postconditions:
|
||||
* out1 = (arg1 + arg2 + arg3) mod 2^26
|
||||
* out2 = ⌊(arg1 + arg2 + arg3) / 2^26⌋
|
||||
*
|
||||
* Input Bounds:
|
||||
* arg1: [0x0 ~> 0x1]
|
||||
* arg2: [0x0 ~> 0x3ffffff]
|
||||
@@ -29,6 +40,11 @@ static void fiat_25519_addcarryx_u26(uint32_t* out1, fiat_25519_uint1* out2, fia
|
||||
}
|
||||
|
||||
/*
|
||||
* The function fiat_25519_subborrowx_u26 is a subtraction with borrow.
|
||||
* Postconditions:
|
||||
* out1 = (-arg1 + arg2 + -arg3) mod 2^26
|
||||
* out2 = -⌊(-arg1 + arg2 + -arg3) / 2^26⌋
|
||||
*
|
||||
* Input Bounds:
|
||||
* arg1: [0x0 ~> 0x1]
|
||||
* arg2: [0x0 ~> 0x3ffffff]
|
||||
@@ -46,6 +62,11 @@ static void fiat_25519_subborrowx_u26(uint32_t* out1, fiat_25519_uint1* out2, fi
|
||||
}
|
||||
|
||||
/*
|
||||
* The function fiat_25519_addcarryx_u25 is an addition with carry.
|
||||
* Postconditions:
|
||||
* out1 = (arg1 + arg2 + arg3) mod 2^25
|
||||
* out2 = ⌊(arg1 + arg2 + arg3) / 2^25⌋
|
||||
*
|
||||
* Input Bounds:
|
||||
* arg1: [0x0 ~> 0x1]
|
||||
* arg2: [0x0 ~> 0x1ffffff]
|
||||
@@ -63,6 +84,11 @@ static void fiat_25519_addcarryx_u25(uint32_t* out1, fiat_25519_uint1* out2, fia
|
||||
}
|
||||
|
||||
/*
|
||||
* The function fiat_25519_subborrowx_u25 is a subtraction with borrow.
|
||||
* Postconditions:
|
||||
* out1 = (-arg1 + arg2 + -arg3) mod 2^25
|
||||
* out2 = -⌊(-arg1 + arg2 + -arg3) / 2^25⌋
|
||||
*
|
||||
* Input Bounds:
|
||||
* arg1: [0x0 ~> 0x1]
|
||||
* arg2: [0x0 ~> 0x1ffffff]
|
||||
@@ -80,6 +106,10 @@ static void fiat_25519_subborrowx_u25(uint32_t* out1, fiat_25519_uint1* out2, fi
|
||||
}
|
||||
|
||||
/*
|
||||
* The function fiat_25519_cmovznz_u32 is a single-word conditional move.
|
||||
* Postconditions:
|
||||
* out1 = (if arg1 = 0 then arg2 else arg3)
|
||||
*
|
||||
* Input Bounds:
|
||||
* arg1: [0x0 ~> 0x1]
|
||||
* arg2: [0x0 ~> 0xffffffff]
|
||||
@@ -101,6 +131,10 @@ static void fiat_25519_cmovznz_u32(uint32_t* out1, fiat_25519_uint1 arg1, uint32
|
||||
}
|
||||
|
||||
/*
|
||||
* The function fiat_25519_carry_mul multiplies two field elements and reduces the result.
|
||||
* Postconditions:
|
||||
* eval out1 mod m = (eval arg1 * eval arg2) mod m
|
||||
*
|
||||
* Input Bounds:
|
||||
* arg1: [[0x0 ~> 0xd333332], [0x0 ~> 0x6999999], [0x0 ~> 0xd333332], [0x0 ~> 0x6999999], [0x0 ~> 0xd333332], [0x0 ~> 0x6999999], [0x0 ~> 0xd333332], [0x0 ~> 0x6999999], [0x0 ~> 0xd333332], [0x0 ~> 0x6999999]]
|
||||
* arg2: [[0x0 ~> 0xd333332], [0x0 ~> 0x6999999], [0x0 ~> 0xd333332], [0x0 ~> 0x6999999], [0x0 ~> 0xd333332], [0x0 ~> 0x6999999], [0x0 ~> 0xd333332], [0x0 ~> 0x6999999], [0x0 ~> 0xd333332], [0x0 ~> 0x6999999]]
|
||||
@@ -108,65 +142,65 @@ static void fiat_25519_cmovznz_u32(uint32_t* out1, fiat_25519_uint1 arg1, uint32
|
||||
* out1: [[0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333]]
|
||||
*/
|
||||
static void fiat_25519_carry_mul(uint32_t out1[10], const uint32_t arg1[10], const uint32_t arg2[10]) {
|
||||
uint64_t x1 = ((uint64_t)(arg1[9]) * ((arg2[9]) * ((uint32_t)0x2 * UINT8_C(0x13))));
|
||||
uint64_t x2 = ((uint64_t)(arg1[9]) * ((arg2[8]) * (uint32_t)UINT8_C(0x13)));
|
||||
uint64_t x3 = ((uint64_t)(arg1[9]) * ((arg2[7]) * ((uint32_t)0x2 * UINT8_C(0x13))));
|
||||
uint64_t x4 = ((uint64_t)(arg1[9]) * ((arg2[6]) * (uint32_t)UINT8_C(0x13)));
|
||||
uint64_t x5 = ((uint64_t)(arg1[9]) * ((arg2[5]) * ((uint32_t)0x2 * UINT8_C(0x13))));
|
||||
uint64_t x6 = ((uint64_t)(arg1[9]) * ((arg2[4]) * (uint32_t)UINT8_C(0x13)));
|
||||
uint64_t x7 = ((uint64_t)(arg1[9]) * ((arg2[3]) * ((uint32_t)0x2 * UINT8_C(0x13))));
|
||||
uint64_t x8 = ((uint64_t)(arg1[9]) * ((arg2[2]) * (uint32_t)UINT8_C(0x13)));
|
||||
uint64_t x9 = ((uint64_t)(arg1[9]) * ((arg2[1]) * ((uint32_t)0x2 * UINT8_C(0x13))));
|
||||
uint64_t x10 = ((uint64_t)(arg1[8]) * ((arg2[9]) * (uint32_t)UINT8_C(0x13)));
|
||||
uint64_t x11 = ((uint64_t)(arg1[8]) * ((arg2[8]) * (uint32_t)UINT8_C(0x13)));
|
||||
uint64_t x12 = ((uint64_t)(arg1[8]) * ((arg2[7]) * (uint32_t)UINT8_C(0x13)));
|
||||
uint64_t x13 = ((uint64_t)(arg1[8]) * ((arg2[6]) * (uint32_t)UINT8_C(0x13)));
|
||||
uint64_t x14 = ((uint64_t)(arg1[8]) * ((arg2[5]) * (uint32_t)UINT8_C(0x13)));
|
||||
uint64_t x15 = ((uint64_t)(arg1[8]) * ((arg2[4]) * (uint32_t)UINT8_C(0x13)));
|
||||
uint64_t x16 = ((uint64_t)(arg1[8]) * ((arg2[3]) * (uint32_t)UINT8_C(0x13)));
|
||||
uint64_t x17 = ((uint64_t)(arg1[8]) * ((arg2[2]) * (uint32_t)UINT8_C(0x13)));
|
||||
uint64_t x18 = ((uint64_t)(arg1[7]) * ((arg2[9]) * ((uint32_t)0x2 * UINT8_C(0x13))));
|
||||
uint64_t x19 = ((uint64_t)(arg1[7]) * ((arg2[8]) * (uint32_t)UINT8_C(0x13)));
|
||||
uint64_t x20 = ((uint64_t)(arg1[7]) * ((arg2[7]) * ((uint32_t)0x2 * UINT8_C(0x13))));
|
||||
uint64_t x21 = ((uint64_t)(arg1[7]) * ((arg2[6]) * (uint32_t)UINT8_C(0x13)));
|
||||
uint64_t x22 = ((uint64_t)(arg1[7]) * ((arg2[5]) * ((uint32_t)0x2 * UINT8_C(0x13))));
|
||||
uint64_t x23 = ((uint64_t)(arg1[7]) * ((arg2[4]) * (uint32_t)UINT8_C(0x13)));
|
||||
uint64_t x24 = ((uint64_t)(arg1[7]) * ((arg2[3]) * ((uint32_t)0x2 * UINT8_C(0x13))));
|
||||
uint64_t x25 = ((uint64_t)(arg1[6]) * ((arg2[9]) * (uint32_t)UINT8_C(0x13)));
|
||||
uint64_t x26 = ((uint64_t)(arg1[6]) * ((arg2[8]) * (uint32_t)UINT8_C(0x13)));
|
||||
uint64_t x27 = ((uint64_t)(arg1[6]) * ((arg2[7]) * (uint32_t)UINT8_C(0x13)));
|
||||
uint64_t x28 = ((uint64_t)(arg1[6]) * ((arg2[6]) * (uint32_t)UINT8_C(0x13)));
|
||||
uint64_t x29 = ((uint64_t)(arg1[6]) * ((arg2[5]) * (uint32_t)UINT8_C(0x13)));
|
||||
uint64_t x30 = ((uint64_t)(arg1[6]) * ((arg2[4]) * (uint32_t)UINT8_C(0x13)));
|
||||
uint64_t x31 = ((uint64_t)(arg1[5]) * ((arg2[9]) * ((uint32_t)0x2 * UINT8_C(0x13))));
|
||||
uint64_t x32 = ((uint64_t)(arg1[5]) * ((arg2[8]) * (uint32_t)UINT8_C(0x13)));
|
||||
uint64_t x33 = ((uint64_t)(arg1[5]) * ((arg2[7]) * ((uint32_t)0x2 * UINT8_C(0x13))));
|
||||
uint64_t x34 = ((uint64_t)(arg1[5]) * ((arg2[6]) * (uint32_t)UINT8_C(0x13)));
|
||||
uint64_t x35 = ((uint64_t)(arg1[5]) * ((arg2[5]) * ((uint32_t)0x2 * UINT8_C(0x13))));
|
||||
uint64_t x36 = ((uint64_t)(arg1[4]) * ((arg2[9]) * (uint32_t)UINT8_C(0x13)));
|
||||
uint64_t x37 = ((uint64_t)(arg1[4]) * ((arg2[8]) * (uint32_t)UINT8_C(0x13)));
|
||||
uint64_t x38 = ((uint64_t)(arg1[4]) * ((arg2[7]) * (uint32_t)UINT8_C(0x13)));
|
||||
uint64_t x39 = ((uint64_t)(arg1[4]) * ((arg2[6]) * (uint32_t)UINT8_C(0x13)));
|
||||
uint64_t x40 = ((uint64_t)(arg1[3]) * ((arg2[9]) * ((uint32_t)0x2 * UINT8_C(0x13))));
|
||||
uint64_t x41 = ((uint64_t)(arg1[3]) * ((arg2[8]) * (uint32_t)UINT8_C(0x13)));
|
||||
uint64_t x42 = ((uint64_t)(arg1[3]) * ((arg2[7]) * ((uint32_t)0x2 * UINT8_C(0x13))));
|
||||
uint64_t x43 = ((uint64_t)(arg1[2]) * ((arg2[9]) * (uint32_t)UINT8_C(0x13)));
|
||||
uint64_t x44 = ((uint64_t)(arg1[2]) * ((arg2[8]) * (uint32_t)UINT8_C(0x13)));
|
||||
uint64_t x45 = ((uint64_t)(arg1[1]) * ((arg2[9]) * ((uint32_t)0x2 * UINT8_C(0x13))));
|
||||
uint64_t x1 = ((uint64_t)(arg1[9]) * ((arg2[9]) * UINT8_C(0x26)));
|
||||
uint64_t x2 = ((uint64_t)(arg1[9]) * ((arg2[8]) * UINT8_C(0x13)));
|
||||
uint64_t x3 = ((uint64_t)(arg1[9]) * ((arg2[7]) * UINT8_C(0x26)));
|
||||
uint64_t x4 = ((uint64_t)(arg1[9]) * ((arg2[6]) * UINT8_C(0x13)));
|
||||
uint64_t x5 = ((uint64_t)(arg1[9]) * ((arg2[5]) * UINT8_C(0x26)));
|
||||
uint64_t x6 = ((uint64_t)(arg1[9]) * ((arg2[4]) * UINT8_C(0x13)));
|
||||
uint64_t x7 = ((uint64_t)(arg1[9]) * ((arg2[3]) * UINT8_C(0x26)));
|
||||
uint64_t x8 = ((uint64_t)(arg1[9]) * ((arg2[2]) * UINT8_C(0x13)));
|
||||
uint64_t x9 = ((uint64_t)(arg1[9]) * ((arg2[1]) * UINT8_C(0x26)));
|
||||
uint64_t x10 = ((uint64_t)(arg1[8]) * ((arg2[9]) * UINT8_C(0x13)));
|
||||
uint64_t x11 = ((uint64_t)(arg1[8]) * ((arg2[8]) * UINT8_C(0x13)));
|
||||
uint64_t x12 = ((uint64_t)(arg1[8]) * ((arg2[7]) * UINT8_C(0x13)));
|
||||
uint64_t x13 = ((uint64_t)(arg1[8]) * ((arg2[6]) * UINT8_C(0x13)));
|
||||
uint64_t x14 = ((uint64_t)(arg1[8]) * ((arg2[5]) * UINT8_C(0x13)));
|
||||
uint64_t x15 = ((uint64_t)(arg1[8]) * ((arg2[4]) * UINT8_C(0x13)));
|
||||
uint64_t x16 = ((uint64_t)(arg1[8]) * ((arg2[3]) * UINT8_C(0x13)));
|
||||
uint64_t x17 = ((uint64_t)(arg1[8]) * ((arg2[2]) * UINT8_C(0x13)));
|
||||
uint64_t x18 = ((uint64_t)(arg1[7]) * ((arg2[9]) * UINT8_C(0x26)));
|
||||
uint64_t x19 = ((uint64_t)(arg1[7]) * ((arg2[8]) * UINT8_C(0x13)));
|
||||
uint64_t x20 = ((uint64_t)(arg1[7]) * ((arg2[7]) * UINT8_C(0x26)));
|
||||
uint64_t x21 = ((uint64_t)(arg1[7]) * ((arg2[6]) * UINT8_C(0x13)));
|
||||
uint64_t x22 = ((uint64_t)(arg1[7]) * ((arg2[5]) * UINT8_C(0x26)));
|
||||
uint64_t x23 = ((uint64_t)(arg1[7]) * ((arg2[4]) * UINT8_C(0x13)));
|
||||
uint64_t x24 = ((uint64_t)(arg1[7]) * ((arg2[3]) * UINT8_C(0x26)));
|
||||
uint64_t x25 = ((uint64_t)(arg1[6]) * ((arg2[9]) * UINT8_C(0x13)));
|
||||
uint64_t x26 = ((uint64_t)(arg1[6]) * ((arg2[8]) * UINT8_C(0x13)));
|
||||
uint64_t x27 = ((uint64_t)(arg1[6]) * ((arg2[7]) * UINT8_C(0x13)));
|
||||
uint64_t x28 = ((uint64_t)(arg1[6]) * ((arg2[6]) * UINT8_C(0x13)));
|
||||
uint64_t x29 = ((uint64_t)(arg1[6]) * ((arg2[5]) * UINT8_C(0x13)));
|
||||
uint64_t x30 = ((uint64_t)(arg1[6]) * ((arg2[4]) * UINT8_C(0x13)));
|
||||
uint64_t x31 = ((uint64_t)(arg1[5]) * ((arg2[9]) * UINT8_C(0x26)));
|
||||
uint64_t x32 = ((uint64_t)(arg1[5]) * ((arg2[8]) * UINT8_C(0x13)));
|
||||
uint64_t x33 = ((uint64_t)(arg1[5]) * ((arg2[7]) * UINT8_C(0x26)));
|
||||
uint64_t x34 = ((uint64_t)(arg1[5]) * ((arg2[6]) * UINT8_C(0x13)));
|
||||
uint64_t x35 = ((uint64_t)(arg1[5]) * ((arg2[5]) * UINT8_C(0x26)));
|
||||
uint64_t x36 = ((uint64_t)(arg1[4]) * ((arg2[9]) * UINT8_C(0x13)));
|
||||
uint64_t x37 = ((uint64_t)(arg1[4]) * ((arg2[8]) * UINT8_C(0x13)));
|
||||
uint64_t x38 = ((uint64_t)(arg1[4]) * ((arg2[7]) * UINT8_C(0x13)));
|
||||
uint64_t x39 = ((uint64_t)(arg1[4]) * ((arg2[6]) * UINT8_C(0x13)));
|
||||
uint64_t x40 = ((uint64_t)(arg1[3]) * ((arg2[9]) * UINT8_C(0x26)));
|
||||
uint64_t x41 = ((uint64_t)(arg1[3]) * ((arg2[8]) * UINT8_C(0x13)));
|
||||
uint64_t x42 = ((uint64_t)(arg1[3]) * ((arg2[7]) * UINT8_C(0x26)));
|
||||
uint64_t x43 = ((uint64_t)(arg1[2]) * ((arg2[9]) * UINT8_C(0x13)));
|
||||
uint64_t x44 = ((uint64_t)(arg1[2]) * ((arg2[8]) * UINT8_C(0x13)));
|
||||
uint64_t x45 = ((uint64_t)(arg1[1]) * ((arg2[9]) * UINT8_C(0x26)));
|
||||
uint64_t x46 = ((uint64_t)(arg1[9]) * (arg2[0]));
|
||||
uint64_t x47 = ((uint64_t)(arg1[8]) * (arg2[1]));
|
||||
uint64_t x48 = ((uint64_t)(arg1[8]) * (arg2[0]));
|
||||
uint64_t x49 = ((uint64_t)(arg1[7]) * (arg2[2]));
|
||||
uint64_t x50 = ((uint64_t)(arg1[7]) * ((arg2[1]) * (uint32_t)0x2));
|
||||
uint64_t x50 = ((uint64_t)(arg1[7]) * ((arg2[1]) * 0x2));
|
||||
uint64_t x51 = ((uint64_t)(arg1[7]) * (arg2[0]));
|
||||
uint64_t x52 = ((uint64_t)(arg1[6]) * (arg2[3]));
|
||||
uint64_t x53 = ((uint64_t)(arg1[6]) * (arg2[2]));
|
||||
uint64_t x54 = ((uint64_t)(arg1[6]) * (arg2[1]));
|
||||
uint64_t x55 = ((uint64_t)(arg1[6]) * (arg2[0]));
|
||||
uint64_t x56 = ((uint64_t)(arg1[5]) * (arg2[4]));
|
||||
uint64_t x57 = ((uint64_t)(arg1[5]) * ((arg2[3]) * (uint32_t)0x2));
|
||||
uint64_t x57 = ((uint64_t)(arg1[5]) * ((arg2[3]) * 0x2));
|
||||
uint64_t x58 = ((uint64_t)(arg1[5]) * (arg2[2]));
|
||||
uint64_t x59 = ((uint64_t)(arg1[5]) * ((arg2[1]) * (uint32_t)0x2));
|
||||
uint64_t x59 = ((uint64_t)(arg1[5]) * ((arg2[1]) * 0x2));
|
||||
uint64_t x60 = ((uint64_t)(arg1[5]) * (arg2[0]));
|
||||
uint64_t x61 = ((uint64_t)(arg1[4]) * (arg2[5]));
|
||||
uint64_t x62 = ((uint64_t)(arg1[4]) * (arg2[4]));
|
||||
@@ -175,11 +209,11 @@ static void fiat_25519_carry_mul(uint32_t out1[10], const uint32_t arg1[10], con
|
||||
uint64_t x65 = ((uint64_t)(arg1[4]) * (arg2[1]));
|
||||
uint64_t x66 = ((uint64_t)(arg1[4]) * (arg2[0]));
|
||||
uint64_t x67 = ((uint64_t)(arg1[3]) * (arg2[6]));
|
||||
uint64_t x68 = ((uint64_t)(arg1[3]) * ((arg2[5]) * (uint32_t)0x2));
|
||||
uint64_t x68 = ((uint64_t)(arg1[3]) * ((arg2[5]) * 0x2));
|
||||
uint64_t x69 = ((uint64_t)(arg1[3]) * (arg2[4]));
|
||||
uint64_t x70 = ((uint64_t)(arg1[3]) * ((arg2[3]) * (uint32_t)0x2));
|
||||
uint64_t x70 = ((uint64_t)(arg1[3]) * ((arg2[3]) * 0x2));
|
||||
uint64_t x71 = ((uint64_t)(arg1[3]) * (arg2[2]));
|
||||
uint64_t x72 = ((uint64_t)(arg1[3]) * ((arg2[1]) * (uint32_t)0x2));
|
||||
uint64_t x72 = ((uint64_t)(arg1[3]) * ((arg2[1]) * 0x2));
|
||||
uint64_t x73 = ((uint64_t)(arg1[3]) * (arg2[0]));
|
||||
uint64_t x74 = ((uint64_t)(arg1[2]) * (arg2[7]));
|
||||
uint64_t x75 = ((uint64_t)(arg1[2]) * (arg2[6]));
|
||||
@@ -190,13 +224,13 @@ static void fiat_25519_carry_mul(uint32_t out1[10], const uint32_t arg1[10], con
|
||||
uint64_t x80 = ((uint64_t)(arg1[2]) * (arg2[1]));
|
||||
uint64_t x81 = ((uint64_t)(arg1[2]) * (arg2[0]));
|
||||
uint64_t x82 = ((uint64_t)(arg1[1]) * (arg2[8]));
|
||||
uint64_t x83 = ((uint64_t)(arg1[1]) * ((arg2[7]) * (uint32_t)0x2));
|
||||
uint64_t x83 = ((uint64_t)(arg1[1]) * ((arg2[7]) * 0x2));
|
||||
uint64_t x84 = ((uint64_t)(arg1[1]) * (arg2[6]));
|
||||
uint64_t x85 = ((uint64_t)(arg1[1]) * ((arg2[5]) * (uint32_t)0x2));
|
||||
uint64_t x85 = ((uint64_t)(arg1[1]) * ((arg2[5]) * 0x2));
|
||||
uint64_t x86 = ((uint64_t)(arg1[1]) * (arg2[4]));
|
||||
uint64_t x87 = ((uint64_t)(arg1[1]) * ((arg2[3]) * (uint32_t)0x2));
|
||||
uint64_t x87 = ((uint64_t)(arg1[1]) * ((arg2[3]) * 0x2));
|
||||
uint64_t x88 = ((uint64_t)(arg1[1]) * (arg2[2]));
|
||||
uint64_t x89 = ((uint64_t)(arg1[1]) * ((arg2[1]) * (uint32_t)0x2));
|
||||
uint64_t x89 = ((uint64_t)(arg1[1]) * ((arg2[1]) * 0x2));
|
||||
uint64_t x90 = ((uint64_t)(arg1[1]) * (arg2[0]));
|
||||
uint64_t x91 = ((uint64_t)(arg1[0]) * (arg2[9]));
|
||||
uint64_t x92 = ((uint64_t)(arg1[0]) * (arg2[8]));
|
||||
@@ -247,12 +281,12 @@ static void fiat_25519_carry_mul(uint32_t out1[10], const uint32_t arg1[10], con
|
||||
uint64_t x137 = (x135 + x104);
|
||||
uint64_t x138 = (x137 >> 25);
|
||||
uint32_t x139 = (uint32_t)(x137 & UINT32_C(0x1ffffff));
|
||||
uint64_t x140 = (x138 * (uint64_t)UINT8_C(0x13));
|
||||
uint64_t x140 = (x138 * UINT8_C(0x13));
|
||||
uint64_t x141 = (x103 + x140);
|
||||
uint32_t x142 = (uint32_t)(x141 >> 26);
|
||||
uint32_t x143 = (uint32_t)(x141 & UINT32_C(0x3ffffff));
|
||||
uint32_t x144 = (x142 + x115);
|
||||
uint32_t x145 = (x144 >> 25);
|
||||
fiat_25519_uint1 x145 = (fiat_25519_uint1)(x144 >> 25);
|
||||
uint32_t x146 = (x144 & UINT32_C(0x1ffffff));
|
||||
uint32_t x147 = (x145 + x118);
|
||||
out1[0] = x143;
|
||||
@@ -268,58 +302,62 @@ static void fiat_25519_carry_mul(uint32_t out1[10], const uint32_t arg1[10], con
|
||||
}
|
||||
|
||||
/*
|
||||
* The function fiat_25519_carry_square squares a field element and reduces the result.
|
||||
* Postconditions:
|
||||
* eval out1 mod m = (eval arg1 * eval arg1) mod m
|
||||
*
|
||||
* Input Bounds:
|
||||
* arg1: [[0x0 ~> 0xd333332], [0x0 ~> 0x6999999], [0x0 ~> 0xd333332], [0x0 ~> 0x6999999], [0x0 ~> 0xd333332], [0x0 ~> 0x6999999], [0x0 ~> 0xd333332], [0x0 ~> 0x6999999], [0x0 ~> 0xd333332], [0x0 ~> 0x6999999]]
|
||||
* Output Bounds:
|
||||
* out1: [[0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333]]
|
||||
*/
|
||||
static void fiat_25519_carry_square(uint32_t out1[10], const uint32_t arg1[10]) {
|
||||
uint32_t x1 = ((arg1[9]) * (uint32_t)UINT8_C(0x13));
|
||||
uint32_t x2 = (x1 * (uint32_t)0x2);
|
||||
uint32_t x3 = ((arg1[9]) * (uint32_t)0x2);
|
||||
uint32_t x4 = ((arg1[8]) * (uint32_t)UINT8_C(0x13));
|
||||
uint64_t x5 = (x4 * (uint64_t)0x2);
|
||||
uint32_t x6 = ((arg1[8]) * (uint32_t)0x2);
|
||||
uint32_t x7 = ((arg1[7]) * (uint32_t)UINT8_C(0x13));
|
||||
uint32_t x8 = (x7 * (uint32_t)0x2);
|
||||
uint32_t x9 = ((arg1[7]) * (uint32_t)0x2);
|
||||
uint32_t x10 = ((arg1[6]) * (uint32_t)UINT8_C(0x13));
|
||||
uint64_t x11 = (x10 * (uint64_t)0x2);
|
||||
uint32_t x12 = ((arg1[6]) * (uint32_t)0x2);
|
||||
uint32_t x13 = ((arg1[5]) * (uint32_t)UINT8_C(0x13));
|
||||
uint32_t x14 = ((arg1[5]) * (uint32_t)0x2);
|
||||
uint32_t x15 = ((arg1[4]) * (uint32_t)0x2);
|
||||
uint32_t x16 = ((arg1[3]) * (uint32_t)0x2);
|
||||
uint32_t x17 = ((arg1[2]) * (uint32_t)0x2);
|
||||
uint32_t x18 = ((arg1[1]) * (uint32_t)0x2);
|
||||
uint64_t x19 = ((uint64_t)(arg1[9]) * (x1 * (uint32_t)0x2));
|
||||
uint32_t x1 = ((arg1[9]) * UINT8_C(0x13));
|
||||
uint32_t x2 = (x1 * 0x2);
|
||||
uint32_t x3 = ((arg1[9]) * 0x2);
|
||||
uint32_t x4 = ((arg1[8]) * UINT8_C(0x13));
|
||||
uint64_t x5 = ((uint64_t)x4 * 0x2);
|
||||
uint32_t x6 = ((arg1[8]) * 0x2);
|
||||
uint32_t x7 = ((arg1[7]) * UINT8_C(0x13));
|
||||
uint32_t x8 = (x7 * 0x2);
|
||||
uint32_t x9 = ((arg1[7]) * 0x2);
|
||||
uint32_t x10 = ((arg1[6]) * UINT8_C(0x13));
|
||||
uint64_t x11 = ((uint64_t)x10 * 0x2);
|
||||
uint32_t x12 = ((arg1[6]) * 0x2);
|
||||
uint32_t x13 = ((arg1[5]) * UINT8_C(0x13));
|
||||
uint32_t x14 = ((arg1[5]) * 0x2);
|
||||
uint32_t x15 = ((arg1[4]) * 0x2);
|
||||
uint32_t x16 = ((arg1[3]) * 0x2);
|
||||
uint32_t x17 = ((arg1[2]) * 0x2);
|
||||
uint32_t x18 = ((arg1[1]) * 0x2);
|
||||
uint64_t x19 = ((uint64_t)(arg1[9]) * (x1 * 0x2));
|
||||
uint64_t x20 = ((uint64_t)(arg1[8]) * x2);
|
||||
uint64_t x21 = ((uint64_t)(arg1[8]) * x4);
|
||||
uint64_t x22 = ((arg1[7]) * (x2 * (uint64_t)0x2));
|
||||
uint64_t x22 = ((arg1[7]) * ((uint64_t)x2 * 0x2));
|
||||
uint64_t x23 = ((arg1[7]) * x5);
|
||||
uint64_t x24 = ((uint64_t)(arg1[7]) * (x7 * (uint32_t)0x2));
|
||||
uint64_t x24 = ((uint64_t)(arg1[7]) * (x7 * 0x2));
|
||||
uint64_t x25 = ((uint64_t)(arg1[6]) * x2);
|
||||
uint64_t x26 = ((arg1[6]) * x5);
|
||||
uint64_t x27 = ((uint64_t)(arg1[6]) * x8);
|
||||
uint64_t x28 = ((uint64_t)(arg1[6]) * x10);
|
||||
uint64_t x29 = ((arg1[5]) * (x2 * (uint64_t)0x2));
|
||||
uint64_t x29 = ((arg1[5]) * ((uint64_t)x2 * 0x2));
|
||||
uint64_t x30 = ((arg1[5]) * x5);
|
||||
uint64_t x31 = ((arg1[5]) * (x8 * (uint64_t)0x2));
|
||||
uint64_t x31 = ((arg1[5]) * ((uint64_t)x8 * 0x2));
|
||||
uint64_t x32 = ((arg1[5]) * x11);
|
||||
uint64_t x33 = ((uint64_t)(arg1[5]) * (x13 * (uint32_t)0x2));
|
||||
uint64_t x33 = ((uint64_t)(arg1[5]) * (x13 * 0x2));
|
||||
uint64_t x34 = ((uint64_t)(arg1[4]) * x2);
|
||||
uint64_t x35 = ((arg1[4]) * x5);
|
||||
uint64_t x36 = ((uint64_t)(arg1[4]) * x8);
|
||||
uint64_t x37 = ((arg1[4]) * x11);
|
||||
uint64_t x38 = ((uint64_t)(arg1[4]) * x14);
|
||||
uint64_t x39 = ((uint64_t)(arg1[4]) * (arg1[4]));
|
||||
uint64_t x40 = ((arg1[3]) * (x2 * (uint64_t)0x2));
|
||||
uint64_t x40 = ((arg1[3]) * ((uint64_t)x2 * 0x2));
|
||||
uint64_t x41 = ((arg1[3]) * x5);
|
||||
uint64_t x42 = ((arg1[3]) * (x8 * (uint64_t)0x2));
|
||||
uint64_t x42 = ((arg1[3]) * ((uint64_t)x8 * 0x2));
|
||||
uint64_t x43 = ((uint64_t)(arg1[3]) * x12);
|
||||
uint64_t x44 = ((uint64_t)(arg1[3]) * (x14 * (uint32_t)0x2));
|
||||
uint64_t x44 = ((uint64_t)(arg1[3]) * (x14 * 0x2));
|
||||
uint64_t x45 = ((uint64_t)(arg1[3]) * x15);
|
||||
uint64_t x46 = ((uint64_t)(arg1[3]) * ((arg1[3]) * (uint32_t)0x2));
|
||||
uint64_t x46 = ((uint64_t)(arg1[3]) * ((arg1[3]) * 0x2));
|
||||
uint64_t x47 = ((uint64_t)(arg1[2]) * x2);
|
||||
uint64_t x48 = ((arg1[2]) * x5);
|
||||
uint64_t x49 = ((uint64_t)(arg1[2]) * x9);
|
||||
@@ -328,15 +366,15 @@ static void fiat_25519_carry_square(uint32_t out1[10], const uint32_t arg1[10])
|
||||
uint64_t x52 = ((uint64_t)(arg1[2]) * x15);
|
||||
uint64_t x53 = ((uint64_t)(arg1[2]) * x16);
|
||||
uint64_t x54 = ((uint64_t)(arg1[2]) * (arg1[2]));
|
||||
uint64_t x55 = ((arg1[1]) * (x2 * (uint64_t)0x2));
|
||||
uint64_t x55 = ((arg1[1]) * ((uint64_t)x2 * 0x2));
|
||||
uint64_t x56 = ((uint64_t)(arg1[1]) * x6);
|
||||
uint64_t x57 = ((uint64_t)(arg1[1]) * (x9 * (uint32_t)0x2));
|
||||
uint64_t x57 = ((uint64_t)(arg1[1]) * (x9 * 0x2));
|
||||
uint64_t x58 = ((uint64_t)(arg1[1]) * x12);
|
||||
uint64_t x59 = ((uint64_t)(arg1[1]) * (x14 * (uint32_t)0x2));
|
||||
uint64_t x59 = ((uint64_t)(arg1[1]) * (x14 * 0x2));
|
||||
uint64_t x60 = ((uint64_t)(arg1[1]) * x15);
|
||||
uint64_t x61 = ((uint64_t)(arg1[1]) * (x16 * (uint32_t)0x2));
|
||||
uint64_t x61 = ((uint64_t)(arg1[1]) * (x16 * 0x2));
|
||||
uint64_t x62 = ((uint64_t)(arg1[1]) * x17);
|
||||
uint64_t x63 = ((uint64_t)(arg1[1]) * ((arg1[1]) * (uint32_t)0x2));
|
||||
uint64_t x63 = ((uint64_t)(arg1[1]) * ((arg1[1]) * 0x2));
|
||||
uint64_t x64 = ((uint64_t)(arg1[0]) * x3);
|
||||
uint64_t x65 = ((uint64_t)(arg1[0]) * x6);
|
||||
uint64_t x66 = ((uint64_t)(arg1[0]) * x9);
|
||||
@@ -386,12 +424,12 @@ static void fiat_25519_carry_square(uint32_t out1[10], const uint32_t arg1[10])
|
||||
uint64_t x110 = (x108 + x77);
|
||||
uint64_t x111 = (x110 >> 25);
|
||||
uint32_t x112 = (uint32_t)(x110 & UINT32_C(0x1ffffff));
|
||||
uint64_t x113 = (x111 * (uint64_t)UINT8_C(0x13));
|
||||
uint64_t x113 = (x111 * UINT8_C(0x13));
|
||||
uint64_t x114 = (x76 + x113);
|
||||
uint32_t x115 = (uint32_t)(x114 >> 26);
|
||||
uint32_t x116 = (uint32_t)(x114 & UINT32_C(0x3ffffff));
|
||||
uint32_t x117 = (x115 + x88);
|
||||
uint32_t x118 = (x117 >> 25);
|
||||
fiat_25519_uint1 x118 = (fiat_25519_uint1)(x117 >> 25);
|
||||
uint32_t x119 = (x117 & UINT32_C(0x1ffffff));
|
||||
uint32_t x120 = (x118 + x91);
|
||||
out1[0] = x116;
|
||||
@@ -407,72 +445,10 @@ static void fiat_25519_carry_square(uint32_t out1[10], const uint32_t arg1[10])
|
||||
}
|
||||
|
||||
/*
|
||||
* Input Bounds:
|
||||
* arg1: [[0x0 ~> 0xd333332], [0x0 ~> 0x6999999], [0x0 ~> 0xd333332], [0x0 ~> 0x6999999], [0x0 ~> 0xd333332], [0x0 ~> 0x6999999], [0x0 ~> 0xd333332], [0x0 ~> 0x6999999], [0x0 ~> 0xd333332], [0x0 ~> 0x6999999]]
|
||||
* Output Bounds:
|
||||
* out1: [[0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333]]
|
||||
*/
|
||||
static void fiat_25519_carry_scmul_121666(uint32_t out1[10], const uint32_t arg1[10]) {
|
||||
uint64_t x1 = ((uint64_t)UINT32_C(0x1db42) * (arg1[9]));
|
||||
uint64_t x2 = ((uint64_t)UINT32_C(0x1db42) * (arg1[8]));
|
||||
uint64_t x3 = ((uint64_t)UINT32_C(0x1db42) * (arg1[7]));
|
||||
uint64_t x4 = ((uint64_t)UINT32_C(0x1db42) * (arg1[6]));
|
||||
uint64_t x5 = ((uint64_t)UINT32_C(0x1db42) * (arg1[5]));
|
||||
uint64_t x6 = ((uint64_t)UINT32_C(0x1db42) * (arg1[4]));
|
||||
uint64_t x7 = ((uint64_t)UINT32_C(0x1db42) * (arg1[3]));
|
||||
uint64_t x8 = ((uint64_t)UINT32_C(0x1db42) * (arg1[2]));
|
||||
uint64_t x9 = ((uint64_t)UINT32_C(0x1db42) * (arg1[1]));
|
||||
uint64_t x10 = ((uint64_t)UINT32_C(0x1db42) * (arg1[0]));
|
||||
uint32_t x11 = (uint32_t)(x10 >> 26);
|
||||
uint32_t x12 = (uint32_t)(x10 & UINT32_C(0x3ffffff));
|
||||
uint64_t x13 = (x11 + x9);
|
||||
uint32_t x14 = (uint32_t)(x13 >> 25);
|
||||
uint32_t x15 = (uint32_t)(x13 & UINT32_C(0x1ffffff));
|
||||
uint64_t x16 = (x14 + x8);
|
||||
uint32_t x17 = (uint32_t)(x16 >> 26);
|
||||
uint32_t x18 = (uint32_t)(x16 & UINT32_C(0x3ffffff));
|
||||
uint64_t x19 = (x17 + x7);
|
||||
uint32_t x20 = (uint32_t)(x19 >> 25);
|
||||
uint32_t x21 = (uint32_t)(x19 & UINT32_C(0x1ffffff));
|
||||
uint64_t x22 = (x20 + x6);
|
||||
uint32_t x23 = (uint32_t)(x22 >> 26);
|
||||
uint32_t x24 = (uint32_t)(x22 & UINT32_C(0x3ffffff));
|
||||
uint64_t x25 = (x23 + x5);
|
||||
uint32_t x26 = (uint32_t)(x25 >> 25);
|
||||
uint32_t x27 = (uint32_t)(x25 & UINT32_C(0x1ffffff));
|
||||
uint64_t x28 = (x26 + x4);
|
||||
uint32_t x29 = (uint32_t)(x28 >> 26);
|
||||
uint32_t x30 = (uint32_t)(x28 & UINT32_C(0x3ffffff));
|
||||
uint64_t x31 = (x29 + x3);
|
||||
uint32_t x32 = (uint32_t)(x31 >> 25);
|
||||
uint32_t x33 = (uint32_t)(x31 & UINT32_C(0x1ffffff));
|
||||
uint64_t x34 = (x32 + x2);
|
||||
uint32_t x35 = (uint32_t)(x34 >> 26);
|
||||
uint32_t x36 = (uint32_t)(x34 & UINT32_C(0x3ffffff));
|
||||
uint64_t x37 = (x35 + x1);
|
||||
uint32_t x38 = (uint32_t)(x37 >> 25);
|
||||
uint32_t x39 = (uint32_t)(x37 & UINT32_C(0x1ffffff));
|
||||
uint32_t x40 = (x38 * (uint32_t)UINT8_C(0x13));
|
||||
uint32_t x41 = (x12 + x40);
|
||||
uint32_t x42 = (x41 >> 26);
|
||||
uint32_t x43 = (x41 & UINT32_C(0x3ffffff));
|
||||
uint32_t x44 = (x42 + x15);
|
||||
uint32_t x45 = (x44 >> 25);
|
||||
uint32_t x46 = (x44 & UINT32_C(0x1ffffff));
|
||||
uint32_t x47 = (x45 + x18);
|
||||
out1[0] = x43;
|
||||
out1[1] = x46;
|
||||
out1[2] = x47;
|
||||
out1[3] = x21;
|
||||
out1[4] = x24;
|
||||
out1[5] = x27;
|
||||
out1[6] = x30;
|
||||
out1[7] = x33;
|
||||
out1[8] = x36;
|
||||
out1[9] = x39;
|
||||
}
|
||||
|
||||
/*
|
||||
* The function fiat_25519_carry reduces a field element.
|
||||
* Postconditions:
|
||||
* eval out1 mod m = eval arg1 mod m
|
||||
*
|
||||
* Input Bounds:
|
||||
* arg1: [[0x0 ~> 0xd333332], [0x0 ~> 0x6999999], [0x0 ~> 0xd333332], [0x0 ~> 0x6999999], [0x0 ~> 0xd333332], [0x0 ~> 0x6999999], [0x0 ~> 0xd333332], [0x0 ~> 0x6999999], [0x0 ~> 0xd333332], [0x0 ~> 0x6999999]]
|
||||
* Output Bounds:
|
||||
@@ -489,11 +465,11 @@ static void fiat_25519_carry(uint32_t out1[10], const uint32_t arg1[10]) {
|
||||
uint32_t x8 = ((x7 >> 26) + (arg1[7]));
|
||||
uint32_t x9 = ((x8 >> 25) + (arg1[8]));
|
||||
uint32_t x10 = ((x9 >> 26) + (arg1[9]));
|
||||
uint32_t x11 = ((x1 & UINT32_C(0x3ffffff)) + ((x10 >> 25) * (uint32_t)UINT8_C(0x13)));
|
||||
uint32_t x12 = ((x11 >> 26) + (x2 & UINT32_C(0x1ffffff)));
|
||||
uint32_t x11 = ((x1 & UINT32_C(0x3ffffff)) + ((x10 >> 25) * UINT8_C(0x13)));
|
||||
uint32_t x12 = ((fiat_25519_uint1)(x11 >> 26) + (x2 & UINT32_C(0x1ffffff)));
|
||||
uint32_t x13 = (x11 & UINT32_C(0x3ffffff));
|
||||
uint32_t x14 = (x12 & UINT32_C(0x1ffffff));
|
||||
uint32_t x15 = ((x12 >> 25) + (x3 & UINT32_C(0x3ffffff)));
|
||||
uint32_t x15 = ((fiat_25519_uint1)(x12 >> 25) + (x3 & UINT32_C(0x3ffffff)));
|
||||
uint32_t x16 = (x4 & UINT32_C(0x1ffffff));
|
||||
uint32_t x17 = (x5 & UINT32_C(0x3ffffff));
|
||||
uint32_t x18 = (x6 & UINT32_C(0x1ffffff));
|
||||
@@ -514,6 +490,10 @@ static void fiat_25519_carry(uint32_t out1[10], const uint32_t arg1[10]) {
|
||||
}
|
||||
|
||||
/*
|
||||
* The function fiat_25519_add adds two field elements.
|
||||
* Postconditions:
|
||||
* eval out1 mod m = (eval arg1 + eval arg2) mod m
|
||||
*
|
||||
* Input Bounds:
|
||||
* arg1: [[0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333]]
|
||||
* arg2: [[0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333]]
|
||||
@@ -544,6 +524,10 @@ static void fiat_25519_add(uint32_t out1[10], const uint32_t arg1[10], const uin
|
||||
}
|
||||
|
||||
/*
|
||||
* The function fiat_25519_sub subtracts two field elements.
|
||||
* Postconditions:
|
||||
* eval out1 mod m = (eval arg1 - eval arg2) mod m
|
||||
*
|
||||
* Input Bounds:
|
||||
* arg1: [[0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333]]
|
||||
* arg2: [[0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333]]
|
||||
@@ -574,6 +558,10 @@ static void fiat_25519_sub(uint32_t out1[10], const uint32_t arg1[10], const uin
|
||||
}
|
||||
|
||||
/*
|
||||
* The function fiat_25519_opp negates a field element.
|
||||
* Postconditions:
|
||||
* eval out1 mod m = -eval arg1 mod m
|
||||
*
|
||||
* Input Bounds:
|
||||
* arg1: [[0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333]]
|
||||
* Output Bounds:
|
||||
@@ -603,6 +591,10 @@ static void fiat_25519_opp(uint32_t out1[10], const uint32_t arg1[10]) {
|
||||
}
|
||||
|
||||
/*
|
||||
* The function fiat_25519_selectznz is a multi-limb conditional select.
|
||||
* Postconditions:
|
||||
* eval out1 = (if arg1 = 0 then eval arg2 else eval arg3)
|
||||
*
|
||||
* Input Bounds:
|
||||
* arg1: [0x0 ~> 0x1]
|
||||
* arg2: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
|
||||
@@ -644,6 +636,10 @@ static void fiat_25519_selectznz(uint32_t out1[10], fiat_25519_uint1 arg1, const
|
||||
}
|
||||
|
||||
/*
|
||||
* The function fiat_25519_to_bytes serializes a field element to bytes in little-endian order.
|
||||
* Postconditions:
|
||||
* out1 = map (λ x, ⌊((eval arg1 mod m) mod 2^(8 * (x + 1))) / 2^(8 * x)⌋) [0..31]
|
||||
*
|
||||
* Input Bounds:
|
||||
* arg1: [[0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333]]
|
||||
* Output Bounds:
|
||||
@@ -684,34 +680,34 @@ static void fiat_25519_to_bytes(uint8_t out1[32], const uint32_t arg1[10]) {
|
||||
fiat_25519_cmovznz_u32(&x21, x20, 0x0, UINT32_C(0xffffffff));
|
||||
uint32_t x22;
|
||||
fiat_25519_uint1 x23;
|
||||
fiat_25519_addcarryx_u26(&x22, &x23, 0x0, (x21 & UINT32_C(0x3ffffed)), x1);
|
||||
fiat_25519_addcarryx_u26(&x22, &x23, 0x0, x1, (x21 & UINT32_C(0x3ffffed)));
|
||||
uint32_t x24;
|
||||
fiat_25519_uint1 x25;
|
||||
fiat_25519_addcarryx_u25(&x24, &x25, x23, (x21 & UINT32_C(0x1ffffff)), x3);
|
||||
fiat_25519_addcarryx_u25(&x24, &x25, x23, x3, (x21 & UINT32_C(0x1ffffff)));
|
||||
uint32_t x26;
|
||||
fiat_25519_uint1 x27;
|
||||
fiat_25519_addcarryx_u26(&x26, &x27, x25, (x21 & UINT32_C(0x3ffffff)), x5);
|
||||
fiat_25519_addcarryx_u26(&x26, &x27, x25, x5, (x21 & UINT32_C(0x3ffffff)));
|
||||
uint32_t x28;
|
||||
fiat_25519_uint1 x29;
|
||||
fiat_25519_addcarryx_u25(&x28, &x29, x27, (x21 & UINT32_C(0x1ffffff)), x7);
|
||||
fiat_25519_addcarryx_u25(&x28, &x29, x27, x7, (x21 & UINT32_C(0x1ffffff)));
|
||||
uint32_t x30;
|
||||
fiat_25519_uint1 x31;
|
||||
fiat_25519_addcarryx_u26(&x30, &x31, x29, (x21 & UINT32_C(0x3ffffff)), x9);
|
||||
fiat_25519_addcarryx_u26(&x30, &x31, x29, x9, (x21 & UINT32_C(0x3ffffff)));
|
||||
uint32_t x32;
|
||||
fiat_25519_uint1 x33;
|
||||
fiat_25519_addcarryx_u25(&x32, &x33, x31, (x21 & UINT32_C(0x1ffffff)), x11);
|
||||
fiat_25519_addcarryx_u25(&x32, &x33, x31, x11, (x21 & UINT32_C(0x1ffffff)));
|
||||
uint32_t x34;
|
||||
fiat_25519_uint1 x35;
|
||||
fiat_25519_addcarryx_u26(&x34, &x35, x33, (x21 & UINT32_C(0x3ffffff)), x13);
|
||||
fiat_25519_addcarryx_u26(&x34, &x35, x33, x13, (x21 & UINT32_C(0x3ffffff)));
|
||||
uint32_t x36;
|
||||
fiat_25519_uint1 x37;
|
||||
fiat_25519_addcarryx_u25(&x36, &x37, x35, (x21 & UINT32_C(0x1ffffff)), x15);
|
||||
fiat_25519_addcarryx_u25(&x36, &x37, x35, x15, (x21 & UINT32_C(0x1ffffff)));
|
||||
uint32_t x38;
|
||||
fiat_25519_uint1 x39;
|
||||
fiat_25519_addcarryx_u26(&x38, &x39, x37, (x21 & UINT32_C(0x3ffffff)), x17);
|
||||
fiat_25519_addcarryx_u26(&x38, &x39, x37, x17, (x21 & UINT32_C(0x3ffffff)));
|
||||
uint32_t x40;
|
||||
fiat_25519_uint1 x41;
|
||||
fiat_25519_addcarryx_u25(&x40, &x41, x39, (x21 & UINT32_C(0x1ffffff)), x19);
|
||||
fiat_25519_addcarryx_u25(&x40, &x41, x39, x19, (x21 & UINT32_C(0x1ffffff)));
|
||||
uint32_t x42 = (x40 << 6);
|
||||
uint32_t x43 = (x38 << 4);
|
||||
uint32_t x44 = (x36 << 3);
|
||||
@@ -824,6 +820,10 @@ static void fiat_25519_to_bytes(uint8_t out1[32], const uint32_t arg1[10]) {
|
||||
}
|
||||
|
||||
/*
|
||||
* The function fiat_25519_from_bytes deserializes a field element from bytes in little-endian order.
|
||||
* Postconditions:
|
||||
* eval out1 mod m = bytes_eval arg1 mod m
|
||||
*
|
||||
* Input Bounds:
|
||||
* arg1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0x7f]]
|
||||
* Output Bounds:
|
||||
@@ -909,3 +909,73 @@ static void fiat_25519_from_bytes(uint32_t out1[10], const uint8_t arg1[32]) {
|
||||
out1[9] = x67;
|
||||
}
|
||||
|
||||
/*
|
||||
* The function fiat_25519_carry_scmul_121666 multiplies a field element by 121666 and reduces the result.
|
||||
* Postconditions:
|
||||
* eval out1 mod m = (121666 * eval arg1) mod m
|
||||
*
|
||||
* Input Bounds:
|
||||
* arg1: [[0x0 ~> 0xd333332], [0x0 ~> 0x6999999], [0x0 ~> 0xd333332], [0x0 ~> 0x6999999], [0x0 ~> 0xd333332], [0x0 ~> 0x6999999], [0x0 ~> 0xd333332], [0x0 ~> 0x6999999], [0x0 ~> 0xd333332], [0x0 ~> 0x6999999]]
|
||||
* Output Bounds:
|
||||
* out1: [[0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], [0x0 ~> 0x4666666], [0x0 ~> 0x2333333]]
|
||||
*/
|
||||
static void fiat_25519_carry_scmul_121666(uint32_t out1[10], const uint32_t arg1[10]) {
|
||||
uint64_t x1 = ((uint64_t)UINT32_C(0x1db42) * (arg1[9]));
|
||||
uint64_t x2 = ((uint64_t)UINT32_C(0x1db42) * (arg1[8]));
|
||||
uint64_t x3 = ((uint64_t)UINT32_C(0x1db42) * (arg1[7]));
|
||||
uint64_t x4 = ((uint64_t)UINT32_C(0x1db42) * (arg1[6]));
|
||||
uint64_t x5 = ((uint64_t)UINT32_C(0x1db42) * (arg1[5]));
|
||||
uint64_t x6 = ((uint64_t)UINT32_C(0x1db42) * (arg1[4]));
|
||||
uint64_t x7 = ((uint64_t)UINT32_C(0x1db42) * (arg1[3]));
|
||||
uint64_t x8 = ((uint64_t)UINT32_C(0x1db42) * (arg1[2]));
|
||||
uint64_t x9 = ((uint64_t)UINT32_C(0x1db42) * (arg1[1]));
|
||||
uint64_t x10 = ((uint64_t)UINT32_C(0x1db42) * (arg1[0]));
|
||||
uint32_t x11 = (uint32_t)(x10 >> 26);
|
||||
uint32_t x12 = (uint32_t)(x10 & UINT32_C(0x3ffffff));
|
||||
uint64_t x13 = (x11 + x9);
|
||||
uint32_t x14 = (uint32_t)(x13 >> 25);
|
||||
uint32_t x15 = (uint32_t)(x13 & UINT32_C(0x1ffffff));
|
||||
uint64_t x16 = (x14 + x8);
|
||||
uint32_t x17 = (uint32_t)(x16 >> 26);
|
||||
uint32_t x18 = (uint32_t)(x16 & UINT32_C(0x3ffffff));
|
||||
uint64_t x19 = (x17 + x7);
|
||||
uint32_t x20 = (uint32_t)(x19 >> 25);
|
||||
uint32_t x21 = (uint32_t)(x19 & UINT32_C(0x1ffffff));
|
||||
uint64_t x22 = (x20 + x6);
|
||||
uint32_t x23 = (uint32_t)(x22 >> 26);
|
||||
uint32_t x24 = (uint32_t)(x22 & UINT32_C(0x3ffffff));
|
||||
uint64_t x25 = (x23 + x5);
|
||||
uint32_t x26 = (uint32_t)(x25 >> 25);
|
||||
uint32_t x27 = (uint32_t)(x25 & UINT32_C(0x1ffffff));
|
||||
uint64_t x28 = (x26 + x4);
|
||||
uint32_t x29 = (uint32_t)(x28 >> 26);
|
||||
uint32_t x30 = (uint32_t)(x28 & UINT32_C(0x3ffffff));
|
||||
uint64_t x31 = (x29 + x3);
|
||||
uint32_t x32 = (uint32_t)(x31 >> 25);
|
||||
uint32_t x33 = (uint32_t)(x31 & UINT32_C(0x1ffffff));
|
||||
uint64_t x34 = (x32 + x2);
|
||||
uint32_t x35 = (uint32_t)(x34 >> 26);
|
||||
uint32_t x36 = (uint32_t)(x34 & UINT32_C(0x3ffffff));
|
||||
uint64_t x37 = (x35 + x1);
|
||||
uint32_t x38 = (uint32_t)(x37 >> 25);
|
||||
uint32_t x39 = (uint32_t)(x37 & UINT32_C(0x1ffffff));
|
||||
uint32_t x40 = (x38 * UINT8_C(0x13));
|
||||
uint32_t x41 = (x12 + x40);
|
||||
fiat_25519_uint1 x42 = (fiat_25519_uint1)(x41 >> 26);
|
||||
uint32_t x43 = (x41 & UINT32_C(0x3ffffff));
|
||||
uint32_t x44 = (x42 + x15);
|
||||
fiat_25519_uint1 x45 = (fiat_25519_uint1)(x44 >> 25);
|
||||
uint32_t x46 = (x44 & UINT32_C(0x1ffffff));
|
||||
uint32_t x47 = (x45 + x18);
|
||||
out1[0] = x43;
|
||||
out1[1] = x46;
|
||||
out1[2] = x47;
|
||||
out1[3] = x21;
|
||||
out1[4] = x24;
|
||||
out1[5] = x27;
|
||||
out1[6] = x30;
|
||||
out1[7] = x33;
|
||||
out1[8] = x36;
|
||||
out1[9] = x39;
|
||||
}
|
||||
|
||||
+135
-75
@@ -1,19 +1,30 @@
|
||||
/* Autogenerated */
|
||||
/* Autogenerated: src/ExtractionOCaml/unsaturated_solinas --static 25519 5 '2^255 - 19' 64 carry_mul carry_square carry add sub opp selectznz to_bytes from_bytes carry_scmul121666 */
|
||||
/* curve description: 25519 */
|
||||
/* requested operations: carry_mul, carry_square, carry_scmul121666, carry, add, sub, opp, selectznz, to_bytes, from_bytes */
|
||||
/* requested operations: carry_mul, carry_square, carry, add, sub, opp, selectznz, to_bytes, from_bytes, carry_scmul121666 */
|
||||
/* n = 5 (from "5") */
|
||||
/* s = 0x8000000000000000000000000000000000000000000000000000000000000000 (from "2^255") */
|
||||
/* c = [(1, 19)] (from "1,19") */
|
||||
/* s-c = 2^255 - [(1, 19)] (from "2^255 - 19") */
|
||||
/* machine_wordsize = 64 (from "64") */
|
||||
|
||||
/* Computed values: */
|
||||
/* carry_chain = [0, 1, 2, 3, 4, 0, 1] */
|
||||
|
||||
#include <stdint.h>
|
||||
typedef unsigned char fiat_25519_uint1;
|
||||
typedef signed char fiat_25519_int1;
|
||||
typedef signed __int128 fiat_25519_int128;
|
||||
typedef unsigned __int128 fiat_25519_uint128;
|
||||
|
||||
#if (-1 & 3) != 3
|
||||
#error "This code only works on a two's complement system"
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* The function fiat_25519_addcarryx_u51 is an addition with carry.
|
||||
* Postconditions:
|
||||
* out1 = (arg1 + arg2 + arg3) mod 2^51
|
||||
* out2 = ⌊(arg1 + arg2 + arg3) / 2^51⌋
|
||||
*
|
||||
* Input Bounds:
|
||||
* arg1: [0x0 ~> 0x1]
|
||||
* arg2: [0x0 ~> 0x7ffffffffffff]
|
||||
@@ -31,6 +42,11 @@ static void fiat_25519_addcarryx_u51(uint64_t* out1, fiat_25519_uint1* out2, fia
|
||||
}
|
||||
|
||||
/*
|
||||
* The function fiat_25519_subborrowx_u51 is a subtraction with borrow.
|
||||
* Postconditions:
|
||||
* out1 = (-arg1 + arg2 + -arg3) mod 2^51
|
||||
* out2 = -⌊(-arg1 + arg2 + -arg3) / 2^51⌋
|
||||
*
|
||||
* Input Bounds:
|
||||
* arg1: [0x0 ~> 0x1]
|
||||
* arg2: [0x0 ~> 0x7ffffffffffff]
|
||||
@@ -48,6 +64,10 @@ static void fiat_25519_subborrowx_u51(uint64_t* out1, fiat_25519_uint1* out2, fi
|
||||
}
|
||||
|
||||
/*
|
||||
* The function fiat_25519_cmovznz_u64 is a single-word conditional move.
|
||||
* Postconditions:
|
||||
* out1 = (if arg1 = 0 then arg2 else arg3)
|
||||
*
|
||||
* Input Bounds:
|
||||
* arg1: [0x0 ~> 0x1]
|
||||
* arg2: [0x0 ~> 0xffffffffffffffff]
|
||||
@@ -69,6 +89,10 @@ static void fiat_25519_cmovznz_u64(uint64_t* out1, fiat_25519_uint1 arg1, uint64
|
||||
}
|
||||
|
||||
/*
|
||||
* The function fiat_25519_carry_mul multiplies two field elements and reduces the result.
|
||||
* Postconditions:
|
||||
* eval out1 mod m = (eval arg1 * eval arg2) mod m
|
||||
*
|
||||
* Input Bounds:
|
||||
* arg1: [[0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664]]
|
||||
* arg2: [[0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664]]
|
||||
@@ -76,16 +100,16 @@ static void fiat_25519_cmovznz_u64(uint64_t* out1, fiat_25519_uint1 arg1, uint64
|
||||
* out1: [[0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc]]
|
||||
*/
|
||||
static void fiat_25519_carry_mul(uint64_t out1[5], const uint64_t arg1[5], const uint64_t arg2[5]) {
|
||||
fiat_25519_uint128 x1 = ((fiat_25519_uint128)(arg1[4]) * ((arg2[4]) * (uint64_t)UINT8_C(0x13)));
|
||||
fiat_25519_uint128 x2 = ((fiat_25519_uint128)(arg1[4]) * ((arg2[3]) * (uint64_t)UINT8_C(0x13)));
|
||||
fiat_25519_uint128 x3 = ((fiat_25519_uint128)(arg1[4]) * ((arg2[2]) * (uint64_t)UINT8_C(0x13)));
|
||||
fiat_25519_uint128 x4 = ((fiat_25519_uint128)(arg1[4]) * ((arg2[1]) * (uint64_t)UINT8_C(0x13)));
|
||||
fiat_25519_uint128 x5 = ((fiat_25519_uint128)(arg1[3]) * ((arg2[4]) * (uint64_t)UINT8_C(0x13)));
|
||||
fiat_25519_uint128 x6 = ((fiat_25519_uint128)(arg1[3]) * ((arg2[3]) * (uint64_t)UINT8_C(0x13)));
|
||||
fiat_25519_uint128 x7 = ((fiat_25519_uint128)(arg1[3]) * ((arg2[2]) * (uint64_t)UINT8_C(0x13)));
|
||||
fiat_25519_uint128 x8 = ((fiat_25519_uint128)(arg1[2]) * ((arg2[4]) * (uint64_t)UINT8_C(0x13)));
|
||||
fiat_25519_uint128 x9 = ((fiat_25519_uint128)(arg1[2]) * ((arg2[3]) * (uint64_t)UINT8_C(0x13)));
|
||||
fiat_25519_uint128 x10 = ((fiat_25519_uint128)(arg1[1]) * ((arg2[4]) * (uint64_t)UINT8_C(0x13)));
|
||||
fiat_25519_uint128 x1 = ((fiat_25519_uint128)(arg1[4]) * ((arg2[4]) * UINT8_C(0x13)));
|
||||
fiat_25519_uint128 x2 = ((fiat_25519_uint128)(arg1[4]) * ((arg2[3]) * UINT8_C(0x13)));
|
||||
fiat_25519_uint128 x3 = ((fiat_25519_uint128)(arg1[4]) * ((arg2[2]) * UINT8_C(0x13)));
|
||||
fiat_25519_uint128 x4 = ((fiat_25519_uint128)(arg1[4]) * ((arg2[1]) * UINT8_C(0x13)));
|
||||
fiat_25519_uint128 x5 = ((fiat_25519_uint128)(arg1[3]) * ((arg2[4]) * UINT8_C(0x13)));
|
||||
fiat_25519_uint128 x6 = ((fiat_25519_uint128)(arg1[3]) * ((arg2[3]) * UINT8_C(0x13)));
|
||||
fiat_25519_uint128 x7 = ((fiat_25519_uint128)(arg1[3]) * ((arg2[2]) * UINT8_C(0x13)));
|
||||
fiat_25519_uint128 x8 = ((fiat_25519_uint128)(arg1[2]) * ((arg2[4]) * UINT8_C(0x13)));
|
||||
fiat_25519_uint128 x9 = ((fiat_25519_uint128)(arg1[2]) * ((arg2[3]) * UINT8_C(0x13)));
|
||||
fiat_25519_uint128 x10 = ((fiat_25519_uint128)(arg1[1]) * ((arg2[4]) * UINT8_C(0x13)));
|
||||
fiat_25519_uint128 x11 = ((fiat_25519_uint128)(arg1[4]) * (arg2[0]));
|
||||
fiat_25519_uint128 x12 = ((fiat_25519_uint128)(arg1[3]) * (arg2[1]));
|
||||
fiat_25519_uint128 x13 = ((fiat_25519_uint128)(arg1[3]) * (arg2[0]));
|
||||
@@ -120,12 +144,12 @@ static void fiat_25519_carry_mul(uint64_t out1[5], const uint64_t arg1[5], const
|
||||
fiat_25519_uint128 x42 = (x40 + x29);
|
||||
uint64_t x43 = (uint64_t)(x42 >> 51);
|
||||
uint64_t x44 = (uint64_t)(x42 & UINT64_C(0x7ffffffffffff));
|
||||
uint64_t x45 = (x43 * (uint64_t)UINT8_C(0x13));
|
||||
uint64_t x45 = (x43 * UINT8_C(0x13));
|
||||
uint64_t x46 = (x28 + x45);
|
||||
uint64_t x47 = (x46 >> 51);
|
||||
uint64_t x48 = (x46 & UINT64_C(0x7ffffffffffff));
|
||||
uint64_t x49 = (x47 + x35);
|
||||
uint64_t x50 = (x49 >> 51);
|
||||
fiat_25519_uint1 x50 = (fiat_25519_uint1)(x49 >> 51);
|
||||
uint64_t x51 = (x49 & UINT64_C(0x7ffffffffffff));
|
||||
uint64_t x52 = (x50 + x38);
|
||||
out1[0] = x48;
|
||||
@@ -136,20 +160,24 @@ static void fiat_25519_carry_mul(uint64_t out1[5], const uint64_t arg1[5], const
|
||||
}
|
||||
|
||||
/*
|
||||
* The function fiat_25519_carry_square squares a field element and reduces the result.
|
||||
* Postconditions:
|
||||
* eval out1 mod m = (eval arg1 * eval arg1) mod m
|
||||
*
|
||||
* Input Bounds:
|
||||
* arg1: [[0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664]]
|
||||
* Output Bounds:
|
||||
* out1: [[0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc]]
|
||||
*/
|
||||
static void fiat_25519_carry_square(uint64_t out1[5], const uint64_t arg1[5]) {
|
||||
uint64_t x1 = ((arg1[4]) * (uint64_t)UINT8_C(0x13));
|
||||
uint64_t x2 = (x1 * (uint64_t)0x2);
|
||||
uint64_t x3 = ((arg1[4]) * (uint64_t)0x2);
|
||||
uint64_t x4 = ((arg1[3]) * (uint64_t)UINT8_C(0x13));
|
||||
uint64_t x5 = (x4 * (uint64_t)0x2);
|
||||
uint64_t x6 = ((arg1[3]) * (uint64_t)0x2);
|
||||
uint64_t x7 = ((arg1[2]) * (uint64_t)0x2);
|
||||
uint64_t x8 = ((arg1[1]) * (uint64_t)0x2);
|
||||
uint64_t x1 = ((arg1[4]) * UINT8_C(0x13));
|
||||
uint64_t x2 = (x1 * 0x2);
|
||||
uint64_t x3 = ((arg1[4]) * 0x2);
|
||||
uint64_t x4 = ((arg1[3]) * UINT8_C(0x13));
|
||||
uint64_t x5 = (x4 * 0x2);
|
||||
uint64_t x6 = ((arg1[3]) * 0x2);
|
||||
uint64_t x7 = ((arg1[2]) * 0x2);
|
||||
uint64_t x8 = ((arg1[1]) * 0x2);
|
||||
fiat_25519_uint128 x9 = ((fiat_25519_uint128)(arg1[4]) * x1);
|
||||
fiat_25519_uint128 x10 = ((fiat_25519_uint128)(arg1[3]) * x2);
|
||||
fiat_25519_uint128 x11 = ((fiat_25519_uint128)(arg1[3]) * x4);
|
||||
@@ -184,12 +212,12 @@ static void fiat_25519_carry_square(uint64_t out1[5], const uint64_t arg1[5]) {
|
||||
fiat_25519_uint128 x40 = (x38 + x27);
|
||||
uint64_t x41 = (uint64_t)(x40 >> 51);
|
||||
uint64_t x42 = (uint64_t)(x40 & UINT64_C(0x7ffffffffffff));
|
||||
uint64_t x43 = (x41 * (uint64_t)UINT8_C(0x13));
|
||||
uint64_t x43 = (x41 * UINT8_C(0x13));
|
||||
uint64_t x44 = (x26 + x43);
|
||||
uint64_t x45 = (x44 >> 51);
|
||||
uint64_t x46 = (x44 & UINT64_C(0x7ffffffffffff));
|
||||
uint64_t x47 = (x45 + x33);
|
||||
uint64_t x48 = (x47 >> 51);
|
||||
fiat_25519_uint1 x48 = (fiat_25519_uint1)(x47 >> 51);
|
||||
uint64_t x49 = (x47 & UINT64_C(0x7ffffffffffff));
|
||||
uint64_t x50 = (x48 + x36);
|
||||
out1[0] = x46;
|
||||
@@ -200,47 +228,10 @@ static void fiat_25519_carry_square(uint64_t out1[5], const uint64_t arg1[5]) {
|
||||
}
|
||||
|
||||
/*
|
||||
* Input Bounds:
|
||||
* arg1: [[0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664]]
|
||||
* Output Bounds:
|
||||
* out1: [[0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc]]
|
||||
*/
|
||||
static void fiat_25519_carry_scmul_121666(uint64_t out1[5], const uint64_t arg1[5]) {
|
||||
fiat_25519_uint128 x1 = (UINT32_C(0x1db42) * (fiat_25519_uint128)(arg1[4]));
|
||||
fiat_25519_uint128 x2 = (UINT32_C(0x1db42) * (fiat_25519_uint128)(arg1[3]));
|
||||
fiat_25519_uint128 x3 = (UINT32_C(0x1db42) * (fiat_25519_uint128)(arg1[2]));
|
||||
fiat_25519_uint128 x4 = (UINT32_C(0x1db42) * (fiat_25519_uint128)(arg1[1]));
|
||||
fiat_25519_uint128 x5 = (UINT32_C(0x1db42) * (fiat_25519_uint128)(arg1[0]));
|
||||
uint64_t x6 = (uint64_t)(x5 >> 51);
|
||||
uint64_t x7 = (uint64_t)(x5 & UINT64_C(0x7ffffffffffff));
|
||||
fiat_25519_uint128 x8 = (x6 + x4);
|
||||
uint64_t x9 = (uint64_t)(x8 >> 51);
|
||||
uint64_t x10 = (uint64_t)(x8 & UINT64_C(0x7ffffffffffff));
|
||||
fiat_25519_uint128 x11 = (x9 + x3);
|
||||
uint64_t x12 = (uint64_t)(x11 >> 51);
|
||||
uint64_t x13 = (uint64_t)(x11 & UINT64_C(0x7ffffffffffff));
|
||||
fiat_25519_uint128 x14 = (x12 + x2);
|
||||
uint64_t x15 = (uint64_t)(x14 >> 51);
|
||||
uint64_t x16 = (uint64_t)(x14 & UINT64_C(0x7ffffffffffff));
|
||||
fiat_25519_uint128 x17 = (x15 + x1);
|
||||
uint64_t x18 = (uint64_t)(x17 >> 51);
|
||||
uint64_t x19 = (uint64_t)(x17 & UINT64_C(0x7ffffffffffff));
|
||||
uint64_t x20 = (x18 * (uint64_t)UINT8_C(0x13));
|
||||
uint64_t x21 = (x7 + x20);
|
||||
uint64_t x22 = (x21 >> 51);
|
||||
uint64_t x23 = (x21 & UINT64_C(0x7ffffffffffff));
|
||||
uint64_t x24 = (x22 + x10);
|
||||
uint64_t x25 = (x24 >> 51);
|
||||
uint64_t x26 = (x24 & UINT64_C(0x7ffffffffffff));
|
||||
uint64_t x27 = (x25 + x13);
|
||||
out1[0] = x23;
|
||||
out1[1] = x26;
|
||||
out1[2] = x27;
|
||||
out1[3] = x16;
|
||||
out1[4] = x19;
|
||||
}
|
||||
|
||||
/*
|
||||
* The function fiat_25519_carry reduces a field element.
|
||||
* Postconditions:
|
||||
* eval out1 mod m = eval arg1 mod m
|
||||
*
|
||||
* Input Bounds:
|
||||
* arg1: [[0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664]]
|
||||
* Output Bounds:
|
||||
@@ -252,11 +243,11 @@ static void fiat_25519_carry(uint64_t out1[5], const uint64_t arg1[5]) {
|
||||
uint64_t x3 = ((x2 >> 51) + (arg1[2]));
|
||||
uint64_t x4 = ((x3 >> 51) + (arg1[3]));
|
||||
uint64_t x5 = ((x4 >> 51) + (arg1[4]));
|
||||
uint64_t x6 = ((x1 & UINT64_C(0x7ffffffffffff)) + ((x5 >> 51) * (uint64_t)UINT8_C(0x13)));
|
||||
uint64_t x7 = ((x6 >> 51) + (x2 & UINT64_C(0x7ffffffffffff)));
|
||||
uint64_t x6 = ((x1 & UINT64_C(0x7ffffffffffff)) + ((x5 >> 51) * UINT8_C(0x13)));
|
||||
uint64_t x7 = ((fiat_25519_uint1)(x6 >> 51) + (x2 & UINT64_C(0x7ffffffffffff)));
|
||||
uint64_t x8 = (x6 & UINT64_C(0x7ffffffffffff));
|
||||
uint64_t x9 = (x7 & UINT64_C(0x7ffffffffffff));
|
||||
uint64_t x10 = ((x7 >> 51) + (x3 & UINT64_C(0x7ffffffffffff)));
|
||||
uint64_t x10 = ((fiat_25519_uint1)(x7 >> 51) + (x3 & UINT64_C(0x7ffffffffffff)));
|
||||
uint64_t x11 = (x4 & UINT64_C(0x7ffffffffffff));
|
||||
uint64_t x12 = (x5 & UINT64_C(0x7ffffffffffff));
|
||||
out1[0] = x8;
|
||||
@@ -267,6 +258,10 @@ static void fiat_25519_carry(uint64_t out1[5], const uint64_t arg1[5]) {
|
||||
}
|
||||
|
||||
/*
|
||||
* The function fiat_25519_add adds two field elements.
|
||||
* Postconditions:
|
||||
* eval out1 mod m = (eval arg1 + eval arg2) mod m
|
||||
*
|
||||
* Input Bounds:
|
||||
* arg1: [[0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc]]
|
||||
* arg2: [[0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc]]
|
||||
@@ -287,6 +282,10 @@ static void fiat_25519_add(uint64_t out1[5], const uint64_t arg1[5], const uint6
|
||||
}
|
||||
|
||||
/*
|
||||
* The function fiat_25519_sub subtracts two field elements.
|
||||
* Postconditions:
|
||||
* eval out1 mod m = (eval arg1 - eval arg2) mod m
|
||||
*
|
||||
* Input Bounds:
|
||||
* arg1: [[0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc]]
|
||||
* arg2: [[0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc]]
|
||||
@@ -307,6 +306,10 @@ static void fiat_25519_sub(uint64_t out1[5], const uint64_t arg1[5], const uint6
|
||||
}
|
||||
|
||||
/*
|
||||
* The function fiat_25519_opp negates a field element.
|
||||
* Postconditions:
|
||||
* eval out1 mod m = -eval arg1 mod m
|
||||
*
|
||||
* Input Bounds:
|
||||
* arg1: [[0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc]]
|
||||
* Output Bounds:
|
||||
@@ -326,6 +329,10 @@ static void fiat_25519_opp(uint64_t out1[5], const uint64_t arg1[5]) {
|
||||
}
|
||||
|
||||
/*
|
||||
* The function fiat_25519_selectznz is a multi-limb conditional select.
|
||||
* Postconditions:
|
||||
* eval out1 = (if arg1 = 0 then eval arg2 else eval arg3)
|
||||
*
|
||||
* Input Bounds:
|
||||
* arg1: [0x0 ~> 0x1]
|
||||
* arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]]
|
||||
@@ -352,6 +359,10 @@ static void fiat_25519_selectznz(uint64_t out1[5], fiat_25519_uint1 arg1, const
|
||||
}
|
||||
|
||||
/*
|
||||
* The function fiat_25519_to_bytes serializes a field element to bytes in little-endian order.
|
||||
* Postconditions:
|
||||
* out1 = map (λ x, ⌊((eval arg1 mod m) mod 2^(8 * (x + 1))) / 2^(8 * x)⌋) [0..31]
|
||||
*
|
||||
* Input Bounds:
|
||||
* arg1: [[0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc]]
|
||||
* Output Bounds:
|
||||
@@ -377,19 +388,19 @@ static void fiat_25519_to_bytes(uint8_t out1[32], const uint64_t arg1[5]) {
|
||||
fiat_25519_cmovznz_u64(&x11, x10, 0x0, UINT64_C(0xffffffffffffffff));
|
||||
uint64_t x12;
|
||||
fiat_25519_uint1 x13;
|
||||
fiat_25519_addcarryx_u51(&x12, &x13, 0x0, (x11 & UINT64_C(0x7ffffffffffed)), x1);
|
||||
fiat_25519_addcarryx_u51(&x12, &x13, 0x0, x1, (x11 & UINT64_C(0x7ffffffffffed)));
|
||||
uint64_t x14;
|
||||
fiat_25519_uint1 x15;
|
||||
fiat_25519_addcarryx_u51(&x14, &x15, x13, (x11 & UINT64_C(0x7ffffffffffff)), x3);
|
||||
fiat_25519_addcarryx_u51(&x14, &x15, x13, x3, (x11 & UINT64_C(0x7ffffffffffff)));
|
||||
uint64_t x16;
|
||||
fiat_25519_uint1 x17;
|
||||
fiat_25519_addcarryx_u51(&x16, &x17, x15, (x11 & UINT64_C(0x7ffffffffffff)), x5);
|
||||
fiat_25519_addcarryx_u51(&x16, &x17, x15, x5, (x11 & UINT64_C(0x7ffffffffffff)));
|
||||
uint64_t x18;
|
||||
fiat_25519_uint1 x19;
|
||||
fiat_25519_addcarryx_u51(&x18, &x19, x17, (x11 & UINT64_C(0x7ffffffffffff)), x7);
|
||||
fiat_25519_addcarryx_u51(&x18, &x19, x17, x7, (x11 & UINT64_C(0x7ffffffffffff)));
|
||||
uint64_t x20;
|
||||
fiat_25519_uint1 x21;
|
||||
fiat_25519_addcarryx_u51(&x20, &x21, x19, (x11 & UINT64_C(0x7ffffffffffff)), x9);
|
||||
fiat_25519_addcarryx_u51(&x20, &x21, x19, x9, (x11 & UINT64_C(0x7ffffffffffff)));
|
||||
uint64_t x22 = (x20 << 4);
|
||||
uint64_t x23 = (x18 * (uint64_t)0x2);
|
||||
uint64_t x24 = (x16 << 6);
|
||||
@@ -495,6 +506,10 @@ static void fiat_25519_to_bytes(uint8_t out1[32], const uint64_t arg1[5]) {
|
||||
}
|
||||
|
||||
/*
|
||||
* The function fiat_25519_from_bytes deserializes a field element from bytes in little-endian order.
|
||||
* Postconditions:
|
||||
* eval out1 mod m = bytes_eval arg1 mod m
|
||||
*
|
||||
* Input Bounds:
|
||||
* arg1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0x7f]]
|
||||
* Output Bounds:
|
||||
@@ -557,3 +572,48 @@ static void fiat_25519_from_bytes(uint64_t out1[5], const uint8_t arg1[32]) {
|
||||
out1[4] = x49;
|
||||
}
|
||||
|
||||
/*
|
||||
* The function fiat_25519_carry_scmul_121666 multiplies a field element by 121666 and reduces the result.
|
||||
* Postconditions:
|
||||
* eval out1 mod m = (121666 * eval arg1) mod m
|
||||
*
|
||||
* Input Bounds:
|
||||
* arg1: [[0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664]]
|
||||
* Output Bounds:
|
||||
* out1: [[0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc]]
|
||||
*/
|
||||
static void fiat_25519_carry_scmul_121666(uint64_t out1[5], const uint64_t arg1[5]) {
|
||||
fiat_25519_uint128 x1 = ((fiat_25519_uint128)UINT32_C(0x1db42) * (arg1[4]));
|
||||
fiat_25519_uint128 x2 = ((fiat_25519_uint128)UINT32_C(0x1db42) * (arg1[3]));
|
||||
fiat_25519_uint128 x3 = ((fiat_25519_uint128)UINT32_C(0x1db42) * (arg1[2]));
|
||||
fiat_25519_uint128 x4 = ((fiat_25519_uint128)UINT32_C(0x1db42) * (arg1[1]));
|
||||
fiat_25519_uint128 x5 = ((fiat_25519_uint128)UINT32_C(0x1db42) * (arg1[0]));
|
||||
uint64_t x6 = (uint64_t)(x5 >> 51);
|
||||
uint64_t x7 = (uint64_t)(x5 & UINT64_C(0x7ffffffffffff));
|
||||
fiat_25519_uint128 x8 = (x6 + x4);
|
||||
uint64_t x9 = (uint64_t)(x8 >> 51);
|
||||
uint64_t x10 = (uint64_t)(x8 & UINT64_C(0x7ffffffffffff));
|
||||
fiat_25519_uint128 x11 = (x9 + x3);
|
||||
uint64_t x12 = (uint64_t)(x11 >> 51);
|
||||
uint64_t x13 = (uint64_t)(x11 & UINT64_C(0x7ffffffffffff));
|
||||
fiat_25519_uint128 x14 = (x12 + x2);
|
||||
uint64_t x15 = (uint64_t)(x14 >> 51);
|
||||
uint64_t x16 = (uint64_t)(x14 & UINT64_C(0x7ffffffffffff));
|
||||
fiat_25519_uint128 x17 = (x15 + x1);
|
||||
uint64_t x18 = (uint64_t)(x17 >> 51);
|
||||
uint64_t x19 = (uint64_t)(x17 & UINT64_C(0x7ffffffffffff));
|
||||
uint64_t x20 = (x18 * UINT8_C(0x13));
|
||||
uint64_t x21 = (x7 + x20);
|
||||
fiat_25519_uint1 x22 = (fiat_25519_uint1)(x21 >> 51);
|
||||
uint64_t x23 = (x21 & UINT64_C(0x7ffffffffffff));
|
||||
uint64_t x24 = (x22 + x10);
|
||||
fiat_25519_uint1 x25 = (fiat_25519_uint1)(x24 >> 51);
|
||||
uint64_t x26 = (x24 & UINT64_C(0x7ffffffffffff));
|
||||
uint64_t x27 = (x25 + x13);
|
||||
out1[0] = x23;
|
||||
out1[1] = x26;
|
||||
out1[2] = x27;
|
||||
out1[3] = x16;
|
||||
out1[4] = x19;
|
||||
}
|
||||
|
||||
-1063
File diff suppressed because it is too large.
Load diff
+1593
-1672
File diff suppressed because it is too large.
Load diff
+512
-503
File diff suppressed because it is too large.
Load diff
+4
-3
@@ -1,6 +1,7 @@
|
||||
ARG swift_version=5.0
|
||||
ARG ubuntu_version=bionic
|
||||
FROM swift:$swift_version-$ubuntu_version
|
||||
ARG base_image=swift:$swift_version-$ubuntu_version
|
||||
FROM $base_image
|
||||
# needed to do again after FROM due to docker limitation
|
||||
ARG swift_version
|
||||
ARG ubuntu_version
|
||||
@@ -12,7 +13,7 @@ ENV LANG en_US.UTF-8
|
||||
ENV LANGUAGE en_US.UTF-8
|
||||
|
||||
# Get lldb out of the way
|
||||
RUN mv /usr/lib/python2.7/site-packages/* /usr/lib/python2.7/dist-packages && rmdir /usr/lib/python2.7/site-packages && ln -s /usr/lib/python2.7/dist-packages /usr/lib/python2.7/site-packages
|
||||
RUN if [ -d /usr/lib/python2.7/site-packages ]; then mv /usr/lib/python2.7/site-packages/* /usr/lib/python2.7/dist-packages && rmdir /usr/lib/python2.7/site-packages && ln -s /usr/lib/python2.7/dist-packages /usr/lib/python2.7/site-packages; fi
|
||||
|
||||
# dependencies
|
||||
RUN apt-get update && apt-get install -y wget
|
||||
@@ -32,7 +33,7 @@ RUN chmod 755 $HOME/.tools/symbolicate-linux-fatal
|
||||
|
||||
# swiftformat (until part of the toolchain)
|
||||
|
||||
ARG swiftformat_version=0.40.12
|
||||
ARG swiftformat_version=0.44.6
|
||||
RUN git clone --branch $swiftformat_version --depth 1 https://github.com/nicklockwood/SwiftFormat $HOME/.tools/swift-format
|
||||
RUN cd $HOME/.tools/swift-format && swift build -c release
|
||||
RUN ln -s $HOME/.tools/swift-format/.build/release/swiftformat $HOME/.tools/swiftformat
|
||||
@@ -0,0 +1,18 @@
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
|
||||
runtime-setup:
|
||||
image: swift-crypto:18.04-5.2
|
||||
build:
|
||||
args:
|
||||
ubuntu_version: "bionic"
|
||||
swift_version: "5.2"
|
||||
|
||||
test:
|
||||
image: swift-crypto:18.04-5.2
|
||||
environment: []
|
||||
#- SANITIZER_ARG=--sanitize=thread
|
||||
|
||||
shell:
|
||||
image: swift-crypto:18.04-5.2
|
||||
@@ -0,0 +1,17 @@
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
|
||||
runtime-setup:
|
||||
image: swift-crypto:18.04-5.3
|
||||
build:
|
||||
args:
|
||||
base_image: "swiftlang/swift:nightly-5.3-bionic"
|
||||
|
||||
test:
|
||||
image: swift-crypto:18.04-5.3
|
||||
environment: []
|
||||
#- SANITIZER_ARG=--sanitize=thread
|
||||
|
||||
shell:
|
||||
image: swift-crypto:18.04-5.3
|
||||
@@ -1,16 +0,0 @@
|
||||
diff --git a/Sources/CCryptoBoringSSL/crypto/mem.c b/Sources/CCryptoBoringSSL/crypto/mem.c
|
||||
index b1d165e..0f66bc4 100644
|
||||
--- a/Sources/CCryptoBoringSSL/crypto/mem.c
|
||||
+++ b/Sources/CCryptoBoringSSL/crypto/mem.c
|
||||
@@ -84,7 +84,10 @@ static void __asan_unpoison_memory_region(const void *addr, size_t size) {}
|
||||
// Windows doesn't really support weak symbols as of May 2019, and Clang on
|
||||
// Windows will emit strong symbols instead. See
|
||||
// https://bugs.llvm.org/show_bug.cgi?id=37598
|
||||
-#if defined(__GNUC__) || (defined(__clang__) && !defined(_MSC_VER))
|
||||
+
|
||||
+// Swift Crypto disables this for compatibility with weird libraries. See
|
||||
+// https://github.com/apple/swift-nio-ssl/issues/189
|
||||
+#if 0
|
||||
// sdallocx is a sized |free| function. By passing the size (which we happen to
|
||||
// always know in BoringSSL), the malloc implementation can save work. We cannot
|
||||
// depend on |sdallocx| being available so we declare a wrapper that falls back
|
||||
@@ -188,7 +188,7 @@ PATTERNS=(
|
||||
'crypto/*/*/*.S'
|
||||
'crypto/*/*/*/*.c'
|
||||
'third_party/fiat/*.h'
|
||||
'third_party/fiat/*.c'
|
||||
#'third_party/fiat/*.c'
|
||||
)
|
||||
|
||||
EXCLUDES=(
|
||||
@@ -275,7 +275,6 @@ echo "PROTECTING against executable stacks"
|
||||
echo "PATCHING BoringSSL"
|
||||
git apply "${HERE}/scripts/patch-1-inttypes.patch"
|
||||
git apply "${HERE}/scripts/patch-2-arm-arch.patch"
|
||||
git apply "${HERE}/scripts/patch-3-weak-linking.patch"
|
||||
|
||||
# We need BoringSSL to be modularised
|
||||
echo "MODULARISING BoringSSL"
|
||||
|
||||
Reference in new issue
Block a user