mirror of
https://github.com/apple/swift-crypto
synced 2026-11-22 04:30:39 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d9825fa541 | ||
|
|
d180057628 | ||
|
|
17d95a6782 | ||
|
|
12a1784190 | ||
|
|
ce8d18032f |
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
||||
# file options
|
||||
|
||||
--swiftversion 5.2
|
||||
--swiftversion 5.4
|
||||
--exclude .build
|
||||
|
||||
# format options
|
||||
|
||||
+64
-19
@@ -1,4 +1,4 @@
|
||||
// swift-tools-version:5.2
|
||||
// swift-tools-version:5.4
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This source file is part of the SwiftCrypto open source project
|
||||
@@ -20,15 +20,38 @@
|
||||
// Sources/CCryptoBoringSSL directory. The source repository is at
|
||||
// https://boringssl.googlesource.com/boringssl.
|
||||
//
|
||||
// BoringSSL Commit: 8bbefbfeee609b17622deedd100163c12f5c95dc
|
||||
// BoringSSL Commit: f961de5c47ed265c3e758ec70dd15ece20809962
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let swiftSettings: [SwiftSetting] = [
|
||||
.define("CRYPTO_IN_SWIFTPM"),
|
||||
// To develop this on Apple platforms, uncomment this define.
|
||||
// .define("CRYPTO_IN_SWIFTPM_FORCE_BUILD_API"),
|
||||
]
|
||||
// To develop this on Apple platforms, set this to true
|
||||
let development = false
|
||||
|
||||
let swiftSettings: [SwiftSetting]
|
||||
let dependencies: [Target.Dependency]
|
||||
if development {
|
||||
swiftSettings = [
|
||||
.define("CRYPTO_IN_SWIFTPM"),
|
||||
.define("CRYPTO_IN_SWIFTPM_FORCE_BUILD_API"),
|
||||
]
|
||||
dependencies = [
|
||||
"CCryptoBoringSSL",
|
||||
"CCryptoBoringSSLShims"
|
||||
]
|
||||
} else {
|
||||
swiftSettings = [
|
||||
.define("CRYPTO_IN_SWIFTPM"),
|
||||
]
|
||||
let platforms: [Platform] = [
|
||||
Platform.linux,
|
||||
Platform.android,
|
||||
Platform.windows,
|
||||
]
|
||||
dependencies = [
|
||||
.target(name: "CCryptoBoringSSL", condition: .when(platforms: platforms)),
|
||||
.target(name: "CCryptoBoringSSLShims", condition: .when(platforms: platforms))
|
||||
]
|
||||
}
|
||||
|
||||
let package = Package(
|
||||
name: "swift-crypto",
|
||||
@@ -48,20 +71,42 @@ let package = Package(
|
||||
dependencies: [],
|
||||
targets: [
|
||||
.target(
|
||||
name: "CCryptoBoringSSL",
|
||||
cSettings: [
|
||||
/*
|
||||
* This define is required on Windows, but because we need older
|
||||
* versions of SPM, we cannot conditionally define this on Windows
|
||||
* only. Unconditionally define it instead.
|
||||
*/
|
||||
.define("WIN32_LEAN_AND_MEAN"),
|
||||
]
|
||||
name: "CCryptoBoringSSL",
|
||||
exclude: [
|
||||
"hash.txt",
|
||||
"include/boringssl_prefix_symbols_nasm.inc",
|
||||
"CMakeLists.txt",
|
||||
],
|
||||
cSettings: [
|
||||
/*
|
||||
* This define is required on Windows, but because we need older
|
||||
* versions of SPM, we cannot conditionally define this on Windows
|
||||
* only. Unconditionally define it instead.
|
||||
*/
|
||||
.define("WIN32_LEAN_AND_MEAN"),
|
||||
]
|
||||
),
|
||||
.target(
|
||||
name: "CCryptoBoringSSLShims",
|
||||
dependencies: ["CCryptoBoringSSL"],
|
||||
exclude: [
|
||||
"CMakeLists.txt"
|
||||
]
|
||||
),
|
||||
.target(
|
||||
name: "Crypto",
|
||||
dependencies: dependencies,
|
||||
exclude: [
|
||||
"CMakeLists.txt",
|
||||
"AEADs/Nonces.swift.gyb",
|
||||
"Digests/Digests.swift.gyb",
|
||||
"Key Agreement/ECDH.swift.gyb",
|
||||
"Signatures/ECDSA.swift.gyb",
|
||||
],
|
||||
swiftSettings: swiftSettings
|
||||
),
|
||||
.target(name: "CCryptoBoringSSLShims", dependencies: ["CCryptoBoringSSL"]),
|
||||
.target(name: "Crypto", dependencies: ["CCryptoBoringSSL", "CCryptoBoringSSLShims"], swiftSettings: swiftSettings),
|
||||
.target(name: "_CryptoExtras", dependencies: ["CCryptoBoringSSL", "CCryptoBoringSSLShims", "Crypto"]),
|
||||
.target(name: "crypto-shasum", dependencies: ["Crypto"]),
|
||||
.executableTarget(name: "crypto-shasum", dependencies: ["Crypto"]),
|
||||
.testTarget(name: "CryptoTests", dependencies: ["Crypto"], swiftSettings: swiftSettings),
|
||||
.testTarget(name: "_CryptoExtrasTests", dependencies: ["_CryptoExtras"]),
|
||||
],
|
||||
|
||||
@@ -108,7 +108,7 @@ If you believe you have identified a vulnerability in Swift Crypto, please [repo
|
||||
|
||||
### Swift versions
|
||||
|
||||
Swift Crypto supports Swift 5.2 and later. Swift Crypto supported Swift 5.1 until version 1.2.
|
||||
Swift Crypto supports Swift 5.4 and later. Swift Crypto supported Swift 5.2 and 5.3 until version 2.1 and Swift 5.1 until version 2.0.
|
||||
|
||||
### Compatibility
|
||||
|
||||
|
||||
+5
-1
@@ -158,7 +158,7 @@ add_library(CCryptoBoringSSL STATIC
|
||||
"crypto/fipsmodule/ec/felem.c"
|
||||
"crypto/fipsmodule/ec/oct.c"
|
||||
"crypto/fipsmodule/ec/p224-64.c"
|
||||
"crypto/fipsmodule/ec/p256-x86_64.c"
|
||||
"crypto/fipsmodule/ec/p256-nistz.c"
|
||||
"crypto/fipsmodule/ec/p256.c"
|
||||
"crypto/fipsmodule/ec/scalar.c"
|
||||
"crypto/fipsmodule/ec/simple.c"
|
||||
@@ -364,6 +364,8 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin AND CMAKE_SYSTEM_PROCESSOR MATCHES "arm
|
||||
crypto/fipsmodule/armv8-mont.ios.aarch64.S
|
||||
crypto/fipsmodule/ghash-neon-armv8.ios.aarch64.S
|
||||
crypto/fipsmodule/ghashv8-armx64.ios.aarch64.S
|
||||
crypto/fipsmodule/p256-armv8-asm.ios.aarch64.S
|
||||
crypto/fipsmodule/p256_beeu-armv8-asm.ios.aarch64.S
|
||||
crypto/fipsmodule/sha1-armv8.ios.aarch64.S
|
||||
crypto/fipsmodule/sha256-armv8.ios.aarch64.S
|
||||
crypto/fipsmodule/sha512-armv8.ios.aarch64.S
|
||||
@@ -375,6 +377,8 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "Linux|Android" AND CMAKE_SYSTEM_PROCESSOR MATC
|
||||
crypto/fipsmodule/armv8-mont.linux.aarch64.S
|
||||
crypto/fipsmodule/ghash-neon-armv8.linux.aarch64.S
|
||||
crypto/fipsmodule/ghashv8-armx64.linux.aarch64.S
|
||||
crypto/fipsmodule/p256-armv8-asm.linux.aarch64.S
|
||||
crypto/fipsmodule/p256_beeu-armv8-asm.linux.aarch64.S
|
||||
crypto/fipsmodule/sha1-armv8.linux.aarch64.S
|
||||
crypto/fipsmodule/sha256-armv8.linux.aarch64.S
|
||||
crypto/fipsmodule/sha512-armv8.linux.aarch64.S
|
||||
|
||||
@@ -74,8 +74,6 @@
|
||||
*/
|
||||
#define ASN1_MAX_CONSTRUCTED_NEST 30
|
||||
|
||||
static int asn1_check_eoc(const unsigned char **in, long len);
|
||||
|
||||
static int asn1_check_tlen(long *olen, int *otag, unsigned char *oclass,
|
||||
char *cst, const unsigned char **in, long len,
|
||||
int exptag, int expclass, char opt, ASN1_TLC *ctx);
|
||||
@@ -373,13 +371,6 @@ static int asn1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in,
|
||||
if (!len)
|
||||
break;
|
||||
q = p;
|
||||
/* TODO(https://crbug.com/boringssl/455): Although we've removed
|
||||
* indefinite-length support, this check is not quite a no-op.
|
||||
* Reject [UNIVERSAL 0] in the tag parsers themselves. */
|
||||
if (asn1_check_eoc(&p, len)) {
|
||||
OPENSSL_PUT_ERROR(ASN1, ASN1_R_UNEXPECTED_EOC);
|
||||
goto err;
|
||||
}
|
||||
/*
|
||||
* This determines the OPTIONAL flag value. The field cannot be
|
||||
* omitted if it is the last of a SEQUENCE and there is still
|
||||
@@ -592,13 +583,6 @@ static int asn1_template_noexp_d2i(ASN1_VALUE **val,
|
||||
while (len > 0) {
|
||||
ASN1_VALUE *skfield;
|
||||
const unsigned char *q = p;
|
||||
/* TODO(https://crbug.com/boringssl/455): Although we've removed
|
||||
* indefinite-length support, this check is not quite a no-op.
|
||||
* Reject [UNIVERSAL 0] in the tag parsers themselves. */
|
||||
if (asn1_check_eoc(&p, len)) {
|
||||
OPENSSL_PUT_ERROR(ASN1, ASN1_R_UNEXPECTED_EOC);
|
||||
goto err;
|
||||
}
|
||||
skfield = NULL;
|
||||
if (!asn1_item_ex_d2i(&skfield, &p, len, ASN1_ITEM_ptr(tt->item),
|
||||
-1, 0, 0, ctx, depth)) {
|
||||
@@ -868,21 +852,6 @@ static int asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Check for ASN1 EOC and swallow it if found */
|
||||
|
||||
static int asn1_check_eoc(const unsigned char **in, long len)
|
||||
{
|
||||
const unsigned char *p;
|
||||
if (len < 2)
|
||||
return 0;
|
||||
p = *in;
|
||||
if (!p[0] && !p[1]) {
|
||||
*in += 2;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check an ASN1 tag and length: a bit like ASN1_get_object but it handles
|
||||
* the ASN1_TLC cache and checks the expected tag.
|
||||
|
||||
@@ -71,18 +71,6 @@ int BIO_printf(BIO *bio, const char *format, ...) {
|
||||
va_start(args, format);
|
||||
out_len = vsnprintf(buf, sizeof(buf), format, args);
|
||||
va_end(args);
|
||||
|
||||
#if defined(OPENSSL_WINDOWS)
|
||||
// On Windows, vsnprintf returns -1 rather than the requested length on
|
||||
// truncation
|
||||
if (out_len < 0) {
|
||||
va_start(args, format);
|
||||
out_len = _vscprintf(format, args);
|
||||
va_end(args);
|
||||
assert(out_len >= (int)sizeof(buf));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (out_len < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -93,11 +93,14 @@ static int cbs_find_ber(const CBS *orig_in, int *ber_found, unsigned depth) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// is_eoc returns true if |header_len| and |contents|, as returned by
|
||||
// |CBS_get_any_ber_asn1_element|, indicate an "end of contents" (EOC) value.
|
||||
static char is_eoc(size_t header_len, CBS *contents) {
|
||||
return header_len == 2 && CBS_len(contents) == 2 &&
|
||||
OPENSSL_memcmp(CBS_data(contents), "\x00\x00", 2) == 0;
|
||||
// cbs_get_eoc returns one if |cbs| begins with an "end of contents" (EOC) value
|
||||
// and zero otherwise. If an EOC was found, it advances |cbs| past it.
|
||||
static int cbs_get_eoc(CBS *cbs) {
|
||||
if (CBS_len(cbs) >= 2 &&
|
||||
CBS_data(cbs)[0] == 0 && CBS_data(cbs)[1] == 0) {
|
||||
return CBS_skip(cbs, 2);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// cbs_convert_ber reads BER data from |in| and writes DER data to |out|. If
|
||||
@@ -116,21 +119,20 @@ static int cbs_convert_ber(CBS *in, CBB *out, unsigned string_tag,
|
||||
}
|
||||
|
||||
while (CBS_len(in) > 0) {
|
||||
if (looking_for_eoc && cbs_get_eoc(in)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
CBS contents;
|
||||
unsigned tag, child_string_tag = string_tag;
|
||||
size_t header_len;
|
||||
int indefinite;
|
||||
CBB *out_contents, out_contents_storage;
|
||||
|
||||
if (!CBS_get_any_ber_asn1_element(in, &contents, &tag, &header_len,
|
||||
/*out_ber_found=*/NULL, &indefinite)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (is_eoc(header_len, &contents)) {
|
||||
return looking_for_eoc;
|
||||
}
|
||||
|
||||
if (string_tag != 0) {
|
||||
// This is part of a constructed string. All elements must match
|
||||
// |string_tag| up to the constructed bit and get appended to |out|
|
||||
|
||||
@@ -279,6 +279,13 @@ static int parse_asn1_tag(CBS *cbs, unsigned *out) {
|
||||
|
||||
tag |= tag_number;
|
||||
|
||||
// Tag [UNIVERSAL 0] is reserved for use by the encoding. Reject it here to
|
||||
// avoid some ambiguity around ANY values and BER indefinite-length EOCs. See
|
||||
// https://crbug.com/boringssl/455.
|
||||
if ((tag & ~CBS_ASN1_CONSTRUCTED) == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
*out = tag;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,10 @@
|
||||
// Various pre-computed constants.
|
||||
#include "./curve25519_tables.h"
|
||||
|
||||
#if defined(OPENSSL_NO_ASM)
|
||||
#define FIAT_25519_NO_ASM
|
||||
#endif
|
||||
|
||||
#if defined(BORINGSSL_CURVE25519_64BIT)
|
||||
#include "../../third_party/fiat/curve25519_64.h"
|
||||
#else
|
||||
|
||||
@@ -76,54 +76,54 @@ const uint32_t kOpenSSLReasonValues[] = {
|
||||
0xc3b00f7,
|
||||
0xc3b8921,
|
||||
0x10320892,
|
||||
0x10329608,
|
||||
0x10331614,
|
||||
0x1033962d,
|
||||
0x10341640,
|
||||
0x10329620,
|
||||
0x1033162c,
|
||||
0x10339645,
|
||||
0x10341658,
|
||||
0x10348f72,
|
||||
0x10350cab,
|
||||
0x10359653,
|
||||
0x1036167d,
|
||||
0x10369690,
|
||||
0x103716af,
|
||||
0x103796c8,
|
||||
0x103816dd,
|
||||
0x103896fb,
|
||||
0x1039170a,
|
||||
0x10399726,
|
||||
0x103a1741,
|
||||
0x103a9750,
|
||||
0x103b176c,
|
||||
0x103b9787,
|
||||
0x103c17ad,
|
||||
0x1035966b,
|
||||
0x10361695,
|
||||
0x103696a8,
|
||||
0x103716c7,
|
||||
0x103796e0,
|
||||
0x103816f5,
|
||||
0x10389713,
|
||||
0x10391722,
|
||||
0x1039973e,
|
||||
0x103a1759,
|
||||
0x103a9768,
|
||||
0x103b1784,
|
||||
0x103b979f,
|
||||
0x103c17c5,
|
||||
0x103c80f7,
|
||||
0x103d17be,
|
||||
0x103d97d2,
|
||||
0x103e17f1,
|
||||
0x103e9800,
|
||||
0x103f1817,
|
||||
0x103f982a,
|
||||
0x103d17d6,
|
||||
0x103d97ea,
|
||||
0x103e1809,
|
||||
0x103e9818,
|
||||
0x103f182f,
|
||||
0x103f9842,
|
||||
0x10400c6f,
|
||||
0x1040983d,
|
||||
0x1041185b,
|
||||
0x1041986e,
|
||||
0x10421888,
|
||||
0x10429898,
|
||||
0x104318ac,
|
||||
0x104398c2,
|
||||
0x104418da,
|
||||
0x104498ef,
|
||||
0x10451903,
|
||||
0x10459915,
|
||||
0x10409855,
|
||||
0x10411873,
|
||||
0x10419886,
|
||||
0x104218a0,
|
||||
0x104298b0,
|
||||
0x104318c4,
|
||||
0x104398da,
|
||||
0x104418f2,
|
||||
0x10449907,
|
||||
0x1045191b,
|
||||
0x1045992d,
|
||||
0x10460635,
|
||||
0x1046899a,
|
||||
0x1047192a,
|
||||
0x10479941,
|
||||
0x10481956,
|
||||
0x10489964,
|
||||
0x10471942,
|
||||
0x10479959,
|
||||
0x1048196e,
|
||||
0x1048997c,
|
||||
0x10490ebe,
|
||||
0x1049979e,
|
||||
0x104a1668,
|
||||
0x104997b6,
|
||||
0x104a1680,
|
||||
0x14320c52,
|
||||
0x14328c60,
|
||||
0x14330c6f,
|
||||
@@ -193,50 +193,50 @@ const uint32_t kOpenSSLReasonValues[] = {
|
||||
0x283480b9,
|
||||
0x283500f7,
|
||||
0x28358cb7,
|
||||
0x2c3232a7,
|
||||
0x2c3232bf,
|
||||
0x2c329351,
|
||||
0x2c3332b5,
|
||||
0x2c33b2c7,
|
||||
0x2c3432db,
|
||||
0x2c34b2ed,
|
||||
0x2c353308,
|
||||
0x2c35b31a,
|
||||
0x2c36334a,
|
||||
0x2c3332cd,
|
||||
0x2c33b2df,
|
||||
0x2c3432f3,
|
||||
0x2c34b305,
|
||||
0x2c353320,
|
||||
0x2c35b332,
|
||||
0x2c363362,
|
||||
0x2c36833a,
|
||||
0x2c373357,
|
||||
0x2c37b383,
|
||||
0x2c3833a8,
|
||||
0x2c38b3bf,
|
||||
0x2c3933dd,
|
||||
0x2c39b3ed,
|
||||
0x2c3a33ff,
|
||||
0x2c3ab413,
|
||||
0x2c3b3424,
|
||||
0x2c3bb443,
|
||||
0x2c37336f,
|
||||
0x2c37b39b,
|
||||
0x2c3833c0,
|
||||
0x2c38b3d7,
|
||||
0x2c3933f5,
|
||||
0x2c39b405,
|
||||
0x2c3a3417,
|
||||
0x2c3ab42b,
|
||||
0x2c3b343c,
|
||||
0x2c3bb45b,
|
||||
0x2c3c1363,
|
||||
0x2c3c9379,
|
||||
0x2c3d3488,
|
||||
0x2c3d34a0,
|
||||
0x2c3d9392,
|
||||
0x2c3e34b2,
|
||||
0x2c3eb4c0,
|
||||
0x2c3f34d8,
|
||||
0x2c3fb4f0,
|
||||
0x2c40351a,
|
||||
0x2c3e34ca,
|
||||
0x2c3eb4d8,
|
||||
0x2c3f34f0,
|
||||
0x2c3fb508,
|
||||
0x2c403532,
|
||||
0x2c409264,
|
||||
0x2c41352b,
|
||||
0x2c41b53e,
|
||||
0x2c413543,
|
||||
0x2c41b556,
|
||||
0x2c42122a,
|
||||
0x2c42b54f,
|
||||
0x2c42b567,
|
||||
0x2c43076d,
|
||||
0x2c43b435,
|
||||
0x2c443396,
|
||||
0x2c44b4fd,
|
||||
0x2c45332d,
|
||||
0x2c45b369,
|
||||
0x2c4633cd,
|
||||
0x2c46b457,
|
||||
0x2c47346c,
|
||||
0x2c47b4a5,
|
||||
0x2c43b44d,
|
||||
0x2c4433ae,
|
||||
0x2c44b515,
|
||||
0x2c453345,
|
||||
0x2c45b381,
|
||||
0x2c4633e5,
|
||||
0x2c46b46f,
|
||||
0x2c473484,
|
||||
0x2c47b4bd,
|
||||
0x30320000,
|
||||
0x30328015,
|
||||
0x3033001f,
|
||||
@@ -375,261 +375,261 @@ const uint32_t kOpenSSLReasonValues[] = {
|
||||
0x3c418db2,
|
||||
0x3c420ebe,
|
||||
0x3c428e48,
|
||||
0x403219f6,
|
||||
0x40329a0c,
|
||||
0x40331a3a,
|
||||
0x40339a44,
|
||||
0x40341a5b,
|
||||
0x40349a79,
|
||||
0x40351a89,
|
||||
0x40359a9b,
|
||||
0x40361aa8,
|
||||
0x40369ab4,
|
||||
0x40371ac9,
|
||||
0x40379adb,
|
||||
0x40381ae6,
|
||||
0x40389af8,
|
||||
0x40321a0e,
|
||||
0x40329a24,
|
||||
0x40331a52,
|
||||
0x40339a5c,
|
||||
0x40341a73,
|
||||
0x40349a91,
|
||||
0x40351aa1,
|
||||
0x40359ab3,
|
||||
0x40361ac0,
|
||||
0x40369acc,
|
||||
0x40371ae1,
|
||||
0x40379af3,
|
||||
0x40381afe,
|
||||
0x40389b10,
|
||||
0x40390f72,
|
||||
0x40399b08,
|
||||
0x403a1b1b,
|
||||
0x403a9b3c,
|
||||
0x403b1b4d,
|
||||
0x403b9b5d,
|
||||
0x40399b20,
|
||||
0x403a1b33,
|
||||
0x403a9b54,
|
||||
0x403b1b65,
|
||||
0x403b9b75,
|
||||
0x403c0071,
|
||||
0x403c8090,
|
||||
0x403d1bbe,
|
||||
0x403d9bd4,
|
||||
0x403e1be3,
|
||||
0x403e9c1b,
|
||||
0x403f1c35,
|
||||
0x403f9c5d,
|
||||
0x40401c72,
|
||||
0x40409c86,
|
||||
0x40411cc1,
|
||||
0x40419cdc,
|
||||
0x40421cf5,
|
||||
0x40429d08,
|
||||
0x40431d1c,
|
||||
0x40439d4a,
|
||||
0x40441d61,
|
||||
0x403d1bd6,
|
||||
0x403d9bec,
|
||||
0x403e1bfb,
|
||||
0x403e9c33,
|
||||
0x403f1c4d,
|
||||
0x403f9c75,
|
||||
0x40401c8a,
|
||||
0x40409c9e,
|
||||
0x40411cd9,
|
||||
0x40419cf4,
|
||||
0x40421d0d,
|
||||
0x40429d20,
|
||||
0x40431d34,
|
||||
0x40439d62,
|
||||
0x40441d79,
|
||||
0x404480b9,
|
||||
0x40451d76,
|
||||
0x40459d88,
|
||||
0x40461dac,
|
||||
0x40469dcc,
|
||||
0x40471dda,
|
||||
0x40479e01,
|
||||
0x40481e72,
|
||||
0x40489f2c,
|
||||
0x40491f43,
|
||||
0x40499f5d,
|
||||
0x404a1f74,
|
||||
0x404a9f92,
|
||||
0x404b1faa,
|
||||
0x404b9fd7,
|
||||
0x404c1fed,
|
||||
0x404c9fff,
|
||||
0x404d2020,
|
||||
0x404da059,
|
||||
0x404e206d,
|
||||
0x404ea07a,
|
||||
0x404f2114,
|
||||
0x404fa18a,
|
||||
0x405021f9,
|
||||
0x4050a20d,
|
||||
0x40512240,
|
||||
0x40522250,
|
||||
0x4052a274,
|
||||
0x4053228c,
|
||||
0x4053a29f,
|
||||
0x405422b4,
|
||||
0x4054a2d7,
|
||||
0x40552302,
|
||||
0x4055a33f,
|
||||
0x40562364,
|
||||
0x4056a37d,
|
||||
0x40572395,
|
||||
0x4057a3a8,
|
||||
0x405823bd,
|
||||
0x4058a3e4,
|
||||
0x40592413,
|
||||
0x4059a440,
|
||||
0x405a2454,
|
||||
0x405aa464,
|
||||
0x405b247c,
|
||||
0x405ba48d,
|
||||
0x405c24a0,
|
||||
0x405ca4df,
|
||||
0x405d24ec,
|
||||
0x405da511,
|
||||
0x405e254f,
|
||||
0x40451d8e,
|
||||
0x40459da0,
|
||||
0x40461dc4,
|
||||
0x40469de4,
|
||||
0x40471df2,
|
||||
0x40479e19,
|
||||
0x40481e8a,
|
||||
0x40489f44,
|
||||
0x40491f5b,
|
||||
0x40499f75,
|
||||
0x404a1f8c,
|
||||
0x404a9faa,
|
||||
0x404b1fc2,
|
||||
0x404b9fef,
|
||||
0x404c2005,
|
||||
0x404ca017,
|
||||
0x404d2038,
|
||||
0x404da071,
|
||||
0x404e2085,
|
||||
0x404ea092,
|
||||
0x404f212c,
|
||||
0x404fa1a2,
|
||||
0x40502211,
|
||||
0x4050a225,
|
||||
0x40512258,
|
||||
0x40522268,
|
||||
0x4052a28c,
|
||||
0x405322a4,
|
||||
0x4053a2b7,
|
||||
0x405422cc,
|
||||
0x4054a2ef,
|
||||
0x4055231a,
|
||||
0x4055a357,
|
||||
0x4056237c,
|
||||
0x4056a395,
|
||||
0x405723ad,
|
||||
0x4057a3c0,
|
||||
0x405823d5,
|
||||
0x4058a3fc,
|
||||
0x4059242b,
|
||||
0x4059a458,
|
||||
0x405a246c,
|
||||
0x405aa47c,
|
||||
0x405b2494,
|
||||
0x405ba4a5,
|
||||
0x405c24b8,
|
||||
0x405ca4f7,
|
||||
0x405d2504,
|
||||
0x405da529,
|
||||
0x405e2567,
|
||||
0x405e8afe,
|
||||
0x405f2570,
|
||||
0x405fa57d,
|
||||
0x4060258b,
|
||||
0x4060a5ad,
|
||||
0x4061260e,
|
||||
0x4061a646,
|
||||
0x4062265d,
|
||||
0x4062a66e,
|
||||
0x406326bb,
|
||||
0x4063a6d0,
|
||||
0x406426e7,
|
||||
0x4064a713,
|
||||
0x4065272e,
|
||||
0x4065a745,
|
||||
0x4066275d,
|
||||
0x4066a787,
|
||||
0x406727b2,
|
||||
0x4067a7f7,
|
||||
0x4068283f,
|
||||
0x4068a860,
|
||||
0x40692892,
|
||||
0x4069a8c0,
|
||||
0x406a28e1,
|
||||
0x406aa901,
|
||||
0x406b2a89,
|
||||
0x406baaac,
|
||||
0x406c2ac2,
|
||||
0x406cadcc,
|
||||
0x406d2dfb,
|
||||
0x406dae23,
|
||||
0x406e2e51,
|
||||
0x406eae9e,
|
||||
0x406f2ef7,
|
||||
0x406faf2f,
|
||||
0x40702f42,
|
||||
0x4070af5f,
|
||||
0x405f2588,
|
||||
0x405fa595,
|
||||
0x406025a3,
|
||||
0x4060a5c5,
|
||||
0x40612626,
|
||||
0x4061a65e,
|
||||
0x40622675,
|
||||
0x4062a686,
|
||||
0x406326d3,
|
||||
0x4063a6e8,
|
||||
0x406426ff,
|
||||
0x4064a72b,
|
||||
0x40652746,
|
||||
0x4065a75d,
|
||||
0x40662775,
|
||||
0x4066a79f,
|
||||
0x406727ca,
|
||||
0x4067a80f,
|
||||
0x40682857,
|
||||
0x4068a878,
|
||||
0x406928aa,
|
||||
0x4069a8d8,
|
||||
0x406a28f9,
|
||||
0x406aa919,
|
||||
0x406b2aa1,
|
||||
0x406baac4,
|
||||
0x406c2ada,
|
||||
0x406cade4,
|
||||
0x406d2e13,
|
||||
0x406dae3b,
|
||||
0x406e2e69,
|
||||
0x406eaeb6,
|
||||
0x406f2f0f,
|
||||
0x406faf47,
|
||||
0x40702f5a,
|
||||
0x4070af77,
|
||||
0x4071084d,
|
||||
0x4071af71,
|
||||
0x40722f84,
|
||||
0x4072afba,
|
||||
0x40732fd2,
|
||||
0x40739563,
|
||||
0x40742fe6,
|
||||
0x4074b000,
|
||||
0x40753011,
|
||||
0x4075b025,
|
||||
0x40763033,
|
||||
0x4071af89,
|
||||
0x40722f9c,
|
||||
0x4072afd2,
|
||||
0x40732fea,
|
||||
0x4073957b,
|
||||
0x40742ffe,
|
||||
0x4074b018,
|
||||
0x40753029,
|
||||
0x4075b03d,
|
||||
0x4076304b,
|
||||
0x40769327,
|
||||
0x40773058,
|
||||
0x4077b098,
|
||||
0x407830b3,
|
||||
0x4078b0ec,
|
||||
0x40793103,
|
||||
0x4079b119,
|
||||
0x407a3145,
|
||||
0x407ab158,
|
||||
0x407b316d,
|
||||
0x407bb17f,
|
||||
0x407c31b0,
|
||||
0x407cb1b9,
|
||||
0x407d287b,
|
||||
0x407da1b2,
|
||||
0x407e30c8,
|
||||
0x407ea3f4,
|
||||
0x407f1dee,
|
||||
0x407f9fc1,
|
||||
0x40802124,
|
||||
0x40809e16,
|
||||
0x40812262,
|
||||
0x4081a0c8,
|
||||
0x40822e3c,
|
||||
0x40829b69,
|
||||
0x408323cf,
|
||||
0x4083a6f8,
|
||||
0x40841e2a,
|
||||
0x4084a42c,
|
||||
0x408524b1,
|
||||
0x4085a5d5,
|
||||
0x40862531,
|
||||
0x4086a1cc,
|
||||
0x40872e82,
|
||||
0x4087a623,
|
||||
0x40881ba7,
|
||||
0x4088a80a,
|
||||
0x40891bf6,
|
||||
0x40899b83,
|
||||
0x408a2afa,
|
||||
0x408a997b,
|
||||
0x408b3194,
|
||||
0x408baf0c,
|
||||
0x408c24c1,
|
||||
0x408c99b3,
|
||||
0x408d1f12,
|
||||
0x408d9e5c,
|
||||
0x408e2042,
|
||||
0x408ea31f,
|
||||
0x408f281e,
|
||||
0x408fa5f1,
|
||||
0x409027d3,
|
||||
0x4090a503,
|
||||
0x40912ae2,
|
||||
0x409199d9,
|
||||
0x40921c43,
|
||||
0x4092aebd,
|
||||
0x40932f9d,
|
||||
0x4093a1dd,
|
||||
0x40941e3e,
|
||||
0x4094ab13,
|
||||
0x4095267f,
|
||||
0x4095b125,
|
||||
0x40962e69,
|
||||
0x4096a13d,
|
||||
0x40972228,
|
||||
0x4097a091,
|
||||
0x40981ca3,
|
||||
0x4098a693,
|
||||
0x40992ed9,
|
||||
0x4099a34c,
|
||||
0x409a22e5,
|
||||
0x409a9997,
|
||||
0x409b1e98,
|
||||
0x409b9ec3,
|
||||
0x409c307a,
|
||||
0x409c9eeb,
|
||||
0x409d20f9,
|
||||
0x409da0de,
|
||||
0x409e1d34,
|
||||
0x409ea172,
|
||||
0x409f215a,
|
||||
0x409f9e8b,
|
||||
0x40a0219a,
|
||||
0x40a0a0ab,
|
||||
0x41f429b4,
|
||||
0x41f92a46,
|
||||
0x41fe2939,
|
||||
0x41feabef,
|
||||
0x41ff2d1d,
|
||||
0x420329cd,
|
||||
0x420829ef,
|
||||
0x4208aa2b,
|
||||
0x4209291d,
|
||||
0x4209aa65,
|
||||
0x420a2974,
|
||||
0x420aa954,
|
||||
0x420b2994,
|
||||
0x420baa0d,
|
||||
0x420c2d39,
|
||||
0x420cab23,
|
||||
0x420d2bd6,
|
||||
0x420dac0d,
|
||||
0x42122c40,
|
||||
0x42172d00,
|
||||
0x4217ac82,
|
||||
0x421c2ca4,
|
||||
0x421f2c5f,
|
||||
0x42212db1,
|
||||
0x42262ce3,
|
||||
0x422b2d8f,
|
||||
0x422babb1,
|
||||
0x422c2d71,
|
||||
0x422cab64,
|
||||
0x422d2b3d,
|
||||
0x422dad50,
|
||||
0x422e2b90,
|
||||
0x42302cbf,
|
||||
0x4230ac27,
|
||||
0x40773070,
|
||||
0x4077b0b0,
|
||||
0x407830cb,
|
||||
0x4078b104,
|
||||
0x4079311b,
|
||||
0x4079b131,
|
||||
0x407a315d,
|
||||
0x407ab170,
|
||||
0x407b3185,
|
||||
0x407bb197,
|
||||
0x407c31c8,
|
||||
0x407cb1d1,
|
||||
0x407d2893,
|
||||
0x407da1ca,
|
||||
0x407e30e0,
|
||||
0x407ea40c,
|
||||
0x407f1e06,
|
||||
0x407f9fd9,
|
||||
0x4080213c,
|
||||
0x40809e2e,
|
||||
0x4081227a,
|
||||
0x4081a0e0,
|
||||
0x40822e54,
|
||||
0x40829b81,
|
||||
0x408323e7,
|
||||
0x4083a710,
|
||||
0x40841e42,
|
||||
0x4084a444,
|
||||
0x408524c9,
|
||||
0x4085a5ed,
|
||||
0x40862549,
|
||||
0x4086a1e4,
|
||||
0x40872e9a,
|
||||
0x4087a63b,
|
||||
0x40881bbf,
|
||||
0x4088a822,
|
||||
0x40891c0e,
|
||||
0x40899b9b,
|
||||
0x408a2b12,
|
||||
0x408a9993,
|
||||
0x408b31ac,
|
||||
0x408baf24,
|
||||
0x408c24d9,
|
||||
0x408c99cb,
|
||||
0x408d1f2a,
|
||||
0x408d9e74,
|
||||
0x408e205a,
|
||||
0x408ea337,
|
||||
0x408f2836,
|
||||
0x408fa609,
|
||||
0x409027eb,
|
||||
0x4090a51b,
|
||||
0x40912afa,
|
||||
0x409199f1,
|
||||
0x40921c5b,
|
||||
0x4092aed5,
|
||||
0x40932fb5,
|
||||
0x4093a1f5,
|
||||
0x40941e56,
|
||||
0x4094ab2b,
|
||||
0x40952697,
|
||||
0x4095b13d,
|
||||
0x40962e81,
|
||||
0x4096a155,
|
||||
0x40972240,
|
||||
0x4097a0a9,
|
||||
0x40981cbb,
|
||||
0x4098a6ab,
|
||||
0x40992ef1,
|
||||
0x4099a364,
|
||||
0x409a22fd,
|
||||
0x409a99af,
|
||||
0x409b1eb0,
|
||||
0x409b9edb,
|
||||
0x409c3092,
|
||||
0x409c9f03,
|
||||
0x409d2111,
|
||||
0x409da0f6,
|
||||
0x409e1d4c,
|
||||
0x409ea18a,
|
||||
0x409f2172,
|
||||
0x409f9ea3,
|
||||
0x40a021b2,
|
||||
0x40a0a0c3,
|
||||
0x41f429cc,
|
||||
0x41f92a5e,
|
||||
0x41fe2951,
|
||||
0x41feac07,
|
||||
0x41ff2d35,
|
||||
0x420329e5,
|
||||
0x42082a07,
|
||||
0x4208aa43,
|
||||
0x42092935,
|
||||
0x4209aa7d,
|
||||
0x420a298c,
|
||||
0x420aa96c,
|
||||
0x420b29ac,
|
||||
0x420baa25,
|
||||
0x420c2d51,
|
||||
0x420cab3b,
|
||||
0x420d2bee,
|
||||
0x420dac25,
|
||||
0x42122c58,
|
||||
0x42172d18,
|
||||
0x4217ac9a,
|
||||
0x421c2cbc,
|
||||
0x421f2c77,
|
||||
0x42212dc9,
|
||||
0x42262cfb,
|
||||
0x422b2da7,
|
||||
0x422babc9,
|
||||
0x422c2d89,
|
||||
0x422cab7c,
|
||||
0x422d2b55,
|
||||
0x422dad68,
|
||||
0x422e2ba8,
|
||||
0x42302cd7,
|
||||
0x4230ac3f,
|
||||
0x44320778,
|
||||
0x44328787,
|
||||
0x44330793,
|
||||
@@ -651,104 +651,105 @@ const uint32_t kOpenSSLReasonValues[] = {
|
||||
0x48329363,
|
||||
0x48331379,
|
||||
0x48339392,
|
||||
0x4c3213b7,
|
||||
0x4c3293c7,
|
||||
0x4c3313da,
|
||||
0x4c3393fa,
|
||||
0x4c3213cf,
|
||||
0x4c3293df,
|
||||
0x4c3313f2,
|
||||
0x4c339412,
|
||||
0x4c3400b9,
|
||||
0x4c3480f7,
|
||||
0x4c351406,
|
||||
0x4c359414,
|
||||
0x4c361430,
|
||||
0x4c369456,
|
||||
0x4c371465,
|
||||
0x4c379473,
|
||||
0x4c381488,
|
||||
0x4c389494,
|
||||
0x4c3914b4,
|
||||
0x4c3994de,
|
||||
0x4c3a14f7,
|
||||
0x4c3a9510,
|
||||
0x4c35141e,
|
||||
0x4c35942c,
|
||||
0x4c361448,
|
||||
0x4c36946e,
|
||||
0x4c37147d,
|
||||
0x4c37948b,
|
||||
0x4c3814a0,
|
||||
0x4c3894ac,
|
||||
0x4c3914cc,
|
||||
0x4c3994f6,
|
||||
0x4c3a150f,
|
||||
0x4c3a9528,
|
||||
0x4c3b0635,
|
||||
0x4c3b9529,
|
||||
0x4c3c153b,
|
||||
0x4c3c954a,
|
||||
0x4c3d1563,
|
||||
0x4c3b9541,
|
||||
0x4c3c1553,
|
||||
0x4c3c9562,
|
||||
0x4c3d157b,
|
||||
0x4c3d8c92,
|
||||
0x4c3e15d0,
|
||||
0x4c3e9572,
|
||||
0x4c3f15f2,
|
||||
0x4c3e15e8,
|
||||
0x4c3e958a,
|
||||
0x4c3f160a,
|
||||
0x4c3f9327,
|
||||
0x4c401588,
|
||||
0x4c4093a3,
|
||||
0x4c4115c0,
|
||||
0x4c419443,
|
||||
0x4c4215ac,
|
||||
0x50323561,
|
||||
0x5032b570,
|
||||
0x5033357b,
|
||||
0x5033b58b,
|
||||
0x503435a4,
|
||||
0x5034b5be,
|
||||
0x503535cc,
|
||||
0x5035b5e2,
|
||||
0x503635f4,
|
||||
0x5036b60a,
|
||||
0x50373623,
|
||||
0x5037b636,
|
||||
0x5038364e,
|
||||
0x5038b65f,
|
||||
0x50393674,
|
||||
0x5039b688,
|
||||
0x503a36a8,
|
||||
0x503ab6be,
|
||||
0x503b36d6,
|
||||
0x503bb6e8,
|
||||
0x503c3704,
|
||||
0x503cb71b,
|
||||
0x503d3734,
|
||||
0x503db74a,
|
||||
0x503e3757,
|
||||
0x503eb76d,
|
||||
0x503f377f,
|
||||
0x4c4015a0,
|
||||
0x4c4093bb,
|
||||
0x4c4115d8,
|
||||
0x4c41945b,
|
||||
0x4c4215c4,
|
||||
0x4c4293a3,
|
||||
0x50323579,
|
||||
0x5032b588,
|
||||
0x50333593,
|
||||
0x5033b5a3,
|
||||
0x503435bc,
|
||||
0x5034b5d6,
|
||||
0x503535e4,
|
||||
0x5035b5fa,
|
||||
0x5036360c,
|
||||
0x5036b622,
|
||||
0x5037363b,
|
||||
0x5037b64e,
|
||||
0x50383666,
|
||||
0x5038b677,
|
||||
0x5039368c,
|
||||
0x5039b6a0,
|
||||
0x503a36c0,
|
||||
0x503ab6d6,
|
||||
0x503b36ee,
|
||||
0x503bb700,
|
||||
0x503c371c,
|
||||
0x503cb733,
|
||||
0x503d374c,
|
||||
0x503db762,
|
||||
0x503e376f,
|
||||
0x503eb785,
|
||||
0x503f3797,
|
||||
0x503f83b3,
|
||||
0x50403792,
|
||||
0x5040b7a2,
|
||||
0x504137bc,
|
||||
0x5041b7cb,
|
||||
0x504237e5,
|
||||
0x5042b802,
|
||||
0x50433812,
|
||||
0x5043b822,
|
||||
0x5044383f,
|
||||
0x504037aa,
|
||||
0x5040b7ba,
|
||||
0x504137d4,
|
||||
0x5041b7e3,
|
||||
0x504237fd,
|
||||
0x5042b81a,
|
||||
0x5043382a,
|
||||
0x5043b83a,
|
||||
0x50443857,
|
||||
0x50448469,
|
||||
0x50453853,
|
||||
0x5045b871,
|
||||
0x50463884,
|
||||
0x5046b89a,
|
||||
0x504738ac,
|
||||
0x5047b8c1,
|
||||
0x504838e7,
|
||||
0x5048b8f5,
|
||||
0x50493908,
|
||||
0x5049b91d,
|
||||
0x504a3933,
|
||||
0x504ab943,
|
||||
0x504b3963,
|
||||
0x504bb976,
|
||||
0x504c3999,
|
||||
0x504cb9c7,
|
||||
0x504d39f4,
|
||||
0x504dba11,
|
||||
0x504e3a2c,
|
||||
0x504eba48,
|
||||
0x504f3a5a,
|
||||
0x504fba71,
|
||||
0x50503a80,
|
||||
0x5045386b,
|
||||
0x5045b889,
|
||||
0x5046389c,
|
||||
0x5046b8b2,
|
||||
0x504738c4,
|
||||
0x5047b8d9,
|
||||
0x504838ff,
|
||||
0x5048b90d,
|
||||
0x50493920,
|
||||
0x5049b935,
|
||||
0x504a394b,
|
||||
0x504ab95b,
|
||||
0x504b397b,
|
||||
0x504bb98e,
|
||||
0x504c39b1,
|
||||
0x504cb9df,
|
||||
0x504d3a0c,
|
||||
0x504dba29,
|
||||
0x504e3a44,
|
||||
0x504eba60,
|
||||
0x504f3a72,
|
||||
0x504fba89,
|
||||
0x50503a98,
|
||||
0x50508729,
|
||||
0x50513a93,
|
||||
0x5051b831,
|
||||
0x505239d9,
|
||||
0x50513aab,
|
||||
0x5051b849,
|
||||
0x505239f1,
|
||||
0x58320fb0,
|
||||
0x68320f72,
|
||||
0x68328cca,
|
||||
@@ -790,21 +791,21 @@ const uint32_t kOpenSSLReasonValues[] = {
|
||||
0x783e0aed,
|
||||
0x783e8a9f,
|
||||
0x7c321240,
|
||||
0x80321456,
|
||||
0x8032146e,
|
||||
0x80328090,
|
||||
0x80333276,
|
||||
0x8033328e,
|
||||
0x803380b9,
|
||||
0x80343285,
|
||||
0x8034b1ed,
|
||||
0x8035320b,
|
||||
0x8035b299,
|
||||
0x8036324d,
|
||||
0x8036b1fc,
|
||||
0x8037323f,
|
||||
0x8037b1da,
|
||||
0x80383260,
|
||||
0x8038b21c,
|
||||
0x80393231,
|
||||
0x8034329d,
|
||||
0x8034b205,
|
||||
0x80353223,
|
||||
0x8035b2b1,
|
||||
0x80363265,
|
||||
0x8036b214,
|
||||
0x80373257,
|
||||
0x8037b1f2,
|
||||
0x80383278,
|
||||
0x8038b234,
|
||||
0x80393249,
|
||||
};
|
||||
|
||||
const size_t kOpenSSLReasonValuesLen = sizeof(kOpenSSLReasonValues) / sizeof(kOpenSSLReasonValues[0]);
|
||||
@@ -1073,6 +1074,7 @@ const char kOpenSSLReasonStringData[] =
|
||||
"NOT_PKCS7_SIGNED_DATA\0"
|
||||
"NO_CERTIFICATES_INCLUDED\0"
|
||||
"NO_CRLS_INCLUDED\0"
|
||||
"AMBIGUOUS_FRIENDLY_NAME\0"
|
||||
"BAD_ITERATION_COUNT\0"
|
||||
"BAD_PKCS12_DATA\0"
|
||||
"BAD_PKCS12_VERSION\0"
|
||||
|
||||
@@ -246,7 +246,8 @@ DEFINE_METHOD_FUNCTION(struct built_in_curves, OPENSSL_built_in_curves) {
|
||||
out->curves[2].param_len = 32;
|
||||
out->curves[2].params = kP256Params;
|
||||
out->curves[2].method =
|
||||
#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && \
|
||||
#if !defined(OPENSSL_NO_ASM) && \
|
||||
(defined(OPENSSL_X86_64) || defined(OPENSSL_AARCH64)) && \
|
||||
!defined(OPENSSL_SMALL)
|
||||
EC_GFp_nistz256_method();
|
||||
#else
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@
|
||||
*/
|
||||
|
||||
// This is the precomputed constant time access table for the code in
|
||||
// p256-x86_64.c, for the default generator. The table consists of 37
|
||||
// p256-nistz.c, for the default generator. The table consists of 37
|
||||
// subtables, each subtable contains 64 affine points. The affine points are
|
||||
// encoded as eight uint64's, four for the x coordinate and four for the y.
|
||||
// Both values are in little-endian order. There are 37 tables because a
|
||||
+8
-7
@@ -26,16 +26,14 @@
|
||||
#include <CCryptoBoringSSL_crypto.h>
|
||||
#include <CCryptoBoringSSL_err.h>
|
||||
|
||||
#include <CCryptoBoringSSL_cpu.h>
|
||||
|
||||
#include "../bn/internal.h"
|
||||
#include "../delocate.h"
|
||||
#include "../../internal.h"
|
||||
#include "internal.h"
|
||||
#include "p256-x86_64.h"
|
||||
#include "p256-nistz.h"
|
||||
|
||||
|
||||
#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && \
|
||||
#if !defined(OPENSSL_NO_ASM) && \
|
||||
(defined(OPENSSL_X86_64) || defined(OPENSSL_AARCH64)) && \
|
||||
!defined(OPENSSL_SMALL)
|
||||
|
||||
typedef P256_POINT_AFFINE PRECOMP256_ROW[64];
|
||||
@@ -47,7 +45,7 @@ static const BN_ULONG ONE[P256_LIMBS] = {
|
||||
};
|
||||
|
||||
// Precomputed tables for the default generator
|
||||
#include "p256-x86_64-table.h"
|
||||
#include "p256-nistz-table.h"
|
||||
|
||||
// Recode window to a signed digit, see |ec_GFp_nistp_recode_scalar_bits| in
|
||||
// util.c for details
|
||||
@@ -556,10 +554,12 @@ static void ecp_nistz256_inv0_mod_ord(const EC_GROUP *group, EC_SCALAR *out,
|
||||
static int ecp_nistz256_scalar_to_montgomery_inv_vartime(const EC_GROUP *group,
|
||||
EC_SCALAR *out,
|
||||
const EC_SCALAR *in) {
|
||||
#if defined(OPENSSL_X86_64)
|
||||
if (!CRYPTO_is_AVX_capable()) {
|
||||
// No AVX support; fallback to generic code.
|
||||
return ec_simple_scalar_to_montgomery_inv_vartime(group, out, in);
|
||||
}
|
||||
#endif
|
||||
|
||||
assert(group->order.width == P256_LIMBS);
|
||||
if (!beeu_mod_inverse_vartime(out->words, in->words, group->order.d)) {
|
||||
@@ -630,5 +630,6 @@ DEFINE_METHOD_FUNCTION(EC_METHOD, EC_GFp_nistz256_method) {
|
||||
out->cmp_x_coordinate = ecp_nistz256_cmp_x_coordinate;
|
||||
}
|
||||
|
||||
#endif /* !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && \
|
||||
#endif /* !defined(OPENSSL_NO_ASM) && \
|
||||
(defined(OPENSSL_X86_64) || defined(OPENSSL_AARCH64)) && \
|
||||
!defined(OPENSSL_SMALL) */
|
||||
+5
-3
@@ -30,7 +30,8 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && \
|
||||
#if !defined(OPENSSL_NO_ASM) && \
|
||||
(defined(OPENSSL_X86_64) || defined(OPENSSL_AARCH64)) && \
|
||||
!defined(OPENSSL_SMALL)
|
||||
|
||||
// P-256 field operations.
|
||||
@@ -142,8 +143,9 @@ void ecp_nistz256_point_add(P256_POINT *r, const P256_POINT *a,
|
||||
void ecp_nistz256_point_add_affine(P256_POINT *r, const P256_POINT *a,
|
||||
const P256_POINT_AFFINE *b);
|
||||
|
||||
#endif /* !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && \
|
||||
!defined(OPENSSL_SMALL) */
|
||||
#endif /* !defined(OPENSSL_NO_ASM) && \
|
||||
(defined(OPENSSL_X86_64) || defined(OPENSSL_AARCH64)) && \
|
||||
!defined(OPENSSL_SMALL) */
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
@@ -31,8 +31,10 @@
|
||||
#include "../delocate.h"
|
||||
#include "./internal.h"
|
||||
|
||||
#if defined(OPENSSL_NO_ASM)
|
||||
#define FIAT_P256_NO_ASM
|
||||
#endif
|
||||
|
||||
// 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"
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,324 @@
|
||||
#define BORINGSSL_PREFIX CCryptoBoringSSL
|
||||
#if defined(__aarch64__) && defined(__APPLE__)
|
||||
// This file is generated from a similarly-named Perl script in the BoringSSL
|
||||
// source tree. Do not edit by hand.
|
||||
|
||||
#if !defined(__has_feature)
|
||||
#define __has_feature(x) 0
|
||||
#endif
|
||||
#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM)
|
||||
#define OPENSSL_NO_ASM
|
||||
#endif
|
||||
|
||||
#if !defined(OPENSSL_NO_ASM)
|
||||
#if defined(BORINGSSL_PREFIX)
|
||||
#include <CCryptoBoringSSL_boringssl_prefix_symbols_asm.h>
|
||||
#endif
|
||||
#include "CCryptoBoringSSL_arm_arch.h"
|
||||
|
||||
.text
|
||||
.globl _beeu_mod_inverse_vartime
|
||||
.private_extern _beeu_mod_inverse_vartime
|
||||
|
||||
.align 4
|
||||
_beeu_mod_inverse_vartime:
|
||||
// Reserve enough space for 14 8-byte registers on the stack
|
||||
// in the first stp call for x29, x30.
|
||||
// Then store the remaining callee-saved registers.
|
||||
//
|
||||
// | x29 | x30 | x19 | x20 | ... | x27 | x28 | x0 | x2 |
|
||||
// ^ ^
|
||||
// sp <------------------- 112 bytes ----------------> old sp
|
||||
// x29 (FP)
|
||||
//
|
||||
AARCH64_SIGN_LINK_REGISTER
|
||||
stp x29,x30,[sp,#-112]!
|
||||
add x29,sp,#0
|
||||
stp x19,x20,[sp,#16]
|
||||
stp x21,x22,[sp,#32]
|
||||
stp x23,x24,[sp,#48]
|
||||
stp x25,x26,[sp,#64]
|
||||
stp x27,x28,[sp,#80]
|
||||
stp x0,x2,[sp,#96]
|
||||
|
||||
// B = b3..b0 := a
|
||||
ldp x25,x26,[x1]
|
||||
ldp x27,x28,[x1,#16]
|
||||
|
||||
// n3..n0 := n
|
||||
// Note: the value of input params are changed in the following.
|
||||
ldp x0,x1,[x2]
|
||||
ldp x2,x30,[x2,#16]
|
||||
|
||||
// A = a3..a0 := n
|
||||
mov x21, x0
|
||||
mov x22, x1
|
||||
mov x23, x2
|
||||
mov x24, x30
|
||||
|
||||
// X = x4..x0 := 1
|
||||
mov x3, #1
|
||||
eor x4, x4, x4
|
||||
eor x5, x5, x5
|
||||
eor x6, x6, x6
|
||||
eor x7, x7, x7
|
||||
|
||||
// Y = y4..y0 := 0
|
||||
eor x8, x8, x8
|
||||
eor x9, x9, x9
|
||||
eor x10, x10, x10
|
||||
eor x11, x11, x11
|
||||
eor x12, x12, x12
|
||||
|
||||
Lbeeu_loop:
|
||||
// if B == 0, jump to .Lbeeu_loop_end
|
||||
orr x14, x25, x26
|
||||
orr x14, x14, x27
|
||||
|
||||
// reverse the bit order of x25. This is needed for clz after this macro
|
||||
rbit x15, x25
|
||||
|
||||
orr x14, x14, x28
|
||||
cbz x14,Lbeeu_loop_end
|
||||
|
||||
|
||||
// 0 < B < |n|,
|
||||
// 0 < A <= |n|,
|
||||
// (1) X*a == B (mod |n|),
|
||||
// (2) (-1)*Y*a == A (mod |n|)
|
||||
|
||||
// Now divide B by the maximum possible power of two in the
|
||||
// integers, and divide X by the same value mod |n|.
|
||||
// When we're done, (1) still holds.
|
||||
|
||||
// shift := number of trailing 0s in x25
|
||||
// ( = number of leading 0s in x15; see the "rbit" instruction in TEST_B_ZERO)
|
||||
clz x13, x15
|
||||
|
||||
// If there is no shift, goto shift_A_Y
|
||||
cbz x13, Lbeeu_shift_A_Y
|
||||
|
||||
// Shift B right by "x13" bits
|
||||
neg x14, x13
|
||||
lsr x25, x25, x13
|
||||
lsl x15, x26, x14
|
||||
|
||||
lsr x26, x26, x13
|
||||
lsl x19, x27, x14
|
||||
|
||||
orr x25, x25, x15
|
||||
|
||||
lsr x27, x27, x13
|
||||
lsl x20, x28, x14
|
||||
|
||||
orr x26, x26, x19
|
||||
|
||||
lsr x28, x28, x13
|
||||
|
||||
orr x27, x27, x20
|
||||
|
||||
|
||||
// Shift X right by "x13" bits, adding n whenever X becomes odd.
|
||||
// x13--;
|
||||
// x14 := 0; needed in the addition to the most significant word in SHIFT1
|
||||
eor x14, x14, x14
|
||||
Lbeeu_shift_loop_X:
|
||||
tbz x3, #0, Lshift1_0
|
||||
adds x3, x3, x0
|
||||
adcs x4, x4, x1
|
||||
adcs x5, x5, x2
|
||||
adcs x6, x6, x30
|
||||
adc x7, x7, x14
|
||||
Lshift1_0:
|
||||
// var0 := [var1|var0]<64..1>;
|
||||
// i.e. concatenate var1 and var0,
|
||||
// extract bits <64..1> from the resulting 128-bit value
|
||||
// and put them in var0
|
||||
extr x3, x4, x3, #1
|
||||
extr x4, x5, x4, #1
|
||||
extr x5, x6, x5, #1
|
||||
extr x6, x7, x6, #1
|
||||
lsr x7, x7, #1
|
||||
|
||||
subs x13, x13, #1
|
||||
bne Lbeeu_shift_loop_X
|
||||
|
||||
// Note: the steps above perform the same sequence as in p256_beeu-x86_64-asm.pl
|
||||
// with the following differences:
|
||||
// - "x13" is set directly to the number of trailing 0s in B
|
||||
// (using rbit and clz instructions)
|
||||
// - The loop is only used to call SHIFT1(X)
|
||||
// and x13 is decreased while executing the X loop.
|
||||
// - SHIFT256(B, x13) is performed before right-shifting X; they are independent
|
||||
|
||||
Lbeeu_shift_A_Y:
|
||||
// Same for A and Y.
|
||||
// Afterwards, (2) still holds.
|
||||
// Reverse the bit order of x21
|
||||
// x13 := number of trailing 0s in x21 (= number of leading 0s in x15)
|
||||
rbit x15, x21
|
||||
clz x13, x15
|
||||
|
||||
// If there is no shift, goto |B-A|, X+Y update
|
||||
cbz x13, Lbeeu_update_B_X_or_A_Y
|
||||
|
||||
// Shift A right by "x13" bits
|
||||
neg x14, x13
|
||||
lsr x21, x21, x13
|
||||
lsl x15, x22, x14
|
||||
|
||||
lsr x22, x22, x13
|
||||
lsl x19, x23, x14
|
||||
|
||||
orr x21, x21, x15
|
||||
|
||||
lsr x23, x23, x13
|
||||
lsl x20, x24, x14
|
||||
|
||||
orr x22, x22, x19
|
||||
|
||||
lsr x24, x24, x13
|
||||
|
||||
orr x23, x23, x20
|
||||
|
||||
|
||||
// Shift Y right by "x13" bits, adding n whenever Y becomes odd.
|
||||
// x13--;
|
||||
// x14 := 0; needed in the addition to the most significant word in SHIFT1
|
||||
eor x14, x14, x14
|
||||
Lbeeu_shift_loop_Y:
|
||||
tbz x8, #0, Lshift1_1
|
||||
adds x8, x8, x0
|
||||
adcs x9, x9, x1
|
||||
adcs x10, x10, x2
|
||||
adcs x11, x11, x30
|
||||
adc x12, x12, x14
|
||||
Lshift1_1:
|
||||
// var0 := [var1|var0]<64..1>;
|
||||
// i.e. concatenate var1 and var0,
|
||||
// extract bits <64..1> from the resulting 128-bit value
|
||||
// and put them in var0
|
||||
extr x8, x9, x8, #1
|
||||
extr x9, x10, x9, #1
|
||||
extr x10, x11, x10, #1
|
||||
extr x11, x12, x11, #1
|
||||
lsr x12, x12, #1
|
||||
|
||||
subs x13, x13, #1
|
||||
bne Lbeeu_shift_loop_Y
|
||||
|
||||
Lbeeu_update_B_X_or_A_Y:
|
||||
// Try T := B - A; if cs, continue with B > A (cs: carry set = no borrow)
|
||||
// Note: this is a case of unsigned arithmetic, where T fits in 4 64-bit words
|
||||
// without taking a sign bit if generated. The lack of a carry would
|
||||
// indicate a negative result. See, for example,
|
||||
// https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/condition-codes-1-condition-flags-and-codes
|
||||
subs x14, x25, x21
|
||||
sbcs x15, x26, x22
|
||||
sbcs x19, x27, x23
|
||||
sbcs x20, x28, x24
|
||||
bcs Lbeeu_B_greater_than_A
|
||||
|
||||
// Else A > B =>
|
||||
// A := A - B; Y := Y + X; goto beginning of the loop
|
||||
subs x21, x21, x25
|
||||
sbcs x22, x22, x26
|
||||
sbcs x23, x23, x27
|
||||
sbcs x24, x24, x28
|
||||
|
||||
adds x8, x8, x3
|
||||
adcs x9, x9, x4
|
||||
adcs x10, x10, x5
|
||||
adcs x11, x11, x6
|
||||
adc x12, x12, x7
|
||||
b Lbeeu_loop
|
||||
|
||||
Lbeeu_B_greater_than_A:
|
||||
// Continue with B > A =>
|
||||
// B := B - A; X := X + Y; goto beginning of the loop
|
||||
mov x25, x14
|
||||
mov x26, x15
|
||||
mov x27, x19
|
||||
mov x28, x20
|
||||
|
||||
adds x3, x3, x8
|
||||
adcs x4, x4, x9
|
||||
adcs x5, x5, x10
|
||||
adcs x6, x6, x11
|
||||
adc x7, x7, x12
|
||||
b Lbeeu_loop
|
||||
|
||||
Lbeeu_loop_end:
|
||||
// The Euclid's algorithm loop ends when A == gcd(a,n);
|
||||
// this would be 1, when a and n are co-prime (i.e. do not have a common factor).
|
||||
// Since (-1)*Y*a == A (mod |n|), Y>0
|
||||
// then out = -Y mod n
|
||||
|
||||
// Verify that A = 1 ==> (-1)*Y*a = A = 1 (mod |n|)
|
||||
// Is A-1 == 0?
|
||||
// If not, fail.
|
||||
sub x14, x21, #1
|
||||
orr x14, x14, x22
|
||||
orr x14, x14, x23
|
||||
orr x14, x14, x24
|
||||
cbnz x14, Lbeeu_err
|
||||
|
||||
// If Y>n ==> Y:=Y-n
|
||||
Lbeeu_reduction_loop:
|
||||
// x_i := y_i - n_i (X is no longer needed, use it as temp)
|
||||
// (x14 = 0 from above)
|
||||
subs x3, x8, x0
|
||||
sbcs x4, x9, x1
|
||||
sbcs x5, x10, x2
|
||||
sbcs x6, x11, x30
|
||||
sbcs x7, x12, x14
|
||||
|
||||
// If result is non-negative (i.e., cs = carry set = no borrow),
|
||||
// y_i := x_i; goto reduce again
|
||||
// else
|
||||
// y_i := y_i; continue
|
||||
csel x8, x3, x8, cs
|
||||
csel x9, x4, x9, cs
|
||||
csel x10, x5, x10, cs
|
||||
csel x11, x6, x11, cs
|
||||
csel x12, x7, x12, cs
|
||||
bcs Lbeeu_reduction_loop
|
||||
|
||||
// Now Y < n (Y cannot be equal to n, since the inverse cannot be 0)
|
||||
// out = -Y = n-Y
|
||||
subs x8, x0, x8
|
||||
sbcs x9, x1, x9
|
||||
sbcs x10, x2, x10
|
||||
sbcs x11, x30, x11
|
||||
|
||||
// Save Y in output (out (x0) was saved on the stack)
|
||||
ldr x3, [sp,#96]
|
||||
stp x8, x9, [x3]
|
||||
stp x10, x11, [x3,#16]
|
||||
// return 1 (success)
|
||||
mov x0, #1
|
||||
b Lbeeu_finish
|
||||
|
||||
Lbeeu_err:
|
||||
// return 0 (error)
|
||||
eor x0, x0, x0
|
||||
|
||||
Lbeeu_finish:
|
||||
// Restore callee-saved registers, except x0, x2
|
||||
add sp,x29,#0
|
||||
ldp x19,x20,[sp,#16]
|
||||
ldp x21,x22,[sp,#32]
|
||||
ldp x23,x24,[sp,#48]
|
||||
ldp x25,x26,[sp,#64]
|
||||
ldp x27,x28,[sp,#80]
|
||||
ldp x29,x30,[sp],#112
|
||||
|
||||
AARCH64_VALIDATE_LINK_REGISTER
|
||||
ret
|
||||
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__aarch64__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,327 @@
|
||||
#define BORINGSSL_PREFIX CCryptoBoringSSL
|
||||
#if defined(__aarch64__) && defined(__linux__)
|
||||
// This file is generated from a similarly-named Perl script in the BoringSSL
|
||||
// source tree. Do not edit by hand.
|
||||
|
||||
#if !defined(__has_feature)
|
||||
#define __has_feature(x) 0
|
||||
#endif
|
||||
#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM)
|
||||
#define OPENSSL_NO_ASM
|
||||
#endif
|
||||
|
||||
#if !defined(OPENSSL_NO_ASM)
|
||||
#if defined(__aarch64__)
|
||||
#if defined(BORINGSSL_PREFIX)
|
||||
#include <CCryptoBoringSSL_boringssl_prefix_symbols_asm.h>
|
||||
#endif
|
||||
#include "CCryptoBoringSSL_arm_arch.h"
|
||||
|
||||
.text
|
||||
.globl beeu_mod_inverse_vartime
|
||||
.hidden beeu_mod_inverse_vartime
|
||||
.type beeu_mod_inverse_vartime, %function
|
||||
.align 4
|
||||
beeu_mod_inverse_vartime:
|
||||
// Reserve enough space for 14 8-byte registers on the stack
|
||||
// in the first stp call for x29, x30.
|
||||
// Then store the remaining callee-saved registers.
|
||||
//
|
||||
// | x29 | x30 | x19 | x20 | ... | x27 | x28 | x0 | x2 |
|
||||
// ^ ^
|
||||
// sp <------------------- 112 bytes ----------------> old sp
|
||||
// x29 (FP)
|
||||
//
|
||||
AARCH64_SIGN_LINK_REGISTER
|
||||
stp x29,x30,[sp,#-112]!
|
||||
add x29,sp,#0
|
||||
stp x19,x20,[sp,#16]
|
||||
stp x21,x22,[sp,#32]
|
||||
stp x23,x24,[sp,#48]
|
||||
stp x25,x26,[sp,#64]
|
||||
stp x27,x28,[sp,#80]
|
||||
stp x0,x2,[sp,#96]
|
||||
|
||||
// B = b3..b0 := a
|
||||
ldp x25,x26,[x1]
|
||||
ldp x27,x28,[x1,#16]
|
||||
|
||||
// n3..n0 := n
|
||||
// Note: the value of input params are changed in the following.
|
||||
ldp x0,x1,[x2]
|
||||
ldp x2,x30,[x2,#16]
|
||||
|
||||
// A = a3..a0 := n
|
||||
mov x21, x0
|
||||
mov x22, x1
|
||||
mov x23, x2
|
||||
mov x24, x30
|
||||
|
||||
// X = x4..x0 := 1
|
||||
mov x3, #1
|
||||
eor x4, x4, x4
|
||||
eor x5, x5, x5
|
||||
eor x6, x6, x6
|
||||
eor x7, x7, x7
|
||||
|
||||
// Y = y4..y0 := 0
|
||||
eor x8, x8, x8
|
||||
eor x9, x9, x9
|
||||
eor x10, x10, x10
|
||||
eor x11, x11, x11
|
||||
eor x12, x12, x12
|
||||
|
||||
.Lbeeu_loop:
|
||||
// if B == 0, jump to .Lbeeu_loop_end
|
||||
orr x14, x25, x26
|
||||
orr x14, x14, x27
|
||||
|
||||
// reverse the bit order of x25. This is needed for clz after this macro
|
||||
rbit x15, x25
|
||||
|
||||
orr x14, x14, x28
|
||||
cbz x14,.Lbeeu_loop_end
|
||||
|
||||
|
||||
// 0 < B < |n|,
|
||||
// 0 < A <= |n|,
|
||||
// (1) X*a == B (mod |n|),
|
||||
// (2) (-1)*Y*a == A (mod |n|)
|
||||
|
||||
// Now divide B by the maximum possible power of two in the
|
||||
// integers, and divide X by the same value mod |n|.
|
||||
// When we're done, (1) still holds.
|
||||
|
||||
// shift := number of trailing 0s in x25
|
||||
// ( = number of leading 0s in x15; see the "rbit" instruction in TEST_B_ZERO)
|
||||
clz x13, x15
|
||||
|
||||
// If there is no shift, goto shift_A_Y
|
||||
cbz x13, .Lbeeu_shift_A_Y
|
||||
|
||||
// Shift B right by "x13" bits
|
||||
neg x14, x13
|
||||
lsr x25, x25, x13
|
||||
lsl x15, x26, x14
|
||||
|
||||
lsr x26, x26, x13
|
||||
lsl x19, x27, x14
|
||||
|
||||
orr x25, x25, x15
|
||||
|
||||
lsr x27, x27, x13
|
||||
lsl x20, x28, x14
|
||||
|
||||
orr x26, x26, x19
|
||||
|
||||
lsr x28, x28, x13
|
||||
|
||||
orr x27, x27, x20
|
||||
|
||||
|
||||
// Shift X right by "x13" bits, adding n whenever X becomes odd.
|
||||
// x13--;
|
||||
// x14 := 0; needed in the addition to the most significant word in SHIFT1
|
||||
eor x14, x14, x14
|
||||
.Lbeeu_shift_loop_X:
|
||||
tbz x3, #0, .Lshift1_0
|
||||
adds x3, x3, x0
|
||||
adcs x4, x4, x1
|
||||
adcs x5, x5, x2
|
||||
adcs x6, x6, x30
|
||||
adc x7, x7, x14
|
||||
.Lshift1_0:
|
||||
// var0 := [var1|var0]<64..1>;
|
||||
// i.e. concatenate var1 and var0,
|
||||
// extract bits <64..1> from the resulting 128-bit value
|
||||
// and put them in var0
|
||||
extr x3, x4, x3, #1
|
||||
extr x4, x5, x4, #1
|
||||
extr x5, x6, x5, #1
|
||||
extr x6, x7, x6, #1
|
||||
lsr x7, x7, #1
|
||||
|
||||
subs x13, x13, #1
|
||||
bne .Lbeeu_shift_loop_X
|
||||
|
||||
// Note: the steps above perform the same sequence as in p256_beeu-x86_64-asm.pl
|
||||
// with the following differences:
|
||||
// - "x13" is set directly to the number of trailing 0s in B
|
||||
// (using rbit and clz instructions)
|
||||
// - The loop is only used to call SHIFT1(X)
|
||||
// and x13 is decreased while executing the X loop.
|
||||
// - SHIFT256(B, x13) is performed before right-shifting X; they are independent
|
||||
|
||||
.Lbeeu_shift_A_Y:
|
||||
// Same for A and Y.
|
||||
// Afterwards, (2) still holds.
|
||||
// Reverse the bit order of x21
|
||||
// x13 := number of trailing 0s in x21 (= number of leading 0s in x15)
|
||||
rbit x15, x21
|
||||
clz x13, x15
|
||||
|
||||
// If there is no shift, goto |B-A|, X+Y update
|
||||
cbz x13, .Lbeeu_update_B_X_or_A_Y
|
||||
|
||||
// Shift A right by "x13" bits
|
||||
neg x14, x13
|
||||
lsr x21, x21, x13
|
||||
lsl x15, x22, x14
|
||||
|
||||
lsr x22, x22, x13
|
||||
lsl x19, x23, x14
|
||||
|
||||
orr x21, x21, x15
|
||||
|
||||
lsr x23, x23, x13
|
||||
lsl x20, x24, x14
|
||||
|
||||
orr x22, x22, x19
|
||||
|
||||
lsr x24, x24, x13
|
||||
|
||||
orr x23, x23, x20
|
||||
|
||||
|
||||
// Shift Y right by "x13" bits, adding n whenever Y becomes odd.
|
||||
// x13--;
|
||||
// x14 := 0; needed in the addition to the most significant word in SHIFT1
|
||||
eor x14, x14, x14
|
||||
.Lbeeu_shift_loop_Y:
|
||||
tbz x8, #0, .Lshift1_1
|
||||
adds x8, x8, x0
|
||||
adcs x9, x9, x1
|
||||
adcs x10, x10, x2
|
||||
adcs x11, x11, x30
|
||||
adc x12, x12, x14
|
||||
.Lshift1_1:
|
||||
// var0 := [var1|var0]<64..1>;
|
||||
// i.e. concatenate var1 and var0,
|
||||
// extract bits <64..1> from the resulting 128-bit value
|
||||
// and put them in var0
|
||||
extr x8, x9, x8, #1
|
||||
extr x9, x10, x9, #1
|
||||
extr x10, x11, x10, #1
|
||||
extr x11, x12, x11, #1
|
||||
lsr x12, x12, #1
|
||||
|
||||
subs x13, x13, #1
|
||||
bne .Lbeeu_shift_loop_Y
|
||||
|
||||
.Lbeeu_update_B_X_or_A_Y:
|
||||
// Try T := B - A; if cs, continue with B > A (cs: carry set = no borrow)
|
||||
// Note: this is a case of unsigned arithmetic, where T fits in 4 64-bit words
|
||||
// without taking a sign bit if generated. The lack of a carry would
|
||||
// indicate a negative result. See, for example,
|
||||
// https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/condition-codes-1-condition-flags-and-codes
|
||||
subs x14, x25, x21
|
||||
sbcs x15, x26, x22
|
||||
sbcs x19, x27, x23
|
||||
sbcs x20, x28, x24
|
||||
bcs .Lbeeu_B_greater_than_A
|
||||
|
||||
// Else A > B =>
|
||||
// A := A - B; Y := Y + X; goto beginning of the loop
|
||||
subs x21, x21, x25
|
||||
sbcs x22, x22, x26
|
||||
sbcs x23, x23, x27
|
||||
sbcs x24, x24, x28
|
||||
|
||||
adds x8, x8, x3
|
||||
adcs x9, x9, x4
|
||||
adcs x10, x10, x5
|
||||
adcs x11, x11, x6
|
||||
adc x12, x12, x7
|
||||
b .Lbeeu_loop
|
||||
|
||||
.Lbeeu_B_greater_than_A:
|
||||
// Continue with B > A =>
|
||||
// B := B - A; X := X + Y; goto beginning of the loop
|
||||
mov x25, x14
|
||||
mov x26, x15
|
||||
mov x27, x19
|
||||
mov x28, x20
|
||||
|
||||
adds x3, x3, x8
|
||||
adcs x4, x4, x9
|
||||
adcs x5, x5, x10
|
||||
adcs x6, x6, x11
|
||||
adc x7, x7, x12
|
||||
b .Lbeeu_loop
|
||||
|
||||
.Lbeeu_loop_end:
|
||||
// The Euclid's algorithm loop ends when A == gcd(a,n);
|
||||
// this would be 1, when a and n are co-prime (i.e. do not have a common factor).
|
||||
// Since (-1)*Y*a == A (mod |n|), Y>0
|
||||
// then out = -Y mod n
|
||||
|
||||
// Verify that A = 1 ==> (-1)*Y*a = A = 1 (mod |n|)
|
||||
// Is A-1 == 0?
|
||||
// If not, fail.
|
||||
sub x14, x21, #1
|
||||
orr x14, x14, x22
|
||||
orr x14, x14, x23
|
||||
orr x14, x14, x24
|
||||
cbnz x14, .Lbeeu_err
|
||||
|
||||
// If Y>n ==> Y:=Y-n
|
||||
.Lbeeu_reduction_loop:
|
||||
// x_i := y_i - n_i (X is no longer needed, use it as temp)
|
||||
// (x14 = 0 from above)
|
||||
subs x3, x8, x0
|
||||
sbcs x4, x9, x1
|
||||
sbcs x5, x10, x2
|
||||
sbcs x6, x11, x30
|
||||
sbcs x7, x12, x14
|
||||
|
||||
// If result is non-negative (i.e., cs = carry set = no borrow),
|
||||
// y_i := x_i; goto reduce again
|
||||
// else
|
||||
// y_i := y_i; continue
|
||||
csel x8, x3, x8, cs
|
||||
csel x9, x4, x9, cs
|
||||
csel x10, x5, x10, cs
|
||||
csel x11, x6, x11, cs
|
||||
csel x12, x7, x12, cs
|
||||
bcs .Lbeeu_reduction_loop
|
||||
|
||||
// Now Y < n (Y cannot be equal to n, since the inverse cannot be 0)
|
||||
// out = -Y = n-Y
|
||||
subs x8, x0, x8
|
||||
sbcs x9, x1, x9
|
||||
sbcs x10, x2, x10
|
||||
sbcs x11, x30, x11
|
||||
|
||||
// Save Y in output (out (x0) was saved on the stack)
|
||||
ldr x3, [sp,#96]
|
||||
stp x8, x9, [x3]
|
||||
stp x10, x11, [x3,#16]
|
||||
// return 1 (success)
|
||||
mov x0, #1
|
||||
b .Lbeeu_finish
|
||||
|
||||
.Lbeeu_err:
|
||||
// return 0 (error)
|
||||
eor x0, x0, x0
|
||||
|
||||
.Lbeeu_finish:
|
||||
// Restore callee-saved registers, except x0, x2
|
||||
add sp,x29,#0
|
||||
ldp x19,x20,[sp,#16]
|
||||
ldp x21,x22,[sp,#32]
|
||||
ldp x23,x24,[sp,#48]
|
||||
ldp x25,x26,[sp,#64]
|
||||
ldp x27,x28,[sp,#80]
|
||||
ldp x29,x30,[sp],#112
|
||||
|
||||
AARCH64_VALIDATE_LINK_REGISTER
|
||||
ret
|
||||
.size beeu_mod_inverse_vartime,.-beeu_mod_inverse_vartime
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif // defined(__aarch64__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -927,6 +927,20 @@ struct poly {
|
||||
#endif
|
||||
};
|
||||
|
||||
// poly_normalize zeros out the excess elements of |x| which are included only
|
||||
// for alignment.
|
||||
static void poly_normalize(struct poly *x) {
|
||||
OPENSSL_memset(&x->v[N], 0, 3 * sizeof(uint16_t));
|
||||
}
|
||||
|
||||
// poly_assert_normalized asserts that the excess elements of |x| are zeroed out
|
||||
// for the cases that case. (E.g. |poly_mul_vec|.)
|
||||
static void poly_assert_normalized(const struct poly *x) {
|
||||
assert(x->v[N] == 0);
|
||||
assert(x->v[N + 1] == 0);
|
||||
assert(x->v[N + 2] == 0);
|
||||
}
|
||||
|
||||
OPENSSL_UNUSED static void poly_print(const struct poly *p) {
|
||||
printf("[");
|
||||
for (unsigned i = 0; i < N; i++) {
|
||||
@@ -1213,13 +1227,12 @@ static void poly_mul_vec_aux(vec_t *restrict out, vec_t *restrict scratch,
|
||||
// poly_mul_vec sets |*out| to |x|×|y| mod (𝑥^n - 1).
|
||||
static void poly_mul_vec(struct POLY_MUL_SCRATCH *scratch, struct poly *out,
|
||||
const struct poly *x, const struct poly *y) {
|
||||
OPENSSL_memset((uint16_t *)&x->v[N], 0, 3 * sizeof(uint16_t));
|
||||
OPENSSL_memset((uint16_t *)&y->v[N], 0, 3 * sizeof(uint16_t));
|
||||
|
||||
OPENSSL_STATIC_ASSERT(sizeof(out->v) == sizeof(vec_t) * VECS_PER_POLY,
|
||||
"struct poly is the wrong size");
|
||||
OPENSSL_STATIC_ASSERT(alignof(struct poly) == alignof(vec_t),
|
||||
"struct poly has incorrect alignment");
|
||||
poly_assert_normalized(x);
|
||||
poly_assert_normalized(y);
|
||||
|
||||
vec_t *const prod = scratch->u.vec.prod;
|
||||
vec_t *const aux_scratch = scratch->u.vec.scratch;
|
||||
@@ -1317,19 +1330,22 @@ static void poly_mul(struct POLY_MUL_SCRATCH *scratch, struct poly *r,
|
||||
#if defined(POLY_RQ_MUL_ASM)
|
||||
if (CRYPTO_is_AVX2_capable()) {
|
||||
poly_Rq_mul(r->v, a->v, b->v, scratch->u.rq);
|
||||
return;
|
||||
}
|
||||
poly_normalize(r);
|
||||
} else
|
||||
#endif
|
||||
|
||||
#if defined(HRSS_HAVE_VECTOR_UNIT)
|
||||
if (vec_capable()) {
|
||||
poly_mul_vec(scratch, r, a, b);
|
||||
return;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
|
||||
// Fallback, non-vector case.
|
||||
poly_mul_novec(scratch, r, a, b);
|
||||
{
|
||||
poly_mul_novec(scratch, r, a, b);
|
||||
}
|
||||
|
||||
poly_assert_normalized(r);
|
||||
}
|
||||
|
||||
// poly_mul_x_minus_1 sets |p| to |p|×(𝑥 - 1) mod (𝑥^n - 1).
|
||||
@@ -1494,6 +1510,8 @@ static void poly_from_poly2(struct poly *out, const struct poly2 *in) {
|
||||
shift = 0;
|
||||
}
|
||||
}
|
||||
|
||||
poly_normalize(out);
|
||||
}
|
||||
|
||||
static void poly_from_poly3(struct poly *out, const struct poly3 *in) {
|
||||
@@ -1518,6 +1536,8 @@ static void poly_from_poly3(struct poly *out, const struct poly3 *in) {
|
||||
shift = 0;
|
||||
}
|
||||
}
|
||||
|
||||
poly_normalize(out);
|
||||
}
|
||||
|
||||
// Polynomial inversion
|
||||
@@ -1571,6 +1591,7 @@ static void poly_invert_mod2(struct poly *out, const struct poly *in) {
|
||||
assert(f.v[0] & 1);
|
||||
poly2_reverse_700(&v, &v);
|
||||
poly_from_poly2(out, &v);
|
||||
poly_assert_normalized(out);
|
||||
}
|
||||
|
||||
// poly_invert sets |*out| to |in^-1| (i.e. such that |*out|×|in| = 1 mod Φ(N)).
|
||||
@@ -1584,6 +1605,7 @@ static void poly_invert(struct POLY_MUL_SCRATCH *scratch, struct poly *out,
|
||||
for (unsigned i = 0; i < N; i++) {
|
||||
a.v[i] = -in->v[i];
|
||||
}
|
||||
poly_normalize(&a);
|
||||
|
||||
// b = in^-1 mod 2.
|
||||
b = out;
|
||||
@@ -1596,6 +1618,8 @@ static void poly_invert(struct POLY_MUL_SCRATCH *scratch, struct poly *out,
|
||||
tmp.v[0] += 2;
|
||||
poly_mul(scratch, b, b, &tmp);
|
||||
}
|
||||
|
||||
poly_assert_normalized(out);
|
||||
}
|
||||
|
||||
// Marshal and unmarshal functions for various basic types.
|
||||
@@ -1685,6 +1709,7 @@ static int poly_unmarshal(struct poly *out, const uint8_t in[POLY_BYTES]) {
|
||||
}
|
||||
|
||||
out->v[N - 1] = (uint16_t)(0u - sum);
|
||||
poly_normalize(out);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -1736,6 +1761,7 @@ static void poly_short_sample(struct poly *out,
|
||||
out->v[i] = v;
|
||||
}
|
||||
out->v[N - 1] = 0;
|
||||
poly_normalize(out);
|
||||
}
|
||||
|
||||
// poly_short_sample_plus performs the T+ sample as defined in [HRSSNIST],
|
||||
@@ -1758,6 +1784,7 @@ static void poly_short_sample_plus(struct poly *out,
|
||||
for (unsigned i = 0; i < N; i += 2) {
|
||||
out->v[i] = (unsigned) out->v[i] * scale;
|
||||
}
|
||||
poly_assert_normalized(out);
|
||||
}
|
||||
|
||||
// poly_lift computes the function discussed in [HRSS], appendix B.
|
||||
@@ -1873,6 +1900,7 @@ static void poly_lift(struct poly *out, const struct poly *a) {
|
||||
}
|
||||
|
||||
poly_mul_x_minus_1(out);
|
||||
poly_normalize(out);
|
||||
}
|
||||
|
||||
struct public_key {
|
||||
@@ -1952,6 +1980,10 @@ int HRSS_generate_key(
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if !defined(NDEBUG)
|
||||
OPENSSL_memset(vars, 0xff, sizeof(struct vars));
|
||||
#endif
|
||||
|
||||
OPENSSL_memcpy(priv->hmac_key, in + 2 * HRSS_SAMPLE_BYTES,
|
||||
sizeof(priv->hmac_key));
|
||||
|
||||
@@ -2011,6 +2043,10 @@ int HRSS_encap(uint8_t out_ciphertext[POLY_BYTES], uint8_t out_shared_key[32],
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if !defined(NDEBUG)
|
||||
OPENSSL_memset(vars, 0xff, sizeof(struct vars));
|
||||
#endif
|
||||
|
||||
poly_short_sample(&vars->m, in);
|
||||
poly_short_sample(&vars->r, in + HRSS_SAMPLE_BYTES);
|
||||
poly_lift(&vars->m_lifted, &vars->m);
|
||||
@@ -2068,6 +2104,10 @@ int HRSS_decap(uint8_t out_shared_key[HRSS_KEY_BYTES],
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if !defined(NDEBUG)
|
||||
OPENSSL_memset(vars, 0xff, sizeof(struct vars));
|
||||
#endif
|
||||
|
||||
// This is HMAC, expanded inline rather than using the |HMAC| function so that
|
||||
// we can avoid dealing with possible allocation failures and so keep this
|
||||
// function infallible.
|
||||
@@ -2118,6 +2158,7 @@ int HRSS_decap(uint8_t out_shared_key[HRSS_KEY_BYTES],
|
||||
for (unsigned i = 0; i < N; i++) {
|
||||
vars->r.v[i] = vars->c.v[i] - vars->m_lifted.v[i];
|
||||
}
|
||||
poly_normalize(&vars->r);
|
||||
poly_mul(&vars->scratch, &vars->r, &vars->r, &priv->ph_inverse);
|
||||
poly_mod_phiN(&vars->r);
|
||||
poly_clamp(&vars->r);
|
||||
|
||||
@@ -126,10 +126,18 @@
|
||||
#endif
|
||||
|
||||
#if !defined(__cplusplus)
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#define alignas(x) __declspec(align(x))
|
||||
#define alignof __alignof
|
||||
#else
|
||||
// With the exception of MSVC, we require C11 to build the library. C11 is a
|
||||
// prerequisite for improved refcounting performance. All our supported C
|
||||
// compilers have long implemented C11 and made it default. The most likely
|
||||
// cause of pre-C11 modes is stale -std=c99 or -std=gnu99 flags in build
|
||||
// configuration. Such flags can be removed.
|
||||
#if __STDC_VERSION__ < 201112L
|
||||
#error "BoringSSL must be built in C11 mode or higher."
|
||||
#endif
|
||||
#include <stdalign.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -180,11 +180,17 @@ void OPENSSL_free(void *orig_ptr) {
|
||||
|
||||
size_t size = *(size_t *)ptr;
|
||||
OPENSSL_cleanse(ptr, size + OPENSSL_MALLOC_PREFIX);
|
||||
|
||||
// ASan knows to intercept malloc and free, but not sdallocx.
|
||||
#if defined(OPENSSL_ASAN)
|
||||
free(ptr);
|
||||
#else
|
||||
if (sdallocx) {
|
||||
sdallocx(ptr, size + OPENSSL_MALLOC_PREFIX, 0 /* flags */);
|
||||
} else {
|
||||
free(ptr);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void *OPENSSL_realloc(void *orig_ptr, size_t new_size) {
|
||||
|
||||
@@ -993,8 +993,8 @@ int PKCS12_verify_mac(const PKCS12 *p12, const char *password,
|
||||
|
||||
// add_bag_attributes adds the bagAttributes field of a SafeBag structure,
|
||||
// containing the specified friendlyName and localKeyId attributes.
|
||||
static int add_bag_attributes(CBB *bag, const char *name, const uint8_t *key_id,
|
||||
size_t key_id_len) {
|
||||
static int add_bag_attributes(CBB *bag, const char *name, size_t name_len,
|
||||
const uint8_t *key_id, size_t key_id_len) {
|
||||
if (name == NULL && key_id_len == 0) {
|
||||
return 1; // Omit the OPTIONAL SET.
|
||||
}
|
||||
@@ -1003,7 +1003,7 @@ static int add_bag_attributes(CBB *bag, const char *name, const uint8_t *key_id,
|
||||
if (!CBB_add_asn1(bag, &attrs, CBS_ASN1_SET)) {
|
||||
return 0;
|
||||
}
|
||||
if (name != NULL) {
|
||||
if (name_len != 0) {
|
||||
// See https://tools.ietf.org/html/rfc2985, section 5.5.1.
|
||||
if (!CBB_add_asn1(&attrs, &attr, CBS_ASN1_SEQUENCE) ||
|
||||
!CBB_add_asn1(&attr, &oid, CBS_ASN1_OBJECT) ||
|
||||
@@ -1014,7 +1014,7 @@ static int add_bag_attributes(CBB *bag, const char *name, const uint8_t *key_id,
|
||||
}
|
||||
// Convert the friendly name to a BMPString.
|
||||
CBS name_cbs;
|
||||
CBS_init(&name_cbs, (const uint8_t *)name, strlen(name));
|
||||
CBS_init(&name_cbs, (const uint8_t *)name, name_len);
|
||||
while (CBS_len(&name_cbs) != 0) {
|
||||
uint32_t c;
|
||||
if (!cbs_get_utf8(&name_cbs, &c) ||
|
||||
@@ -1059,10 +1059,24 @@ static int add_cert_bag(CBB *cbb, X509 *cert, const char *name,
|
||||
}
|
||||
uint8_t *buf;
|
||||
int len = i2d_X509(cert, NULL);
|
||||
|
||||
int int_name_len = 0;
|
||||
const char *cert_name = (const char *)X509_alias_get0(cert, &int_name_len);
|
||||
size_t name_len = int_name_len;
|
||||
if (name) {
|
||||
if (name_len != 0) {
|
||||
OPENSSL_PUT_ERROR(PKCS8, PKCS8_R_AMBIGUOUS_FRIENDLY_NAME);
|
||||
return 0;
|
||||
}
|
||||
name_len = strlen(name);
|
||||
} else {
|
||||
name = cert_name;
|
||||
}
|
||||
|
||||
if (len < 0 ||
|
||||
!CBB_add_space(&cert_value, &buf, (size_t)len) ||
|
||||
i2d_X509(cert, &buf) < 0 ||
|
||||
!add_bag_attributes(&bag, name, key_id, key_id_len) ||
|
||||
!add_bag_attributes(&bag, name, name_len, key_id, key_id_len) ||
|
||||
!CBB_flush(cbb)) {
|
||||
return 0;
|
||||
}
|
||||
@@ -1323,7 +1337,11 @@ PKCS12 *PKCS12_create(const char *password, const char *name,
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
if (!add_bag_attributes(&bag, name, key_id, key_id_len) ||
|
||||
size_t name_len = 0;
|
||||
if (name) {
|
||||
name_len = strlen(name);
|
||||
}
|
||||
if (!add_bag_attributes(&bag, name, name_len, key_id, key_id_len) ||
|
||||
!CBB_flush(&content_infos)) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
@@ -204,6 +204,11 @@ void CRYPTO_poly1305_update(poly1305_state *statep, const uint8_t *in,
|
||||
size_t in_len) {
|
||||
struct poly1305_state_st *state = poly1305_aligned_state(statep);
|
||||
|
||||
// Work around a C language bug. See https://crbug.com/1019588.
|
||||
if (in_len == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(OPENSSL_POLY1305_NEON)
|
||||
if (CRYPTO_is_NEON_capable()) {
|
||||
CRYPTO_poly1305_update_neon(statep, in, in_len);
|
||||
|
||||
@@ -156,7 +156,7 @@ struct x509_st {
|
||||
STACK_OF(DIST_POINT) *crldp;
|
||||
STACK_OF(GENERAL_NAME) *altname;
|
||||
NAME_CONSTRAINTS *nc;
|
||||
unsigned char sha1_hash[SHA_DIGEST_LENGTH];
|
||||
unsigned char cert_hash[SHA256_DIGEST_LENGTH];
|
||||
X509_CERT_AUX *aux;
|
||||
CRYPTO_BUFFER *buf;
|
||||
CRYPTO_MUTEX lock;
|
||||
@@ -219,7 +219,7 @@ struct X509_crl_st {
|
||||
// CRL and base CRL numbers for delta processing
|
||||
ASN1_INTEGER *crl_number;
|
||||
ASN1_INTEGER *base_crl_number;
|
||||
unsigned char sha1_hash[SHA_DIGEST_LENGTH];
|
||||
unsigned char crl_hash[SHA256_DIGEST_LENGTH];
|
||||
STACK_OF(GENERAL_NAMES) *issuers;
|
||||
const X509_CRL_METHOD *meth;
|
||||
void *meth_data;
|
||||
|
||||
@@ -322,9 +322,7 @@ int X509_signature_print(BIO *bp, const X509_ALGOR *sigalg,
|
||||
int X509_NAME_print(BIO *bp, const X509_NAME *name, int obase)
|
||||
{
|
||||
char *s, *c, *b;
|
||||
int ret = 0, l, i;
|
||||
|
||||
l = 80 - 2 - obase;
|
||||
int ret = 0, i;
|
||||
|
||||
b = X509_NAME_oneline(name, NULL, 0);
|
||||
if (!b)
|
||||
@@ -351,12 +349,10 @@ int X509_NAME_print(BIO *bp, const X509_NAME *name, int obase)
|
||||
if (BIO_write(bp, ", ", 2) != 2)
|
||||
goto err;
|
||||
}
|
||||
l--;
|
||||
}
|
||||
if (*s == '\0')
|
||||
break;
|
||||
s++;
|
||||
l--;
|
||||
}
|
||||
|
||||
ret = 1;
|
||||
|
||||
@@ -101,7 +101,7 @@ int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b)
|
||||
|
||||
int X509_CRL_match(const X509_CRL *a, const X509_CRL *b)
|
||||
{
|
||||
return OPENSSL_memcmp(a->sha1_hash, b->sha1_hash, 20);
|
||||
return OPENSSL_memcmp(a->crl_hash, b->crl_hash, SHA256_DIGEST_LENGTH);
|
||||
}
|
||||
|
||||
X509_NAME *X509_get_issuer_name(const X509 *a)
|
||||
@@ -154,7 +154,7 @@ unsigned long X509_subject_name_hash_old(X509 *x)
|
||||
*/
|
||||
int X509_cmp(const X509 *a, const X509 *b)
|
||||
{
|
||||
/* Fill in the |sha1_hash| fields.
|
||||
/* Fill in the |cert_hash| fields.
|
||||
*
|
||||
* TODO(davidben): This may fail, in which case the the hash will be all
|
||||
* zeros. This produces a consistent comparison (failures are sticky), but
|
||||
@@ -165,7 +165,7 @@ int X509_cmp(const X509 *a, const X509 *b)
|
||||
x509v3_cache_extensions((X509 *)a);
|
||||
x509v3_cache_extensions((X509 *)b);
|
||||
|
||||
int rv = OPENSSL_memcmp(a->sha1_hash, b->sha1_hash, SHA_DIGEST_LENGTH);
|
||||
int rv = OPENSSL_memcmp(a->cert_hash, b->cert_hash, SHA256_DIGEST_LENGTH);
|
||||
if (rv)
|
||||
return rv;
|
||||
/* Check for match against stored encoding too */
|
||||
|
||||
@@ -71,7 +71,6 @@ static int trust_1oid(X509_TRUST *trust, X509 *x, int flags);
|
||||
static int trust_compat(X509_TRUST *trust, X509 *x, int flags);
|
||||
|
||||
static int obj_trust(int id, X509 *x, int flags);
|
||||
static int (*default_trust) (int id, X509 *x, int flags) = obj_trust;
|
||||
|
||||
/*
|
||||
* WARNING: the following table should be kept in order of trust and without
|
||||
@@ -106,14 +105,6 @@ static int tr_cmp(const X509_TRUST **a, const X509_TRUST **b)
|
||||
return (*a)->trust - (*b)->trust;
|
||||
}
|
||||
|
||||
int (*X509_TRUST_set_default(int (*trust) (int, X509 *, int))) (int, X509 *,
|
||||
int) {
|
||||
int (*oldtrust) (int, X509 *, int);
|
||||
oldtrust = default_trust;
|
||||
default_trust = trust;
|
||||
return oldtrust;
|
||||
}
|
||||
|
||||
int X509_check_trust(X509 *x, int id, int flags)
|
||||
{
|
||||
X509_TRUST *pt;
|
||||
@@ -130,7 +121,7 @@ int X509_check_trust(X509 *x, int id, int flags)
|
||||
}
|
||||
idx = X509_TRUST_get_by_id(id);
|
||||
if (idx == -1)
|
||||
return default_trust(id, x, flags);
|
||||
return obj_trust(id, x, flags);
|
||||
pt = X509_TRUST_get0(idx);
|
||||
return pt->check_trust(pt, x, flags);
|
||||
}
|
||||
|
||||
@@ -251,7 +251,7 @@ static int crl_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
break;
|
||||
|
||||
case ASN1_OP_D2I_POST:
|
||||
if (!X509_CRL_digest(crl, EVP_sha1(), crl->sha1_hash, NULL)) {
|
||||
if (!X509_CRL_digest(crl, EVP_sha256(), crl->crl_hash, NULL)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -437,7 +437,7 @@ int x509v3_cache_extensions(X509 *x)
|
||||
return (x->ex_flags & EXFLAG_INVALID) == 0;
|
||||
}
|
||||
|
||||
if (!X509_digest(x, EVP_sha1(), x->sha1_hash, NULL))
|
||||
if (!X509_digest(x, EVP_sha256(), x->cert_hash, NULL))
|
||||
x->ex_flags |= EXFLAG_INVALID;
|
||||
/* V1 should mean no extensions ... */
|
||||
if (X509_get_version(x) == X509_VERSION_1)
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
This directory is derived from BoringSSL cloned from https://boringssl.googlesource.com/boringssl at revision 8bbefbfeee609b17622deedd100163c12f5c95dc
|
||||
This directory is derived from BoringSSL cloned from https://boringssl.googlesource.com/boringssl at revision f961de5c47ed265c3e758ec70dd15ece20809962
|
||||
@@ -2016,7 +2016,6 @@
|
||||
#define X509_TRUST_get_flags BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_TRUST_get_flags)
|
||||
#define X509_TRUST_get_trust BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_TRUST_get_trust)
|
||||
#define X509_TRUST_set BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_TRUST_set)
|
||||
#define X509_TRUST_set_default BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_TRUST_set_default)
|
||||
#define X509_VAL_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_VAL_free)
|
||||
#define X509_VAL_it BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_VAL_it)
|
||||
#define X509_VAL_new BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_VAL_new)
|
||||
@@ -2554,6 +2553,10 @@
|
||||
#define ecdsa_do_verify_no_self_test BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ecdsa_do_verify_no_self_test)
|
||||
#define ecdsa_sign_with_nonce_for_known_answer_test BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ecdsa_sign_with_nonce_for_known_answer_test)
|
||||
#define ecp_nistz256_avx2_select_w7 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ecp_nistz256_avx2_select_w7)
|
||||
#define ecp_nistz256_div_by_2 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ecp_nistz256_div_by_2)
|
||||
#define ecp_nistz256_from_mont BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ecp_nistz256_from_mont)
|
||||
#define ecp_nistz256_mul_by_2 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ecp_nistz256_mul_by_2)
|
||||
#define ecp_nistz256_mul_by_3 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ecp_nistz256_mul_by_3)
|
||||
#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)
|
||||
#define ecp_nistz256_ord_mul_mont BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ecp_nistz256_ord_mul_mont)
|
||||
@@ -2564,6 +2567,8 @@
|
||||
#define ecp_nistz256_select_w5 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ecp_nistz256_select_w5)
|
||||
#define ecp_nistz256_select_w7 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ecp_nistz256_select_w7)
|
||||
#define ecp_nistz256_sqr_mont BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ecp_nistz256_sqr_mont)
|
||||
#define ecp_nistz256_sub BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ecp_nistz256_sub)
|
||||
#define ecp_nistz256_to_mont BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ecp_nistz256_to_mont)
|
||||
#define ed25519_asn1_meth BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ed25519_asn1_meth)
|
||||
#define ed25519_pkey_meth BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ed25519_pkey_meth)
|
||||
#define gcm_ghash_avx BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, gcm_ghash_avx)
|
||||
|
||||
@@ -2021,7 +2021,6 @@
|
||||
#define _X509_TRUST_get_flags BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_TRUST_get_flags)
|
||||
#define _X509_TRUST_get_trust BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_TRUST_get_trust)
|
||||
#define _X509_TRUST_set BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_TRUST_set)
|
||||
#define _X509_TRUST_set_default BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_TRUST_set_default)
|
||||
#define _X509_VAL_free BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_VAL_free)
|
||||
#define _X509_VAL_it BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_VAL_it)
|
||||
#define _X509_VAL_new BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_VAL_new)
|
||||
@@ -2559,6 +2558,10 @@
|
||||
#define _ecdsa_do_verify_no_self_test BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ecdsa_do_verify_no_self_test)
|
||||
#define _ecdsa_sign_with_nonce_for_known_answer_test BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ecdsa_sign_with_nonce_for_known_answer_test)
|
||||
#define _ecp_nistz256_avx2_select_w7 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ecp_nistz256_avx2_select_w7)
|
||||
#define _ecp_nistz256_div_by_2 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ecp_nistz256_div_by_2)
|
||||
#define _ecp_nistz256_from_mont BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ecp_nistz256_from_mont)
|
||||
#define _ecp_nistz256_mul_by_2 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ecp_nistz256_mul_by_2)
|
||||
#define _ecp_nistz256_mul_by_3 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ecp_nistz256_mul_by_3)
|
||||
#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)
|
||||
#define _ecp_nistz256_ord_mul_mont BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ecp_nistz256_ord_mul_mont)
|
||||
@@ -2569,6 +2572,8 @@
|
||||
#define _ecp_nistz256_select_w5 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ecp_nistz256_select_w5)
|
||||
#define _ecp_nistz256_select_w7 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ecp_nistz256_select_w7)
|
||||
#define _ecp_nistz256_sqr_mont BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ecp_nistz256_sqr_mont)
|
||||
#define _ecp_nistz256_sub BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ecp_nistz256_sub)
|
||||
#define _ecp_nistz256_to_mont BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ecp_nistz256_to_mont)
|
||||
#define _ed25519_asn1_meth BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ed25519_asn1_meth)
|
||||
#define _ed25519_pkey_meth BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ed25519_pkey_meth)
|
||||
#define _gcm_ghash_avx BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, gcm_ghash_avx)
|
||||
|
||||
@@ -265,6 +265,10 @@ OPENSSL_EXPORT int CBS_get_any_asn1_element(CBS *cbs, CBS *out,
|
||||
// also true for empty elements so |*out_indefinite| should be checked). If
|
||||
// |out_ber_found| is not NULL then it is set to one if any case of invalid DER
|
||||
// but valid BER is found, and to zero otherwise.
|
||||
//
|
||||
// This function will not successfully parse an end-of-contents (EOC) as an
|
||||
// element. Callers parsing indefinite-length encoding must check for EOC
|
||||
// separately.
|
||||
OPENSSL_EXPORT int CBS_get_any_ber_asn1_element(CBS *cbs, CBS *out,
|
||||
unsigned *out_tag,
|
||||
size_t *out_header_len,
|
||||
|
||||
@@ -122,6 +122,8 @@ OPENSSL_EXPORT EVP_PKEY *PKCS8_parse_encrypted_private_key(CBS *cbs,
|
||||
// and decrypts it using |password|, sets |*out_key| to the included private
|
||||
// key and appends the included certificates to |out_certs|. It returns one on
|
||||
// success and zero on error. The caller takes ownership of the outputs.
|
||||
// Any friendlyName attributes (RFC 2985) in the PKCS#12 structure will be
|
||||
// returned on the |X509| objects as aliases. See also |X509_alias_get0|.
|
||||
OPENSSL_EXPORT int PKCS12_get_key_and_certs(EVP_PKEY **out_key,
|
||||
STACK_OF(X509) *out_certs,
|
||||
CBS *in, const char *password);
|
||||
@@ -219,6 +221,11 @@ OPENSSL_EXPORT int PKCS12_verify_mac(const PKCS12 *p12, const char *password,
|
||||
// implemented for compatibility with external packages. Note the output still
|
||||
// requires a password for the MAC. Unencrypted keys in PKCS#12 are also not
|
||||
// widely supported and may not open in other implementations.
|
||||
//
|
||||
// If |cert| or |chain| have associated aliases (see |X509_alias_set1|), they
|
||||
// will be included in the output as friendlyName attributes (RFC 2985). It is
|
||||
// an error to specify both an alias on |cert| and a non-NULL |name|
|
||||
// parameter.
|
||||
OPENSSL_EXPORT PKCS12 *PKCS12_create(const char *password, const char *name,
|
||||
const EVP_PKEY *pkey, X509 *cert,
|
||||
const STACK_OF(X509) *chain, int key_nid,
|
||||
@@ -278,5 +285,6 @@ BSSL_NAMESPACE_END
|
||||
#define PKCS8_R_UNSUPPORTED_PRF 130
|
||||
#define PKCS8_R_INVALID_CHARACTERS 131
|
||||
#define PKCS8_R_UNSUPPORTED_OPTIONS 132
|
||||
#define PKCS8_R_AMBIGUOUS_FRIENDLY_NAME 133
|
||||
|
||||
#endif // OPENSSL_HEADER_PKCS8_H
|
||||
@@ -96,6 +96,15 @@ class Span : private internal::SpanBase<const T> {
|
||||
private:
|
||||
static const size_t npos = static_cast<size_t>(-1);
|
||||
|
||||
// Heuristically test whether C is a container type that can be converted into
|
||||
// a Span by checking for data() and size() member functions.
|
||||
//
|
||||
// TODO(davidben): Require C++17 support for std::is_convertible_v, etc.
|
||||
template <typename C>
|
||||
using EnableIfContainer = std::enable_if_t<
|
||||
std::is_convertible<decltype(std::declval<C>().data()), T *>::value &&
|
||||
std::is_integral<decltype(std::declval<C>().size())>::value>;
|
||||
|
||||
public:
|
||||
constexpr Span() : Span(nullptr, 0) {}
|
||||
constexpr Span(T *ptr, size_t len) : data_(ptr), size_(len) {}
|
||||
@@ -103,29 +112,12 @@ class Span : private internal::SpanBase<const T> {
|
||||
template <size_t N>
|
||||
constexpr Span(T (&array)[N]) : Span(array, N) {}
|
||||
|
||||
template <
|
||||
typename C,
|
||||
// TODO(davidben): Switch everything to std::enable_if_t when we remove
|
||||
// support for MSVC 2015. Although we could write our own enable_if_t and
|
||||
// MSVC 2015 has std::enable_if_t anyway, MSVC 2015's SFINAE
|
||||
// implementation is problematic and does not work below unless we write
|
||||
// the ::type at use.
|
||||
//
|
||||
// TODO(davidben): Move this and the identical copy below into an
|
||||
// EnableIfContainer alias when we drop MSVC 2015 support. MSVC 2015's
|
||||
// SFINAE support cannot handle type aliases.
|
||||
typename = typename std::enable_if<
|
||||
std::is_convertible<decltype(std::declval<C>().data()), T *>::value &&
|
||||
std::is_integral<decltype(std::declval<C>().size())>::value>::type,
|
||||
typename = typename std::enable_if<std::is_const<T>::value, C>::type>
|
||||
template <typename C, typename = EnableIfContainer<C>,
|
||||
typename = std::enable_if_t<std::is_const<T>::value, C>>
|
||||
Span(const C &container) : data_(container.data()), size_(container.size()) {}
|
||||
|
||||
template <
|
||||
typename C,
|
||||
typename = typename std::enable_if<
|
||||
std::is_convertible<decltype(std::declval<C>().data()), T *>::value &&
|
||||
std::is_integral<decltype(std::declval<C>().size())>::value>::type,
|
||||
typename = typename std::enable_if<!std::is_const<T>::value, C>::type>
|
||||
template <typename C, typename = EnableIfContainer<C>,
|
||||
typename = std::enable_if_t<!std::is_const<T>::value, C>>
|
||||
explicit Span(C &container)
|
||||
: data_(container.data()), size_(container.size()) {}
|
||||
|
||||
|
||||
@@ -443,16 +443,14 @@ namespace internal {
|
||||
|
||||
// Stacks defined with |DEFINE_CONST_STACK_OF| are freed with |sk_free|.
|
||||
template <typename Stack>
|
||||
struct DeleterImpl<
|
||||
Stack, typename std::enable_if<StackTraits<Stack>::kIsConst>::type> {
|
||||
struct DeleterImpl<Stack, std::enable_if_t<StackTraits<Stack>::kIsConst>> {
|
||||
static void Free(Stack *sk) { sk_free(reinterpret_cast<_STACK *>(sk)); }
|
||||
};
|
||||
|
||||
// Stacks defined with |DEFINE_STACK_OF| are freed with |sk_pop_free| and the
|
||||
// corresponding type's deleter.
|
||||
template <typename Stack>
|
||||
struct DeleterImpl<
|
||||
Stack, typename std::enable_if<!StackTraits<Stack>::kIsConst>::type> {
|
||||
struct DeleterImpl<Stack, std::enable_if_t<!StackTraits<Stack>::kIsConst>> {
|
||||
static void Free(Stack *sk) {
|
||||
// sk_FOO_pop_free is defined by macros and bound by name, so we cannot
|
||||
// access it from C++ here.
|
||||
@@ -502,18 +500,17 @@ class StackIteratorImpl {
|
||||
};
|
||||
|
||||
template <typename Stack>
|
||||
using StackIterator = typename std::enable_if<StackTraits<Stack>::kIsStack,
|
||||
StackIteratorImpl<Stack>>::type;
|
||||
using StackIterator =
|
||||
std::enable_if_t<StackTraits<Stack>::kIsStack, StackIteratorImpl<Stack>>;
|
||||
|
||||
} // namespace internal
|
||||
|
||||
// PushToStack pushes |elem| to |sk|. It returns true on success and false on
|
||||
// allocation failure.
|
||||
template <typename Stack>
|
||||
inline
|
||||
typename std::enable_if<!internal::StackTraits<Stack>::kIsConst, bool>::type
|
||||
PushToStack(Stack *sk,
|
||||
UniquePtr<typename internal::StackTraits<Stack>::Type> elem) {
|
||||
inline std::enable_if_t<!internal::StackTraits<Stack>::kIsConst, bool>
|
||||
PushToStack(Stack *sk,
|
||||
UniquePtr<typename internal::StackTraits<Stack>::Type> elem) {
|
||||
if (!sk_push(reinterpret_cast<_STACK *>(sk), elem.get())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,12 @@ extern "C" {
|
||||
// C11 defines the |_Static_assert| keyword and the |static_assert| macro in
|
||||
// assert.h. While the former is available at all versions in Clang and GCC, the
|
||||
// later depends on libc and, in glibc, depends on being built in C11 mode. We
|
||||
// do not require this, for now, so use |_Static_assert| directly.
|
||||
// require C11 mode to build the library but, for now, do not require it in
|
||||
// public headers. Use |_Static_assert| directly.
|
||||
//
|
||||
// TODO(davidben): In July 2022, if the C11 change has not been reverted, switch
|
||||
// all uses of this macro within the library to C11 |static_assert|. This macro
|
||||
// will only be necessary in public headers.
|
||||
#define OPENSSL_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -993,9 +993,6 @@ OPENSSL_EXPORT void X509_trust_clear(X509 *x);
|
||||
OPENSSL_EXPORT void X509_reject_clear(X509 *x);
|
||||
|
||||
|
||||
OPENSSL_EXPORT int (*X509_TRUST_set_default(int (*trust)(int, X509 *,
|
||||
int)))(int, X509 *,
|
||||
int);
|
||||
OPENSSL_EXPORT int X509_TRUST_set(int *t, int trust);
|
||||
|
||||
DECLARE_ASN1_FUNCTIONS(X509_REVOKED)
|
||||
|
||||
@@ -2013,7 +2013,6 @@
|
||||
%xdefine _X509_TRUST_get_flags _ %+ BORINGSSL_PREFIX %+ _X509_TRUST_get_flags
|
||||
%xdefine _X509_TRUST_get_trust _ %+ BORINGSSL_PREFIX %+ _X509_TRUST_get_trust
|
||||
%xdefine _X509_TRUST_set _ %+ BORINGSSL_PREFIX %+ _X509_TRUST_set
|
||||
%xdefine _X509_TRUST_set_default _ %+ BORINGSSL_PREFIX %+ _X509_TRUST_set_default
|
||||
%xdefine _X509_VAL_free _ %+ BORINGSSL_PREFIX %+ _X509_VAL_free
|
||||
%xdefine _X509_VAL_it _ %+ BORINGSSL_PREFIX %+ _X509_VAL_it
|
||||
%xdefine _X509_VAL_new _ %+ BORINGSSL_PREFIX %+ _X509_VAL_new
|
||||
@@ -2551,6 +2550,10 @@
|
||||
%xdefine _ecdsa_do_verify_no_self_test _ %+ BORINGSSL_PREFIX %+ _ecdsa_do_verify_no_self_test
|
||||
%xdefine _ecdsa_sign_with_nonce_for_known_answer_test _ %+ BORINGSSL_PREFIX %+ _ecdsa_sign_with_nonce_for_known_answer_test
|
||||
%xdefine _ecp_nistz256_avx2_select_w7 _ %+ BORINGSSL_PREFIX %+ _ecp_nistz256_avx2_select_w7
|
||||
%xdefine _ecp_nistz256_div_by_2 _ %+ BORINGSSL_PREFIX %+ _ecp_nistz256_div_by_2
|
||||
%xdefine _ecp_nistz256_from_mont _ %+ BORINGSSL_PREFIX %+ _ecp_nistz256_from_mont
|
||||
%xdefine _ecp_nistz256_mul_by_2 _ %+ BORINGSSL_PREFIX %+ _ecp_nistz256_mul_by_2
|
||||
%xdefine _ecp_nistz256_mul_by_3 _ %+ BORINGSSL_PREFIX %+ _ecp_nistz256_mul_by_3
|
||||
%xdefine _ecp_nistz256_mul_mont _ %+ BORINGSSL_PREFIX %+ _ecp_nistz256_mul_mont
|
||||
%xdefine _ecp_nistz256_neg _ %+ BORINGSSL_PREFIX %+ _ecp_nistz256_neg
|
||||
%xdefine _ecp_nistz256_ord_mul_mont _ %+ BORINGSSL_PREFIX %+ _ecp_nistz256_ord_mul_mont
|
||||
@@ -2561,6 +2564,8 @@
|
||||
%xdefine _ecp_nistz256_select_w5 _ %+ BORINGSSL_PREFIX %+ _ecp_nistz256_select_w5
|
||||
%xdefine _ecp_nistz256_select_w7 _ %+ BORINGSSL_PREFIX %+ _ecp_nistz256_select_w7
|
||||
%xdefine _ecp_nistz256_sqr_mont _ %+ BORINGSSL_PREFIX %+ _ecp_nistz256_sqr_mont
|
||||
%xdefine _ecp_nistz256_sub _ %+ BORINGSSL_PREFIX %+ _ecp_nistz256_sub
|
||||
%xdefine _ecp_nistz256_to_mont _ %+ BORINGSSL_PREFIX %+ _ecp_nistz256_to_mont
|
||||
%xdefine _ed25519_asn1_meth _ %+ BORINGSSL_PREFIX %+ _ed25519_asn1_meth
|
||||
%xdefine _ed25519_pkey_meth _ %+ BORINGSSL_PREFIX %+ _ed25519_pkey_meth
|
||||
%xdefine _gcm_ghash_avx _ %+ BORINGSSL_PREFIX %+ _gcm_ghash_avx
|
||||
@@ -4878,7 +4883,6 @@
|
||||
%xdefine X509_TRUST_get_flags BORINGSSL_PREFIX %+ _X509_TRUST_get_flags
|
||||
%xdefine X509_TRUST_get_trust BORINGSSL_PREFIX %+ _X509_TRUST_get_trust
|
||||
%xdefine X509_TRUST_set BORINGSSL_PREFIX %+ _X509_TRUST_set
|
||||
%xdefine X509_TRUST_set_default BORINGSSL_PREFIX %+ _X509_TRUST_set_default
|
||||
%xdefine X509_VAL_free BORINGSSL_PREFIX %+ _X509_VAL_free
|
||||
%xdefine X509_VAL_it BORINGSSL_PREFIX %+ _X509_VAL_it
|
||||
%xdefine X509_VAL_new BORINGSSL_PREFIX %+ _X509_VAL_new
|
||||
@@ -5416,6 +5420,10 @@
|
||||
%xdefine ecdsa_do_verify_no_self_test BORINGSSL_PREFIX %+ _ecdsa_do_verify_no_self_test
|
||||
%xdefine ecdsa_sign_with_nonce_for_known_answer_test BORINGSSL_PREFIX %+ _ecdsa_sign_with_nonce_for_known_answer_test
|
||||
%xdefine ecp_nistz256_avx2_select_w7 BORINGSSL_PREFIX %+ _ecp_nistz256_avx2_select_w7
|
||||
%xdefine ecp_nistz256_div_by_2 BORINGSSL_PREFIX %+ _ecp_nistz256_div_by_2
|
||||
%xdefine ecp_nistz256_from_mont BORINGSSL_PREFIX %+ _ecp_nistz256_from_mont
|
||||
%xdefine ecp_nistz256_mul_by_2 BORINGSSL_PREFIX %+ _ecp_nistz256_mul_by_2
|
||||
%xdefine ecp_nistz256_mul_by_3 BORINGSSL_PREFIX %+ _ecp_nistz256_mul_by_3
|
||||
%xdefine ecp_nistz256_mul_mont BORINGSSL_PREFIX %+ _ecp_nistz256_mul_mont
|
||||
%xdefine ecp_nistz256_neg BORINGSSL_PREFIX %+ _ecp_nistz256_neg
|
||||
%xdefine ecp_nistz256_ord_mul_mont BORINGSSL_PREFIX %+ _ecp_nistz256_ord_mul_mont
|
||||
@@ -5426,6 +5434,8 @@
|
||||
%xdefine ecp_nistz256_select_w5 BORINGSSL_PREFIX %+ _ecp_nistz256_select_w5
|
||||
%xdefine ecp_nistz256_select_w7 BORINGSSL_PREFIX %+ _ecp_nistz256_select_w7
|
||||
%xdefine ecp_nistz256_sqr_mont BORINGSSL_PREFIX %+ _ecp_nistz256_sqr_mont
|
||||
%xdefine ecp_nistz256_sub BORINGSSL_PREFIX %+ _ecp_nistz256_sub
|
||||
%xdefine ecp_nistz256_to_mont BORINGSSL_PREFIX %+ _ecp_nistz256_to_mont
|
||||
%xdefine ed25519_asn1_meth BORINGSSL_PREFIX %+ _ed25519_asn1_meth
|
||||
%xdefine ed25519_pkey_meth BORINGSSL_PREFIX %+ _ed25519_pkey_meth
|
||||
%xdefine gcm_ghash_avx BORINGSSL_PREFIX %+ _gcm_ghash_avx
|
||||
|
||||
+1241
-657
File diff suppressed because it is too large.
Load diff
+751
-398
File diff suppressed because it is too large.
Load diff
+2766
-1153
File diff suppressed because it is too large.
Load diff
+1272
-487
File diff suppressed because it is too large.
Load diff
@@ -11,6 +11,9 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
#if (os(macOS) || os(iOS) || os(watchOS) || os(tvOS)) && CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
@_exported import CryptoKit
|
||||
#else
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
|
||||
/// A wrapper around BoringSSL's EC_POINT with some lifetime management.
|
||||
@@ -76,3 +79,4 @@ extension EllipticCurvePoint {
|
||||
return (x: x, y: y)
|
||||
}
|
||||
}
|
||||
#endif // (os(macOS) || os(iOS) || os(watchOS) || os(tvOS)) && CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
@@ -11,6 +11,9 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
#if (os(macOS) || os(iOS) || os(watchOS) || os(tvOS)) && CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
@_exported import CryptoKit
|
||||
#else
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
|
||||
/// A wrapper around BoringSSL's EC_GROUP object that handles reference counting and
|
||||
@@ -117,3 +120,4 @@ extension BoringSSLEllipticCurveGroup.CurveName {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // (os(macOS) || os(iOS) || os(watchOS) || os(tvOS)) && CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
@@ -11,6 +11,9 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
#if (os(macOS) || os(iOS) || os(watchOS) || os(tvOS)) && CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
@_exported import CryptoKit
|
||||
#else
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
@_implementationOnly import CCryptoBoringSSLShims
|
||||
import Foundation
|
||||
@@ -101,3 +104,4 @@ class ECDSASignature {
|
||||
try body(self._baseSig)
|
||||
}
|
||||
}
|
||||
#endif // (os(macOS) || os(iOS) || os(watchOS) || os(tvOS)) && CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
@@ -11,6 +11,9 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
#if (os(macOS) || os(iOS) || os(watchOS) || os(tvOS)) && CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
@_exported import CryptoKit
|
||||
#else
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
@_implementationOnly import CCryptoBoringSSLShims
|
||||
import Foundation
|
||||
@@ -439,3 +442,4 @@ extension ArbitraryPrecisionInteger: CustomDebugStringConvertible {
|
||||
return String(decoding: UnsafeBufferPointer(start: stringPointer, count: length), as: Unicode.UTF8.self)
|
||||
}
|
||||
}
|
||||
#endif // (os(macOS) || os(iOS) || os(watchOS) || os(tvOS)) && CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
@@ -11,6 +11,9 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
#if (os(macOS) || os(iOS) || os(watchOS) || os(tvOS)) && CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
@_exported import CryptoKit
|
||||
#else
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
|
||||
extension CryptoKitError {
|
||||
@@ -20,3 +23,4 @@ extension CryptoKitError {
|
||||
.underlyingCoreCryptoError(error: Int32(bitPattern: CCryptoBoringSSL_ERR_get_error()))
|
||||
}
|
||||
}
|
||||
#endif // (os(macOS) || os(iOS) || os(watchOS) || os(tvOS)) && CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
@@ -11,6 +11,9 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
#if (os(macOS) || os(iOS) || os(watchOS) || os(tvOS)) && CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
@_exported import CryptoKit
|
||||
#else
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
import Foundation
|
||||
|
||||
@@ -153,3 +156,4 @@ extension FiniteFieldArithmeticContext {
|
||||
return try ArbitraryPrecisionInteger(copying: actualOutputPointer)
|
||||
}
|
||||
}
|
||||
#endif // (os(macOS) || os(iOS) || os(watchOS) || os(tvOS)) && CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
@@ -11,6 +11,8 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
#if (os(macOS) || os(iOS) || os(watchOS) || os(tvOS)) && CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
#else
|
||||
@testable import Crypto
|
||||
import XCTest
|
||||
|
||||
@@ -110,3 +112,4 @@ final class ArbitraryPrecisionIntegerTests: XCTestCase {
|
||||
XCTAssertTrue(two >= two)
|
||||
}
|
||||
}
|
||||
#endif // (os(macOS) || os(iOS) || os(watchOS) || os(tvOS)) && CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
||||
@@ -26,15 +26,11 @@ func orFail<T>(file: StaticString = #file, line: UInt = #line, _ closure: () thr
|
||||
}
|
||||
}
|
||||
|
||||
#if compiler(>=5.2) && canImport(Darwin)
|
||||
if #available(macOS 10.15.4, macCatalyst 13.4, iOS 13.4, tvOS 13.4, watchOS 6.0, *) {
|
||||
return try closure()
|
||||
} else {
|
||||
return try wrapper(closure, file: file, line: line)
|
||||
}
|
||||
#else
|
||||
if #available(macOS 10.15.4, macCatalyst 13.4, iOS 13.4, tvOS 13.4, watchOS 6.0, *) {
|
||||
return try closure()
|
||||
} else {
|
||||
return try wrapper(closure, file: file, line: line)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
extension XCTestCase {
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
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
|
||||
@@ -1,17 +0,0 @@
|
||||
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
|
||||
@@ -3,19 +3,19 @@ version: "3"
|
||||
services:
|
||||
|
||||
runtime-setup:
|
||||
image: swift-crypto:20.04-5.4
|
||||
image: swift-crypto:18.04-5.4
|
||||
build:
|
||||
args:
|
||||
ubuntu_version: "focal"
|
||||
swift_version: "5.4"
|
||||
|
||||
test:
|
||||
image: swift-crypto:20.04-5.4
|
||||
image: swift-crypto:18.04-5.4
|
||||
environment: []
|
||||
#- SANITIZER_ARG=--sanitize=thread
|
||||
|
||||
cmake:
|
||||
image: swift-crypto:20.04-5.4
|
||||
image: swift-crypto:18.04-5.4
|
||||
|
||||
shell:
|
||||
image: swift-crypto:20.04-5.4
|
||||
image: swift-crypto:18.04-5.4
|
||||
@@ -1,21 +0,0 @@
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
|
||||
runtime-setup:
|
||||
image: swift-crypto:20.04-5.3
|
||||
build:
|
||||
args:
|
||||
ubuntu_version: "focal"
|
||||
swift_version: "5.3"
|
||||
|
||||
test:
|
||||
image: swift-crypto:20.04-5.3
|
||||
environment: []
|
||||
#- SANITIZER_ARG=--sanitize=thread
|
||||
|
||||
cmake:
|
||||
image: swift-crypto:20.04-5.3
|
||||
|
||||
shell:
|
||||
image: swift-crypto:20.04-5.3
|
||||
@@ -3,7 +3,7 @@
|
||||
##
|
||||
## This source file is part of the SwiftCrypto open source project
|
||||
##
|
||||
## Copyright (c) 2019-2020 Apple Inc. and the SwiftCrypto project authors
|
||||
## Copyright (c) 2019-2022 Apple Inc. and the SwiftCrypto project authors
|
||||
## Licensed under Apache License v2.0
|
||||
##
|
||||
## See LICENSE.txt for license information
|
||||
@@ -15,46 +15,15 @@
|
||||
|
||||
set -eu
|
||||
|
||||
# repodir
|
||||
function all_modules() {
|
||||
local repodir="$1"
|
||||
(
|
||||
set -eu
|
||||
cd "$repodir"
|
||||
swift package dump-package | jq '.products |
|
||||
map(select(.type | has("library") )) |
|
||||
map(.name) | .[]' | tr -d '"'
|
||||
)
|
||||
}
|
||||
|
||||
# repodir tag output
|
||||
function build_and_do() {
|
||||
local repodir=$1
|
||||
local tag=$2
|
||||
local output=$3
|
||||
|
||||
(
|
||||
cd "$repodir"
|
||||
git checkout -q "$tag"
|
||||
# Clean up output from previous build to prevent potential interference
|
||||
rm -rf .build
|
||||
swift build
|
||||
while read -r module; do
|
||||
swift api-digester -sdk "$sdk" -dump-sdk -module "$module" \
|
||||
-o "$output/$module.json" -I "$repodir/.build/debug"
|
||||
done < <(all_modules "$repodir")
|
||||
)
|
||||
}
|
||||
|
||||
function usage() {
|
||||
echo >&2 "Usage: $0 REPO-GITHUB-URL NEW-VERSION OLD-VERSIONS..."
|
||||
echo >&2
|
||||
echo >&2 "This script requires a Swift 5.1+ toolchain."
|
||||
echo >&2 "This script requires a Swift 5.6+ toolchain."
|
||||
echo >&2
|
||||
echo >&2 "Examples:"
|
||||
echo >&2
|
||||
echo >&2 "Check between main and tag 2.1.1 of swift-nio:"
|
||||
echo >&2 " $0 https://github.com/apple/swift-nio main 2.1.1"
|
||||
echo >&2 "Check between main and tag 2.0.5 of swift-crypto:"
|
||||
echo >&2 " $0 https://github.com/apple/swift-crypto main 2.0.5"
|
||||
echo >&2
|
||||
echo >&2 "Check between HEAD and commit 64cf63d7 using the provided toolchain:"
|
||||
echo >&2 " xcrun --toolchain org.swift.5120190702a $0 ../some-local-repo HEAD 64cf63d7"
|
||||
@@ -65,12 +34,6 @@ if [[ $# -lt 3 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sdk=/
|
||||
if [[ "$(uname -s)" == Darwin ]]; then
|
||||
sdk=$(xcrun --show-sdk-path)
|
||||
fi
|
||||
|
||||
hash jq 2> /dev/null || { echo >&2 "ERROR: jq must be installed"; exit 1; }
|
||||
tmpdir=$(mktemp -d /tmp/.check-api_XXXXXX)
|
||||
repo_url=$1
|
||||
new_tag=$2
|
||||
@@ -79,46 +42,13 @@ shift 2
|
||||
repodir="$tmpdir/repo"
|
||||
git clone "$repo_url" "$repodir"
|
||||
git -C "$repodir" fetch -q origin '+refs/pull/*:refs/remotes/origin/pr/*'
|
||||
errors=0
|
||||
cd "$repodir"
|
||||
git checkout -q "$new_tag"
|
||||
|
||||
for old_tag in "$@"; do
|
||||
mkdir "$tmpdir/api-old"
|
||||
mkdir "$tmpdir/api-new"
|
||||
|
||||
echo "Checking public API breakages from $old_tag to $new_tag"
|
||||
|
||||
build_and_do "$repodir" "$new_tag" "$tmpdir/api-new/"
|
||||
build_and_do "$repodir" "$old_tag" "$tmpdir/api-old/"
|
||||
|
||||
for f in "$tmpdir/api-new"/*; do
|
||||
f=$(basename "$f")
|
||||
report="$tmpdir/$f.report"
|
||||
if [[ ! -f "$tmpdir/api-old/$f" ]]; then
|
||||
echo "NOTICE: NEW MODULE $f"
|
||||
continue
|
||||
fi
|
||||
|
||||
echo -n "Checking $f... "
|
||||
swift api-digester -sdk "$sdk" -diagnose-sdk \
|
||||
--input-paths "$tmpdir/api-old/$f" -input-paths "$tmpdir/api-new/$f" 2>&1 \
|
||||
> "$report" 2>&1
|
||||
|
||||
if ! shasum "$report" | grep -q afd2a1b542b33273920d65821deddc653063c700; then
|
||||
echo ERROR
|
||||
echo >&2 "=============================="
|
||||
echo >&2 "ERROR: public API change in $f"
|
||||
echo >&2 "=============================="
|
||||
cat >&2 "$report"
|
||||
errors=$(( errors + 1 ))
|
||||
else
|
||||
echo OK
|
||||
fi
|
||||
done
|
||||
rm -rf "$tmpdir/api-new" "$tmpdir/api-old"
|
||||
swift package diagnose-api-breaking-changes "$old_tag"
|
||||
done
|
||||
|
||||
if [[ "$errors" == 0 ]]; then
|
||||
echo "OK, all seems good"
|
||||
fi
|
||||
echo done
|
||||
exit "$errors"
|
||||
@@ -17,7 +17,7 @@ set -eu
|
||||
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
function replace_acceptable_years() {
|
||||
# this needs to replace all acceptable forms with 'YEARS'
|
||||
sed -e 's/20[12][890]-20[12][190]/YEARS/' -e 's/2019/YEARS/' -e 's/2020/YEARS/' -e 's/2021/YEARS/'
|
||||
sed -e 's/20[12][890]-20[12][1290]/YEARS/' -e 's/2019/YEARS/' -e 's/2020/YEARS/' -e 's/2021/YEARS/'
|
||||
}
|
||||
|
||||
printf "=> Checking for unacceptable language... "
|
||||
@@ -85,7 +85,7 @@ find Sources/* Tests/* -name BoringSSL -type d | while IFS= read -r d; do
|
||||
done
|
||||
|
||||
printf "=> Checking #defines..."
|
||||
if grep '\.define("CRYPTO_IN_SWIFTPM_FORCE_BUILD_API")' Package.swift | grep -v "//" > /dev/null; then
|
||||
if grep 'development = true' Package.swift > /dev/null; then
|
||||
printf "\033[0;31mstill in development mode!\033[0m Comment out CRYPTO_IN_SWIFTPM_FORCE_BUILD_API.\n"
|
||||
exit 1
|
||||
else
|
||||
|
||||
@@ -271,7 +271,7 @@ echo "RENAMING header files"
|
||||
rmdir "include/openssl"
|
||||
|
||||
# Now change the imports from "<openssl/X> to "<CCryptoBoringSSL_X>", apply the same prefix to the 'boringssl_prefix_symbols' headers.
|
||||
find . -name "*.[ch]" -or -name "*.cc" -or -name "*.S" | xargs $sed -i -e 's+include <openssl/+include <CCryptoBoringSSL_+' -e 's+include <boringssl_prefix_symbols+include <CCryptoBoringSSL_boringssl_prefix_symbols+'
|
||||
find . -name "*.[ch]" -or -name "*.cc" -or -name "*.S" | xargs $sed -i -e 's+include <openssl/+include <CCryptoBoringSSL_+' -e 's+include <boringssl_prefix_symbols+include <CCryptoBoringSSL_boringssl_prefix_symbols+' -e 's+include "openssl/+include "CCryptoBoringSSL_+'
|
||||
|
||||
# Okay now we need to rename the headers adding the prefix "CCryptoBoringSSL_".
|
||||
pushd include
|
||||
|
||||
Reference in new issue
Block a user