Skip to content

Commit 22d7772

Browse files
[AUTO-CHERRYPICK] symcrypt: upgrade to 103.5.1 - branch 3.0-dev (#10815)
Co-authored-by: Tobias Brick <39196763+tobiasb-ms@users.noreply.github.com>
1 parent b5f1eb0 commit 22d7772

7 files changed

Lines changed: 214 additions & 26 deletions

SPECS/SymCrypt/0001-add-build-flags-to-prevent-stripping-and-post-proces.patch

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
1-
From a91f9a55e6b8b01511538827005a6e948ccf6e27 Mon Sep 17 00:00:00 2001
2-
From: Tobias Brick <tobiasb@microsoft.com>
3-
Date: Sat, 12 Oct 2024 02:06:21 +0000
4-
Subject: [PATCH] add build flags to prevent stripping and post processing
1+
From 997c3bdf24749edbdb562af15f9d95be35f062de Mon Sep 17 00:00:00 2001
2+
From: Tobias Brick <tobiasb@exchange.microsoft.com>
3+
Date: Tue, 15 Oct 2024 16:21:27 +0000
4+
Subject: [PATCH] Merged PR 11601893: add build flags to prevent stripping and
5+
post processing
56

7+
## Description:
8+
Add build flags to prevent stripping and post processing of binary after building. This is useful to fit in to different package build systems.
9+
10+
----
11+
#### AI description (iteration 1)
12+
#### PR Classification
13+
New feature
14+
15+
#### PR Summary
16+
This pull request introduces build flags to control binary stripping and FIPS postprocessing.
17+
- `CMakeLists.txt`: Added options `SYMCRYPT_STRIP_BINARY` and `SYMCRYPT_FIPS_POSTPROCESS` with default values set to `ON`.
18+
- `scripts/build.py`: Added command-line arguments `--no-strip-binary` and `--no-fips-postprocess` to control the new build options.
19+
- `BUILD.md`: Updated documentation to include the new build options.
20+
- `modules/linux/common/ModuleCommon.cmake`: Modified conditions to respect the new build flags for stripping and FIPS postprocessing.
621
---
722
BUILD.md | 2 ++
823
CMakeLists.txt | 14 ++++++++++++++
@@ -11,10 +26,10 @@ Subject: [PATCH] add build flags to prevent stripping and post processing
1126
4 files changed, 26 insertions(+), 2 deletions(-)
1227

1328
diff --git a/BUILD.md b/BUILD.md
14-
index e7f0618..a4984da 100644
29+
index f6c781d..e8eaa88 100644
1530
--- a/BUILD.md
1631
+++ b/BUILD.md
17-
@@ -63,6 +63,8 @@ and building the Linux modules with FIPS integrity checks.
32+
@@ -74,6 +74,8 @@ and building the Linux modules with FIPS integrity checks.
1833
* To cross-compile for Linux ARM64, you must also use `--toolchain=cmake-configs/Toolchain-Clang-ARM64.cmake`
1934
* `-DSYMCRYPT_USE_ASM=<ON|OFF>` to choose whether to use assembly optimizations. Defaults to `ON`.
2035
* `-DSYMCRYPT_FIPS_BUILD=<ON|OFF>` to choose whether to enable FIPS self-tests in the SymCrypt shared object module. Defaults to `ON`. Currently only affects Linux builds.
@@ -24,11 +39,11 @@ index e7f0618..a4984da 100644
2439
1. `cmake --build bin`
2540
* Optionally, for a release build on Windows, specify `--config Release`
2641
diff --git a/CMakeLists.txt b/CMakeLists.txt
27-
index 6da485d..1533e9d 100644
42+
index cd9aa15..9e0c599 100644
2843
--- a/CMakeLists.txt
2944
+++ b/CMakeLists.txt
30-
@@ -54,6 +54,18 @@ if(SYMCRYPT_FIPS_BUILD)
31-
add_compile_options(-DSYMCRYPT_DO_FIPS_SELFTESTS=1)
45+
@@ -56,6 +56,18 @@ if(SYMCRYPT_FIPS_BUILD)
46+
add_compile_definitions(SYMCRYPT_DO_FIPS_SELFTESTS=1)
3247
endif()
3348

3449
+option(
@@ -46,20 +61,20 @@ index 6da485d..1533e9d 100644
4661
option(
4762
SYMCRYPT_TEST_LEGACY_IMPL
4863
"When enabled, the SymCrypt unit tests will be linked against and configured to run compatibility and performance tests on the legacy
49-
@@ -94,6 +106,8 @@ message(STATUS "Host: ${CMAKE_HOST_SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_PROCESSOR}")
64+
@@ -104,6 +116,8 @@ message(STATUS "Host: ${CMAKE_HOST_SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_PROCESSOR}")
5065
message(STATUS "Target: ${CMAKE_SYSTEM_NAME} ${SYMCRYPT_TARGET_ARCH} ${SYMCRYPT_TARGET_ENV}")
5166
message(STATUS "ASM optimizations: ${SYMCRYPT_USE_ASM}")
5267
message(STATUS "FIPS build: ${SYMCRYPT_FIPS_BUILD}")
5368
+message(STATUS "Strip binary: ${SYMCRYPT_STRIP_BINARY}")
5469
+message(STATUS "FIPS postprocess: ${SYMCRYPT_FIPS_POSTPROCESS}")
5570

56-
# Set output directories binaries
57-
# Note: we use a generator expression because "Multi-configuration generators [e.g. Visual Studio]
71+
# Validate compiler versions
72+
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
5873
diff --git a/modules/linux/common/ModuleCommon.cmake b/modules/linux/common/ModuleCommon.cmake
59-
index ced60ac..7d626c0 100644
74+
index e6db214..fbe1421 100644
6075
--- a/modules/linux/common/ModuleCommon.cmake
6176
+++ b/modules/linux/common/ModuleCommon.cmake
62-
@@ -57,7 +57,7 @@ set_target_properties(${TARGET_NAME} PROPERTIES VERSION ${PROJECT_VERSION})
77+
@@ -61,7 +61,7 @@ set_target_properties(${TARGET_NAME} PROPERTIES VERSION ${PROJECT_VERSION})
6378
set_target_properties(${TARGET_NAME} PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR})
6479

6580

@@ -68,7 +83,7 @@ index ced60ac..7d626c0 100644
6883
add_custom_command(
6984
TARGET ${TARGET_NAME}
7085
POST_BUILD
71-
@@ -69,7 +69,7 @@ if(CMAKE_BUILD_TYPE MATCHES "Release|RelWithDebInfo")
86+
@@ -73,7 +73,7 @@ if(CMAKE_BUILD_TYPE MATCHES "Release|RelWithDebInfo")
7287
)
7388
endif()
7489

@@ -78,7 +93,7 @@ index ced60ac..7d626c0 100644
7893
TARGET ${TARGET_NAME}
7994
POST_BUILD
8095
diff --git a/scripts/build.py b/scripts/build.py
81-
index bbf0c89..48a7146 100755
96+
index af9b0bc..3a70b84 100755
8297
--- a/scripts/build.py
8398
+++ b/scripts/build.py
8499
@@ -101,6 +101,12 @@ def configure_cmake(args : argparse.Namespace) -> None:
@@ -94,7 +109,7 @@ index bbf0c89..48a7146 100755
94109
if args.test_legacy_impl:
95110
cmake_args.append("-DSYMCRYPT_TEST_LEGACY_IMPL=ON")
96111

97-
@@ -215,6 +221,8 @@ def main() -> None:
112+
@@ -218,6 +224,8 @@ def main() -> None:
98113
parser_cmake.add_argument("--cxx", type = str, help = "Specify the C++ compiler to use. If not provided, uses platform default.")
99114
parser_cmake.add_argument("--no-asm", action = "store_false", dest = "asm", help = "Disable handwritten ASM optimizations.", default = True)
100115
parser_cmake.add_argument("--no-fips", action = "store_false", dest = "fips", help = "Disable FIPS selftests and postprocessing of binary. Currently only affects Linux targets.", default = True)
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"Signatures": {
3-
"SymCrypt-103.4.2.tar.gz": "7cbcee7625fd1d99286e393a727504189dab4d407c6c3474bd2532d5ee231921",
3+
"SymCrypt-103.5.1.tar.gz": "1c4d41972f7683cb2c053ddc58452d6f4b56c1b556b7499f9fedbd7706ccd0fe",
44
"find-debuginfo": "356800f19b755879993103c121c83fb4cc97d0e8656ea34d051daa310f54cedf",
5-
"jitterentropy-library-3.3.1.tar.gz": "4a50cb02b4836cd5550016e2fc2263e6982abaa11467a9e1cea260c1c2f7d487"
5+
"jitterentropy-library-3.3.1.tar.gz": "4a50cb02b4836cd5550016e2fc2263e6982abaa11467a9e1cea260c1c2f7d487",
6+
"symcrypt-build-environment-variables-v103.5.1.sh": "6f6e162011e8203de66be6af59c0b4511992b731370a152044b028e8075578a7"
67
}
78
}

SPECS/SymCrypt/SymCrypt.spec

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Summary: A core cryptographic library written by Microsoft
22
Name: SymCrypt
3-
Version: 103.4.2
4-
Release: 2%{?dist}
3+
Version: 103.5.1
4+
Release: 1%{?dist}
55
License: MIT
66
Vendor: Microsoft Corporation
77
Distribution: Azure Linux
@@ -10,6 +10,9 @@ URL: https://github.com/microsoft/SymCrypt
1010
Source0: https://github.com/microsoft/SymCrypt/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
1111
Source1: https://github.com/smuellerDD/jitterentropy-library/archive/v3.3.1.tar.gz#/jitterentropy-library-3.3.1.tar.gz
1212
Source2: find-debuginfo
13+
# Use ./generate-env-file.sh --release-tag <git-version-tag> to generate this. For example:
14+
# ./generate-env-file.sh --release-tag v103.5.1
15+
Source3: symcrypt-build-environment-variables-v%{version}.sh
1316
Patch1: 0001-add-build-flags-to-prevent-stripping-and-post-proces.patch
1417
Patch2: 0001-add-parameter-to-process_fips_module-to-specify-the-.patch
1518
BuildRequires: cmake
@@ -48,9 +51,7 @@ rm -rf 3rdparty/jitterentropy-library
4851
ln -s ../jitterentropy-library-3.3.1 3rdparty/jitterentropy-library
4952

5053
%build
51-
SYMCRYPT_BRANCH=main \
52-
SYMCRYPT_COMMIT_HASH=a84ffe1 \
53-
SYMCRYPT_COMMIT_TIMESTAMP=2024-01-26T22:00:47-08:00 \
54+
source %{SOURCE3}
5455
cmake -S . -B bin \
5556
-DSYMCRYPT_TARGET_ARCH=%{symcrypt_arch} \
5657
-DSYMCRYPT_STRIP_BINARY=OFF \
@@ -104,6 +105,9 @@ chmod 755 %{buildroot}%{_libdir}/libsymcrypt.so.%{version}
104105
%{_includedir}/*
105106

106107
%changelog
108+
* Mon Oct 21 2024 Tobias Brick <tobiasb@microsoft.com> - 103.5.1-1
109+
- Update 103.5.1
110+
107111
* Mon Oct 14 2024 Tobias Brick <tobiasb@microsoft.com> - 103.4.2-2
108112
- Add debuginfo package
109113

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
From 1425f9e27cb1bae39e0b22e25fce50daa47618ca Mon Sep 17 00:00:00 2001
2+
From: Tobias Brick <tobiasb@exchange.microsoft.com>
3+
Date: Tue, 15 Oct 2024 22:59:08 +0000
4+
Subject: [PATCH] Merged PR 11618838: add parameter to version script to print
5+
the commit info environment variables
6+
7+
Add parameter to version script to print the commit info environment variables. This makes it easier to get those right for builds based on the source tarball rather than from a git clone.
8+
9+
----
10+
#### AI description (iteration 1)
11+
#### PR Classification
12+
New feature
13+
14+
#### PR Summary
15+
Added a new parameter to the version script to print commit information as environment variables.
16+
- `scripts/version.py`: Introduced `--commit-info` argument to print commit hash and timestamp as environment variables. Added `print_commit_info` function to handle this new feature.
17+
---
18+
scripts/version.py | 20 ++++++++++++++++++--
19+
1 file changed, 18 insertions(+), 2 deletions(-)
20+
21+
diff --git a/scripts/version.py b/scripts/version.py
22+
index 49edf9b..4ac1862 100644
23+
--- a/scripts/version.py
24+
+++ b/scripts/version.py
25+
@@ -180,27 +180,43 @@ def print_devops_vars(version_info: SymCryptVersion) -> None:
26+
set_task_variable("VER_MINOR", version_info.minor)
27+
set_task_variable("VER_PATCH", version_info.patch)
28+
29+
+def print_commit_info(version_info: SymCryptVersion) -> None:
30+
+ """
31+
+ Prints the commit information as environment variables that would override the commit hash and timestamp.
32+
+ """
33+
+
34+
+ print("export {}={}".format(ENV_SYMCRYPT_BRANCH, version_info.branch))
35+
+ print("export {}={}".format(ENV_SYMCRYPT_COMMIT_HASH, version_info.commit_hash))
36+
+ print("export {}={}".format(ENV_SYMCRYPT_COMMIT_TIMESTAMP, version_info.commit_timestamp.isoformat(timespec = "seconds")))
37+
+
38+
def main() -> None:
39+
"""
40+
Entrypoint
41+
"""
42+
43+
parser = argparse.ArgumentParser(description = "Versioning helper script for SymCrypt.")
44+
+ parser.add_argument("--no-print-version-number", dest = "print_version_number", help = "Do not print the version number", action = "store_false", default = True)
45+
group = parser.add_mutually_exclusive_group()
46+
group.add_argument("-b", "--build-info", help = "Generate buildInfo.h", action = "store_true")
47+
group.add_argument("--devops", help = "Format output to set Azure DevOps variables", action = "store_true")
48+
+ group.add_argument("--commit-info",
49+
+ help = "Format commit info as environment variables that would override the commit hash and timestamp, which can then be used when building from the source tarball rather than a git clone.",
50+
+ action = "store_true")
51+
52+
args = parser.parse_args()
53+
54+
# Parse the version information from the SymCrypt headers
55+
version_info = get_version_info()
56+
57+
- print("{}.{}.{}".format(version_info.major, version_info.minor, version_info.patch))
58+
+ if args.print_version_number:
59+
+ print("{}.{}.{}".format(version_info.major, version_info.minor, version_info.patch))
60+
61+
if args.build_info:
62+
generate_build_info(version_info)
63+
elif args.devops:
64+
print_devops_vars(version_info)
65+
+ elif args.commit_info:
66+
+ print_commit_info(version_info)
67+
68+
if __name__ == "__main__":
69+
- main()
70+
\ No newline at end of file
71+
+ main()
72+
--
73+
2.39.4
74+
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/bin/bash
2+
3+
# Fail out if anything fails.
4+
set -e
5+
6+
SYMCRYPT_REPO='https://github.com/microsoft/SymCrypt.git'
7+
SYMCRYPT_DIR='./SymCrypt'
8+
9+
CURRENT_DIR=$(pwd)
10+
RELEASE_TAG=
11+
12+
function show_help() {
13+
echo "Usage: $0 [--release-tag <tag>]"
14+
echo
15+
echo "Options:"
16+
echo " --release-tag <tag> The release tag to use for the build, e.g.: v103.5.1"
17+
echo " --debug Enable debug output, which is just 'set -x'"
18+
echo " --help Display this help message"
19+
echo
20+
echo "Generates a sourceable script file that sets git-related environment variables for the SymCrypt build."
21+
echo "The script file will be named 'symcrypt-build-environment-variables-<release-tag>.sh"
22+
}
23+
24+
while [[ "$#" -gt 0 ]]; do
25+
case $1 in
26+
-h|--help)
27+
show_help
28+
exit 0
29+
;;
30+
-t|--tag|--release-tag)
31+
RELEASE_TAG="$2"
32+
shift
33+
;;
34+
-d|--debug)
35+
set -x
36+
;;
37+
*)
38+
echo "Unknown parameter passed: $1"
39+
exit 1
40+
;;
41+
esac
42+
shift
43+
done
44+
45+
if [ -z "${RELEASE_TAG}" ]; then
46+
echo "release tag is required" >> /dev/stderr
47+
show_help
48+
exit 1
49+
fi
50+
51+
echo "generating env file for release tag: '${RELEASE_TAG}'"
52+
53+
# Create a temporary directory to clone the git repo
54+
TEMP_DIR=$(mktemp -d)
55+
if [[ ! "$TEMP_DIR" || ! -d "$TEMP_DIR" ]]; then
56+
echo "Could not create temp dir to clone git repo" >> /dev/stderr
57+
exit 1
58+
fi
59+
60+
# Clone into the temp directory
61+
pushd "${TEMP_DIR}" > /dev/null
62+
echo "Cloning SymCrypt repo '${SYMCRYPT_REPO}' into temp directory '${TEMP_DIR}"
63+
git clone "${SYMCRYPT_REPO}"
64+
65+
# The version script uses the current git branch, which want to main but at the commit for the release tag.
66+
echo "Getting to the commit for release tag '${RELEASE_TAG}'"
67+
cd "${SYMCRYPT_DIR}"
68+
TAG_COMMIT=$(git rev-parse --verify "${RELEASE_TAG}")
69+
if [[ ! "$TAG_COMMIT" ]]; then
70+
echo "Could not find commit for release tag '${RELEASE_TAG}'"
71+
exit 1
72+
fi
73+
echo "Tag commit is '${TAG_COMMIT}'"
74+
git reset --hard "${TAG_COMMIT}"
75+
76+
# Patching the version script; will be unneeded as of v103.5.2
77+
git apply "${CURRENT_DIR}/add-parameter-to-version-script-to-print-the-commit-info.patch"
78+
79+
# Call the version script to get the properly formmatted git info
80+
ENV_SCRIPT_FILE_NAME="symcrypt-build-environment-variables-${RELEASE_TAG}.sh"
81+
echo "#!/bin/bash" > "${CURRENT_DIR}/${ENV_SCRIPT_FILE_NAME}"
82+
echo "# Generated by 'generate-env-file.sh'" >> "${CURRENT_DIR}/${ENV_SCRIPT_FILE_NAME}"
83+
echo "Running version script"
84+
python3 scripts/version.py --no-print-version-number --commit-info >> "${CURRENT_DIR}/${ENV_SCRIPT_FILE_NAME}"
85+
echo "Generated '${ENV_SCRIPT_FILE_NAME}'"
86+
87+
# Clean up the temp directory
88+
popd > /dev/null
89+
rm -rf "${TEMP_DIR}"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
# Generated by 'generate-env-file.sh'
3+
export SYMCRYPT_BRANCH=main
4+
export SYMCRYPT_COMMIT_HASH=907622c
5+
export SYMCRYPT_COMMIT_TIMESTAMP=2024-09-18T20:38:10+00:00

cgmanifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28226,8 +28226,8 @@
2822628226
"type": "other",
2822728227
"other": {
2822828228
"name": "SymCrypt",
28229-
"version": "103.4.2",
28230-
"downloadUrl": "https://github.com/microsoft/SymCrypt/archive/v103.4.2.tar.gz"
28229+
"version": "103.5.1",
28230+
"downloadUrl": "https://github.com/microsoft/SymCrypt/archive/v103.5.1.tar.gz"
2823128231
}
2823228232
}
2823328233
},

0 commit comments

Comments
 (0)