mirror of
https://github.com/apple/swift-nio-ssl
synced 2026-11-26 04:57:52 +00:00
Use .note.GNU-stack section in ASM. (#137)
Motivation:
Well-formed Linux assembly code declares a .note.GNU-stack section in
order to help out the linker. When absent, the linker makes some
suboptimal linking decisions that can cause pain in running programs.
Modifications:
- Amend the vendoring script to add the .note.GNU-stack section to all
assembly files on Linux.
- Updated BoringSSL
Results:
Better linker behaviour.
This commit is contained in:
1 parent
71aa686d58
commit
109faef770
149 files changed
+4445
-1078
No files matched your search
+1
-1
@@ -22,7 +22,7 @@ import PackageDescription
|
||||
// Sources/CNIOBoringSSL directory. The source repository is at
|
||||
// https://boringssl.googlesource.com/boringssl.
|
||||
//
|
||||
// BoringSSL Commit: 9806ae005b3085683a2fcf2953e4170893e0973d
|
||||
// BoringSSL Commit: 6e7255c17e1a7348a2377fbc804441dd284806e2
|
||||
|
||||
let package = Package(
|
||||
name: "swift-nio-ssl",
|
||||
|
||||
@@ -192,7 +192,7 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
|
||||
/* Use indefinite length constructed if requested */
|
||||
if (aclass & ASN1_TFLG_NDEF)
|
||||
ndef = 2;
|
||||
/* fall through */
|
||||
OPENSSL_FALLTHROUGH;
|
||||
|
||||
case ASN1_ITYPE_SEQUENCE:
|
||||
i = asn1_enc_restore(&seqcontlen, out, pval, it);
|
||||
|
||||
@@ -1499,3 +1499,7 @@ OPENSSL_armcap_P:
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__arm__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -1493,3 +1493,7 @@ ChaCha20_neon:
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__arm__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -1983,3 +1983,7 @@ Ldone_512_neon:
|
||||
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__aarch64__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -1985,3 +1985,7 @@ ChaCha20_512_neon:
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__aarch64__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -975,3 +975,7 @@ ChaCha20_ssse3:
|
||||
.byte 114,103,62,0
|
||||
#endif
|
||||
#endif // defined(__i386__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -1633,3 +1633,7 @@ ChaCha20_8x:
|
||||
.size ChaCha20_8x,.-ChaCha20_8x
|
||||
#endif
|
||||
#endif // defined(__x86_64__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -1626,3 +1626,7 @@ L$8x_epilogue:
|
||||
|
||||
#endif
|
||||
#endif // defined(__x86_64__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -3079,3 +3079,7 @@ aes256gcmsiv_kdf:
|
||||
.size aes256gcmsiv_kdf, .-aes256gcmsiv_kdf
|
||||
#endif
|
||||
#endif // defined(__x86_64__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -3069,3 +3069,7 @@ _aes256gcmsiv_kdf:
|
||||
|
||||
#endif
|
||||
#endif // defined(__x86_64__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -8987,3 +8987,7 @@ seal_avx2_short_tail:
|
||||
.cfi_endproc
|
||||
#endif
|
||||
#endif // defined(__x86_64__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -8986,3 +8986,7 @@ seal_avx2_short_tail:
|
||||
|
||||
#endif
|
||||
#endif // defined(__x86_64__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -164,17 +164,23 @@ void OPENSSL_cpuid_setup(void) {
|
||||
if (is_amd) {
|
||||
// See https://www.amd.com/system/files/TechDocs/25481.pdf, page 10.
|
||||
const uint32_t base_family = (eax >> 8) & 15;
|
||||
const uint32_t base_model = (eax >> 4) & 15;
|
||||
|
||||
uint32_t family = base_family;
|
||||
uint32_t model = base_model;
|
||||
if (base_family == 0xf) {
|
||||
const uint32_t ext_family = (eax >> 20) & 255;
|
||||
family += ext_family;
|
||||
const uint32_t ext_model = (eax >> 16) & 15;
|
||||
model |= ext_model << 4;
|
||||
}
|
||||
|
||||
if (family < 0x17) {
|
||||
if (family < 0x17 || (family == 0x17 && 0x70 <= model && model <= 0x7f)) {
|
||||
// Disable RDRAND on AMD families before 0x17 (Zen) due to reported
|
||||
// failures after suspend.
|
||||
// https://bugzilla.redhat.com/show_bug.cgi?id=1150286
|
||||
// Also disable for family 0x17, models 0x70–0x7f, due to possible RDRAND
|
||||
// failures there too.
|
||||
ecx &= ~(1u << 30);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
// that tests the capability values will still skip the constructor but, so
|
||||
// far, the init constructor function only sets the capability variables.
|
||||
|
||||
#if !defined(NDEBUG) && !defined(BORINGSSL_FIPS)
|
||||
#if defined(BORINGSSL_DISPATCH_TEST)
|
||||
// This value must be explicitly initialised to zero in order to work around a
|
||||
// bug in libtool or the linker on OS X.
|
||||
//
|
||||
|
||||
@@ -2133,3 +2133,7 @@ bx lr
|
||||
|
||||
#endif /* !OPENSSL_NO_ASM && __arm__ && !__APPLE__ */
|
||||
#endif // defined(__arm__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -79,7 +79,7 @@
|
||||
#define OPENSSL_DSA_MAX_MODULUS_BITS 10000
|
||||
|
||||
// Primality test according to FIPS PUB 186[-1], Appendix 2.1: 50 rounds of
|
||||
// Rabin-Miller
|
||||
// Miller-Rabin.
|
||||
#define DSS_prime_checks 50
|
||||
|
||||
static int dsa_sign_setup(const DSA *dsa, BN_CTX *ctx_in, BIGNUM **out_kinv,
|
||||
|
||||
@@ -264,7 +264,8 @@ static int parse_explicit_prime_curve(CBS *in, CBS *out_prime, CBS *out_a,
|
||||
CBS *out_base_y, CBS *out_order) {
|
||||
// See RFC 3279, section 2.3.5. Note that RFC 3279 calls this structure an
|
||||
// ECParameters while RFC 5480 calls it a SpecifiedECDomain.
|
||||
CBS params, field_id, field_type, curve, base;
|
||||
CBS params, field_id, field_type, curve, base, cofactor;
|
||||
int has_cofactor;
|
||||
uint64_t version;
|
||||
if (!CBS_get_asn1(in, ¶ms, CBS_ASN1_SEQUENCE) ||
|
||||
!CBS_get_asn1_uint64(¶ms, &version) ||
|
||||
@@ -272,7 +273,8 @@ static int parse_explicit_prime_curve(CBS *in, CBS *out_prime, CBS *out_a,
|
||||
!CBS_get_asn1(¶ms, &field_id, CBS_ASN1_SEQUENCE) ||
|
||||
!CBS_get_asn1(&field_id, &field_type, CBS_ASN1_OBJECT) ||
|
||||
CBS_len(&field_type) != sizeof(kPrimeField) ||
|
||||
OPENSSL_memcmp(CBS_data(&field_type), kPrimeField, sizeof(kPrimeField)) != 0 ||
|
||||
OPENSSL_memcmp(CBS_data(&field_type), kPrimeField, sizeof(kPrimeField)) !=
|
||||
0 ||
|
||||
!CBS_get_asn1(&field_id, out_prime, CBS_ASN1_INTEGER) ||
|
||||
!is_unsigned_integer(out_prime) ||
|
||||
CBS_len(&field_id) != 0 ||
|
||||
@@ -280,16 +282,26 @@ static int parse_explicit_prime_curve(CBS *in, CBS *out_prime, CBS *out_a,
|
||||
!CBS_get_asn1(&curve, out_a, CBS_ASN1_OCTETSTRING) ||
|
||||
!CBS_get_asn1(&curve, out_b, CBS_ASN1_OCTETSTRING) ||
|
||||
// |curve| has an optional BIT STRING seed which we ignore.
|
||||
!CBS_get_optional_asn1(&curve, NULL, NULL, CBS_ASN1_BITSTRING) ||
|
||||
CBS_len(&curve) != 0 ||
|
||||
!CBS_get_asn1(¶ms, &base, CBS_ASN1_OCTETSTRING) ||
|
||||
!CBS_get_asn1(¶ms, out_order, CBS_ASN1_INTEGER) ||
|
||||
!is_unsigned_integer(out_order)) {
|
||||
!is_unsigned_integer(out_order) ||
|
||||
!CBS_get_optional_asn1(¶ms, &cofactor, &has_cofactor,
|
||||
CBS_ASN1_INTEGER) ||
|
||||
CBS_len(¶ms) != 0) {
|
||||
OPENSSL_PUT_ERROR(EC, EC_R_DECODE_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// |params| has an optional cofactor which we ignore. With the optional seed
|
||||
// in |curve|, a group already has arbitrarily many encodings. Parse enough to
|
||||
// uniquely determine the curve.
|
||||
if (has_cofactor) {
|
||||
// We only support prime-order curves so the cofactor must be one.
|
||||
if (CBS_len(&cofactor) != 1 ||
|
||||
CBS_data(&cofactor)[0] != 1) {
|
||||
OPENSSL_PUT_ERROR(EC, EC_R_UNKNOWN_GROUP);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Require that the base point use uncompressed form.
|
||||
uint8_t form;
|
||||
|
||||
@@ -75,54 +75,54 @@ const uint32_t kOpenSSLReasonValues[] = {
|
||||
0xc3b00ea,
|
||||
0xc3b88d6,
|
||||
0x10320847,
|
||||
0x10329585,
|
||||
0x10331591,
|
||||
0x103395aa,
|
||||
0x103415bd,
|
||||
0x1032959f,
|
||||
0x103315ab,
|
||||
0x103395c4,
|
||||
0x103415d7,
|
||||
0x10348f27,
|
||||
0x10350c60,
|
||||
0x103595d0,
|
||||
0x103615fa,
|
||||
0x1036960d,
|
||||
0x1037162c,
|
||||
0x10379645,
|
||||
0x1038165a,
|
||||
0x10389678,
|
||||
0x10391687,
|
||||
0x103996a3,
|
||||
0x103a16be,
|
||||
0x103a96cd,
|
||||
0x103b16e9,
|
||||
0x103b9704,
|
||||
0x103c172a,
|
||||
0x103595ea,
|
||||
0x10361614,
|
||||
0x10369627,
|
||||
0x10371646,
|
||||
0x1037965f,
|
||||
0x10381674,
|
||||
0x10389692,
|
||||
0x103916a1,
|
||||
0x103996bd,
|
||||
0x103a16d8,
|
||||
0x103a96e7,
|
||||
0x103b1703,
|
||||
0x103b971e,
|
||||
0x103c1744,
|
||||
0x103c80ea,
|
||||
0x103d173b,
|
||||
0x103d974f,
|
||||
0x103e176e,
|
||||
0x103e977d,
|
||||
0x103f1794,
|
||||
0x103f97a7,
|
||||
0x103d1755,
|
||||
0x103d9769,
|
||||
0x103e1788,
|
||||
0x103e9797,
|
||||
0x103f17ae,
|
||||
0x103f97c1,
|
||||
0x10400c24,
|
||||
0x104097ba,
|
||||
0x104117d8,
|
||||
0x104197eb,
|
||||
0x10421805,
|
||||
0x10429815,
|
||||
0x10431829,
|
||||
0x1043983f,
|
||||
0x10441857,
|
||||
0x1044986c,
|
||||
0x10451880,
|
||||
0x10459892,
|
||||
0x104097d4,
|
||||
0x104117f2,
|
||||
0x10419805,
|
||||
0x1042181f,
|
||||
0x1042982f,
|
||||
0x10431843,
|
||||
0x10439859,
|
||||
0x10441871,
|
||||
0x10449886,
|
||||
0x1045189a,
|
||||
0x104598ac,
|
||||
0x104605fd,
|
||||
0x1046894f,
|
||||
0x104718a7,
|
||||
0x104798be,
|
||||
0x104818d3,
|
||||
0x104898e1,
|
||||
0x104718c1,
|
||||
0x104798d8,
|
||||
0x104818ed,
|
||||
0x104898fb,
|
||||
0x10490e73,
|
||||
0x1049971b,
|
||||
0x104a15e5,
|
||||
0x10499735,
|
||||
0x104a15ff,
|
||||
0x14320c07,
|
||||
0x14328c15,
|
||||
0x14330c24,
|
||||
@@ -148,39 +148,40 @@ const uint32_t kOpenSSLReasonValues[] = {
|
||||
0x183a1091,
|
||||
0x183a90b7,
|
||||
0x183b0c7f,
|
||||
0x183b90ec,
|
||||
0x183c10fe,
|
||||
0x183c9109,
|
||||
0x183d1119,
|
||||
0x183d912a,
|
||||
0x183e113b,
|
||||
0x183e914d,
|
||||
0x183f1176,
|
||||
0x183f918f,
|
||||
0x184011a7,
|
||||
0x183b9106,
|
||||
0x183c1118,
|
||||
0x183c9123,
|
||||
0x183d1133,
|
||||
0x183d9144,
|
||||
0x183e1155,
|
||||
0x183e9167,
|
||||
0x183f1190,
|
||||
0x183f91a9,
|
||||
0x184011c1,
|
||||
0x184086d5,
|
||||
0x184110da,
|
||||
0x184190a5,
|
||||
0x184210c4,
|
||||
0x18428c6c,
|
||||
0x18431080,
|
||||
0x203211e1,
|
||||
0x203291ce,
|
||||
0x243211ed,
|
||||
0x184390ec,
|
||||
0x203211fb,
|
||||
0x203291e8,
|
||||
0x24321207,
|
||||
0x24328995,
|
||||
0x243311ff,
|
||||
0x2433920c,
|
||||
0x24341219,
|
||||
0x2434922b,
|
||||
0x2435123a,
|
||||
0x24359257,
|
||||
0x24361264,
|
||||
0x24369272,
|
||||
0x24371280,
|
||||
0x2437928e,
|
||||
0x24381297,
|
||||
0x243892a4,
|
||||
0x243912b7,
|
||||
0x24331219,
|
||||
0x24339226,
|
||||
0x24341233,
|
||||
0x24349245,
|
||||
0x24351254,
|
||||
0x24359271,
|
||||
0x2436127e,
|
||||
0x2436928c,
|
||||
0x2437129a,
|
||||
0x243792a8,
|
||||
0x243812b1,
|
||||
0x243892be,
|
||||
0x243912d1,
|
||||
0x28320c54,
|
||||
0x28328c7f,
|
||||
0x28330c24,
|
||||
@@ -189,44 +190,44 @@ const uint32_t kOpenSSLReasonValues[] = {
|
||||
0x283480ac,
|
||||
0x283500ea,
|
||||
0x28358c6c,
|
||||
0x2c322ef2,
|
||||
0x2c3292ce,
|
||||
0x2c332f00,
|
||||
0x2c33af12,
|
||||
0x2c342f26,
|
||||
0x2c34af38,
|
||||
0x2c352f53,
|
||||
0x2c35af65,
|
||||
0x2c362f78,
|
||||
0x2c322f0c,
|
||||
0x2c3292e8,
|
||||
0x2c332f1a,
|
||||
0x2c33af2c,
|
||||
0x2c342f40,
|
||||
0x2c34af52,
|
||||
0x2c352f6d,
|
||||
0x2c35af7f,
|
||||
0x2c362f92,
|
||||
0x2c36832d,
|
||||
0x2c372f85,
|
||||
0x2c37af97,
|
||||
0x2c382fbc,
|
||||
0x2c38afd3,
|
||||
0x2c392fe1,
|
||||
0x2c39aff1,
|
||||
0x2c3a3003,
|
||||
0x2c3ab017,
|
||||
0x2c3b3028,
|
||||
0x2c3bb047,
|
||||
0x2c3c12e0,
|
||||
0x2c3c92f6,
|
||||
0x2c3d305b,
|
||||
0x2c3d930f,
|
||||
0x2c3e3078,
|
||||
0x2c3eb086,
|
||||
0x2c3f309e,
|
||||
0x2c3fb0b6,
|
||||
0x2c4030e0,
|
||||
0x2c4091e1,
|
||||
0x2c4130f1,
|
||||
0x2c41b104,
|
||||
0x2c4211a7,
|
||||
0x2c42b115,
|
||||
0x2c372f9f,
|
||||
0x2c37afb1,
|
||||
0x2c382fd6,
|
||||
0x2c38afed,
|
||||
0x2c392ffb,
|
||||
0x2c39b00b,
|
||||
0x2c3a301d,
|
||||
0x2c3ab031,
|
||||
0x2c3b3042,
|
||||
0x2c3bb061,
|
||||
0x2c3c12fa,
|
||||
0x2c3c9310,
|
||||
0x2c3d3075,
|
||||
0x2c3d9329,
|
||||
0x2c3e3092,
|
||||
0x2c3eb0a0,
|
||||
0x2c3f30b8,
|
||||
0x2c3fb0d0,
|
||||
0x2c4030fa,
|
||||
0x2c4091fb,
|
||||
0x2c41310b,
|
||||
0x2c41b11e,
|
||||
0x2c4211c1,
|
||||
0x2c42b12f,
|
||||
0x2c430722,
|
||||
0x2c43b039,
|
||||
0x2c442faa,
|
||||
0x2c44b0c3,
|
||||
0x2c43b053,
|
||||
0x2c442fc4,
|
||||
0x2c44b0dd,
|
||||
0x30320000,
|
||||
0x30328015,
|
||||
0x3033001f,
|
||||
@@ -361,241 +362,241 @@ const uint32_t kOpenSSLReasonValues[] = {
|
||||
0x3c418d67,
|
||||
0x3c420e73,
|
||||
0x3c428dfd,
|
||||
0x40321957,
|
||||
0x4032996d,
|
||||
0x4033199b,
|
||||
0x403399a5,
|
||||
0x403419bc,
|
||||
0x403499da,
|
||||
0x403519ea,
|
||||
0x403599fc,
|
||||
0x40361a09,
|
||||
0x40369a15,
|
||||
0x40371a2a,
|
||||
0x40379a3c,
|
||||
0x40381a47,
|
||||
0x40389a59,
|
||||
0x40321971,
|
||||
0x40329987,
|
||||
0x403319b5,
|
||||
0x403399bf,
|
||||
0x403419d6,
|
||||
0x403499f4,
|
||||
0x40351a04,
|
||||
0x40359a16,
|
||||
0x40361a23,
|
||||
0x40369a2f,
|
||||
0x40371a44,
|
||||
0x40379a56,
|
||||
0x40381a61,
|
||||
0x40389a73,
|
||||
0x40390f27,
|
||||
0x40399a69,
|
||||
0x403a1a7c,
|
||||
0x403a9a9d,
|
||||
0x403b1aae,
|
||||
0x403b9abe,
|
||||
0x40399a83,
|
||||
0x403a1a96,
|
||||
0x403a9ab7,
|
||||
0x403b1ac8,
|
||||
0x403b9ad8,
|
||||
0x403c0064,
|
||||
0x403c8083,
|
||||
0x403d1b42,
|
||||
0x403d9b58,
|
||||
0x403e1b67,
|
||||
0x403e9b9f,
|
||||
0x403f1bb9,
|
||||
0x403f9be1,
|
||||
0x40401bf6,
|
||||
0x40409c0a,
|
||||
0x40411c27,
|
||||
0x40419c42,
|
||||
0x40421c5b,
|
||||
0x40429c6e,
|
||||
0x40431c82,
|
||||
0x40439c9a,
|
||||
0x40441cb1,
|
||||
0x403d1b5c,
|
||||
0x403d9b72,
|
||||
0x403e1b81,
|
||||
0x403e9bb9,
|
||||
0x403f1bd3,
|
||||
0x403f9bfb,
|
||||
0x40401c10,
|
||||
0x40409c24,
|
||||
0x40411c41,
|
||||
0x40419c5c,
|
||||
0x40421c75,
|
||||
0x40429c88,
|
||||
0x40431c9c,
|
||||
0x40439cb4,
|
||||
0x40441ccb,
|
||||
0x404480ac,
|
||||
0x40451cc6,
|
||||
0x40459cd8,
|
||||
0x40461cfc,
|
||||
0x40469d1c,
|
||||
0x40471d2a,
|
||||
0x40479d51,
|
||||
0x40481dc2,
|
||||
0x40489df5,
|
||||
0x40491e0c,
|
||||
0x40499e26,
|
||||
0x404a1e3d,
|
||||
0x404a9e5b,
|
||||
0x404b1e73,
|
||||
0x404b9e8a,
|
||||
0x404c1ea0,
|
||||
0x404c9eb2,
|
||||
0x404d1ed3,
|
||||
0x404d9f0c,
|
||||
0x404e1f20,
|
||||
0x404e9f2d,
|
||||
0x404f1f74,
|
||||
0x404f9fba,
|
||||
0x40502011,
|
||||
0x4050a025,
|
||||
0x40512058,
|
||||
0x40522068,
|
||||
0x4052a08c,
|
||||
0x405320a4,
|
||||
0x4053a0b7,
|
||||
0x405420cc,
|
||||
0x4054a0ef,
|
||||
0x405520fd,
|
||||
0x4055a13a,
|
||||
0x40562147,
|
||||
0x4056a160,
|
||||
0x40572178,
|
||||
0x4057a18b,
|
||||
0x405821a0,
|
||||
0x4058a1c7,
|
||||
0x405921f6,
|
||||
0x4059a223,
|
||||
0x405a2237,
|
||||
0x405aa247,
|
||||
0x405b225f,
|
||||
0x405ba270,
|
||||
0x405c2283,
|
||||
0x405ca2c2,
|
||||
0x405d22cf,
|
||||
0x405da2f4,
|
||||
0x405e2332,
|
||||
0x40451ce0,
|
||||
0x40459cf2,
|
||||
0x40461d16,
|
||||
0x40469d36,
|
||||
0x40471d44,
|
||||
0x40479d6b,
|
||||
0x40481ddc,
|
||||
0x40489e0f,
|
||||
0x40491e26,
|
||||
0x40499e40,
|
||||
0x404a1e57,
|
||||
0x404a9e75,
|
||||
0x404b1e8d,
|
||||
0x404b9ea4,
|
||||
0x404c1eba,
|
||||
0x404c9ecc,
|
||||
0x404d1eed,
|
||||
0x404d9f26,
|
||||
0x404e1f3a,
|
||||
0x404e9f47,
|
||||
0x404f1f8e,
|
||||
0x404f9fd4,
|
||||
0x4050202b,
|
||||
0x4050a03f,
|
||||
0x40512072,
|
||||
0x40522082,
|
||||
0x4052a0a6,
|
||||
0x405320be,
|
||||
0x4053a0d1,
|
||||
0x405420e6,
|
||||
0x4054a109,
|
||||
0x40552117,
|
||||
0x4055a154,
|
||||
0x40562161,
|
||||
0x4056a17a,
|
||||
0x40572192,
|
||||
0x4057a1a5,
|
||||
0x405821ba,
|
||||
0x4058a1e1,
|
||||
0x40592210,
|
||||
0x4059a23d,
|
||||
0x405a2251,
|
||||
0x405aa261,
|
||||
0x405b2279,
|
||||
0x405ba28a,
|
||||
0x405c229d,
|
||||
0x405ca2dc,
|
||||
0x405d22e9,
|
||||
0x405da30e,
|
||||
0x405e234c,
|
||||
0x405e8ab3,
|
||||
0x405f2353,
|
||||
0x405fa360,
|
||||
0x4060236e,
|
||||
0x4060a390,
|
||||
0x406123f1,
|
||||
0x4061a429,
|
||||
0x40622440,
|
||||
0x4062a451,
|
||||
0x40632476,
|
||||
0x4063a48b,
|
||||
0x406424a2,
|
||||
0x4064a4ce,
|
||||
0x406524e9,
|
||||
0x4065a500,
|
||||
0x40662518,
|
||||
0x4066a542,
|
||||
0x4067256d,
|
||||
0x4067a5b2,
|
||||
0x406825fa,
|
||||
0x4068a61b,
|
||||
0x4069264d,
|
||||
0x4069a67b,
|
||||
0x406a269c,
|
||||
0x406aa6bc,
|
||||
0x406b2844,
|
||||
0x406ba867,
|
||||
0x406c287d,
|
||||
0x406cab20,
|
||||
0x406d2b4f,
|
||||
0x406dab77,
|
||||
0x406e2ba5,
|
||||
0x406eabf2,
|
||||
0x406f2c2d,
|
||||
0x406fac65,
|
||||
0x40702c78,
|
||||
0x4070ac95,
|
||||
0x405f236d,
|
||||
0x405fa37a,
|
||||
0x40602388,
|
||||
0x4060a3aa,
|
||||
0x4061240b,
|
||||
0x4061a443,
|
||||
0x4062245a,
|
||||
0x4062a46b,
|
||||
0x40632490,
|
||||
0x4063a4a5,
|
||||
0x406424bc,
|
||||
0x4064a4e8,
|
||||
0x40652503,
|
||||
0x4065a51a,
|
||||
0x40662532,
|
||||
0x4066a55c,
|
||||
0x40672587,
|
||||
0x4067a5cc,
|
||||
0x40682614,
|
||||
0x4068a635,
|
||||
0x40692667,
|
||||
0x4069a695,
|
||||
0x406a26b6,
|
||||
0x406aa6d6,
|
||||
0x406b285e,
|
||||
0x406ba881,
|
||||
0x406c2897,
|
||||
0x406cab3a,
|
||||
0x406d2b69,
|
||||
0x406dab91,
|
||||
0x406e2bbf,
|
||||
0x406eac0c,
|
||||
0x406f2c47,
|
||||
0x406fac7f,
|
||||
0x40702c92,
|
||||
0x4070acaf,
|
||||
0x40710802,
|
||||
0x4071aca7,
|
||||
0x40722cba,
|
||||
0x4072acf0,
|
||||
0x40732d08,
|
||||
0x407394e0,
|
||||
0x40742d1c,
|
||||
0x4074ad36,
|
||||
0x40752d47,
|
||||
0x4075ad5b,
|
||||
0x40762d69,
|
||||
0x407692a4,
|
||||
0x40772d8e,
|
||||
0x4077adb0,
|
||||
0x40782dcb,
|
||||
0x4078ae04,
|
||||
0x40792e1b,
|
||||
0x4079ae31,
|
||||
0x407a2e5d,
|
||||
0x407aae70,
|
||||
0x407b2e85,
|
||||
0x407bae97,
|
||||
0x407c2ec8,
|
||||
0x407caed1,
|
||||
0x407d2636,
|
||||
0x407d9fca,
|
||||
0x407e2de0,
|
||||
0x407ea1d7,
|
||||
0x407f1d3e,
|
||||
0x407f9ae4,
|
||||
0x40801f84,
|
||||
0x40809d66,
|
||||
0x4081207a,
|
||||
0x40819f5e,
|
||||
0x40822b90,
|
||||
0x40829aca,
|
||||
0x408321b2,
|
||||
0x4083a4b3,
|
||||
0x40841d7a,
|
||||
0x4084a20f,
|
||||
0x40852294,
|
||||
0x4085a3b8,
|
||||
0x40862314,
|
||||
0x40869fe4,
|
||||
0x40872bd6,
|
||||
0x4087a406,
|
||||
0x40881b2b,
|
||||
0x4088a5c5,
|
||||
0x40891b7a,
|
||||
0x40899b07,
|
||||
0x408a28b5,
|
||||
0x408a98f8,
|
||||
0x408b2eac,
|
||||
0x408bac42,
|
||||
0x408c22a4,
|
||||
0x408c9914,
|
||||
0x408d1ddb,
|
||||
0x408d9dac,
|
||||
0x408e1ef5,
|
||||
0x408ea11a,
|
||||
0x408f25d9,
|
||||
0x408fa3d4,
|
||||
0x4090258e,
|
||||
0x4090a2e6,
|
||||
0x4091289d,
|
||||
0x4091993a,
|
||||
0x40921bc7,
|
||||
0x4092ac11,
|
||||
0x40932cd3,
|
||||
0x40939ff5,
|
||||
0x40941d8e,
|
||||
0x4094a8ce,
|
||||
0x40952462,
|
||||
0x4095ae3d,
|
||||
0x40962bbd,
|
||||
0x40969f9d,
|
||||
0x40972040,
|
||||
0x40979f44,
|
||||
0x41f4276f,
|
||||
0x41f92801,
|
||||
0x41fe26f4,
|
||||
0x41fea911,
|
||||
0x41ff2a02,
|
||||
0x42032788,
|
||||
0x420827aa,
|
||||
0x4208a7e6,
|
||||
0x420926d8,
|
||||
0x4209a820,
|
||||
0x420a272f,
|
||||
0x420aa70f,
|
||||
0x420b274f,
|
||||
0x420ba7c8,
|
||||
0x420c2a1e,
|
||||
0x420ca8de,
|
||||
0x420d28f8,
|
||||
0x420da92f,
|
||||
0x42122949,
|
||||
0x421729e5,
|
||||
0x4217a98b,
|
||||
0x421c29ad,
|
||||
0x421f2968,
|
||||
0x42212a35,
|
||||
0x422629c8,
|
||||
0x422b2b04,
|
||||
0x422baab2,
|
||||
0x422c2aec,
|
||||
0x422caa71,
|
||||
0x422d2a50,
|
||||
0x422daad1,
|
||||
0x422e2a97,
|
||||
0x4071acc1,
|
||||
0x40722cd4,
|
||||
0x4072ad0a,
|
||||
0x40732d22,
|
||||
0x407394fa,
|
||||
0x40742d36,
|
||||
0x4074ad50,
|
||||
0x40752d61,
|
||||
0x4075ad75,
|
||||
0x40762d83,
|
||||
0x407692be,
|
||||
0x40772da8,
|
||||
0x4077adca,
|
||||
0x40782de5,
|
||||
0x4078ae1e,
|
||||
0x40792e35,
|
||||
0x4079ae4b,
|
||||
0x407a2e77,
|
||||
0x407aae8a,
|
||||
0x407b2e9f,
|
||||
0x407baeb1,
|
||||
0x407c2ee2,
|
||||
0x407caeeb,
|
||||
0x407d2650,
|
||||
0x407d9fe4,
|
||||
0x407e2dfa,
|
||||
0x407ea1f1,
|
||||
0x407f1d58,
|
||||
0x407f9afe,
|
||||
0x40801f9e,
|
||||
0x40809d80,
|
||||
0x40812094,
|
||||
0x40819f78,
|
||||
0x40822baa,
|
||||
0x40829ae4,
|
||||
0x408321cc,
|
||||
0x4083a4cd,
|
||||
0x40841d94,
|
||||
0x4084a229,
|
||||
0x408522ae,
|
||||
0x4085a3d2,
|
||||
0x4086232e,
|
||||
0x40869ffe,
|
||||
0x40872bf0,
|
||||
0x4087a420,
|
||||
0x40881b45,
|
||||
0x4088a5df,
|
||||
0x40891b94,
|
||||
0x40899b21,
|
||||
0x408a28cf,
|
||||
0x408a9912,
|
||||
0x408b2ec6,
|
||||
0x408bac5c,
|
||||
0x408c22be,
|
||||
0x408c992e,
|
||||
0x408d1df5,
|
||||
0x408d9dc6,
|
||||
0x408e1f0f,
|
||||
0x408ea134,
|
||||
0x408f25f3,
|
||||
0x408fa3ee,
|
||||
0x409025a8,
|
||||
0x4090a300,
|
||||
0x409128b7,
|
||||
0x40919954,
|
||||
0x40921be1,
|
||||
0x4092ac2b,
|
||||
0x40932ced,
|
||||
0x4093a00f,
|
||||
0x40941da8,
|
||||
0x4094a8e8,
|
||||
0x4095247c,
|
||||
0x4095ae57,
|
||||
0x40962bd7,
|
||||
0x40969fb7,
|
||||
0x4097205a,
|
||||
0x40979f5e,
|
||||
0x41f42789,
|
||||
0x41f9281b,
|
||||
0x41fe270e,
|
||||
0x41fea92b,
|
||||
0x41ff2a1c,
|
||||
0x420327a2,
|
||||
0x420827c4,
|
||||
0x4208a800,
|
||||
0x420926f2,
|
||||
0x4209a83a,
|
||||
0x420a2749,
|
||||
0x420aa729,
|
||||
0x420b2769,
|
||||
0x420ba7e2,
|
||||
0x420c2a38,
|
||||
0x420ca8f8,
|
||||
0x420d2912,
|
||||
0x420da949,
|
||||
0x42122963,
|
||||
0x421729ff,
|
||||
0x4217a9a5,
|
||||
0x421c29c7,
|
||||
0x421f2982,
|
||||
0x42212a4f,
|
||||
0x422629e2,
|
||||
0x422b2b1e,
|
||||
0x422baacc,
|
||||
0x422c2b06,
|
||||
0x422caa8b,
|
||||
0x422d2a6a,
|
||||
0x422daaeb,
|
||||
0x422e2ab1,
|
||||
0x4432072d,
|
||||
0x4432873c,
|
||||
0x44330748,
|
||||
@@ -613,106 +614,106 @@ const uint32_t kOpenSSLReasonValues[] = {
|
||||
0x44390802,
|
||||
0x44398810,
|
||||
0x443a0823,
|
||||
0x483212ce,
|
||||
0x483292e0,
|
||||
0x483312f6,
|
||||
0x4833930f,
|
||||
0x4c321334,
|
||||
0x4c329344,
|
||||
0x4c331357,
|
||||
0x4c339377,
|
||||
0x483212e8,
|
||||
0x483292fa,
|
||||
0x48331310,
|
||||
0x48339329,
|
||||
0x4c32134e,
|
||||
0x4c32935e,
|
||||
0x4c331371,
|
||||
0x4c339391,
|
||||
0x4c3400ac,
|
||||
0x4c3480ea,
|
||||
0x4c351383,
|
||||
0x4c359391,
|
||||
0x4c3613ad,
|
||||
0x4c3693d3,
|
||||
0x4c3713e2,
|
||||
0x4c3793f0,
|
||||
0x4c381405,
|
||||
0x4c389411,
|
||||
0x4c391431,
|
||||
0x4c39945b,
|
||||
0x4c3a1474,
|
||||
0x4c3a948d,
|
||||
0x4c35139d,
|
||||
0x4c3593ab,
|
||||
0x4c3613c7,
|
||||
0x4c3693ed,
|
||||
0x4c3713fc,
|
||||
0x4c37940a,
|
||||
0x4c38141f,
|
||||
0x4c38942b,
|
||||
0x4c39144b,
|
||||
0x4c399475,
|
||||
0x4c3a148e,
|
||||
0x4c3a94a7,
|
||||
0x4c3b05fd,
|
||||
0x4c3b94a6,
|
||||
0x4c3c14b8,
|
||||
0x4c3c94c7,
|
||||
0x4c3d14e0,
|
||||
0x4c3b94c0,
|
||||
0x4c3c14d2,
|
||||
0x4c3c94e1,
|
||||
0x4c3d14fa,
|
||||
0x4c3d8c47,
|
||||
0x4c3e154d,
|
||||
0x4c3e94ef,
|
||||
0x4c3f156f,
|
||||
0x4c3f92a4,
|
||||
0x4c401505,
|
||||
0x4c409320,
|
||||
0x4c41153d,
|
||||
0x4c4193c0,
|
||||
0x4c421529,
|
||||
0x50323127,
|
||||
0x5032b136,
|
||||
0x50333141,
|
||||
0x5033b151,
|
||||
0x5034316a,
|
||||
0x5034b184,
|
||||
0x50353192,
|
||||
0x5035b1a8,
|
||||
0x503631ba,
|
||||
0x5036b1d0,
|
||||
0x503731e9,
|
||||
0x5037b1fc,
|
||||
0x50383214,
|
||||
0x5038b225,
|
||||
0x5039323a,
|
||||
0x5039b24e,
|
||||
0x503a326e,
|
||||
0x503ab284,
|
||||
0x503b329c,
|
||||
0x503bb2ae,
|
||||
0x503c32ca,
|
||||
0x503cb2e1,
|
||||
0x503d32fa,
|
||||
0x503db310,
|
||||
0x503e331d,
|
||||
0x503eb333,
|
||||
0x503f3345,
|
||||
0x4c3e1567,
|
||||
0x4c3e9509,
|
||||
0x4c3f1589,
|
||||
0x4c3f92be,
|
||||
0x4c40151f,
|
||||
0x4c40933a,
|
||||
0x4c411557,
|
||||
0x4c4193da,
|
||||
0x4c421543,
|
||||
0x50323141,
|
||||
0x5032b150,
|
||||
0x5033315b,
|
||||
0x5033b16b,
|
||||
0x50343184,
|
||||
0x5034b19e,
|
||||
0x503531ac,
|
||||
0x5035b1c2,
|
||||
0x503631d4,
|
||||
0x5036b1ea,
|
||||
0x50373203,
|
||||
0x5037b216,
|
||||
0x5038322e,
|
||||
0x5038b23f,
|
||||
0x50393254,
|
||||
0x5039b268,
|
||||
0x503a3288,
|
||||
0x503ab29e,
|
||||
0x503b32b6,
|
||||
0x503bb2c8,
|
||||
0x503c32e4,
|
||||
0x503cb2fb,
|
||||
0x503d3314,
|
||||
0x503db32a,
|
||||
0x503e3337,
|
||||
0x503eb34d,
|
||||
0x503f335f,
|
||||
0x503f837b,
|
||||
0x50403358,
|
||||
0x5040b368,
|
||||
0x50413382,
|
||||
0x5041b391,
|
||||
0x504233ab,
|
||||
0x5042b3c8,
|
||||
0x504333d8,
|
||||
0x5043b3e8,
|
||||
0x504433f7,
|
||||
0x50403372,
|
||||
0x5040b382,
|
||||
0x5041339c,
|
||||
0x5041b3ab,
|
||||
0x504233c5,
|
||||
0x5042b3e2,
|
||||
0x504333f2,
|
||||
0x5043b402,
|
||||
0x50443411,
|
||||
0x50448431,
|
||||
0x5045340b,
|
||||
0x5045b429,
|
||||
0x5046343c,
|
||||
0x5046b452,
|
||||
0x50473464,
|
||||
0x5047b479,
|
||||
0x5048349f,
|
||||
0x5048b4ad,
|
||||
0x504934c0,
|
||||
0x5049b4d5,
|
||||
0x504a34eb,
|
||||
0x504ab4fb,
|
||||
0x504b351b,
|
||||
0x504bb52e,
|
||||
0x504c3551,
|
||||
0x504cb57f,
|
||||
0x504d3591,
|
||||
0x504db5ae,
|
||||
0x504e35c9,
|
||||
0x504eb5e5,
|
||||
0x504f35f7,
|
||||
0x504fb60e,
|
||||
0x5050361d,
|
||||
0x50453425,
|
||||
0x5045b443,
|
||||
0x50463456,
|
||||
0x5046b46c,
|
||||
0x5047347e,
|
||||
0x5047b493,
|
||||
0x504834b9,
|
||||
0x5048b4c7,
|
||||
0x504934da,
|
||||
0x5049b4ef,
|
||||
0x504a3505,
|
||||
0x504ab515,
|
||||
0x504b3535,
|
||||
0x504bb548,
|
||||
0x504c356b,
|
||||
0x504cb599,
|
||||
0x504d35ab,
|
||||
0x504db5c8,
|
||||
0x504e35e3,
|
||||
0x504eb5ff,
|
||||
0x504f3611,
|
||||
0x504fb628,
|
||||
0x50503637,
|
||||
0x505086f1,
|
||||
0x50513630,
|
||||
0x5051364a,
|
||||
0x58320f65,
|
||||
0x68320f27,
|
||||
0x68328c7f,
|
||||
@@ -753,7 +754,7 @@ const uint32_t kOpenSSLReasonValues[] = {
|
||||
0x783d8b4c,
|
||||
0x783e0aa2,
|
||||
0x783e8a54,
|
||||
0x7c3211bd,
|
||||
0x7c3211d7,
|
||||
};
|
||||
|
||||
const size_t kOpenSSLReasonValuesLen = sizeof(kOpenSSLReasonValues) / sizeof(kOpenSSLReasonValues[0]);
|
||||
@@ -984,6 +985,7 @@ const char kOpenSSLReasonStringData[] =
|
||||
"KEYS_NOT_SET\0"
|
||||
"MEMORY_LIMIT_EXCEEDED\0"
|
||||
"NOT_A_PRIVATE_KEY\0"
|
||||
"NOT_XOF_OR_INVALID_LENGTH\0"
|
||||
"NO_DEFAULT_DIGEST\0"
|
||||
"NO_KEY_SET\0"
|
||||
"NO_MDC2_SUPPORT\0"
|
||||
|
||||
@@ -71,6 +71,11 @@
|
||||
#include "../internal.h"
|
||||
|
||||
|
||||
// Node depends on |EVP_R_NOT_XOF_OR_INVALID_LENGTH|.
|
||||
//
|
||||
// TODO(davidben): Fix Node to not touch the error queue itself and remove this.
|
||||
OPENSSL_DECLARE_ERROR_REASON(EVP, NOT_XOF_OR_INVALID_LENGTH)
|
||||
|
||||
EVP_PKEY *EVP_PKEY_new(void) {
|
||||
EVP_PKEY *ret;
|
||||
|
||||
|
||||
@@ -3263,3 +3263,7 @@ aes_nohw_set_decrypt_key:
|
||||
.byte 111,64,111,112,101,110,115,115,108,46,111,114,103,62,0
|
||||
#endif
|
||||
#endif // defined(__i386__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -1234,3 +1234,7 @@ Ldec_loop:
|
||||
.align 2
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__arm__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -1222,3 +1222,7 @@ _armv4_AES_decrypt:
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__arm__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -2665,3 +2665,7 @@ aes_nohw_cbc_encrypt:
|
||||
.align 64
|
||||
#endif
|
||||
#endif // defined(__x86_64__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -2646,3 +2646,7 @@ L$AES_Td:
|
||||
.p2align 6
|
||||
#endif
|
||||
#endif // defined(__x86_64__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -38,6 +38,7 @@ OPENSSL_INLINE int hwaes_capable(void) {
|
||||
#if defined(OPENSSL_X86_64)
|
||||
#define VPAES_CTR32
|
||||
#endif
|
||||
#define VPAES_CBC
|
||||
OPENSSL_INLINE int vpaes_capable(void) {
|
||||
return (OPENSSL_ia32cap_get()[1] & (1 << (41 - 32))) != 0;
|
||||
}
|
||||
@@ -49,11 +50,15 @@ OPENSSL_INLINE int hwaes_capable(void) { return CRYPTO_is_ARMv8_AES_capable(); }
|
||||
|
||||
#if defined(OPENSSL_ARM)
|
||||
#define BSAES
|
||||
#define VPAES
|
||||
#define VPAES_CTR32
|
||||
OPENSSL_INLINE int bsaes_capable(void) { return CRYPTO_is_NEON_capable(); }
|
||||
OPENSSL_INLINE int vpaes_capable(void) { return CRYPTO_is_NEON_capable(); }
|
||||
#endif
|
||||
|
||||
#if defined(OPENSSL_AARCH64)
|
||||
#define VPAES
|
||||
#define VPAES_CBC
|
||||
#define VPAES_CTR32
|
||||
OPENSSL_INLINE int vpaes_capable(void) { return CRYPTO_is_NEON_capable(); }
|
||||
#endif
|
||||
@@ -130,12 +135,14 @@ void aes_hw_ecb_encrypt(const uint8_t *in, uint8_t *out, size_t length,
|
||||
|
||||
|
||||
#if defined(BSAES)
|
||||
// On platforms where BSAES gets defined (just above), then these functions are
|
||||
// provided by asm. Note |bsaes_cbc_encrypt| requires |enc| to be zero.
|
||||
// Note |bsaes_cbc_encrypt| requires |enc| to be zero.
|
||||
void bsaes_cbc_encrypt(const uint8_t *in, uint8_t *out, size_t length,
|
||||
const AES_KEY *key, uint8_t ivec[16], int enc);
|
||||
void bsaes_ctr32_encrypt_blocks(const uint8_t *in, uint8_t *out, size_t len,
|
||||
const AES_KEY *key, const uint8_t ivec[16]);
|
||||
// VPAES to BSAES conversions are available on all BSAES platforms.
|
||||
void vpaes_encrypt_key_to_bsaes(AES_KEY *out_bsaes, const AES_KEY *vpaes);
|
||||
void vpaes_decrypt_key_to_bsaes(AES_KEY *out_bsaes, const AES_KEY *vpaes);
|
||||
#else
|
||||
OPENSSL_INLINE char bsaes_capable(void) { return 0; }
|
||||
|
||||
@@ -152,6 +159,16 @@ OPENSSL_INLINE void bsaes_ctr32_encrypt_blocks(const uint8_t *in, uint8_t *out,
|
||||
const uint8_t ivec[16]) {
|
||||
abort();
|
||||
}
|
||||
|
||||
OPENSSL_INLINE void vpaes_encrypt_key_to_bsaes(AES_KEY *out_bsaes,
|
||||
const AES_KEY *vpaes) {
|
||||
abort();
|
||||
}
|
||||
|
||||
OPENSSL_INLINE void vpaes_decrypt_key_to_bsaes(AES_KEY *out_bsaes,
|
||||
const AES_KEY *vpaes) {
|
||||
abort();
|
||||
}
|
||||
#endif // !BSAES
|
||||
|
||||
|
||||
@@ -164,8 +181,10 @@ int vpaes_set_decrypt_key(const uint8_t *userKey, int bits, AES_KEY *key);
|
||||
void vpaes_encrypt(const uint8_t *in, uint8_t *out, const AES_KEY *key);
|
||||
void vpaes_decrypt(const uint8_t *in, uint8_t *out, const AES_KEY *key);
|
||||
|
||||
#if defined(VPAES_CBC)
|
||||
void vpaes_cbc_encrypt(const uint8_t *in, uint8_t *out, size_t length,
|
||||
const AES_KEY *key, uint8_t *ivec, int enc);
|
||||
#endif
|
||||
#if defined(VPAES_CTR32)
|
||||
void vpaes_ctr32_encrypt_blocks(const uint8_t *in, uint8_t *out, size_t len,
|
||||
const AES_KEY *key, const uint8_t ivec[16]);
|
||||
|
||||
@@ -558,12 +558,10 @@ _aesni_ctr32_6x:
|
||||
.align 32
|
||||
aesni_gcm_encrypt:
|
||||
.cfi_startproc
|
||||
#ifndef NDEBUG
|
||||
#ifndef BORINGSSL_FIPS
|
||||
#ifdef BORINGSSL_DISPATCH_TEST
|
||||
.extern BORINGSSL_function_hit
|
||||
.hidden BORINGSSL_function_hit
|
||||
movb $1,BORINGSSL_function_hit+2(%rip)
|
||||
#endif
|
||||
#endif
|
||||
xorq %r10,%r10
|
||||
|
||||
@@ -854,3 +852,7 @@ aesni_gcm_encrypt:
|
||||
.align 64
|
||||
#endif
|
||||
#endif // defined(__x86_64__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -558,11 +558,9 @@ L$handle_ctr32_2:
|
||||
.p2align 5
|
||||
_aesni_gcm_encrypt:
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifndef BORINGSSL_FIPS
|
||||
#ifdef BORINGSSL_DISPATCH_TEST
|
||||
|
||||
movb $1,_BORINGSSL_function_hit+2(%rip)
|
||||
#endif
|
||||
#endif
|
||||
xorq %r10,%r10
|
||||
|
||||
@@ -853,3 +851,7 @@ L$one_lsb:
|
||||
.p2align 6
|
||||
#endif
|
||||
#endif // defined(__x86_64__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <CNIOBoringSSL_boringssl_prefix_symbols_asm.h>
|
||||
#endif
|
||||
.text
|
||||
#ifndef NDEBUG
|
||||
#ifdef BORINGSSL_DISPATCH_TEST
|
||||
#endif
|
||||
.globl aes_hw_encrypt
|
||||
.hidden aes_hw_encrypt
|
||||
@@ -16,7 +16,7 @@
|
||||
.align 16
|
||||
aes_hw_encrypt:
|
||||
.L_aes_hw_encrypt_begin:
|
||||
#ifndef NDEBUG
|
||||
#ifdef BORINGSSL_DISPATCH_TEST
|
||||
pushl %ebx
|
||||
pushl %edx
|
||||
call .L000pic
|
||||
@@ -847,7 +847,7 @@ aes_hw_ctr32_encrypt_blocks:
|
||||
pushl %ebx
|
||||
pushl %esi
|
||||
pushl %edi
|
||||
#ifndef NDEBUG
|
||||
#ifdef BORINGSSL_DISPATCH_TEST
|
||||
pushl %ebx
|
||||
pushl %edx
|
||||
call .L038pic
|
||||
@@ -2442,7 +2442,7 @@ _aesni_set_encrypt_key:
|
||||
.align 16
|
||||
aes_hw_set_encrypt_key:
|
||||
.L_aes_hw_set_encrypt_key_begin:
|
||||
#ifndef NDEBUG
|
||||
#ifdef BORINGSSL_DISPATCH_TEST
|
||||
pushl %ebx
|
||||
pushl %edx
|
||||
call .L116pic
|
||||
@@ -2513,3 +2513,7 @@ aes_hw_set_decrypt_key:
|
||||
.byte 115,108,46,111,114,103,62,0
|
||||
#endif
|
||||
#endif // defined(__i386__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -22,12 +22,10 @@
|
||||
.align 16
|
||||
aes_hw_encrypt:
|
||||
.cfi_startproc
|
||||
#ifndef NDEBUG
|
||||
#ifndef BORINGSSL_FIPS
|
||||
#ifdef BORINGSSL_DISPATCH_TEST
|
||||
.extern BORINGSSL_function_hit
|
||||
.hidden BORINGSSL_function_hit
|
||||
movb $1,BORINGSSL_function_hit+1(%rip)
|
||||
#endif
|
||||
#endif
|
||||
movups (%rdi),%xmm2
|
||||
movl 240(%rdx),%eax
|
||||
@@ -889,10 +887,8 @@ aes_hw_ecb_encrypt:
|
||||
.align 16
|
||||
aes_hw_ctr32_encrypt_blocks:
|
||||
.cfi_startproc
|
||||
#ifndef NDEBUG
|
||||
#ifndef BORINGSSL_FIPS
|
||||
#ifdef BORINGSSL_DISPATCH_TEST
|
||||
movb $1,BORINGSSL_function_hit(%rip)
|
||||
#endif
|
||||
#endif
|
||||
cmpq $1,%rdx
|
||||
jne .Lctr32_bulk
|
||||
@@ -2113,11 +2109,9 @@ aes_hw_set_decrypt_key:
|
||||
aes_hw_set_encrypt_key:
|
||||
__aesni_set_encrypt_key:
|
||||
.cfi_startproc
|
||||
#ifndef NDEBUG
|
||||
#ifndef BORINGSSL_FIPS
|
||||
#ifdef BORINGSSL_DISPATCH_TEST
|
||||
movb $1,BORINGSSL_function_hit+3(%rip)
|
||||
#endif
|
||||
#endif
|
||||
.byte 0x48,0x83,0xEC,0x08
|
||||
.cfi_adjust_cfa_offset 8
|
||||
movq $-1,%rax
|
||||
@@ -2512,3 +2506,7 @@ __aesni_set_encrypt_key:
|
||||
.align 64
|
||||
#endif
|
||||
#endif // defined(__x86_64__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -21,11 +21,9 @@
|
||||
.p2align 4
|
||||
_aes_hw_encrypt:
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifndef BORINGSSL_FIPS
|
||||
#ifdef BORINGSSL_DISPATCH_TEST
|
||||
|
||||
movb $1,_BORINGSSL_function_hit+1(%rip)
|
||||
#endif
|
||||
#endif
|
||||
movups (%rdi),%xmm2
|
||||
movl 240(%rdx),%eax
|
||||
@@ -887,10 +885,8 @@ L$ecb_ret:
|
||||
.p2align 4
|
||||
_aes_hw_ctr32_encrypt_blocks:
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifndef BORINGSSL_FIPS
|
||||
#ifdef BORINGSSL_DISPATCH_TEST
|
||||
movb $1,_BORINGSSL_function_hit(%rip)
|
||||
#endif
|
||||
#endif
|
||||
cmpq $1,%rdx
|
||||
jne L$ctr32_bulk
|
||||
@@ -2111,11 +2107,9 @@ L$SEH_end_set_decrypt_key:
|
||||
_aes_hw_set_encrypt_key:
|
||||
__aesni_set_encrypt_key:
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifndef BORINGSSL_FIPS
|
||||
#ifdef BORINGSSL_DISPATCH_TEST
|
||||
movb $1,_BORINGSSL_function_hit+3(%rip)
|
||||
#endif
|
||||
#endif
|
||||
.byte 0x48,0x83,0xEC,0x08
|
||||
|
||||
movq $-1,%rax
|
||||
@@ -2510,3 +2504,7 @@ L$key_rcon1b:
|
||||
.p2align 6
|
||||
#endif
|
||||
#endif // defined(__x86_64__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -791,3 +791,7 @@ Lctr32_done:
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__arm__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -781,3 +781,7 @@ aes_hw_ctr32_encrypt_blocks:
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__arm__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -773,3 +773,7 @@ Lctr32_done:
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__aarch64__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -775,3 +775,7 @@ aes_hw_ctr32_encrypt_blocks:
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__aarch64__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -983,3 +983,7 @@ OPENSSL_armcap_P:
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__arm__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -977,3 +977,7 @@ bn_mul8x_mont_neon:
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__arm__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -1421,3 +1421,7 @@ Lmul4x_done:
|
||||
.align 4
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__aarch64__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -1423,3 +1423,7 @@ __bn_mul4x_mont:
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__aarch64__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -1544,3 +1544,7 @@ bn_sub_part_words:
|
||||
.size bn_sub_part_words,.-.L_bn_sub_part_words_begin
|
||||
#endif
|
||||
#endif // defined(__i386__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -126,6 +126,10 @@ void BN_CTX_free(BN_CTX *ctx) {
|
||||
return;
|
||||
}
|
||||
|
||||
// All |BN_CTX_start| calls must be matched with |BN_CTX_end|, otherwise the
|
||||
// function may use more memory than expected, potentially without bound if
|
||||
// done in a loop. Assert that all |BIGNUM|s have been released.
|
||||
assert(ctx->used == 0 || ctx->error);
|
||||
sk_BIGNUM_pop_free(ctx->bignums, BN_free);
|
||||
BN_STACK_cleanup(&ctx->stack);
|
||||
OPENSSL_free(ctx);
|
||||
|
||||
@@ -594,10 +594,10 @@ int bn_odd_number_is_obviously_composite(const BIGNUM *bn) {
|
||||
return bn_trial_division(&prime, bn) && !BN_is_word(bn, prime);
|
||||
}
|
||||
|
||||
int BN_primality_test(int *is_probably_prime, const BIGNUM *w,
|
||||
int BN_primality_test(int *out_is_probably_prime, const BIGNUM *w,
|
||||
int iterations, BN_CTX *ctx, int do_trial_division,
|
||||
BN_GENCB *cb) {
|
||||
*is_probably_prime = 0;
|
||||
*out_is_probably_prime = 0;
|
||||
|
||||
// To support RSA key generation, this function should treat |w| as secret if
|
||||
// it is a large prime. Composite numbers are discarded, so they may return
|
||||
@@ -609,13 +609,13 @@ int BN_primality_test(int *is_probably_prime, const BIGNUM *w,
|
||||
|
||||
if (!BN_is_odd(w)) {
|
||||
// The only even prime is two.
|
||||
*is_probably_prime = BN_is_word(w, 2);
|
||||
*out_is_probably_prime = BN_is_word(w, 2);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Miller-Rabin does not work for three.
|
||||
if (BN_is_word(w, 3)) {
|
||||
*is_probably_prime = 1;
|
||||
*out_is_probably_prime = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -623,7 +623,7 @@ int BN_primality_test(int *is_probably_prime, const BIGNUM *w,
|
||||
// Perform additional trial division checks to discard small primes.
|
||||
uint16_t prime;
|
||||
if (bn_trial_division(&prime, w)) {
|
||||
*is_probably_prime = BN_is_word(w, prime);
|
||||
*out_is_probably_prime = BN_is_word(w, prime);
|
||||
return 1;
|
||||
}
|
||||
if (!BN_GENCB_call(cb, 1, -1)) {
|
||||
@@ -691,9 +691,9 @@ int BN_primality_test(int *is_probably_prime, const BIGNUM *w,
|
||||
// discard out-of-range values. To avoid leaking information on |w|, we use
|
||||
// |bn_rand_secret_range| which, rather than discarding bad values, adjusts
|
||||
// them to be in range. Though not uniformly selected, these adjusted values
|
||||
// are still usable as Rabin-Miller checks.
|
||||
// are still usable as Miller-Rabin checks.
|
||||
//
|
||||
// Rabin-Miller is already probabilistic, so we could reach the desired
|
||||
// Miller-Rabin is already probabilistic, so we could reach the desired
|
||||
// confidence levels by just suitably increasing the iteration count. However,
|
||||
// to align with FIPS 186-4, we use a more pessimal analysis: we do not count
|
||||
// the non-uniform values towards the iteration count. As a result, this
|
||||
@@ -771,7 +771,7 @@ int BN_primality_test(int *is_probably_prime, const BIGNUM *w,
|
||||
// Step 4.6. We did not see z = w-1 before z = 1, so w must be composite.
|
||||
// (For any prime, the value of z immediately preceding 1 must be -1.
|
||||
// There are no non-trivial square roots of 1 modulo a prime.)
|
||||
*is_probably_prime = 0;
|
||||
*out_is_probably_prime = 0;
|
||||
ret = 1;
|
||||
goto err;
|
||||
}
|
||||
@@ -783,7 +783,7 @@ int BN_primality_test(int *is_probably_prime, const BIGNUM *w,
|
||||
}
|
||||
|
||||
assert(uniform_iterations >= (crypto_word_t)iterations);
|
||||
*is_probably_prime = 1;
|
||||
*out_is_probably_prime = 1;
|
||||
ret = 1;
|
||||
|
||||
err:
|
||||
|
||||
@@ -1537,3 +1537,7 @@ Lctr_enc_bzero:@ wipe key schedule [if any]
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__arm__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -1529,3 +1529,7 @@ bsaes_ctr32_encrypt_blocks:
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__arm__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -125,9 +125,10 @@ int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
void EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *ctx) {
|
||||
int EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *ctx) {
|
||||
EVP_CIPHER_CTX_cleanup(ctx);
|
||||
EVP_CIPHER_CTX_init(ctx);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
|
||||
@@ -191,7 +192,7 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
|
||||
|
||||
case EVP_CIPH_CFB_MODE:
|
||||
ctx->num = 0;
|
||||
// fall-through
|
||||
OPENSSL_FALLTHROUGH;
|
||||
|
||||
case EVP_CIPH_CBC_MODE:
|
||||
assert(EVP_CIPHER_CTX_iv_length(ctx) <= sizeof(ctx->iv));
|
||||
|
||||
@@ -68,6 +68,48 @@
|
||||
OPENSSL_MSVC_PRAGMA(warning(push))
|
||||
OPENSSL_MSVC_PRAGMA(warning(disable: 4702)) // Unreachable code.
|
||||
|
||||
#if defined(BSAES)
|
||||
static void vpaes_ctr32_encrypt_blocks_with_bsaes(const uint8_t *in,
|
||||
uint8_t *out, size_t blocks,
|
||||
const AES_KEY *key,
|
||||
const uint8_t ivec[16]) {
|
||||
// |bsaes_ctr32_encrypt_blocks| is faster than |vpaes_ctr32_encrypt_blocks|,
|
||||
// but it takes at least one full 8-block batch to amortize the conversion.
|
||||
if (blocks < 8) {
|
||||
vpaes_ctr32_encrypt_blocks(in, out, blocks, key, ivec);
|
||||
return;
|
||||
}
|
||||
|
||||
size_t bsaes_blocks = blocks;
|
||||
if (bsaes_blocks % 8 < 6) {
|
||||
// |bsaes_ctr32_encrypt_blocks| internally works in 8-block batches. If the
|
||||
// final batch is too small (under six blocks), it is faster to loop over
|
||||
// |vpaes_encrypt|. Round |bsaes_blocks| down to a multiple of 8.
|
||||
bsaes_blocks -= bsaes_blocks % 8;
|
||||
}
|
||||
|
||||
AES_KEY bsaes;
|
||||
vpaes_encrypt_key_to_bsaes(&bsaes, key);
|
||||
bsaes_ctr32_encrypt_blocks(in, out, bsaes_blocks, &bsaes, ivec);
|
||||
OPENSSL_cleanse(&bsaes, sizeof(bsaes));
|
||||
|
||||
in += 16 * bsaes_blocks;
|
||||
out += 16 * bsaes_blocks;
|
||||
blocks -= bsaes_blocks;
|
||||
|
||||
union {
|
||||
uint32_t u32[4];
|
||||
uint8_t u8[16];
|
||||
} new_ivec;
|
||||
memcpy(new_ivec.u8, ivec, 16);
|
||||
uint32_t ctr = CRYPTO_bswap4(new_ivec.u32[3]) + bsaes_blocks;
|
||||
new_ivec.u32[3] = CRYPTO_bswap4(ctr);
|
||||
|
||||
// Finish any remaining blocks with |vpaes_ctr32_encrypt_blocks|.
|
||||
vpaes_ctr32_encrypt_blocks(in, out, blocks, key, new_ivec.u8);
|
||||
}
|
||||
#endif // BSAES
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
double align;
|
||||
@@ -110,14 +152,23 @@ static int aes_init_key(EVP_CIPHER_CTX *ctx, const uint8_t *key,
|
||||
dat->stream.cbc = aes_hw_cbc_encrypt;
|
||||
}
|
||||
} else if (bsaes_capable() && mode == EVP_CIPH_CBC_MODE) {
|
||||
ret = aes_nohw_set_decrypt_key(key, ctx->key_len * 8, &dat->ks.ks);
|
||||
assert(vpaes_capable());
|
||||
ret = vpaes_set_decrypt_key(key, ctx->key_len * 8, &dat->ks.ks);
|
||||
if (ret == 0) {
|
||||
vpaes_decrypt_key_to_bsaes(&dat->ks.ks, &dat->ks.ks);
|
||||
}
|
||||
// If |dat->stream.cbc| is provided, |dat->block| is never used.
|
||||
dat->block = NULL;
|
||||
dat->stream.cbc = bsaes_cbc_encrypt;
|
||||
} else if (vpaes_capable()) {
|
||||
ret = vpaes_set_decrypt_key(key, ctx->key_len * 8, &dat->ks.ks);
|
||||
dat->block = vpaes_decrypt;
|
||||
dat->stream.cbc = mode == EVP_CIPH_CBC_MODE ? vpaes_cbc_encrypt : NULL;
|
||||
dat->stream.cbc = NULL;
|
||||
#if defined(VPAES_CBC)
|
||||
if (mode == EVP_CIPH_CBC_MODE) {
|
||||
dat->stream.cbc = vpaes_cbc_encrypt;
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
ret = aes_nohw_set_decrypt_key(key, ctx->key_len * 8, &dat->ks.ks);
|
||||
dat->block = aes_nohw_decrypt;
|
||||
@@ -137,23 +188,23 @@ static int aes_init_key(EVP_CIPHER_CTX *ctx, const uint8_t *key,
|
||||
} else if (mode == EVP_CIPH_CTR_MODE) {
|
||||
dat->stream.ctr = aes_hw_ctr32_encrypt_blocks;
|
||||
}
|
||||
} else if (bsaes_capable() && mode == EVP_CIPH_CTR_MODE) {
|
||||
ret = aes_nohw_set_encrypt_key(key, ctx->key_len * 8, &dat->ks.ks);
|
||||
// If |dat->stream.ctr| is provided, |dat->block| is never used.
|
||||
dat->block = NULL;
|
||||
dat->stream.ctr = bsaes_ctr32_encrypt_blocks;
|
||||
} else if (vpaes_capable()) {
|
||||
ret = vpaes_set_encrypt_key(key, ctx->key_len * 8, &dat->ks.ks);
|
||||
dat->block = vpaes_encrypt;
|
||||
dat->stream.cbc = NULL;
|
||||
#if defined(VPAES_CBC)
|
||||
if (mode == EVP_CIPH_CBC_MODE) {
|
||||
dat->stream.cbc = vpaes_cbc_encrypt;
|
||||
}
|
||||
#if defined(VPAES_CTR32)
|
||||
if (mode == EVP_CIPH_CTR_MODE) {
|
||||
dat->stream.ctr = vpaes_ctr32_encrypt_blocks;
|
||||
}
|
||||
#endif
|
||||
if (mode == EVP_CIPH_CTR_MODE) {
|
||||
#if defined(BSAES)
|
||||
assert(bsaes_capable());
|
||||
dat->stream.ctr = vpaes_ctr32_encrypt_blocks_with_bsaes;
|
||||
#elif defined(VPAES_CTR32)
|
||||
dat->stream.ctr = vpaes_ctr32_encrypt_blocks;
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
ret = aes_nohw_set_encrypt_key(key, ctx->key_len * 8, &dat->ks.ks);
|
||||
dat->block = aes_nohw_encrypt;
|
||||
@@ -242,17 +293,6 @@ ctr128_f aes_ctr_set_key(AES_KEY *aes_key, GCM128_KEY *gcm_key,
|
||||
return aes_hw_ctr32_encrypt_blocks;
|
||||
}
|
||||
|
||||
if (bsaes_capable()) {
|
||||
aes_nohw_set_encrypt_key(key, key_bytes * 8, aes_key);
|
||||
if (gcm_key != NULL) {
|
||||
CRYPTO_gcm128_init_key(gcm_key, aes_key, aes_nohw_encrypt, 0);
|
||||
}
|
||||
if (out_block) {
|
||||
*out_block = aes_nohw_encrypt;
|
||||
}
|
||||
return bsaes_ctr32_encrypt_blocks;
|
||||
}
|
||||
|
||||
if (vpaes_capable()) {
|
||||
vpaes_set_encrypt_key(key, key_bytes * 8, aes_key);
|
||||
if (out_block) {
|
||||
@@ -261,7 +301,10 @@ ctr128_f aes_ctr_set_key(AES_KEY *aes_key, GCM128_KEY *gcm_key,
|
||||
if (gcm_key != NULL) {
|
||||
CRYPTO_gcm128_init_key(gcm_key, aes_key, vpaes_encrypt, 0);
|
||||
}
|
||||
#if defined(VPAES_CTR32)
|
||||
#if defined(BSAES)
|
||||
assert(bsaes_capable());
|
||||
return vpaes_ctr32_encrypt_blocks_with_bsaes;
|
||||
#elif defined(VPAES_CTR32)
|
||||
return vpaes_ctr32_encrypt_blocks;
|
||||
#else
|
||||
return NULL;
|
||||
@@ -847,7 +890,7 @@ static int aead_aes_gcm_init_impl(struct aead_aes_gcm_ctx *gcm_ctx,
|
||||
size_t key_len, size_t tag_len) {
|
||||
const size_t key_bits = key_len * 8;
|
||||
|
||||
if (key_bits != 128 && key_bits != 256) {
|
||||
if (key_bits != 128 && key_bits != 192 && key_bits != 256) {
|
||||
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BAD_KEY_LENGTH);
|
||||
return 0; // EVP_AEAD_CTX_init should catch this.
|
||||
}
|
||||
@@ -1020,6 +1063,21 @@ DEFINE_METHOD_FUNCTION(EVP_AEAD, EVP_aead_aes_128_gcm) {
|
||||
out->open_gather = aead_aes_gcm_open_gather;
|
||||
}
|
||||
|
||||
DEFINE_METHOD_FUNCTION(EVP_AEAD, EVP_aead_aes_192_gcm) {
|
||||
memset(out, 0, sizeof(EVP_AEAD));
|
||||
|
||||
out->key_len = 24;
|
||||
out->nonce_len = 12;
|
||||
out->overhead = EVP_AEAD_AES_GCM_TAG_LEN;
|
||||
out->max_tag_len = EVP_AEAD_AES_GCM_TAG_LEN;
|
||||
out->seal_scatter_supports_extra_in = 1;
|
||||
|
||||
out->init = aead_aes_gcm_init;
|
||||
out->cleanup = aead_aes_gcm_cleanup;
|
||||
out->seal_scatter = aead_aes_gcm_seal_scatter;
|
||||
out->open_gather = aead_aes_gcm_open_gather;
|
||||
}
|
||||
|
||||
DEFINE_METHOD_FUNCTION(EVP_AEAD, EVP_aead_aes_256_gcm) {
|
||||
memset(out, 0, sizeof(EVP_AEAD));
|
||||
|
||||
|
||||
@@ -1266,3 +1266,7 @@ bn_sqr_comba4:
|
||||
.size bn_sqr_comba4,.-.L_bn_sqr_comba4_begin
|
||||
#endif
|
||||
#endif // defined(__i386__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -120,6 +120,8 @@ int EVP_DigestFinalXOF(EVP_MD_CTX *ctx, uint8_t *out, size_t len) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t EVP_MD_meth_get_flags(const EVP_MD *md) { return EVP_MD_flags(md); }
|
||||
|
||||
int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in) {
|
||||
// |in->digest| may be NULL if this is a signing |EVP_MD_CTX| for, e.g.,
|
||||
// Ed25519 which does not hash with |EVP_MD_CTX|.
|
||||
|
||||
@@ -369,8 +369,8 @@ int EC_KEY_check_fips(const EC_KEY *key) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x,
|
||||
BIGNUM *y) {
|
||||
int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, const BIGNUM *x,
|
||||
const BIGNUM *y) {
|
||||
EC_POINT *point = NULL;
|
||||
int ok = 0;
|
||||
|
||||
|
||||
@@ -601,3 +601,7 @@ Lgmult_neon:
|
||||
.align 2
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__arm__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -591,3 +591,7 @@ gcm_ghash_neon:
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__arm__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -339,3 +339,7 @@ Lmasks:
|
||||
.align 2
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__aarch64__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -341,3 +341,7 @@ gcm_ghash_neon:
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__aarch64__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -294,3 +294,7 @@ gcm_ghash_ssse3:
|
||||
.long 252645135,252645135,252645135,252645135
|
||||
#endif
|
||||
#endif // defined(__i386__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -427,3 +427,7 @@ gcm_ghash_ssse3:
|
||||
.quad 0x0f0f0f0f0f0f0f0f, 0x0f0f0f0f0f0f0f0f
|
||||
#endif
|
||||
#endif // defined(__x86_64__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -427,3 +427,7 @@ L$low4_mask:
|
||||
.quad 0x0f0f0f0f0f0f0f0f, 0x0f0f0f0f0f0f0f0f
|
||||
#endif
|
||||
#endif // defined(__x86_64__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -1075,3 +1075,7 @@ gcm_ghash_clmul:
|
||||
.byte 0
|
||||
#endif
|
||||
#endif // defined(__i386__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -1872,3 +1872,7 @@ gcm_ghash_avx:
|
||||
.align 64
|
||||
#endif
|
||||
#endif // defined(__x86_64__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -1859,3 +1859,7 @@ L$rem_8bit:
|
||||
.p2align 6
|
||||
#endif
|
||||
#endif // defined(__x86_64__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -257,3 +257,7 @@ Ldone_v8:
|
||||
.align 2
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__arm__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -253,3 +253,7 @@ gcm_ghash_v8:
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__arm__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -247,3 +247,7 @@ Ldone_v8:
|
||||
.align 2
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__aarch64__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -249,3 +249,7 @@ gcm_ghash_v8:
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__aarch64__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -688,3 +688,7 @@ md5_block_asm_data_order:
|
||||
.size md5_block_asm_data_order,.-.L_md5_block_asm_data_order_begin
|
||||
#endif
|
||||
#endif // defined(__i386__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -702,3 +702,7 @@ md5_block_asm_data_order:
|
||||
.size md5_block_asm_data_order,.-md5_block_asm_data_order
|
||||
#endif
|
||||
#endif // defined(__x86_64__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -697,3 +697,7 @@ L$epilogue:
|
||||
|
||||
#endif
|
||||
#endif // defined(__x86_64__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -4543,3 +4543,7 @@ ecp_nistz256_point_add_affinex:
|
||||
.size ecp_nistz256_point_add_affinex,.-ecp_nistz256_point_add_affinex
|
||||
#endif
|
||||
#endif // defined(__x86_64__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -4468,3 +4468,7 @@ L$add_affinex_epilogue:
|
||||
|
||||
#endif
|
||||
#endif // defined(__x86_64__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -343,3 +343,7 @@ beeu_mod_inverse_vartime:
|
||||
.size beeu_mod_inverse_vartime, .-beeu_mod_inverse_vartime
|
||||
#endif
|
||||
#endif // defined(__x86_64__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -329,3 +329,7 @@ L$beeu_finish:
|
||||
|
||||
#endif
|
||||
#endif // defined(__x86_64__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -26,6 +26,11 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(OPENSSL_WINDOWS) && !defined(OPENSSL_FUCHSIA) && \
|
||||
!defined(BORINGSSL_UNSAFE_DETERMINISTIC_MODE) && !defined(OPENSSL_TRUSTY)
|
||||
#define OPENSSL_URANDOM
|
||||
#endif
|
||||
|
||||
// RAND_bytes_with_additional_data samples from the RNG after mixing 32 bytes
|
||||
// from |user_additional_data| in.
|
||||
void RAND_bytes_with_additional_data(uint8_t *out, size_t out_len,
|
||||
@@ -35,6 +40,14 @@ void RAND_bytes_with_additional_data(uint8_t *out, size_t out_len,
|
||||
// system.
|
||||
void CRYPTO_sysrand(uint8_t *buf, size_t len);
|
||||
|
||||
#if defined(OPENSSL_URANDOM) && defined(BORINGSSL_FIPS)
|
||||
// CRYPTO_sysrand_if_available fills |len| bytes at |buf| with entropy from the
|
||||
// operating system, if the entropy pool is initialized. If it is uninitialized,
|
||||
// it will not block and will instead fill |buf| with all zeros or early
|
||||
// /dev/urandom output.
|
||||
void CRYPTO_sysrand_if_available(uint8_t *buf, size_t len);
|
||||
#endif
|
||||
|
||||
// rand_fork_unsafe_buffering_enabled returns whether fork-unsafe buffering has
|
||||
// been enabled via |RAND_enable_fork_unsafe_buffering|.
|
||||
int rand_fork_unsafe_buffering_enabled(void);
|
||||
|
||||
@@ -179,7 +179,8 @@ static void rand_get_seed(struct rand_thread_state *state,
|
||||
#define FIPS_OVERREAD 10
|
||||
uint8_t entropy[CTR_DRBG_ENTROPY_LEN * FIPS_OVERREAD];
|
||||
|
||||
if (!hwrand(entropy, sizeof(entropy))) {
|
||||
int used_hwrand = hwrand(entropy, sizeof(entropy));
|
||||
if (!used_hwrand) {
|
||||
CRYPTO_sysrand(entropy, sizeof(entropy));
|
||||
}
|
||||
|
||||
@@ -210,6 +211,17 @@ static void rand_get_seed(struct rand_thread_state *state,
|
||||
seed[j] ^= entropy[CTR_DRBG_ENTROPY_LEN * i + j];
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(OPENSSL_URANDOM)
|
||||
// If we used RDRAND, also opportunistically read from the system. This avoids
|
||||
// solely relying on the hardware once the entropy pool has been initialized.
|
||||
if (used_hwrand) {
|
||||
CRYPTO_sysrand_if_available(entropy, CTR_DRBG_ENTROPY_LEN);
|
||||
for (size_t i = 0; i < CTR_DRBG_ENTROPY_LEN; i++) {
|
||||
seed[i] ^= entropy[i];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
@@ -18,8 +18,9 @@
|
||||
|
||||
#include <CNIOBoringSSL_rand.h>
|
||||
|
||||
#if !defined(OPENSSL_WINDOWS) && !defined(OPENSSL_FUCHSIA) && \
|
||||
!defined(BORINGSSL_UNSAFE_DETERMINISTIC_MODE) && !defined(OPENSSL_TRUSTY)
|
||||
#include "internal.h"
|
||||
|
||||
#if defined(OPENSSL_URANDOM)
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
@@ -53,10 +54,13 @@
|
||||
#endif
|
||||
#endif // OPENSSL_LINUX
|
||||
|
||||
#if defined(OPENSSL_MACOS)
|
||||
#include <sys/random.h>
|
||||
#endif
|
||||
|
||||
#include <CNIOBoringSSL_thread.h>
|
||||
#include <CNIOBoringSSL_mem.h>
|
||||
|
||||
#include "internal.h"
|
||||
#include "../delocate.h"
|
||||
#include "../../internal.h"
|
||||
|
||||
@@ -133,6 +137,12 @@ DEFINE_BSS_GET(int, urandom_fd_requested)
|
||||
// urandom_fd is a file descriptor to /dev/urandom. It's protected by |once|.
|
||||
DEFINE_BSS_GET(int, urandom_fd)
|
||||
|
||||
#if defined(USE_NR_getrandom)
|
||||
// getrandom_ready is one if |getrandom| had been initialized by the time
|
||||
// |init_once| was called and zero otherwise.
|
||||
DEFINE_BSS_GET(int, getrandom_ready)
|
||||
#endif
|
||||
|
||||
DEFINE_STATIC_ONCE(rand_once)
|
||||
|
||||
// init_once initializes the state of this module to values previously
|
||||
@@ -145,44 +155,46 @@ static void init_once(void) {
|
||||
CRYPTO_STATIC_MUTEX_unlock_read(rand_lock_bss_get());
|
||||
|
||||
#if defined(USE_NR_getrandom)
|
||||
int have_getrandom;
|
||||
uint8_t dummy;
|
||||
ssize_t getrandom_ret =
|
||||
boringssl_getrandom(&dummy, sizeof(dummy), GRND_NONBLOCK);
|
||||
|
||||
if (getrandom_ret == -1 && errno == EAGAIN) {
|
||||
// Attempt to get the path of the current process to aid in debugging when
|
||||
// something blocks.
|
||||
const char *current_process = "<unknown>";
|
||||
#if defined(OPENSSL_HAS_GETAUXVAL)
|
||||
const unsigned long getauxval_ret = getauxval(AT_EXECFN);
|
||||
if (getauxval_ret != 0) {
|
||||
current_process = (const char *)getauxval_ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
fprintf(stderr,
|
||||
"%s: getrandom indicates that the entropy pool has not been "
|
||||
"initialized. Rather than continue with poor entropy, this process "
|
||||
"will block until entropy is available.\n",
|
||||
current_process);
|
||||
|
||||
getrandom_ret =
|
||||
boringssl_getrandom(&dummy, sizeof(dummy), 0 /* no flags */);
|
||||
}
|
||||
|
||||
if (getrandom_ret == 1) {
|
||||
*urandom_fd_bss_get() = kHaveGetrandom;
|
||||
return;
|
||||
}
|
||||
|
||||
// Ignore ENOSYS and fallthrough to using /dev/urandom, below. Otherwise it's
|
||||
// a fatal error.
|
||||
if (getrandom_ret != -1 || errno != ENOSYS) {
|
||||
*getrandom_ready_bss_get() = 1;
|
||||
have_getrandom = 1;
|
||||
} else if (getrandom_ret == -1 && errno == EAGAIN) {
|
||||
// We have getrandom, but the entropy pool has not been initialized yet.
|
||||
have_getrandom = 1;
|
||||
} else if (getrandom_ret == -1 && errno == ENOSYS) {
|
||||
// Fallthrough to using /dev/urandom, below.
|
||||
have_getrandom = 0;
|
||||
} else {
|
||||
// Other errors are fatal.
|
||||
perror("getrandom");
|
||||
abort();
|
||||
}
|
||||
|
||||
if (have_getrandom) {
|
||||
*urandom_fd_bss_get() = kHaveGetrandom;
|
||||
return;
|
||||
}
|
||||
#endif // USE_NR_getrandom
|
||||
|
||||
#if defined(OPENSSL_MACOS)
|
||||
// getentropy is available in macOS 10.12 and up. iOS 10 and up may also
|
||||
// support it, but the header is missing. See https://crbug.com/boringssl/287.
|
||||
if (__builtin_available(macos 10.12, *)) {
|
||||
*urandom_fd_bss_get() = kHaveGetrandom;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Android FIPS builds must support getrandom.
|
||||
#if defined(BORINGSSL_FIPS) && defined(OPENSSL_ANDROID)
|
||||
perror("getrandom not found");
|
||||
abort();
|
||||
#endif
|
||||
|
||||
if (fd == kUnset) {
|
||||
do {
|
||||
fd = open("/dev/urandom", O_RDONLY);
|
||||
@@ -208,6 +220,70 @@ static void init_once(void) {
|
||||
}
|
||||
}
|
||||
|
||||
int flags = fcntl(fd, F_GETFD);
|
||||
if (flags == -1) {
|
||||
// Native Client doesn't implement |fcntl|.
|
||||
if (errno != ENOSYS) {
|
||||
perror("failed to get flags from urandom fd");
|
||||
abort();
|
||||
}
|
||||
} else {
|
||||
flags |= FD_CLOEXEC;
|
||||
if (fcntl(fd, F_SETFD, flags) == -1) {
|
||||
perror("failed to set FD_CLOEXEC on urandom fd");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
*urandom_fd_bss_get() = fd;
|
||||
}
|
||||
|
||||
DEFINE_STATIC_ONCE(wait_for_entropy_once)
|
||||
|
||||
static void wait_for_entropy(void) {
|
||||
int fd = *urandom_fd_bss_get();
|
||||
if (fd == kHaveGetrandom) {
|
||||
// |getrandom| and |getentropy| support blocking in |fill_with_entropy|
|
||||
// directly. For |getrandom|, we first probe with a non-blocking call to aid
|
||||
// debugging.
|
||||
#if defined(USE_NR_getrandom)
|
||||
if (*getrandom_ready_bss_get()) {
|
||||
// The entropy pool was already initialized in |init_once|.
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t dummy;
|
||||
ssize_t getrandom_ret =
|
||||
boringssl_getrandom(&dummy, sizeof(dummy), GRND_NONBLOCK);
|
||||
if (getrandom_ret == -1 && errno == EAGAIN) {
|
||||
// Attempt to get the path of the current process to aid in debugging when
|
||||
// something blocks.
|
||||
const char *current_process = "<unknown>";
|
||||
#if defined(OPENSSL_HAS_GETAUXVAL)
|
||||
const unsigned long getauxval_ret = getauxval(AT_EXECFN);
|
||||
if (getauxval_ret != 0) {
|
||||
current_process = (const char *)getauxval_ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
fprintf(
|
||||
stderr,
|
||||
"%s: getrandom indicates that the entropy pool has not been "
|
||||
"initialized. Rather than continue with poor entropy, this process "
|
||||
"will block until entropy is available.\n",
|
||||
current_process);
|
||||
|
||||
getrandom_ret =
|
||||
boringssl_getrandom(&dummy, sizeof(dummy), 0 /* no flags */);
|
||||
}
|
||||
|
||||
if (getrandom_ret != 1) {
|
||||
perror("getrandom");
|
||||
abort();
|
||||
}
|
||||
#endif // USE_NR_getrandom
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(BORINGSSL_FIPS)
|
||||
// In FIPS mode we ensure that the kernel has sufficient entropy before
|
||||
// continuing. This is automatically handled by getrandom, which requires
|
||||
@@ -229,23 +305,7 @@ static void init_once(void) {
|
||||
|
||||
usleep(250000);
|
||||
}
|
||||
#endif
|
||||
|
||||
int flags = fcntl(fd, F_GETFD);
|
||||
if (flags == -1) {
|
||||
// Native Client doesn't implement |fcntl|.
|
||||
if (errno != ENOSYS) {
|
||||
perror("failed to get flags from urandom fd");
|
||||
abort();
|
||||
}
|
||||
} else {
|
||||
flags |= FD_CLOEXEC;
|
||||
if (fcntl(fd, F_SETFD, flags) == -1) {
|
||||
perror("failed to set FD_CLOEXEC on urandom fd");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
*urandom_fd_bss_get() = fd;
|
||||
#endif // BORINGSSL_FIPS
|
||||
}
|
||||
|
||||
void RAND_set_urandom_fd(int fd) {
|
||||
@@ -283,14 +343,41 @@ void RAND_set_urandom_fd(int fd) {
|
||||
}
|
||||
|
||||
// fill_with_entropy writes |len| bytes of entropy into |out|. It returns one
|
||||
// on success and zero on error.
|
||||
static char fill_with_entropy(uint8_t *out, size_t len) {
|
||||
// on success and zero on error. If |block| is one, this function will block
|
||||
// until the entropy pool is initialized. Otherwise, this function may fail,
|
||||
// setting |errno| to |EAGAIN| if the entropy pool has not yet been initialized.
|
||||
static int fill_with_entropy(uint8_t *out, size_t len, int block) {
|
||||
if (len == 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
CRYPTO_once(rand_once_bss_get(), init_once);
|
||||
if (block) {
|
||||
CRYPTO_once(wait_for_entropy_once_bss_get(), wait_for_entropy);
|
||||
}
|
||||
|
||||
// Clear |errno| so it has defined value if |read| or |getrandom|
|
||||
// "successfully" returns zero.
|
||||
errno = 0;
|
||||
while (len > 0) {
|
||||
ssize_t r;
|
||||
|
||||
if (*urandom_fd_bss_get() == kHaveGetrandom) {
|
||||
#if defined(USE_NR_getrandom)
|
||||
r = boringssl_getrandom(out, len, 0 /* no flags */);
|
||||
r = boringssl_getrandom(out, len, block ? 0 : GRND_NONBLOCK);
|
||||
#elif defined(OPENSSL_MACOS)
|
||||
if (__builtin_available(macos 10.12, *)) {
|
||||
// |getentropy| can only request 256 bytes at a time.
|
||||
size_t todo = len <= 256 ? len : 256;
|
||||
if (getentropy(out, todo) != 0) {
|
||||
r = -1;
|
||||
} else {
|
||||
r = (ssize_t)todo;
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "urandom fd corrupt.\n");
|
||||
abort();
|
||||
}
|
||||
#else // USE_NR_getrandom
|
||||
fprintf(stderr, "urandom fd corrupt.\n");
|
||||
abort();
|
||||
@@ -313,13 +400,7 @@ static char fill_with_entropy(uint8_t *out, size_t len) {
|
||||
|
||||
// CRYPTO_sysrand puts |requested| random bytes into |out|.
|
||||
void CRYPTO_sysrand(uint8_t *out, size_t requested) {
|
||||
if (requested == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
CRYPTO_once(rand_once_bss_get(), init_once);
|
||||
|
||||
if (!fill_with_entropy(out, requested)) {
|
||||
if (!fill_with_entropy(out, requested, /*block=*/1)) {
|
||||
perror("entropy fill failed");
|
||||
abort();
|
||||
}
|
||||
@@ -331,5 +412,17 @@ void CRYPTO_sysrand(uint8_t *out, size_t requested) {
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* !OPENSSL_WINDOWS && !defined(OPENSSL_FUCHSIA) && \
|
||||
!BORINGSSL_UNSAFE_DETERMINISTIC_MODE && !OPENSSL_TRUSTY */
|
||||
#if defined(BORINGSSL_FIPS)
|
||||
void CRYPTO_sysrand_if_available(uint8_t *out, size_t requested) {
|
||||
// Return all zeros if |fill_with_entropy| fails.
|
||||
OPENSSL_memset(out, 0, requested);
|
||||
|
||||
if (!fill_with_entropy(out, requested, /*block=*/0) &&
|
||||
errno != EAGAIN) {
|
||||
perror("opportunistic entropy fill failed");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
#endif // BORINGSSL_FIPS
|
||||
|
||||
#endif // OPENSSL_URANDOM
|
||||
@@ -63,3 +63,7 @@ CRYPTO_rdrand_multiple8_buf:
|
||||
.size CRYPTO_rdrand_multiple8_buf,.-CRYPTO_rdrand_multiple8_buf
|
||||
#endif
|
||||
#endif // defined(__x86_64__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -63,3 +63,7 @@ L$err:
|
||||
|
||||
#endif
|
||||
#endif // defined(__x86_64__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -1035,7 +1035,7 @@ static int generate_prime(BIGNUM *out, int bits, const BIGNUM *e,
|
||||
}
|
||||
|
||||
// RSA key generation's bottleneck is discarding composites. If it fails
|
||||
// trial division, do not bother computing a GCD or performing Rabin-Miller.
|
||||
// trial division, do not bother computing a GCD or performing Miller-Rabin.
|
||||
if (!bn_odd_number_is_obviously_composite(out)) {
|
||||
// Check gcd(out-1, e) is one (steps 4.5 and 5.6).
|
||||
int relatively_prime;
|
||||
|
||||
@@ -1749,3 +1749,7 @@ rsaz_1024_gather5_avx2:
|
||||
.align 64
|
||||
#endif
|
||||
#endif // defined(__x86_64__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -1749,3 +1749,7 @@ L$inc:
|
||||
.p2align 6
|
||||
#endif
|
||||
#endif // defined(__x86_64__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <CNIOBoringSSL_crypto.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <CNIOBoringSSL_aead.h>
|
||||
#include <CNIOBoringSSL_aes.h>
|
||||
@@ -35,6 +36,21 @@
|
||||
// compile this.
|
||||
#if !defined(_MSC_VER)
|
||||
|
||||
#if defined(BORINGSSL_FIPS) && defined(OPENSSL_ANDROID)
|
||||
// FIPS builds on Android will test for flag files, named after the module hash,
|
||||
// in /dev/boringssl/selftest/. If such a flag file exists, it's assumed that
|
||||
// self-tests have already passed and thus do not need to be repeated. (The
|
||||
// integrity tests always run, however.)
|
||||
//
|
||||
// If self-tests complete successfully and the environment variable named in
|
||||
// |kFlagWriteEnableEnvVar| is present, then the flag file will be created. The
|
||||
// flag file isn't written without the environment variable being set in order
|
||||
// to avoid SELinux violations on Android.
|
||||
#define BORINGSSL_FIPS_SELF_TEST_FLAG_FILE
|
||||
static const char kFlagPrefix[] = "/dev/boringssl/selftest/";
|
||||
static const char kFlagWriteEnableEnvVar[] = "BORINGSSL_SELF_TEST_CREATE_FLAG";
|
||||
#endif
|
||||
|
||||
static void hexdump(const uint8_t *in, size_t len) {
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
fprintf(stderr, "%02x", in[i]);
|
||||
@@ -227,7 +243,42 @@ static EC_KEY *self_test_ecdsa_key(void) {
|
||||
return ec_key;
|
||||
}
|
||||
|
||||
int BORINGSSL_self_test(void) {
|
||||
#if defined(OPENSSL_ANDROID)
|
||||
static const size_t kModuleDigestSize = SHA256_DIGEST_LENGTH;
|
||||
#else
|
||||
static const size_t kModuleDigestSize = SHA512_DIGEST_LENGTH;
|
||||
#endif
|
||||
|
||||
int boringssl_fips_self_test(
|
||||
const uint8_t *module_hash, size_t module_hash_len) {
|
||||
#if defined(BORINGSSL_FIPS_SELF_TEST_FLAG_FILE)
|
||||
char flag_path[sizeof(kFlagPrefix) + 2*kModuleDigestSize];
|
||||
if (module_hash_len != 0) {
|
||||
if (module_hash_len != kModuleDigestSize) {
|
||||
fprintf(stderr,
|
||||
"module hash of length %zu does not match expected length %zu\n",
|
||||
module_hash_len, kModuleDigestSize);
|
||||
BORINGSSL_FIPS_abort();
|
||||
}
|
||||
|
||||
// Test whether the flag file exists.
|
||||
memcpy(flag_path, kFlagPrefix, sizeof(kFlagPrefix) - 1);
|
||||
static const char kHexTable[17] = "0123456789abcdef";
|
||||
for (size_t i = 0; i < kModuleDigestSize; i++) {
|
||||
flag_path[sizeof(kFlagPrefix) - 1 + 2 * i] =
|
||||
kHexTable[module_hash[i] >> 4];
|
||||
flag_path[sizeof(kFlagPrefix) - 1 + 2 * i + 1] =
|
||||
kHexTable[module_hash[i] & 15];
|
||||
}
|
||||
flag_path[sizeof(flag_path) - 1] = 0;
|
||||
|
||||
if (access(flag_path, F_OK) == 0) {
|
||||
// Flag file found. Skip self-tests.
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
#endif // BORINGSSL_FIPS_SELF_TEST_FLAG_FILE
|
||||
|
||||
static const uint8_t kAESKey[16] = "BoringCrypto Key";
|
||||
static const uint8_t kAESIV[16] = {0};
|
||||
static const uint8_t kPlaintext[64] =
|
||||
@@ -577,6 +628,16 @@ int BORINGSSL_self_test(void) {
|
||||
|
||||
ret = 1;
|
||||
|
||||
#if defined(BORINGSSL_FIPS_SELF_TEST_FLAG_FILE)
|
||||
// Tests were successful. Write flag file if requested.
|
||||
if (module_hash_len != 0 && getenv(kFlagWriteEnableEnvVar) != NULL) {
|
||||
const int fd = open(flag_path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
|
||||
if (fd >= 0) {
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
#endif // BORINGSSL_FIPS_SELF_TEST_FLAG_FILE
|
||||
|
||||
err:
|
||||
EVP_AEAD_CTX_cleanup(&aead_ctx);
|
||||
RSA_free(rsa_key);
|
||||
@@ -586,4 +647,8 @@ err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int BORINGSSL_self_test(void) {
|
||||
return boringssl_fips_self_test(NULL, 0);
|
||||
}
|
||||
|
||||
#endif // !_MSC_VER
|
||||
@@ -3808,3 +3808,7 @@ _sha1_block_data_order_avx:
|
||||
.byte 114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0
|
||||
#endif
|
||||
#endif // defined(__i386__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -1519,3 +1519,7 @@ OPENSSL_armcap_P:
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__arm__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -1511,3 +1511,7 @@ sha1_block_data_order_armv8:
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__arm__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -1233,3 +1233,7 @@ Lconst:
|
||||
.private_extern _OPENSSL_armcap_P
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__aarch64__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -1235,3 +1235,7 @@ sha1_block_armv8:
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__aarch64__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -3601,3 +3601,7 @@ K_XX_XX:
|
||||
.align 64
|
||||
#endif
|
||||
#endif // defined(__x86_64__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -3600,3 +3600,7 @@ K_XX_XX:
|
||||
.p2align 6
|
||||
#endif
|
||||
#endif // defined(__x86_64__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -5567,3 +5567,7 @@ sha256_block_data_order:
|
||||
.size sha256_block_data_order,.-.L_sha256_block_data_order_begin
|
||||
#endif
|
||||
#endif // defined(__i386__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -2847,3 +2847,7 @@ OPENSSL_armcap_P:
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__arm__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -2839,3 +2839,7 @@ sha256_block_data_order_armv8:
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__arm__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -1211,3 +1211,7 @@ Loop_hw:
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__aarch64__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -1213,3 +1213,7 @@ sha256_block_armv8:
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__aarch64__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -3973,3 +3973,7 @@ sha256_block_data_order_avx:
|
||||
.size sha256_block_data_order_avx,.-sha256_block_data_order_avx
|
||||
#endif
|
||||
#endif // defined(__x86_64__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -3972,3 +3972,7 @@ L$epilogue_avx:
|
||||
|
||||
#endif
|
||||
#endif // defined(__x86_64__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -2837,3 +2837,7 @@ sha512_block_data_order:
|
||||
.byte 62,0
|
||||
#endif
|
||||
#endif // defined(__i386__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -1900,3 +1900,7 @@ OPENSSL_armcap_P:
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__arm__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -1894,3 +1894,7 @@ sha512_block_data_order_neon:
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__arm__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -1083,3 +1083,7 @@ LK512:
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__aarch64__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -1085,3 +1085,7 @@ sha512_block_data_order:
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__aarch64__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -2992,3 +2992,7 @@ sha512_block_data_order_avx:
|
||||
.size sha512_block_data_order_avx,.-sha512_block_data_order_avx
|
||||
#endif
|
||||
#endif // defined(__x86_64__) && defined(__linux__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
@@ -2991,3 +2991,7 @@ L$epilogue_avx:
|
||||
|
||||
#endif
|
||||
#endif // defined(__x86_64__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
Loaded 100 of 149 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user