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

cryptomb: add BN_bn2lebinpad definition for fips build #33756

Merged
merged 4 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
19 changes: 19 additions & 0 deletions bazel/foreign_cc/ipp-crypto-bn2lebinpad.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
diff --git a/sources/ippcp/crypto_mb/src/common/ifma_cvt52.c b/sources/ippcp/crypto_mb/src/common/ifma_cvt52.c
index e6db178c..0a1ecc49 100644
--- a/sources/ippcp/crypto_mb/src/common/ifma_cvt52.c
+++ b/sources/ippcp/crypto_mb/src/common/ifma_cvt52.c
@@ -16,9 +16,14 @@

#include <internal/common/ifma_defs.h>
#include <internal/common/ifma_math.h>
+#include <openssl/bn.h>

#include <assert.h>

+static int BN_bn2lebinpad(const BIGNUM *a, unsigned char *to, int tolen) {
+ return BN_bn2le_padded(to, tolen, a);
+}
+
#if defined(_MSC_VER) && (_MSC_VER < 1920)
// Disable optimization for VS2017 due to AVX512 masking bug
#define DISABLE_OPTIMIZATION __pragma(optimize( "", off ))
14 changes: 14 additions & 0 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ def envoy_dependencies(skip_targets = []):
_com_github_rules_proto_grpc()
_com_github_unicode_org_icu()
_com_github_intel_ipp_crypto_crypto_mb()
_com_github_intel_ipp_crypto_crypto_mb_fips()
_com_github_intel_qatlib()
_com_github_intel_qatzip()
_com_github_qat_zstd()
Expand Down Expand Up @@ -549,6 +550,19 @@ def _com_github_intel_ipp_crypto_crypto_mb():
build_file_content = BUILD_ALL_CONTENT,
)

def _com_github_intel_ipp_crypto_crypto_mb_fips():
# Temporary fix for building ipp-crypto when boringssl-fips is used.
# Build will fail if bn2lebinpad patch is applied. Remove this archive
# when upstream dependency fixes this issue.
external_http_archive(
name = "com_github_intel_ipp_crypto_crypto_mb_fips",
patches = ["@envoy//bazel/foreign_cc:ipp-crypto-bn2lebinpad.patch"],
patch_args = ["-p1"],
build_file_content = BUILD_ALL_CONTENT,
# Use existing ipp-crypto repository location name to avoid redefinition.
location_name = "com_github_intel_ipp_crypto_crypto_mb",
)

def _com_github_intel_qatlib():
external_http_archive(
name = "com_github_intel_qatlib",
Expand Down
2 changes: 1 addition & 1 deletion ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ case $CI_TARGET in
--define wasm=wasmtime \
--define enable_logging=disabled \
-c fastbuild \
@envoy//source/exe:envoy-static \
@envoy//contrib/exe:envoy-static \
phlax marked this conversation as resolved.
Show resolved Hide resolved
--build_tag_filters=-nofips
collect_build_profile build
;;
Expand Down
5 changes: 4 additions & 1 deletion contrib/cryptomb/private_key_providers/source/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ envoy_cmake(
defines = [
"OPENSSL_USE_STATIC_LIBS=TRUE",
],
lib_source = "@com_github_intel_ipp_crypto_crypto_mb//:all",
lib_source = select({
"//bazel:boringssl_fips": "@com_github_intel_ipp_crypto_crypto_mb_fips//:all",
"//conditions:default": "@com_github_intel_ipp_crypto_crypto_mb//:all",
}),
out_lib_dir = "lib/intel64",
out_static_libs = ["libcrypto_mb.a"],
tags = ["skip_on_windows"],
Expand Down