Skip to content

Commit 44f3d7d

Browse files
Willy Zhangwillyzha
authored andcommitted
Enable ML-DSA support via hermetic OpenSSL 3.5.5 build
Integrates OpenSSL 3.5.5 to provide FIPS 204 (ML-DSA) support. Signed-off-by: Willy Zhang <[email protected]>
1 parent de25891 commit 44f3d7d

File tree

4 files changed

+64
-11
lines changed

4 files changed

+64
-11
lines changed

MODULE.bazel

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,15 @@ http_archive(
324324
urls = ["https://github.com/inazarenko/protobuf-matchers/archive/7c8e15741bcea83db7819cc472c3e96301a95158.zip"],
325325
)
326326

327+
# OpenSSL 3.5.5
328+
http_archive(
329+
name = "openssl",
330+
build_file = "//third_party/openssl:BUILD.openssl.bazel",
331+
sha256 = "4ca7d770686ae621c88c78ee20a49c11aaa984c354ed038137ba87850e5386b8",
332+
strip_prefix = "openssl-openssl-3.5.5",
333+
urls = ["https://github.com/openssl/openssl/archive/refs/tags/openssl-3.5.5.tar.gz"],
334+
)
335+
327336
# SoftHSM2
328337
http_archive(
329338
name = "softhsm2",

third_party/openssl/BUILD.bazel

Whitespace-only changes.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Copyright lowRISC contributors (OpenTitan project).
2+
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
load("@rules_foreign_cc//foreign_cc:configure.bzl", "configure_make")
6+
7+
package(default_visibility = ["//visibility:public"])
8+
9+
filegroup(
10+
name = "all_srcs",
11+
srcs = glob(["**"]),
12+
)
13+
14+
configure_make(
15+
name = "openssl",
16+
args = ["DESTDIR=$INSTALLDIR"],
17+
configure_command = "Configure",
18+
configure_options = [
19+
"no-shared",
20+
"no-tests",
21+
"no-engine",
22+
"no-dso",
23+
"no-comp",
24+
"no-idea",
25+
"no-mdc2",
26+
"no-rc5",
27+
"no-ssl3",
28+
"no-weak-ssl-ciphers",
29+
"no-apps",
30+
"-fPIC",
31+
"--prefix=/",
32+
"--openssldir=/ssl",
33+
"--libdir=lib",
34+
],
35+
env = select({
36+
"@platforms//os:linux": {
37+
"AR": "ar",
38+
},
39+
"//conditions:default": {},
40+
}),
41+
lib_source = ":all_srcs",
42+
out_static_libs = [
43+
"libssl.a",
44+
"libcrypto.a",
45+
],
46+
# OpenSSL's Configure script doesn't like some of the default flags
47+
# passed by rules_foreign_cc, so we keep it simple.
48+
targets = ["install_sw"],
49+
)

third_party/softhsm2/BUILD.softhsm2.bazel

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,33 +20,28 @@ cmake(
2020
"ENABLE_ECC": "ON",
2121
"ENABLE_MLDSA": "ON",
2222
"WITH_CRYPTO_BACKEND": "openssl",
23-
24-
# This build is for tests only.
25-
# "CMAKE_BUILD_TYPE": "Debug",
23+
"OPENSSL_USE_STATIC_LIBS": "ON",
2624

2725
# SoftHSM wants to dump a bunch of nonsense into /etc, which is
2826
# not relevant to our use-case. To discard it, we set all of these
2927
# variables, which determine where all those files *would* land,
3028
# to the CMake build directory.
3129
"CMAKE_INSTALL_LOCALSTATEDIR": ".",
3230
"CMAKE_INSTALL_SYSCONFDIR": ".",
33-
"PROJECT_BINARY_DIR": ".",
34-
"CMAKE_CXX_FLAGS": "-DWITH_ML_DSA",
31+
"CMAKE_CXX_FLAGS": "-DWITH_ML_DSA -DWITHOUT_OPENSSL_ENGINES",
3532
},
3633
# Set up SoftHSM to provide useful debug messages during testing.
3734
copts = [
3835
# Uncomment this for verbose logging from SoftHSM.
3936
# "-DDEBUG_LOG_STDERR",
4037
# "-DSOFTHSM_LOG_FUNCTION_NAME",
4138
],
39+
env = {
40+
"OPENSSL_ROOT_DIR": "$$EXT_BUILD_DEPS/openssl",
41+
},
4242
generate_args = ["-GNinja"],
4343
lib_source = ":all_srcs",
4444
out_binaries = ["softhsm2-util"],
4545
out_shared_libs = ["softhsm/libsofthsm2.so"],
46-
# `install` is not smart enough to figure out that it needs to build
47-
# everything, so we specify "" here explicitly.
48-
targets = [
49-
"",
50-
"libsofthsm2.so",
51-
],
46+
deps = ["@openssl"],
5247
)

0 commit comments

Comments
 (0)