Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge BoringSSL through 7b9b9baa95449d49019f7ce45b94963f8763005f #1656

Merged
merged 194 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
194 commits
Select commit Hold shift + click to select a range
1967621
Reduce architecture detection in CMake.
davidben Jan 25, 2023
c371b8b
Set C11 in all compilers.
davidben Jan 25, 2023
971b330
Use the same Deleter across all bssl::UniquePtr<T>.
davidben Jan 25, 2023
76a83aa
Align ppc assembly setup with other architectures
davidben Jan 26, 2023
50a5caf
Add CBS_get_u64_decimal.
davidben Dec 28, 2022
cbccae5
Remove ppc64le delocate and FIPS build.
davidben Jan 26, 2023
5fdc03f
Remove ppc64le assembly.
davidben Jan 26, 2023
68f4c72
Switch ERR_GET_* to inline functions
davidben Jan 27, 2023
7d2338d
Remove support for ppc64le.
davidben Jan 26, 2023
80a243e
Remove old Trust Token redeem API.
dvorak42 Jan 26, 2023
3a5c4ff
Add tests for X509_NAME_hash and X509_NAME_hash_old.
davidben Jan 5, 2023
42b7b35
Introduce a locale-independent version of isspace
davidben Jan 28, 2023
f81f16c
Introduce constants for ASN1_BOOLEAN
davidben Jan 28, 2023
915eb69
Add some tests for optional and default ASN1_BOOLEAN.
davidben Jan 28, 2023
112e1a7
Rewrite ASN1_generate_v3.
davidben Dec 30, 2022
33b5692
Add a fuzzer for the config file machinery.
davidben Dec 31, 2022
f86a63c
Introduce a locale-independent version of isdigit
Jan 30, 2023
a7fbc54
Remove now unnecessary check in CBS_peek_asn1_tag.
davidben Dec 11, 2022
507ac83
Fix error-handling in X509V3_EXT_add_nconf_sk and X509v3_add_ext.
davidben Jan 31, 2023
8a69c0d
Check for null value in set_dist_point_name.
davidben Jan 31, 2023
741c153
Align the generated CMake build with the main one.
davidben Jan 25, 2023
54b04fd
Mark standalone Go scripts with go:build ignore
davidben Jan 29, 2023
4ed497f
Fix stray */s in // line comment license headers
davidben Jan 29, 2023
f316547
Simplify a pair of Go range expressions
davidben Jan 29, 2023
23776d0
Simplify the external Bazel build.
davidben Dec 9, 2022
a5ab818
Define BORINGSSL_IMPLEMENTATION in the Bazel build
davidben Jan 31, 2023
07d3536
Fix leak on invalid input to a2i_GENERAL_NAME.
davidben Jan 31, 2023
62ab404
Make X509V3_get_value_int free the old value before overwriting it.
davidben Feb 1, 2023
2c12ebd
Remove the last of the broken NEON workaround
davidben Feb 1, 2023
1df70ce
Correctly handle optional ASN1_ITEM_TEMPLATE types.
davidben Dec 5, 2022
afa460c
Unexport and remove support for implicit tagging on ASN1_ITYPE_EXTERN.
davidben Dec 6, 2022
0a1af78
Remove ASN1_TFLG_COMBINE.
davidben Dec 11, 2022
67bb28c
Fix OPENSSL_NO_ASM builds with the generated CMake build.
davidben Feb 1, 2023
00c70b8
Add locale independent implementations of isalpha, isalnum, isdigit,
Feb 1, 2023
a1c7922
Align header guard style in the remaining headers.
davidben Jan 2, 2023
31f1466
Move OpenSSLConfig.cmake into the cmake/ directory
davidben Jan 29, 2023
50de086
Cap bit indices in the unsafe string-based X.509 extensions API
davidben Feb 2, 2023
3c70539
Fix leak on error in v2i_POLICY_MAPPINGS
davidben Feb 2, 2023
5bdf5e4
Silence an uninitialized variable false positive in GCC.
davidben Feb 1, 2023
aa83c12
Clear various false positives in RSA constant-time validation
davidben Feb 1, 2023
53b876a
Stop clang from un-constant-timing copy_from_prebuf.
davidben Feb 2, 2023
210674b
Fix some clang-format formatting.
davidben Jan 31, 2023
8f220ec
Clear false positives in RSA-OAEP constant time validation
davidben Feb 3, 2023
eb0b7e4
Fix leak in error-handling for issuingDistributionPoint
davidben Feb 3, 2023
a028a5e
Fix leak in set_dist_point_name error handling.
davidben Feb 6, 2023
db98bec
Const-correct the various EVP_PKEY PEM writers
davidben Feb 6, 2023
582904f
Move malloc failure testing into OPENSSL_malloc
davidben Feb 4, 2023
29564f2
Reject even moduli in RSA_check_key.
davidben Feb 3, 2023
3a16df9
Rearrange bn/generic.c
davidben Feb 2, 2023
d1b4516
Add bn_add_words and bn_sub_words assembly for aarch64.
davidben Feb 2, 2023
d4396e3
Avoid branches in GCC in bn/generic.c.
davidben Feb 1, 2023
a9ce915
Add ABI tests for bn_add_words, etc.
davidben Feb 6, 2023
5e356a8
Partially mitigate quadratic-time malloc tests in unit tests
davidben Feb 5, 2023
f7d37fb
Fix various malloc failure paths.
davidben Feb 5, 2023
8bc06cf
Clean up test_support_lib and GTest dependencies slightly.
davidben Feb 5, 2023
61266e4
Limit the CMake -isysroot assembly workaround to older CMake
davidben Jan 29, 2023
60d6119
Remove old clang-cl workaround
davidben Jan 29, 2023
f219ae9
Fix the type of x400Address in GENERAL_NAME
davidben Jan 31, 2023
e3912cd
Also test i2d_GENERAL_NAME in X509Test.GeneralName
davidben Feb 7, 2023
d3d7d36
Unexport GENERAL_NAME_cmp
davidben Feb 7, 2023
0586618
Trim unnecessary -lrt and ws2_32 deps in the build.
davidben Jan 29, 2023
70e415d
Remove if'd-out OCB-AES assembly
achernya Feb 7, 2023
49d7b2d
Remove stale TODO in util/bot/DEPS
davidben Feb 7, 2023
908b130
Don't use object reuse in X509_parse_from_buffer.
davidben Jan 16, 2023
d9ea555
Don't use negative values for unimplemented modes
davidben Feb 8, 2023
19721cd
Remove d2i_FOO object reuse
davidben Jan 16, 2023
6e20b77
Get rid of time_t usage internally, change to int64_t
Feb 8, 2023
261ec61
Move Go CMake support into its own file.
davidben Jan 29, 2023
04b3a96
Revert "Drop HRSS assembly."
agl Feb 8, 2023
8846d7b
VMS? I don't think so. Take this for a walk behind the barn.
Feb 9, 2023
9580424
Bound the overall output size of ASN1_generate_v3
davidben Feb 9, 2023
bd7e419
Generate Rust wrappers for HKDF
Feb 9, 2023
ace3316
Add a note in INCORPORATING about which branch to use
davidben Feb 10, 2023
350f854
Add OPENSSL_asprintf and friends for asprintf(3) functionality.
Feb 7, 2023
fc524c1
Make ERR and thread use system malloc.
Feb 7, 2023
d5e93f5
Cap decimal input sizes in s2i_ASN1_INTEGER
davidben Feb 13, 2023
dcabfe2
Make OPENSSL_malloc push ERR_R_MALLOC_FAILURE on failure.
Feb 8, 2023
ec64d7e
Fix a -Wignored-qualifiers warning in trust_token_test.cc
davidben Feb 10, 2023
9c9b2c2
Align the hash-to-curve formulation with draft-16.
davidben Feb 10, 2023
3950d6c
Implement P256_XMD:SHA-256_SSWU_RO_ and P384_XMD:SHA-384_SSWU_RO_
davidben Feb 10, 2023
de12e3c
Unify the two copies of bn_add_words and bn_sub_words
davidben Feb 14, 2023
0e68520
Specify -Iinclude with the crypto target.
davidben Feb 5, 2023
e5f7266
Don't include custom builds of libc++ in CMake installs
davidben Jan 29, 2023
8c75ed0
Remove global_target from build.
davidben Feb 5, 2023
503ba98
Remove proxy certificate support.
Feb 14, 2023
ca1690e
Tidy up check_chain_extensions after proxy certificate removal
davidben Feb 14, 2023
b8b924c
Use --allowlist-file in bssl-sys
davidben Feb 14, 2023
f30c031
Update build tools
davidben Feb 10, 2023
987dff1
Make boringssl_gtest_main a STATIC library
davidben Feb 15, 2023
890c201
Make EVP_PKEY opaque.
davidben Feb 8, 2023
ffb8050
Replace the union inside EVP_PKEY with void*.
davidben Feb 9, 2023
bab2f96
Revert go:build ignore lines
davidben Feb 16, 2023
badf673
Add bbe@ to list of reviewers
Feb 17, 2023
e18ba27
Move constants from .text to .rodata on aarch64
botovq Feb 17, 2023
bade461
Update Go dependencies
davidben Feb 21, 2023
016de5a
acvp: fix tests
agl Feb 17, 2023
f39826d
acvp: write updated tests without `.bz2` suffix
agl Feb 17, 2023
583c60b
acvp: update test expectations
agl Feb 17, 2023
9227295
Fix Android tests with new recipe changes
davidben Feb 22, 2023
7c860a4
Gracefully handle DSA objects with missing fields
davidben Feb 13, 2023
aa8d3b5
Reject zero ECDSA keys in EC_KEY_set_private_key
davidben Feb 11, 2023
85a1e2e
Revert "Revert "Fetch entropy from a system daemon in FIPS mode on An…
Jul 29, 2022
788bf74
Add more DSA consistency checks.
davidben Feb 13, 2023
474ddf8
Cap the number of ECDSA and DSA sign iterations.
davidben Feb 11, 2023
3cd7faa
Tweak urandom_test for Android devices without getrandom.
agl Feb 23, 2023
7864b14
Start a Kyber implementation with basic Keccak code.
agl Feb 17, 2023
ebd43ef
Move data from .text to .rodata on x86_64
botovq Feb 17, 2023
bffae8a
Print the reason the child stopped in urandom_test
davidben Feb 23, 2023
8251dd8
Pass the full user_regs_struct to PTRACE_SETREGS
davidben Feb 23, 2023
5eb9343
Go back to breaking syscalls with the syscall number
davidben Feb 23, 2023
6ab4f0a
Require getauxval on 32-bit Arm Linux
davidben Feb 21, 2023
7fa0910
Create the SSLKeyShare object in TLS 1.2 client ECDHE slightly later
davidben Jan 26, 2023
a5dcf35
Move the ASN.1-based SSLKeyShare serialization to handoff.cc.
davidben Jan 26, 2023
9cbff81
Simplify ECKeyShare slightly.
davidben Jan 26, 2023
55902f2
Switch to CIPD's copy of perl
davidben Feb 24, 2023
b3c2c75
Pick up a VS 2022 toolchain from Chromium
davidben Feb 24, 2023
f53ca9f
Run Go tests as part of run_tests
davidben Feb 24, 2023
1b666dd
Ignore elf.ErrNoSymbols in util/read_symbols.go
davidben Feb 27, 2023
8c4ec3b
Replace almost all instances of CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR
davidben Feb 27, 2023
92859cc
Fix the generated CMake build
davidben Feb 27, 2023
3c6085b
Workaround yet more NULL + 0 language bugs
davidben Feb 27, 2023
e3a5fac
Fix ninja run_tests
davidben Feb 27, 2023
f88b7c8
Use the common location for CMake in the bots
davidben Feb 27, 2023
028bae7
Define a NID for P-384 + Kyber768.
agl Feb 27, 2023
08b1f38
Use KEM terminology in TLS ECDHE and key_share abstractions
davidben Feb 28, 2023
76cb7c5
urandom_test: force MADV_WIPEONFORK both ways.
agl Mar 1, 2023
e06f172
Fix use of unitialized cbb on failure case.
Mar 2, 2023
93e8d44
Add a few more assertions to compiler_test.cc.
davidben Mar 2, 2023
3a7dfdb
Plug a leak in ASN1_item_i2d()
botovq Mar 5, 2023
abb9af8
Work around a NASM bug
davidben Mar 6, 2023
082e953
test_fips: flush stdout before aborting on failure.
prbprbprb Aug 25, 2022
a925c22
Remove EVP_PKEY_ASN1_METHOD and EVP_PKEY_METHOD from public headers
davidben Mar 7, 2023
ecb722a
Add prefetch to sha1_block_data_order_shaext
TocarIP Mar 6, 2023
8aa51dd
Add OPENSSL_EXPORT to BN_mod_inverse_blinded
rrliu Mar 9, 2023
be79283
initial setup for bssl crate with hmac and sha2 bindings
Feb 14, 2023
6f3e822
Rust build cleanup
Mar 14, 2023
39da68f
Rust bindings to boringssl plain AES implementation
Feb 17, 2023
50bc2ea
Tidy up HMAC_Init_ex slightly
davidben Mar 14, 2023
d0cff63
Test that X509_NAMEs sort their RDNs when encoding.
davidben Mar 14, 2023
8c7aa6b
Const-correct and document a few functions in x509v3.h.
davidben Mar 14, 2023
3002573
Hmac should be able to take longer keys
Mar 14, 2023
7464656
Add CTRDBG_STATE to bssl::UniquePtr
davidben Mar 15, 2023
6a231e5
Add a test for OPTIONAL CHOICE values
davidben Mar 12, 2023
860cc73
Reduce type-punning in ASN1_TYPE
davidben Mar 12, 2023
9ea4128
Set up cargo deny to deny new dependencies by default.
Mar 16, 2023
7b04d72
Get rid of the libc crate dependency in bssl-sys
Mar 16, 2023
cc57542
add bindings for hkdf and update panic handler
Feb 23, 2023
2cb7b33
Rewrite ASN1_OBJECT and ASN1_BOOLEAN d2i/i2d functions.
davidben Dec 29, 2022
173b639
Make ASN1_OBJECT_create size_t-clean.
davidben Jan 1, 2023
898de8d
Rewrite c2i_ASN1_OBJECT
davidben Mar 11, 2023
92de195
- remove dependency on hex-literal crate
Mar 20, 2023
8c8629b
Represent unknown universal types with V_ASN1_OTHER
davidben Mar 13, 2023
172b291
add bindings to RAND_bytes
Mar 20, 2023
2a52444
Reimplement X509 parsing without templates
davidben Mar 16, 2023
8ebfea7
Reject non-minimal lengths in ASN1_get_object
davidben Mar 16, 2023
b6a50fd
Give X509 an ASN1_ITEM again
davidben Mar 22, 2023
2e13e36
Fix parameter name for i2d_X509_EXTENSION
davidben Mar 23, 2023
0e8e3c6
Add a warning about OBJ_create and global state
davidben Mar 28, 2023
97d48db
Sort various X.509 global lists sooner
davidben Mar 28, 2023
af0739f
Const-correct sk_FOO_cmp_func
davidben Jan 9, 2023
678bae4
Remove dynamic X509_VERIFY_PARAM registration
davidben Mar 28, 2023
fca688f
Fix policy validation when the user policy set is NULL
davidben Mar 29, 2023
28226f5
Fix handling of critical X.509 policy constraints
davidben Mar 29, 2023
58472cc
Adding a C implementation of Kyber.
sophieschmieg Mar 7, 2023
bc49415
Add comment about regenerating peg files.
agl Mar 31, 2023
d897027
Update X25519+Kyber ID.
agl Mar 31, 2023
502d24c
Add various tests for memory BIOs.
davidben Apr 2, 2023
6e723e5
Convert a few more ints to bools in libssl.
davidben Mar 29, 2023
e8b168d
Fix size_t truncations in bio_mem.c
davidben Apr 1, 2023
44a389a
Tidy up some lengths in SSL_SESSION
davidben Dec 10, 2022
9a56503
RESOURCE_LEAK in method STACK_OF(TRUST_TOKEN) *voprf_unblind before r…
wangjiale3 Mar 31, 2023
0c069cb
Don't consume the newline in BIO_gets for fds
davidben Apr 3, 2023
8843d98
If the ret is not null, it needs to be released before return
wangjiale3 Mar 31, 2023
fe7a067
Run `go fmt` in `ssl/test/runner`.
agl Apr 10, 2023
bf1b792
Remove SSL_CIPHER_get_rfc_name
davidben Apr 11, 2023
a438519
Fix miscellaneous size_t truncations
davidben Mar 25, 2023
7b9b9ba
leaked_storage in method POLICYQUALINFO *notice_section
wangjiale3 Mar 31, 2023
25c9990
Ignore BoringSSL '1967621'..'aa83c12'.
briansmith Sep 28, 2023
8166b68
Merge BoringSSL '53b876a'.
briansmith Sep 28, 2023
1d98a79
Ignore BoringSSL '210674b'.
briansmith Sep 28, 2023
bcb347b
No-op merge of BoringSSL '8f220ec'.
briansmith Sep 28, 2023
8857252
Skip BoringSSL '3a16df9'.
briansmith Sep 28, 2023
0671a90
Partial merge of BoringSSL 'd1b4516': Add bn_add_words and bn_sub_wor…
briansmith Sep 28, 2023
4cffc85
Skip BoringSSL 'd4396e3': Avoid branches in GCC in bn/generic.c.
briansmith Sep 28, 2023
c93317d
Skip BoringSSL 'a9ce915': Add ABI tests for bn_add_words, etc.
briansmith Sep 28, 2023
f3b8acf
Ignore BoringSSL '5e356a8'..'0586618'
briansmith Sep 28, 2023
58565c6
No-op merge of BoringSSL '70e415d': Remove if'd-out OCB-AES assembly
briansmith Sep 28, 2023
58bb53d
Ignore BoringSSL '49d7b2d'..'badf673'.
briansmith Sep 28, 2023
7dcdf3c
Merge BoringSSL 'e18ba27': Move constants from .text to .rodata on aa…
briansmith Sep 28, 2023
126bfcd
Ignore BoringSSL 'bade461'..'7864b14'.
briansmith Sep 28, 2023
c833ff6
Merge BoringSSL 'ebd43ef': Move data from .text to .rodata on x86_64
briansmith Sep 28, 2023
533ecb6
Ignore BoringSSL 'bffae8a'..'3a7dfdb9'.
briansmith Sep 28, 2023
88331f0
Take BoringSSL 'abb9af8': Work around a NASM bug.
briansmith Sep 28, 2023
4faa980
Ignore BoringSSL '082e953'..'7b9b9ba'.
briansmith Sep 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crypto/chacha/asm/chacha-x86_64.pl
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@

.extern OPENSSL_ia32cap_P

.section .rodata
.align 64
.Lzero:
.long 0,0,0,0
Expand Down Expand Up @@ -107,6 +108,7 @@
.Lsixteen:
.long 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16
.asciz "ChaCha20 for x86_64, CRYPTOGAMS by <appro\@openssl.org>"
.text
___

sub AUTOLOAD() # thunk [simplified] 32-bit style perlasm
Expand Down
2 changes: 2 additions & 0 deletions crypto/cipher_extra/asm/chacha20_poly1305_x86_64.pl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

chacha20_poly1305_constants:

.section .rodata
.align 64
.Lchacha20_consts:
.byte 'e','x','p','a','n','d',' ','3','2','-','b','y','t','e',' ','k'
Expand Down Expand Up @@ -79,6 +80,7 @@
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00
.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
.text
___

my ($oup,$inp,$inl,$adp,$keyp,$itr1,$itr2,$adl)=("%rdi","%rsi","%rbx","%rcx","%r9","%rcx","%r8","%r8");
Expand Down
4 changes: 0 additions & 4 deletions crypto/curve25519/curve25519.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@
// Various pre-computed constants.
#include "./curve25519_tables.h"

#if defined(OPENSSL_NO_ASM)
#define FIAT_25519_NO_ASM
#endif

#if defined(BORINGSSL_CURVE25519_64BIT)
#if defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wpedantic"
Expand Down
2 changes: 2 additions & 0 deletions crypto/fipsmodule/aes/asm/aesni-x86_64.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1505,6 +1505,7 @@ sub aesni_generate8 {
}

$code.=<<___;
.section .rodata
.align 64
.Lbswap_mask:
.byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0
Expand All @@ -1525,6 +1526,7 @@ sub aesni_generate8 {

.asciz "AES for Intel AES-NI, CRYPTOGAMS by <appro\@openssl.org>"
.align 64
.text
___

# EXCEPTION_DISPOSITION handler (EXCEPTION_RECORD *rec,ULONG64 frame,
Expand Down
2 changes: 2 additions & 0 deletions crypto/fipsmodule/aes/asm/vpaes-x86_64.pl
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,7 @@
## ##
########################################################
.type _vpaes_consts,\@object
.section .rodata
.align 64
_vpaes_consts:
.Lk_inv: # inv, inva
Expand Down Expand Up @@ -941,6 +942,7 @@
.asciz "Vector Permutation AES for x86_64/SSSE3, Mike Hamburg (Stanford University)"
.align 64
.size _vpaes_consts,.-_vpaes_consts
.text
___

if ($win64) {
Expand Down
118 changes: 118 additions & 0 deletions crypto/fipsmodule/bn/asm/bn-armv8.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#!/usr/bin/env perl
# Copyright (c) 2023, 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.

use strict;

my $flavour = shift;
my $output = shift;
if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }

$0 =~ m/(.*[\/\\])[^\/\\]+$/;
my $dir = $1;
my $xlate;
( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or
( $xlate="${dir}../../../perlasm/arm-xlate.pl" and -f $xlate) or
die "can't locate arm-xlate.pl";

open OUT, "| \"$^X\" \"$xlate\" $flavour \"$output\"";
*STDOUT = *OUT;

my ($rp, $ap, $bp, $num) = ("x0", "x1", "x2", "x3");
my ($a0, $a1, $b0, $b1, $num_pairs) = ("x4", "x5", "x6", "x7", "x8");
my $code = <<____;
#include <ring-core/arm_arch.h>

.text

// BN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
// size_t num);
.type bn_add_words, %function
.globl bn_add_words
.align 4
bn_add_words:
AARCH64_VALID_CALL_TARGET
# Clear the carry flag.
cmn xzr, xzr

# aarch64 can load two registers at a time, so we do two loop iterations at
# at a time. Split $num = 2 * $num_pairs + $num. This allows loop
# operations to use CBNZ without clobbering the carry flag.
lsr $num_pairs, $num, #1
and $num, $num, #1

cbz $num_pairs, .Ladd_tail
.Ladd_loop:
ldp $a0, $a1, [$ap], #16
ldp $b0, $b1, [$bp], #16
sub $num_pairs, $num_pairs, #1
adcs $a0, $a0, $b0
adcs $a1, $a1, $b1
stp $a0, $a1, [$rp], #16
cbnz $num_pairs, .Ladd_loop

.Ladd_tail:
cbz $num, .Ladd_exit
ldr $a0, [$ap], #8
ldr $b0, [$bp], #8
adcs $a0, $a0, $b0
str $a0, [$rp], #8

.Ladd_exit:
cset x0, cs
ret
.size bn_add_words,.-bn_add_words

// BN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
// size_t num);
.type bn_sub_words, %function
.globl bn_sub_words
.align 4
bn_sub_words:
AARCH64_VALID_CALL_TARGET
# Set the carry flag. Arm's borrow bit is flipped from the carry flag,
# so we want C = 1 here.
cmp xzr, xzr

# aarch64 can load two registers at a time, so we do two loop iterations at
# at a time. Split $num = 2 * $num_pairs + $num. This allows loop
# operations to use CBNZ without clobbering the carry flag.
lsr $num_pairs, $num, #1
and $num, $num, #1

cbz $num_pairs, .Lsub_tail
.Lsub_loop:
ldp $a0, $a1, [$ap], #16
ldp $b0, $b1, [$bp], #16
sub $num_pairs, $num_pairs, #1
sbcs $a0, $a0, $b0
sbcs $a1, $a1, $b1
stp $a0, $a1, [$rp], #16
cbnz $num_pairs, .Lsub_loop

.Lsub_tail:
cbz $num, .Lsub_exit
ldr $a0, [$ap], #8
ldr $b0, [$bp], #8
sbcs $a0, $a0, $b0
str $a0, [$rp], #8

.Lsub_exit:
cset x0, cc
ret
size bn_sub_words,.-bn_sub_words
____

print $code;
close STDOUT or die "error closing STDOUT: $!";
2 changes: 2 additions & 0 deletions crypto/fipsmodule/bn/asm/x86_64-mont5.pl
Original file line number Diff line number Diff line change
Expand Up @@ -3576,11 +3576,13 @@
___
}
$code.=<<___;
.section .rodata
.align 64
.Linc:
.long 0,0, 1,1
.long 2,2, 2,2
.asciz "Montgomery Multiplication with scatter/gather for x86_64, CRYPTOGAMS by <appro\@openssl.org>"
.text
___

# EXCEPTION_DISPOSITION handler (EXCEPTION_RECORD *rec,ULONG64 frame,
Expand Down
48 changes: 32 additions & 16 deletions crypto/fipsmodule/ec/asm/p256-armv8-asm.pl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
$code.=<<___;
#include "ring-core/arm_arch.h"

.text
.section .rodata
.align 5
.Lpoly:
.quad 0xffffffffffffffff,0x00000000ffffffff,0x0000000000000000,0xffffffff00000001
Expand All @@ -71,6 +71,7 @@
.LordK:
.quad 0xccd1c8aaee00bc4f
.asciz "ECP_NISTZ256 for ARMv8, CRYPTOGAMS by <appro\@openssl.org>"
.text

// void ecp_nistz256_mul_mont(BN_ULONG x0[4],const BN_ULONG x1[4],
// const BN_ULONG x2[4]);
Expand All @@ -86,8 +87,10 @@
ldr $bi,[$bp] // bp[0]
ldp $a0,$a1,[$ap]
ldp $a2,$a3,[$ap,#16]
ldr $poly1,.Lpoly+8
ldr $poly3,.Lpoly+24
adrp $poly3,:pg_hi21:.Lpoly
add $poly3,$poly3,:lo12:.Lpoly
ldr $poly1,[$poly3,#8]
ldr $poly3,[$poly3,#24]

bl __ecp_nistz256_mul_mont

Expand All @@ -109,8 +112,10 @@

ldp $a0,$a1,[$ap]
ldp $a2,$a3,[$ap,#16]
ldr $poly1,.Lpoly+8
ldr $poly3,.Lpoly+24
adrp $poly3,:pg_hi21:.Lpoly
add $poly3,$poly3,:lo12:.Lpoly
ldr $poly1,[$poly3,#8]
ldr $poly3,[$poly3,#24]

bl __ecp_nistz256_sqr_mont

Expand All @@ -134,8 +139,10 @@
mov $acc1,xzr
mov $acc2,xzr
mov $acc3,xzr
ldr $poly1,.Lpoly+8
ldr $poly3,.Lpoly+24
adrp $poly3,:pg_hi21:.Lpoly
add $poly3,$poly3,:lo12:.Lpoly
ldr $poly1,[$poly3,#8]
ldr $poly3,[$poly3,#24]

bl __ecp_nistz256_sub_from

Expand Down Expand Up @@ -513,9 +520,11 @@
mov $rp_real,$rp
ldp $acc2,$acc3,[$ap,#48]
mov $ap_real,$ap
ldr $poly1,.Lpoly+8
adrp $poly3,:pg_hi21:.Lpoly
add $poly3,$poly3,:lo12:.Lpoly
ldr $poly1,[$poly3,#8]
mov $t0,$acc0
ldr $poly3,.Lpoly+24
ldr $poly3,[$poly3,#24]
mov $t1,$acc1
ldp $a0,$a1,[$ap_real,#64] // forward load for p256_sqr_mont
mov $t2,$acc2
Expand Down Expand Up @@ -674,8 +683,10 @@
mov $rp_real,$rp
mov $ap_real,$ap
mov $bp_real,$bp
ldr $poly1,.Lpoly+8
ldr $poly3,.Lpoly+24
adrp $poly3,:pg_hi21:.Lpoly
add $poly3,$poly3,:lo12:.Lpoly
ldr $poly1,[$poly3,#8]
ldr $poly3,[$poly3,#24]
orr $t0,$a0,$a1
orr $t2,$a2,$a3
orr $in2infty,$t0,$t2
Expand Down Expand Up @@ -928,8 +939,10 @@
mov $rp_real,$rp
mov $ap_real,$ap
mov $bp_real,$bp
ldr $poly1,.Lpoly+8
ldr $poly3,.Lpoly+24
adrp $poly3,:pg_hi21:.Lpoly
add $poly3,$poly3,:lo12:.Lpoly
ldr $poly1,[$poly3,#8]
ldr $poly3,[$poly3,#24]

ldp $a0,$a1,[$ap,#64] // in1_z
ldp $a2,$a3,[$ap,#64+16]
Expand Down Expand Up @@ -1080,7 +1093,8 @@
stp $acc2,$acc3,[$rp_real,#$i+16]
___
$code.=<<___ if ($i == 0);
adr $bp_real,.Lone_mont-64
adrp $bp_real,:pg_hi21:.Lone_mont-64
add $bp_real,$bp_real,:lo12:.Lone_mont-64
___
}
$code.=<<___;
Expand Down Expand Up @@ -1131,7 +1145,8 @@
stp x21,x22,[sp,#32]
stp x23,x24,[sp,#48]

adr $ordk,.Lord
adrp $ordk,:pg_hi21:.Lord
add $ordk,$ordk,:lo12:.Lord
ldr $bi,[$bp] // bp[0]
ldp $a0,$a1,[$ap]
ldp $a2,$a3,[$ap,#16]
Expand Down Expand Up @@ -1274,7 +1289,8 @@
stp x21,x22,[sp,#32]
stp x23,x24,[sp,#48]

adr $ordk,.Lord
adrp $ordk,:pg_hi21:.Lord
add $ordk,$ordk,:lo12:.Lord
ldp $a0,$a1,[$ap]
ldp $a2,$a3,[$ap,#16]

Expand Down
2 changes: 2 additions & 0 deletions crypto/fipsmodule/ec/asm/p256-x86_64-asm.pl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
.extern OPENSSL_ia32cap_P

# The polynomial
.section .rodata
.align 64
.Lpoly:
.quad 0xffffffffffffffff, 0x00000000ffffffff, 0x0000000000000000, 0xffffffff00000001
Expand All @@ -80,6 +81,7 @@
.quad 0xf3b9cac2fc632551, 0xbce6faada7179e84, 0xffffffffffffffff, 0xffffffff00000000
.LordK:
.quad 0xccd1c8aaee00bc4f
.text
___

{
Expand Down
4 changes: 0 additions & 4 deletions crypto/fipsmodule/ec/p256.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@
#pragma GCC diagnostic ignored "-Winline"
#endif

#if defined(OPENSSL_NO_ASM)
#define FIAT_P256_NO_ASM
#endif

#if defined(BORINGSSL_HAS_UINT128)
#if defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wpedantic"
Expand Down
2 changes: 2 additions & 0 deletions crypto/fipsmodule/modes/asm/aesni-gcm-x86_64.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,7 @@
___

$code.=<<___;
.section .rodata
.align 64
.Lbswap_mask:
.byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0
Expand All @@ -1066,6 +1067,7 @@
.byte 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.asciz "AES-NI GCM module for x86_64, CRYPTOGAMS by <appro\@openssl.org>"
.align 64
.text
___
}}} else {{{
$code=<<___; # assembler is too old
Expand Down
2 changes: 2 additions & 0 deletions crypto/fipsmodule/modes/asm/ghash-x86_64.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1286,6 +1286,7 @@ sub reduction_avx {
}

$code.=<<___;
.section .rodata
.align 64
.Lbswap_mask:
.byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0
Expand All @@ -1297,6 +1298,7 @@ sub reduction_avx {

.asciz "GHASH for x86_64, CRYPTOGAMS by <appro\@openssl.org>"
.align 64
.text
___

$code =~ s/\`([^\`]*)\`/eval($1)/gem;
Expand Down
Loading