Skip to content

Commit

Permalink
Patch BoringSSL files for C tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonGross committed Oct 22, 2023
1 parent 6d981bc commit 5ad9efc
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
43 changes: 43 additions & 0 deletions etc/ci/boringssl-patches/2023-10-05-p256-adx.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
diff --git a/third_party/fiat/p256_64.h b/third_party/fiat/p256_64.h
index c772638..a691407 100644
--- a/third_party/fiat/p256_64.h
+++ b/third_party/fiat/p256_64.h

@@ -1,3 +1,9 @@
+#include "../../crypto/internal.h"
+#if !defined(OPENSSL_NO_ASM) && defined(__GNUC__) && defined(__x86_64__)
+void fiat_p256_adx_mul(uint64_t*, const uint64_t*, const uint64_t*);
+void fiat_p256_adx_sqr(uint64_t*, const uint64_t*);
+#endif
+
/* Autogenerated: 'src/ExtractionOCaml/word_by_word_montgomery' --inline --static --use-value-barrier p256 64 '2^256 - 2^224 + 2^192 + 2^96 - 1' mul square add sub opp from_montgomery to_montgomery nonzero selectznz to_bytes from_bytes one msat divstep divstep_precomp */
/* curve description: p256 */
/* machine_wordsize = 64 (from "64") */
@@ -165,6 +171,13 @@
*
*/
static FIAT_P256_FIAT_INLINE void fiat_p256_mul(fiat_p256_montgomery_domain_field_element out1, const fiat_p256_montgomery_domain_field_element arg1, const fiat_p256_montgomery_domain_field_element arg2) {
+#if !defined(OPENSSL_NO_ASM) && defined(__GNUC__) && defined(__x86_64__)
+ if (CRYPTO_is_BMI1_capable() && CRYPTO_is_BMI2_capable() &&
+ CRYPTO_is_ADX_capable()) {
+ fiat_p256_adx_mul(out1, arg1, arg2);
+ return;
+ }
+#endif
uint64_t x1;
uint64_t x2;
uint64_t x3;
@@ -472,6 +485,13 @@
*
*/
static FIAT_P256_FIAT_INLINE void fiat_p256_square(fiat_p256_montgomery_domain_field_element out1, const fiat_p256_montgomery_domain_field_element arg1) {
+#if !defined(OPENSSL_NO_ASM) && defined(__GNUC__) && defined(__x86_64__)
+ if (CRYPTO_is_BMI1_capable() && CRYPTO_is_BMI2_capable() &&
+ CRYPTO_is_ADX_capable()) {
+ fiat_p256_adx_sqr(out1, arg1);
+ return;
+ }
+#endif
uint64_t x1;
uint64_t x2;
uint64_t x3;
7 changes: 7 additions & 0 deletions etc/ci/test-fiat-c-boringssl.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env bash
# USAGE: $0 SUBCOMPONENT (e.g., fiat-c/src)

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

################################################################################
# Tests for BoringSSL
################################################################################
Expand Down Expand Up @@ -32,6 +34,11 @@ echo "::group::Patching BoringSSL"
cp "${SUBCOMPONENT_PATH}/${i/.h/.c}" "$i" || exit $?
done ) || exit $?
( cd third_party/fiat && git --no-pager diff )
( cd third_party/fiat &&
for i in "$DIR/boringssl-patches"/*.patch; do
git apply "$i"
done ) || exit $?
( cd third_party/fiat && git --no-pager diff )
}) || exit $?
echo "::endgroup::"

Expand Down

0 comments on commit 5ad9efc

Please sign in to comment.