|
| 1 | +# Standard debuginfo generation breaks the FIPS self-test, so we disable it. |
| 2 | +%define debug_package %{nil} |
| 3 | +Summary: A core cryptographic library written by Microsoft |
| 4 | +Name: SymCrypt |
| 5 | +Version: 103.11.0 |
| 6 | +Release: %autorelease |
| 7 | +License: MIT |
| 8 | +Vendor: Microsoft Corporation |
| 9 | +Distribution: Azure Linux |
| 10 | +Group: System/Libraries |
| 11 | +URL: https://github.com/microsoft/SymCrypt |
| 12 | +Source0: https://github.com/microsoft/SymCrypt/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz |
| 13 | +Source1: https://github.com/smuellerDD/jitterentropy-library/archive/v3.3.1.tar.gz#/jitterentropy-library-3.3.1.tar.gz |
| 14 | +# Use ./generate-env-file.sh --release-tag <git-version-tag> to generate this. For example: |
| 15 | +# ./generate-env-file.sh --release-tag v103.5.1 |
| 16 | +Source3: symcrypt-build-environment-variables-v%{version}.sh |
| 17 | +BuildRequires: cmake |
| 18 | +%ifarch aarch64 |
| 19 | +BuildRequires: clang >= 12.0.1-4 |
| 20 | +%endif |
| 21 | +BuildRequires: gcc |
| 22 | +BuildRequires: gcc-c++ |
| 23 | +BuildRequires: libatomic |
| 24 | +BuildRequires: make |
| 25 | +BuildRequires: python3 |
| 26 | +BuildRequires: python3-pyelftools |
| 27 | + |
| 28 | +%description |
| 29 | +A core cryptographic library written by Microsoft |
| 30 | + |
| 31 | +# Only x86_64 and aarch64 are currently supported |
| 32 | +%ifarch x86_64 |
| 33 | +%define symcrypt_arch AMD64 |
| 34 | +%define symcrypt_cc gcc |
| 35 | +%define symcrypt_c_flags "-Wno-maybe-uninitialized" |
| 36 | +%define symcrypt_cxx g++ |
| 37 | +%endif |
| 38 | + |
| 39 | + |
| 40 | +%ifarch aarch64 |
| 41 | +%define symcrypt_arch ARM64 |
| 42 | +# Currently SymCrypt ARM64 build requires use of clang |
| 43 | +%define symcrypt_cc clang |
| 44 | +%define symcrypt_c_flags "-mno-outline-atomics -Wno-conditional-uninitialized" |
| 45 | +%define symcrypt_cxx clang++ |
| 46 | +%endif |
| 47 | + |
| 48 | +%prep |
| 49 | +%autosetup -a 1 -p1 |
| 50 | +# SymCrypt's tagged tarballs have jitterentropy as an empty directory, so we |
| 51 | +# create a symbolic link as if jitterentropy-library has been pulled in as git submodule |
| 52 | +rm -rf 3rdparty/jitterentropy-library |
| 53 | +ln -s ../jitterentropy-library-3.3.1 3rdparty/jitterentropy-library |
| 54 | + |
| 55 | +%build |
| 56 | +# CHANGE FROM 3.0: REMOVE -z pack-relative-relocs |
| 57 | +# AZL4's default LDFLAGS include -Wl,-z,pack-relative-relocs, which makes the |
| 58 | +# linker emit R_X86_64_RELATIVE entries in DT_RELR format instead of SHT_RELA. |
| 59 | +# SymCrypt's FIPS post-processor (process_fips_module.py) only walks SHT_RELA, |
| 60 | +# so RELR-packed relocations are not zeroed before the integrity HMAC is |
| 61 | +# computed. The dynamic loader still applies them at load time, so in-memory |
| 62 | +# bytes diverge from the hashed bytes and the FIPS self-test fails. Combined |
| 63 | +# with -z now, the failure surfaces as a SIGSEGV the instant libsymcrypt.so |
| 64 | +# is mapped (e.g. any LD_PRELOAD or DT_NEEDED user crashes immediately). |
| 65 | +# Remove until process_fips_module.py learns about DT_RELR. |
| 66 | +export LDFLAGS="${LDFLAGS//-Wl,-z,pack-relative-relocs/}" |
| 67 | + |
| 68 | +source %{SOURCE3} |
| 69 | + |
| 70 | +%cmake \ |
| 71 | + -DSYMCRYPT_TARGET_ARCH=%{symcrypt_arch} \ |
| 72 | + -DCMAKE_BUILD_TYPE=Release \ |
| 73 | + -DCMAKE_C_COMPILER=%{symcrypt_cc} \ |
| 74 | + -DCMAKE_CXX_COMPILER=%{symcrypt_cxx} \ |
| 75 | + -DCMAKE_C_FLAGS="%{symcrypt_c_flags}" \ |
| 76 | + -DCMAKE_CXX_FLAGS="-Wno-unused-but-set-variable" |
| 77 | + |
| 78 | +%cmake_build |
| 79 | + |
| 80 | +%install |
| 81 | +mkdir -p %{buildroot}%{_libdir} |
| 82 | +mkdir -p %{buildroot}%{_includedir} |
| 83 | +install inc/symcrypt* %{buildroot}%{_includedir} |
| 84 | +# Use cp -P to preserve symbolic links |
| 85 | +cp -P %{__cmake_builddir}/module/generic/libsymcrypt.so* %{buildroot}%{_libdir} |
| 86 | +chmod 755 %{buildroot}%{_libdir}/libsymcrypt.so.%{version} |
| 87 | + |
| 88 | +%check |
| 89 | +./%{__cmake_builddir}/exe/symcryptunittest |
| 90 | + |
| 91 | +%files |
| 92 | +%license LICENSE.txt |
| 93 | +%license NOTICE.txt |
| 94 | +%{_libdir}/libsymcrypt.so* |
| 95 | +%{_includedir}/* |
| 96 | + |
| 97 | +%changelog |
| 98 | +%autochangelog |
0 commit comments