Update BoringSSL to aefa5d24da34ef77ac797bdbe684734e5bd870f4 (#312)

Update BoringSSL to aefa5d24da34ef77ac797bdbe684734e5bd870f4, and modify
the vendoring script to reduce our warnings.
This commit is contained in:
Cory Benfield authored and GitHub committed 2024-12-13 14:07:54 +00:00
1 parent 600eda380a
commit 555b9f1dab
242 files changed
+7474 -5584

No files matched your search

+4 -4
View File
@@ -20,7 +20,7 @@
// Sources/CCryptoBoringSSL directory. The source repository is at
// https://boringssl.googlesource.com/boringssl.
//
// BoringSSL Commit: fcef13a49852397a0d39c00be8d7bc2ba1ab6fb9
// BoringSSL Commit: aefa5d24da34ef77ac797bdbe684734e5bd870f4
import PackageDescription
@@ -98,9 +98,9 @@ let package = Package(
* These files are excluded to support WASI libc which doesn't provide <netdb.h>.
* This is safe for all platforms as we do not rely on networking features.
*/
"crypto/bio/connect.c",
"crypto/bio/socket_helper.c",
"crypto/bio/socket.c"
"crypto/bio/connect.cc",
"crypto/bio/socket_helper.cc",
"crypto/bio/socket.cc"
],
resources: privacyManifestResource,
cSettings: [
+2 -9
View File
@@ -91,7 +91,6 @@ add_library(CCryptoBoringSSL STATIC
"crypto/dh_extra/dh_asn1.cc"
"crypto/dh_extra/params.cc"
"crypto/digest_extra/digest_extra.cc"
"crypto/dilithium/dilithium.cc"
"crypto/dsa/dsa.cc"
"crypto/dsa/dsa_asn1.cc"
"crypto/ec_extra/ec_asn1.cc"
@@ -125,7 +124,6 @@ add_library(CCryptoBoringSSL STATIC
"crypto/fipsmodule/fips_shared_support.cc"
"crypto/hpke/hpke.cc"
"crypto/hrss/hrss.cc"
"crypto/keccak/keccak.cc"
"crypto/kyber/kyber.cc"
"crypto/lhash/lhash.cc"
"crypto/md4/md4.cc"
@@ -177,13 +175,6 @@ add_library(CCryptoBoringSSL STATIC
"crypto/slhdsa/slhdsa.cc"
"crypto/slhdsa/thash.cc"
"crypto/slhdsa/wots.cc"
"crypto/spx/spx.cc"
"crypto/spx/spx_address.cc"
"crypto/spx/spx_fors.cc"
"crypto/spx/spx_merkle.cc"
"crypto/spx/spx_thash.cc"
"crypto/spx/spx_util.cc"
"crypto/spx/spx_wots.cc"
"crypto/stack/stack.cc"
"crypto/thread.cc"
"crypto/thread_none.cc"
@@ -266,6 +257,7 @@ add_library(CCryptoBoringSSL STATIC
if(CMAKE_SYSTEM_NAME STREQUAL Darwin AND CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64")
target_sources(CCryptoBoringSSL PRIVATE
gen/bcm/aes-gcm-avx10-x86_64-apple.S
gen/bcm/aesni-gcm-x86_64-apple.S
gen/bcm/aesni-x86_64-apple.S
gen/bcm/ghash-ssse3-x86_64-apple.S
@@ -286,6 +278,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL Darwin AND CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x
gen/crypto/md5-x86_64-apple.S)
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux|Android" AND CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64")
target_sources(CCryptoBoringSSL PRIVATE
gen/bcm/aes-gcm-avx10-x86_64-linux.S
gen/bcm/aesni-gcm-x86_64-linux.S
gen/bcm/aesni-x86_64-linux.S
gen/bcm/ghash-ssse3-x86_64-linux.S
@@ -1,4 +1,4 @@
/* Copyright (c) 2022, Google Inc.
/* Copyright 2022 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -70,9 +70,6 @@ void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it) {
}
void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it) {
const ASN1_TEMPLATE *tt = NULL, *seqtt;
const ASN1_EXTERN_FUNCS *ef;
int i;
if (!pval) {
return;
}
@@ -97,16 +94,14 @@ void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it) {
const ASN1_AUX *aux = reinterpret_cast<const ASN1_AUX *>(it->funcs);
ASN1_aux_cb *asn1_cb = aux != NULL ? aux->asn1_cb : NULL;
if (asn1_cb) {
i = asn1_cb(ASN1_OP_FREE_PRE, pval, it, NULL);
if (i == 2) {
if (asn1_cb(ASN1_OP_FREE_PRE, pval, it, NULL) == 2) {
return;
}
}
i = asn1_get_choice_selector(pval, it);
int i = asn1_get_choice_selector(pval, it);
if ((i >= 0) && (i < it->tcount)) {
ASN1_VALUE **pchval;
tt = it->templates + i;
pchval = asn1_get_field_ptr(pval, tt);
const ASN1_TEMPLATE *tt = it->templates + i;
ASN1_VALUE **pchval = asn1_get_field_ptr(pval, tt);
ASN1_template_free(pchval, tt);
}
if (asn1_cb) {
@@ -117,12 +112,14 @@ void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it) {
break;
}
case ASN1_ITYPE_EXTERN:
ef = reinterpret_cast<const ASN1_EXTERN_FUNCS *>(it->funcs);
case ASN1_ITYPE_EXTERN: {
const ASN1_EXTERN_FUNCS *ef =
reinterpret_cast<const ASN1_EXTERN_FUNCS *>(it->funcs);
if (ef && ef->asn1_ex_free) {
ef->asn1_ex_free(pval, it);
}
break;
}
case ASN1_ITYPE_SEQUENCE: {
if (!asn1_refcount_dec_and_test_zero(pval, it)) {
@@ -131,8 +128,7 @@ void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it) {
const ASN1_AUX *aux = reinterpret_cast<const ASN1_AUX *>(it->funcs);
ASN1_aux_cb *asn1_cb = aux != NULL ? aux->asn1_cb : NULL;
if (asn1_cb) {
i = asn1_cb(ASN1_OP_FREE_PRE, pval, it, NULL);
if (i == 2) {
if (asn1_cb(ASN1_OP_FREE_PRE, pval, it, NULL) == 2) {
return;
}
}
@@ -140,14 +136,12 @@ void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it) {
// If we free up as normal we will invalidate any ANY DEFINED BY
// field and we wont be able to determine the type of the field it
// defines. So free up in reverse order.
tt = it->templates + it->tcount - 1;
for (i = 0; i < it->tcount; tt--, i++) {
ASN1_VALUE **pseqval;
seqtt = asn1_do_adb(pval, tt, 0);
for (int i = it->tcount - 1; i >= 0; i--) {
const ASN1_TEMPLATE *seqtt = asn1_do_adb(pval, &it->templates[i], 0);
if (!seqtt) {
continue;
}
pseqval = asn1_get_field_ptr(pval, seqtt);
ASN1_VALUE **pseqval = asn1_get_field_ptr(pval, seqtt);
ASN1_template_free(pseqval, seqtt);
}
if (asn1_cb) {
@@ -1,4 +1,4 @@
/* Copyright (c) 2024, Google Inc.
/* Copyright 2024 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2014, Google Inc.
/* Copyright 2014 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2021, Google Inc.
/* Copyright 2021 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2015, Google Inc.
/* Copyright 2015 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2016, Google Inc.
/* Copyright 2016 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2014, Google Inc.
/* Copyright 2014 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2014, Google Inc.
/* Copyright 2014 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2014, Google Inc.
/* Copyright 2014 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2014, Google Inc.
/* Copyright 2014 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2018, Google Inc.
/* Copyright 2018 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2014, Google Inc.
/* Copyright 2014 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2018, Google Inc.
/* Copyright 2018 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2017, Google Inc.
/* Copyright 2017 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2017, Google Inc.
/* Copyright 2017 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2014, Google Inc.
/* Copyright 2014 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2014, Google Inc.
/* Copyright 2014 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2015, Google Inc.
/* Copyright 2015 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2021, Google Inc.
/* Copyright 2021 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2018, Google Inc.
/* Copyright 2018 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2016, Google Inc.
/* Copyright 2016 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2023, Google Inc.
/* Copyright 2023 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2018, Google Inc.
/* Copyright 2018 The BoringSSL Authors
* Copyright (c) 2020, Arm Ltd.
*
* Permission to use, copy, modify, and/or distribute this software for any
@@ -1,4 +1,4 @@
/* Copyright (c) 2022, Google Inc.
/* Copyright 2022 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2016, Google Inc.
/* Copyright 2016 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2018, Google Inc.
/* Copyright 2018 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
+17 -1
View File
@@ -117,6 +117,22 @@ static uint64_t OPENSSL_xgetbv(uint32_t xcr) {
#endif
}
static bool os_supports_avx512(uint64_t xcr0) {
#if defined(__APPLE__)
// The Darwin kernel had a bug where it could corrupt the opmask registers.
// See
// https://community.intel.com/t5/Software-Tuning-Performance/MacOS-Darwin-kernel-bug-clobbers-AVX-512-opmask-register-state/m-p/1327259
// Darwin also does not initially set the XCR0 bits for AVX512, but they are
// set if the thread tries to use AVX512 anyway. Thus, to safely and
// consistently use AVX512 on macOS we'd need to check the kernel version as
// well as detect AVX512 support using a macOS-specific method. We don't
// bother with this, especially given Apple's transition to arm64.
return false;
#else
return (xcr0 & 0xe6) == 0xe6;
#endif
}
// handle_cpu_env applies the value from |in| to the CPUID values in |out[0]|
// and |out[1]|. See the comment in |OPENSSL_cpuid_setup| about this.
static void handle_cpu_env(uint32_t *out, const char *in) {
@@ -234,7 +250,7 @@ void OPENSSL_cpuid_setup(void) {
// See Intel manual, volume 1, sections 15.2 ("Detection of AVX-512 Foundation
// Instructions") through 15.4 ("Detection of Intel AVX-512 Instruction Groups
// Operating at 256 and 128-bit Vector Lengths").
if ((xcr0 & 0xe6) != 0xe6) {
if (!os_supports_avx512(xcr0)) {
// Without XCR0.111xx11x, no AVX512 feature can be used. This includes ZMM
// registers, masking, SIMD registers 16-31 (even if accessed as YMM or
// XMM), and EVEX-coded instructions (even on YMM or XMM). Even if only
+2 -2
View File
@@ -1,4 +1,4 @@
/* Copyright (c) 2014, Google Inc.
/* Copyright 2014 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -54,7 +54,7 @@ static_assert(sizeof(ossl_ssize_t) == sizeof(size_t),
// archive, linking on OS X will fail to resolve common symbols. By
// initialising it to zero, it becomes a "data symbol", which isn't so
// affected.
HIDDEN uint8_t BORINGSSL_function_hit[7] = {0};
HIDDEN uint8_t BORINGSSL_function_hit[8] = {0};
#endif
#if defined(OPENSSL_X86) || defined(OPENSSL_X86_64)
@@ -1,6 +1,6 @@
#define BORINGSSL_PREFIX CCryptoBoringSSL
#if defined(__arm__) && defined(__linux__)
/* Copyright (c) 2015, Google Inc.
/* Copyright 2015 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2020, Google Inc.
/* Copyright 2020 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2023, Google Inc.
/* Copyright 2023 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2020, Google Inc.
/* Copyright 2020 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2020, Google Inc.
/* Copyright 2020 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2016, Google Inc.
/* Copyright 2016 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,5 +1,5 @@
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2000.
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project
* 2000.
*/
/* ====================================================================
* Copyright (c) 2000-2005 The OpenSSL Project. All rights reserved.
File diff suppressed because it is too large. Load diff
@@ -1,58 +0,0 @@
/* Copyright (c) 2023, Google LLC
*
* 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_DILITHIUM_INTERNAL_H
#define OPENSSL_HEADER_CRYPTO_DILITHIUM_INTERNAL_H
#include <CCryptoBoringSSL_base.h>
#include <experimental/CCryptoBoringSSL_dilithium.h>
#if defined(__cplusplus)
extern "C" {
#endif
// DILITHIUM_GENERATE_KEY_ENTROPY is the number of bytes of uniformly random
// entropy necessary to generate a key pair.
#define DILITHIUM_GENERATE_KEY_ENTROPY 32
// DILITHIUM_SIGNATURE_RANDOMIZER_BYTES is the number of bytes of uniformly
// random entropy necessary to generate a signature in randomized mode.
#define DILITHIUM_SIGNATURE_RANDOMIZER_BYTES 32
// DILITHIUM_generate_key_external_entropy generates a public/private key pair
// using the given seed, writes the encoded public key to
// |out_encoded_public_key| and sets |out_private_key| to the private key,
// returning 1 on success and 0 on failure. Returns 1 on success and 0 on
// failure.
OPENSSL_EXPORT int DILITHIUM_generate_key_external_entropy(
uint8_t out_encoded_public_key[DILITHIUM_PUBLIC_KEY_BYTES],
struct DILITHIUM_private_key *out_private_key,
const uint8_t entropy[DILITHIUM_GENERATE_KEY_ENTROPY]);
// DILITHIUM_sign_deterministic generates a signature for the message |msg| of
// length |msg_len| using |private_key| following the deterministic algorithm,
// and writes the encoded signature to |out_encoded_signature|. Returns 1 on
// success and 0 on failure.
OPENSSL_EXPORT int DILITHIUM_sign_deterministic(
uint8_t out_encoded_signature[DILITHIUM_SIGNATURE_BYTES],
const struct DILITHIUM_private_key *private_key, const uint8_t *msg,
size_t msg_len);
#if defined(__cplusplus)
} // extern C
#endif
#endif // OPENSSL_HEADER_CRYPTO_DILITHIUM_INTERNAL_H
@@ -1,5 +1,5 @@
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2000. */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project
* 2000. */
/* ====================================================================
* Copyright (c) 2000-2005 The OpenSSL Project. All rights reserved.
*
@@ -1,4 +1,4 @@
/* Copyright (c) 2020, Google Inc.
/* Copyright 2020 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2019, Google Inc.
/* Copyright 2019 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2020, Google Inc.
/* Copyright 2020 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2020, Google Inc.
/* Copyright 2020 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2014, Google Inc.
/* Copyright 2014 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -740,7 +740,6 @@ static void err_add_error_vdata(unsigned num, va_list args) {
assert(0); // should not be possible.
}
}
va_end(args);
err_set_error_data(buf);
}
@@ -1,4 +1,4 @@
/* Copyright (c) 2017, Google Inc.
/* Copyright 2017 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
+2 -2
View File
@@ -1,5 +1,5 @@
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006.
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project
* 2006.
*/
/* ====================================================================
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
@@ -1,5 +1,5 @@
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006.
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project
* 2006.
*/
/* ====================================================================
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
@@ -1,4 +1,4 @@
/* Copyright (c) 2017, Google Inc.
/* Copyright 2017 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2017, Google Inc.
/* Copyright 2017 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2022, Google Inc.
/* Copyright 2022 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
+2 -2
View File
@@ -1,5 +1,5 @@
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006.
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project
* 2006.
*/
/* ====================================================================
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
@@ -1,5 +1,5 @@
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006.
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project
* 2006.
*/
/* ====================================================================
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
@@ -1,4 +1,4 @@
/* Copyright (c) 2019, Google Inc.
/* Copyright 2019 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2019, Google Inc.
/* Copyright 2019 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
+2 -2
View File
@@ -1,5 +1,5 @@
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 1999.
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project
* 1999.
*/
/* ====================================================================
* Copyright (c) 1999 The OpenSSL Project. All rights reserved.
@@ -140,7 +140,7 @@ static void scryptROMix(block_t *B, uint64_t r, uint64_t N, block_t *T,
// SCRYPT_MAX_MEM is the default maximum memory that may be allocated by
// |EVP_PBE_scrypt|.
#define SCRYPT_MAX_MEM (1024 * 1024 * 32)
#define SCRYPT_MAX_MEM (1024 * 1024 * 65)
int EVP_PBE_scrypt(const char *password, size_t password_len,
const uint8_t *salt, size_t salt_len, uint64_t N, uint64_t r,
@@ -1,4 +1,4 @@
/* Copyright (c) 2019, Google Inc.
/* Copyright 2019 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2017, Google Inc.
/* Copyright 2017 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2017, Google Inc.
/* Copyright 2017 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -86,6 +86,8 @@
#include "ecdsa/ecdsa.cc.inc"
#include "hkdf/hkdf.cc.inc"
#include "hmac/hmac.cc.inc"
#include "keccak/keccak.cc.inc"
#include "mldsa/mldsa.cc.inc"
#include "modes/cbc.cc.inc"
#include "modes/cfb.cc.inc"
#include "modes/ctr.cc.inc"
@@ -1,4 +1,4 @@
/* Copyright (c) 2024, Google Inc.
/* Copyright 2024 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -34,23 +34,25 @@ extern "C" {
// FIPS service indicator. For the moment, the official service indicator
// remains the counter, not these values. Once we fully transition to
// these return values from bcm we will change that.
enum bcm_infallible_t {
bcm_infallible_approved,
bcm_infallible_not_approved,
enum class bcm_infallible_t {
approved,
not_approved,
};
enum bcm_status_t {
bcm_status_approved,
bcm_status_not_approved,
// Failure codes, which must all be negative.
bcm_status_failure,
enum class bcm_status_t {
approved,
not_approved,
failure,
};
typedef enum bcm_status_t bcm_status;
typedef enum bcm_infallible_t bcm_infallible;
OPENSSL_INLINE int bcm_success(bcm_status status) {
return status == bcm_status_approved || status == bcm_status_not_approved;
return status == bcm_status::approved || status == bcm_status::not_approved;
}
OPENSSL_INLINE bcm_status_t bcm_as_approved_status(int result) {
return result ? bcm_status::approved : bcm_status::failure;
}
@@ -237,6 +239,204 @@ bcm_infallible BCM_sha512_256_final(uint8_t out[BCM_SHA512_256_DIGEST_LENGTH],
SHA512_CTX *sha);
// ML-DSA
//
// Where not commented, these functions have the same signature as the
// corresponding public function.
// BCM_MLDSA_SIGNATURE_RANDOMIZER_BYTES is the number of bytes of uniformly
// random entropy necessary to generate a signature in randomized mode.
#define BCM_MLDSA_SIGNATURE_RANDOMIZER_BYTES 32
// BCM_MLDSA_SEED_BYTES is the number of bytes in an ML-DSA seed value.
#define BCM_MLDSA_SEED_BYTES 32
// BCM_MLDSA65_PRIVATE_KEY_BYTES is the number of bytes in an encoded ML-DSA-65
// private key.
#define BCM_MLDSA65_PRIVATE_KEY_BYTES 4032
// BCM_MLDSA65_PUBLIC_KEY_BYTES is the number of bytes in an encoded ML-DSA-65
// public key.
#define BCM_MLDSA65_PUBLIC_KEY_BYTES 1952
// BCM_MLDSA65_SIGNATURE_BYTES is the number of bytes in an encoded ML-DSA-65
// signature.
#define BCM_MLDSA65_SIGNATURE_BYTES 3309
struct BCM_mldsa65_private_key {
union {
uint8_t bytes[32 + 32 + 64 + 256 * 4 * (5 + 6 + 6)];
uint32_t alignment;
} opaque;
};
struct BCM_mldsa65_public_key {
union {
uint8_t bytes[32 + 64 + 256 * 4 * 6];
uint32_t alignment;
} opaque;
};
OPENSSL_EXPORT bcm_status BCM_mldsa65_generate_key(
uint8_t out_encoded_public_key[BCM_MLDSA65_PUBLIC_KEY_BYTES],
uint8_t out_seed[BCM_MLDSA_SEED_BYTES],
struct BCM_mldsa65_private_key *out_private_key);
OPENSSL_EXPORT bcm_status BCM_mldsa65_private_key_from_seed(
struct BCM_mldsa65_private_key *out_private_key,
const uint8_t seed[BCM_MLDSA_SEED_BYTES]);
OPENSSL_EXPORT bcm_status BCM_mldsa65_public_from_private(
struct BCM_mldsa65_public_key *out_public_key,
const struct BCM_mldsa65_private_key *private_key);
OPENSSL_EXPORT bcm_status BCM_mldsa65_sign(
uint8_t out_encoded_signature[BCM_MLDSA65_SIGNATURE_BYTES],
const struct BCM_mldsa65_private_key *private_key, const uint8_t *msg,
size_t msg_len, const uint8_t *context, size_t context_len);
OPENSSL_EXPORT bcm_status BCM_mldsa65_verify(
const struct BCM_mldsa65_public_key *public_key,
const uint8_t signature[BCM_MLDSA65_SIGNATURE_BYTES], const uint8_t *msg,
size_t msg_len, const uint8_t *context, size_t context_len);
OPENSSL_EXPORT bcm_status BCM_mldsa65_marshal_public_key(
CBB *out, const struct BCM_mldsa65_public_key *public_key);
OPENSSL_EXPORT bcm_status BCM_mldsa65_parse_public_key(
struct BCM_mldsa65_public_key *public_key, CBS *in);
OPENSSL_EXPORT bcm_status BCM_mldsa65_parse_private_key(
struct BCM_mldsa65_private_key *private_key, CBS *in);
// BCM_mldsa65_generate_key_external_entropy generates a public/private key pair
// using the given seed, writes the encoded public key to
// |out_encoded_public_key| and sets |out_private_key| to the private key.
OPENSSL_EXPORT bcm_status BCM_mldsa65_generate_key_external_entropy(
uint8_t out_encoded_public_key[BCM_MLDSA65_PUBLIC_KEY_BYTES],
struct BCM_mldsa65_private_key *out_private_key,
const uint8_t entropy[BCM_MLDSA_SEED_BYTES]);
// BCM_mldsa5_sign_internal signs |msg| using |private_key| and writes the
// signature to |out_encoded_signature|. The |context_prefix| and |context| are
// prefixed to the message, in that order, before signing. The |randomizer|
// value can be set to zero bytes in order to make a deterministic signature, or
// else filled with entropy for the usual |MLDSA_sign| behavior.
OPENSSL_EXPORT bcm_status BCM_mldsa65_sign_internal(
uint8_t out_encoded_signature[BCM_MLDSA65_SIGNATURE_BYTES],
const struct BCM_mldsa65_private_key *private_key, const uint8_t *msg,
size_t msg_len, const uint8_t *context_prefix, size_t context_prefix_len,
const uint8_t *context, size_t context_len,
const uint8_t randomizer[BCM_MLDSA_SIGNATURE_RANDOMIZER_BYTES]);
// BCM_mldsa5_verify_internal verifies that |encoded_signature| is a valid
// signature of |msg| by |public_key|. The |context_prefix| and |context| are
// prefixed to the message before verification, in that order.
OPENSSL_EXPORT bcm_status BCM_mldsa65_verify_internal(
const struct BCM_mldsa65_public_key *public_key,
const uint8_t encoded_signature[BCM_MLDSA65_SIGNATURE_BYTES],
const uint8_t *msg, size_t msg_len, const uint8_t *context_prefix,
size_t context_prefix_len, const uint8_t *context, size_t context_len);
// BCM_mldsa65_marshal_private_key serializes |private_key| to |out| in the
// NIST format for ML-DSA-65 private keys.
OPENSSL_EXPORT bcm_status BCM_mldsa65_marshal_private_key(
CBB *out, const struct BCM_mldsa65_private_key *private_key);
// BCM_MLDSA87_PRIVATE_KEY_BYTES is the number of bytes in an encoded ML-DSA-87
// private key.
#define BCM_MLDSA87_PRIVATE_KEY_BYTES 4896
// BCM_MLDSA87_PUBLIC_KEY_BYTES is the number of bytes in an encoded ML-DSA-87
// public key.
#define BCM_MLDSA87_PUBLIC_KEY_BYTES 2592
// BCM_MLDSA87_SIGNATURE_BYTES is the number of bytes in an encoded ML-DSA-87
// signature.
#define BCM_MLDSA87_SIGNATURE_BYTES 4627
struct BCM_mldsa87_private_key {
union {
uint8_t bytes[32 + 32 + 64 + 256 * 4 * (7 + 8 + 8)];
uint32_t alignment;
} opaque;
};
struct BCM_mldsa87_public_key {
union {
uint8_t bytes[32 + 64 + 256 * 4 * 8];
uint32_t alignment;
} opaque;
};
OPENSSL_EXPORT bcm_status BCM_mldsa87_generate_key(
uint8_t out_encoded_public_key[BCM_MLDSA87_PUBLIC_KEY_BYTES],
uint8_t out_seed[BCM_MLDSA_SEED_BYTES],
struct BCM_mldsa87_private_key *out_private_key);
OPENSSL_EXPORT bcm_status BCM_mldsa87_private_key_from_seed(
struct BCM_mldsa87_private_key *out_private_key,
const uint8_t seed[BCM_MLDSA_SEED_BYTES]);
OPENSSL_EXPORT bcm_status BCM_mldsa87_public_from_private(
struct BCM_mldsa87_public_key *out_public_key,
const struct BCM_mldsa87_private_key *private_key);
OPENSSL_EXPORT bcm_status BCM_mldsa87_sign(
uint8_t out_encoded_signature[BCM_MLDSA87_SIGNATURE_BYTES],
const struct BCM_mldsa87_private_key *private_key, const uint8_t *msg,
size_t msg_len, const uint8_t *context, size_t context_len);
OPENSSL_EXPORT bcm_status
BCM_mldsa87_verify(const struct BCM_mldsa87_public_key *public_key,
const uint8_t *signature, const uint8_t *msg, size_t msg_len,
const uint8_t *context, size_t context_len);
OPENSSL_EXPORT bcm_status BCM_mldsa87_marshal_public_key(
CBB *out, const struct BCM_mldsa87_public_key *public_key);
OPENSSL_EXPORT bcm_status BCM_mldsa87_parse_public_key(
struct BCM_mldsa87_public_key *public_key, CBS *in);
OPENSSL_EXPORT bcm_status BCM_mldsa87_parse_private_key(
struct BCM_mldsa87_private_key *private_key, CBS *in);
// BCM_mldsa87_generate_key_external_entropy generates a public/private key pair
// using the given seed, writes the encoded public key to
// |out_encoded_public_key| and sets |out_private_key| to the private key.
OPENSSL_EXPORT bcm_status BCM_mldsa87_generate_key_external_entropy(
uint8_t out_encoded_public_key[BCM_MLDSA87_PUBLIC_KEY_BYTES],
struct BCM_mldsa87_private_key *out_private_key,
const uint8_t entropy[BCM_MLDSA_SEED_BYTES]);
// BCM_mldsa87_sign_internal signs |msg| using |private_key| and writes the
// signature to |out_encoded_signature|. The |context_prefix| and |context| are
// prefixed to the message, in that order, before signing. The |randomizer|
// value can be set to zero bytes in order to make a deterministic signature, or
// else filled with entropy for the usual |MLDSA_sign| behavior.
OPENSSL_EXPORT bcm_status BCM_mldsa87_sign_internal(
uint8_t out_encoded_signature[BCM_MLDSA87_SIGNATURE_BYTES],
const struct BCM_mldsa87_private_key *private_key, const uint8_t *msg,
size_t msg_len, const uint8_t *context_prefix, size_t context_prefix_len,
const uint8_t *context, size_t context_len,
const uint8_t randomizer[BCM_MLDSA_SIGNATURE_RANDOMIZER_BYTES]);
// BCM_mldsa87_verify_internal verifies that |encoded_signature| is a valid
// signature of |msg| by |public_key|. The |context_prefix| and |context| are
// prefixed to the message before verification, in that order.
OPENSSL_EXPORT bcm_status BCM_mldsa87_verify_internal(
const struct BCM_mldsa87_public_key *public_key,
const uint8_t encoded_signature[BCM_MLDSA87_SIGNATURE_BYTES],
const uint8_t *msg, size_t msg_len, const uint8_t *context_prefix,
size_t context_prefix_len, const uint8_t *context, size_t context_len);
// BCM_mldsa87_marshal_private_key serializes |private_key| to |out| in the
// NIST format for ML-DSA-87 private keys.
OPENSSL_EXPORT bcm_status BCM_mldsa87_marshal_private_key(
CBB *out, const struct BCM_mldsa87_private_key *private_key);
#if defined(__cplusplus)
} // extern C
#endif
@@ -1,4 +1,4 @@
/* Copyright (c) 2018, Google Inc.
/* Copyright 2018 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2018, Google Inc.
/* Copyright 2018 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2014, Google Inc.
/* Copyright 2014 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2017, Google Inc.
/* Copyright 2017 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2022, Google Inc.
/* Copyright 2022 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -266,24 +266,27 @@ int EVP_Digest(const void *data, size_t count, uint8_t *out_md,
return ret;
}
const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx) {
const EVP_MD *EVP_MD_CTX_get0_md(const EVP_MD_CTX *ctx) {
if (ctx == NULL) {
return NULL;
}
return ctx->digest;
}
const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx) {
return EVP_MD_CTX_get0_md(ctx);
}
size_t EVP_MD_CTX_size(const EVP_MD_CTX *ctx) {
return EVP_MD_size(EVP_MD_CTX_md(ctx));
return EVP_MD_size(EVP_MD_CTX_get0_md(ctx));
}
size_t EVP_MD_CTX_block_size(const EVP_MD_CTX *ctx) {
return EVP_MD_block_size(EVP_MD_CTX_md(ctx));
return EVP_MD_block_size(EVP_MD_CTX_get0_md(ctx));
}
int EVP_MD_CTX_type(const EVP_MD_CTX *ctx) {
return EVP_MD_type(EVP_MD_CTX_md(ctx));
return EVP_MD_type(EVP_MD_CTX_get0_md(ctx));
}
int EVP_add_digest(const EVP_MD *digest) { return 1; }
@@ -1,5 +1,5 @@
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006.
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project
* 2006.
*/
/* ====================================================================
* Copyright (c) 2006,2007 The OpenSSL Project. All rights reserved.
@@ -1,4 +1,4 @@
/* Copyright (c) 2023, Google Inc.
/* Copyright 2023 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2018, Google Inc.
/* Copyright 2018 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2015, Google Inc.
/* Copyright 2015 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2020, Google Inc.
/* Copyright 2020 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2020, Google Inc.
/* Copyright 2020 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2018, Google Inc.
/* Copyright 2018 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2018, Google Inc.
/* Copyright 2018 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2015, Google Inc.
/* Copyright 2015 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2021, Google Inc.
/* Copyright 2021 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2019, Google Inc.
/* Copyright 2019 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2014, Google Inc.
/* Copyright 2014 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2023, Google Inc.
/* Copyright 2023 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2023, Google Inc.
/* Copyright 2023 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -17,7 +17,7 @@
#include <assert.h>
#include <stdlib.h>
#include "../internal.h"
#include "../../internal.h"
#include "./internal.h"
File diff suppressed because it is too large. Load diff
@@ -135,14 +135,42 @@ void gcm_init_ssse3(u128 Htable[16], const uint64_t H[2]) {
#if defined(HW_GCM) && defined(OPENSSL_X86_64)
static size_t hw_gcm_encrypt(const uint8_t *in, uint8_t *out, size_t len,
const AES_KEY *key, uint8_t ivec[16],
uint8_t Xi[16], const u128 Htable[16]) {
return aesni_gcm_encrypt(in, out, len, key, ivec, Htable, Xi);
uint8_t Xi[16], const u128 Htable[16],
enum gcm_impl_t impl) {
switch (impl) {
case gcm_x86_vaes_avx10_256:
len &= kSizeTWithoutLower4Bits;
aes_gcm_enc_update_vaes_avx10_256(in, out, len, key, ivec, Htable, Xi);
CRYPTO_store_u32_be(&ivec[12], CRYPTO_load_u32_be(&ivec[12]) + len / 16);
return len;
case gcm_x86_vaes_avx10_512:
len &= kSizeTWithoutLower4Bits;
aes_gcm_enc_update_vaes_avx10_512(in, out, len, key, ivec, Htable, Xi);
CRYPTO_store_u32_be(&ivec[12], CRYPTO_load_u32_be(&ivec[12]) + len / 16);
return len;
default:
return aesni_gcm_encrypt(in, out, len, key, ivec, Htable, Xi);
}
}
static size_t hw_gcm_decrypt(const uint8_t *in, uint8_t *out, size_t len,
const AES_KEY *key, uint8_t ivec[16],
uint8_t Xi[16], const u128 Htable[16]) {
return aesni_gcm_decrypt(in, out, len, key, ivec, Htable, Xi);
uint8_t Xi[16], const u128 Htable[16],
enum gcm_impl_t impl) {
switch (impl) {
case gcm_x86_vaes_avx10_256:
len &= kSizeTWithoutLower4Bits;
aes_gcm_dec_update_vaes_avx10_256(in, out, len, key, ivec, Htable, Xi);
CRYPTO_store_u32_be(&ivec[12], CRYPTO_load_u32_be(&ivec[12]) + len / 16);
return len;
case gcm_x86_vaes_avx10_512:
len &= kSizeTWithoutLower4Bits;
aes_gcm_dec_update_vaes_avx10_512(in, out, len, key, ivec, Htable, Xi);
CRYPTO_store_u32_be(&ivec[12], CRYPTO_load_u32_be(&ivec[12]) + len / 16);
return len;
default:
return aesni_gcm_decrypt(in, out, len, key, ivec, Htable, Xi);
}
}
#endif // HW_GCM && X86_64
@@ -150,7 +178,8 @@ static size_t hw_gcm_decrypt(const uint8_t *in, uint8_t *out, size_t len,
static size_t hw_gcm_encrypt(const uint8_t *in, uint8_t *out, size_t len,
const AES_KEY *key, uint8_t ivec[16],
uint8_t Xi[16], const u128 Htable[16]) {
uint8_t Xi[16], const u128 Htable[16],
enum gcm_impl_t impl) {
const size_t len_blocks = len & kSizeTWithoutLower4Bits;
if (!len_blocks) {
return 0;
@@ -161,7 +190,8 @@ static size_t hw_gcm_encrypt(const uint8_t *in, uint8_t *out, size_t len,
static size_t hw_gcm_decrypt(const uint8_t *in, uint8_t *out, size_t len,
const AES_KEY *key, uint8_t ivec[16],
uint8_t Xi[16], const u128 Htable[16]) {
uint8_t Xi[16], const u128 Htable[16],
enum gcm_impl_t impl) {
const size_t len_blocks = len & kSizeTWithoutLower4Bits;
if (!len_blocks) {
return 0;
@@ -173,21 +203,28 @@ static size_t hw_gcm_decrypt(const uint8_t *in, uint8_t *out, size_t len,
#endif // HW_GCM && AARCH64
void CRYPTO_ghash_init(gmult_func *out_mult, ghash_func *out_hash,
u128 out_table[16], int *out_is_avx,
const uint8_t gcm_key[16]) {
*out_is_avx = 0;
u128 out_table[16], const uint8_t gcm_key[16]) {
// H is passed to |gcm_init_*| as a pair of byte-swapped, 64-bit values.
uint64_t H[2] = {CRYPTO_load_u64_be(gcm_key),
CRYPTO_load_u64_be(gcm_key + 8)};
#if defined(GHASH_ASM_X86_64)
if (crypto_gcm_clmul_enabled()) {
if (CRYPTO_is_AVX512BW_capable() && CRYPTO_is_AVX512VL_capable() &&
CRYPTO_is_VPCLMULQDQ_capable() && CRYPTO_is_BMI2_capable()) {
gcm_init_vpclmulqdq_avx10(out_table, H);
*out_mult = gcm_gmult_vpclmulqdq_avx10;
if (CRYPTO_cpu_avoid_zmm_registers()) {
*out_hash = gcm_ghash_vpclmulqdq_avx10_256;
} else {
*out_hash = gcm_ghash_vpclmulqdq_avx10_512;
}
return;
}
if (CRYPTO_is_AVX_capable() && CRYPTO_is_MOVBE_capable()) {
gcm_init_avx(out_table, H);
*out_mult = gcm_gmult_avx;
*out_hash = gcm_ghash_avx;
*out_is_avx = 1;
return;
}
gcm_init_clmul(out_table, H);
@@ -244,14 +281,25 @@ void CRYPTO_gcm128_init_key(GCM128_KEY *gcm_key, const AES_KEY *aes_key,
OPENSSL_memset(ghash_key, 0, sizeof(ghash_key));
(*block)(ghash_key, ghash_key, aes_key);
int is_avx;
CRYPTO_ghash_init(&gcm_key->gmult, &gcm_key->ghash, gcm_key->Htable, &is_avx,
CRYPTO_ghash_init(&gcm_key->gmult, &gcm_key->ghash, gcm_key->Htable,
ghash_key);
#if defined(OPENSSL_AARCH64) && !defined(OPENSSL_NO_ASM)
gcm_key->use_hw_gcm_crypt = (gcm_pmull_capable() && block_is_hwaes) ? 1 : 0;
#else
gcm_key->use_hw_gcm_crypt = (is_avx && block_is_hwaes) ? 1 : 0;
#if !defined(OPENSSL_NO_ASM)
#if defined(OPENSSL_X86_64)
if (gcm_key->ghash == gcm_ghash_vpclmulqdq_avx10_256 &&
CRYPTO_is_VAES_capable()) {
gcm_key->impl = gcm_x86_vaes_avx10_256;
} else if (gcm_key->ghash == gcm_ghash_vpclmulqdq_avx10_512 &&
CRYPTO_is_VAES_capable()) {
gcm_key->impl = gcm_x86_vaes_avx10_512;
} else if (gcm_key->ghash == gcm_ghash_avx && block_is_hwaes) {
gcm_key->impl = gcm_x86_aesni;
}
#elif defined(OPENSSL_AARCH64)
if (gcm_pmull_capable() && block_is_hwaes) {
gcm_key->impl = gcm_arm64_aes;
}
#endif
#endif
}
@@ -565,11 +613,11 @@ int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx, const AES_KEY *key,
#if defined(HW_GCM)
// Check |len| to work around a C language bug. See https://crbug.com/1019588.
if (ctx->gcm_key.use_hw_gcm_crypt && len > 0) {
if (ctx->gcm_key.impl != gcm_separate && len > 0) {
// |hw_gcm_encrypt| may not process all the input given to it. It may
// not process *any* of its input if it is deemed too small.
size_t bulk = hw_gcm_encrypt(in, out, len, key, ctx->Yi, ctx->Xi,
ctx->gcm_key.Htable);
ctx->gcm_key.Htable, ctx->gcm_key.impl);
in += bulk;
out += bulk;
len -= bulk;
@@ -654,11 +702,11 @@ int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx, const AES_KEY *key,
#if defined(HW_GCM)
// Check |len| to work around a C language bug. See https://crbug.com/1019588.
if (ctx->gcm_key.use_hw_gcm_crypt && len > 0) {
if (ctx->gcm_key.impl != gcm_separate && len > 0) {
// |hw_gcm_decrypt| may not process all the input given to it. It may
// not process *any* of its input if it is deemed too small.
size_t bulk = hw_gcm_decrypt(in, out, len, key, ctx->Yi, ctx->Xi,
ctx->gcm_key.Htable);
ctx->gcm_key.Htable, ctx->gcm_key.impl);
in += bulk;
out += bulk;
len -= bulk;
@@ -1,4 +1,4 @@
/* Copyright (c) 2019, Google Inc.
/* Copyright 2019 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -126,6 +126,15 @@ void CRYPTO_ctr128_encrypt_ctr32(const uint8_t *in, uint8_t *out, size_t len,
// can be safely copied. Additionally, |gcm_key| is split into a separate
// struct.
// gcm_impl_t specifies an assembly implementation of AES-GCM.
enum gcm_impl_t {
gcm_separate = 0, // No combined AES-GCM, but may have AES-CTR and GHASH.
gcm_x86_aesni,
gcm_x86_vaes_avx10_256,
gcm_x86_vaes_avx10_512,
gcm_arm64_aes,
};
typedef struct { uint64_t hi,lo; } u128;
// gmult_func multiplies |Xi| by the GCM key and writes the result back to
@@ -148,10 +157,7 @@ typedef struct gcm128_key_st {
ghash_func ghash;
block128_f block;
// use_hw_gcm_crypt is true if this context should use platform-specific
// assembly to process GCM data.
unsigned use_hw_gcm_crypt:1;
enum gcm_impl_t impl;
} GCM128_KEY;
// GCM128_CONTEXT contains state for a single GCM operation. The structure
@@ -182,72 +188,62 @@ int crypto_gcm_clmul_enabled(void);
// CRYPTO_ghash_init writes a precomputed table of powers of |gcm_key| to
// |out_table| and sets |*out_mult| and |*out_hash| to (potentially hardware
// accelerated) functions for performing operations in the GHASH field. If the
// AVX implementation was used |*out_is_avx| will be true.
// accelerated) functions for performing operations in the GHASH field.
void CRYPTO_ghash_init(gmult_func *out_mult, ghash_func *out_hash,
u128 out_table[16], int *out_is_avx,
const uint8_t gcm_key[16]);
u128 out_table[16], const uint8_t gcm_key[16]);
// CRYPTO_gcm128_init_key initialises |gcm_key| to use |block| (typically AES)
// with the given key. |block_is_hwaes| is one if |block| is |aes_hw_encrypt|.
OPENSSL_EXPORT void CRYPTO_gcm128_init_key(GCM128_KEY *gcm_key,
const AES_KEY *key, block128_f block,
int block_is_hwaes);
void CRYPTO_gcm128_init_key(GCM128_KEY *gcm_key, const AES_KEY *key,
block128_f block, int block_is_hwaes);
// CRYPTO_gcm128_setiv sets the IV (nonce) for |ctx|. The |key| must be the
// same key that was passed to |CRYPTO_gcm128_init|.
OPENSSL_EXPORT void CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx, const AES_KEY *key,
const uint8_t *iv, size_t iv_len);
void CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx, const AES_KEY *key,
const uint8_t *iv, size_t iv_len);
// CRYPTO_gcm128_aad sets the authenticated data for an instance of GCM.
// This must be called before and data is encrypted. It returns one on success
// and zero otherwise.
OPENSSL_EXPORT int CRYPTO_gcm128_aad(GCM128_CONTEXT *ctx, const uint8_t *aad,
size_t len);
int CRYPTO_gcm128_aad(GCM128_CONTEXT *ctx, const uint8_t *aad, size_t len);
// CRYPTO_gcm128_encrypt encrypts |len| bytes from |in| to |out|. The |key|
// must be the same key that was passed to |CRYPTO_gcm128_init|. It returns one
// on success and zero otherwise.
OPENSSL_EXPORT int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx,
const AES_KEY *key, const uint8_t *in,
uint8_t *out, size_t len);
int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx, const AES_KEY *key,
const uint8_t *in, uint8_t *out, size_t len);
// CRYPTO_gcm128_decrypt decrypts |len| bytes from |in| to |out|. The |key|
// must be the same key that was passed to |CRYPTO_gcm128_init|. It returns one
// on success and zero otherwise.
OPENSSL_EXPORT int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx,
const AES_KEY *key, const uint8_t *in,
uint8_t *out, size_t len);
int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx, const AES_KEY *key,
const uint8_t *in, uint8_t *out, size_t len);
// CRYPTO_gcm128_encrypt_ctr32 encrypts |len| bytes from |in| to |out| using
// a CTR function that only handles the bottom 32 bits of the nonce, like
// |CRYPTO_ctr128_encrypt_ctr32|. The |key| must be the same key that was
// passed to |CRYPTO_gcm128_init|. It returns one on success and zero
// otherwise.
OPENSSL_EXPORT int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx,
const AES_KEY *key,
const uint8_t *in, uint8_t *out,
size_t len, ctr128_f stream);
int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx, const AES_KEY *key,
const uint8_t *in, uint8_t *out, size_t len,
ctr128_f stream);
// CRYPTO_gcm128_decrypt_ctr32 decrypts |len| bytes from |in| to |out| using
// a CTR function that only handles the bottom 32 bits of the nonce, like
// |CRYPTO_ctr128_encrypt_ctr32|. The |key| must be the same key that was
// passed to |CRYPTO_gcm128_init|. It returns one on success and zero
// otherwise.
OPENSSL_EXPORT int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx,
const AES_KEY *key,
const uint8_t *in, uint8_t *out,
size_t len, ctr128_f stream);
int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx, const AES_KEY *key,
const uint8_t *in, uint8_t *out, size_t len,
ctr128_f stream);
// CRYPTO_gcm128_finish calculates the authenticator and compares it against
// |len| bytes of |tag|. It returns one on success and zero otherwise.
OPENSSL_EXPORT int CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx, const uint8_t *tag,
size_t len);
int CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx, const uint8_t *tag, size_t len);
// CRYPTO_gcm128_tag calculates the authenticator and copies it into |tag|.
// The minimum of |len| and 16 bytes are copied into |tag|.
OPENSSL_EXPORT void CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, uint8_t *tag,
size_t len);
void CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, uint8_t *tag, size_t len);
// GCM assembly.
@@ -287,6 +283,30 @@ size_t aesni_gcm_encrypt(const uint8_t *in, uint8_t *out, size_t len,
size_t aesni_gcm_decrypt(const uint8_t *in, uint8_t *out, size_t len,
const AES_KEY *key, uint8_t ivec[16],
const u128 Htable[16], uint8_t Xi[16]);
void gcm_init_vpclmulqdq_avx10(u128 Htable[16], const uint64_t H[2]);
void gcm_gmult_vpclmulqdq_avx10(uint8_t Xi[16], const u128 Htable[16]);
void gcm_ghash_vpclmulqdq_avx10_256(uint8_t Xi[16], const u128 Htable[16],
const uint8_t *in, size_t len);
void gcm_ghash_vpclmulqdq_avx10_512(uint8_t Xi[16], const u128 Htable[16],
const uint8_t *in, size_t len);
void aes_gcm_enc_update_vaes_avx10_256(const uint8_t *in, uint8_t *out,
size_t len, const AES_KEY *key,
const uint8_t ivec[16],
const u128 Htable[16], uint8_t Xi[16]);
void aes_gcm_dec_update_vaes_avx10_256(const uint8_t *in, uint8_t *out,
size_t len, const AES_KEY *key,
const uint8_t ivec[16],
const u128 Htable[16], uint8_t Xi[16]);
void aes_gcm_enc_update_vaes_avx10_512(const uint8_t *in, uint8_t *out,
size_t len, const AES_KEY *key,
const uint8_t ivec[16],
const u128 Htable[16], uint8_t Xi[16]);
void aes_gcm_dec_update_vaes_avx10_512(const uint8_t *in, uint8_t *out,
size_t len, const AES_KEY *key,
const uint8_t ivec[16],
const u128 Htable[16], uint8_t Xi[16]);
#endif // OPENSSL_X86_64
#if defined(OPENSSL_X86)
@@ -1,4 +1,4 @@
/* Copyright (c) 2016, Google Inc.
/* Copyright 2016 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -56,8 +56,7 @@ void CRYPTO_POLYVAL_init(struct polyval_ctx *ctx, const uint8_t key[16]) {
OPENSSL_memcpy(H, key, 16);
reverse_and_mulX_ghash(H);
int is_avx;
CRYPTO_ghash_init(&ctx->gmult, &ctx->ghash, ctx->Htable, &is_avx, H);
CRYPTO_ghash_init(&ctx->gmult, &ctx->ghash, ctx->Htable, H);
OPENSSL_memset(&ctx->S, 0, sizeof(ctx->S));
}
@@ -1,4 +1,4 @@
/* Copyright (c) 2017, Google Inc.
/* Copyright 2017 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2015, Google Inc.
/* Copyright 2015 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2014, Google Inc.
/* Copyright 2014 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -169,12 +169,12 @@ static int rdrand(uint8_t *buf, size_t len) { return 0; }
bcm_status BCM_rand_bytes_hwrng(uint8_t *buf, const size_t len) {
if (!have_rdrand()) {
return bcm_status_failure;
return bcm_status::failure;
}
if (rdrand(buf, len)) {
return bcm_status_not_approved;
return bcm_status::not_approved;
}
return bcm_status_failure;
return bcm_status::failure;
}
#if defined(BORINGSSL_FIPS)
@@ -213,7 +213,7 @@ bcm_infallible BCM_rand_load_entropy(const uint8_t *entropy, size_t entropy_len,
buffer->bytes_valid += entropy_len;
buffer->want_additional_input |= want_additional_input && (entropy_len != 0);
CRYPTO_MUTEX_unlock_write(entropy_buffer_lock_bss_get());
return bcm_infallible_not_approved;
return bcm_infallible::not_approved;
}
// get_seed_entropy fills |out_entropy_len| bytes of |out_entropy| from the
@@ -330,7 +330,7 @@ static void rand_get_seed(struct rand_thread_state *state,
bcm_infallible BCM_rand_bytes_with_additional_data(
uint8_t *out, size_t out_len, const uint8_t user_additional_data[32]) {
if (out_len == 0) {
return bcm_infallible_approved;
return bcm_infallible::approved;
}
const uint64_t fork_generation = CRYPTO_get_fork_generation();
@@ -471,11 +471,11 @@ bcm_infallible BCM_rand_bytes_with_additional_data(
#if defined(BORINGSSL_FIPS)
CRYPTO_MUTEX_unlock_read(&state->clear_drbg_lock);
#endif
return bcm_infallible_approved;
return bcm_infallible::approved;
}
bcm_infallible BCM_rand_bytes(uint8_t *out, size_t out_len) {
static const uint8_t kZeroAdditionalData[32] = {0};
BCM_rand_bytes_with_additional_data(out, out_len, kZeroAdditionalData);
return bcm_infallible_approved;
return bcm_infallible::approved;
}
@@ -1,5 +1,5 @@
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2005.
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project
* 2005.
*/
/* ====================================================================
* Copyright (c) 2005 The OpenSSL Project. All rights reserved.
@@ -1,4 +1,4 @@
/* Copyright (c) 2017, Google Inc.
/* Copyright 2017 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
/* Copyright (c) 2017, Google Inc.
/* Copyright 2017 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -186,7 +186,7 @@ static int is_md_fips_approved_for_verifying(int md_type) {
static void evp_md_ctx_verify_service_indicator(const EVP_MD_CTX *ctx,
int (*md_ok)(int md_type)) {
if (EVP_MD_CTX_md(ctx) == NULL) {
if (EVP_MD_CTX_get0_md(ctx) == NULL) {
// Signature schemes without a prehash are currently never FIPS approved.
return;
}
@@ -1,4 +1,4 @@
/* Copyright (c) 2018, Google Inc.
/* Copyright 2018 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -72,7 +72,7 @@ bcm_infallible BCM_sha1_init(SHA_CTX *sha) {
sha->h[2] = 0x98badcfeUL;
sha->h[3] = 0x10325476UL;
sha->h[4] = 0xc3d2e1f0UL;
return bcm_infallible_approved;
return bcm_infallible::approved;
}
#if !defined(SHA1_ASM)
@@ -82,14 +82,14 @@ static void sha1_block_data_order(uint32_t state[5], const uint8_t *data,
bcm_infallible BCM_sha1_transform(SHA_CTX *c, const uint8_t data[SHA_CBLOCK]) {
sha1_block_data_order(c->h, data, 1);
return bcm_infallible_approved;
return bcm_infallible::approved;
}
bcm_infallible BCM_sha1_update(SHA_CTX *c, const void *data, size_t len) {
crypto_md32_update(&sha1_block_data_order, c->h, c->data, SHA_CBLOCK, &c->num,
&c->Nh, &c->Nl, reinterpret_cast<const uint8_t *>(data),
len);
return bcm_infallible_approved;
return bcm_infallible::approved;
}
static void sha1_output_state(uint8_t out[SHA_DIGEST_LENGTH],
@@ -107,7 +107,7 @@ bcm_infallible BCM_sha1_final(uint8_t out[SHA_DIGEST_LENGTH], SHA_CTX *c) {
sha1_output_state(out, c);
FIPS_service_indicator_update_state();
return bcm_infallible_approved;
return bcm_infallible::approved;
}
bcm_infallible BCM_fips_186_2_prf(uint8_t *out, size_t out_len,
@@ -144,7 +144,7 @@ bcm_infallible BCM_fips_186_2_prf(uint8_t *out, size_t out_len,
out += SHA_DIGEST_LENGTH;
out_len -= SHA_DIGEST_LENGTH;
}
return bcm_infallible_not_approved;
return bcm_infallible::not_approved;
}
#define Xupdate(a, ix, ia, ib, ic, id) \
@@ -76,7 +76,7 @@ bcm_infallible BCM_sha224_init(SHA256_CTX *sha) {
sha->h[6] = 0x64f98fa7UL;
sha->h[7] = 0xbefa4fa4UL;
sha->md_len = BCM_SHA224_DIGEST_LENGTH;
return bcm_infallible_approved;
return bcm_infallible::approved;
}
bcm_infallible BCM_sha256_init(SHA256_CTX *sha) {
@@ -90,7 +90,7 @@ bcm_infallible BCM_sha256_init(SHA256_CTX *sha) {
sha->h[6] = 0x1f83d9abUL;
sha->h[7] = 0x5be0cd19UL;
sha->md_len = BCM_SHA256_DIGEST_LENGTH;
return bcm_infallible_approved;
return bcm_infallible::approved;
}
#if !defined(SHA256_ASM)
@@ -101,14 +101,14 @@ static void sha256_block_data_order(uint32_t state[8], const uint8_t *in,
bcm_infallible BCM_sha256_transform(SHA256_CTX *c,
const uint8_t data[BCM_SHA256_CBLOCK]) {
sha256_block_data_order(c->h, data, 1);
return bcm_infallible_approved;
return bcm_infallible::approved;
}
bcm_infallible BCM_sha256_update(SHA256_CTX *c, const void *data, size_t len) {
crypto_md32_update(&sha256_block_data_order, c->h, c->data, BCM_SHA256_CBLOCK,
&c->num, &c->Nh, &c->Nl,
reinterpret_cast<const uint8_t *>(data), len);
return bcm_infallible_approved;
return bcm_infallible::approved;
}
bcm_infallible BCM_sha224_update(SHA256_CTX *ctx, const void *data,
@@ -140,7 +140,7 @@ bcm_infallible BCM_sha256_final(uint8_t out[BCM_SHA256_DIGEST_LENGTH],
//
// TODO(davidben): Add an assert and fix code to match them up.
sha256_final_impl(out, c->md_len, c);
return bcm_infallible_approved;
return bcm_infallible::approved;
}
bcm_infallible BCM_sha224_final(uint8_t out[BCM_SHA224_DIGEST_LENGTH],
@@ -149,7 +149,7 @@ bcm_infallible BCM_sha224_final(uint8_t out[BCM_SHA224_DIGEST_LENGTH],
// to |BCM_SHA224_DIGEST_LENGTH|.
assert(ctx->md_len == BCM_SHA224_DIGEST_LENGTH);
sha256_final_impl(out, BCM_SHA224_DIGEST_LENGTH, ctx);
return bcm_infallible_approved;
return bcm_infallible::approved;
}
#if !defined(SHA256_ASM)
@@ -328,7 +328,7 @@ bcm_infallible BCM_sha256_transform_blocks(uint32_t state[8],
const uint8_t *data,
size_t num_blocks) {
sha256_block_data_order(state, data, num_blocks);
return bcm_infallible_approved;
return bcm_infallible::approved;
}
#undef Sigma0
@@ -86,7 +86,7 @@ bcm_infallible BCM_sha384_init(SHA512_CTX *sha) {
sha->Nh = 0;
sha->num = 0;
sha->md_len = BCM_SHA384_DIGEST_LENGTH;
return bcm_infallible_approved;
return bcm_infallible::approved;
}
@@ -104,7 +104,7 @@ bcm_infallible BCM_sha512_init(SHA512_CTX *sha) {
sha->Nh = 0;
sha->num = 0;
sha->md_len = BCM_SHA512_DIGEST_LENGTH;
return bcm_infallible_approved;
return bcm_infallible::approved;
}
bcm_infallible BCM_sha512_256_init(SHA512_CTX *sha) {
@@ -121,7 +121,7 @@ bcm_infallible BCM_sha512_256_init(SHA512_CTX *sha) {
sha->Nh = 0;
sha->num = 0;
sha->md_len = BCM_SHA512_256_DIGEST_LENGTH;
return bcm_infallible_approved;
return bcm_infallible::approved;
}
#if !defined(SHA512_ASM)
@@ -136,7 +136,7 @@ bcm_infallible BCM_sha384_final(uint8_t out[BCM_SHA384_DIGEST_LENGTH],
// |sha->md_len| to |BCM_SHA384_DIGEST_LENGTH|.
assert(sha->md_len == BCM_SHA384_DIGEST_LENGTH);
sha512_final_impl(out, BCM_SHA384_DIGEST_LENGTH, sha);
return bcm_infallible_approved;
return bcm_infallible::approved;
}
bcm_infallible BCM_sha384_update(SHA512_CTX *sha, const void *data,
@@ -155,13 +155,13 @@ bcm_infallible BCM_sha512_256_final(uint8_t out[BCM_SHA512_256_DIGEST_LENGTH],
// |sha->md_len| to |BCM_SHA512_256_DIGEST_LENGTH|.
assert(sha->md_len == BCM_SHA512_256_DIGEST_LENGTH);
sha512_final_impl(out, BCM_SHA512_256_DIGEST_LENGTH, sha);
return bcm_infallible_approved;
return bcm_infallible::approved;
}
bcm_infallible BCM_sha512_transform(SHA512_CTX *c,
const uint8_t block[SHA512_CBLOCK]) {
sha512_block_data_order(c->h, block, 1);
return bcm_infallible_approved;
return bcm_infallible::approved;
}
bcm_infallible BCM_sha512_update(SHA512_CTX *c, const void *in_data,
@@ -171,7 +171,7 @@ bcm_infallible BCM_sha512_update(SHA512_CTX *c, const void *in_data,
const uint8_t *data = reinterpret_cast<const uint8_t *>(in_data);
if (len == 0) {
return bcm_infallible_approved;
return bcm_infallible::approved;
}
l = (c->Nl + (((uint64_t)len) << 3)) & UINT64_C(0xffffffffffffffff);
@@ -189,7 +189,7 @@ bcm_infallible BCM_sha512_update(SHA512_CTX *c, const void *in_data,
if (len < n) {
OPENSSL_memcpy(p + c->num, data, len);
c->num += (unsigned int)len;
return bcm_infallible_approved;
return bcm_infallible::approved;
} else {
OPENSSL_memcpy(p + c->num, data, n), c->num = 0;
len -= n;
@@ -210,7 +210,7 @@ bcm_infallible BCM_sha512_update(SHA512_CTX *c, const void *in_data,
c->num = (int)len;
}
return bcm_infallible_approved;
return bcm_infallible::approved;
}
bcm_infallible BCM_sha512_final(uint8_t out[BCM_SHA512_DIGEST_LENGTH],
@@ -221,7 +221,7 @@ bcm_infallible BCM_sha512_final(uint8_t out[BCM_SHA512_DIGEST_LENGTH],
//
// TODO(davidben): Add an assert and fix code to match them up.
sha512_final_impl(out, sha->md_len, sha);
return bcm_infallible_approved;
return bcm_infallible::approved;
}
static void sha512_final_impl(uint8_t *out, size_t md_len, SHA512_CTX *sha) {
@@ -1,4 +1,4 @@
/* Copyright (c) 2018, Google Inc.
/* Copyright 2018 The BoringSSL Authors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
Loaded 100 of 242 files, more files were not shown because too many files have changed in this diff. Show more