Skip to content

Latest commit

 

History

History
128 lines (89 loc) · 4.7 KB

Compiling-on-Windows.md

File metadata and controls

128 lines (89 loc) · 4.7 KB

Compiling on Windows

Build Requirements

Getting OpenSSL

Prebuilt OpenSSL libraries are available here. Download and install the 32 bit or 64 bit package for your target platform. OpenSSL can then be found on C:\OpenSSL-Win32 or C:\OpenSSL-Win64 respectively.

Getting OpenPACE

Download and unpack the source code of the latest release of OpenPACE. Open a Visual Studio Developer Command Prompt and change to the OpenPACE's src directory. Compile the library:

set OPENSSL=C:\OpenSSL-Win64

When compiling for 32 bit, use

set OPENSSL=C:\OpenSSL-Win32 
cl /I%OPENSSL%\include /I. /DX509DIR=\"/\" /DCVCDIR=\"/\" /W3 /D_CRT_SECURE_NO_DEPRECATE /DWIN32_LEAN_AND_MEAN /GS /MT /c ca_lib.c cv_cert.c cvc_lookup.c x509_lookup.c eac_asn1.c eac.c eac_ca.c eac_dh.c eac_ecdh.c eac_kdf.c eac_lib.c eac_print.c eac_util.c misc.c pace.c pace_lib.c pace_mappings.c ri.c ri_lib.c ta.c ta_lib.c objects.c
lib /out:libeac.lib ca_lib.obj cv_cert.obj cvc_lookup.obj x509_lookup.obj eac_asn1.obj eac.obj eac_ca.obj eac_dh.obj eac_ecdh.obj eac_kdf.obj eac_lib.obj eac_print.obj eac_util.obj misc.obj pace.obj pace_lib.obj pace_mappings.obj ri.obj ri_lib.obj ta.obj ta_lib.obj objects.obj

Getting zlib

Download and unpack the source code of the latest release of zlib. Open a Visual Studio Developer Command Prompt and change to the zlib directory.

Compile the library for 32 bit:

nmake -f win32/Makefile.msc LOC="-DASMV -DASMINF" OBJA="inffas32.obj match686.obj" zlib.lib

Compile the library for 64 bit:

nmake -f win32/Makefile.msc AS=ml64 LOC="-DASMV -DASMINF -I." OBJA="inffasx64.obj gvmat64.obj inffas8664.obj" zlib.lib

CPDK

When the new CPDK is used, you shall update the Include path:

--- a/win32/Make.rules.mak
+++ b/win32/Make.rules.mak
@@ -131,7 +131,7 @@ CANDLEFLAGS = -dOpenPACE="$(OPENPACE_DIR)" $(CANDLEFLAGS)


 # Used for MiniDriver
-CNGSDK_INCL_DIR = "/IC:\Program Files (x86)\Microsoft CNG Development Kit\Include"
+CNGSDK_INCL_DIR = "/IC:\Program Files (x86)\Windows Kits\10\Cryptographic Provider Development Kit\Include"
 !IF "$(PROCESSOR_ARCHITECTURE)" == "x86" && "$(PROCESSOR_ARCHITEW6432)" == ""
 CNGSDK_INCL_DIR = "/IC:\Program Files\Microsoft CNG Development Kit\Include"
 !ENDIF</code></pre>

Build Configuration

Edit Make.rules.mak

Change win32/Make.rules.mak according to your desired build configuration. Specifically, you may want to change

  • WIX for WiX Toolset
  • OPENSSL_DEF for OpenSSL
  • OPENPACE_DEF and OPENPACE_DIR for OpenPACE
  • ZLIBSTATIC_DEF, ZLIB_LIB and ZLIB_INCL_DIR for zlib

Creation of Build Source Files

Creating Built Source Files Using Autoconf

Use Cygwin or MSYS2 to install

  • autoconf
  • automake
  • libtool
  • make
  • gcc or mingw-w64 (will not be used for build)
  • pkg-config

Open a Cygwin/MSYS2 terminal or console and change to the OpenSC directory (the previously installed tools need to be found in the %PATH%). Create the built source files:

autoreconf -i
./configure --disable-openssl --disable-readline --disable-zlib
make -C etc opensc.conf
cp win32/winconfig.h config.h

Manually Creating Built Source Files

copy src\minidriver\versioninfo-minidriver.rc.in src\minidriver\versioninfo-minidriver.rc
copy src\pkcs11\versioninfo-pkcs11.rc.in src\pkcs11\versioninfo-pkcs11.rc
copy src\pkcs11\versioninfo-pkcs11-spy.rc.in src\pkcs11\versioninfo-pkcs11-spy.rc
copy src\tools\versioninfo-tools.rc.in src\tools\versioninfo-tools.rc
copy win32\OpenSC.wxs.in win32\OpenSC.wxs
copy win32\versioninfo-customactions.rc.in win32\versioninfo-customactions.rc
copy win32\versioninfo.rc.in win32\versioninfo.rc
copy win32\winconfig.h.in win32\winconfig.h

The resulting files still contain strings that are encapsulated in @@@. You need to replace these place holders with meaningful values.

Build OpenSC

Open a Visual Studio Developer Command Prompt and change to the OpenSC directory. Build the OpenSC binaries and installer:

nmake /f Makefile.mak
cd win32
nmake /f Makefile.mak OpenSC.msi

Code Signing

Free code signing provided by SignPath.io, certificate by SignPath Foundation.