mirror of
https://github.com/apple/swift-crypto
synced 2026-11-23 04:34:21 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bcd9208428 | ||
|
|
ddb07e896a | ||
|
|
3bea268b22 |
No files matched your search
@@ -37,6 +37,12 @@ if(BUILD_SHARED_LIBS)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE YES)
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL Darwin AND NOT CMAKE_CROSSCOMPILING)
|
||||
set(CMAKE_AR "/usr/bin/ar")
|
||||
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> crs <TARGET> <LINK_FLAGS> <OBJECTS>")
|
||||
set(CMAKE_RANLIB "/usr/bin/ranlib")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
|
||||
find_package(dispatch CONFIG)
|
||||
find_package(Foundation CONFIG)
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
// Sources/CCryptoBoringSSL directory. The source repository is at
|
||||
// https://boringssl.googlesource.com/boringssl.
|
||||
//
|
||||
// BoringSSL Commit: bb43a45d6de7375f3310511d37f040d1055f8a10
|
||||
// BoringSSL Commit: 04b3213d43492b6c9e0434d8e2a4530a9938f958
|
||||
|
||||
import PackageDescription
|
||||
|
||||
|
||||
-1
@@ -259,7 +259,6 @@ add_library(CCryptoBoringSSL STATIC
|
||||
"crypto/x509/x509_ext.c"
|
||||
"crypto/x509/x509_lu.c"
|
||||
"crypto/x509/x509_obj.c"
|
||||
"crypto/x509/x509_r2x.c"
|
||||
"crypto/x509/x509_req.c"
|
||||
"crypto/x509/x509_set.c"
|
||||
"crypto/x509/x509_trs.c"
|
||||
|
||||
@@ -175,7 +175,13 @@ void OPENSSL_cpuid_setup(void) {
|
||||
hwcap = crypto_get_arm_hwcap_from_cpuinfo(&cpuinfo);
|
||||
}
|
||||
|
||||
// Clear NEON support if known broken.
|
||||
// Clear NEON support if known broken. Note, if NEON is available statically,
|
||||
// the non-NEON code is dropped and this workaround is a no-op.
|
||||
//
|
||||
// TODO(davidben): The Android NDK now builds with NEON statically available
|
||||
// by default. Cronet still has some consumers that support NEON-less devices
|
||||
// (b/150371744). Get metrics on whether they still see this CPU and, if not,
|
||||
// remove this check entirely.
|
||||
g_has_broken_neon = crypto_cpuinfo_has_broken_neon(&cpuinfo);
|
||||
if (g_has_broken_neon) {
|
||||
hwcap &= ~HWCAP_NEON;
|
||||
@@ -186,7 +192,10 @@ void OPENSSL_cpuid_setup(void) {
|
||||
OPENSSL_armcap_P |= ARMV7_NEON;
|
||||
|
||||
// Some ARMv8 Android devices don't expose AT_HWCAP2. Fall back to
|
||||
// /proc/cpuinfo. See https://crbug.com/596156.
|
||||
// /proc/cpuinfo. See https://crbug.com/boringssl/46. As of February 2021,
|
||||
// this is now rare (see Chrome's Net.NeedsHWCAP2Workaround metric), but AES
|
||||
// and PMULL extensions are very useful, so we still carry the workaround
|
||||
// for now.
|
||||
unsigned long hwcap2 = 0;
|
||||
if (getauxval != NULL) {
|
||||
hwcap2 = getauxval(AT_HWCAP2);
|
||||
|
||||
@@ -22,15 +22,15 @@
|
||||
|
||||
extern uint32_t OPENSSL_armcap_P;
|
||||
|
||||
char CRYPTO_is_NEON_capable_at_runtime(void) {
|
||||
int CRYPTO_is_NEON_capable_at_runtime(void) {
|
||||
return (OPENSSL_armcap_P & ARMV7_NEON) != 0;
|
||||
}
|
||||
|
||||
int CRYPTO_is_ARMv8_AES_capable(void) {
|
||||
int CRYPTO_is_ARMv8_AES_capable_at_runtime(void) {
|
||||
return (OPENSSL_armcap_P & ARMV8_AES) != 0;
|
||||
}
|
||||
|
||||
int CRYPTO_is_ARMv8_PMULL_capable(void) {
|
||||
int CRYPTO_is_ARMv8_PMULL_capable_at_runtime(void) {
|
||||
return (OPENSSL_armcap_P & ARMV8_PMULL) != 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -192,47 +192,47 @@ const uint32_t kOpenSSLReasonValues[] = {
|
||||
0x283480b9,
|
||||
0x283500f7,
|
||||
0x28358c79,
|
||||
0x2c3230db,
|
||||
0x2c3230e6,
|
||||
0x2c3292ff,
|
||||
0x2c3330e9,
|
||||
0x2c33b0fb,
|
||||
0x2c34310f,
|
||||
0x2c34b121,
|
||||
0x2c35313c,
|
||||
0x2c35b14e,
|
||||
0x2c36317e,
|
||||
0x2c3330f4,
|
||||
0x2c33b106,
|
||||
0x2c34311a,
|
||||
0x2c34b12c,
|
||||
0x2c353147,
|
||||
0x2c35b159,
|
||||
0x2c363189,
|
||||
0x2c36833a,
|
||||
0x2c37318b,
|
||||
0x2c37b1b7,
|
||||
0x2c3831dc,
|
||||
0x2c38b1f3,
|
||||
0x2c393211,
|
||||
0x2c39b221,
|
||||
0x2c3a3233,
|
||||
0x2c3ab247,
|
||||
0x2c3b3258,
|
||||
0x2c3bb277,
|
||||
0x2c373196,
|
||||
0x2c37b1c2,
|
||||
0x2c3831e7,
|
||||
0x2c38b1fe,
|
||||
0x2c39321c,
|
||||
0x2c39b22c,
|
||||
0x2c3a323e,
|
||||
0x2c3ab252,
|
||||
0x2c3b3263,
|
||||
0x2c3bb282,
|
||||
0x2c3c1311,
|
||||
0x2c3c9327,
|
||||
0x2c3d328b,
|
||||
0x2c3d3296,
|
||||
0x2c3d9340,
|
||||
0x2c3e32a8,
|
||||
0x2c3eb2b6,
|
||||
0x2c3f32ce,
|
||||
0x2c3fb2e6,
|
||||
0x2c403310,
|
||||
0x2c3e32b3,
|
||||
0x2c3eb2c1,
|
||||
0x2c3f32d9,
|
||||
0x2c3fb2f1,
|
||||
0x2c40331b,
|
||||
0x2c409212,
|
||||
0x2c413321,
|
||||
0x2c41b334,
|
||||
0x2c41332c,
|
||||
0x2c41b33f,
|
||||
0x2c4211d8,
|
||||
0x2c42b345,
|
||||
0x2c42b350,
|
||||
0x2c43072f,
|
||||
0x2c43b269,
|
||||
0x2c4431ca,
|
||||
0x2c44b2f3,
|
||||
0x2c453161,
|
||||
0x2c45b19d,
|
||||
0x2c463201,
|
||||
0x2c43b274,
|
||||
0x2c4431d5,
|
||||
0x2c44b2fe,
|
||||
0x2c45316c,
|
||||
0x2c45b1a8,
|
||||
0x2c46320c,
|
||||
0x30320000,
|
||||
0x30328015,
|
||||
0x3033001f,
|
||||
@@ -431,185 +431,185 @@ const uint32_t kOpenSSLReasonValues[] = {
|
||||
0x4050206f,
|
||||
0x4050a083,
|
||||
0x405120b6,
|
||||
0x405220d3,
|
||||
0x4052a0f7,
|
||||
0x4053210f,
|
||||
0x4053a122,
|
||||
0x40542137,
|
||||
0x4054a15a,
|
||||
0x40552185,
|
||||
0x4055a1c2,
|
||||
0x405621cf,
|
||||
0x4056a1e8,
|
||||
0x40572200,
|
||||
0x4057a213,
|
||||
0x40582228,
|
||||
0x4058a24f,
|
||||
0x4059227e,
|
||||
0x4059a2ab,
|
||||
0x405a22bf,
|
||||
0x405aa2cf,
|
||||
0x405b22e7,
|
||||
0x405ba2f8,
|
||||
0x405c230b,
|
||||
0x405ca34a,
|
||||
0x405d2357,
|
||||
0x405da37c,
|
||||
0x405e23ba,
|
||||
0x405220c6,
|
||||
0x4052a0ea,
|
||||
0x40532102,
|
||||
0x4053a115,
|
||||
0x4054212a,
|
||||
0x4054a14d,
|
||||
0x40552178,
|
||||
0x4055a1b5,
|
||||
0x405621da,
|
||||
0x4056a1f3,
|
||||
0x4057220b,
|
||||
0x4057a21e,
|
||||
0x40582233,
|
||||
0x4058a25a,
|
||||
0x40592289,
|
||||
0x4059a2b6,
|
||||
0x405a22ca,
|
||||
0x405aa2da,
|
||||
0x405b22f2,
|
||||
0x405ba303,
|
||||
0x405c2316,
|
||||
0x405ca355,
|
||||
0x405d2362,
|
||||
0x405da387,
|
||||
0x405e23c5,
|
||||
0x405e8ac0,
|
||||
0x405f23db,
|
||||
0x405fa3e8,
|
||||
0x406023f6,
|
||||
0x4060a418,
|
||||
0x40612479,
|
||||
0x4061a4b1,
|
||||
0x406224c8,
|
||||
0x4062a4d9,
|
||||
0x40632526,
|
||||
0x4063a53b,
|
||||
0x40642552,
|
||||
0x4064a57e,
|
||||
0x40652599,
|
||||
0x4065a5b0,
|
||||
0x406625c8,
|
||||
0x4066a5f2,
|
||||
0x4067261d,
|
||||
0x4067a662,
|
||||
0x406826aa,
|
||||
0x4068a6cb,
|
||||
0x406926fd,
|
||||
0x4069a72b,
|
||||
0x406a274c,
|
||||
0x406aa76c,
|
||||
0x406b28f4,
|
||||
0x406ba917,
|
||||
0x406c292d,
|
||||
0x406cac1e,
|
||||
0x406d2c4d,
|
||||
0x406dac75,
|
||||
0x406e2ca3,
|
||||
0x406eacf0,
|
||||
0x406f2d49,
|
||||
0x406fad81,
|
||||
0x40702d94,
|
||||
0x4070adb1,
|
||||
0x405f23e6,
|
||||
0x405fa3f3,
|
||||
0x40602401,
|
||||
0x4060a423,
|
||||
0x40612484,
|
||||
0x4061a4bc,
|
||||
0x406224d3,
|
||||
0x4062a4e4,
|
||||
0x40632531,
|
||||
0x4063a546,
|
||||
0x4064255d,
|
||||
0x4064a589,
|
||||
0x406525a4,
|
||||
0x4065a5bb,
|
||||
0x406625d3,
|
||||
0x4066a5fd,
|
||||
0x40672628,
|
||||
0x4067a66d,
|
||||
0x406826b5,
|
||||
0x4068a6d6,
|
||||
0x40692708,
|
||||
0x4069a736,
|
||||
0x406a2757,
|
||||
0x406aa777,
|
||||
0x406b28ff,
|
||||
0x406ba922,
|
||||
0x406c2938,
|
||||
0x406cac29,
|
||||
0x406d2c58,
|
||||
0x406dac80,
|
||||
0x406e2cae,
|
||||
0x406eacfb,
|
||||
0x406f2d54,
|
||||
0x406fad8c,
|
||||
0x40702d9f,
|
||||
0x4070adbc,
|
||||
0x4071080f,
|
||||
0x4071adc3,
|
||||
0x40722dd6,
|
||||
0x4072ae0c,
|
||||
0x40732e24,
|
||||
0x4071adce,
|
||||
0x40722de1,
|
||||
0x4072ae17,
|
||||
0x40732e2f,
|
||||
0x40739511,
|
||||
0x40742e38,
|
||||
0x4074ae52,
|
||||
0x40752e63,
|
||||
0x4075ae77,
|
||||
0x40762e85,
|
||||
0x40742e43,
|
||||
0x4074ae5d,
|
||||
0x40752e6e,
|
||||
0x4075ae82,
|
||||
0x40762e90,
|
||||
0x407692d5,
|
||||
0x40772eaa,
|
||||
0x4077aecc,
|
||||
0x40782ee7,
|
||||
0x4078af20,
|
||||
0x40792f37,
|
||||
0x4079af4d,
|
||||
0x407a2f79,
|
||||
0x407aaf8c,
|
||||
0x407b2fa1,
|
||||
0x407bafb3,
|
||||
0x407c2fe4,
|
||||
0x407cafed,
|
||||
0x407d26e6,
|
||||
0x40772eb5,
|
||||
0x4077aed7,
|
||||
0x40782ef2,
|
||||
0x4078af2b,
|
||||
0x40792f42,
|
||||
0x4079af58,
|
||||
0x407a2f84,
|
||||
0x407aaf97,
|
||||
0x407b2fac,
|
||||
0x407bafbe,
|
||||
0x407c2fef,
|
||||
0x407caff8,
|
||||
0x407d26f1,
|
||||
0x407da028,
|
||||
0x407e2efc,
|
||||
0x407ea25f,
|
||||
0x407e2f07,
|
||||
0x407ea26a,
|
||||
0x407f1d86,
|
||||
0x407f9ed2,
|
||||
0x40801fe2,
|
||||
0x40809dae,
|
||||
0x408120e5,
|
||||
0x408120d8,
|
||||
0x40819fbc,
|
||||
0x40822c8e,
|
||||
0x40822c99,
|
||||
0x40829b17,
|
||||
0x4083223a,
|
||||
0x4083a563,
|
||||
0x40832245,
|
||||
0x4083a56e,
|
||||
0x40841dc2,
|
||||
0x4084a297,
|
||||
0x4085231c,
|
||||
0x4085a440,
|
||||
0x4086239c,
|
||||
0x4084a2a2,
|
||||
0x40852327,
|
||||
0x4085a44b,
|
||||
0x408623a7,
|
||||
0x4086a042,
|
||||
0x40872cd4,
|
||||
0x4087a48e,
|
||||
0x40872cdf,
|
||||
0x4087a499,
|
||||
0x40881b55,
|
||||
0x4088a675,
|
||||
0x4088a680,
|
||||
0x40891ba4,
|
||||
0x40899b31,
|
||||
0x408a2965,
|
||||
0x408a2970,
|
||||
0x408a9929,
|
||||
0x408b2fc8,
|
||||
0x408bad5e,
|
||||
0x408c232c,
|
||||
0x408b2fd3,
|
||||
0x408bad69,
|
||||
0x408c2337,
|
||||
0x408c9961,
|
||||
0x408d1e23,
|
||||
0x408d9df4,
|
||||
0x408e1f53,
|
||||
0x408ea1a2,
|
||||
0x408f2689,
|
||||
0x408fa45c,
|
||||
0x4090263e,
|
||||
0x4090a36e,
|
||||
0x4091294d,
|
||||
0x408ea195,
|
||||
0x408f2694,
|
||||
0x408fa467,
|
||||
0x40902649,
|
||||
0x4090a379,
|
||||
0x40912958,
|
||||
0x40919987,
|
||||
0x40921bf1,
|
||||
0x4092ad0f,
|
||||
0x40932def,
|
||||
0x4092ad1a,
|
||||
0x40932dfa,
|
||||
0x4093a053,
|
||||
0x40941dd6,
|
||||
0x4094a97e,
|
||||
0x409524ea,
|
||||
0x4095af59,
|
||||
0x40962cbb,
|
||||
0x4094a989,
|
||||
0x409524f5,
|
||||
0x4095af64,
|
||||
0x40962cc6,
|
||||
0x40969ffb,
|
||||
0x4097209e,
|
||||
0x40979fa2,
|
||||
0x40981c51,
|
||||
0x4098a4fe,
|
||||
0x40992d2b,
|
||||
0x4099a0c6,
|
||||
0x409a2168,
|
||||
0x4098a509,
|
||||
0x40992d36,
|
||||
0x4099a1c2,
|
||||
0x409a215b,
|
||||
0x409a9945,
|
||||
0x41f4281f,
|
||||
0x41f928b1,
|
||||
0x41fe27a4,
|
||||
0x41feaa5a,
|
||||
0x41ff2b6f,
|
||||
0x42032838,
|
||||
0x4208285a,
|
||||
0x4208a896,
|
||||
0x42092788,
|
||||
0x4209a8d0,
|
||||
0x420a27df,
|
||||
0x420aa7bf,
|
||||
0x420b27ff,
|
||||
0x420ba878,
|
||||
0x420c2b8b,
|
||||
0x420ca98e,
|
||||
0x420d2a41,
|
||||
0x420daa78,
|
||||
0x42122a92,
|
||||
0x42172b52,
|
||||
0x4217aad4,
|
||||
0x421c2af6,
|
||||
0x421f2ab1,
|
||||
0x42212c03,
|
||||
0x42262b35,
|
||||
0x422b2be1,
|
||||
0x422baa1c,
|
||||
0x422c2bc3,
|
||||
0x422ca9cf,
|
||||
0x422d29a8,
|
||||
0x422daba2,
|
||||
0x422e29fb,
|
||||
0x42302b11,
|
||||
0x41f4282a,
|
||||
0x41f928bc,
|
||||
0x41fe27af,
|
||||
0x41feaa65,
|
||||
0x41ff2b7a,
|
||||
0x42032843,
|
||||
0x42082865,
|
||||
0x4208a8a1,
|
||||
0x42092793,
|
||||
0x4209a8db,
|
||||
0x420a27ea,
|
||||
0x420aa7ca,
|
||||
0x420b280a,
|
||||
0x420ba883,
|
||||
0x420c2b96,
|
||||
0x420ca999,
|
||||
0x420d2a4c,
|
||||
0x420daa83,
|
||||
0x42122a9d,
|
||||
0x42172b5d,
|
||||
0x4217aadf,
|
||||
0x421c2b01,
|
||||
0x421f2abc,
|
||||
0x42212c0e,
|
||||
0x42262b40,
|
||||
0x422b2bec,
|
||||
0x422baa27,
|
||||
0x422c2bce,
|
||||
0x422ca9da,
|
||||
0x422d29b3,
|
||||
0x422dabad,
|
||||
0x422e2a06,
|
||||
0x42302b1c,
|
||||
0x4432073a,
|
||||
0x44328749,
|
||||
0x44330755,
|
||||
@@ -664,69 +664,69 @@ const uint32_t kOpenSSLReasonValues[] = {
|
||||
0x4c41156e,
|
||||
0x4c4193f1,
|
||||
0x4c42155a,
|
||||
0x50323357,
|
||||
0x5032b366,
|
||||
0x50333371,
|
||||
0x5033b381,
|
||||
0x5034339a,
|
||||
0x5034b3b4,
|
||||
0x503533c2,
|
||||
0x5035b3d8,
|
||||
0x503633ea,
|
||||
0x5036b400,
|
||||
0x50373419,
|
||||
0x5037b42c,
|
||||
0x50383444,
|
||||
0x5038b455,
|
||||
0x5039346a,
|
||||
0x5039b47e,
|
||||
0x503a349e,
|
||||
0x503ab4b4,
|
||||
0x503b34cc,
|
||||
0x503bb4de,
|
||||
0x503c34fa,
|
||||
0x503cb511,
|
||||
0x503d352a,
|
||||
0x503db540,
|
||||
0x503e354d,
|
||||
0x503eb563,
|
||||
0x503f3575,
|
||||
0x50323362,
|
||||
0x5032b371,
|
||||
0x5033337c,
|
||||
0x5033b38c,
|
||||
0x503433a5,
|
||||
0x5034b3bf,
|
||||
0x503533cd,
|
||||
0x5035b3e3,
|
||||
0x503633f5,
|
||||
0x5036b40b,
|
||||
0x50373424,
|
||||
0x5037b437,
|
||||
0x5038344f,
|
||||
0x5038b460,
|
||||
0x50393475,
|
||||
0x5039b489,
|
||||
0x503a34a9,
|
||||
0x503ab4bf,
|
||||
0x503b34d7,
|
||||
0x503bb4e9,
|
||||
0x503c3505,
|
||||
0x503cb51c,
|
||||
0x503d3535,
|
||||
0x503db54b,
|
||||
0x503e3558,
|
||||
0x503eb56e,
|
||||
0x503f3580,
|
||||
0x503f8388,
|
||||
0x50403588,
|
||||
0x5040b598,
|
||||
0x504135b2,
|
||||
0x5041b5c1,
|
||||
0x504235db,
|
||||
0x5042b5f8,
|
||||
0x50433608,
|
||||
0x5043b618,
|
||||
0x50443627,
|
||||
0x50403593,
|
||||
0x5040b5a3,
|
||||
0x504135bd,
|
||||
0x5041b5cc,
|
||||
0x504235e6,
|
||||
0x5042b603,
|
||||
0x50433613,
|
||||
0x5043b623,
|
||||
0x50443632,
|
||||
0x5044843e,
|
||||
0x5045363b,
|
||||
0x5045b659,
|
||||
0x5046366c,
|
||||
0x5046b682,
|
||||
0x50473694,
|
||||
0x5047b6a9,
|
||||
0x504836cf,
|
||||
0x5048b6dd,
|
||||
0x504936f0,
|
||||
0x5049b705,
|
||||
0x504a371b,
|
||||
0x504ab72b,
|
||||
0x504b374b,
|
||||
0x504bb75e,
|
||||
0x504c3781,
|
||||
0x504cb7af,
|
||||
0x504d37c1,
|
||||
0x504db7de,
|
||||
0x504e37f9,
|
||||
0x504eb815,
|
||||
0x504f3827,
|
||||
0x504fb83e,
|
||||
0x5050384d,
|
||||
0x50453646,
|
||||
0x5045b664,
|
||||
0x50463677,
|
||||
0x5046b68d,
|
||||
0x5047369f,
|
||||
0x5047b6b4,
|
||||
0x504836da,
|
||||
0x5048b6e8,
|
||||
0x504936fb,
|
||||
0x5049b710,
|
||||
0x504a3726,
|
||||
0x504ab736,
|
||||
0x504b3756,
|
||||
0x504bb769,
|
||||
0x504c378c,
|
||||
0x504cb7ba,
|
||||
0x504d37cc,
|
||||
0x504db7e9,
|
||||
0x504e3804,
|
||||
0x504eb820,
|
||||
0x504f3832,
|
||||
0x504fb849,
|
||||
0x50503858,
|
||||
0x505086fe,
|
||||
0x50513860,
|
||||
0x5051386b,
|
||||
0x58320f72,
|
||||
0x68320f34,
|
||||
0x68328c8c,
|
||||
@@ -770,19 +770,19 @@ const uint32_t kOpenSSLReasonValues[] = {
|
||||
0x7c3211ee,
|
||||
0x80321404,
|
||||
0x80328090,
|
||||
0x803330aa,
|
||||
0x803330b5,
|
||||
0x803380b9,
|
||||
0x803430b9,
|
||||
0x8034b021,
|
||||
0x8035303f,
|
||||
0x8035b0cd,
|
||||
0x80363081,
|
||||
0x8036b030,
|
||||
0x80373073,
|
||||
0x8037b00e,
|
||||
0x80383094,
|
||||
0x8038b050,
|
||||
0x80393065,
|
||||
0x803430c4,
|
||||
0x8034b02c,
|
||||
0x8035304a,
|
||||
0x8035b0d8,
|
||||
0x8036308c,
|
||||
0x8036b03b,
|
||||
0x8037307e,
|
||||
0x8037b019,
|
||||
0x8038309f,
|
||||
0x8038b05b,
|
||||
0x80393070,
|
||||
};
|
||||
|
||||
const size_t kOpenSSLReasonValuesLen = sizeof(kOpenSSLReasonValues) / sizeof(kOpenSSLReasonValues[0]);
|
||||
@@ -1201,7 +1201,6 @@ const char kOpenSSLReasonStringData[] =
|
||||
"INVALID_TICKET_KEYS_LENGTH\0"
|
||||
"KEY_USAGE_BIT_INCORRECT\0"
|
||||
"LENGTH_MISMATCH\0"
|
||||
"MISSING_ALPN\0"
|
||||
"MISSING_EXTENSION\0"
|
||||
"MISSING_KEY_SHARE\0"
|
||||
"MISSING_RSA_CERTIFICATE\0"
|
||||
@@ -1213,6 +1212,7 @@ const char kOpenSSLReasonStringData[] =
|
||||
"NEGOTIATED_BOTH_NPN_AND_ALPN\0"
|
||||
"NEGOTIATED_TB_WITHOUT_EMS_OR_RI\0"
|
||||
"NESTED_GROUP\0"
|
||||
"NO_APPLICATION_PROTOCOL\0"
|
||||
"NO_CERTIFICATES_RETURNED\0"
|
||||
"NO_CERTIFICATE_ASSIGNED\0"
|
||||
"NO_CERTIFICATE_SET\0"
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
#include <CCryptoBoringSSL_cipher.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <CCryptoBoringSSL_err.h>
|
||||
@@ -224,7 +225,6 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
|
||||
|
||||
ctx->buf_len = 0;
|
||||
ctx->final_used = 0;
|
||||
ctx->block_mask = ctx->cipher->block_size - 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -238,16 +238,31 @@ int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
|
||||
return EVP_CipherInit_ex(ctx, cipher, impl, key, iv, 0);
|
||||
}
|
||||
|
||||
// block_remainder returns the number of bytes to remove from |len| to get a
|
||||
// multiple of |ctx|'s block size.
|
||||
static int block_remainder(const EVP_CIPHER_CTX *ctx, int len) {
|
||||
// |block_size| must be a power of two.
|
||||
assert(ctx->cipher->block_size != 0);
|
||||
assert((ctx->cipher->block_size & (ctx->cipher->block_size - 1)) == 0);
|
||||
return len & (ctx->cipher->block_size - 1);
|
||||
}
|
||||
|
||||
int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, uint8_t *out, int *out_len,
|
||||
const uint8_t *in, int in_len) {
|
||||
int i, j, bl;
|
||||
// Ciphers that use blocks may write up to |bl| extra bytes. Ensure the output
|
||||
// does not overflow |*out_len|.
|
||||
int bl = ctx->cipher->block_size;
|
||||
if (bl > 1 && in_len > INT_MAX - bl) {
|
||||
OPENSSL_PUT_ERROR(CIPHER, ERR_R_OVERFLOW);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) {
|
||||
i = ctx->cipher->cipher(ctx, out, in, in_len);
|
||||
if (i < 0) {
|
||||
int ret = ctx->cipher->cipher(ctx, out, in, in_len);
|
||||
if (ret < 0) {
|
||||
return 0;
|
||||
} else {
|
||||
*out_len = i;
|
||||
*out_len = ret;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -257,7 +272,7 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, uint8_t *out, int *out_len,
|
||||
return in_len == 0;
|
||||
}
|
||||
|
||||
if (ctx->buf_len == 0 && (in_len & ctx->block_mask) == 0) {
|
||||
if (ctx->buf_len == 0 && block_remainder(ctx, in_len) == 0) {
|
||||
if (ctx->cipher->cipher(ctx, out, in, in_len)) {
|
||||
*out_len = in_len;
|
||||
return 1;
|
||||
@@ -267,8 +282,7 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, uint8_t *out, int *out_len,
|
||||
}
|
||||
}
|
||||
|
||||
i = ctx->buf_len;
|
||||
bl = ctx->cipher->block_size;
|
||||
int i = ctx->buf_len;
|
||||
assert(bl <= (int)sizeof(ctx->buf));
|
||||
if (i != 0) {
|
||||
if (bl - i > in_len) {
|
||||
@@ -277,7 +291,7 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, uint8_t *out, int *out_len,
|
||||
*out_len = 0;
|
||||
return 1;
|
||||
} else {
|
||||
j = bl - i;
|
||||
int j = bl - i;
|
||||
OPENSSL_memcpy(&ctx->buf[i], in, j);
|
||||
if (!ctx->cipher->cipher(ctx, out, ctx->buf, bl)) {
|
||||
return 0;
|
||||
@@ -291,7 +305,7 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, uint8_t *out, int *out_len,
|
||||
*out_len = 0;
|
||||
}
|
||||
|
||||
i = in_len & ctx->block_mask;
|
||||
i = block_remainder(ctx, in_len);
|
||||
in_len -= i;
|
||||
if (in_len > 0) {
|
||||
if (!ctx->cipher->cipher(ctx, out, in, in_len)) {
|
||||
@@ -353,8 +367,13 @@ int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, uint8_t *out, int *out_len) {
|
||||
|
||||
int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, uint8_t *out, int *out_len,
|
||||
const uint8_t *in, int in_len) {
|
||||
int fix_len;
|
||||
unsigned int b;
|
||||
// Ciphers that use blocks may write up to |bl| extra bytes. Ensure the output
|
||||
// does not overflow |*out_len|.
|
||||
unsigned int b = ctx->cipher->block_size;
|
||||
if (b > 1 && in_len > INT_MAX - (int)b) {
|
||||
OPENSSL_PUT_ERROR(CIPHER, ERR_R_OVERFLOW);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) {
|
||||
int r = ctx->cipher->cipher(ctx, out, in, in_len);
|
||||
@@ -376,15 +395,12 @@ int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, uint8_t *out, int *out_len,
|
||||
return EVP_EncryptUpdate(ctx, out, out_len, in, in_len);
|
||||
}
|
||||
|
||||
b = ctx->cipher->block_size;
|
||||
assert(b <= sizeof(ctx->final));
|
||||
|
||||
int fix_len = 0;
|
||||
if (ctx->final_used) {
|
||||
OPENSSL_memcpy(out, ctx->final, b);
|
||||
out += b;
|
||||
fix_len = 1;
|
||||
} else {
|
||||
fix_len = 0;
|
||||
}
|
||||
|
||||
if (!EVP_EncryptUpdate(ctx, out, out_len, in, in_len)) {
|
||||
|
||||
@@ -65,6 +65,7 @@
|
||||
#include <CCryptoBoringSSL_thread.h>
|
||||
|
||||
#include "../../internal.h"
|
||||
#include "../bn/internal.h"
|
||||
|
||||
|
||||
#define OPENSSL_DH_MAX_MODULUS_BITS 10000
|
||||
@@ -403,3 +404,53 @@ int DH_up_ref(DH *dh) {
|
||||
CRYPTO_refcount_inc(&dh->references);
|
||||
return 1;
|
||||
}
|
||||
|
||||
DH *DH_get_rfc7919_2048(void) {
|
||||
// This is the prime from https://tools.ietf.org/html/rfc7919#appendix-A.1,
|
||||
// which is specifically approved for FIPS in appendix D of SP 800-56Ar3.
|
||||
static const BN_ULONG kFFDHE2048Data[] = {
|
||||
TOBN(0xffffffff, 0xffffffff), TOBN(0x886b4238, 0x61285c97),
|
||||
TOBN(0xc6f34a26, 0xc1b2effa), TOBN(0xc58ef183, 0x7d1683b2),
|
||||
TOBN(0x3bb5fcbc, 0x2ec22005), TOBN(0xc3fe3b1b, 0x4c6fad73),
|
||||
TOBN(0x8e4f1232, 0xeef28183), TOBN(0x9172fe9c, 0xe98583ff),
|
||||
TOBN(0xc03404cd, 0x28342f61), TOBN(0x9e02fce1, 0xcdf7e2ec),
|
||||
TOBN(0x0b07a7c8, 0xee0a6d70), TOBN(0xae56ede7, 0x6372bb19),
|
||||
TOBN(0x1d4f42a3, 0xde394df4), TOBN(0xb96adab7, 0x60d7f468),
|
||||
TOBN(0xd108a94b, 0xb2c8e3fb), TOBN(0xbc0ab182, 0xb324fb61),
|
||||
TOBN(0x30acca4f, 0x483a797a), TOBN(0x1df158a1, 0x36ade735),
|
||||
TOBN(0xe2a689da, 0xf3efe872), TOBN(0x984f0c70, 0xe0e68b77),
|
||||
TOBN(0xb557135e, 0x7f57c935), TOBN(0x85636555, 0x3ded1af3),
|
||||
TOBN(0x2433f51f, 0x5f066ed0), TOBN(0xd3df1ed5, 0xd5fd6561),
|
||||
TOBN(0xf681b202, 0xaec4617a), TOBN(0x7d2fe363, 0x630c75d8),
|
||||
TOBN(0xcc939dce, 0x249b3ef9), TOBN(0xa9e13641, 0x146433fb),
|
||||
TOBN(0xd8b9c583, 0xce2d3695), TOBN(0xafdc5620, 0x273d3cf1),
|
||||
TOBN(0xadf85458, 0xa2bb4a9a), TOBN(0xffffffff, 0xffffffff),
|
||||
};
|
||||
|
||||
BIGNUM *const ffdhe2048_p = BN_new();
|
||||
BIGNUM *const ffdhe2048_q = BN_new();
|
||||
BIGNUM *const ffdhe2048_g = BN_new();
|
||||
DH *const dh = DH_new();
|
||||
|
||||
if (!ffdhe2048_p || !ffdhe2048_q || !ffdhe2048_g || !dh) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
bn_set_static_words(ffdhe2048_p, kFFDHE2048Data,
|
||||
OPENSSL_ARRAY_SIZE(kFFDHE2048Data));
|
||||
|
||||
if (!BN_rshift1(ffdhe2048_q, ffdhe2048_p) ||
|
||||
!BN_set_word(ffdhe2048_g, 2) ||
|
||||
!DH_set0_pqg(dh, ffdhe2048_p, ffdhe2048_q, ffdhe2048_g)) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
return dh;
|
||||
|
||||
err:
|
||||
BN_free(ffdhe2048_p);
|
||||
BN_free(ffdhe2048_q);
|
||||
BN_free(ffdhe2048_g);
|
||||
DH_free(dh);
|
||||
return NULL;
|
||||
}
|
||||
@@ -1232,6 +1232,10 @@ void ec_set_to_safe_point(const EC_GROUP *group, EC_RAW_POINT *out) {
|
||||
|
||||
void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag) {}
|
||||
|
||||
int EC_GROUP_get_asn1_flag(const EC_GROUP *group) {
|
||||
return OPENSSL_EC_NAMED_CURVE;
|
||||
}
|
||||
|
||||
const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group) {
|
||||
// This function exists purely to give callers a way to call
|
||||
// |EC_METHOD_get_field_type|. cryptography.io crashes if |EC_GROUP_method_of|
|
||||
|
||||
@@ -171,7 +171,6 @@ void EC_KEY_free(EC_KEY *r) {
|
||||
EC_GROUP_free(r->group);
|
||||
EC_POINT_free(r->pub_key);
|
||||
ec_wrapped_scalar_free(r->priv_key);
|
||||
BN_free(r->fixed_k);
|
||||
|
||||
CRYPTO_free_ex_data(g_ec_ex_data_class_bss_get(), r, &r->ex_data);
|
||||
|
||||
|
||||
@@ -729,10 +729,6 @@ struct ec_key_st {
|
||||
EC_POINT *pub_key;
|
||||
EC_WRAPPED_SCALAR *priv_key;
|
||||
|
||||
// fixed_k may contain a specific value of 'k', to be used in ECDSA signing.
|
||||
// This is only for the FIPS power-on tests.
|
||||
BIGNUM *fixed_k;
|
||||
|
||||
unsigned int enc_flag;
|
||||
point_conversion_form_t conv_form;
|
||||
|
||||
|
||||
@@ -61,9 +61,10 @@
|
||||
#include <CCryptoBoringSSL_sha.h>
|
||||
#include <CCryptoBoringSSL_type_check.h>
|
||||
|
||||
#include "../../internal.h"
|
||||
#include "../bn/internal.h"
|
||||
#include "../ec/internal.h"
|
||||
#include "../../internal.h"
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
// digest_to_scalar interprets |digest_len| bytes from |digest| as a scalar for
|
||||
@@ -198,68 +199,104 @@ int ECDSA_do_verify(const uint8_t *digest, size_t digest_len,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ecdsa_sign_setup(const EC_KEY *eckey, EC_SCALAR *out_kinv_mont,
|
||||
EC_SCALAR *out_r, const uint8_t *digest,
|
||||
size_t digest_len, const EC_SCALAR *priv_key) {
|
||||
static ECDSA_SIG *ecdsa_sign_impl(const EC_GROUP *group, int *out_retry,
|
||||
const EC_SCALAR *priv_key, const EC_SCALAR *k,
|
||||
const uint8_t *digest, size_t digest_len) {
|
||||
*out_retry = 0;
|
||||
|
||||
// Check that the size of the group order is FIPS compliant (FIPS 186-4
|
||||
// B.5.2).
|
||||
const EC_GROUP *group = EC_KEY_get0_group(eckey);
|
||||
const BIGNUM *order = EC_GROUP_get0_order(group);
|
||||
if (BN_num_bits(order) < 160) {
|
||||
OPENSSL_PUT_ERROR(ECDSA, EC_R_INVALID_GROUP_ORDER);
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int ret = 0;
|
||||
EC_SCALAR k;
|
||||
// Compute r, the x-coordinate of k * generator.
|
||||
EC_RAW_POINT tmp_point;
|
||||
do {
|
||||
// Include the private key and message digest in the k generation.
|
||||
if (eckey->fixed_k != NULL) {
|
||||
if (!ec_bignum_to_scalar(group, &k, eckey->fixed_k)) {
|
||||
goto err;
|
||||
}
|
||||
if (ec_scalar_is_zero(group, &k)) {
|
||||
OPENSSL_PUT_ERROR(ECDSA, ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
} else {
|
||||
// Pass a SHA512 hash of the private key and digest as additional data
|
||||
// into the RBG. This is a hardening measure against entropy failure.
|
||||
OPENSSL_STATIC_ASSERT(SHA512_DIGEST_LENGTH >= 32,
|
||||
"additional_data is too large for SHA-512");
|
||||
SHA512_CTX sha;
|
||||
uint8_t additional_data[SHA512_DIGEST_LENGTH];
|
||||
SHA512_Init(&sha);
|
||||
SHA512_Update(&sha, priv_key->words, order->width * sizeof(BN_ULONG));
|
||||
SHA512_Update(&sha, digest, digest_len);
|
||||
SHA512_Final(additional_data, &sha);
|
||||
if (!ec_random_nonzero_scalar(group, &k, additional_data)) {
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
EC_SCALAR r;
|
||||
if (!ec_point_mul_scalar_base(group, &tmp_point, k) ||
|
||||
!ec_get_x_coordinate_as_scalar(group, &r, &tmp_point)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Compute k^-1 in the Montgomery domain. This is |ec_scalar_to_montgomery|
|
||||
// followed by |ec_scalar_inv0_montgomery|, but |ec_scalar_inv0_montgomery|
|
||||
// followed by |ec_scalar_from_montgomery| is equivalent and slightly more
|
||||
// efficient. Note k is non-zero, so the inverse must exist.
|
||||
ec_scalar_inv0_montgomery(group, out_kinv_mont, &k);
|
||||
ec_scalar_from_montgomery(group, out_kinv_mont, out_kinv_mont);
|
||||
if (ec_scalar_is_zero(group, &r)) {
|
||||
*out_retry = 1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Compute r, the x-coordinate of generator * k.
|
||||
if (!ec_point_mul_scalar_base(group, &tmp_point, &k) ||
|
||||
!ec_get_x_coordinate_as_scalar(group, out_r, &tmp_point)) {
|
||||
goto err;
|
||||
}
|
||||
} while (ec_scalar_is_zero(group, out_r));
|
||||
// s = priv_key * r. Note if only one parameter is in the Montgomery domain,
|
||||
// |ec_scalar_mod_mul_montgomery| will compute the answer in the normal
|
||||
// domain.
|
||||
EC_SCALAR s;
|
||||
ec_scalar_to_montgomery(group, &s, &r);
|
||||
ec_scalar_mul_montgomery(group, &s, priv_key, &s);
|
||||
|
||||
ret = 1;
|
||||
// s = m + priv_key * r.
|
||||
EC_SCALAR tmp;
|
||||
digest_to_scalar(group, &tmp, digest, digest_len);
|
||||
ec_scalar_add(group, &s, &s, &tmp);
|
||||
|
||||
err:
|
||||
OPENSSL_cleanse(&k, sizeof(k));
|
||||
// s = k^-1 * (m + priv_key * r). First, we compute k^-1 in the Montgomery
|
||||
// domain. This is |ec_scalar_to_montgomery| followed by
|
||||
// |ec_scalar_inv0_montgomery|, but |ec_scalar_inv0_montgomery| followed by
|
||||
// |ec_scalar_from_montgomery| is equivalent and slightly more efficient.
|
||||
// Then, as above, only one parameter is in the Montgomery domain, so the
|
||||
// result is in the normal domain. Finally, note k is non-zero (or computing r
|
||||
// would fail), so the inverse must exist.
|
||||
ec_scalar_inv0_montgomery(group, &tmp, k); // tmp = k^-1 R^2
|
||||
ec_scalar_from_montgomery(group, &tmp, &tmp); // tmp = k^-1 R
|
||||
ec_scalar_mul_montgomery(group, &s, &s, &tmp);
|
||||
if (ec_scalar_is_zero(group, &s)) {
|
||||
*out_retry = 1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ECDSA_SIG *ret = ECDSA_SIG_new();
|
||||
if (ret == NULL || //
|
||||
!bn_set_words(ret->r, r.words, order->width) ||
|
||||
!bn_set_words(ret->s, s.words, order->width)) {
|
||||
ECDSA_SIG_free(ret);
|
||||
return NULL;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
ECDSA_SIG *ecdsa_sign_with_nonce_for_known_answer_test(const uint8_t *digest,
|
||||
size_t digest_len,
|
||||
const EC_KEY *eckey,
|
||||
const uint8_t *nonce,
|
||||
size_t nonce_len) {
|
||||
if (eckey->ecdsa_meth && eckey->ecdsa_meth->sign) {
|
||||
OPENSSL_PUT_ERROR(ECDSA, ECDSA_R_NOT_IMPLEMENTED);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const EC_GROUP *group = EC_KEY_get0_group(eckey);
|
||||
if (group == NULL || eckey->priv_key == NULL) {
|
||||
OPENSSL_PUT_ERROR(ECDSA, ERR_R_PASSED_NULL_PARAMETER);
|
||||
return NULL;
|
||||
}
|
||||
const EC_SCALAR *priv_key = &eckey->priv_key->scalar;
|
||||
|
||||
EC_SCALAR k;
|
||||
if (!ec_scalar_from_bytes(group, &k, nonce, nonce_len)) {
|
||||
return NULL;
|
||||
}
|
||||
int retry_ignored;
|
||||
return ecdsa_sign_impl(group, &retry_ignored, priv_key, &k, digest,
|
||||
digest_len);
|
||||
}
|
||||
|
||||
// This function is only exported for testing and is not called in production
|
||||
// code.
|
||||
ECDSA_SIG *ECDSA_sign_with_nonce_and_leak_private_key_for_testing(
|
||||
const uint8_t *digest, size_t digest_len, const EC_KEY *eckey,
|
||||
const uint8_t *nonce, size_t nonce_len) {
|
||||
return ecdsa_sign_with_nonce_for_known_answer_test(digest, digest_len, eckey,
|
||||
nonce, nonce_len);
|
||||
}
|
||||
|
||||
ECDSA_SIG *ECDSA_do_sign(const uint8_t *digest, size_t digest_len,
|
||||
const EC_KEY *eckey) {
|
||||
if (eckey->ecdsa_meth && eckey->ecdsa_meth->sign) {
|
||||
@@ -275,54 +312,28 @@ ECDSA_SIG *ECDSA_do_sign(const uint8_t *digest, size_t digest_len,
|
||||
const BIGNUM *order = EC_GROUP_get0_order(group);
|
||||
const EC_SCALAR *priv_key = &eckey->priv_key->scalar;
|
||||
|
||||
int ok = 0;
|
||||
ECDSA_SIG *ret = ECDSA_SIG_new();
|
||||
EC_SCALAR kinv_mont, r_mont, s, m, tmp;
|
||||
if (ret == NULL) {
|
||||
OPENSSL_PUT_ERROR(ECDSA, ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
// Pass a SHA512 hash of the private key and digest as additional data
|
||||
// into the RBG. This is a hardening measure against entropy failure.
|
||||
OPENSSL_STATIC_ASSERT(SHA512_DIGEST_LENGTH >= 32,
|
||||
"additional_data is too large for SHA-512");
|
||||
SHA512_CTX sha;
|
||||
uint8_t additional_data[SHA512_DIGEST_LENGTH];
|
||||
SHA512_Init(&sha);
|
||||
SHA512_Update(&sha, priv_key->words, order->width * sizeof(BN_ULONG));
|
||||
SHA512_Update(&sha, digest, digest_len);
|
||||
SHA512_Final(additional_data, &sha);
|
||||
|
||||
digest_to_scalar(group, &m, digest, digest_len);
|
||||
for (;;) {
|
||||
if (!ecdsa_sign_setup(eckey, &kinv_mont, &r_mont, digest, digest_len,
|
||||
priv_key) ||
|
||||
!bn_set_words(ret->r, r_mont.words, order->width)) {
|
||||
goto err;
|
||||
EC_SCALAR k;
|
||||
if (!ec_random_nonzero_scalar(group, &k, additional_data)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Compute priv_key * r (mod order). Note if only one parameter is in the
|
||||
// Montgomery domain, |ec_scalar_mod_mul_montgomery| will compute the answer
|
||||
// in the normal domain.
|
||||
ec_scalar_to_montgomery(group, &r_mont, &r_mont);
|
||||
ec_scalar_mul_montgomery(group, &s, priv_key, &r_mont);
|
||||
|
||||
// Compute tmp = m + priv_key * r.
|
||||
ec_scalar_add(group, &tmp, &m, &s);
|
||||
|
||||
// Finally, multiply s by k^-1. That was retained in Montgomery form, so the
|
||||
// same technique as the previous multiplication works.
|
||||
ec_scalar_mul_montgomery(group, &s, &tmp, &kinv_mont);
|
||||
if (!bn_set_words(ret->s, s.words, order->width)) {
|
||||
goto err;
|
||||
}
|
||||
if (!BN_is_zero(ret->s)) {
|
||||
// s != 0 => we have a valid signature
|
||||
break;
|
||||
int retry;
|
||||
ECDSA_SIG *sig =
|
||||
ecdsa_sign_impl(group, &retry, priv_key, &k, digest, digest_len);
|
||||
if (sig != NULL || !retry) {
|
||||
return sig;
|
||||
}
|
||||
}
|
||||
|
||||
ok = 1;
|
||||
|
||||
err:
|
||||
if (!ok) {
|
||||
ECDSA_SIG_free(ret);
|
||||
ret = NULL;
|
||||
}
|
||||
OPENSSL_cleanse(&kinv_mont, sizeof(kinv_mont));
|
||||
OPENSSL_cleanse(&r_mont, sizeof(r_mont));
|
||||
OPENSSL_cleanse(&s, sizeof(s));
|
||||
OPENSSL_cleanse(&tmp, sizeof(tmp));
|
||||
OPENSSL_cleanse(&m, sizeof(m));
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/* Copyright (c) 2021, Google Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
||||
|
||||
#ifndef OPENSSL_HEADER_CRYPTO_FIPSMODULE_ECDSA_INTERNAL_H
|
||||
#define OPENSSL_HEADER_CRYPTO_FIPSMODULE_ECDSA_INTERNAL_H
|
||||
|
||||
#include <CCryptoBoringSSL_base.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
// ecdsa_sign_with_nonce_for_known_answer_test behaves like |ECDSA_do_sign| but
|
||||
// takes a fixed nonce. This function is used as part of known-answer tests in
|
||||
// the FIPS module.
|
||||
ECDSA_SIG *ecdsa_sign_with_nonce_for_known_answer_test(const uint8_t *digest,
|
||||
size_t digest_len,
|
||||
const EC_KEY *eckey,
|
||||
const uint8_t *nonce,
|
||||
size_t nonce_len);
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // OPENSSL_HEADER_CRYPTO_FIPSMODULE_ECDSA_INTERNAL_H
|
||||
@@ -83,16 +83,18 @@ struct rand_thread_state {
|
||||
// called when the whole process is exiting.
|
||||
DEFINE_BSS_GET(struct rand_thread_state *, thread_states_list);
|
||||
DEFINE_STATIC_MUTEX(thread_states_list_lock);
|
||||
DEFINE_STATIC_MUTEX(state_clear_all_lock);
|
||||
|
||||
static void rand_thread_state_clear_all(void) __attribute__((destructor));
|
||||
static void rand_thread_state_clear_all(void) {
|
||||
CRYPTO_STATIC_MUTEX_lock_write(thread_states_list_lock_bss_get());
|
||||
CRYPTO_STATIC_MUTEX_lock_write(state_clear_all_lock_bss_get());
|
||||
for (struct rand_thread_state *cur = *thread_states_list_bss_get();
|
||||
cur != NULL; cur = cur->next) {
|
||||
CTR_DRBG_clear(&cur->drbg);
|
||||
}
|
||||
// |thread_states_list_lock is deliberately left locked so that any threads
|
||||
// that are still running will hang if they try to call |RAND_bytes|.
|
||||
// The locks are deliberately left locked so that any threads that are still
|
||||
// running will hang if they try to call |RAND_bytes|.
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -415,7 +417,7 @@ void RAND_bytes_with_additional_data(uint8_t *out, size_t out_len,
|
||||
// bug on ppc64le. glibc may implement pthread locks by wrapping user code
|
||||
// in a hardware transaction, but, on some older versions of glibc and the
|
||||
// kernel, syscalls made with |syscall| did not abort the transaction.
|
||||
CRYPTO_STATIC_MUTEX_lock_read(thread_states_list_lock_bss_get());
|
||||
CRYPTO_STATIC_MUTEX_lock_read(state_clear_all_lock_bss_get());
|
||||
#endif
|
||||
if (!CTR_DRBG_reseed(&state->drbg, seed, NULL, 0)) {
|
||||
abort();
|
||||
@@ -424,7 +426,7 @@ void RAND_bytes_with_additional_data(uint8_t *out, size_t out_len,
|
||||
state->fork_generation = fork_generation;
|
||||
} else {
|
||||
#if defined(BORINGSSL_FIPS)
|
||||
CRYPTO_STATIC_MUTEX_lock_read(thread_states_list_lock_bss_get());
|
||||
CRYPTO_STATIC_MUTEX_lock_read(state_clear_all_lock_bss_get());
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -453,7 +455,7 @@ void RAND_bytes_with_additional_data(uint8_t *out, size_t out_len,
|
||||
}
|
||||
|
||||
#if defined(BORINGSSL_FIPS)
|
||||
CRYPTO_STATIC_MUTEX_unlock_read(thread_states_list_lock_bss_get());
|
||||
CRYPTO_STATIC_MUTEX_unlock_read(state_clear_all_lock_bss_get());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
#include "../../internal.h"
|
||||
#include "../ec/internal.h"
|
||||
#include "../ecdsa/internal.h"
|
||||
#include "../rand/internal.h"
|
||||
#include "../tls/internal.h"
|
||||
|
||||
@@ -248,26 +249,15 @@ static EC_KEY *self_test_ecdsa_key(void) {
|
||||
}
|
||||
|
||||
static DH *self_test_dh(void) {
|
||||
// This is the prime from https://tools.ietf.org/html/rfc7919#appendix-A.1,
|
||||
// which is specifically approved for FIPS in appendix D of SP 800-56Ar3.
|
||||
static const BN_ULONG kFFDHE2048Data[] = {
|
||||
TOBN(0xffffffff, 0xffffffff), TOBN(0x886b4238, 0x61285c97),
|
||||
TOBN(0xc6f34a26, 0xc1b2effa), TOBN(0xc58ef183, 0x7d1683b2),
|
||||
TOBN(0x3bb5fcbc, 0x2ec22005), TOBN(0xc3fe3b1b, 0x4c6fad73),
|
||||
TOBN(0x8e4f1232, 0xeef28183), TOBN(0x9172fe9c, 0xe98583ff),
|
||||
TOBN(0xc03404cd, 0x28342f61), TOBN(0x9e02fce1, 0xcdf7e2ec),
|
||||
TOBN(0x0b07a7c8, 0xee0a6d70), TOBN(0xae56ede7, 0x6372bb19),
|
||||
TOBN(0x1d4f42a3, 0xde394df4), TOBN(0xb96adab7, 0x60d7f468),
|
||||
TOBN(0xd108a94b, 0xb2c8e3fb), TOBN(0xbc0ab182, 0xb324fb61),
|
||||
TOBN(0x30acca4f, 0x483a797a), TOBN(0x1df158a1, 0x36ade735),
|
||||
TOBN(0xe2a689da, 0xf3efe872), TOBN(0x984f0c70, 0xe0e68b77),
|
||||
TOBN(0xb557135e, 0x7f57c935), TOBN(0x85636555, 0x3ded1af3),
|
||||
TOBN(0x2433f51f, 0x5f066ed0), TOBN(0xd3df1ed5, 0xd5fd6561),
|
||||
TOBN(0xf681b202, 0xaec4617a), TOBN(0x7d2fe363, 0x630c75d8),
|
||||
TOBN(0xcc939dce, 0x249b3ef9), TOBN(0xa9e13641, 0x146433fb),
|
||||
TOBN(0xd8b9c583, 0xce2d3695), TOBN(0xafdc5620, 0x273d3cf1),
|
||||
TOBN(0xadf85458, 0xa2bb4a9a), TOBN(0xffffffff, 0xffffffff),
|
||||
};
|
||||
DH *dh = DH_get_rfc7919_2048();
|
||||
if (!dh) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BIGNUM *priv = BN_new();
|
||||
if (!priv) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
// kFFDHE2048PrivateKeyData is a 225-bit value. (225 because that's the
|
||||
// minimum private key size in
|
||||
@@ -279,41 +269,16 @@ static DH *self_test_dh(void) {
|
||||
TOBN(0x00000001, 0x91173f2a),
|
||||
};
|
||||
|
||||
BIGNUM *const ffdhe2048_p = BN_new();
|
||||
BIGNUM *const ffdhe2048_q = BN_new();
|
||||
BIGNUM *const ffdhe2048_g = BN_new();
|
||||
BIGNUM *ffdhe2048_priv = BN_new();
|
||||
DH *const dh = DH_new();
|
||||
|
||||
if (!ffdhe2048_p || !ffdhe2048_q || !ffdhe2048_g || !ffdhe2048_priv || !dh) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
bn_set_static_words(ffdhe2048_p, kFFDHE2048Data,
|
||||
OPENSSL_ARRAY_SIZE(kFFDHE2048Data));
|
||||
bn_set_static_words(ffdhe2048_priv, kFFDHE2048PrivateKeyData,
|
||||
bn_set_static_words(priv, kFFDHE2048PrivateKeyData,
|
||||
OPENSSL_ARRAY_SIZE(kFFDHE2048PrivateKeyData));
|
||||
|
||||
if (!BN_copy(ffdhe2048_q, ffdhe2048_p) ||
|
||||
!BN_sub_word(ffdhe2048_q, 1) ||
|
||||
BN_div_word(ffdhe2048_q, 2) != 0 ||
|
||||
!BN_set_word(ffdhe2048_g, 2) ||
|
||||
!DH_set0_key(dh, NULL, ffdhe2048_priv)) {
|
||||
if (!DH_set0_key(dh, NULL, priv)) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
ffdhe2048_priv = NULL;
|
||||
if (!DH_set0_pqg(dh, ffdhe2048_p, ffdhe2048_q, ffdhe2048_g)) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
return dh;
|
||||
|
||||
err:
|
||||
BN_free(ffdhe2048_p);
|
||||
BN_free(ffdhe2048_q);
|
||||
BN_free(ffdhe2048_g);
|
||||
BN_free(ffdhe2048_priv);
|
||||
BN_free(priv);
|
||||
DH_free(dh);
|
||||
return NULL;
|
||||
}
|
||||
@@ -763,14 +728,12 @@ int boringssl_fips_self_test(
|
||||
// ECDSA Sign/Verify KAT
|
||||
|
||||
// The 'k' value for ECDSA is fixed to avoid an entropy draw.
|
||||
ec_key->fixed_k = BN_new();
|
||||
if (ec_key->fixed_k == NULL ||
|
||||
!BN_set_word(ec_key->fixed_k, 42)) {
|
||||
fprintf(stderr, "Out of memory\n");
|
||||
goto err;
|
||||
}
|
||||
uint8_t ecdsa_k[32] = {0};
|
||||
ecdsa_k[31] = 42;
|
||||
|
||||
sig = ECDSA_do_sign(kPlaintextSHA256, sizeof(kPlaintextSHA256), ec_key);
|
||||
sig = ecdsa_sign_with_nonce_for_known_answer_test(
|
||||
kPlaintextSHA256, sizeof(kPlaintextSHA256), ec_key, ecdsa_k,
|
||||
sizeof(ecdsa_k));
|
||||
|
||||
uint8_t ecdsa_r_bytes[sizeof(kECDSASigR)];
|
||||
uint8_t ecdsa_s_bytes[sizeof(kECDSASigS)];
|
||||
|
||||
@@ -943,11 +943,6 @@ int PKCS12_parse(const PKCS12 *p12, const char *password, EVP_PKEY **out_pkey,
|
||||
|
||||
// OpenSSL selects the last certificate which matches the private key as
|
||||
// |out_cert|.
|
||||
//
|
||||
// TODO(davidben): OpenSSL additionally reverses the order of the
|
||||
// certificates, which was likely originally a bug, but may be a feature by
|
||||
// now. See https://crbug.com/boringssl/250 and
|
||||
// https://github.com/openssl/openssl/issues/6698.
|
||||
*out_cert = NULL;
|
||||
size_t num_certs = sk_X509_num(ca_certs);
|
||||
if (*out_pkey != NULL && num_certs > 0) {
|
||||
@@ -1074,31 +1069,24 @@ static int add_cert_bag(CBB *cbb, X509 *cert, const char *name,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int make_cert_safe_contents(uint8_t **out_data, size_t *out_len,
|
||||
X509 *cert, const STACK_OF(X509) *chain,
|
||||
const char *name, const uint8_t *key_id,
|
||||
size_t key_id_len) {
|
||||
int ret = 0;
|
||||
CBB cbb, safe_contents;
|
||||
if (!CBB_init(&cbb, 0) ||
|
||||
!CBB_add_asn1(&cbb, &safe_contents, CBS_ASN1_SEQUENCE) ||
|
||||
static int add_cert_safe_contents(CBB *cbb, X509 *cert,
|
||||
const STACK_OF(X509) *chain, const char *name,
|
||||
const uint8_t *key_id, size_t key_id_len) {
|
||||
CBB safe_contents;
|
||||
if (!CBB_add_asn1(cbb, &safe_contents, CBS_ASN1_SEQUENCE) ||
|
||||
(cert != NULL &&
|
||||
!add_cert_bag(&safe_contents, cert, name, key_id, key_id_len))) {
|
||||
goto err;
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < sk_X509_num(chain); i++) {
|
||||
// Only the leaf certificate gets attributes.
|
||||
if (!add_cert_bag(&safe_contents, sk_X509_value(chain, i), NULL, NULL, 0)) {
|
||||
goto err;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
ret = CBB_finish(&cbb, out_data, out_len);
|
||||
|
||||
err:
|
||||
CBB_cleanup(&cbb);
|
||||
return ret;
|
||||
return CBB_flush(cbb);
|
||||
}
|
||||
|
||||
static int add_encrypted_data(CBB *out, int pbe_nid, const char *password,
|
||||
@@ -1181,9 +1169,6 @@ PKCS12 *PKCS12_create(const char *password, const char *name,
|
||||
if (// In OpenSSL, this specifies a non-standard Microsoft key usage extension
|
||||
// which we do not currently support.
|
||||
key_type != 0 ||
|
||||
// In OpenSSL, -1 here means to use no encryption, which we do not
|
||||
// currently support.
|
||||
key_nid < 0 || cert_nid < 0 ||
|
||||
// In OpenSSL, -1 here means to omit the MAC, which we do not
|
||||
// currently support. Omitting it is also invalid for a password-based
|
||||
// PKCS#12 file.
|
||||
@@ -1194,6 +1179,36 @@ PKCS12 *PKCS12_create(const char *password, const char *name,
|
||||
return 0;
|
||||
}
|
||||
|
||||
// PKCS#12 is a very confusing recursive data format, built out of another
|
||||
// recursive data format. Section 5.1 of RFC7292 describes the encoding
|
||||
// algorithm, but there is no clear overview. A quick summary:
|
||||
//
|
||||
// PKCS#7 defines a ContentInfo structure, which is a overgeneralized typed
|
||||
// combinator structure for applying cryptography. We care about two types. A
|
||||
// data ContentInfo contains an OCTET STRING and is a leaf node of the
|
||||
// combinator tree. An encrypted-data ContentInfo contains encryption
|
||||
// parameters (key derivation and encryption) and wraps another ContentInfo,
|
||||
// usually data.
|
||||
//
|
||||
// A PKCS#12 file is a PFX structure (section 4), which contains a single data
|
||||
// ContentInfo and a MAC over it. This root ContentInfo is the
|
||||
// AuthenticatedSafe and its payload is a SEQUENCE of other ContentInfos, so
|
||||
// that different parts of the PKCS#12 file can by differently protected.
|
||||
//
|
||||
// Each ContentInfo in the AuthenticatedSafe, after undoing all the PKCS#7
|
||||
// combinators, has SafeContents payload. A SafeContents is a SEQUENCE of
|
||||
// SafeBag. SafeBag is PKCS#12's typed structure, with subtypes such as KeyBag
|
||||
// and CertBag. Confusingly, there is a SafeContents bag type which itself
|
||||
// recursively contains more SafeBags, but we do not implement this. Bags also
|
||||
// can have attributes.
|
||||
//
|
||||
// The grouping of SafeBags into intermediate ContentInfos does not appear to
|
||||
// be significant, except that all SafeBags sharing a ContentInfo have the
|
||||
// same level of protection. Additionally, while keys may be encrypted by
|
||||
// placing a KeyBag in an encrypted-data ContentInfo, PKCS#12 also defines a
|
||||
// key-specific encryption container, PKCS8ShroudedKeyBag, which is used
|
||||
// instead.
|
||||
|
||||
// Note that |password| may be NULL to specify no password, rather than the
|
||||
// empty string. They are encoded differently in PKCS#12. (One is the empty
|
||||
// byte array and the other is NUL-terminated UCS-2.)
|
||||
@@ -1236,24 +1251,43 @@ PKCS12 *PKCS12_create(const char *password, const char *name,
|
||||
// If there are any certificates, place them in CertBags wrapped in a single
|
||||
// encrypted ContentInfo.
|
||||
if (cert != NULL || sk_X509_num(chain) > 0) {
|
||||
uint8_t *data;
|
||||
size_t len;
|
||||
if (!make_cert_safe_contents(&data, &len, cert, chain, name, key_id,
|
||||
key_id_len)) {
|
||||
goto err;
|
||||
}
|
||||
int ok = add_encrypted_data(&content_infos, cert_nid, password,
|
||||
password_len, iterations, data, len);
|
||||
OPENSSL_free(data);
|
||||
if (!ok) {
|
||||
goto err;
|
||||
if (cert_nid < 0) {
|
||||
// Place the certificates in an unencrypted ContentInfo. This could be
|
||||
// more compactly-encoded by reusing the same ContentInfo as the key, but
|
||||
// OpenSSL does not do this. We keep them separate for consistency. (Keys,
|
||||
// even when encrypted, are always placed in unencrypted ContentInfos.
|
||||
// PKCS#12 defines bag-level encryption for keys.)
|
||||
CBB content_info, oid, wrapper, data;
|
||||
if (!CBB_add_asn1(&content_infos, &content_info, CBS_ASN1_SEQUENCE) ||
|
||||
!CBB_add_asn1(&content_info, &oid, CBS_ASN1_OBJECT) ||
|
||||
!CBB_add_bytes(&oid, kPKCS7Data, sizeof(kPKCS7Data)) ||
|
||||
!CBB_add_asn1(&content_info, &wrapper,
|
||||
CBS_ASN1_CONSTRUCTED | CBS_ASN1_CONTEXT_SPECIFIC | 0) ||
|
||||
!CBB_add_asn1(&wrapper, &data, CBS_ASN1_OCTETSTRING) ||
|
||||
!add_cert_safe_contents(&data, cert, chain, name, key_id,
|
||||
key_id_len) ||
|
||||
!CBB_flush(&content_infos)) {
|
||||
goto err;
|
||||
}
|
||||
} else {
|
||||
CBB plaintext_cbb;
|
||||
int ok = CBB_init(&plaintext_cbb, 0) &&
|
||||
add_cert_safe_contents(&plaintext_cbb, cert, chain, name, key_id,
|
||||
key_id_len) &&
|
||||
add_encrypted_data(
|
||||
&content_infos, cert_nid, password, password_len, iterations,
|
||||
CBB_data(&plaintext_cbb), CBB_len(&plaintext_cbb));
|
||||
CBB_cleanup(&plaintext_cbb);
|
||||
if (!ok) {
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If there is a key, place it in a single PKCS8ShroudedKeyBag wrapped in an
|
||||
// unencrypted ContentInfo. (One could also place it in a KeyBag inside an
|
||||
// encrypted ContentInfo, but OpenSSL does not do this and some PKCS#12
|
||||
// consumers do not support KeyBags.)
|
||||
// If there is a key, place it in a single KeyBag or PKCS8ShroudedKeyBag
|
||||
// wrapped in an unencrypted ContentInfo. (One could also place it in a KeyBag
|
||||
// inside an encrypted ContentInfo, but OpenSSL does not do this and some
|
||||
// PKCS#12 consumers do not support KeyBags.)
|
||||
if (pkey != NULL) {
|
||||
CBB content_info, oid, wrapper, data, safe_contents, bag, bag_oid,
|
||||
bag_contents;
|
||||
@@ -1267,16 +1301,29 @@ PKCS12 *PKCS12_create(const char *password, const char *name,
|
||||
!CBB_add_asn1(&data, &safe_contents, CBS_ASN1_SEQUENCE) ||
|
||||
// Add a SafeBag containing a PKCS8ShroudedKeyBag.
|
||||
!CBB_add_asn1(&safe_contents, &bag, CBS_ASN1_SEQUENCE) ||
|
||||
!CBB_add_asn1(&bag, &bag_oid, CBS_ASN1_OBJECT) ||
|
||||
!CBB_add_bytes(&bag_oid, kPKCS8ShroudedKeyBag,
|
||||
sizeof(kPKCS8ShroudedKeyBag)) ||
|
||||
!CBB_add_asn1(&bag, &bag_contents,
|
||||
CBS_ASN1_CONSTRUCTED | CBS_ASN1_CONTEXT_SPECIFIC | 0) ||
|
||||
!PKCS8_marshal_encrypted_private_key(
|
||||
&bag_contents, key_nid, NULL, password, password_len,
|
||||
NULL /* generate a random salt */, 0 /* use default salt length */,
|
||||
iterations, pkey) ||
|
||||
!add_bag_attributes(&bag, name, key_id, key_id_len) ||
|
||||
!CBB_add_asn1(&bag, &bag_oid, CBS_ASN1_OBJECT)) {
|
||||
goto err;
|
||||
}
|
||||
if (key_nid < 0) {
|
||||
if (!CBB_add_bytes(&bag_oid, kKeyBag, sizeof(kKeyBag)) ||
|
||||
!CBB_add_asn1(&bag, &bag_contents,
|
||||
CBS_ASN1_CONSTRUCTED | CBS_ASN1_CONTEXT_SPECIFIC | 0) ||
|
||||
!EVP_marshal_private_key(&bag_contents, pkey)) {
|
||||
goto err;
|
||||
}
|
||||
} else {
|
||||
if (!CBB_add_bytes(&bag_oid, kPKCS8ShroudedKeyBag,
|
||||
sizeof(kPKCS8ShroudedKeyBag)) ||
|
||||
!CBB_add_asn1(&bag, &bag_contents,
|
||||
CBS_ASN1_CONSTRUCTED | CBS_ASN1_CONTEXT_SPECIFIC | 0) ||
|
||||
!PKCS8_marshal_encrypted_private_key(
|
||||
&bag_contents, key_nid, NULL, password, password_len,
|
||||
NULL /* generate a random salt */,
|
||||
0 /* use default salt length */, iterations, pkey)) {
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
if (!add_bag_attributes(&bag, name, key_id, key_id_len) ||
|
||||
!CBB_flush(&content_infos)) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
@@ -69,6 +69,6 @@ RAND_METHOD *RAND_OpenSSL(void) {
|
||||
|
||||
const RAND_METHOD *RAND_get_rand_method(void) { return RAND_SSLeay(); }
|
||||
|
||||
void RAND_set_rand_method(const RAND_METHOD *method) {}
|
||||
int RAND_set_rand_method(const RAND_METHOD *method) { return 1; }
|
||||
|
||||
void RAND_cleanup(void) {}
|
||||
@@ -24,6 +24,14 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Internal structures. */
|
||||
|
||||
struct X509_val_st {
|
||||
ASN1_TIME *notBefore;
|
||||
ASN1_TIME *notAfter;
|
||||
} /* X509_VAL */;
|
||||
|
||||
|
||||
/* RSA-PSS functions. */
|
||||
|
||||
/* x509_rsa_pss_to_ctx configures |ctx| for an RSA-PSS operation based on
|
||||
|
||||
@@ -83,34 +83,6 @@ int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b)
|
||||
return (X509_NAME_cmp(ai->issuer, bi->issuer));
|
||||
}
|
||||
|
||||
unsigned long X509_issuer_and_serial_hash(X509 *a)
|
||||
{
|
||||
unsigned long ret = 0;
|
||||
EVP_MD_CTX ctx;
|
||||
unsigned char md[16];
|
||||
char *f;
|
||||
|
||||
EVP_MD_CTX_init(&ctx);
|
||||
f = X509_NAME_oneline(a->cert_info->issuer, NULL, 0);
|
||||
if (!EVP_DigestInit_ex(&ctx, EVP_md5(), NULL))
|
||||
goto err;
|
||||
if (!EVP_DigestUpdate(&ctx, (unsigned char *)f, strlen(f)))
|
||||
goto err;
|
||||
OPENSSL_free(f);
|
||||
if (!EVP_DigestUpdate
|
||||
(&ctx, (unsigned char *)a->cert_info->serialNumber->data,
|
||||
(unsigned long)a->cert_info->serialNumber->length))
|
||||
goto err;
|
||||
if (!EVP_DigestFinal_ex(&ctx, &(md[0]), NULL))
|
||||
goto err;
|
||||
ret = (((unsigned long)md[0]) | ((unsigned long)md[1] << 8L) |
|
||||
((unsigned long)md[2] << 16L) | ((unsigned long)md[3] << 24L)
|
||||
) & 0xffffffffL;
|
||||
err:
|
||||
EVP_MD_CTX_cleanup(&ctx);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
int X509_issuer_name_cmp(const X509 *a, const X509 *b)
|
||||
{
|
||||
return (X509_NAME_cmp(a->cert_info->issuer, b->cert_info->issuer));
|
||||
@@ -411,7 +383,7 @@ int X509_chain_check_suiteb(int *perror_depth, X509 *x, STACK_OF(X509) *chain,
|
||||
} else
|
||||
i = 0;
|
||||
|
||||
if (X509_get_version(x) != 2) {
|
||||
if (X509_get_version(x) != X509V3_VERSION) {
|
||||
rv = X509_V_ERR_SUITE_B_INVALID_VERSION;
|
||||
/* Correct error depth */
|
||||
i = 0;
|
||||
@@ -429,7 +401,7 @@ int X509_chain_check_suiteb(int *perror_depth, X509 *x, STACK_OF(X509) *chain,
|
||||
for (; i < sk_X509_num(chain); i++) {
|
||||
sign_nid = X509_get_signature_nid(x);
|
||||
x = sk_X509_value(chain, i);
|
||||
if (X509_get_version(x) != 2) {
|
||||
if (X509_get_version(x) != X509V3_VERSION) {
|
||||
rv = X509_V_ERR_SUITE_B_INVALID_VERSION;
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.] */
|
||||
|
||||
#include <CCryptoBoringSSL_asn1.h>
|
||||
#include <CCryptoBoringSSL_bn.h>
|
||||
#include <CCryptoBoringSSL_digest.h>
|
||||
#include <CCryptoBoringSSL_err.h>
|
||||
#include <CCryptoBoringSSL_evp.h>
|
||||
#include <CCryptoBoringSSL_obj.h>
|
||||
#include <CCryptoBoringSSL_x509.h>
|
||||
|
||||
X509 *X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey)
|
||||
{
|
||||
X509 *ret = NULL;
|
||||
X509_CINF *xi = NULL;
|
||||
X509_NAME *xn;
|
||||
EVP_PKEY *pubkey = NULL;
|
||||
int res;
|
||||
|
||||
if ((ret = X509_new()) == NULL) {
|
||||
OPENSSL_PUT_ERROR(X509, ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* duplicate the request */
|
||||
xi = ret->cert_info;
|
||||
|
||||
if (sk_X509_ATTRIBUTE_num(r->req_info->attributes) != 0) {
|
||||
if ((xi->version = ASN1_INTEGER_new()) == NULL)
|
||||
goto err;
|
||||
if (!ASN1_INTEGER_set(xi->version, 2))
|
||||
goto err;
|
||||
/*
|
||||
* xi->extensions=ri->attributes; <- bad, should not ever be done
|
||||
* ri->attributes=NULL;
|
||||
*/
|
||||
}
|
||||
|
||||
xn = X509_REQ_get_subject_name(r);
|
||||
if (X509_set_subject_name(ret, xn) == 0)
|
||||
goto err;
|
||||
if (X509_set_issuer_name(ret, xn) == 0)
|
||||
goto err;
|
||||
|
||||
if (X509_gmtime_adj(xi->validity->notBefore, 0) == NULL)
|
||||
goto err;
|
||||
if (X509_gmtime_adj(xi->validity->notAfter, (long)60 * 60 * 24 * days) ==
|
||||
NULL)
|
||||
goto err;
|
||||
|
||||
pubkey = X509_REQ_get_pubkey(r);
|
||||
res = X509_set_pubkey(ret, pubkey);
|
||||
EVP_PKEY_free(pubkey);
|
||||
|
||||
if (!res || !X509_sign(ret, pkey, EVP_md5()))
|
||||
goto err;
|
||||
if (0) {
|
||||
err:
|
||||
X509_free(ret);
|
||||
ret = NULL;
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
@@ -60,8 +60,15 @@
|
||||
#include <CCryptoBoringSSL_obj.h>
|
||||
#include <CCryptoBoringSSL_x509.h>
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
long X509_get_version(const X509 *x509)
|
||||
{
|
||||
// The default version is v1(0).
|
||||
if (x509->cert_info->version == NULL) {
|
||||
return X509V1_VERSION;
|
||||
}
|
||||
return ASN1_INTEGER_get(x509->cert_info->version);
|
||||
}
|
||||
|
||||
@@ -72,6 +79,7 @@ X509_CINF *X509_get_cert_info(const X509 *x509)
|
||||
|
||||
int X509_set_version(X509 *x, long version)
|
||||
{
|
||||
// TODO(davidben): Reject invalid version numbers.
|
||||
if (x == NULL)
|
||||
return (0);
|
||||
if (version == 0) {
|
||||
@@ -86,7 +94,7 @@ int X509_set_version(X509 *x, long version)
|
||||
return (ASN1_INTEGER_set(x->cert_info->version, version));
|
||||
}
|
||||
|
||||
int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial)
|
||||
int X509_set_serialNumber(X509 *x, const ASN1_INTEGER *serial)
|
||||
{
|
||||
ASN1_INTEGER *in;
|
||||
|
||||
|
||||
@@ -2052,7 +2052,7 @@ X509_CRL *X509_CRL_diff(X509_CRL *base, X509_CRL *newer,
|
||||
}
|
||||
/* Create new CRL */
|
||||
crl = X509_CRL_new();
|
||||
if (!crl || !X509_CRL_set_version(crl, 1))
|
||||
if (!crl || !X509_CRL_set_version(crl, X509V2_VERSION))
|
||||
goto memerr;
|
||||
/* Set issuer name */
|
||||
if (!X509_CRL_set_issuer_name(crl, X509_CRL_get_issuer(newer)))
|
||||
|
||||
@@ -85,27 +85,32 @@ IMPLEMENT_ASN1_DUP_FUNCTION(X509_ATTRIBUTE)
|
||||
|
||||
X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value)
|
||||
{
|
||||
X509_ATTRIBUTE *ret = NULL;
|
||||
ASN1_TYPE *val = NULL;
|
||||
const ASN1_OBJECT *obj = OBJ_nid2obj(nid);
|
||||
if (obj == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((ret = X509_ATTRIBUTE_new()) == NULL)
|
||||
return (NULL);
|
||||
/* TODO(fork): const correctness. */
|
||||
ret->object = (ASN1_OBJECT *)OBJ_nid2obj(nid);
|
||||
X509_ATTRIBUTE *ret = X509_ATTRIBUTE_new();
|
||||
ASN1_TYPE *val = ASN1_TYPE_new();
|
||||
if (ret == NULL || val == NULL) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* TODO(fork): const correctness. |ASN1_OBJECT| is messy because static
|
||||
* objects are const but freeable with a no-op |ASN1_OBJECT_free|. */
|
||||
ret->object = (ASN1_OBJECT *)obj;
|
||||
ret->single = 0;
|
||||
if ((ret->value.set = sk_ASN1_TYPE_new_null()) == NULL)
|
||||
goto err;
|
||||
if ((val = ASN1_TYPE_new()) == NULL)
|
||||
goto err;
|
||||
if (!sk_ASN1_TYPE_push(ret->value.set, val))
|
||||
ret->value.set = sk_ASN1_TYPE_new_null();
|
||||
if (ret->value.set == NULL ||
|
||||
!sk_ASN1_TYPE_push(ret->value.set, val)) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
ASN1_TYPE_set(val, atrtype, value);
|
||||
return (ret);
|
||||
return ret;
|
||||
|
||||
err:
|
||||
if (ret != NULL)
|
||||
X509_ATTRIBUTE_free(ret);
|
||||
if (val != NULL)
|
||||
ASN1_TYPE_free(val);
|
||||
return (NULL);
|
||||
X509_ATTRIBUTE_free(ret);
|
||||
ASN1_TYPE_free(val);
|
||||
return NULL;
|
||||
}
|
||||
@@ -436,6 +436,11 @@ int X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x)
|
||||
|
||||
static int def_crl_verify(X509_CRL *crl, EVP_PKEY *r)
|
||||
{
|
||||
if (X509_ALGOR_cmp(crl->sig_alg, crl->crl->sig_alg) != 0) {
|
||||
OPENSSL_PUT_ERROR(X509, X509_R_SIGNATURE_ALGORITHM_MISMATCH);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (ASN1_item_verify(ASN1_ITEM_rptr(X509_CRL_INFO),
|
||||
crl->sig_alg, crl->signature, crl->crl, r));
|
||||
}
|
||||
|
||||
@@ -60,6 +60,8 @@
|
||||
#include <CCryptoBoringSSL_asn1t.h>
|
||||
#include <CCryptoBoringSSL_x509.h>
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
ASN1_SEQUENCE(X509_VAL) = {
|
||||
ASN1_SIMPLE(X509_VAL, notBefore, ASN1_TIME),
|
||||
|
||||
@@ -136,10 +136,12 @@ static int x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
}
|
||||
|
||||
/* Per RFC5280, section 4.1.2.9, extensions require v3. */
|
||||
/* Check disabled. TODO re-enable in April 2021.
|
||||
https://crbug.com/boringssl/375
|
||||
if (version != 2 && ret->cert_info->extensions != NULL) {
|
||||
OPENSSL_PUT_ERROR(X509, X509_R_INVALID_FIELD_FOR_VERSION);
|
||||
return 0;
|
||||
}
|
||||
}*/
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -440,7 +440,7 @@ int x509v3_cache_extensions(X509 *x)
|
||||
if (!X509_digest(x, EVP_sha1(), x->sha1_hash, NULL))
|
||||
x->ex_flags |= EXFLAG_INVALID;
|
||||
/* V1 should mean no extensions ... */
|
||||
if (!X509_get_version(x))
|
||||
if (X509_get_version(x) == X509V1_VERSION)
|
||||
x->ex_flags |= EXFLAG_V1;
|
||||
/* Handle basic constraints */
|
||||
if ((bs = X509_get_ext_d2i(x, NID_basic_constraints, &j, NULL))) {
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
This directory is derived from BoringSSL cloned from https://boringssl.googlesource.com/boringssl at revision bb43a45d6de7375f3310511d37f040d1055f8a10
|
||||
This directory is derived from BoringSSL cloned from https://boringssl.googlesource.com/boringssl at revision 04b3213d43492b6c9e0434d8e2a4530a9938f958
|
||||
@@ -113,6 +113,10 @@ extern "C" {
|
||||
#elif defined(__MIPSEL__) && defined(__LP64__)
|
||||
#define OPENSSL_64_BIT
|
||||
#define OPENSSL_MIPS64
|
||||
#elif defined(__riscv) && __SIZEOF_POINTER__ == 8
|
||||
#define OPENSSL_64_BIT
|
||||
#elif defined(__riscv) && __SIZEOF_POINTER__ == 4
|
||||
#define OPENSSL_32_BIT
|
||||
#elif defined(__pnacl__)
|
||||
#define OPENSSL_32_BIT
|
||||
#define OPENSSL_PNACL
|
||||
|
||||
@@ -596,8 +596,8 @@
|
||||
#define CRYPTO_has_asm BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_has_asm)
|
||||
#define CRYPTO_hchacha20 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_hchacha20)
|
||||
#define CRYPTO_init_sysrand BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_init_sysrand)
|
||||
#define CRYPTO_is_ARMv8_AES_capable BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_is_ARMv8_AES_capable)
|
||||
#define CRYPTO_is_ARMv8_PMULL_capable BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_is_ARMv8_PMULL_capable)
|
||||
#define CRYPTO_is_ARMv8_AES_capable_at_runtime BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_is_ARMv8_AES_capable_at_runtime)
|
||||
#define CRYPTO_is_ARMv8_PMULL_capable_at_runtime BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_is_ARMv8_PMULL_capable_at_runtime)
|
||||
#define CRYPTO_is_NEON_capable_at_runtime BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_is_NEON_capable_at_runtime)
|
||||
#define CRYPTO_is_confidential_build BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_is_confidential_build)
|
||||
#define CRYPTO_library_init BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_library_init)
|
||||
@@ -656,6 +656,7 @@
|
||||
#define DH_get0_priv_key BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_get0_priv_key)
|
||||
#define DH_get0_pub_key BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_get0_pub_key)
|
||||
#define DH_get0_q BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_get0_q)
|
||||
#define DH_get_rfc7919_2048 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_get_rfc7919_2048)
|
||||
#define DH_marshal_parameters BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_marshal_parameters)
|
||||
#define DH_new BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_new)
|
||||
#define DH_num_bits BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_num_bits)
|
||||
@@ -731,6 +732,7 @@
|
||||
#define ECDSA_do_sign BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ECDSA_do_sign)
|
||||
#define ECDSA_do_verify BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ECDSA_do_verify)
|
||||
#define ECDSA_sign BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ECDSA_sign)
|
||||
#define ECDSA_sign_with_nonce_and_leak_private_key_for_testing BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ECDSA_sign_with_nonce_and_leak_private_key_for_testing)
|
||||
#define ECDSA_size BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ECDSA_size)
|
||||
#define ECDSA_verify BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ECDSA_verify)
|
||||
#define EC_GFp_mont_method BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_GFp_mont_method)
|
||||
@@ -742,6 +744,7 @@
|
||||
#define EC_GROUP_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_GROUP_free)
|
||||
#define EC_GROUP_get0_generator BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_GROUP_get0_generator)
|
||||
#define EC_GROUP_get0_order BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_GROUP_get0_order)
|
||||
#define EC_GROUP_get_asn1_flag BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_GROUP_get_asn1_flag)
|
||||
#define EC_GROUP_get_cofactor BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_GROUP_get_cofactor)
|
||||
#define EC_GROUP_get_curve_GFp BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_GROUP_get_curve_GFp)
|
||||
#define EC_GROUP_get_curve_name BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_GROUP_get_curve_name)
|
||||
@@ -1847,7 +1850,6 @@
|
||||
#define X509_REQ_set_version BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_REQ_set_version)
|
||||
#define X509_REQ_sign BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_REQ_sign)
|
||||
#define X509_REQ_sign_ctx BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_REQ_sign_ctx)
|
||||
#define X509_REQ_to_X509 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_REQ_to_X509)
|
||||
#define X509_REQ_verify BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_REQ_verify)
|
||||
#define X509_REVOKED_add1_ext_i2d BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_REVOKED_add1_ext_i2d)
|
||||
#define X509_REVOKED_add_ext BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_REVOKED_add_ext)
|
||||
@@ -2066,7 +2068,6 @@
|
||||
#define X509_getm_notBefore BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_getm_notBefore)
|
||||
#define X509_gmtime_adj BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_gmtime_adj)
|
||||
#define X509_issuer_and_serial_cmp BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_issuer_and_serial_cmp)
|
||||
#define X509_issuer_and_serial_hash BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_issuer_and_serial_hash)
|
||||
#define X509_issuer_name_cmp BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_issuer_name_cmp)
|
||||
#define X509_issuer_name_hash BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_issuer_name_hash)
|
||||
#define X509_issuer_name_hash_old BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_issuer_name_hash_old)
|
||||
@@ -2491,6 +2492,7 @@
|
||||
#define ec_set_to_safe_point BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_set_to_safe_point)
|
||||
#define ec_simple_scalar_inv0_montgomery BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_simple_scalar_inv0_montgomery)
|
||||
#define ec_simple_scalar_to_montgomery_inv_vartime BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_simple_scalar_to_montgomery_inv_vartime)
|
||||
#define 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_mul_mont BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ecp_nistz256_mul_mont)
|
||||
#define ecp_nistz256_neg BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ecp_nistz256_neg)
|
||||
|
||||
@@ -601,8 +601,8 @@
|
||||
#define _CRYPTO_has_asm BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_has_asm)
|
||||
#define _CRYPTO_hchacha20 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_hchacha20)
|
||||
#define _CRYPTO_init_sysrand BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_init_sysrand)
|
||||
#define _CRYPTO_is_ARMv8_AES_capable BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_is_ARMv8_AES_capable)
|
||||
#define _CRYPTO_is_ARMv8_PMULL_capable BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_is_ARMv8_PMULL_capable)
|
||||
#define _CRYPTO_is_ARMv8_AES_capable_at_runtime BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_is_ARMv8_AES_capable_at_runtime)
|
||||
#define _CRYPTO_is_ARMv8_PMULL_capable_at_runtime BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_is_ARMv8_PMULL_capable_at_runtime)
|
||||
#define _CRYPTO_is_NEON_capable_at_runtime BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_is_NEON_capable_at_runtime)
|
||||
#define _CRYPTO_is_confidential_build BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_is_confidential_build)
|
||||
#define _CRYPTO_library_init BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_library_init)
|
||||
@@ -661,6 +661,7 @@
|
||||
#define _DH_get0_priv_key BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_get0_priv_key)
|
||||
#define _DH_get0_pub_key BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_get0_pub_key)
|
||||
#define _DH_get0_q BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_get0_q)
|
||||
#define _DH_get_rfc7919_2048 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_get_rfc7919_2048)
|
||||
#define _DH_marshal_parameters BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_marshal_parameters)
|
||||
#define _DH_new BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_new)
|
||||
#define _DH_num_bits BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_num_bits)
|
||||
@@ -736,6 +737,7 @@
|
||||
#define _ECDSA_do_sign BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ECDSA_do_sign)
|
||||
#define _ECDSA_do_verify BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ECDSA_do_verify)
|
||||
#define _ECDSA_sign BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ECDSA_sign)
|
||||
#define _ECDSA_sign_with_nonce_and_leak_private_key_for_testing BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ECDSA_sign_with_nonce_and_leak_private_key_for_testing)
|
||||
#define _ECDSA_size BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ECDSA_size)
|
||||
#define _ECDSA_verify BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ECDSA_verify)
|
||||
#define _EC_GFp_mont_method BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_GFp_mont_method)
|
||||
@@ -747,6 +749,7 @@
|
||||
#define _EC_GROUP_free BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_GROUP_free)
|
||||
#define _EC_GROUP_get0_generator BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_GROUP_get0_generator)
|
||||
#define _EC_GROUP_get0_order BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_GROUP_get0_order)
|
||||
#define _EC_GROUP_get_asn1_flag BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_GROUP_get_asn1_flag)
|
||||
#define _EC_GROUP_get_cofactor BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_GROUP_get_cofactor)
|
||||
#define _EC_GROUP_get_curve_GFp BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_GROUP_get_curve_GFp)
|
||||
#define _EC_GROUP_get_curve_name BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_GROUP_get_curve_name)
|
||||
@@ -1852,7 +1855,6 @@
|
||||
#define _X509_REQ_set_version BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_REQ_set_version)
|
||||
#define _X509_REQ_sign BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_REQ_sign)
|
||||
#define _X509_REQ_sign_ctx BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_REQ_sign_ctx)
|
||||
#define _X509_REQ_to_X509 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_REQ_to_X509)
|
||||
#define _X509_REQ_verify BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_REQ_verify)
|
||||
#define _X509_REVOKED_add1_ext_i2d BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_REVOKED_add1_ext_i2d)
|
||||
#define _X509_REVOKED_add_ext BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_REVOKED_add_ext)
|
||||
@@ -2071,7 +2073,6 @@
|
||||
#define _X509_getm_notBefore BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_getm_notBefore)
|
||||
#define _X509_gmtime_adj BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_gmtime_adj)
|
||||
#define _X509_issuer_and_serial_cmp BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_issuer_and_serial_cmp)
|
||||
#define _X509_issuer_and_serial_hash BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_issuer_and_serial_hash)
|
||||
#define _X509_issuer_name_cmp BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_issuer_name_cmp)
|
||||
#define _X509_issuer_name_hash BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_issuer_name_hash)
|
||||
#define _X509_issuer_name_hash_old BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_issuer_name_hash_old)
|
||||
@@ -2496,6 +2497,7 @@
|
||||
#define _ec_set_to_safe_point BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_set_to_safe_point)
|
||||
#define _ec_simple_scalar_inv0_montgomery BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_simple_scalar_inv0_montgomery)
|
||||
#define _ec_simple_scalar_to_montgomery_inv_vartime BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_simple_scalar_to_montgomery_inv_vartime)
|
||||
#define _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_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)
|
||||
|
||||
@@ -556,10 +556,6 @@ struct evp_cipher_ctx_st {
|
||||
// final_used is non-zero if the |final| buffer contains plaintext.
|
||||
int final_used;
|
||||
|
||||
// block_mask contains |cipher->block_size| minus one. (The block size
|
||||
// assumed to be a power of two.)
|
||||
int block_mask;
|
||||
|
||||
uint8_t final[EVP_MAX_BLOCK_LENGTH]; // possible final block
|
||||
} /* EVP_CIPHER_CTX */;
|
||||
|
||||
|
||||
@@ -111,26 +111,18 @@ OPENSSL_INLINE const uint32_t *OPENSSL_ia32cap_get(void) {
|
||||
#endif
|
||||
|
||||
#if !defined(OPENSSL_STATIC_ARMCAP)
|
||||
|
||||
// CRYPTO_is_NEON_capable_at_runtime returns true if the current CPU has a NEON
|
||||
// unit. Note that |OPENSSL_armcap_P| also exists and contains the same
|
||||
// information in a form that's easier for assembly to use.
|
||||
OPENSSL_EXPORT char CRYPTO_is_NEON_capable_at_runtime(void);
|
||||
OPENSSL_EXPORT int CRYPTO_is_NEON_capable_at_runtime(void);
|
||||
|
||||
// CRYPTO_is_NEON_capable returns true if the current CPU has a NEON unit. If
|
||||
// this is known statically then it returns one immediately.
|
||||
OPENSSL_INLINE int CRYPTO_is_NEON_capable(void) {
|
||||
// Only statically skip the runtime lookup on aarch64. On arm, one CPU is
|
||||
// known to have a broken NEON unit which is known to fail with on some
|
||||
// hand-written NEON assembly. For now, continue to apply the workaround even
|
||||
// when the compiler is instructed to freely emit NEON code. See
|
||||
// https://crbug.com/341598 and https://crbug.com/606629.
|
||||
#if (defined(__ARM_NEON__) || defined(__ARM_NEON)) && !defined(OPENSSL_ARM)
|
||||
return 1;
|
||||
#else
|
||||
return CRYPTO_is_NEON_capable_at_runtime();
|
||||
#endif
|
||||
}
|
||||
// CRYPTO_is_ARMv8_AES_capable_at_runtime returns true if the current CPU
|
||||
// supports the ARMv8 AES instruction.
|
||||
int CRYPTO_is_ARMv8_AES_capable_at_runtime(void);
|
||||
|
||||
// CRYPTO_is_ARMv8_PMULL_capable_at_runtime returns true if the current CPU
|
||||
// supports the ARMv8 PMULL instruction.
|
||||
int CRYPTO_is_ARMv8_PMULL_capable_at_runtime(void);
|
||||
|
||||
#if defined(OPENSSL_ARM)
|
||||
// CRYPTO_has_broken_NEON returns one if the current CPU is known to have a
|
||||
@@ -141,43 +133,41 @@ OPENSSL_EXPORT int CRYPTO_has_broken_NEON(void);
|
||||
// workaround was needed. See https://crbug.com/boringssl/46.
|
||||
OPENSSL_EXPORT int CRYPTO_needs_hwcap2_workaround(void);
|
||||
#endif
|
||||
#endif // !OPENSSL_STATIC_ARMCAP
|
||||
|
||||
// CRYPTO_is_ARMv8_AES_capable returns true if the current CPU supports the
|
||||
// ARMv8 AES instruction.
|
||||
int CRYPTO_is_ARMv8_AES_capable(void);
|
||||
|
||||
// CRYPTO_is_ARMv8_PMULL_capable returns true if the current CPU supports the
|
||||
// ARMv8 PMULL instruction.
|
||||
int CRYPTO_is_ARMv8_PMULL_capable(void);
|
||||
|
||||
#else
|
||||
|
||||
// CRYPTO_is_NEON_capable returns true if the current CPU has a NEON unit. If
|
||||
// this is known statically, it is a constant inline function.
|
||||
OPENSSL_INLINE int CRYPTO_is_NEON_capable(void) {
|
||||
#if defined(OPENSSL_STATIC_ARMCAP_NEON) || \
|
||||
(defined(__ARM_NEON__) || defined(__ARM_NEON))
|
||||
#if defined(__ARM_NEON__) || defined(__ARM_NEON) || \
|
||||
defined(OPENSSL_STATIC_ARMCAP_NEON)
|
||||
return 1;
|
||||
#else
|
||||
#elif defined(OPENSSL_STATIC_ARMCAP)
|
||||
return 0;
|
||||
#else
|
||||
return CRYPTO_is_NEON_capable_at_runtime();
|
||||
#endif
|
||||
}
|
||||
|
||||
OPENSSL_INLINE int CRYPTO_is_ARMv8_AES_capable(void) {
|
||||
#if defined(OPENSSL_STATIC_ARMCAP_AES) || defined(__ARM_FEATURE_CRYPTO)
|
||||
return 1;
|
||||
#else
|
||||
#elif defined(OPENSSL_STATIC_ARMCAP)
|
||||
return 0;
|
||||
#else
|
||||
return CRYPTO_is_ARMv8_AES_capable_at_runtime();
|
||||
#endif
|
||||
}
|
||||
|
||||
OPENSSL_INLINE int CRYPTO_is_ARMv8_PMULL_capable(void) {
|
||||
#if defined(OPENSSL_STATIC_ARMCAP_PMULL) || defined(__ARM_FEATURE_CRYPTO)
|
||||
return 1;
|
||||
#else
|
||||
#elif defined(OPENSSL_STATIC_ARMCAP)
|
||||
return 0;
|
||||
#else
|
||||
return CRYPTO_is_ARMv8_PMULL_capable_at_runtime();
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // OPENSSL_STATIC_ARMCAP
|
||||
#endif // OPENSSL_ARM || OPENSSL_AARCH64
|
||||
|
||||
#if defined(OPENSSL_PPC64LE)
|
||||
|
||||
@@ -139,6 +139,11 @@ OPENSSL_EXPORT int DH_set_length(DH *dh, unsigned priv_length);
|
||||
// and returned. It returns NULL on allocation failure.
|
||||
OPENSSL_EXPORT BIGNUM *BN_get_rfc3526_prime_1536(BIGNUM *ret);
|
||||
|
||||
// DH_get_rfc7919_2048 returns the group `ffdhe2048` from
|
||||
// https://tools.ietf.org/html/rfc7919#appendix-A.1. It returns NULL if out
|
||||
// of memory.
|
||||
OPENSSL_EXPORT DH *DH_get_rfc7919_2048(void);
|
||||
|
||||
|
||||
// Parameter generation.
|
||||
|
||||
|
||||
@@ -343,11 +343,14 @@ OPENSSL_EXPORT int EC_GROUP_set_generator(EC_GROUP *group,
|
||||
OPENSSL_EXPORT int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order,
|
||||
BN_CTX *ctx);
|
||||
|
||||
#define OPENSSL_EC_EXPLICIT_CURVE 0
|
||||
#define OPENSSL_EC_NAMED_CURVE 1
|
||||
|
||||
// EC_GROUP_set_asn1_flag does nothing.
|
||||
OPENSSL_EXPORT void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag);
|
||||
|
||||
#define OPENSSL_EC_NAMED_CURVE 0
|
||||
#define OPENSSL_EC_EXPLICIT_CURVE 1
|
||||
// EC_GROUP_get_asn1_flag returns |OPENSSL_EC_NAMED_CURVE|.
|
||||
OPENSSL_EXPORT int EC_GROUP_get_asn1_flag(const EC_GROUP *group);
|
||||
|
||||
typedef struct ec_method_st EC_METHOD;
|
||||
|
||||
|
||||
@@ -162,6 +162,25 @@ OPENSSL_EXPORT int ECDSA_SIG_to_bytes(uint8_t **out_bytes, size_t *out_len,
|
||||
OPENSSL_EXPORT size_t ECDSA_SIG_max_len(size_t order_len);
|
||||
|
||||
|
||||
// Testing-only functions.
|
||||
|
||||
// ECDSA_sign_with_nonce_and_leak_private_key_for_testing behaves like
|
||||
// |ECDSA_do_sign| but uses |nonce| for the ECDSA nonce 'k', instead of a random
|
||||
// value. |nonce| is interpreted as a big-endian integer. It must be reduced
|
||||
// modulo the group order and padded with zeros up to |BN_num_bytes(order)|
|
||||
// bytes.
|
||||
//
|
||||
// WARNING: This function is only exported for testing purposes, when using test
|
||||
// vectors or fuzzing strategies. It must not be used outside tests and may leak
|
||||
// any private keys it is used with.
|
||||
OPENSSL_EXPORT ECDSA_SIG *
|
||||
ECDSA_sign_with_nonce_and_leak_private_key_for_testing(const uint8_t *digest,
|
||||
size_t digest_len,
|
||||
const EC_KEY *eckey,
|
||||
const uint8_t *nonce,
|
||||
size_t nonce_len);
|
||||
|
||||
|
||||
// Deprecated functions.
|
||||
|
||||
// d2i_ECDSA_SIG parses an ASN.1, DER-encoded, signature from |len| bytes at
|
||||
|
||||
@@ -101,6 +101,7 @@ typedef struct {
|
||||
typedef void PKCS7_ENVELOPE;
|
||||
typedef void PKCS7_DIGEST;
|
||||
typedef void PKCS7_ENCRYPT;
|
||||
typedef void PKCS7_SIGNER_INFO;
|
||||
|
||||
typedef struct {
|
||||
uint8_t *ber_bytes;
|
||||
@@ -183,6 +184,7 @@ OPENSSL_EXPORT int PKCS7_type_is_signedAndEnveloped(const PKCS7 *p7);
|
||||
#define PKCS7_NOATTR 0x100
|
||||
#define PKCS7_NOSMIMECAP 0x200
|
||||
#define PKCS7_STREAM 0x1000
|
||||
#define PKCS7_PARTIAL 0x4000
|
||||
|
||||
// PKCS7_sign assembles |certs| into a PKCS#7 signed data ContentInfo with
|
||||
// external data and no signatures. It returns a newly-allocated |PKCS7| on
|
||||
|
||||
@@ -175,7 +175,9 @@ OPENSSL_EXPORT int i2d_PKCS12_fp(FILE *fp, const PKCS12 *p12);
|
||||
//
|
||||
// Note if |p12| does not contain a private key, both |*out_pkey| and
|
||||
// |*out_cert| will be set to NULL and all certificates will be returned via
|
||||
// |*out_ca_certs|.
|
||||
// |*out_ca_certs|. Also note this function differs from OpenSSL in that extra
|
||||
// certificates are returned in the order they appear in the file. OpenSSL 1.1.1
|
||||
// returns them in reverse order, but this will be fixed in OpenSSL 3.0.
|
||||
//
|
||||
// It returns one on success and zero on error.
|
||||
//
|
||||
@@ -206,6 +208,12 @@ OPENSSL_EXPORT int PKCS12_verify_mac(const PKCS12 *p12, const char *password,
|
||||
// Each of |key_nid|, |cert_nid|, |iterations|, and |mac_iterations| may be zero
|
||||
// to use defaults, which are |NID_pbe_WithSHA1And3_Key_TripleDES_CBC|,
|
||||
// |NID_pbe_WithSHA1And40BitRC2_CBC|, 2048, and one, respectively.
|
||||
//
|
||||
// |key_nid| or |cert_nid| may also be -1 to disable encryption of the key or
|
||||
// certificate, respectively. This option is not recommended and is only
|
||||
// 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.
|
||||
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,
|
||||
|
||||
@@ -103,8 +103,8 @@ OPENSSL_EXPORT RAND_METHOD *RAND_OpenSSL(void);
|
||||
// RAND_get_rand_method returns |RAND_SSLeay()|.
|
||||
OPENSSL_EXPORT const RAND_METHOD *RAND_get_rand_method(void);
|
||||
|
||||
// RAND_set_rand_method does nothing.
|
||||
OPENSSL_EXPORT void RAND_set_rand_method(const RAND_METHOD *);
|
||||
// RAND_set_rand_method returns one.
|
||||
OPENSSL_EXPORT int RAND_set_rand_method(const RAND_METHOD *);
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
@@ -115,11 +115,6 @@ DECLARE_ASN1_SET_OF(X509_ALGOR)
|
||||
|
||||
typedef STACK_OF(X509_ALGOR) X509_ALGORS;
|
||||
|
||||
struct X509_val_st {
|
||||
ASN1_TIME *notBefore;
|
||||
ASN1_TIME *notAfter;
|
||||
} /* X509_VAL */;
|
||||
|
||||
struct X509_pubkey_st {
|
||||
X509_ALGOR *algor;
|
||||
ASN1_BIT_STRING *public_key;
|
||||
@@ -475,16 +470,34 @@ extern "C" {
|
||||
// it is safe to call mutating functions is a little tricky due to various
|
||||
// internal caches.
|
||||
|
||||
// X509_get_version returns the numerical value of |x509|'s version. That is,
|
||||
// it returns zero for X.509v1, one for X.509v2, and two for X.509v3. Unknown
|
||||
// versions are rejected by the parser, but a manually-created |X509| object may
|
||||
// encode invalid versions. In that case, the function will return the invalid
|
||||
// version, or -1 on overflow.
|
||||
// The following constants are version numbers of X.509-related structures. Note
|
||||
// APIs typically return the numerical value of X.509 versions, which are one
|
||||
// less than the named version.
|
||||
#define X509V1_VERSION 0
|
||||
#define X509V2_VERSION 1
|
||||
#define X509V3_VERSION 2
|
||||
|
||||
// X509_get_version returns the numerical value of |x509|'s version. Callers may
|
||||
// compare the result to the |X509V*_VERSION| constants. Unknown versions are
|
||||
// rejected by the parser, but a manually-created |X509| object may encode
|
||||
// invalid versions. In that case, the function will return the invalid version,
|
||||
// or -1 on overflow.
|
||||
OPENSSL_EXPORT long X509_get_version(const X509 *x509);
|
||||
|
||||
// X509_set_version sets |x509|'s version to |version|, which should be one of
|
||||
// the |X509V*_VERSION| constants. It returns one on success and zero on error.
|
||||
//
|
||||
// If unsure, use |X509V3_VERSION|.
|
||||
OPENSSL_EXPORT int X509_set_version(X509 *x509, long version);
|
||||
|
||||
// X509_get0_serialNumber returns |x509|'s serial number.
|
||||
OPENSSL_EXPORT const ASN1_INTEGER *X509_get0_serialNumber(const X509 *x509);
|
||||
|
||||
// X509_set_serialNumber sets |x509|'s serial number to |serial|. It returns one
|
||||
// on success and zero on error.
|
||||
OPENSSL_EXPORT int X509_set_serialNumber(X509 *x509,
|
||||
const ASN1_INTEGER *serial);
|
||||
|
||||
// X509_get0_notBefore returns |x509|'s notBefore time.
|
||||
OPENSSL_EXPORT const ASN1_TIME *X509_get0_notBefore(const X509 *x509);
|
||||
|
||||
@@ -550,9 +563,9 @@ OPENSSL_EXPORT X509_CINF *X509_get_cert_info(const X509 *x509);
|
||||
// |EXFLAG_INVALID| bit.
|
||||
OPENSSL_EXPORT long X509_get_pathlen(X509 *x509);
|
||||
|
||||
// X509_REQ_get_version returns the numerical value of |req|'s version. That is,
|
||||
// it returns zero for a v1 request. If |req| is invalid, it may return another
|
||||
// value, or -1 on overflow.
|
||||
// X509_REQ_get_version returns the numerical value of |req|'s version. Callers
|
||||
// may compare the result to |X509V*_VERSION| constants. If |req| is invalid, it
|
||||
// may return another value, or -1 on overflow.
|
||||
OPENSSL_EXPORT long X509_REQ_get_version(const X509_REQ *req);
|
||||
|
||||
// X509_REQ_get_subject_name returns |req|'s subject name. Note this function is
|
||||
@@ -565,9 +578,9 @@ OPENSSL_EXPORT X509_NAME *X509_REQ_get_subject_name(const X509_REQ *req);
|
||||
// X509_name_cmp is a legacy alias for |X509_NAME_cmp|.
|
||||
#define X509_name_cmp(a, b) X509_NAME_cmp((a), (b))
|
||||
|
||||
// X509_REQ_get_version returns the numerical value of |crl|'s version. That is,
|
||||
// it returns zero for a v1 CRL and one for a v2 CRL. If |crl| is invalid, it
|
||||
// may return another value, or -1 on overflow.
|
||||
// X509_CRL_get_version returns the numerical value of |crl|'s version. Callers
|
||||
// may compare the result to |X509V*_VERSION| constants. If |crl| is invalid,
|
||||
// it may return another value, or -1 on overflow.
|
||||
OPENSSL_EXPORT long X509_CRL_get_version(const X509_CRL *crl);
|
||||
|
||||
// X509_CRL_get0_lastUpdate returns |crl|'s lastUpdate time.
|
||||
@@ -923,7 +936,6 @@ OPENSSL_EXPORT const char *X509_get_default_private_dir(void);
|
||||
|
||||
OPENSSL_EXPORT X509_REQ *X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey,
|
||||
const EVP_MD *md);
|
||||
OPENSSL_EXPORT X509 *X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey);
|
||||
|
||||
DECLARE_ASN1_ENCODE_FUNCTIONS(X509_ALGORS, X509_ALGORS, X509_ALGORS)
|
||||
DECLARE_ASN1_FUNCTIONS(X509_VAL)
|
||||
@@ -955,8 +967,8 @@ DECLARE_ASN1_FUNCTIONS(X509_CINF)
|
||||
DECLARE_ASN1_FUNCTIONS(X509)
|
||||
DECLARE_ASN1_FUNCTIONS(X509_CERT_AUX)
|
||||
|
||||
// X509_up_ref adds one to the reference count of |x| and returns one.
|
||||
OPENSSL_EXPORT int X509_up_ref(X509 *x);
|
||||
// X509_up_ref adds one to the reference count of |x509| and returns one.
|
||||
OPENSSL_EXPORT int X509_up_ref(X509 *x509);
|
||||
|
||||
OPENSSL_EXPORT int X509_get_ex_new_index(long argl, void *argp,
|
||||
CRYPTO_EX_unused *unused,
|
||||
@@ -1014,9 +1026,22 @@ OPENSSL_EXPORT int X509_set1_signature_algo(X509 *x509, const X509_ALGOR *algo);
|
||||
OPENSSL_EXPORT int X509_set1_signature_value(X509 *x509, const uint8_t *sig,
|
||||
size_t sig_len);
|
||||
|
||||
OPENSSL_EXPORT void X509_get0_signature(const ASN1_BIT_STRING **psig,
|
||||
const X509_ALGOR **palg, const X509 *x);
|
||||
OPENSSL_EXPORT int X509_get_signature_nid(const X509 *x);
|
||||
// X509_get0_signature sets |*out_sig| and |*out_alg| to the signature and
|
||||
// signature algorithm of |x509|, respectively. Either output pointer may be
|
||||
// NULL to ignore the value.
|
||||
//
|
||||
// This function outputs the outer signature algorithm. For the one in the
|
||||
// TBSCertificate, see |X509_get0_tbs_sigalg|. Certificates with mismatched
|
||||
// signature algorithms will successfully parse, but they will be rejected when
|
||||
// verifying.
|
||||
OPENSSL_EXPORT void X509_get0_signature(const ASN1_BIT_STRING **out_sig,
|
||||
const X509_ALGOR **out_alg,
|
||||
const X509 *x509);
|
||||
|
||||
// X509_get_signature_nid returns the NID corresponding to |x509|'s signature
|
||||
// algorithm, or |NID_undef| if the signature algorithm does not correspond to
|
||||
// a known NID.
|
||||
OPENSSL_EXPORT int X509_get_signature_nid(const X509 *x509);
|
||||
|
||||
OPENSSL_EXPORT int X509_alias_set1(X509 *x, const unsigned char *name, int len);
|
||||
OPENSSL_EXPORT int X509_keyid_set1(X509 *x, const unsigned char *id, int len);
|
||||
@@ -1071,8 +1096,6 @@ OPENSSL_EXPORT int ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1,
|
||||
ASN1_BIT_STRING *signature, void *asn,
|
||||
EVP_MD_CTX *ctx);
|
||||
|
||||
OPENSSL_EXPORT int X509_set_version(X509 *x, long version);
|
||||
OPENSSL_EXPORT int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial);
|
||||
OPENSSL_EXPORT ASN1_INTEGER *X509_get_serialNumber(X509 *x);
|
||||
OPENSSL_EXPORT int X509_set_issuer_name(X509 *x, X509_NAME *name);
|
||||
OPENSSL_EXPORT X509_NAME *X509_get_issuer_name(const X509 *a);
|
||||
@@ -1083,14 +1106,33 @@ OPENSSL_EXPORT EVP_PKEY *X509_get_pubkey(X509 *x);
|
||||
OPENSSL_EXPORT ASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x);
|
||||
OPENSSL_EXPORT const STACK_OF(X509_EXTENSION) *X509_get0_extensions(
|
||||
const X509 *x);
|
||||
OPENSSL_EXPORT const X509_ALGOR *X509_get0_tbs_sigalg(const X509 *x);
|
||||
|
||||
OPENSSL_EXPORT int X509_REQ_set_version(X509_REQ *x, long version);
|
||||
// X509_get0_tbs_sigalg returns the signature algorithm in |x509|'s
|
||||
// TBSCertificate. For the outer signature algorithm, see |X509_get0_signature|.
|
||||
//
|
||||
// Certificates with mismatched signature algorithms will successfully parse,
|
||||
// but they will be rejected when verifying.
|
||||
OPENSSL_EXPORT const X509_ALGOR *X509_get0_tbs_sigalg(const X509 *x509);
|
||||
|
||||
// X509_REQ_set_version sets |req|'s version to |version|, which should be
|
||||
// |X509V1_VERSION|. It returns one on success and zero on error.
|
||||
//
|
||||
// Note no versions other than |X509V1_VERSION| are defined for CSRs.
|
||||
OPENSSL_EXPORT int X509_REQ_set_version(X509_REQ *req, long version);
|
||||
OPENSSL_EXPORT int X509_REQ_set_subject_name(X509_REQ *req, X509_NAME *name);
|
||||
|
||||
// X509_REQ_get0_signature sets |*out_sig| and |*out_alg| to the signature and
|
||||
// signature algorithm of |req|, respectively. Either output pointer may be NULL
|
||||
// to ignore the value.
|
||||
OPENSSL_EXPORT void X509_REQ_get0_signature(const X509_REQ *req,
|
||||
const ASN1_BIT_STRING **psig,
|
||||
const X509_ALGOR **palg);
|
||||
const ASN1_BIT_STRING **out_sig,
|
||||
const X509_ALGOR **out_alg);
|
||||
|
||||
// X509_REQ_get_signature_nid returns the NID corresponding to |req|'s signature
|
||||
// algorithm, or |NID_undef| if the signature algorithm does not correspond to
|
||||
// a known NID.
|
||||
OPENSSL_EXPORT int X509_REQ_get_signature_nid(const X509_REQ *req);
|
||||
|
||||
OPENSSL_EXPORT int i2d_re_X509_REQ_tbs(X509_REQ *req, unsigned char **pp);
|
||||
OPENSSL_EXPORT int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey);
|
||||
OPENSSL_EXPORT EVP_PKEY *X509_REQ_get_pubkey(X509_REQ *req);
|
||||
@@ -1123,14 +1165,33 @@ OPENSSL_EXPORT int X509_REQ_add1_attr_by_txt(X509_REQ *req,
|
||||
const unsigned char *bytes,
|
||||
int len);
|
||||
|
||||
OPENSSL_EXPORT int X509_CRL_set_version(X509_CRL *x, long version);
|
||||
// X509_CRL_set_version sets |crl|'s version to |version|, which should be one
|
||||
// of the |X509V*_VERSION| constants. It returns one on success and zero on
|
||||
// error.
|
||||
//
|
||||
// If unsure, use |X509V2_VERSION|. Note |X509V3_VERSION| is not defined for
|
||||
// CRLs.
|
||||
OPENSSL_EXPORT int X509_CRL_set_version(X509_CRL *crl, long version);
|
||||
OPENSSL_EXPORT int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name);
|
||||
OPENSSL_EXPORT int X509_CRL_sort(X509_CRL *crl);
|
||||
|
||||
// X509_CRL_up_ref adds one to the reference count of |crl| and returns one.
|
||||
OPENSSL_EXPORT int X509_CRL_up_ref(X509_CRL *crl);
|
||||
|
||||
// X509_CRL_get0_signature sets |*out_sig| and |*out_alg| to the signature and
|
||||
// signature algorithm of |crl|, respectively. Either output pointer may be NULL
|
||||
// to ignore the value.
|
||||
//
|
||||
// This function outputs the outer signature algorithm, not the one in the
|
||||
// TBSCertList. CRLs with mismatched signature algorithms will successfully
|
||||
// parse, but they will be rejected when verifying.
|
||||
OPENSSL_EXPORT void X509_CRL_get0_signature(const X509_CRL *crl,
|
||||
const ASN1_BIT_STRING **psig,
|
||||
const X509_ALGOR **palg);
|
||||
const ASN1_BIT_STRING **out_sig,
|
||||
const X509_ALGOR **out_alg);
|
||||
|
||||
// X509_CRL_get_signature_nid returns the NID corresponding to |crl|'s signature
|
||||
// algorithm, or |NID_undef| if the signature algorithm does not correspond to
|
||||
// a known NID.
|
||||
OPENSSL_EXPORT int X509_CRL_get_signature_nid(const X509_CRL *crl);
|
||||
|
||||
// i2d_re_X509_CRL_tbs serializes the TBSCertList portion of |crl|. If |outp| is
|
||||
@@ -1198,10 +1259,14 @@ OPENSSL_EXPORT int X509_chain_check_suiteb(int *perror_depth, X509 *x,
|
||||
unsigned long flags);
|
||||
OPENSSL_EXPORT int X509_CRL_check_suiteb(X509_CRL *crl, EVP_PKEY *pk,
|
||||
unsigned long flags);
|
||||
|
||||
// X509_chain_up_ref returns a newly-allocated |STACK_OF(X509)| containing a
|
||||
// shallow copy of |chain|, or NULL on error. That is, the return value has the
|
||||
// same contents as |chain|, and each |X509|'s reference count is incremented by
|
||||
// one.
|
||||
OPENSSL_EXPORT STACK_OF(X509) *X509_chain_up_ref(STACK_OF(X509) *chain);
|
||||
|
||||
OPENSSL_EXPORT int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b);
|
||||
OPENSSL_EXPORT unsigned long X509_issuer_and_serial_hash(X509 *a);
|
||||
|
||||
OPENSSL_EXPORT int X509_issuer_name_cmp(const X509 *a, const X509 *b);
|
||||
OPENSSL_EXPORT unsigned long X509_issuer_name_hash(X509 *a);
|
||||
|
||||
@@ -910,6 +910,8 @@ BORINGSSL_MAKE_DELETER(AUTHORITY_KEYID, AUTHORITY_KEYID_free)
|
||||
BORINGSSL_MAKE_DELETER(BASIC_CONSTRAINTS, BASIC_CONSTRAINTS_free)
|
||||
BORINGSSL_MAKE_DELETER(DIST_POINT, DIST_POINT_free)
|
||||
BORINGSSL_MAKE_DELETER(GENERAL_NAME, GENERAL_NAME_free)
|
||||
BORINGSSL_MAKE_DELETER(NAME_CONSTRAINTS, NAME_CONSTRAINTS_free)
|
||||
BORINGSSL_MAKE_DELETER(POLICY_MAPPING, POLICY_MAPPING_free)
|
||||
BORINGSSL_MAKE_DELETER(POLICYINFO, POLICYINFO_free)
|
||||
|
||||
BSSL_NAMESPACE_END
|
||||
|
||||
@@ -593,8 +593,8 @@
|
||||
%xdefine _CRYPTO_has_asm _ %+ BORINGSSL_PREFIX %+ _CRYPTO_has_asm
|
||||
%xdefine _CRYPTO_hchacha20 _ %+ BORINGSSL_PREFIX %+ _CRYPTO_hchacha20
|
||||
%xdefine _CRYPTO_init_sysrand _ %+ BORINGSSL_PREFIX %+ _CRYPTO_init_sysrand
|
||||
%xdefine _CRYPTO_is_ARMv8_AES_capable _ %+ BORINGSSL_PREFIX %+ _CRYPTO_is_ARMv8_AES_capable
|
||||
%xdefine _CRYPTO_is_ARMv8_PMULL_capable _ %+ BORINGSSL_PREFIX %+ _CRYPTO_is_ARMv8_PMULL_capable
|
||||
%xdefine _CRYPTO_is_ARMv8_AES_capable_at_runtime _ %+ BORINGSSL_PREFIX %+ _CRYPTO_is_ARMv8_AES_capable_at_runtime
|
||||
%xdefine _CRYPTO_is_ARMv8_PMULL_capable_at_runtime _ %+ BORINGSSL_PREFIX %+ _CRYPTO_is_ARMv8_PMULL_capable_at_runtime
|
||||
%xdefine _CRYPTO_is_NEON_capable_at_runtime _ %+ BORINGSSL_PREFIX %+ _CRYPTO_is_NEON_capable_at_runtime
|
||||
%xdefine _CRYPTO_is_confidential_build _ %+ BORINGSSL_PREFIX %+ _CRYPTO_is_confidential_build
|
||||
%xdefine _CRYPTO_library_init _ %+ BORINGSSL_PREFIX %+ _CRYPTO_library_init
|
||||
@@ -653,6 +653,7 @@
|
||||
%xdefine _DH_get0_priv_key _ %+ BORINGSSL_PREFIX %+ _DH_get0_priv_key
|
||||
%xdefine _DH_get0_pub_key _ %+ BORINGSSL_PREFIX %+ _DH_get0_pub_key
|
||||
%xdefine _DH_get0_q _ %+ BORINGSSL_PREFIX %+ _DH_get0_q
|
||||
%xdefine _DH_get_rfc7919_2048 _ %+ BORINGSSL_PREFIX %+ _DH_get_rfc7919_2048
|
||||
%xdefine _DH_marshal_parameters _ %+ BORINGSSL_PREFIX %+ _DH_marshal_parameters
|
||||
%xdefine _DH_new _ %+ BORINGSSL_PREFIX %+ _DH_new
|
||||
%xdefine _DH_num_bits _ %+ BORINGSSL_PREFIX %+ _DH_num_bits
|
||||
@@ -728,6 +729,7 @@
|
||||
%xdefine _ECDSA_do_sign _ %+ BORINGSSL_PREFIX %+ _ECDSA_do_sign
|
||||
%xdefine _ECDSA_do_verify _ %+ BORINGSSL_PREFIX %+ _ECDSA_do_verify
|
||||
%xdefine _ECDSA_sign _ %+ BORINGSSL_PREFIX %+ _ECDSA_sign
|
||||
%xdefine _ECDSA_sign_with_nonce_and_leak_private_key_for_testing _ %+ BORINGSSL_PREFIX %+ _ECDSA_sign_with_nonce_and_leak_private_key_for_testing
|
||||
%xdefine _ECDSA_size _ %+ BORINGSSL_PREFIX %+ _ECDSA_size
|
||||
%xdefine _ECDSA_verify _ %+ BORINGSSL_PREFIX %+ _ECDSA_verify
|
||||
%xdefine _EC_GFp_mont_method _ %+ BORINGSSL_PREFIX %+ _EC_GFp_mont_method
|
||||
@@ -739,6 +741,7 @@
|
||||
%xdefine _EC_GROUP_free _ %+ BORINGSSL_PREFIX %+ _EC_GROUP_free
|
||||
%xdefine _EC_GROUP_get0_generator _ %+ BORINGSSL_PREFIX %+ _EC_GROUP_get0_generator
|
||||
%xdefine _EC_GROUP_get0_order _ %+ BORINGSSL_PREFIX %+ _EC_GROUP_get0_order
|
||||
%xdefine _EC_GROUP_get_asn1_flag _ %+ BORINGSSL_PREFIX %+ _EC_GROUP_get_asn1_flag
|
||||
%xdefine _EC_GROUP_get_cofactor _ %+ BORINGSSL_PREFIX %+ _EC_GROUP_get_cofactor
|
||||
%xdefine _EC_GROUP_get_curve_GFp _ %+ BORINGSSL_PREFIX %+ _EC_GROUP_get_curve_GFp
|
||||
%xdefine _EC_GROUP_get_curve_name _ %+ BORINGSSL_PREFIX %+ _EC_GROUP_get_curve_name
|
||||
@@ -1844,7 +1847,6 @@
|
||||
%xdefine _X509_REQ_set_version _ %+ BORINGSSL_PREFIX %+ _X509_REQ_set_version
|
||||
%xdefine _X509_REQ_sign _ %+ BORINGSSL_PREFIX %+ _X509_REQ_sign
|
||||
%xdefine _X509_REQ_sign_ctx _ %+ BORINGSSL_PREFIX %+ _X509_REQ_sign_ctx
|
||||
%xdefine _X509_REQ_to_X509 _ %+ BORINGSSL_PREFIX %+ _X509_REQ_to_X509
|
||||
%xdefine _X509_REQ_verify _ %+ BORINGSSL_PREFIX %+ _X509_REQ_verify
|
||||
%xdefine _X509_REVOKED_add1_ext_i2d _ %+ BORINGSSL_PREFIX %+ _X509_REVOKED_add1_ext_i2d
|
||||
%xdefine _X509_REVOKED_add_ext _ %+ BORINGSSL_PREFIX %+ _X509_REVOKED_add_ext
|
||||
@@ -2063,7 +2065,6 @@
|
||||
%xdefine _X509_getm_notBefore _ %+ BORINGSSL_PREFIX %+ _X509_getm_notBefore
|
||||
%xdefine _X509_gmtime_adj _ %+ BORINGSSL_PREFIX %+ _X509_gmtime_adj
|
||||
%xdefine _X509_issuer_and_serial_cmp _ %+ BORINGSSL_PREFIX %+ _X509_issuer_and_serial_cmp
|
||||
%xdefine _X509_issuer_and_serial_hash _ %+ BORINGSSL_PREFIX %+ _X509_issuer_and_serial_hash
|
||||
%xdefine _X509_issuer_name_cmp _ %+ BORINGSSL_PREFIX %+ _X509_issuer_name_cmp
|
||||
%xdefine _X509_issuer_name_hash _ %+ BORINGSSL_PREFIX %+ _X509_issuer_name_hash
|
||||
%xdefine _X509_issuer_name_hash_old _ %+ BORINGSSL_PREFIX %+ _X509_issuer_name_hash_old
|
||||
@@ -2488,6 +2489,7 @@
|
||||
%xdefine _ec_set_to_safe_point _ %+ BORINGSSL_PREFIX %+ _ec_set_to_safe_point
|
||||
%xdefine _ec_simple_scalar_inv0_montgomery _ %+ BORINGSSL_PREFIX %+ _ec_simple_scalar_inv0_montgomery
|
||||
%xdefine _ec_simple_scalar_to_montgomery_inv_vartime _ %+ BORINGSSL_PREFIX %+ _ec_simple_scalar_to_montgomery_inv_vartime
|
||||
%xdefine _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_mul_mont _ %+ BORINGSSL_PREFIX %+ _ecp_nistz256_mul_mont
|
||||
%xdefine _ecp_nistz256_neg _ %+ BORINGSSL_PREFIX %+ _ecp_nistz256_neg
|
||||
@@ -3400,8 +3402,8 @@
|
||||
%xdefine CRYPTO_has_asm BORINGSSL_PREFIX %+ _CRYPTO_has_asm
|
||||
%xdefine CRYPTO_hchacha20 BORINGSSL_PREFIX %+ _CRYPTO_hchacha20
|
||||
%xdefine CRYPTO_init_sysrand BORINGSSL_PREFIX %+ _CRYPTO_init_sysrand
|
||||
%xdefine CRYPTO_is_ARMv8_AES_capable BORINGSSL_PREFIX %+ _CRYPTO_is_ARMv8_AES_capable
|
||||
%xdefine CRYPTO_is_ARMv8_PMULL_capable BORINGSSL_PREFIX %+ _CRYPTO_is_ARMv8_PMULL_capable
|
||||
%xdefine CRYPTO_is_ARMv8_AES_capable_at_runtime BORINGSSL_PREFIX %+ _CRYPTO_is_ARMv8_AES_capable_at_runtime
|
||||
%xdefine CRYPTO_is_ARMv8_PMULL_capable_at_runtime BORINGSSL_PREFIX %+ _CRYPTO_is_ARMv8_PMULL_capable_at_runtime
|
||||
%xdefine CRYPTO_is_NEON_capable_at_runtime BORINGSSL_PREFIX %+ _CRYPTO_is_NEON_capable_at_runtime
|
||||
%xdefine CRYPTO_is_confidential_build BORINGSSL_PREFIX %+ _CRYPTO_is_confidential_build
|
||||
%xdefine CRYPTO_library_init BORINGSSL_PREFIX %+ _CRYPTO_library_init
|
||||
@@ -3460,6 +3462,7 @@
|
||||
%xdefine DH_get0_priv_key BORINGSSL_PREFIX %+ _DH_get0_priv_key
|
||||
%xdefine DH_get0_pub_key BORINGSSL_PREFIX %+ _DH_get0_pub_key
|
||||
%xdefine DH_get0_q BORINGSSL_PREFIX %+ _DH_get0_q
|
||||
%xdefine DH_get_rfc7919_2048 BORINGSSL_PREFIX %+ _DH_get_rfc7919_2048
|
||||
%xdefine DH_marshal_parameters BORINGSSL_PREFIX %+ _DH_marshal_parameters
|
||||
%xdefine DH_new BORINGSSL_PREFIX %+ _DH_new
|
||||
%xdefine DH_num_bits BORINGSSL_PREFIX %+ _DH_num_bits
|
||||
@@ -3535,6 +3538,7 @@
|
||||
%xdefine ECDSA_do_sign BORINGSSL_PREFIX %+ _ECDSA_do_sign
|
||||
%xdefine ECDSA_do_verify BORINGSSL_PREFIX %+ _ECDSA_do_verify
|
||||
%xdefine ECDSA_sign BORINGSSL_PREFIX %+ _ECDSA_sign
|
||||
%xdefine ECDSA_sign_with_nonce_and_leak_private_key_for_testing BORINGSSL_PREFIX %+ _ECDSA_sign_with_nonce_and_leak_private_key_for_testing
|
||||
%xdefine ECDSA_size BORINGSSL_PREFIX %+ _ECDSA_size
|
||||
%xdefine ECDSA_verify BORINGSSL_PREFIX %+ _ECDSA_verify
|
||||
%xdefine EC_GFp_mont_method BORINGSSL_PREFIX %+ _EC_GFp_mont_method
|
||||
@@ -3546,6 +3550,7 @@
|
||||
%xdefine EC_GROUP_free BORINGSSL_PREFIX %+ _EC_GROUP_free
|
||||
%xdefine EC_GROUP_get0_generator BORINGSSL_PREFIX %+ _EC_GROUP_get0_generator
|
||||
%xdefine EC_GROUP_get0_order BORINGSSL_PREFIX %+ _EC_GROUP_get0_order
|
||||
%xdefine EC_GROUP_get_asn1_flag BORINGSSL_PREFIX %+ _EC_GROUP_get_asn1_flag
|
||||
%xdefine EC_GROUP_get_cofactor BORINGSSL_PREFIX %+ _EC_GROUP_get_cofactor
|
||||
%xdefine EC_GROUP_get_curve_GFp BORINGSSL_PREFIX %+ _EC_GROUP_get_curve_GFp
|
||||
%xdefine EC_GROUP_get_curve_name BORINGSSL_PREFIX %+ _EC_GROUP_get_curve_name
|
||||
@@ -4651,7 +4656,6 @@
|
||||
%xdefine X509_REQ_set_version BORINGSSL_PREFIX %+ _X509_REQ_set_version
|
||||
%xdefine X509_REQ_sign BORINGSSL_PREFIX %+ _X509_REQ_sign
|
||||
%xdefine X509_REQ_sign_ctx BORINGSSL_PREFIX %+ _X509_REQ_sign_ctx
|
||||
%xdefine X509_REQ_to_X509 BORINGSSL_PREFIX %+ _X509_REQ_to_X509
|
||||
%xdefine X509_REQ_verify BORINGSSL_PREFIX %+ _X509_REQ_verify
|
||||
%xdefine X509_REVOKED_add1_ext_i2d BORINGSSL_PREFIX %+ _X509_REVOKED_add1_ext_i2d
|
||||
%xdefine X509_REVOKED_add_ext BORINGSSL_PREFIX %+ _X509_REVOKED_add_ext
|
||||
@@ -4870,7 +4874,6 @@
|
||||
%xdefine X509_getm_notBefore BORINGSSL_PREFIX %+ _X509_getm_notBefore
|
||||
%xdefine X509_gmtime_adj BORINGSSL_PREFIX %+ _X509_gmtime_adj
|
||||
%xdefine X509_issuer_and_serial_cmp BORINGSSL_PREFIX %+ _X509_issuer_and_serial_cmp
|
||||
%xdefine X509_issuer_and_serial_hash BORINGSSL_PREFIX %+ _X509_issuer_and_serial_hash
|
||||
%xdefine X509_issuer_name_cmp BORINGSSL_PREFIX %+ _X509_issuer_name_cmp
|
||||
%xdefine X509_issuer_name_hash BORINGSSL_PREFIX %+ _X509_issuer_name_hash
|
||||
%xdefine X509_issuer_name_hash_old BORINGSSL_PREFIX %+ _X509_issuer_name_hash_old
|
||||
@@ -5295,6 +5298,7 @@
|
||||
%xdefine ec_set_to_safe_point BORINGSSL_PREFIX %+ _ec_set_to_safe_point
|
||||
%xdefine ec_simple_scalar_inv0_montgomery BORINGSSL_PREFIX %+ _ec_simple_scalar_inv0_montgomery
|
||||
%xdefine ec_simple_scalar_to_montgomery_inv_vartime BORINGSSL_PREFIX %+ _ec_simple_scalar_to_montgomery_inv_vartime
|
||||
%xdefine 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_mul_mont BORINGSSL_PREFIX %+ _ecp_nistz256_mul_mont
|
||||
%xdefine ecp_nistz256_neg BORINGSSL_PREFIX %+ _ecp_nistz256_neg
|
||||
|
||||
@@ -84,13 +84,19 @@ function mangle_symbols {
|
||||
|
||||
# Begin by building for macOS.
|
||||
swift build --product CCryptoBoringSSL --enable-test-discovery
|
||||
go run "${SRCROOT}/util/read_symbols.go" -out "${TMPDIR}/symbols-macOS.txt" "${HERE}/.build/debug/libCCryptoBoringSSL.a"
|
||||
(
|
||||
cd "${SRCROOT}"
|
||||
go run "util/read_symbols.go" -out "${TMPDIR}/symbols-macOS.txt" "${HERE}/.build/debug/libCCryptoBoringSSL.a"
|
||||
)
|
||||
|
||||
# Now build for iOS. We use xcodebuild for this because SwiftPM doesn't
|
||||
# meaningfully support it. Unfortunately we must archive ourselves.
|
||||
xcodebuild -sdk iphoneos -scheme CCryptoBoringSSL -derivedDataPath "${TMPDIR}/iphoneos-deriveddata"
|
||||
ar -r "${TMPDIR}/libCCryptoBoringSSL-ios.a" "${TMPDIR}/iphoneos-deriveddata/Build/Products/Debug-iphoneos/CCryptoBoringSSL.o"
|
||||
go run "${SRCROOT}/util/read_symbols.go" -out "${TMPDIR}/symbols-iOS.txt" "${TMPDIR}/libCCryptoBoringSSL-ios.a"
|
||||
(
|
||||
cd "${SRCROOT}"
|
||||
go run "util/read_symbols.go" -out "${TMPDIR}/symbols-iOS.txt" "${TMPDIR}/libCCryptoBoringSSL-ios.a"
|
||||
)
|
||||
|
||||
# Now cross compile for our targets.
|
||||
# If you have trouble with the script around this point, consider
|
||||
@@ -103,13 +109,19 @@ function mangle_symbols {
|
||||
|
||||
# Now we need to generate symbol mangles for Linux. We can do this in
|
||||
# one go for all of them.
|
||||
go run "${SRCROOT}/util/read_symbols.go" -obj-file-format elf -out "${TMPDIR}/symbols-linux-all.txt" "${HERE}"/.build/*-unknown-linux/debug/libCCryptoBoringSSL.a
|
||||
(
|
||||
cd "${SRCROOT}"
|
||||
go run "util/read_symbols.go" -obj-file-format elf -out "${TMPDIR}/symbols-linux-all.txt" "${HERE}"/.build/*-unknown-linux/debug/libCCryptoBoringSSL.a
|
||||
)
|
||||
|
||||
# Now we concatenate all the symbols together and uniquify it.
|
||||
cat "${TMPDIR}"/symbols-*.txt | sort | uniq > "${TMPDIR}/symbols.txt"
|
||||
|
||||
# Use this as the input to the mangle.
|
||||
go run "${SRCROOT}/util/make_prefix_headers.go" -out "${HERE}/${DSTROOT}/include/openssl" "${TMPDIR}/symbols.txt"
|
||||
(
|
||||
cd "${SRCROOT}"
|
||||
go run "util/make_prefix_headers.go" -out "${HERE}/${DSTROOT}/include/openssl" "${TMPDIR}/symbols.txt"
|
||||
)
|
||||
|
||||
# Remove the product, as we no longer need it.
|
||||
$sed -i -e 's/MANGLE_START\*\//MANGLE_START/' -e 's/\/\*MANGLE_END/MANGLE_END/' "${HERE}/Package.swift"
|
||||
|
||||
Reference in new issue
Block a user