Skip to content

Commit 88481f7

Browse files
committed
Merged PR 10509720: Make msbignum and rsa32 optional for MSBuild
This change updates the MSBuild projects to make the inclusion of msbignum and rsa32 optional. This will allow external users to more easily use MSBuild, and also unblock testing potential future changes to undocked pipelines.
1 parent 50239fe commit 88481f7

File tree

6 files changed

+42
-22
lines changed

6 files changed

+42
-22
lines changed

.pipelines/templates/build-windows-undocked.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ jobs:
127127
configuration: $(ob_build_config)
128128
maximumCpuCount: true
129129
restoreNugetPackages: ${{ parameters.restoreNugetPackages }}
130-
msbuildArgs: '-p:UndockedOfficial=${{ parameters.nativeCompiler }} -p:UndockedBuildId=$(Build.BuildId) -p:VER_BUILD_ID=$(Build.BuildId) -p:VER_SUFFIX=${{ parameters.buildSuffix }} ${{ parameters.msbuildArgs }}'
130+
msbuildArgs: '-p:UndockedOfficial=${{ parameters.nativeCompiler }} -p:UndockedBuildId=$(Build.BuildId) -p:VER_BUILD_ID=$(Build.BuildId) -p:VER_SUFFIX=${{ parameters.buildSuffix }} -p:SymCryptTestLegacyImpl=true ${{ parameters.msbuildArgs }}'
131131

132132
# Overwrite default artifact publishing with our copy (enables publishing binaries for failed runs)
133133
- task: PowerShell@2

BUILD.md

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ combinations, and we're working on adding support for more.
1717
SymCrypt supports a variety of operating systems, CPU architectures, and runtime environments, but due to functionality
1818
gaps in the build systems we use, not every combination is supported by every build system. Specifically, because
1919
CMake does not currently support building kernel mode components, we also support MSBuild for building kernel-mode
20-
libraries on Windows. Internally, we used Razzle as our legacy build system, but SymCrypt's support for Razzle builds
21-
is on a deprecation path and will be removed in a future release. Additionally, it has not been tested with the
22-
public open source version of Razzle, and is unlikely to work with it.
20+
libraries on Windows. Internally, we previously used Razzle as our legacy build system, but SymCrypt's support
21+
for Razzle builds is on a deprecation path and will be removed in a future release. Additionally, it has not been
22+
tested with the public open source version of Razzle, and is unlikely to work with it.
2323

2424
The ability to build SymCrypt on any particular platform or architecture, with or without ASM optimizations, does not
2525
imply that it has been tested for or is actively supported by Microsoft on that platform/architecture. While we make
@@ -30,18 +30,19 @@ warranties of merchantability, fitness for a particular purpose and noninfringem
3030
## Build Instructions
3131
For Microsoft employees building the library internally, to include msbignum and RSA32 implementation benchmarks in
3232
the unit tests, make sure the SymCryptDependencies submodule is initialized by following the steps above
33-
(`git submodule update --init`). When building, provide the additional CMake argument `-DSYMCRYPT_TEST_LEGACY_IMPL=ON`.
34-
This only affects the unit tests, and does not change the functionality of the SymCrypt library itself.
33+
(`git submodule update --init`). When building, specify `/p:SymCryptTestLegacyImpl=true` for MSBuild,
34+
or `-DSYMCRYPT_TEST_LEGACY_IMPL=ON` for CMake. This only affects the unit tests, and does not change the
35+
functionality of the SymCrypt library itself.
3536

3637
### Using Python scripts
3738
Building SymCrypt can be complicated due to the number of platforms, architectures and targets supported. To improve
38-
ease of use and have a consistent build solution that can be leveraged by both developers and our automated CI pipelines,
39-
we have created a set of Python scripts to help with building, testing and packaging. You can run `scripts/build.py --help`
40-
to get help with supported options.
39+
ease of use and have a consistent build solution that can be leveraged by both developers and our automated CI
40+
pipelines, we have created a set of Python scripts to help with building, testing and packaging. You can run
41+
`scripts/build.py --help` to get help with supported options.
4142

4243
1. To build SymCrypt for Windows or Linux using the CMake build system, run `scripts/build.py cmake build_dir` where `build_dir` is the desired build output directory.
4344
* To see additional options, run `scripts/build.py cmake --help`.
44-
* On Windows, the the build script also supports MSBuild. Currently this is for internal use only. To use MSBuild, run `scripts\build.py msbuild`. The output directory for MSBuild is always `build\bin`.
45+
* On Windows, the the build script also supports MSBuild. To use MSBuild, run `scripts\build.py msbuild`. The output directory for MSBuild is always `build\bin`.
4546
1. To run the unit tests after a build has finished, run `scripts/test.py build_dir`.
4647
* Additional positional arguments will be passed directly to the unit test executable.
4748
1. To package up the built binaries into an archive, run `scripts/package.py build_dir arch configuration module_name release_dir`, where:
@@ -52,9 +53,9 @@ to get help with supported options.
5253
* `release_dir` is the output directory for the release archive
5354

5455
### Building with CMake
55-
If you don't want to use the Python helper scripts, or if they do not support the specific build flags you desire, you can
56-
build SymCrypt by directly invoking CMake. Note that Python is still required for translating SymCryptAsm and building the
57-
Linux modules with FIPS integrity checks.
56+
If you don't want to use the Python helper scripts, or if they do not support the specific build flags you desire,
57+
you can build SymCrypt by directly invoking CMake. Note that Python is still required for translating SymCryptAsm
58+
and building the Linux modules with FIPS integrity checks.
5859

5960
1. Run `cmake -S . -B bin` to configure your build. You can add the following optional CMake arguments to change build options:
6061
* `-DSYMCRYPT_TARGET_ARCH=<AMD64|X86|ARM64>` to choose a target architecture. If not specified, it will default to the host system architecture.
@@ -74,12 +75,11 @@ to your build directory:
7475
* `exe` - unit tests
7576

7677
### Building with MSBuild
77-
Currently, MSBuild is only supported internally for use in Azure DevOps pipelines that produce artifacts for Windows.
78-
Building the SymCrypt unit tests with MSBuild requires access to the msbignum and RSA32 implementations, which cannot
79-
be released externally due to licensing restrictions. If you wish to build directly with MSBuild, bypassing the Python
80-
helper script, you can run `msbuild /p:Platform=<platform> /p:Architecture=<arch> symcrypt.sln`. Note that Python is
81-
still required for translating SymCryptAsm. The output directory for MSBuild is always `build\bin`, and all compiled
82-
outputs are placed in this directory.
78+
SymCrypt also supports building with MSBuild on Windows. This is primarily intended for Microsoft-internal use in
79+
official builds, for compatibility with the Windows engineering system. If you wish to build directly with MSBuild,
80+
bypassing the Python helper script, you can run `msbuild /p:Platform=<platform> /p:Architecture=<arch> symcrypt.sln`.
81+
Note that Python is still required for translating SymCryptAsm. The output directory for MSBuild is always `build\bin`,
82+
and all compiled outputs are placed in this directory.
8383

8484
## Building Linux targets
8585

@@ -104,19 +104,24 @@ qemu-arm -L /usr/arm-linux-gnueabihf/ ./bin_arm/exe/symcryptunittest -rsa -dsa -
104104
```
105105

106106
## Performance comparison with OpenSSL
107-
`symcryptunittest.exe` can be used to compare and measure performance of algorithms provided by SymCrypt and OpenSSL. On Windows `symcryptunittest.exe` would have to be compiled with OpenSSL. `nasm` and `strawberryperl` are prerequisites to building OpenSSL.
107+
`symcryptunittest.exe` can be used to compare and measure performance of algorithms provided by SymCrypt and OpenSSL.
108+
On Windows `symcryptunittest.exe` would have to be compiled with OpenSSL. `nasm` and `strawberryperl` are
109+
prerequisites to building OpenSSL.
110+
108111
```
109112
winget install nasm strawberryperl
110113
.\scripts\build.py cmake bin --config Release --openssl-build-from-source
111114
```
112115

113116
And on Linux we can use OpenSSL installed by system's package manager.
117+
114118
```
115119
sudo apt install -y libssl-dev
116120
./scripts/build.py cmake bin --config Release --openssl
117121
```
118122

119123
To build OpenSSL on Linux we need to install following prerequisites.
124+
120125
```
121126
sudo apt install -y nasm perl
122127
.\scripts\build.py cmake bin --config Release --openssl-build-from-source

msbuild/symcrypt.undocked.props

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
<Import Project="$(VCTargetsPath)\BuildCustomizations\marmasm.props" />
99
</ImportGroup>
1010

11+
<PropertyGroup>
12+
<SymCryptTestLegacyImpl Condition="'$(SymCryptTestLegacyImpl)' == ''">false</SymCryptTestLegacyImpl>
13+
</PropertyGroup>
14+
1115
<PropertyGroup Label="IncludePath">
1216
<IncludePath>$(SolutionDir)inc;$(WindowsSdkDir)Include\$(TargetPlatformVersion)\km;$(IncludePath);</IncludePath>
1317
</PropertyGroup>
@@ -28,6 +32,8 @@
2832
<CharacterSet>MultiByte</CharacterSet>
2933
<WholeProgramOptimization>true</WholeProgramOptimization>
3034
<AdditionalOptions>/Gy %(AdditionalOptions)</AdditionalOptions>
35+
<!-- Only applicable to unit tests: exclude private legacy implementations unless explicitly specified -->
36+
<PreprocessorDefinitions Condition="$(SymCryptTestLegacyImpl)!='true'">INCLUDE_IMPL_MSBIGNUM=0;INCLUDE_IMPL_RSA32=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
3137
</ClCompile>
3238
<MASM>
3339
<GenerateDebugInformation>true</GenerateDebugInformation>

unittest/exe_test/SymCryptUnitTest.vcxproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,12 @@
4141
<SubSystem>Console</SubSystem>
4242
<GenerateDebugInformation>true</GenerateDebugInformation>
4343
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
44-
<AdditionalDependencies>%(AdditionalDependencies);rsa32.lib;msbignum.lib;ntdll.lib;Bcrypt.lib</AdditionalDependencies>
44+
<AdditionalDependencies>%(AdditionalDependencies);ntdll.lib;Bcrypt.lib</AdditionalDependencies>
4545
<AdditionalLibraryDirectories>..\SymCryptDependencies\$(ProcessorArchitecture)</AdditionalLibraryDirectories>
4646
</Link>
47+
<Link Condition="'$(SymCryptTestLegacyImpl)'=='true'">
48+
<AdditionalDependencies>%(AdditionalDependencies);rsa32.lib;msbignum.lib</AdditionalDependencies>
49+
</Link>
4750
</ItemDefinitionGroup>
4851
<ItemGroup>
4952
<ClCompile Include="main_exe.cpp" />

unittest/inc/test_lib.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,12 +465,18 @@ extern "C" {
465465
#define INCLUDE_IMPL_CNG (1)
466466
#endif
467467

468+
#if !defined( INCLUDE_IMPL_OPENSSL )
469+
// OpenSSL implementation is disabled by default
470+
#define INCLUDE_IMPL_OPENSSL (0)
471+
#endif
472+
468473
#if !defined( INCLUDE_IMPL_REF )
469474
#define INCLUDE_IMPL_REF (1)
470475
#endif
471476

472477

473478

479+
474480
//
475481
// Our own header info
476482
//

unittest/module_windows/symcrypttestmodule.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<GenerateDebugInformation>true</GenerateDebugInformation>
4343
<EnableUAC>false</EnableUAC>
4444
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
45-
<AdditionalDependencies>%(AdditionalDependencies);rsa32.lib;msbignum.lib;ntdll.lib;Bcrypt.lib</AdditionalDependencies>
45+
<AdditionalDependencies>%(AdditionalDependencies);ntdll.lib;Bcrypt.lib</AdditionalDependencies>
4646
<AdditionalLibraryDirectories>..\SymCryptDependencies\$(ProcessorArchitecture)</AdditionalLibraryDirectories>
4747
<ModuleDefinitionFile>exports.def</ModuleDefinitionFile>
4848
</Link>

0 commit comments

Comments
 (0)