mirror of
https://github.com/mtrojnar/osslsigncode.git
synced 2025-07-02 19:22:47 -05:00
Compare commits
114 Commits
Author | SHA1 | Date | |
---|---|---|---|
225a8f78fa | |||
23288f5a00 | |||
0e80573c58 | |||
8f6d1617eb | |||
15185acb0a | |||
703ae70602 | |||
c59f5dd02c | |||
0a9dcbda6c | |||
f87618326f | |||
80de8e7738 | |||
306d467a29 | |||
d0a958919d | |||
81b58f744d | |||
8f30bf28e7 | |||
a12b5c0951 | |||
5bf24b34a2 | |||
7871e28141 | |||
d7daf98db8 | |||
1d0918c84d | |||
f42459ff09 | |||
66a6a1ced5 | |||
a44c8decbc | |||
d556fb78dc | |||
4c856f3a1e | |||
1bf5f9a07b | |||
c930d9aa7a | |||
5df8d7c181 | |||
cf20354b91 | |||
665ecfb64c | |||
6430bf0036 | |||
92673b8f00 | |||
3d0640a2cc | |||
28c68aeebf | |||
26b7d5f617 | |||
88bf99dec8 | |||
757d9c39a4 | |||
ce2d586956 | |||
396318dcd1 | |||
24ed108099 | |||
7b29b45348 | |||
6b3450ada8 | |||
ac3e8e5221 | |||
99400d92d6 | |||
b63b023c5c | |||
6ffe7fa0de | |||
b7d4c72756 | |||
fb19651926 | |||
213ea27f99 | |||
a19d77a8a7 | |||
6a873c3a49 | |||
a892c50147 | |||
95615faf1d | |||
860e8d6f4e | |||
60fe5d15fe | |||
b96717506c | |||
157bb78a6e | |||
4396c451eb | |||
40bd33ee01 | |||
d7ae7c90f9 | |||
247a82232c | |||
3a84987107 | |||
afda3cc810 | |||
44eeeb1515 | |||
1c523ed616 | |||
8ba94fafd9 | |||
82185eef18 | |||
bec2ae2eed | |||
c5c23cefac | |||
4c1b972f9e | |||
1bd9a87e2f | |||
65d17836ab | |||
6a1a884f3c | |||
98308f2e0a | |||
da4413d0c7 | |||
c08b8cb3d5 | |||
5af84745de | |||
0459fb99ef | |||
73d7cf011e | |||
7affd85c46 | |||
d8a182614c | |||
ac672640be | |||
5d68e8699a | |||
b48458499b | |||
4731667c35 | |||
85594d9fb2 | |||
5f60cc6563 | |||
77b2b30d1f | |||
e0d652b987 | |||
b774a56aa9 | |||
6eaf0d9368 | |||
d471b51db5 | |||
7b12abf21f | |||
f248286d6f | |||
5db237f242 | |||
95c5a4451b | |||
f0207411b9 | |||
aef958f880 | |||
a6d3be739e | |||
4eeeec32b4 | |||
ce196ce147 | |||
289c345280 | |||
bdea1d1c2a | |||
45fedd9e50 | |||
e177ded9a5 | |||
5a2d0affc1 | |||
5afafecc23 | |||
07bf24911d | |||
357747d2fc | |||
28f6ffbc42 | |||
fb75eee385 | |||
6e2fb03b7b | |||
46d43d70b3 | |||
407579ca58 | |||
96df1a709f |
131
.github/workflows/ci.yml
vendored
Normal file
131
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,131 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
env:
|
||||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
||||
BUILD_TYPE: Release
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- triplet: x64-linux
|
||||
os: ubuntu-latest
|
||||
vcpkg_root: /usr/local/share/vcpkg
|
||||
- triplet: x64-osx
|
||||
os: macOS-latest
|
||||
vcpkg_root: /usr/local/share/vcpkg
|
||||
cache: /Users/runner/.cache/vcpkg/archives
|
||||
- triplet: x64-windows
|
||||
arch: x64
|
||||
os: windows-latest
|
||||
vcpkg_root: C:/vcpkg
|
||||
cache: C:/Users/runneradmin/AppData/Local/vcpkg/archives
|
||||
- triplet: x86-windows
|
||||
arch: x86
|
||||
os: windows-latest
|
||||
vcpkg_root: C:/vcpkg
|
||||
cache: C:/Users/runneradmin/AppData/Local/vcpkg/archives
|
||||
- triplet: x64-windows-static
|
||||
arch: x64
|
||||
os: windows-latest
|
||||
vcpkg_root: C:/vcpkg
|
||||
cache: C:/Users/runneradmin/AppData/Local/vcpkg/archives
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Cache the vcpkg archives
|
||||
if: matrix.os != 'ubuntu-latest'
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{matrix.cache}}
|
||||
key: ${{matrix.triplet}}-${{hashFiles('vcpkg.json')}}
|
||||
restore-keys: |
|
||||
${{matrix.triplet}}-${{hashFiles('vcpkg.json')}}
|
||||
${{matrix.triplet}}-
|
||||
|
||||
- name: Configure VS Toolchain (Windows)
|
||||
if: matrix.os == 'windows-latest'
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
with:
|
||||
arch: ${{matrix.arch}}
|
||||
|
||||
- name: Install apt dependencies (Linux)
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: sudo apt-get install -y libssl-dev libcurl4-openssl-dev faketime
|
||||
|
||||
- name: Setup the oldest supported version of cmake (macOS)
|
||||
if: matrix.os == 'macOS-latest'
|
||||
uses: jwlawson/actions-setup-cmake@v1.12
|
||||
with:
|
||||
cmake-version: '3.17.0'
|
||||
|
||||
- name: Configure CMake (Linux)
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: cmake
|
||||
-S ${{github.workspace}}
|
||||
-B ${{github.workspace}}/build
|
||||
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/dist
|
||||
|
||||
- name: Configure CMake (macOS)
|
||||
if: matrix.os == 'macOS-latest'
|
||||
run: cmake
|
||||
-S ${{github.workspace}}
|
||||
-B ${{github.workspace}}/build
|
||||
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/dist
|
||||
-DCMAKE_TOOLCHAIN_FILE=${{matrix.vcpkg_root}}/scripts/buildsystems/vcpkg.cmake
|
||||
-DVCPKG_TARGET_TRIPLET=${{matrix.triplet}}
|
||||
|
||||
- name: Configure CMake (Windows)
|
||||
if: matrix.os == 'windows-latest'
|
||||
run: cmake
|
||||
-G Ninja
|
||||
-S ${{github.workspace}}
|
||||
-B ${{github.workspace}}/build
|
||||
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/dist
|
||||
-DCMAKE_TOOLCHAIN_FILE=${{matrix.vcpkg_root}}/scripts/buildsystems/vcpkg.cmake
|
||||
-DVCPKG_TARGET_TRIPLET=${{matrix.triplet}}
|
||||
|
||||
- name: Build
|
||||
run: cmake
|
||||
--build ${{github.workspace}}/build
|
||||
--config ${{env.BUILD_TYPE}}
|
||||
|
||||
- name: List files (Linux/macOS)
|
||||
if: matrix.os != 'windows-latest'
|
||||
run: find .. -ls
|
||||
|
||||
- name: List files (Windows)
|
||||
if: matrix.os == 'windows-latest'
|
||||
run: Get-ChildItem -Recurse -Name ..
|
||||
|
||||
- name: Test
|
||||
working-directory: ${{github.workspace}}/build
|
||||
run: ctest -C ${{env.BUILD_TYPE}}
|
||||
|
||||
- name: Upload the errors
|
||||
uses: actions/upload-artifact@v3
|
||||
if: failure()
|
||||
with:
|
||||
name: errors-${{matrix.triplet}}
|
||||
path: ${{github.workspace}}/build/Testing/Temporary/LastTest.log
|
||||
|
||||
- name: Install
|
||||
run: cmake --install ${{github.workspace}}/build
|
||||
|
||||
- name: Upload the executables
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: osslsigncode-${{matrix.triplet}}
|
||||
path: ${{github.workspace}}/dist
|
43
.gitignore
vendored
43
.gitignore
vendored
@ -1,24 +1,21 @@
|
||||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
autom4te.cache/
|
||||
compile
|
||||
build/
|
||||
CMakeFiles/
|
||||
_CPack_Packages/
|
||||
Testing/
|
||||
.vs/
|
||||
|
||||
CMakeCache.txt
|
||||
cmake_install.cmake
|
||||
config.h
|
||||
config.h.in
|
||||
config.h.in~
|
||||
config.log
|
||||
config.status
|
||||
configure
|
||||
depcomp
|
||||
install-sh
|
||||
CPackConfig.cmake
|
||||
CPackSourceConfig.cmake
|
||||
CTestTestfile.cmake
|
||||
install_manifest.txt
|
||||
Makefile
|
||||
missing
|
||||
osslsigncode
|
||||
osslsigncode.o
|
||||
msi.o
|
||||
osslsigncode.exe
|
||||
stamp-h1
|
||||
INSTALL
|
||||
COPYING
|
||||
|
||||
.#*#
|
||||
.*.bak
|
||||
@ -26,24 +23,20 @@ COPYING
|
||||
.*.rej
|
||||
.*~
|
||||
#*#
|
||||
*.asc
|
||||
*.bak
|
||||
*.bz2
|
||||
*.d
|
||||
*.def
|
||||
*.dll
|
||||
*.exe
|
||||
*.gz
|
||||
*.la
|
||||
*.lib
|
||||
*.lo
|
||||
*.orig
|
||||
*.pc
|
||||
*.pdb
|
||||
*.rej
|
||||
*.u
|
||||
*.rc
|
||||
*.pc
|
||||
*~
|
||||
*.gz
|
||||
*.bz2
|
||||
|
||||
**/*.log
|
||||
!myapp.exe
|
||||
*.pem
|
||||
|
95
CMakeLists.txt
Normal file
95
CMakeLists.txt
Normal file
@ -0,0 +1,95 @@
|
||||
# required cmake version
|
||||
cmake_minimum_required(VERSION 3.17)
|
||||
|
||||
# autodetect vcpkg CMAKE_TOOLCHAIN_FILE if VCPKG_ROOT is defined
|
||||
# this needs to be configured before the project() directive
|
||||
if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
|
||||
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
|
||||
CACHE STRING "")
|
||||
endif(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
|
||||
set(BUILTIN_SOCKET ON CACHE BOOL "") # for static Python
|
||||
|
||||
# configure basic project information
|
||||
project(osslsigncode
|
||||
VERSION 2.4
|
||||
DESCRIPTION "OpenSSL based Authenticode signing for PE, CAB, CAT and MSI files"
|
||||
HOMEPAGE_URL "https://github.com/mtrojnar/osslsigncode"
|
||||
LANGUAGES C)
|
||||
|
||||
# force nonstandard version format for development packages
|
||||
set(DEV "")
|
||||
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}${DEV}")
|
||||
|
||||
# version and contact information
|
||||
set(PACKAGE_STRING "${PROJECT_NAME} ${PROJECT_VERSION}")
|
||||
set(PACKAGE_BUGREPORT "Michal.Trojnara@stunnel.org")
|
||||
|
||||
# specify the C standard
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||
|
||||
# load CMake library modules
|
||||
include(FindOpenSSL)
|
||||
include(FindCURL)
|
||||
|
||||
# load CMake project modules
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
|
||||
include(SetBashCompletion)
|
||||
include(FindHeaders)
|
||||
|
||||
# define the target
|
||||
add_executable(osslsigncode)
|
||||
|
||||
# add compiler/linker flags
|
||||
include(SetCompilerFlags)
|
||||
|
||||
# create and use config.h
|
||||
configure_file(Config.h.in config.h)
|
||||
target_compile_definitions(osslsigncode PRIVATE HAVE_CONFIG_H=1)
|
||||
|
||||
# set sources
|
||||
target_sources(osslsigncode PRIVATE osslsigncode.c msi.c)
|
||||
if(WIN32)
|
||||
target_sources(osslsigncode PRIVATE applink.c)
|
||||
endif(WIN32)
|
||||
|
||||
# set include directories
|
||||
target_include_directories(osslsigncode PRIVATE "${PROJECT_BINARY_DIR}")
|
||||
|
||||
# set OpenSSL includes/libraries
|
||||
if(NOT OPENSSL_FOUND)
|
||||
message(FATAL_ERROR "OpenSSL library not found")
|
||||
endif(NOT OPENSSL_FOUND)
|
||||
target_include_directories(osslsigncode PRIVATE ${OPENSSL_INCLUDE_DIR})
|
||||
target_link_libraries(osslsigncode PRIVATE ${OPENSSL_LIBRARIES})
|
||||
|
||||
# set cURL includes/libraries
|
||||
if(CURL_FOUND)
|
||||
target_compile_definitions(osslsigncode PRIVATE ENABLE_CURL=1)
|
||||
target_include_directories(osslsigncode PRIVATE ${CURL_INCLUDE_DIRS})
|
||||
target_link_libraries(osslsigncode PRIVATE ${CURL_LIBRARIES})
|
||||
message(STATUS "cURL support enabled")
|
||||
else(CURL_FOUND)
|
||||
message(STATUS "cURL support disabled (library not found)")
|
||||
endif(CURL_FOUND)
|
||||
|
||||
# add paths to linker search and installed rpath
|
||||
set_target_properties(osslsigncode PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
|
||||
# testing with CTest
|
||||
include(CMakeTest)
|
||||
|
||||
# installation rules for a project
|
||||
install(TARGETS osslsigncode RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||
if(WIN32)
|
||||
install(
|
||||
DIRECTORY ${PROJECT_BINARY_DIR}/ DESTINATION ${CMAKE_INSTALL_PREFIX}
|
||||
FILES_MATCHING
|
||||
PATTERN "*.dll"
|
||||
PATTERN "vcpkg_installed" EXCLUDE
|
||||
PATTERN "CMakeFiles" EXCLUDE
|
||||
PATTERN "Testing" EXCLUDE
|
||||
)
|
||||
else(WIN32)
|
||||
include(CMakeDist)
|
||||
endif(WIN32)
|
50
CMakeSettings.json
Normal file
50
CMakeSettings.json
Normal file
@ -0,0 +1,50 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "x86-Debug",
|
||||
"generator": "Ninja",
|
||||
"configurationType": "Debug",
|
||||
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
||||
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||
"cmakeCommandArgs": "",
|
||||
"buildCommandArgs": "",
|
||||
"ctestCommandArgs": "",
|
||||
"inheritEnvironments": [ "msvc_x86" ]
|
||||
},
|
||||
{
|
||||
"name": "x86-Release",
|
||||
"generator": "Ninja",
|
||||
"configurationType": "RelWithDebInfo",
|
||||
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
||||
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||
"cmakeCommandArgs": "",
|
||||
"buildCommandArgs": "",
|
||||
"ctestCommandArgs": "",
|
||||
"inheritEnvironments": [ "msvc_x86" ]
|
||||
},
|
||||
{
|
||||
"name": "x64-Debug",
|
||||
"generator": "Ninja",
|
||||
"configurationType": "Debug",
|
||||
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
||||
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||
"cmakeCommandArgs": "",
|
||||
"buildCommandArgs": "",
|
||||
"ctestCommandArgs": "",
|
||||
"inheritEnvironments": [ "msvc_x64_x64" ],
|
||||
"variables": []
|
||||
},
|
||||
{
|
||||
"name": "x64-Release",
|
||||
"generator": "Ninja",
|
||||
"configurationType": "RelWithDebInfo",
|
||||
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
||||
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||
"cmakeCommandArgs": "",
|
||||
"buildCommandArgs": "",
|
||||
"ctestCommandArgs": "",
|
||||
"inheritEnvironments": [ "msvc_x64_x64" ],
|
||||
"variables": []
|
||||
}
|
||||
]
|
||||
}
|
12
Config.h.in
Normal file
12
Config.h.in
Normal file
@ -0,0 +1,12 @@
|
||||
/* the configured options and settings for osslsigncode */
|
||||
#define VERSION_MAJOR "@osslsigncode_VERSION_MAJOR@"
|
||||
#define VERSION_MINOR "@osslsigncode_VERSION_MINOR@"
|
||||
#cmakedefine PACKAGE_STRING "@PACKAGE_STRING@"
|
||||
#cmakedefine PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@"
|
||||
#cmakedefine ENABLE_CURL
|
||||
#cmakedefine HAVE_TERMIOS_H
|
||||
#cmakedefine HAVE_GETPASS
|
||||
#cmakedefine HAVE_SYS_MMAN_H
|
||||
#cmakedefine HAVE_MMAP
|
||||
#cmakedefine HAVE_MAPVIEWOFFILE
|
||||
#cmakedefine _WIN32
|
@ -3,9 +3,9 @@
|
||||
### Building osslsigncode source with MSYS2 MinGW 64-bit and MSYS2 packages:
|
||||
|
||||
1) Download and install MSYS2 from https://msys2.github.io/ and follow installation instructions.
|
||||
Once up and running install even mingw-w64-x86_64-gcc, mingw-w64-x86_64-curl, mingw-w64-x86_64-libgsf.
|
||||
Once up and running install even mingw-w64-x86_64-gcc, mingw-w64-x86_64-curl.
|
||||
```
|
||||
pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-curl mingw-w64-x86_64-libgsf
|
||||
pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-curl
|
||||
```
|
||||
mingw-w64-x86_64-openssl and mingw-w64-x86_64-zlib packages are installed with dependencies.
|
||||
|
||||
@ -13,26 +13,21 @@
|
||||
```
|
||||
cd osslsigncode-folder
|
||||
x86_64-w64-mingw32-gcc osslsigncode.c msi.c -o osslsigncode.exe \
|
||||
-lcrypto -lssl -lcurl -lgsf-1 -lgobject-2.0 -lglib-2.0 -lxml2 \
|
||||
-I 'C:/msys64/mingw64/include/libgsf-1' \
|
||||
-I 'C:/msys64/mingw64/include/glib-2.0' \
|
||||
-I 'C:/msys64/mingw64/lib/glib-2.0/include' \
|
||||
-D 'PACKAGE_STRING="osslsigncode 2.1.0"' \
|
||||
-D 'PACKAGE_BUGREPORT="Michal.Trojnara@stunnel.org"' \
|
||||
-D ENABLE_CURL \
|
||||
-D WITH_GSF
|
||||
-lcrypto -lssl -lcurl \
|
||||
-D 'PACKAGE_STRING="osslsigncode x.y"' \
|
||||
-D 'PACKAGE_BUGREPORT="Your.Email@example.com"' \
|
||||
-D ENABLE_CURL
|
||||
```
|
||||
|
||||
3) Run "Command prompt" and include "c:\msys64\mingw64\bin" folder as part of the path.
|
||||
```
|
||||
path=%path%;c:\msys64\mingw64\bin
|
||||
cd osslsigncode-folder
|
||||
|
||||
osslsigncode.exe -v
|
||||
osslsigncode 2.1.0, using:
|
||||
OpenSSL 1.1.1g 21 Apr 2020
|
||||
libcurl/7.70.0 OpenSSL/1.1.1g (Schannel) zlib/1.2.11 brotli/1.0.7 libidn2/2.3.0
|
||||
libpsl/0.21.0 (+libidn2/2.3.0) libssh2/1.9.0 nghttp2/1.40.0 libgsf 1.14.46
|
||||
osslsigncode 2.4, using:
|
||||
OpenSSL 1.1.1g 21 Apr 2020 (Library: OpenSSL 1.1.1g 21 Apr 2020)
|
||||
libcurl/7.70.0 OpenSSL/1.1.1g (Schannel) zlib/1.2.11 brotli/1.0.7 libidn2/2.3.0
|
||||
libpsl/0.21.0 (+libidn2/2.3.0) libssh2/1.9.0 nghttp2/1.40.0
|
||||
```
|
||||
|
||||
|
||||
@ -68,20 +63,21 @@
|
||||
--disable-ftp --disable-tftp --disable-file --disable-dict \
|
||||
--disable-telnet --disable-imap --disable-smb --disable-smtp \
|
||||
--disable-gopher --disable-pop --disable-pop3 --disable-rtsp \
|
||||
--disable-ldap --disable-ldaps --disable-unix-sockets --disable-pthreads
|
||||
--disable-ldap --disable-ldaps --disable-unix-sockets \
|
||||
--disable-pthreads --without-zstd --without-zlib
|
||||
make && make install
|
||||
```
|
||||
|
||||
3) Build 64-bit Windows executables.
|
||||
```
|
||||
cd osslsigncode-folder
|
||||
x86_64-w64-mingw32-gcc osslsigncode.c -o osslsigncode.exe \
|
||||
x86_64-w64-mingw32-gcc osslsigncode.c msi.c -o osslsigncode.exe \
|
||||
-L 'C:/OpenSSL/lib/' -lcrypto -lssl \
|
||||
-I 'C:/OpenSSL/include/' \
|
||||
-L 'C:/curl/lib' -lcurl \
|
||||
-I 'C:/curl/include' \
|
||||
-D 'PACKAGE_STRING="osslsigncode 2.1.0"' \
|
||||
-D 'PACKAGE_BUGREPORT="Michal.Trojnara@stunnel.org"' \
|
||||
-D 'PACKAGE_STRING="osslsigncode x.y"' \
|
||||
-D 'PACKAGE_BUGREPORT="Your.Email@example.com"' \
|
||||
-D ENABLE_CURL
|
||||
```
|
||||
|
||||
@ -91,11 +87,36 @@
|
||||
copy C:\OpenSSL\bin\libssl-1_1-x64.dll
|
||||
copy C:\OpenSSL\bin\libcrypto-1_1-x64.dll
|
||||
copy C:\curl\bin\libcurl-4.dll
|
||||
copy C:\msys64\mingw64\bin\zlib1.dll
|
||||
|
||||
osslsigncode.exe -v
|
||||
osslsigncode 2.1.0, using:
|
||||
OpenSSL 1.1.1g 21 Apr 2020
|
||||
libcurl/7.70.0 OpenSSL/1.1.1g zlib/1.2.11
|
||||
no libgsf available
|
||||
osslsigncode 2.4, using:
|
||||
OpenSSL 1.1.1k 25 Mar 2021 (Library: OpenSSL 1.1.1k 25 Mar 2021)
|
||||
libcurl/7.78.0 OpenSSL/1.1.1k
|
||||
```
|
||||
|
||||
### Building OpenSSL, Curl and osslsigncode sources with Microsoft Visual Studio:
|
||||
|
||||
1) Install and integrate vcpkg: https://vcpkg.io/en/getting-started.html
|
||||
|
||||
2) Git clone osslsigncode: https://github.com/mtrojnar/osslsigncode/
|
||||
|
||||
3) Build osslsigncode with GUI or cmake.
|
||||
Navigate to the build directory and run CMake to configure the osslsigncode project
|
||||
and generate a native build system:
|
||||
```
|
||||
mkdir build && cd build && cmake -S .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=[installation directory] -DCMAKE_TOOLCHAIN_FILE=[path to vcpkg]/scripts/buildsystems/vcpkg.cmake
|
||||
```
|
||||
Then call that build system to actually compile/link the osslsigncode project:
|
||||
```
|
||||
cmake --build .
|
||||
```
|
||||
|
||||
4) Make tests.
|
||||
```
|
||||
ctest -C Release
|
||||
```
|
||||
|
||||
5) Make install (with administrative privileges if necessary).
|
||||
```
|
||||
cmake --install .
|
||||
```
|
||||
|
@ -1,7 +1,7 @@
|
||||
OpenSSL based Authenticode signing for PE/MSI/Java CAB files.
|
||||
|
||||
Copyright (C) 2005-2014 Per Allansson <pallansson@gmail.com>
|
||||
Copyright (C) 2018-2019 Michał Trojnara <Michal.Trojnara@stunnel.org>
|
||||
Copyright (C) 2018-2022 Michał Trojnara <Michal.Trojnara@stunnel.org>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
16
Makefile.am
16
Makefile.am
@ -1,16 +0,0 @@
|
||||
AUTOMAKE_OPTIONS = foreign 1.10
|
||||
MAINTAINERCLEANFILES = \
|
||||
config.log config.status \
|
||||
$(srcdir)/Makefile.in \
|
||||
$(srcdir)/config.h.in $(srcdir)/config.h.in~ $(srcdir)/configure \
|
||||
$(srcdir)/install-sh $(srcdir)/ltmain.sh $(srcdir)/missing \
|
||||
$(srcdir)/depcomp $(srcdir)/aclocal.m4 $(srcdir)/ylwrap \
|
||||
$(srcdir)/config.guess $(srcdir)/config.sub
|
||||
EXTRA_DIST = .gitignore
|
||||
|
||||
AM_CFLAGS = $(OPENSSL_CFLAGS) $(OPTIONAL_LIBCURL_CFLAGS)
|
||||
|
||||
bin_PROGRAMS = osslsigncode
|
||||
|
||||
osslsigncode_SOURCES = osslsigncode.c msi.c msi.h
|
||||
osslsigncode_LDADD = $(OPENSSL_LIBS) $(OPTIONAL_LIBCURL_LIBS)
|
36
NEWS.md
36
NEWS.md
@ -1,3 +1,39 @@
|
||||
# osslsigncode change log
|
||||
|
||||
### 2.4 (2022.08.02)
|
||||
|
||||
- migrated the build system from GNU Autoconf to CMake
|
||||
- added the "-h" option to set the cryptographic hash function
|
||||
for the "attach -signature" and "add" commands
|
||||
- set the default hash function to "sha256"
|
||||
- added the "attach-signature" option to compute and compare the
|
||||
leaf certificate hash for the "add" command
|
||||
- renamed the "-st" option "-time" (the old name is accepted for
|
||||
compatibility)
|
||||
- updated the "-time" option to also set explicit verification time
|
||||
- added the "-ignore-timestamp" option to disable timestamp server
|
||||
signature verification
|
||||
- removed the "-timestamp-expiration" option
|
||||
- fixed several bugs
|
||||
- updated the included documentation
|
||||
- enabled additional compiler/linker hardening options
|
||||
- added CI based on GitHub Actions
|
||||
|
||||
### 2.3 (2022.03.06)
|
||||
|
||||
**CRITICAL SECURITY VULNERABILITIES**
|
||||
|
||||
This release fixes several critical memory corruption vulnerabilities.
|
||||
A malicious attacker could create a file, which, when processed with
|
||||
osslsigncode, triggers arbitrary code execution. Any previous version
|
||||
of osslsigncode should be immediately upgraded if the tool is used for
|
||||
processing of untrusted files.
|
||||
|
||||
- fixed several memory safety issues
|
||||
- fixed non-interactive PVK (MSBLOB) key decryption
|
||||
- added a bash completion script
|
||||
- added CA bundle path auto-detection
|
||||
|
||||
### 2.2 (2021.08.15)
|
||||
|
||||
- CAT files support (thanks to James McKenzie)
|
||||
|
119
README.md
119
README.md
@ -1,6 +1,10 @@
|
||||
osslsigncode
|
||||
============
|
||||
|
||||
## BUILD STATUS
|
||||
|
||||
[](https://github.com/mtrojnar/osslsigncode/actions/workflows/ci.yml)
|
||||
|
||||
## WHAT IS IT?
|
||||
|
||||
osslsigncode is a small tool that implements part of the functionality
|
||||
@ -29,43 +33,47 @@ supports signature verification, removal and extraction.
|
||||
|
||||
This section covers building osslsigncode for [Unix-like](https://en.wikipedia.org/wiki/Unix-like) operating systems.
|
||||
See [INSTALL.W32.md](https://github.com/mtrojnar/osslsigncode/blob/master/INSTALL.W32.md) for Windows notes.
|
||||
We highly recommend downloading a [release tarball](https://github.com/mtrojnar/osslsigncode/releases) instead of cloning from a git repository.
|
||||
|
||||
### Generate the ./configure script
|
||||
|
||||
This step is only needed if osslsigncode was cloned from a git repository.
|
||||
We highly recommend downloading a [release tarball](https://github.com/mtrojnar/osslsigncode/releases) instead.
|
||||
### Configure, build, make tests and install osslsigncode
|
||||
|
||||
* Install prerequisites on a Debian-based distributions, such as Ubuntu:
|
||||
```
|
||||
sudo apt update && sudo apt install automake pkg-config
|
||||
sudo apt update && sudo apt install cmake libssl-dev libcurl4-openssl-dev
|
||||
```
|
||||
|
||||
* Install prerequisites on macOS with Homebrew:
|
||||
```
|
||||
brew install automake pkg-config
|
||||
```
|
||||
|
||||
* Generate the ./configure script:
|
||||
```
|
||||
./bootstrap
|
||||
```
|
||||
|
||||
### Configure, build and install osslsigncode
|
||||
|
||||
* Install prerequisites on a Debian-based distributions, such as Ubuntu:
|
||||
```
|
||||
sudo apt update && sudo apt install build-essential pkg-config libssl-dev libcurl4-openssl-dev
|
||||
```
|
||||
|
||||
* Install prerequisites on macOS with Homebrew:
|
||||
```
|
||||
brew install pkg-config openssl@1.1
|
||||
brew install cmake pkg-config openssl@1.1
|
||||
export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig"
|
||||
```
|
||||
**NOTE:** osslsigncode requires CMake 3.6 or newer.
|
||||
|
||||
* Configure, build and install osslsigncode:
|
||||
You may need to use `cmake3` instead of `cmake` to complete the following steps on your system.
|
||||
* Navigate to the build directory and run CMake to configure the osslsigncode project
|
||||
and generate a native build system:
|
||||
```
|
||||
./configure && make && sudo make install
|
||||
mkdir build && cd build && cmake ..
|
||||
```
|
||||
with specific compile options:
|
||||
```
|
||||
-Denable-strict=ON
|
||||
-Denable-pedantic=ON
|
||||
```
|
||||
* Then call that build system to actually compile/link the osslsigncode project (alias `make`):
|
||||
```
|
||||
cmake --build .
|
||||
```
|
||||
* Make test:
|
||||
```
|
||||
ctest -C Release
|
||||
```
|
||||
* Make install:
|
||||
```
|
||||
sudo cmake --install . --prefix "/home/myuser/installdir"
|
||||
```
|
||||
* Make tarball (simulate autotools' `make dist`):
|
||||
```
|
||||
cmake --build . --target package_source
|
||||
```
|
||||
|
||||
## USAGE
|
||||
@ -136,41 +144,42 @@ and then choose the signature from the list, and click on
|
||||
Details. You should then be presented with a dialog that says
|
||||
amongst other things that "This digital signature is OK".
|
||||
|
||||
## CONVERTING FROM PVK TO DER
|
||||
## UNAUTHENTICATED BLOBS
|
||||
|
||||
(This guide was written by Ryan Rubley)
|
||||
The "-addUnauthenticatedBlob" parameter adds a 1024-byte unauthenticated blob
|
||||
of data to the signature in the same area as the timestamp. This can be used
|
||||
while signing, while timestamping, after a file has been code signed, or by
|
||||
itself. This technique (but not this project) is used by Dropbox, GoToMeeting,
|
||||
and Summit Route.
|
||||
|
||||
If you've managed to finally find osslsigncode from some searches,
|
||||
you're most likely going to have a heck of a time getting your SPC
|
||||
and PVK files into the formats osslsigncode wants.
|
||||
### Example 1. Sign and add blob to unsigned file
|
||||
|
||||
On the computer where you originally purchased your certificate, you
|
||||
probably had to use IE to get it. Run IE and select Tools/Internet
|
||||
Options from the menu, then under the Content tab, click the Certificates
|
||||
button. Under the Personal tab, select your certificate and click the
|
||||
Export button. On the second page of the wizard, select the PKCS #7
|
||||
Certificate (.P7B) format. This file you export as a *.p7b is what you
|
||||
use instead of your *.spc file. It's the same basic thing, in a different format.
|
||||
|
||||
For your PVK file, you will need to download a little utility called
|
||||
PVK.EXE. This can currently be downloaded at
|
||||
|
||||
https://www.globalsign.com/support/code-signing/PVK.zip
|
||||
|
||||
Run:
|
||||
```
|
||||
pvk -in foo.pvk -nocrypt -out foo.pem
|
||||
```shell
|
||||
osslsigncode sign -addUnauthenticatedBlob -pkcs12 yourcert.pfx -pass your_password -n "Your Company" -i https://YourSite.com/ -in srepp.msi -out srepp_added.msi
|
||||
```
|
||||
|
||||
This will convert your PVK file to a PEM file.
|
||||
From there, you can copy the PEM file to a Linux box, and run:
|
||||
```
|
||||
openssl rsa -outform der -in foo.pem -out foo.der
|
||||
```
|
||||
This will convert your PEM file to a DER file.
|
||||
### Example 2. Timestamp and add blob to signed file
|
||||
|
||||
You need the *.p7b and *.der files to use osslsigncode, instead of your
|
||||
*.spc and *.pvk files.
|
||||
```shell
|
||||
osslsigncode.exe add -addUnauthenticatedBlob -t http://timestamp.digicert.com -in your_signed_file.exe -out out.exe
|
||||
```
|
||||
|
||||
### Example 3. Add blob to signed and time-stamped file
|
||||
|
||||
```shell
|
||||
osslsigncode.exe add -addUnauthenticatedBlob -in your_signed_file.exe -out out.exe
|
||||
```
|
||||
|
||||
### WARNING
|
||||
|
||||
This feature allows for doing dumb things. Be very careful with what you put
|
||||
in the unauthenticated blob, as an attacker could modify this. Do NOT, under
|
||||
any circumstances, put a URL here that you will use to download an additional
|
||||
file. If you do do that, you would need to check the newly downloaded file is
|
||||
code signed AND that it has been signed with your cert AND that it is the
|
||||
version you expect. You should consider using asymmetrical encryption for the
|
||||
data you put in the blob, such that the executable contains the public key to
|
||||
decrypt the data. Basically, be VERY careful.
|
||||
|
||||
## BUGS, QUESTIONS etc.
|
||||
|
||||
|
@ -1,58 +0,0 @@
|
||||
# This is NOT the official repo for osslsigncode
|
||||
|
||||
This project was copied from osslsigncode 1.7.1 to apply some patches for compiling with cygwin and being able to add unauthenticated blobs. The official source for the project is at: http://sourceforge.net/projects/osslsigncode/
|
||||
|
||||
## Features added
|
||||
|
||||
Adds the argument "-addUnauthenticatedBlob" to add a 1024 byte unauthenticated blob of data to the signature in the same area as the timestamp. This can be used while signing, while timestamping (new `add` command added to allow just time-stamping, after a file has been code signed, or by itself.
|
||||
|
||||
Examples:
|
||||
```
|
||||
# Example 1. Sign and add blob to unsigned file
|
||||
osslsigncode sign -addUnauthenticatedBlob -pkcs12 yourcert.pfx -pass your_password -n "Your Company" -i https://YourSite.com/ -in srepp.msi -out srepp_added.msi
|
||||
```
|
||||
|
||||
```
|
||||
# Example 2. Timestamp and add blob to signed file
|
||||
osslsigncode.exe add -addUnauthenticatedBlob -t http://timestamp.digicert.com -in your_signed_file.exe -out out.exe
|
||||
```
|
||||
|
||||
```
|
||||
# Example 3. Add blob to signed and time-stamped file
|
||||
osslsigncode.exe add -addUnauthenticatedBlob -in your_signed_file.exe -out out.exe
|
||||
```
|
||||
|
||||
```
|
||||
# Example 4. Sign, timestamp, and add blob
|
||||
# Technically you can do this, but this would mean your signing certificate
|
||||
# is on a computer that is connected the Internet,
|
||||
# which means you are doing something wrong,
|
||||
# so I'm not going to show how to do that.
|
||||
|
||||
```
|
||||
|
||||
This technique (but not this project) is used by Dropbox, GoToMeeting, and Summit Route. You can read more about this technique here:
|
||||
|
||||
- https://tech.dropbox.com/2014/08/tech-behind-dropboxs-new-user-experience-for-mobile/
|
||||
- http://blogs.msdn.com/b/ieinternals/archive/2014/09/04/personalizing-installers-using-unauthenticated-data-inside-authenticode-signed-binaries.aspx
|
||||
|
||||
## WARNING
|
||||
|
||||
The capability this adds can allow you to do dumb things. Be very careful with what you put in the unauthenticated blob, as an attacker could modify this. Do NOT under any circumstances put a URL here that you will use to download an additional file. If you do do that, you would need to check the newly downloaded file is code signed AND that it has been signed with your cert AND that it is the version you expect. You should consider using asymmetrical encryption for the data you put in the blob, such that the executable contains the public key to decrypt the data. Basically, be VERY careful.
|
||||
|
||||
## Compiling under cygwin
|
||||
|
||||
- Ensure you install the development libraries for openssl, libgfs, and curl.
|
||||
- Install pkg-config
|
||||
- Run
|
||||
```
|
||||
export SHELLOPTS
|
||||
set -o igncr
|
||||
./configure
|
||||
make
|
||||
```
|
||||
|
||||
## Download
|
||||
|
||||
- Compiled binary for cygwin: https://summitroute.com/downloads/osslsigncode.exe
|
||||
- Compiled binary plus all the required DLL's (self-extracting exe): https://summitroute.com/downloads/osslsigncode-cygwin_files.exe
|
145
applink.c
Normal file
145
applink.c
Normal file
@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Copyright 2004-2021 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#define APPLINK_STDIN 1
|
||||
#define APPLINK_STDOUT 2
|
||||
#define APPLINK_STDERR 3
|
||||
#define APPLINK_FPRINTF 4
|
||||
#define APPLINK_FGETS 5
|
||||
#define APPLINK_FREAD 6
|
||||
#define APPLINK_FWRITE 7
|
||||
#define APPLINK_FSETMOD 8
|
||||
#define APPLINK_FEOF 9
|
||||
#define APPLINK_FCLOSE 10 /* should not be used */
|
||||
|
||||
#define APPLINK_FOPEN 11 /* solely for completeness */
|
||||
#define APPLINK_FSEEK 12
|
||||
#define APPLINK_FTELL 13
|
||||
#define APPLINK_FFLUSH 14
|
||||
#define APPLINK_FERROR 15
|
||||
#define APPLINK_CLEARERR 16
|
||||
#define APPLINK_FILENO 17 /* to be used with below */
|
||||
|
||||
#define APPLINK_OPEN 18 /* formally can't be used, as flags can vary */
|
||||
#define APPLINK_READ 19
|
||||
#define APPLINK_WRITE 20
|
||||
#define APPLINK_LSEEK 21
|
||||
#define APPLINK_CLOSE 22
|
||||
#define APPLINK_MAX 22 /* always same as last macro */
|
||||
|
||||
#ifndef APPMACROS_ONLY
|
||||
# include <stdio.h>
|
||||
# include <io.h>
|
||||
# include <fcntl.h>
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
/* _lseek in <io.h> is a function-like macro so we can't take its address */
|
||||
# undef _lseek
|
||||
# define _lseek lseek
|
||||
# endif
|
||||
|
||||
static void *app_stdin(void)
|
||||
{
|
||||
return stdin;
|
||||
}
|
||||
|
||||
static void *app_stdout(void)
|
||||
{
|
||||
return stdout;
|
||||
}
|
||||
|
||||
static void *app_stderr(void)
|
||||
{
|
||||
return stderr;
|
||||
}
|
||||
|
||||
static int app_feof(FILE *fp)
|
||||
{
|
||||
return feof(fp);
|
||||
}
|
||||
|
||||
static int app_ferror(FILE *fp)
|
||||
{
|
||||
return ferror(fp);
|
||||
}
|
||||
|
||||
static void app_clearerr(FILE *fp)
|
||||
{
|
||||
clearerr(fp);
|
||||
}
|
||||
|
||||
static int app_fileno(FILE *fp)
|
||||
{
|
||||
return _fileno(fp);
|
||||
}
|
||||
|
||||
static int app_fsetmod(FILE *fp, char mod)
|
||||
{
|
||||
return _setmode(_fileno(fp), mod == 'b' ? _O_BINARY : _O_TEXT);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
__declspec(dllexport)
|
||||
void **
|
||||
# if defined(__BORLANDC__)
|
||||
/*
|
||||
* __stdcall appears to be the only way to get the name
|
||||
* decoration right with Borland C. Otherwise it works
|
||||
* purely incidentally, as we pass no parameters.
|
||||
*/
|
||||
__stdcall
|
||||
# else
|
||||
__cdecl
|
||||
# endif
|
||||
#pragma warning(push, 2)
|
||||
OPENSSL_Applink(void)
|
||||
{
|
||||
static int once = 1;
|
||||
static void *OPENSSL_ApplinkTable[APPLINK_MAX + 1] =
|
||||
{ (void *)APPLINK_MAX };
|
||||
|
||||
if (once) {
|
||||
OPENSSL_ApplinkTable[APPLINK_STDIN] = app_stdin;
|
||||
OPENSSL_ApplinkTable[APPLINK_STDOUT] = app_stdout;
|
||||
OPENSSL_ApplinkTable[APPLINK_STDERR] = app_stderr;
|
||||
OPENSSL_ApplinkTable[APPLINK_FPRINTF] = fprintf;
|
||||
OPENSSL_ApplinkTable[APPLINK_FGETS] = fgets;
|
||||
OPENSSL_ApplinkTable[APPLINK_FREAD] = fread;
|
||||
OPENSSL_ApplinkTable[APPLINK_FWRITE] = fwrite;
|
||||
OPENSSL_ApplinkTable[APPLINK_FSETMOD] = app_fsetmod;
|
||||
OPENSSL_ApplinkTable[APPLINK_FEOF] = app_feof;
|
||||
OPENSSL_ApplinkTable[APPLINK_FCLOSE] = fclose;
|
||||
|
||||
OPENSSL_ApplinkTable[APPLINK_FOPEN] = fopen;
|
||||
OPENSSL_ApplinkTable[APPLINK_FSEEK] = fseek;
|
||||
OPENSSL_ApplinkTable[APPLINK_FTELL] = ftell;
|
||||
OPENSSL_ApplinkTable[APPLINK_FFLUSH] = fflush;
|
||||
OPENSSL_ApplinkTable[APPLINK_FERROR] = app_ferror;
|
||||
OPENSSL_ApplinkTable[APPLINK_CLEARERR] = app_clearerr;
|
||||
OPENSSL_ApplinkTable[APPLINK_FILENO] = app_fileno;
|
||||
|
||||
OPENSSL_ApplinkTable[APPLINK_OPEN] = _open;
|
||||
OPENSSL_ApplinkTable[APPLINK_READ] = _read;
|
||||
OPENSSL_ApplinkTable[APPLINK_WRITE] = _write;
|
||||
OPENSSL_ApplinkTable[APPLINK_LSEEK] = _lseek;
|
||||
OPENSSL_ApplinkTable[APPLINK_CLOSE] = _close;
|
||||
|
||||
once = 0;
|
||||
}
|
||||
|
||||
return OPENSSL_ApplinkTable;
|
||||
}
|
||||
#pragma warning(pop)
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
27
cmake/CMakeDist.cmake
Normal file
27
cmake/CMakeDist.cmake
Normal file
@ -0,0 +1,27 @@
|
||||
# make dist
|
||||
# cmake --build . --target package_source
|
||||
|
||||
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
|
||||
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "OpenSSL based Authenticode signing for PE, CAB, CAT and MSI files")
|
||||
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
|
||||
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
|
||||
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.txt")
|
||||
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
|
||||
set(CPACK_SOURCE_GENERATOR "TGZ")
|
||||
set(CPACK_SOURCE_IGNORE_FILES "\.git/;\.gitignore")
|
||||
list(APPEND CPACK_SOURCE_IGNORE_FILES "Makefile")
|
||||
list(APPEND CPACK_SOURCE_IGNORE_FILES "CMakeCache.txt")
|
||||
list(APPEND CPACK_SOURCE_IGNORE_FILES "CMakeFiles")
|
||||
list(APPEND CPACK_SOURCE_IGNORE_FILES "CPackConfig.cmake")
|
||||
list(APPEND CPACK_SOURCE_IGNORE_FILES "CPackSourceConfig.cmake")
|
||||
list(APPEND CPACK_SOURCE_IGNORE_FILES "CTestTestfile.cmake")
|
||||
list(APPEND CPACK_SOURCE_IGNORE_FILES "cmake_install.cmake")
|
||||
list(APPEND CPACK_SOURCE_IGNORE_FILES "config.h")
|
||||
list(APPEND CPACK_SOURCE_IGNORE_FILES "/CMakeFiles/")
|
||||
list(APPEND CPACK_SOURCE_IGNORE_FILES "/Testing/")
|
||||
list(APPEND CPACK_SOURCE_IGNORE_FILES "/_CPack_Packages/")
|
||||
list(APPEND CPACK_SOURCE_IGNORE_FILES "/build/")
|
||||
|
||||
include(CPack)
|
||||
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
|
298
cmake/CMakeTest.cmake
Normal file
298
cmake/CMakeTest.cmake
Normal file
@ -0,0 +1,298 @@
|
||||
# make test
|
||||
# ctest -C Release
|
||||
|
||||
include(FindPython3)
|
||||
enable_testing()
|
||||
|
||||
set(FILES "${PROJECT_BINARY_DIR}/Testing/files")
|
||||
set(CERTS "${PROJECT_BINARY_DIR}/Testing/certs")
|
||||
set(CONF "${PROJECT_BINARY_DIR}/Testing/conf")
|
||||
|
||||
file(COPY
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/tests/files"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/tests/conf"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/tests/tsa_server.py"
|
||||
DESTINATION "${PROJECT_BINARY_DIR}/Testing"
|
||||
)
|
||||
|
||||
file(COPY
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/tests/certs/ca-bundle.crt"
|
||||
DESTINATION "${CONF}"
|
||||
)
|
||||
|
||||
set(priv_p12 "-pkcs12" "${CERTS}/cert.p12" "-readpass" "${CERTS}/password.txt")
|
||||
set(priv_spc "-certs" "${CERTS}/cert.spc" "-key" "${CERTS}/key.pvk" "-pass" "passme")
|
||||
set(priv_der "-certs" "${CERTS}/cert.pem" "-key" "${CERTS}/key.der" "-pass" "passme")
|
||||
set(priv_pkey "-certs" "${CERTS}/cert.pem" "-key" "${CERTS}/keyp.pem" "-pass" "passme")
|
||||
set(sign_opt "-time" "1556708400"
|
||||
"-add-msi-dse" "-comm" "-ph" "-jp" "low"
|
||||
"-h" "sha512" "-i" "https://www.osslsigncode.com/"
|
||||
"-n" "osslsigncode" "-ac" "${CERTS}/crosscert.pem"
|
||||
)
|
||||
|
||||
if(NOT CMAKE_HOST_WIN32)
|
||||
execute_process(
|
||||
COMMAND "${CONF}/makecerts.sh"
|
||||
WORKING_DIRECTORY ${CONF}
|
||||
OUTPUT_VARIABLE makecerts_output
|
||||
RESULT_VARIABLE makecerts_result
|
||||
)
|
||||
else()
|
||||
set(makecerts_result 1)
|
||||
endif()
|
||||
if(makecerts_result)
|
||||
message(STATUS "makecerts.sh failed")
|
||||
if(makecerts_output)
|
||||
message(STATUS "${makecerts_output}")
|
||||
endif()
|
||||
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/tests/certs"
|
||||
DESTINATION "${PROJECT_BINARY_DIR}/Testing"
|
||||
)
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} -E sha256sum "${CERTS}/cert.der"
|
||||
OUTPUT_VARIABLE sha256sum
|
||||
)
|
||||
string(SUBSTRING ${sha256sum} 0 64 leafhash)
|
||||
set(verify_opt "-CAfile" "${CERTS}/CACert.pem"
|
||||
"-CRLfile" "${CERTS}/CACertCRL.pem"
|
||||
"-TSA-CAfile" "${CERTS}/TSACA.pem"
|
||||
)
|
||||
set(extensions_4 "exe" "ex_" "msi" "cat")
|
||||
set(extensions_3 "exe" "ex_" "msi")
|
||||
set(files_4 "signed" "nested" "added")
|
||||
set(files_3 "removed" "attached_pem" "attached_der")
|
||||
set(sign_formats "pem" "der")
|
||||
set(pem_certs "cert" "expired" "revoked")
|
||||
set(failed_certs "expired" "revoked")
|
||||
|
||||
add_test(
|
||||
NAME version
|
||||
COMMAND osslsigncode --version
|
||||
)
|
||||
|
||||
foreach(ext ${extensions_4})
|
||||
# Signing time: May 1 00:00:00 2019 GMT
|
||||
set(sign_${ext} )
|
||||
add_test(
|
||||
NAME signed_${ext}
|
||||
COMMAND osslsigncode "sign" ${sign_opt} ${priv_p12}
|
||||
"-in" "${FILES}/unsigned.${ext}" "-out" "${FILES}/signed.${ext}"
|
||||
)
|
||||
endforeach()
|
||||
|
||||
foreach(ext ${extensions_3})
|
||||
add_test(
|
||||
NAME removed_${ext}
|
||||
COMMAND osslsigncode "remove-signature"
|
||||
"-in" "${FILES}/signed.${ext}" "-out" "${FILES}/removed.${ext}"
|
||||
)
|
||||
endforeach()
|
||||
|
||||
foreach(ext ${extensions_3})
|
||||
add_test(
|
||||
NAME extract_pem_${ext}
|
||||
COMMAND osslsigncode "extract-signature" "-pem"
|
||||
"-in" "${FILES}/signed.${ext}" "-out" "${FILES}/${ext}.pem"
|
||||
)
|
||||
endforeach()
|
||||
|
||||
foreach(ext ${extensions_3})
|
||||
add_test(
|
||||
NAME extract_der_${ext}
|
||||
COMMAND osslsigncode "extract-signature"
|
||||
"-in" "${FILES}/signed.${ext}" "-out" "${FILES}/${ext}.der"
|
||||
)
|
||||
endforeach()
|
||||
|
||||
foreach(ext ${extensions_3})
|
||||
set_tests_properties(removed_${ext} extract_pem_${ext} extract_der_${ext}
|
||||
PROPERTIES DEPENDS sign_${ext}
|
||||
REQUIRED_FILES "${FILES}/signed.${ext}"
|
||||
)
|
||||
endforeach()
|
||||
|
||||
foreach(ext ${extensions_3})
|
||||
foreach(format ${sign_formats})
|
||||
# Signature verification time: Sep 1 00:00:00 2019 GMT
|
||||
add_test(
|
||||
NAME attached_${format}_${ext}
|
||||
COMMAND osslsigncode "attach-signature" ${verify_opt}
|
||||
"-time" "1567296000"
|
||||
"-require-leaf-hash" "SHA256:${leafhash}"
|
||||
"-add-msi-dse" "-h" "sha512" "-nest"
|
||||
"-sigin" "${FILES}/${ext}.${format}"
|
||||
"-in" "${FILES}/signed.${ext}" "-out" "${FILES}/attached_${format}.${ext}"
|
||||
)
|
||||
set_tests_properties(attached_${format}_${ext} PROPERTIES
|
||||
DEPENDS extract_pem_${ext}
|
||||
REQUIRED_FILES "${FILES}/signed.${ext}"
|
||||
REQUIRED_FILES "${FILES}/${ext}.${format}"
|
||||
)
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
foreach(ext ${extensions_4})
|
||||
add_test(
|
||||
NAME added_${ext}
|
||||
COMMAND osslsigncode "add"
|
||||
"-addUnauthenticatedBlob" "-add-msi-dse" "-h" "sha512"
|
||||
"-in" "${FILES}/signed.${ext}" "-out" "${FILES}/added.${ext}"
|
||||
)
|
||||
set_tests_properties(added_${ext} PROPERTIES
|
||||
DEPENDS sign_${ext}
|
||||
REQUIRED_FILES "${FILES}/signed.${ext}"
|
||||
)
|
||||
endforeach()
|
||||
|
||||
foreach(ext ${extensions_4})
|
||||
add_test(
|
||||
NAME nested_${ext}
|
||||
COMMAND osslsigncode "sign" "-nest" ${sign_opt} ${priv_der}
|
||||
"-in" "${FILES}/signed.${ext}" "-out" "${FILES}/nested.${ext}"
|
||||
)
|
||||
set_tests_properties(nested_${ext} PROPERTIES
|
||||
DEPENDS sign_${ext}
|
||||
REQUIRED_FILES "${FILES}/signed.${ext}"
|
||||
)
|
||||
endforeach()
|
||||
|
||||
|
||||
foreach(file ${files_4})
|
||||
foreach(ext ${extensions_4})
|
||||
# Signature verification time: Sep 1 00:00:00 2019 GMT
|
||||
add_test(
|
||||
NAME verify_${file}_${ext}
|
||||
COMMAND osslsigncode "verify" ${verify_opt}
|
||||
"-time" "1567296000"
|
||||
"-require-leaf-hash" "SHA256:${leafhash}"
|
||||
"-in" "${FILES}/${file}.${ext}"
|
||||
)
|
||||
set_tests_properties(verify_${file}_${ext} PROPERTIES
|
||||
DEPENDS ${file}_${ext}
|
||||
REQUIRED_FILES "${FILES}/${file}.${ext}"
|
||||
)
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
foreach(file ${files_3})
|
||||
foreach(ext ${extensions_3})
|
||||
# Signature verification time: Sep 1 00:00:00 2019 GMT
|
||||
add_test(
|
||||
NAME verify_${file}_${ext}
|
||||
COMMAND osslsigncode "verify" ${verify_opt}
|
||||
"-time" "1567296000"
|
||||
"-require-leaf-hash" "SHA256:${leafhash}"
|
||||
"-in" "${FILES}/${file}.${ext}"
|
||||
)
|
||||
set_tests_properties(verify_${file}_${ext} PROPERTIES
|
||||
DEPENDS ${file}_${ext}
|
||||
REQUIRED_FILES "${FILES}/${file}.${ext}"
|
||||
)
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
foreach(ext ${extensions_3})
|
||||
set_tests_properties(verify_removed_${ext} PROPERTIES
|
||||
WILL_FAIL TRUE
|
||||
)
|
||||
endforeach()
|
||||
|
||||
|
||||
if(Python3_FOUND)
|
||||
foreach(ext ${extensions_4})
|
||||
foreach(cert ${pem_certs})
|
||||
add_test(
|
||||
NAME sign_ts_${cert}_${ext}
|
||||
COMMAND ${Python3_EXECUTABLE} "${PROJECT_BINARY_DIR}/Testing/tsa_server.py"
|
||||
"--certs" "${CERTS}/${cert}.pem" "--key" "${CERTS}/key.pem"
|
||||
"--input" "${FILES}/unsigned.${ext}" "--output" "${FILES}/ts_${cert}.${ext}"
|
||||
)
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
foreach(ext ${extensions_4})
|
||||
# Signature verification time: Sep 1 00:00:00 2019 GMT
|
||||
add_test(
|
||||
NAME verify_ts_cert_${ext}
|
||||
COMMAND osslsigncode "verify" ${verify_opt}
|
||||
"-time" "1567296000"
|
||||
"-in" "${FILES}/ts_cert.${ext}"
|
||||
)
|
||||
set_tests_properties(verify_ts_cert_${ext} PROPERTIES
|
||||
DEPENDS sign_ts_${cert}_${ext}
|
||||
REQUIRED_FILES "${FILES}/ts_cert.${ext}"
|
||||
)
|
||||
endforeach()
|
||||
|
||||
# Signature verification time: Jan 1 00:00:00 2035 GMT
|
||||
foreach(ext ${extensions_4})
|
||||
add_test(
|
||||
NAME verify_ts_future_${ext}
|
||||
COMMAND osslsigncode "verify" ${verify_opt}
|
||||
"-time" "2051222400"
|
||||
"-in" "${FILES}/ts_cert.${ext}"
|
||||
)
|
||||
set_tests_properties(verify_ts_future_${ext} PROPERTIES
|
||||
DEPENDS sign_ts_${cert}_${ext}
|
||||
REQUIRED_FILES "${FILES}/ts_cert.${ext}"
|
||||
)
|
||||
endforeach()
|
||||
|
||||
# Signature verification time: Jan 1 00:00:00 2035 GMT
|
||||
# enabled "-ignore-timestamp" option
|
||||
foreach(ext ${extensions_4})
|
||||
add_test(
|
||||
NAME verify_ts_ignore_${ext}
|
||||
COMMAND osslsigncode "verify" ${verify_opt}
|
||||
"-time" "2051222400"
|
||||
"-ignore-timestamp"
|
||||
"-in" "${FILES}/ts_cert.${ext}"
|
||||
)
|
||||
set_tests_properties(verify_ts_ignore_${ext} PROPERTIES
|
||||
DEPENDS sign_ts_${cert}_${ext}
|
||||
REQUIRED_FILES "${FILES}/ts_cert.${ext}"
|
||||
WILL_FAIL TRUE
|
||||
)
|
||||
endforeach()
|
||||
|
||||
# Signature verification time: Sep 1 00:00:00 2019 GMT
|
||||
# Certificate has expired or revoked
|
||||
foreach(ext ${extensions_4})
|
||||
foreach(cert ${failed_certs})
|
||||
add_test(
|
||||
NAME verify_ts_${cert}_${ext}
|
||||
COMMAND osslsigncode "verify" ${verify_opt}
|
||||
"-time" "1567296000"
|
||||
"-in" "${FILES}/ts_${cert}.${ext}"
|
||||
)
|
||||
set_tests_properties(verify_ts_${cert}_${ext} PROPERTIES
|
||||
DEPENDS sign_ts_${cert}_${ext}
|
||||
REQUIRED_FILES "${FILES}/ts_${cert}.${ext}"
|
||||
WILL_FAIL TRUE
|
||||
)
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
else()
|
||||
message(STATUS "Python3 was not found, skip timestamping tests")
|
||||
endif()
|
||||
|
||||
foreach(ext ${extensions_4})
|
||||
set(OUTPUT_FILES ${OUTPUT_FILES} "${FILES}/signed.${ext}")
|
||||
set(OUTPUT_FILES ${OUTPUT_FILES} "${FILES}/nested.${ext}")
|
||||
set(OUTPUT_FILES ${OUTPUT_FILES} "${FILES}/removed.${ext}")
|
||||
set(OUTPUT_FILES ${OUTPUT_FILES} "${FILES}/added.${ext}")
|
||||
foreach(cert ${pem_certs})
|
||||
set(OUTPUT_FILES ${OUTPUT_FILES} "${FILES}/ts_${cert}.${ext}")
|
||||
endforeach()
|
||||
foreach(format ${sign_formats})
|
||||
set(OUTPUT_FILES ${OUTPUT_FILES} "${FILES}/${ext}.${format}")
|
||||
set(OUTPUT_FILES ${OUTPUT_FILES} "${FILES}/${ext}.${format}")
|
||||
set(OUTPUT_FILES ${OUTPUT_FILES} "${FILES}/attached_${format}.${ext}")
|
||||
endforeach()
|
||||
set(OUTPUT_FILES ${OUTPUT_FILES} "${FILES}/jreq.tsq")
|
||||
set(OUTPUT_FILES ${OUTPUT_FILES} "${FILES}/jresp.tsr")
|
||||
endforeach()
|
||||
add_test(NAME remove_files COMMAND ${CMAKE_COMMAND} -E rm -f ${OUTPUT_FILES})
|
22
cmake/FindHeaders.cmake
Normal file
22
cmake/FindHeaders.cmake
Normal file
@ -0,0 +1,22 @@
|
||||
include(CheckIncludeFile)
|
||||
include(CheckFunctionExists)
|
||||
|
||||
if(NOT MSVC)
|
||||
check_function_exists(getpass HAVE_GETPASS)
|
||||
check_include_file(termios.h HAVE_TERMIOS_H)
|
||||
check_include_file(sys/mman.h HAVE_SYS_MMAN_H)
|
||||
if(HAVE_SYS_MMAN_H)
|
||||
check_function_exists(mmap HAVE_MMAP)
|
||||
if(NOT HAVE_MMAP)
|
||||
message(FATAL_ERROR "Error: Need mmap to build.")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# include wincrypt.h in Windows.h
|
||||
if(MSVC AND NOT CYGWIN)
|
||||
check_include_file(windows.h HAVE_MAPVIEWOFFILE)
|
||||
if(NOT (HAVE_MMAP OR HAVE_MAPVIEWOFFILE))
|
||||
message(FATAL_ERROR "Error: Need file mapping function to build.")
|
||||
endif()
|
||||
endif()
|
13
cmake/SetBashCompletion.cmake
Normal file
13
cmake/SetBashCompletion.cmake
Normal file
@ -0,0 +1,13 @@
|
||||
if(NOT MSVC)
|
||||
find_package(bash-completion QUIET)
|
||||
if(NOT BASH_COMPLETION_COMPLETIONSDIR)
|
||||
if(BASH_COMPLETION_COMPATDIR)
|
||||
set(BASH_COMPLETION_COMPLETIONSDIR ${BASH_COMPLETION_COMPATDIR})
|
||||
else()
|
||||
set(SHAREDIR "${CMAKE_INSTALL_PREFIX}/share")
|
||||
set(BASH_COMPLETION_COMPLETIONSDIR "${SHAREDIR}/bash-completion/completions")
|
||||
endif()
|
||||
endif()
|
||||
message(STATUS "Using bash completions dir ${BASH_COMPLETION_COMPLETIONSDIR}")
|
||||
install(FILES "osslsigncode.bash" DESTINATION ${BASH_COMPLETION_COMPLETIONSDIR})
|
||||
endif()
|
111
cmake/SetCompilerFlags.cmake
Normal file
111
cmake/SetCompilerFlags.cmake
Normal file
@ -0,0 +1,111 @@
|
||||
include(CheckCCompilerFlag)
|
||||
|
||||
set(CMAKE_REQUIRED_QUIET ON)
|
||||
|
||||
function(add_debug_flag_if_supported flagname targets)
|
||||
check_c_compiler_flag("${flagname}" HAVE_FLAG_${flagname})
|
||||
if (HAVE_FLAG_${flagname})
|
||||
foreach(target ${targets})
|
||||
target_compile_options(${target} PRIVATE $<$<CONFIG:DEBUG>:${flagname}>)
|
||||
endforeach()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(add_compile_flag_to_targets targets)
|
||||
set(CHECKED_DEBUG_FLAGS
|
||||
"-ggdb"
|
||||
"-g"
|
||||
"-O2"
|
||||
"-pedantic"
|
||||
"-Wall"
|
||||
"-Wextra"
|
||||
"-Wno-long-long"
|
||||
"-Wconversion"
|
||||
"-D_FORTIFY_SOURCE=2"
|
||||
"-Wformat=2"
|
||||
"-Wredundant-decls"
|
||||
"-Wcast-qual"
|
||||
"-Wnull-dereference"
|
||||
"-Wno-deprecated-declarations"
|
||||
"-Wmissing-declarations"
|
||||
"-Wmissing-prototypes"
|
||||
"-Wmissing-noreturn"
|
||||
"-Wmissing-braces"
|
||||
"-Wparentheses"
|
||||
"-Wstrict-aliasing=3"
|
||||
"-Wstrict-overflow=2"
|
||||
"-Wlogical-op"
|
||||
"-Wwrite-strings"
|
||||
"-Wcast-align=strict"
|
||||
"-Wdisabled-optimization"
|
||||
"-Wshift-overflow=2"
|
||||
"-Wundef"
|
||||
"-Wshadow"
|
||||
"-Wmisleading-indentation"
|
||||
"-Wabsolute-value"
|
||||
"-Wunused-parameter"
|
||||
"-Wunused-function"
|
||||
)
|
||||
foreach(flag ${CHECKED_DEBUG_FLAGS})
|
||||
add_debug_flag_if_supported(${flag} ${targets})
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
function(add_compile_flags target)
|
||||
if(MSVC)
|
||||
# Enable parallel builds
|
||||
target_compile_options(${target} PRIVATE /MP)
|
||||
# Use address space layout randomization, generate PIE code for ASLR (default on)
|
||||
target_link_options(${target} PRIVATE /DYNAMICBASE)
|
||||
# Create terminal server aware application (default on)
|
||||
target_link_options(${target} PRIVATE /TSAWARE)
|
||||
# Mark the binary as compatible with Intel Control-flow Enforcement Technology (CET) Shadow Stack
|
||||
target_link_options(${target} PRIVATE /CETCOMPAT)
|
||||
# Enable compiler generation of Control Flow Guard security checks
|
||||
target_compile_options(${target} PRIVATE /guard:cf)
|
||||
target_link_options(${target} PRIVATE /guard:cf)
|
||||
# Buffer Security Check
|
||||
target_compile_options(${target} PRIVATE /GS)
|
||||
# Suppress startup banner
|
||||
target_link_options(${target} PRIVATE /NOLOGO)
|
||||
# Generate debug info
|
||||
target_link_options(${target} PRIVATE /DEBUG)
|
||||
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
|
||||
# High entropy ASLR for 64 bits targets (default on)
|
||||
target_link_options(${target} PRIVATE /HIGHENTROPYVA)
|
||||
# Enable generation of EH Continuation (EHCONT) metadata by the compiler
|
||||
#target_compile_options(${target} PRIVATE /guard:ehcont)
|
||||
#target_link_options(${target} PRIVATE /guard:ehcont)
|
||||
else()
|
||||
# Can handle addresses larger than 2 gigabytes
|
||||
target_link_options(${target} PRIVATE /LARGEADDRESSAWARE)
|
||||
# Safe structured exception handlers (x86 only)
|
||||
target_link_options(${target} PRIVATE /SAFESEH)
|
||||
endif()
|
||||
target_compile_options(${target} PRIVATE $<$<CONFIG:DEBUG>:/D_FORTIFY_SOURCE=2>)
|
||||
# Unrecognized compiler options are errors
|
||||
target_compile_options(${target} PRIVATE $<$<CONFIG:DEBUG>:/options:strict>)
|
||||
else()
|
||||
check_c_compiler_flag("-fstack-protector-all" HAVE_STACK_PROTECTOR_ALL)
|
||||
if(HAVE_STACK_PROTECTOR_ALL)
|
||||
target_link_options(${target} PRIVATE -fstack-protector-all)
|
||||
else()
|
||||
check_c_compiler_flag("-fstack-protector" HAVE_STACK_PROTECTOR)
|
||||
if(HAVE_STACK_PROTECTOR)
|
||||
target_link_options(${target} PRIVATE -fstack-protector)
|
||||
else()
|
||||
message(WARNING "No stack protection supported")
|
||||
endif()
|
||||
endif()
|
||||
# Support address space layout randomization (ASLR)
|
||||
target_compile_options(${target} PRIVATE $<$<NOT:$<C_COMPILER_ID:AppleClang>>:-fPIE>)
|
||||
target_link_options(${target} PRIVATE $<$<NOT:$<C_COMPILER_ID:AppleClang>>:-fPIE -pie>)
|
||||
target_link_options(${target} PRIVATE $<$<NOT:$<C_COMPILER_ID:AppleClang>>:-Wl,-z,relro>)
|
||||
target_link_options(${target} PRIVATE $<$<NOT:$<C_COMPILER_ID:AppleClang>>:-Wl,-z,now>)
|
||||
target_link_options(${target} PRIVATE $<$<NOT:$<C_COMPILER_ID:AppleClang>>:-Wl,-z,noexecstack>)
|
||||
target_link_options(${target} PRIVATE -fstack-check)
|
||||
add_compile_flag_to_targets(${target})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
add_compile_flags(osslsigncode)
|
126
configure.ac
126
configure.ac
@ -1,126 +0,0 @@
|
||||
AC_PREREQ(2.60)
|
||||
|
||||
AC_INIT([osslsigncode], [2.2.0], [Michal.Trojnara@stunnel.org])
|
||||
AC_CONFIG_AUX_DIR([.])
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
AM_INIT_AUTOMAKE
|
||||
|
||||
AC_CONFIG_SRCDIR([osslsigncode.c])
|
||||
|
||||
dnl Checks for programs.
|
||||
AC_PROG_CC
|
||||
AC_USE_SYSTEM_EXTENSIONS
|
||||
|
||||
AC_ARG_ENABLE(
|
||||
[strict],
|
||||
[AS_HELP_STRING([--enable-strict],[enable strict compile mode @<:@disabled@:>@])],
|
||||
,
|
||||
[enable_strict="no"]
|
||||
)
|
||||
|
||||
AC_ARG_ENABLE(
|
||||
[pedantic],
|
||||
[AS_HELP_STRING([--enable-pedantic],[enable pedantic compile mode @<:@disabled@:>@])],
|
||||
,
|
||||
[enable_pedantic="no"]
|
||||
)
|
||||
|
||||
AC_ARG_WITH(
|
||||
[curl],
|
||||
[AS_HELP_STRING([--with-curl],[enable curl @<:@enabled@:>@])],
|
||||
,
|
||||
[with_curl="yes"]
|
||||
)
|
||||
|
||||
if test "${enable_pedantic}" = "yes"; then
|
||||
enable_strict="yes";
|
||||
CFLAGS="${CFLAGS} -pedantic"
|
||||
fi
|
||||
if test "${enable_strict}" = "yes"; then
|
||||
CFLAGS="${CFLAGS} -Wall -Wextra"
|
||||
fi
|
||||
|
||||
PKG_PROG_PKG_CONFIG
|
||||
AC_PROG_CPP
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LN_S
|
||||
AC_PROG_MKDIR_P
|
||||
AC_PROG_SED
|
||||
AC_PROG_MAKE_SET
|
||||
|
||||
AC_C_CONST
|
||||
AC_HEADER_STDC
|
||||
AC_HEADER_TIME
|
||||
AC_CHECK_HEADERS(
|
||||
[sys/mman.h],
|
||||
[AC_CHECK_FUNC(
|
||||
[mmap],
|
||||
[AC_DEFINE(HAVE_MMAP, [1], [Define to 1 if you have mmap])],
|
||||
[AC_MSG_ERROR([Need mmap to build.])]
|
||||
)],
|
||||
[have_mmap=no]
|
||||
)
|
||||
AC_CHECK_HEADERS(
|
||||
[windows.h],
|
||||
[],
|
||||
[have_MapViewOfFile=no]
|
||||
)
|
||||
AS_IF([test "x$have_mmap$have_MapViewOfFile" = "xnono"],
|
||||
[AC_MSG_ERROR([Need file mapping function to buid.])])
|
||||
|
||||
AC_CHECK_LIB(
|
||||
[dl],
|
||||
[dlopen],
|
||||
[DL_LIBS="-ldl"]
|
||||
)
|
||||
|
||||
AC_CHECK_HEADERS([termios.h])
|
||||
AC_CHECK_FUNCS(getpass)
|
||||
|
||||
PKG_CHECK_MODULES(
|
||||
[OPENSSL],
|
||||
[libcrypto >= 1.1.1],
|
||||
,
|
||||
[PKG_CHECK_MODULES(
|
||||
[OPENSSL],
|
||||
[openssl >= 1.1.1],
|
||||
,
|
||||
[AC_CHECK_LIB(
|
||||
[crypto],
|
||||
[EVP_MD_CTX_new],
|
||||
[OPENSSL_LIBS="-lcrypto ${SOCKETS_LIBS} ${DL_LIBS}"],
|
||||
[AC_MSG_ERROR([OpenSSL 1.1.1 or later is required. https://www.openssl.org/])],
|
||||
[${DL_LIBS}]
|
||||
)]
|
||||
)]
|
||||
)
|
||||
|
||||
PKG_CHECK_MODULES(
|
||||
[LIBCURL],
|
||||
[libcurl >= 7.12.0],
|
||||
,
|
||||
[AC_CHECK_LIB(
|
||||
[curl],
|
||||
[curl_easy_strerror],
|
||||
[LIBCURL_LIBS="-lcurl"],
|
||||
,
|
||||
[${DL_LIBS}]
|
||||
)]
|
||||
)
|
||||
|
||||
if test "${with_curl}" = "yes"; then
|
||||
test -z "${LIBCURL_LIBS}" && AC_MSG_ERROR([Curl 7.12.0 or later is required for timestamping support. http://curl.haxx.se/])
|
||||
OPTIONAL_LIBCURL_CFLAGS="${LIBCURL_CFLAGS}"
|
||||
OPTIONAL_LIBCURL_LIBS="${LIBCURL_LIBS}"
|
||||
AC_DEFINE([ENABLE_CURL], [1], [libcurl is enabled])
|
||||
fi
|
||||
|
||||
AC_SUBST([OPTIONAL_LIBCURL_CFLAGS])
|
||||
AC_SUBST([OPTIONAL_LIBCURL_LIBS])
|
||||
|
||||
AC_DEFINE_UNQUOTED([CA_BUNDLE_PATH], ["$(curl-config --ca 2>/dev/null)"], [CA bundle install path])
|
||||
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
AC_OUTPUT
|
||||
|
||||
# vim: set ts=4 noexpandtab:
|
567
msi.c
567
msi.c
@ -15,19 +15,22 @@
|
||||
|
||||
#define MIN(a,b) ((a) < (b) ? a : b)
|
||||
|
||||
static int recurse_entry(MSI_FILE *msi, uint32_t entryID, MSI_DIRENT *parent);
|
||||
|
||||
/* Get absolute address from sector and offset */
|
||||
static const u_char *sector_offset_to_address(MSI_FILE *msi, size_t sector, size_t offset)
|
||||
static const u_char *sector_offset_to_address(MSI_FILE *msi, uint32_t sector, uint32_t offset)
|
||||
{
|
||||
if (sector >= MAXREGSECT || offset >= msi->m_sectorSize ||
|
||||
msi->m_bufferLen <= msi->m_sectorSize * sector + msi->m_sectorSize + offset) {
|
||||
if (sector >= MAXREGSECT || offset >= msi->m_sectorSize
|
||||
|| (msi->m_bufferLen - offset) / msi->m_sectorSize <= sector) {
|
||||
printf("Corrupted file\n");
|
||||
return NULL; /* FAILED */
|
||||
}
|
||||
return msi->m_buffer + msi->m_sectorSize + msi->m_sectorSize * sector + offset;
|
||||
return msi->m_buffer + (sector + 1) * msi->m_sectorSize + offset;
|
||||
}
|
||||
|
||||
static size_t get_fat_sector_location(MSI_FILE *msi, size_t fatSectorNumber)
|
||||
static uint32_t get_fat_sector_location(MSI_FILE *msi, uint32_t fatSectorNumber)
|
||||
{
|
||||
size_t entriesPerSector, difatSectorLocation;
|
||||
uint32_t entriesPerSector, difatSectorLocation;
|
||||
const u_char *address;
|
||||
|
||||
if (fatSectorNumber < DIFAT_IN_HEADER) {
|
||||
@ -39,40 +42,68 @@ static size_t get_fat_sector_location(MSI_FILE *msi, size_t fatSectorNumber)
|
||||
while (fatSectorNumber >= entriesPerSector) {
|
||||
fatSectorNumber -= entriesPerSector;
|
||||
address = sector_offset_to_address(msi, difatSectorLocation, msi->m_sectorSize - 4);
|
||||
if (!address) {
|
||||
printf("Failed to get a next sector address\n");
|
||||
return NOSTREAM; /* FAILED */
|
||||
}
|
||||
difatSectorLocation = GET_UINT32_LE(address);
|
||||
}
|
||||
return GET_UINT32_LE(sector_offset_to_address(msi, difatSectorLocation, fatSectorNumber * 4));
|
||||
address = sector_offset_to_address(msi, difatSectorLocation, fatSectorNumber * 4);
|
||||
if (!address) {
|
||||
printf("Failed to get a next sector address\n");
|
||||
return NOSTREAM; /* FAILED */
|
||||
}
|
||||
return GET_UINT32_LE(address);
|
||||
}
|
||||
}
|
||||
|
||||
/* Lookup FAT */
|
||||
static size_t get_next_sector(MSI_FILE *msi, size_t sector)
|
||||
static uint32_t get_next_sector(MSI_FILE *msi, uint32_t sector)
|
||||
{
|
||||
size_t entriesPerSector = msi->m_sectorSize / 4;
|
||||
size_t fatSectorNumber = sector / entriesPerSector;
|
||||
size_t fatSectorLocation = get_fat_sector_location(msi, fatSectorNumber);
|
||||
return GET_UINT32_LE(sector_offset_to_address(msi, fatSectorLocation, sector % entriesPerSector * 4));
|
||||
const u_char *address;
|
||||
uint32_t entriesPerSector = msi->m_sectorSize / 4;
|
||||
uint32_t fatSectorNumber = sector / entriesPerSector;
|
||||
uint32_t fatSectorLocation = get_fat_sector_location(msi, fatSectorNumber);
|
||||
if (fatSectorLocation == NOSTREAM) {
|
||||
printf("Failed to get a fat sector location\n");
|
||||
return NOSTREAM; /* FAILED */
|
||||
}
|
||||
address = sector_offset_to_address(msi, fatSectorLocation, sector % entriesPerSector * 4);
|
||||
if (!address) {
|
||||
printf("Failed to get a next sector address\n");
|
||||
return NOSTREAM; /* FAILED */
|
||||
}
|
||||
return GET_UINT32_LE(address);
|
||||
}
|
||||
|
||||
/* Locate the final sector/offset when original offset expands multiple sectors */
|
||||
static void locate_final_sector(MSI_FILE *msi, size_t sector, size_t offset, size_t *finalSector, size_t *finalOffset)
|
||||
static int locate_final_sector(MSI_FILE *msi, uint32_t sector, uint32_t offset, uint32_t *finalSector, uint32_t *finalOffset)
|
||||
{
|
||||
while (offset >= msi->m_sectorSize) {
|
||||
offset -= msi->m_sectorSize;
|
||||
sector = get_next_sector(msi, sector);
|
||||
if (sector == NOSTREAM) {
|
||||
printf("Failed to get a next sector\n");
|
||||
return 0; /* FAILED */
|
||||
}
|
||||
}
|
||||
*finalSector = sector;
|
||||
*finalOffset = offset;
|
||||
return 1; /* OK */
|
||||
}
|
||||
|
||||
/* Get absolute address from mini sector and offset */
|
||||
static const u_char *mini_sector_offset_to_address(MSI_FILE *msi, size_t sector, size_t offset)
|
||||
static const u_char *mini_sector_offset_to_address(MSI_FILE *msi, uint32_t sector, uint32_t offset)
|
||||
{
|
||||
if (sector >= MAXREGSECT || offset >= msi->m_minisectorSize ||
|
||||
msi->m_bufferLen <= msi->m_minisectorSize * sector + offset) {
|
||||
(msi->m_bufferLen - offset) / msi->m_minisectorSize <= sector) {
|
||||
printf("Corrupted file\n");
|
||||
return NULL; /* FAILED */
|
||||
}
|
||||
if (!locate_final_sector(msi, msi->m_miniStreamStartSector, sector * msi->m_minisectorSize + offset, §or, &offset)) {
|
||||
printf("Failed to locate a final sector\n");
|
||||
return NULL; /* FAILED */
|
||||
}
|
||||
locate_final_sector(msi, msi->m_miniStreamStartSector, sector * msi->m_minisectorSize + offset, §or, &offset);
|
||||
return sector_offset_to_address(msi, sector, offset);
|
||||
}
|
||||
|
||||
@ -80,66 +111,109 @@ static const u_char *mini_sector_offset_to_address(MSI_FILE *msi, size_t sector,
|
||||
* Copy as many as possible in each step
|
||||
* copylen typically iterate as: msi->m_sectorSize - offset --> msi->m_sectorSize --> msi->m_sectorSize --> ... --> remaining
|
||||
*/
|
||||
static int read_stream(MSI_FILE *msi, size_t sector, size_t offset, char *buffer, size_t len)
|
||||
static int read_stream(MSI_FILE *msi, uint32_t sector, uint32_t offset, char *buffer, uint32_t len)
|
||||
{
|
||||
locate_final_sector(msi, sector, offset, §or, &offset);
|
||||
if (!locate_final_sector(msi, sector, offset, §or, &offset)) {
|
||||
printf("Failed to locate a final sector\n");
|
||||
return 0; /* FAILED */
|
||||
}
|
||||
while (len > 0) {
|
||||
const u_char *address = sector_offset_to_address(msi, sector, offset);
|
||||
size_t copylen = MIN(len, msi->m_sectorSize - offset);
|
||||
const u_char *address;
|
||||
uint32_t copylen;
|
||||
address = sector_offset_to_address(msi, sector, offset);
|
||||
if (!address) {
|
||||
printf("Failed to get a next sector address\n");
|
||||
return 0; /* FAILED */
|
||||
}
|
||||
copylen = MIN(len, msi->m_sectorSize - offset);
|
||||
if (msi->m_buffer + msi->m_bufferLen < address + copylen) {
|
||||
printf("Corrupted file\n");
|
||||
return 0; /* FAILED */
|
||||
}
|
||||
memcpy(buffer, address, copylen);
|
||||
buffer += copylen;
|
||||
len -= copylen;
|
||||
sector = get_next_sector(msi, sector);
|
||||
if (sector == 0) {
|
||||
printf("Failed to get a next sector\n");
|
||||
return 0; /* FAILED */
|
||||
}
|
||||
offset = 0;
|
||||
}
|
||||
return 1;
|
||||
return 1; /* OK */
|
||||
}
|
||||
|
||||
/* Lookup miniFAT */
|
||||
static size_t get_next_mini_sector(MSI_FILE *msi, size_t miniSector)
|
||||
static uint32_t get_next_mini_sector(MSI_FILE *msi, uint32_t miniSector)
|
||||
{
|
||||
size_t sector, offset;
|
||||
locate_final_sector(msi, msi->m_hdr->firstMiniFATSectorLocation, miniSector * 4, §or, &offset);
|
||||
return GET_UINT32_LE(sector_offset_to_address(msi, sector, offset));
|
||||
uint32_t sector, offset;
|
||||
const u_char *address;
|
||||
|
||||
if (!locate_final_sector(msi, msi->m_hdr->firstMiniFATSectorLocation, miniSector * 4, §or, &offset)) {
|
||||
printf("Failed to locate a final sector\n");
|
||||
return NOSTREAM; /* FAILED */
|
||||
}
|
||||
address = sector_offset_to_address(msi, sector, offset);
|
||||
if (!address) {
|
||||
printf("Failed to get a next mini sector address\n");
|
||||
return NOSTREAM; /* FAILED */
|
||||
}
|
||||
return GET_UINT32_LE(address);
|
||||
}
|
||||
|
||||
static void locate_final_mini_sector(MSI_FILE *msi, size_t sector, size_t offset, size_t *finalSector, size_t *finalOffset)
|
||||
static int locate_final_mini_sector(MSI_FILE *msi, uint32_t sector, uint32_t offset, uint32_t *finalSector, uint32_t *finalOffset)
|
||||
{
|
||||
while (offset >= msi->m_minisectorSize) {
|
||||
offset -= msi->m_minisectorSize;
|
||||
sector = get_next_mini_sector(msi, sector);
|
||||
if (sector == NOSTREAM) {
|
||||
printf("Failed to get a next mini sector\n");
|
||||
return 0; /* FAILED */
|
||||
}
|
||||
}
|
||||
*finalSector = sector;
|
||||
*finalOffset = offset;
|
||||
return 1; /* OK */
|
||||
}
|
||||
|
||||
/* Same logic as "read_stream" except that use mini stream functions instead */
|
||||
static int read_mini_stream(MSI_FILE *msi, size_t sector, size_t offset, char *buffer, size_t len)
|
||||
static int read_mini_stream(MSI_FILE *msi, uint32_t sector, uint32_t offset, char *buffer, uint32_t len)
|
||||
{
|
||||
locate_final_mini_sector(msi, sector, offset, §or, &offset);
|
||||
if (!locate_final_mini_sector(msi, sector, offset, §or, &offset)) {
|
||||
printf("Failed to locate a final mini sector\n");
|
||||
return 0; /* FAILED */
|
||||
}
|
||||
while (len > 0) {
|
||||
const u_char *address = mini_sector_offset_to_address(msi, sector, offset);
|
||||
size_t copylen = MIN(len, msi->m_minisectorSize - offset);
|
||||
if (!address || msi->m_buffer + msi->m_bufferLen < address + copylen) {
|
||||
const u_char *address;
|
||||
uint32_t copylen;
|
||||
address = mini_sector_offset_to_address(msi, sector, offset);
|
||||
if (!address) {
|
||||
printf("Failed to get a next mini sector address\n");
|
||||
return 0; /* FAILED */
|
||||
}
|
||||
copylen = MIN(len, msi->m_minisectorSize - offset);
|
||||
if (msi->m_buffer + msi->m_bufferLen < address + copylen) {
|
||||
printf("Corrupted file\n");
|
||||
return 0; /* FAILED */
|
||||
}
|
||||
memcpy(buffer, address, copylen);
|
||||
buffer += copylen;
|
||||
len -= copylen;
|
||||
sector = get_next_mini_sector(msi, sector);
|
||||
if (sector == NOSTREAM) {
|
||||
printf("Failed to get a next mini sector\n");
|
||||
return 0; /* FAILED */
|
||||
}
|
||||
offset = 0;
|
||||
}
|
||||
return 1;
|
||||
return 1; /* OK */
|
||||
}
|
||||
|
||||
/*
|
||||
* Get file (stream) data start with "offset".
|
||||
* The buffer must have enough space to store "len" bytes. Typically "len" is derived by the steam length.
|
||||
*/
|
||||
int msi_file_read(MSI_FILE *msi, MSI_ENTRY *entry, size_t offset, char *buffer, size_t len)
|
||||
int msi_file_read(MSI_FILE *msi, MSI_ENTRY *entry, uint32_t offset, char *buffer, uint32_t len)
|
||||
{
|
||||
if (len < msi->m_hdr->miniStreamCutoffSize) {
|
||||
if (!read_mini_stream(msi, entry->startSectorLocation, offset, buffer, len))
|
||||
@ -148,43 +222,108 @@ int msi_file_read(MSI_FILE *msi, MSI_ENTRY *entry, size_t offset, char *buffer,
|
||||
if (!read_stream(msi, entry->startSectorLocation, offset, buffer, len))
|
||||
return 0; /* FAILED */
|
||||
}
|
||||
return 1;
|
||||
return 1; /* OK */
|
||||
}
|
||||
|
||||
/* Parse MSI_FILE_HDR struct */
|
||||
static MSI_FILE_HDR *parse_header(char *data)
|
||||
{
|
||||
MSI_FILE_HDR *header = (MSI_FILE_HDR *)OPENSSL_malloc(HEADER_SIZE);
|
||||
if (!data) {
|
||||
/* initialise 512 bytes */
|
||||
memset(header, 0, sizeof(MSI_FILE_HDR));
|
||||
} else {
|
||||
memcpy(header->signature, data + HEADER_SIGNATURE, sizeof header->signature);
|
||||
header->minorVersion = GET_UINT16_LE(data + HEADER_MINOR_VER);
|
||||
header->majorVersion = GET_UINT16_LE(data + HEADER_MAJOR_VER);
|
||||
header->byteOrder = GET_UINT16_LE(data + HEADER_BYTE_ORDER);
|
||||
header->sectorShift = GET_UINT16_LE(data + HEADER_SECTOR_SHIFT);
|
||||
header->miniSectorShift = GET_UINT16_LE(data + HEADER_MINI_SECTOR_SHIFT);
|
||||
header->numDirectorySector = GET_UINT32_LE(data + HEADER_DIR_SECTORS_NUM);
|
||||
header->numFATSector = GET_UINT32_LE(data + HEADER_FAT_SECTORS_NUM);
|
||||
header->firstDirectorySectorLocation = GET_UINT32_LE(data + HEADER_DIR_SECTOR_LOC);
|
||||
header->transactionSignatureNumber = GET_UINT32_LE(data + HEADER_TRANSACTION);
|
||||
header->miniStreamCutoffSize = GET_UINT32_LE(data + HEADER_MINI_STREAM_CUTOFF);
|
||||
header->firstMiniFATSectorLocation = GET_UINT32_LE(data + HEADER_MINI_FAT_SECTOR_LOC);
|
||||
header->numMiniFATSector = GET_UINT32_LE(data + HEADER_MINI_FAT_SECTORS_NUM);
|
||||
header->firstDIFATSectorLocation = GET_UINT32_LE(data + HEADER_DIFAT_SECTOR_LOC);
|
||||
header->numDIFATSector = GET_UINT32_LE(data + HEADER_DIFAT_SECTORS_NUM);
|
||||
memcpy(header->headerDIFAT, data + HEADER_DIFAT, sizeof header->headerDIFAT);
|
||||
|
||||
/* initialise 512 bytes */
|
||||
memset(header, 0, sizeof(MSI_FILE_HDR));
|
||||
memcpy(header->signature, data + HEADER_SIGNATURE, sizeof header->signature);
|
||||
/* Minor Version field SHOULD be set to 0x003E. */
|
||||
header->minorVersion = GET_UINT16_LE(data + HEADER_MINOR_VER);
|
||||
if (header->minorVersion !=0x003E ) {
|
||||
printf("Warning: Minor Version field SHOULD be 0x003E, but is: 0x%04X\n", header->minorVersion);
|
||||
}
|
||||
/* Major Version field MUST be set to either 0x0003 (version 3) or 0x0004 (version 4). */
|
||||
header->majorVersion = GET_UINT16_LE(data + HEADER_MAJOR_VER);
|
||||
if (header->majorVersion != 0x0003 && header->majorVersion != 0x0004) {
|
||||
printf("Unknown Major Version: 0x%04X\n", header->majorVersion);
|
||||
OPENSSL_free(header);
|
||||
return NULL; /* FAILED */
|
||||
}
|
||||
/* Byte Order field MUST be set to 0xFFFE, specifies little-endian byte order. */
|
||||
header->byteOrder = GET_UINT16_LE(data + HEADER_BYTE_ORDER);
|
||||
if (header->byteOrder != 0xFFFE) {
|
||||
printf("Unknown Byte Order: 0x%04X\n", header->byteOrder);
|
||||
OPENSSL_free(header);
|
||||
return NULL; /* FAILED */
|
||||
}
|
||||
/* Sector Shift field MUST be set to 0x0009, or 0x000c, depending on the Major Version field.
|
||||
* This field specifies the sector size of the compound file as a power of 2. */
|
||||
header->sectorShift = GET_UINT16_LE(data + HEADER_SECTOR_SHIFT);
|
||||
if ((header->majorVersion == 0x0003 && header->sectorShift != 0x0009) ||
|
||||
(header->majorVersion == 0x0004 && header->sectorShift != 0x000C)) {
|
||||
printf("Unknown Sector Shift: 0x%04X\n", header->sectorShift);
|
||||
OPENSSL_free(header);
|
||||
return NULL; /* FAILED */
|
||||
}
|
||||
/* Mini Sector Shift field MUST be set to 0x0006.
|
||||
* This field specifies the sector size of the Mini Stream as a power of 2.
|
||||
* The sector size of the Mini Stream MUST be 64 bytes. */
|
||||
header->miniSectorShift = GET_UINT16_LE(data + HEADER_MINI_SECTOR_SHIFT);
|
||||
if (header->miniSectorShift != 0x0006) {
|
||||
printf("Unknown Mini Sector Shift: 0x%04X\n", header->miniSectorShift);
|
||||
OPENSSL_free(header);
|
||||
return NULL; /* FAILED */
|
||||
}
|
||||
/* Number of Directory Sectors field contains the count of the number
|
||||
* of directory sectors in the compound file.
|
||||
* If Major Version is 3, the Number of Directory Sectors MUST be zero. */
|
||||
header->numDirectorySector = GET_UINT32_LE(data + HEADER_DIR_SECTORS_NUM);
|
||||
if (header->majorVersion == 0x0003 && header->numDirectorySector != 0x00000000) {
|
||||
printf("Unsupported Number of Directory Sectors: 0x%08X\n", header->numDirectorySector);
|
||||
OPENSSL_free(header);
|
||||
return NULL; /* FAILED */
|
||||
}
|
||||
header->numFATSector = GET_UINT32_LE(data + HEADER_FAT_SECTORS_NUM);
|
||||
header->firstDirectorySectorLocation = GET_UINT32_LE(data + HEADER_DIR_SECTOR_LOC);
|
||||
header->transactionSignatureNumber = GET_UINT32_LE(data + HEADER_TRANSACTION);
|
||||
/* Mini Stream Cutoff Size field MUST be set to 0x00001000.
|
||||
* This field specifies the maximum size of a user-defined data stream that is allocated
|
||||
* from the mini FAT and mini stream, and that cutoff is 4,096 bytes.
|
||||
* Any user-defined data stream that is greater than or equal to this cutoff size
|
||||
* must be allocated as normal sectors from the FAT. */
|
||||
header->miniStreamCutoffSize = GET_UINT32_LE(data + HEADER_MINI_STREAM_CUTOFF);
|
||||
if (header->miniStreamCutoffSize != 0x00001000) {
|
||||
printf("Unsupported Mini Stream Cutoff Size: 0x%08X\n", header->miniStreamCutoffSize);
|
||||
OPENSSL_free(header);
|
||||
return NULL; /* FAILED */
|
||||
}
|
||||
header->firstMiniFATSectorLocation = GET_UINT32_LE(data + HEADER_MINI_FAT_SECTOR_LOC);
|
||||
header->numMiniFATSector = GET_UINT32_LE(data + HEADER_MINI_FAT_SECTORS_NUM);
|
||||
header->firstDIFATSectorLocation = GET_UINT32_LE(data + HEADER_DIFAT_SECTOR_LOC);
|
||||
header->numDIFATSector = GET_UINT32_LE(data + HEADER_DIFAT_SECTORS_NUM);
|
||||
memcpy(header->headerDIFAT, data + HEADER_DIFAT, sizeof header->headerDIFAT);
|
||||
return header;
|
||||
}
|
||||
|
||||
/* Parse MSI_ENTRY struct */
|
||||
static MSI_ENTRY *parse_entry(const u_char *data)
|
||||
static MSI_ENTRY *parse_entry(MSI_FILE *msi, const u_char *data, int is_root)
|
||||
{
|
||||
uint32_t inlen;
|
||||
MSI_ENTRY *entry = (MSI_ENTRY *)OPENSSL_malloc(sizeof(MSI_ENTRY));
|
||||
|
||||
/* initialise 128 bytes */
|
||||
memset(entry, 0, sizeof(MSI_ENTRY));
|
||||
entry->nameLen = GET_UINT16_LE(data + DIRENT_NAME_LEN);
|
||||
/* This length MUST NOT exceed 64, the maximum size of the Directory Entry Name field */
|
||||
if (entry->nameLen == 0 || entry->nameLen > 64) {
|
||||
printf("Corrupted Directory Entry Name Length\n");
|
||||
OPENSSL_free(entry);
|
||||
return NULL; /* FAILED */
|
||||
}
|
||||
memcpy(entry->name, data + DIRENT_NAME, entry->nameLen);
|
||||
/* The root directory entry's Name field MUST contain the null-terminated
|
||||
* string "Root Entry" in Unicode UTF-16. */
|
||||
if (is_root && memcmp(entry->name, msi_root_entry, entry->nameLen)) {
|
||||
printf("Corrupted Root Directory Entry's Name\n");
|
||||
OPENSSL_free(entry);
|
||||
return NULL; /* FAILED */
|
||||
}
|
||||
entry->type = GET_UINT8_LE(data + DIRENT_TYPE);
|
||||
entry->colorFlag = GET_UINT8_LE(data + DIRENT_COLOUR);
|
||||
entry->leftSiblingID = GET_UINT32_LE(data + DIRENT_LEFT_SIBLING_ID);
|
||||
@ -193,9 +332,25 @@ static MSI_ENTRY *parse_entry(const u_char *data)
|
||||
memcpy(entry->clsid, data + DIRENT_CLSID, 16);
|
||||
memcpy(entry->stateBits, data + DIRENT_STATE_BITS, 4);
|
||||
memcpy(entry->creationTime, data + DIRENT_CREATE_TIME, 8);
|
||||
/* The Creation Time field in the root storage directory entry MUST be all zeroes
|
||||
but the Modified Time field in the root storage directory entry MAY be all zeroes */
|
||||
if (is_root && memcmp(entry->creationTime, msi_zeroes, 8)) {
|
||||
printf("Corrupted Root Directory Entry's Creation Time\n");
|
||||
OPENSSL_free(entry);
|
||||
return NULL; /* FAILED */
|
||||
}
|
||||
memcpy(entry->modifiedTime, data + DIRENT_MODIFY_TIME, 8);
|
||||
entry->startSectorLocation = GET_UINT32_LE(data + DIRENT_START_SECTOR_LOC);
|
||||
memcpy(entry->size, data + DIRENT_FILE_SIZE, 8);
|
||||
/* For a version 3 compound file 512-byte sector size, the value of this field
|
||||
MUST be less than or equal to 0x80000000 */
|
||||
inlen = GET_UINT32_LE(entry->size);
|
||||
if ((msi->m_sectorSize == 0x0200 && inlen > 0x80000000)
|
||||
|| (msi->m_bufferLen <= inlen)) {
|
||||
printf("Corrupted Stream Size 0x%08X\n", inlen);
|
||||
OPENSSL_free(entry);
|
||||
return NULL; /* FAILED */
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
|
||||
@ -204,63 +359,86 @@ static MSI_ENTRY *parse_entry(const u_char *data)
|
||||
* Pass "0" to get the root directory entry. -- This is the start point to navigate the compound file.
|
||||
* Use the returned object to access child entries.
|
||||
*/
|
||||
static MSI_ENTRY *get_entry(MSI_FILE *msi, size_t entryID)
|
||||
static MSI_ENTRY *get_entry(MSI_FILE *msi, uint32_t entryID, int is_root)
|
||||
{
|
||||
size_t sector = 0;
|
||||
size_t offset = 0;
|
||||
uint32_t sector = 0;
|
||||
uint32_t offset = 0;
|
||||
const u_char *address;
|
||||
|
||||
/* The special value NOSTREAM (0xFFFFFFFF) is used as a terminator */
|
||||
if (entryID == NOSTREAM) {
|
||||
/* Corrupted file */
|
||||
if (!is_root && entryID == 0) {
|
||||
printf("Corrupted entryID\n");
|
||||
return NULL; /* FAILED */
|
||||
}
|
||||
if (msi->m_bufferLen / sizeof(MSI_ENTRY) <= entryID) {
|
||||
printf("Invalid argument entryID\n");
|
||||
return NULL; /* FAILED */
|
||||
}
|
||||
locate_final_sector(msi, msi->m_hdr->firstDirectorySectorLocation, entryID * sizeof(MSI_ENTRY), §or, &offset);
|
||||
/* The first entry in the first sector of the directory chain is known as
|
||||
the root directory entry so it can not contain the directory stream */
|
||||
if (msi->m_hdr->firstDirectorySectorLocation == 0 && entryID == 0) {
|
||||
printf("Corrupted First Directory Sector Location\n");
|
||||
return NULL; /* FAILED */
|
||||
}
|
||||
if (!locate_final_sector(msi, msi->m_hdr->firstDirectorySectorLocation,
|
||||
entryID * sizeof(MSI_ENTRY), §or, &offset)) {
|
||||
printf("Failed to locate a final sector\n");
|
||||
return NULL; /* FAILED */
|
||||
}
|
||||
address = sector_offset_to_address(msi, sector, offset);
|
||||
return parse_entry(address);
|
||||
if (!address) {
|
||||
printf("Failed to get a final address\n");
|
||||
return NULL; /* FAILED */
|
||||
}
|
||||
return parse_entry(msi, address, is_root);
|
||||
}
|
||||
|
||||
MSI_ENTRY *msi_root_entry_get(MSI_FILE *msi)
|
||||
{
|
||||
return get_entry(msi, 0);
|
||||
return get_entry(msi, 0, TRUE);
|
||||
}
|
||||
|
||||
/* Parse MSI_FILE struct */
|
||||
MSI_FILE *msi_file_new(char *buffer, size_t len)
|
||||
MSI_FILE *msi_file_new(char *buffer, uint32_t len)
|
||||
{
|
||||
MSI_FILE *msi;
|
||||
MSI_ENTRY *root;
|
||||
MSI_FILE_HDR *header;
|
||||
|
||||
if (buffer == NULL || len == 0) {
|
||||
printf("Invalid argument\n");
|
||||
return NULL; /* FAILED */
|
||||
}
|
||||
header = parse_header(buffer);
|
||||
if (!header) {
|
||||
printf("Failed to parse MSI_FILE_HDR struct\n");
|
||||
return NULL; /* FAILED */
|
||||
}
|
||||
msi = (MSI_FILE *)OPENSSL_malloc(sizeof(MSI_FILE));
|
||||
msi->m_buffer = (const u_char *)(buffer);
|
||||
msi->m_bufferLen = len;
|
||||
msi->m_hdr = parse_header(buffer);
|
||||
msi->m_sectorSize = 1 << msi->m_hdr->sectorShift;;
|
||||
msi->m_hdr = header;
|
||||
msi->m_sectorSize = 1 << msi->m_hdr->sectorShift;
|
||||
msi->m_minisectorSize = 1 << msi->m_hdr->miniSectorShift;
|
||||
msi->m_miniStreamStartSector = 0;
|
||||
|
||||
if (msi->m_bufferLen < sizeof *(msi->m_hdr) ||
|
||||
memcmp(msi->m_hdr->signature, msi_magic, sizeof msi_magic)) {
|
||||
printf("Wrong file format\n");
|
||||
msi_file_free(msi);
|
||||
return NULL; /* FAILED */
|
||||
}
|
||||
msi->m_sectorSize = msi->m_hdr->majorVersion == 3 ? 512 : 4096;
|
||||
|
||||
/* The file must contains at least 3 sectors */
|
||||
if (msi->m_bufferLen < msi->m_sectorSize * 3) {
|
||||
printf("The file must contains at least 3 sectors\n");
|
||||
msi_file_free(msi);
|
||||
return NULL; /* FAILED */
|
||||
}
|
||||
root = msi_root_entry_get(msi);
|
||||
if (root == NULL) {
|
||||
printf("File corrupted\n");
|
||||
if (!root) {
|
||||
printf("Failed to get msi root entry\n");
|
||||
msi_file_free(msi);
|
||||
return NULL; /* FAILED */
|
||||
}
|
||||
msi->m_miniStreamStartSector = root->startSectorLocation;
|
||||
@ -268,37 +446,90 @@ MSI_FILE *msi_file_new(char *buffer, size_t len)
|
||||
return msi;
|
||||
}
|
||||
|
||||
MSI_FILE_HDR *msi_header_get(MSI_FILE *msi)
|
||||
{
|
||||
return msi->m_hdr;
|
||||
}
|
||||
|
||||
/* Recursively parse MSI_DIRENT struct */
|
||||
MSI_DIRENT *msi_dirent_new(MSI_FILE *msi, MSI_ENTRY *entry, MSI_DIRENT *parent)
|
||||
/* Recursively create a tree of MSI_DIRENT structures */
|
||||
int msi_dirent_new(MSI_FILE *msi, MSI_ENTRY *entry, MSI_DIRENT *parent, MSI_DIRENT **ret)
|
||||
{
|
||||
MSI_DIRENT *dirent;
|
||||
static int cnt;
|
||||
static MSI_DIRENT *tortoise, *hare;
|
||||
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
return 1; /* OK */
|
||||
}
|
||||
if (entry->nameLen == 0 || entry->nameLen > 64) {
|
||||
printf("Corrupted Directory Entry Name Length\n");
|
||||
return 0; /* FAILED */
|
||||
}
|
||||
/* detect cycles in previously visited entries (parents, siblings) */
|
||||
if (!ret) { /* initialized (non-root entry) */
|
||||
if ((entry->leftSiblingID != NOSTREAM && tortoise->entry->leftSiblingID == entry->leftSiblingID)
|
||||
|| (entry->rightSiblingID != NOSTREAM && tortoise->entry->rightSiblingID == entry->rightSiblingID)
|
||||
|| (entry->childID != NOSTREAM && tortoise->entry->childID == entry->childID)) {
|
||||
printf("MSI_ENTRY cycle detected at level %d\n", cnt);
|
||||
OPENSSL_free(entry);
|
||||
return 0; /* FAILED */
|
||||
}
|
||||
}
|
||||
|
||||
dirent = (MSI_DIRENT *)OPENSSL_malloc(sizeof(MSI_DIRENT));
|
||||
memcpy(dirent->name, entry->name, entry->nameLen);
|
||||
dirent->nameLen = entry->nameLen;
|
||||
dirent->type = entry->type;
|
||||
dirent->entry = entry;
|
||||
dirent->children = sk_MSI_DIRENT_new_null();
|
||||
dirent->next = NULL; /* fail-safe */
|
||||
|
||||
if (parent != NULL) {
|
||||
sk_MSI_DIRENT_push(parent->children, dirent);
|
||||
/* Floyd's cycle-finding algorithm */
|
||||
if (!ret) { /* initialized (non-root entry) */
|
||||
if (cnt++ & 1) /* move the tortoise every other invocation of msi_dirent_new() */
|
||||
tortoise = tortoise->next;
|
||||
hare->next = dirent; /* build a linked list of visited entries */
|
||||
hare = dirent; /* move the hare every time */
|
||||
} else { /* initialization needed (root entry) */
|
||||
cnt = 0;
|
||||
tortoise = dirent;
|
||||
hare = dirent;
|
||||
}
|
||||
/* NOTE : These links are a tree, not a linked list */
|
||||
msi_dirent_new(msi, get_entry(msi, entry->leftSiblingID), parent);
|
||||
msi_dirent_new(msi, get_entry(msi, entry->rightSiblingID), parent);
|
||||
|
||||
if (entry->type != DIR_STREAM) {
|
||||
msi_dirent_new(msi, get_entry(msi, entry->childID), dirent);
|
||||
if (parent && !sk_MSI_DIRENT_push(parent->children, dirent)) {
|
||||
printf("Failed to insert MSI_DIRENT\n");
|
||||
return 0; /* FAILED */
|
||||
}
|
||||
return dirent;
|
||||
|
||||
if (ret)
|
||||
*ret = dirent;
|
||||
|
||||
if (!recurse_entry(msi, entry->leftSiblingID, parent)
|
||||
|| !recurse_entry(msi, entry->rightSiblingID, parent)
|
||||
|| !recurse_entry(msi, entry->childID, dirent)) {
|
||||
printf("Failed to add a sibling or a child to the tree\n");
|
||||
return 0; /* FAILED */
|
||||
}
|
||||
|
||||
return 1; /* OK */
|
||||
}
|
||||
|
||||
/* Add a sibling or a child to the tree */
|
||||
/* NOTE: These links are a tree, not a linked list */
|
||||
static int recurse_entry(MSI_FILE *msi, uint32_t entryID, MSI_DIRENT *parent)
|
||||
{
|
||||
MSI_ENTRY *node;
|
||||
|
||||
/* The special NOSTREAM (0xFFFFFFFF) value is used as a terminator */
|
||||
if (entryID == NOSTREAM) /* stop condition */
|
||||
return 1; /* OK */
|
||||
|
||||
node = get_entry(msi, entryID, FALSE);
|
||||
if (!node) {
|
||||
printf("Corrupted ID: 0x%08X\n", entryID);
|
||||
return 0; /* FAILED */
|
||||
}
|
||||
|
||||
if (!msi_dirent_new(msi, node, parent, NULL)) {
|
||||
return 0; /* FAILED */
|
||||
}
|
||||
|
||||
return 1; /* OK */
|
||||
}
|
||||
|
||||
/* Return DigitalSignature and MsiDigitalSignatureEx */
|
||||
@ -456,14 +687,16 @@ int msi_hash_dir(MSI_FILE *msi, MSI_DIRENT *dirent, BIO *hash, int is_root)
|
||||
}
|
||||
indata = (char *)OPENSSL_malloc(inlen);
|
||||
if (!msi_file_read(msi, child->entry, 0, indata, inlen)) {
|
||||
printf("Read stream data error\n\n");
|
||||
printf("Failed to read stream data\n");
|
||||
OPENSSL_free(indata);
|
||||
goto out;
|
||||
}
|
||||
BIO_write(hash, indata, inlen);
|
||||
BIO_write(hash, indata, (int)inlen);
|
||||
OPENSSL_free(indata);
|
||||
}
|
||||
if (child->type == DIR_STORAGE) {
|
||||
if (!msi_hash_dir(msi, child, hash, 0)) {
|
||||
printf("Failed to hash a MSI storage\n");
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
@ -476,15 +709,18 @@ out:
|
||||
}
|
||||
|
||||
/* Compute a simple sha1/sha256 message digest of the MSI file */
|
||||
void msi_calc_digest(char *indata, const EVP_MD *md, u_char *mdbuf, size_t fileend)
|
||||
int msi_calc_digest(char *indata, int mdtype, u_char *mdbuf, uint32_t fileend)
|
||||
{
|
||||
BIO *bio = NULL;
|
||||
EVP_MD_CTX *mdctx;
|
||||
size_t n;
|
||||
uint32_t n;
|
||||
int ret = 0;
|
||||
const EVP_MD *md = EVP_get_digestbynid(mdtype);
|
||||
BIO *bio = BIO_new_mem_buf(indata, (int)fileend);
|
||||
EVP_MD_CTX *mdctx = EVP_MD_CTX_new();
|
||||
|
||||
bio = BIO_new_mem_buf(indata, fileend);
|
||||
mdctx = EVP_MD_CTX_new();
|
||||
EVP_DigestInit(mdctx, md);
|
||||
if (!EVP_DigestInit(mdctx, md)) {
|
||||
printf("Unable to set up the digest context\n");
|
||||
goto out;
|
||||
}
|
||||
memset(mdbuf, 0, EVP_MAX_MD_SIZE);
|
||||
(void)BIO_seek(bio, 0);
|
||||
|
||||
@ -492,48 +728,51 @@ void msi_calc_digest(char *indata, const EVP_MD *md, u_char *mdbuf, size_t filee
|
||||
while (n < fileend) {
|
||||
int l;
|
||||
static u_char bfb[16*1024*1024];
|
||||
size_t want = fileend - n;
|
||||
uint32_t want = fileend - n;
|
||||
if (want > sizeof bfb)
|
||||
want = sizeof bfb;
|
||||
l = BIO_read(bio, bfb, want);
|
||||
l = BIO_read(bio, bfb, (int)want);
|
||||
if (l <= 0)
|
||||
break;
|
||||
EVP_DigestUpdate(mdctx, bfb, l);
|
||||
n += l;
|
||||
EVP_DigestUpdate(mdctx, bfb, (size_t)l);
|
||||
n += (uint32_t)l;
|
||||
}
|
||||
EVP_DigestFinal(mdctx, mdbuf, NULL);
|
||||
ret = 1; /* OK */
|
||||
out:
|
||||
EVP_MD_CTX_free(mdctx);
|
||||
BIO_free(bio);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void ministream_append(MSI_OUT *out, char *buf, int len)
|
||||
static void ministream_append(MSI_OUT *out, char *buf, uint32_t len)
|
||||
{
|
||||
int needSectors = (len + out->sectorSize - 1) / out->sectorSize;
|
||||
uint32_t needSectors = (len + out->sectorSize - 1) / out->sectorSize;
|
||||
if (out->miniStreamLen + len >= out->ministreamsMemallocCount * out->sectorSize) {
|
||||
out->ministreamsMemallocCount += needSectors;
|
||||
out->ministream = OPENSSL_realloc(out->ministream, out->ministreamsMemallocCount * out->sectorSize);
|
||||
out->ministream = OPENSSL_realloc(out->ministream, (size_t)(out->ministreamsMemallocCount * out->sectorSize));
|
||||
}
|
||||
memcpy(out->ministream + out->miniStreamLen, buf, len);
|
||||
memcpy(out->ministream + out->miniStreamLen, buf, (size_t)len);
|
||||
out->miniStreamLen += len;
|
||||
}
|
||||
|
||||
static void minifat_append(MSI_OUT *out, char *buf, int len)
|
||||
static void minifat_append(MSI_OUT *out, char *buf, uint32_t len)
|
||||
{
|
||||
if (out->minifatLen == out->minifatMemallocCount * out->sectorSize) {
|
||||
out->minifatMemallocCount += 1;
|
||||
out->minifat = OPENSSL_realloc(out->minifat, out->minifatMemallocCount * out->sectorSize);
|
||||
out->minifat = OPENSSL_realloc(out->minifat, (size_t)(out->minifatMemallocCount * out->sectorSize));
|
||||
}
|
||||
memcpy(out->minifat + out->minifatLen, buf, len);
|
||||
memcpy(out->minifat + out->minifatLen, buf, (size_t)len);
|
||||
out->minifatLen += len;
|
||||
}
|
||||
|
||||
static void fat_append(MSI_OUT *out, char *buf, int len)
|
||||
static void fat_append(MSI_OUT *out, char *buf, uint32_t len)
|
||||
{
|
||||
if (out->fatLen == out->fatMemallocCount * out->sectorSize) {
|
||||
out->fatMemallocCount += 1;
|
||||
out->fat = OPENSSL_realloc(out->fat, out->fatMemallocCount * out->sectorSize);
|
||||
out->fat = OPENSSL_realloc(out->fat, (size_t)(out->fatMemallocCount * out->sectorSize));
|
||||
}
|
||||
memcpy(out->fat + out->fatLen, buf, len);
|
||||
memcpy(out->fat + out->fatLen, buf, (size_t)len);
|
||||
out->fatLen += len;
|
||||
}
|
||||
|
||||
@ -598,7 +837,7 @@ static int dirent_insert(MSI_DIRENT *dirent, const u_char *name, uint16_t nameLe
|
||||
return 1; /* OK */
|
||||
}
|
||||
|
||||
static int signature_insert(MSI_DIRENT *dirent, int len_msiex)
|
||||
static int signature_insert(MSI_DIRENT *dirent, uint32_t len_msiex)
|
||||
{
|
||||
if (len_msiex > 0) {
|
||||
if (!dirent_insert(dirent, digital_signature_ex, sizeof digital_signature_ex)) {
|
||||
@ -615,8 +854,8 @@ static int signature_insert(MSI_DIRENT *dirent, int len_msiex)
|
||||
return 1; /* OK */
|
||||
}
|
||||
|
||||
static int stream_read(MSI_FILE *msi, MSI_ENTRY *entry, u_char *p_msi, int len_msi,
|
||||
u_char *p_msiex, int len_msiex, char **indata, int inlen, int is_root)
|
||||
static uint32_t stream_read(MSI_FILE *msi, MSI_ENTRY *entry, u_char *p_msi, uint32_t len_msi,
|
||||
u_char *p_msiex, uint32_t len_msiex, char **indata, uint32_t inlen, int is_root)
|
||||
{
|
||||
if (is_root && !memcmp(entry->name, digital_signature, sizeof digital_signature)) {
|
||||
*indata = (char *)p_msi;
|
||||
@ -626,7 +865,7 @@ static int stream_read(MSI_FILE *msi, MSI_ENTRY *entry, u_char *p_msi, int len_m
|
||||
inlen = len_msiex;
|
||||
} else {
|
||||
if (!msi_file_read(msi, entry, 0, *indata, inlen)) {
|
||||
printf("Read stream data error\n");
|
||||
printf("Failed to read stream data\n");
|
||||
return 0; /* FAILED */
|
||||
}
|
||||
}
|
||||
@ -634,8 +873,8 @@ static int stream_read(MSI_FILE *msi, MSI_ENTRY *entry, u_char *p_msi, int len_m
|
||||
}
|
||||
|
||||
/* Recursively handle data from MSI_DIRENT struct */
|
||||
static int stream_handle(MSI_FILE *msi, MSI_DIRENT *dirent, u_char *p_msi, int len_msi,
|
||||
u_char *p_msiex, int len_msiex, BIO *outdata, MSI_OUT *out, int is_root)
|
||||
static int stream_handle(MSI_FILE *msi, MSI_DIRENT *dirent, u_char *p_msi, uint32_t len_msi,
|
||||
u_char *p_msiex, uint32_t len_msiex, BIO *outdata, MSI_OUT *out, int is_root)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -665,15 +904,15 @@ static int stream_handle(MSI_FILE *msi, MSI_DIRENT *dirent, u_char *p_msi, int l
|
||||
/* set the size of the user-defined data if this is a stream object */
|
||||
PUT_UINT32_LE(inlen, buf);
|
||||
memcpy(child->entry->size, buf, sizeof child->entry->size);
|
||||
|
||||
|
||||
if (inlen < MINI_STREAM_CUTOFF_SIZE) {
|
||||
/* set the index into the mini FAT to track the chain of sectors through the mini stream */
|
||||
child->entry->startSectorLocation = out->miniSectorNum;
|
||||
ministream_append(out, indata, inlen);
|
||||
/* fill to the end with known data, such as all zeroes */
|
||||
if (inlen % msi->m_minisectorSize > 0) {
|
||||
int remain = msi->m_minisectorSize - inlen % msi->m_minisectorSize;
|
||||
memset(buf, 0, remain);
|
||||
uint32_t remain = msi->m_minisectorSize - inlen % msi->m_minisectorSize;
|
||||
memset(buf, 0, (size_t)remain);
|
||||
ministream_append(out, buf, remain);
|
||||
}
|
||||
while (inlen > msi->m_minisectorSize) {
|
||||
@ -689,12 +928,12 @@ static int stream_handle(MSI_FILE *msi, MSI_DIRENT *dirent, u_char *p_msi, int l
|
||||
/* set the first sector location if this is a stream object */
|
||||
child->entry->startSectorLocation = out->sectorNum;
|
||||
/* stream save */
|
||||
BIO_write(outdata, indata, inlen);
|
||||
BIO_write(outdata, indata, (int)inlen);
|
||||
/* fill to the end with known data, such as all zeroes */
|
||||
if (inlen % out->sectorSize > 0) {
|
||||
int remain = out->sectorSize - inlen % out->sectorSize;
|
||||
memset(buf, 0, remain);
|
||||
BIO_write(outdata, buf, remain);
|
||||
uint32_t remain = out->sectorSize - inlen % out->sectorSize;
|
||||
memset(buf, 0, (size_t)remain);
|
||||
BIO_write(outdata, buf, (int)remain);
|
||||
}
|
||||
/* set a sector chain in the FAT */
|
||||
while (inlen > out->sectorSize) {
|
||||
@ -716,19 +955,19 @@ static int stream_handle(MSI_FILE *msi, MSI_DIRENT *dirent, u_char *p_msi, int l
|
||||
static void ministream_save(MSI_DIRENT *dirent, BIO *outdata, MSI_OUT *out)
|
||||
{
|
||||
char buf[MAX_SECTOR_SIZE];
|
||||
int remain, i;
|
||||
int ministreamSectorsCount = (out->miniStreamLen + out->sectorSize - 1) / out->sectorSize;
|
||||
uint32_t i, remain;
|
||||
uint32_t ministreamSectorsCount = (out->miniStreamLen + out->sectorSize - 1) / out->sectorSize;
|
||||
|
||||
/* set the first sector of the mini stream in the entry root object */
|
||||
dirent->entry->startSectorLocation = out->sectorNum;
|
||||
/* ministream save */
|
||||
BIO_write(outdata, out->ministream, out->miniStreamLen);
|
||||
BIO_write(outdata, out->ministream, (int)out->miniStreamLen);
|
||||
OPENSSL_free(out->ministream);
|
||||
/* fill to the end with known data, such as all zeroes */
|
||||
if (out->miniStreamLen % out->sectorSize > 0) {
|
||||
remain = out->sectorSize - out->miniStreamLen % out->sectorSize;
|
||||
memset(buf, 0, remain);
|
||||
BIO_write(outdata, buf, remain);
|
||||
memset(buf, 0, (size_t)remain);
|
||||
BIO_write(outdata, buf, (int)remain);
|
||||
}
|
||||
/* set a sector chain in the FAT */
|
||||
for (i=1; i<ministreamSectorsCount; i++) {
|
||||
@ -745,8 +984,8 @@ static void ministream_save(MSI_DIRENT *dirent, BIO *outdata, MSI_OUT *out)
|
||||
static void minifat_save(BIO *outdata, MSI_OUT *out)
|
||||
{
|
||||
char buf[MAX_SECTOR_SIZE];
|
||||
int i,remain;
|
||||
|
||||
uint32_t i, remain;
|
||||
|
||||
/* set Mini FAT Starting Sector Location in the header */
|
||||
if (out->minifatLen == 0) {
|
||||
PUT_UINT32_LE(ENDOFCHAIN, buf);
|
||||
@ -756,7 +995,7 @@ static void minifat_save(BIO *outdata, MSI_OUT *out)
|
||||
PUT_UINT32_LE(out->sectorNum, buf);
|
||||
memcpy(out->header + HEADER_MINI_FAT_SECTOR_LOC, buf, 4);
|
||||
/* minifat save */
|
||||
BIO_write(outdata, out->minifat, out->minifatLen);
|
||||
BIO_write(outdata, out->minifat, (int)out->minifatLen);
|
||||
/* marks the end of the stream */
|
||||
PUT_UINT32_LE(ENDOFCHAIN, buf);
|
||||
BIO_write(outdata, buf, 4);
|
||||
@ -764,8 +1003,8 @@ static void minifat_save(BIO *outdata, MSI_OUT *out)
|
||||
/* empty unallocated free sectors in the last Mini FAT sector */
|
||||
if (out->minifatLen % out->sectorSize > 0) {
|
||||
remain = out->sectorSize - out->minifatLen % out->sectorSize;
|
||||
memset(buf, FREESECT, remain);
|
||||
BIO_write(outdata, buf, remain);
|
||||
memset(buf, (int)FREESECT, (size_t)remain);
|
||||
BIO_write(outdata, buf, (int)remain);
|
||||
}
|
||||
/* set a sector chain in the FAT */
|
||||
out->minifatSectorsCount = (out->minifatLen + out->sectorSize - 1) / out->sectorSize;
|
||||
@ -820,13 +1059,13 @@ static char *msi_unused_dirent_get()
|
||||
/* initialise 127 bytes */
|
||||
memset(data, 0, DIRENT_SIZE);
|
||||
|
||||
memset(data + DIRENT_LEFT_SIBLING_ID, NOSTREAM, 4);
|
||||
memset(data + DIRENT_RIGHT_SIBLING_ID, NOSTREAM, 4);
|
||||
memset(data + DIRENT_CHILD_ID, NOSTREAM, 4);
|
||||
memset(data + DIRENT_LEFT_SIBLING_ID, (int)NOSTREAM, 4);
|
||||
memset(data + DIRENT_RIGHT_SIBLING_ID, (int)NOSTREAM, 4);
|
||||
memset(data + DIRENT_CHILD_ID, (int)NOSTREAM, 4);
|
||||
return data;
|
||||
}
|
||||
|
||||
static int dirents_save(MSI_DIRENT *dirent, BIO *outdata, MSI_OUT *out, int *streamId, int count, int last)
|
||||
static int dirents_save(MSI_DIRENT *dirent, BIO *outdata, MSI_OUT *out, uint32_t *streamId, int count, int last)
|
||||
{
|
||||
int i, childenNum;
|
||||
char *entry;
|
||||
@ -844,27 +1083,27 @@ static int dirents_save(MSI_DIRENT *dirent, BIO *outdata, MSI_OUT *out, int *str
|
||||
} else {
|
||||
/* make linked list rather than tree, only use next - right sibling */
|
||||
count += childenNum;
|
||||
dirent->entry->rightSiblingID = *streamId + count + 1;
|
||||
dirent->entry->rightSiblingID = *streamId + (uint32_t)count + 1;
|
||||
}
|
||||
} else { /* DIR_ROOT */
|
||||
dirent->entry->rightSiblingID = NOSTREAM;
|
||||
}
|
||||
dirent->entry->childID = *streamId + 1;
|
||||
dirent->entry->childID = *streamId + 1;
|
||||
entry = msi_dirent_get(dirent->entry);
|
||||
BIO_write(outdata, entry, DIRENT_SIZE);
|
||||
OPENSSL_free(entry);
|
||||
out->dirtreeLen += DIRENT_SIZE;
|
||||
for (i = 0; i < childenNum; i++) {
|
||||
MSI_DIRENT *child = sk_MSI_DIRENT_value(children, i);
|
||||
int last = i == childenNum - 1 ? 1 : 0;
|
||||
int last_dir = i == childenNum - 1 ? 1 : 0;
|
||||
*streamId += 1;
|
||||
if (child->type == DIR_STORAGE) {
|
||||
count += dirents_save(child, outdata, out, streamId, count, last);
|
||||
count += dirents_save(child, outdata, out, streamId, count, last_dir);
|
||||
} else { /* DIR_STREAM */
|
||||
count = 0;
|
||||
child->entry->colorFlag = BLACK_COLOR;
|
||||
child->entry->leftSiblingID = NOSTREAM;
|
||||
if (last) {
|
||||
if (last_dir) {
|
||||
child->entry->rightSiblingID = NOSTREAM;
|
||||
} else {
|
||||
child->entry->rightSiblingID = *streamId + 1;
|
||||
@ -883,8 +1122,7 @@ static void dirtree_save(MSI_DIRENT *dirent, BIO *outdata, MSI_OUT *out)
|
||||
{
|
||||
char buf[MAX_SECTOR_SIZE];
|
||||
char *unused_entry;
|
||||
int i, remain;
|
||||
int streamId = 0;
|
||||
uint32_t i, remain, streamId = 0;
|
||||
|
||||
/* set Directory Starting Sector Location in the header */
|
||||
PUT_UINT32_LE(out->sectorNum, buf);
|
||||
@ -923,8 +1161,8 @@ static void dirtree_save(MSI_DIRENT *dirent, BIO *outdata, MSI_OUT *out)
|
||||
static int fat_save(BIO *outdata, MSI_OUT *out)
|
||||
{
|
||||
char buf[MAX_SECTOR_SIZE];
|
||||
int i, remain;
|
||||
|
||||
uint32_t i, remain;
|
||||
|
||||
remain = (out->fatLen + out->sectorSize - 1) / out->sectorSize;
|
||||
out->fatSectorsCount = (out->fatLen + remain * 4 + out->sectorSize - 1) / out->sectorSize;
|
||||
|
||||
@ -948,17 +1186,17 @@ static int fat_save(BIO *outdata, MSI_OUT *out)
|
||||
/* empty unallocated free sectors in the last FAT sector */
|
||||
if (out->fatLen % out->sectorSize > 0) {
|
||||
remain = out->sectorSize - out->fatLen % out->sectorSize;
|
||||
memset(buf, FREESECT, remain);
|
||||
memset(buf, (int)FREESECT, (size_t)remain);
|
||||
fat_append(out, buf, remain);
|
||||
}
|
||||
BIO_write(outdata, out->fat, out->fatLen);
|
||||
BIO_write(outdata, out->fat, (int)out->fatLen);
|
||||
return 1; /* OK */
|
||||
}
|
||||
|
||||
static void header_save(BIO *outdata, MSI_OUT *out)
|
||||
{
|
||||
char buf[MAX_SECTOR_SIZE];
|
||||
int remain;
|
||||
uint32_t remain;
|
||||
|
||||
/* set Number of FAT sectors in the header */
|
||||
PUT_UINT32_LE(out->fatSectorsCount, buf);
|
||||
@ -977,8 +1215,8 @@ static void header_save(BIO *outdata, MSI_OUT *out)
|
||||
BIO_write(outdata, out->header, HEADER_SIZE);
|
||||
|
||||
remain = out->sectorSize - HEADER_SIZE;
|
||||
memset(buf, 0, remain);
|
||||
BIO_write(outdata, buf, remain);
|
||||
memset(buf, 0, (size_t)remain);
|
||||
BIO_write(outdata, buf, (int)remain);
|
||||
}
|
||||
|
||||
static char *header_new(MSI_FILE_HDR *hdr, MSI_OUT *out)
|
||||
@ -1002,7 +1240,7 @@ static char *header_new(MSI_FILE_HDR *hdr, MSI_OUT *out)
|
||||
} else {
|
||||
PUT_UINT16_LE(0x0003, buf);
|
||||
}
|
||||
memcpy(data + HEADER_MAJOR_VER, buf, 2);
|
||||
memcpy(data + HEADER_MAJOR_VER, buf, 2);
|
||||
PUT_UINT16_LE(hdr->byteOrder, buf);
|
||||
memcpy(data + HEADER_BYTE_ORDER, buf, 2);
|
||||
PUT_UINT16_LE(hdr->sectorShift, buf);
|
||||
@ -1028,15 +1266,14 @@ static char *header_new(MSI_FILE_HDR *hdr, MSI_OUT *out)
|
||||
memset(data + HEADER_DIFAT_SECTORS_NUM, 0, 4); /* no DIFAT */
|
||||
memcpy(data + HEADER_DIFAT, dead_food, 4); /* sector number for FAT */
|
||||
for (i = 1; i < DIFAT_IN_HEADER; i++) {
|
||||
memset(data + HEADER_DIFAT + 4*i, FREESECT, 4); /* free FAT sectors */
|
||||
memset(data + HEADER_DIFAT + 4*i, (int)FREESECT, 4); /* free FAT sectors */
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
static int msiout_set(MSI_FILE *msi, int len_msi, int len_msiex, MSI_OUT *out)
|
||||
static int msiout_set(MSI_FILE *msi, uint32_t len_msi, uint32_t len_msiex, MSI_OUT *out)
|
||||
{
|
||||
MSI_FILE_HDR *hdr = msi_header_get(msi);
|
||||
int msi_size, msiex_size;
|
||||
uint32_t msi_size, msiex_size;
|
||||
|
||||
out->sectorSize = msi->m_sectorSize;
|
||||
|
||||
@ -1057,9 +1294,9 @@ static int msiout_set(MSI_FILE *msi, int len_msi, int len_msiex, MSI_OUT *out)
|
||||
printf("DIFAT sectors are not supported\n");
|
||||
return 0;/* FAILED */
|
||||
}
|
||||
out->header = header_new(hdr, out);
|
||||
out->minifatMemallocCount = hdr->numMiniFATSector;
|
||||
out->fatMemallocCount = hdr->numFATSector;
|
||||
out->header = header_new(msi->m_hdr, out);
|
||||
out->minifatMemallocCount = msi->m_hdr->numMiniFATSector;
|
||||
out->fatMemallocCount = msi->m_hdr->numFATSector;
|
||||
out->ministream = NULL;
|
||||
out->minifat = OPENSSL_malloc(out->minifatMemallocCount * out->sectorSize);
|
||||
out->fat = OPENSSL_malloc(out->fatMemallocCount * out->sectorSize);
|
||||
@ -1068,13 +1305,13 @@ static int msiout_set(MSI_FILE *msi, int len_msi, int len_msiex, MSI_OUT *out)
|
||||
return 1; /* OK */
|
||||
}
|
||||
|
||||
int msi_file_write(MSI_FILE *msi, MSI_DIRENT *dirent, u_char *p_msi, int len_msi,
|
||||
u_char *p_msiex, int len_msiex, BIO *outdata)
|
||||
int msi_file_write(MSI_FILE *msi, MSI_DIRENT *dirent, u_char *p_msi, uint32_t len_msi,
|
||||
u_char *p_msiex, uint32_t len_msiex, BIO *outdata)
|
||||
{
|
||||
MSI_OUT out;
|
||||
int ret = 0;
|
||||
|
||||
memset(&out, 0, sizeof(MSI_OUT));
|
||||
memset(&out, 0, sizeof(MSI_OUT));
|
||||
if (!msiout_set(msi, len_msi, len_msiex, &out)) {
|
||||
goto out; /* FAILED */
|
||||
}
|
||||
@ -1097,3 +1334,13 @@ out:
|
||||
OPENSSL_free(out.minifat);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
indent-tabs-mode: t
|
||||
End:
|
||||
|
||||
vim: set ts=4 noexpandtab:
|
||||
*/
|
||||
|
104
msi.h
104
msi.h
@ -72,25 +72,36 @@
|
||||
#define DIRENT_START_SECTOR_LOC 0x74
|
||||
#define DIRENT_FILE_SIZE 0x78
|
||||
|
||||
#define GET_UINT8_LE(p) ((u_char*)(p))[0]
|
||||
#define GET_UINT8_LE(p) ((const u_char *)(p))[0]
|
||||
|
||||
#define GET_UINT16_LE(p) (((u_char*)(p))[0] | (((u_char*)(p))[1]<<8))
|
||||
#define GET_UINT16_LE(p) (uint16_t)(((const u_char *)(p))[0] | \
|
||||
(((const u_char *)(p))[1] << 8))
|
||||
|
||||
#define GET_UINT32_LE(p) (((u_char*)(p))[0] | (((u_char*)(p))[1]<<8) | \
|
||||
(((u_char*)(p))[2]<<16) | (((u_char*)(p))[3]<<24))
|
||||
#define GET_UINT32_LE(p) (uint32_t)(((const u_char *)(p))[0] | \
|
||||
(((const u_char *)(p))[1] << 8) | \
|
||||
(((const u_char *)(p))[2] << 16) | \
|
||||
(((const u_char *)(p))[3] << 24))
|
||||
|
||||
#define PUT_UINT8_LE(i,p) \
|
||||
((u_char*)(p))[0] = (i) & 0xff;
|
||||
|
||||
#define PUT_UINT16_LE(i,p) \
|
||||
((u_char*)(p))[0] = (i) & 0xff; \
|
||||
((u_char*)(p))[1] = ((i)>>8) & 0xff
|
||||
#define PUT_UINT8_LE(i, p) ((u_char *)(p))[0] = (u_char)((i) & 0xff);
|
||||
|
||||
#define PUT_UINT32_LE(i,p) \
|
||||
((u_char*)(p))[0] = (i) & 0xff; \
|
||||
((u_char*)(p))[1] = ((i)>>8) & 0xff; \
|
||||
((u_char*)(p))[2] = ((i)>>16) & 0xff; \
|
||||
((u_char*)(p))[3] = ((i)>>24) & 0xff
|
||||
#define PUT_UINT16_LE(i,p) ((u_char *)(p))[0] = (u_char)((i) & 0xff); \
|
||||
((u_char *)(p))[1] = (u_char)(((i) >> 8) & 0xff)
|
||||
|
||||
#define PUT_UINT32_LE(i,p) ((u_char *)(p))[0] = (u_char)((i) & 0xff); \
|
||||
((u_char *)(p))[1] = (u_char)(((i) >> 8) & 0xff); \
|
||||
((u_char *)(p))[2] = (u_char)(((i) >> 16) & 0xff); \
|
||||
((u_char *)(p))[3] = (u_char)(((i) >> 24) & 0xff)
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#define SIZE_64K 65536 /* 2^16 */
|
||||
#define SIZE_16M 16777216 /* 2^24 */
|
||||
|
||||
typedef unsigned char u_char;
|
||||
|
||||
@ -131,23 +142,24 @@ typedef struct {
|
||||
u_char size[8];
|
||||
} MSI_ENTRY;
|
||||
|
||||
typedef struct {
|
||||
typedef struct msi_dirent_struct {
|
||||
u_char name[DIRENT_MAX_NAME_SIZE];
|
||||
uint16_t nameLen;
|
||||
uint8_t type;
|
||||
MSI_ENTRY *entry;
|
||||
STACK_OF(MSI_DIRENT) *children;
|
||||
struct msi_dirent_struct *next; /* for cycle detection */
|
||||
} MSI_DIRENT;
|
||||
|
||||
DEFINE_STACK_OF(MSI_DIRENT)
|
||||
|
||||
typedef struct {
|
||||
const u_char *m_buffer;
|
||||
size_t m_bufferLen;
|
||||
uint32_t m_bufferLen;
|
||||
MSI_FILE_HDR *m_hdr;
|
||||
size_t m_sectorSize;
|
||||
size_t m_minisectorSize;
|
||||
size_t m_miniStreamStartSector;
|
||||
uint32_t m_sectorSize;
|
||||
uint32_t m_minisectorSize;
|
||||
uint32_t m_miniStreamStartSector;
|
||||
} MSI_FILE;
|
||||
|
||||
typedef struct {
|
||||
@ -159,18 +171,18 @@ typedef struct {
|
||||
uint32_t miniStreamLen;
|
||||
uint32_t minifatLen;
|
||||
uint32_t fatLen;
|
||||
int ministreamsMemallocCount;
|
||||
int minifatMemallocCount;
|
||||
int fatMemallocCount;
|
||||
int dirtreeSectorsCount;
|
||||
int minifatSectorsCount;
|
||||
int fatSectorsCount;
|
||||
int miniSectorNum;
|
||||
int sectorNum;
|
||||
size_t sectorSize;
|
||||
uint32_t ministreamsMemallocCount;
|
||||
uint32_t minifatMemallocCount;
|
||||
uint32_t fatMemallocCount;
|
||||
uint32_t dirtreeSectorsCount;
|
||||
uint32_t minifatSectorsCount;
|
||||
uint32_t fatSectorsCount;
|
||||
uint32_t miniSectorNum;
|
||||
uint32_t sectorNum;
|
||||
uint32_t sectorSize;
|
||||
} MSI_OUT;
|
||||
|
||||
static u_char msi_magic[] = {
|
||||
static const u_char msi_magic[] = {
|
||||
0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1
|
||||
};
|
||||
|
||||
@ -191,16 +203,36 @@ static const u_char digital_signature_ex[] = {
|
||||
0x45, 0x00, 0x78, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
int msi_file_read(MSI_FILE *msi, MSI_ENTRY *entry, size_t offset, char *buffer, size_t len);
|
||||
MSI_FILE *msi_file_new(char *buffer, size_t len);
|
||||
static const u_char msi_root_entry[] = {
|
||||
0x52, 0x00, 0x6F, 0x00, 0x6F, 0x00, 0x74, 0x00,
|
||||
0x20, 0x00, 0x45, 0x00, 0x6E, 0x00, 0x74, 0x00,
|
||||
0x72, 0x00, 0x79, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
static const u_char msi_zeroes[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
int msi_file_read(MSI_FILE *msi, MSI_ENTRY *entry, uint32_t offset, char *buffer, uint32_t len);
|
||||
MSI_FILE *msi_file_new(char *buffer, uint32_t len);
|
||||
void msi_file_free(MSI_FILE *msi);
|
||||
MSI_ENTRY *msi_root_entry_get(MSI_FILE *msi);
|
||||
MSI_DIRENT *msi_dirent_new(MSI_FILE *msi, MSI_ENTRY *entry, MSI_DIRENT *parent);
|
||||
int msi_dirent_new(MSI_FILE *msi, MSI_ENTRY *entry, MSI_DIRENT *parent, MSI_DIRENT **ret);
|
||||
MSI_ENTRY *msi_signatures_get(MSI_DIRENT *dirent, MSI_ENTRY **dse);
|
||||
void msi_dirent_free(MSI_DIRENT *dirent);
|
||||
MSI_FILE_HDR *msi_header_get(MSI_FILE *msi);
|
||||
int msi_prehash_dir(MSI_DIRENT *dirent, BIO *hash, int is_root);
|
||||
int msi_hash_dir(MSI_FILE *msi, MSI_DIRENT *dirent, BIO *hash, int is_root);
|
||||
void msi_calc_digest(char *indata, const EVP_MD *md, u_char *mdbuf, size_t fileend);
|
||||
int msi_calc_digest(char *indata, int mdtype, u_char *mdbuf, uint32_t fileend);
|
||||
int msi_dirent_delete(MSI_DIRENT *dirent, const u_char *name, uint16_t nameLen);
|
||||
int msi_file_write(MSI_FILE *msi, MSI_DIRENT *dirent, u_char *p, int len, u_char *p_msiex, int len_msiex, BIO *outdata);
|
||||
int msi_file_write(MSI_FILE *msi, MSI_DIRENT *dirent, u_char *p, uint32_t len,
|
||||
u_char *p_msiex, uint32_t len_msiex, BIO *outdata);
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
indent-tabs-mode: t
|
||||
End:
|
||||
|
||||
vim: set ts=4 noexpandtab:
|
||||
*/
|
||||
|
76
osslsigncode.bash
Normal file
76
osslsigncode.bash
Normal file
@ -0,0 +1,76 @@
|
||||
# bash completion for osslsigncode -*- shell-script -*-
|
||||
# Copyright (C) 2021-2022 Michał Trojnara <Michal.Trojnara@stunnel.org>
|
||||
# Author: Małgorzata Olszówka <Malgorzata.Olszowka@stunnel.org>
|
||||
|
||||
bind 'set show-all-if-ambiguous on'
|
||||
bind 'set completion-ignore-case on'
|
||||
COMP_WORDBREAKS=${COMP_WORDBREAKS//:}
|
||||
|
||||
_comp_cmd_osslsigncode()
|
||||
{
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
local commands command options timestamps rfc3161
|
||||
|
||||
commands="--help --version -v
|
||||
sign add attach-signature extract-signature remove-signature verify"
|
||||
|
||||
timestamps="http://timestamp.digicert.com
|
||||
http://time.certum.pl
|
||||
http://timestamp.sectigo.com
|
||||
http://timestamp.globalsign.com/?signature=sha2"
|
||||
|
||||
rfc3161="http://timestamp.digicert.com
|
||||
http://time.certum.pl
|
||||
http://timestamp.entrust.net/TSS/RFC3161sha2TS
|
||||
http://tss.accv.es:8318/tsa
|
||||
http://kstamp.keynectis.com/KSign/
|
||||
http://sha256timestamp.ws.symantec.com/sha256/timestamp"
|
||||
|
||||
|
||||
if ((cword == 1)); then
|
||||
COMPREPLY=($(compgen -W "${commands}" -- ${cur}))
|
||||
else
|
||||
command=${words[1]}
|
||||
case $prev in
|
||||
-ac | -c | -catalog | -certs | -spc | -key | -pkcs12 | -pass | \
|
||||
-readpass | -pkcs11engine | -pkcs11module | -in | -out | -sigin | \
|
||||
-n | -CAfile | -CRLfile | -TSA-CAfile | -TSA-CRLfile)
|
||||
_filedir
|
||||
return
|
||||
;;
|
||||
-h | -require-leaf-hash)
|
||||
COMPREPLY=($(compgen -W 'md5 sha1 sha2 sha256 sha384 sha512' \
|
||||
-- "$cur"))
|
||||
return
|
||||
;;
|
||||
-jp)
|
||||
COMPREPLY=($(compgen -W 'low medium high' -- "$cur"))
|
||||
return
|
||||
;;
|
||||
-t)
|
||||
COMPREPLY=($(compgen -W "${timestamps}" -- "$cur"))
|
||||
return
|
||||
;;
|
||||
-ts)
|
||||
COMPREPLY=($(compgen -W "${rfc3161}" -- "$cur"))
|
||||
return
|
||||
;;
|
||||
-i | -p)
|
||||
_known_hosts_real -- "$cur"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ $cur == -* ]]; then
|
||||
# possible options for the command
|
||||
options=$(_parse_help "$1" "$command --help" 2>/dev/null)
|
||||
COMPREPLY=($(compgen -W "${options}" -- ${cur}))
|
||||
fi
|
||||
fi
|
||||
|
||||
} &&
|
||||
complete -F _comp_cmd_osslsigncode osslsigncode
|
||||
|
||||
# ex: filetype=sh
|
1508
osslsigncode.c
1508
osslsigncode.c
File diff suppressed because it is too large
Load Diff
7
tests/certs/.gitignore
vendored
7
tests/certs/.gitignore
vendored
@ -1,6 +1 @@
|
||||
*.der
|
||||
*.pem
|
||||
*.pvk
|
||||
*.p12
|
||||
*.spc
|
||||
*.txt
|
||||
*.log
|
||||
|
22
tests/certs/CACert.pem
Normal file
22
tests/certs/CACert.pem
Normal file
@ -0,0 +1,22 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDoTCCAomgAwIBAgIUOK8lwJ8A1Oqw8jDAb3TF06ve+PcwDQYJKoZIhvcNAQEL
|
||||
BQAwWDELMAkGA1UEBhMCUEwxFTATBgNVBAoMDG9zc2xzaWduY29kZTEgMB4GA1UE
|
||||
CwwXQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxEDAOBgNVBAMMB1Jvb3QgQ0EwHhcN
|
||||
MTcwMTAxMDAwMDAwWhcNMjYxMTEwMDAwMDAwWjBYMQswCQYDVQQGEwJQTDEVMBMG
|
||||
A1UECgwMb3NzbHNpZ25jb2RlMSAwHgYDVQQLDBdDZXJ0aWZpY2F0aW9uIEF1dGhv
|
||||
cml0eTEQMA4GA1UEAwwHUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
|
||||
AQoCggEBAKzObJwYq4t9Y/OOQLqUNLU8RDXq284L8zQgRLkvApF87FNN7kozIgC9
|
||||
/HAgJSho/Lup5lzkCWa3fjkYm1EBrL+JihesSaCxxe7LOg6tRaY+WxikwMUnlkNE
|
||||
s3R+DogeGVsla4q0FEcICiz3FHTfSAUVmrN3Nj1ll7npJXrqmXxfCuO3slgjUkHq
|
||||
tdZ5t1rSWwbiUhGIQKLzo3/uw2XoOI28qpoOw+0/y8AyjWs8My3u8GrYFr+qh5fx
|
||||
Y0Zp0EhhAJo23Xd43XmeVKjuKIOaHu3JiM8sp9K1WFsTvFNAO27TBRn/X0mJCeDX
|
||||
T117dQxhWOCcQ/uRGuXICT4ign8MLtUCAwEAAaNjMGEwDwYDVR0TAQH/BAUwAwEB
|
||||
/zAdBgNVHQ4EFgQU6ewx3DIpbR8OptEmDFlYNELRqP4wHwYDVR0jBBgwFoAU6ewx
|
||||
3DIpbR8OptEmDFlYNELRqP4wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUA
|
||||
A4IBAQAhRMun0IzPmHVFM+SOfSCPVAgogWpqR5XlBAFlS+Aen6v3ukQAQjEhfBbE
|
||||
dZG6ye9i0ebf9qXYTvSq5wfaqP7FGb2/Z96uPXNMXPi796KjLW2CG578DitORPb7
|
||||
x1eV3UGrQX2bMQ0JbGkBU+DIdIRBqDfad/kjLtm5eHyCbaodSWdaZO4LSUIy3MBx
|
||||
2UeBj2qD4RTA0Dt7hG7RA5QdTxHlZyLIk8HX3krZ+il5RmSbOnQs/XqK5DJp4J5p
|
||||
122sIO4Y9ki+Wewzx8f3/7mcVbcMo67GwRHo8bk3GjWE74pczyrzfP68vDQ4tn85
|
||||
NcLPeLClfSziJD09z+Iyp94EQeKX
|
||||
-----END CERTIFICATE-----
|
13
tests/certs/CACertCRL.pem
Normal file
13
tests/certs/CACertCRL.pem
Normal file
@ -0,0 +1,13 @@
|
||||
-----BEGIN X509 CRL-----
|
||||
MIIB9zCB4AIBATANBgkqhkiG9w0BAQsFADBgMQswCQYDVQQGEwJQTDEVMBMGA1UE
|
||||
CgwMb3NzbHNpZ25jb2RlMSAwHgYDVQQLDBdDZXJ0aWZpY2F0aW9uIEF1dGhvcml0
|
||||
eTEYMBYGA1UEAwwPSW50ZXJtZWRpYXRlIENBFw0xOTAxMDEwMDAwMDBaFw00MzAx
|
||||
MDEwMDAwMDBaMCcwJQIUOpY5wp7DtqsdxII7sxculedk0PYXDTIyMDcyNjEzMDk1
|
||||
NlqgIzAhMB8GA1UdIwQYMBaAFJ4FrAtb4UB/ag702URPiid97ziLMA0GCSqGSIb3
|
||||
DQEBCwUAA4IBAQA4Kw0vEJrtjjMam16iN/stOMxJDgkp1IQzA3narxr9fEjX5Ynk
|
||||
JztuEExtowPIDOLGWCySXNEMmxCzXNAMvlUq+UQvnWrwgHQ9R7TBYIcAY+VRmzKz
|
||||
T4PXvDSL2WMuJ1dLWoIcL2D0wEdti7YMvAnCrOC8HAPGgke5QcOgSfMSAYSAtpiw
|
||||
PZAFgcuo53AodlCw9J+CPcHPYw+C2QExOy8s8q6d8Xgjg+Ge7v3RxLWy74sNPl0u
|
||||
uZ79vcLNEeqEXxKaw5abqDqIDcUKIT3b62KsSxkak9IGNMLcTASw1V+YaKVLSYNW
|
||||
NTuc5WJblfZi/q7WUMKkmRERzvdg2rf0CSH1
|
||||
-----END X509 CRL-----
|
28
tests/certs/TSA.key
Normal file
28
tests/certs/TSA.key
Normal file
@ -0,0 +1,28 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCivbbTCnbOqPoV
|
||||
7VVP/KJzgslx8yfX9laGwTsvzqStQtG8j40ljR85WD/bgy3I5duebudg7JhOVH2f
|
||||
aSqbh8SCzP4YNDFcseDIuHdoXi54POgW3S/wbe8l8P7g3btcBgnlXh/izhUlEMib
|
||||
Q/8G8UZj0n/MgKMLzcXc4t2eQ4Pzw7xAPqoXBZ20Fg2rFBfUsDDLc5F7lpO5t1WQ
|
||||
dXTYmF0oAL/HLmd+HKe5Xgp9jJ6XacesjWLnhRdZ06uUP9cgo+Jem4QZxeFhOtMe
|
||||
KAf7JH3Juz2Gi0a+4dMSNzES4m8RAlf6pXh4kAh7EhMNb/Ir6ZpY8uKM7dtn38mh
|
||||
1f59EKc9AgMBAAECggEAK5zB0P695hYcpyGqOjxO4LvM9m+eXt7SQ1ynWuF6+j+s
|
||||
62ZhAg42rux6eH5IF82ZtHSuJyhgjKVR4RWS6IlS3WbINX5PODMnNUNSJLMQqwJP
|
||||
hEkUXs9nRni2JVbmrfukTUaTLvnhasR7rjhjsN2Z6ohv3UMf7rrfapmVoKMhSoLd
|
||||
jqvZ2ZoaT5mfTiK/5PDyWqrt/vmvE4VlipAsvudwozG5vQDEsCNDNUTg5OTGnPUU
|
||||
i0xeQTioqzCcweIlEaWhj/eMHx/eAeZ6V0Evid/YwTDlbTqVDWZGLJ/phOnKJs3V
|
||||
j+eOv7E2d1ga7149SPDIv5Y0YZ91v3M06ICk5o66gQKBgQDSM+YyR5YOJTSAuAcI
|
||||
uKTc33wwCbPiJF/F1zLJDdPp2IamZQbuNIX/8fOG3Gho+OnfNAykMcr3rFrug2vi
|
||||
9GhWDQqguYGh16xos+2zNan6P/s0/rQ4OfPIsTEGC8X3fJeMzZUNMvnyN/FXzzus
|
||||
020o29gu59esEfGHEsvAupC3IQKBgQDGMqGLgrU4oW/5mmm4BZlwwkZJNMmFH49u
|
||||
Qe4Ylj87SQduExJMmTfrmANqQXu7RXG0IxLcvhwMLVCCYAkvuBv1awsbg2yfP1Pn
|
||||
Wb/K+5CaHaxnpwSpRiGaN6fnAPDl8PnALMVXtQGru2MMcISxOIFQ9slHth0lmaMo
|
||||
odIPIL1YnQKBgAOSskUEhn5zD3NorWXujY7blabTY2VirOYWBFz6iTGeZpuJeBaw
|
||||
ed6h5DvUn0m5gXAz2EsqNYMEQP9w6HKRKPzdd+LHhHaVze5xsIatUNhaIhECi1mx
|
||||
Un2E1Yp+xLyyN3lDPVdeGHWPkeCmOyNy7JYXNpOFiVr5axuarC/4e+FBAoGAeuRR
|
||||
/mshaufOwnnYK15tcdlEM4gjnAOhr7/5ng0rT9tMXBg/NHeckNxE4dGQouHASu2k
|
||||
eHL4eSRv0ycxCwGhdF7XGEw5QdTGdaDUp0ussaLMj8ijv0HY/AKefUG8HRd6BIq+
|
||||
Ik/9pTofhEsQO8LJjCY5T9m/4NyOqlcMJI0sWpECgYBvPLnutbBXYONVAE3jL05K
|
||||
hWwenKpv5Aaa11ahqzhil2Tj+VOMtmvhsSc5loSG83qp5LtN4LxyR0Vn9AGN7Z+d
|
||||
Ut6LHeZ/DMW3/RPT+1MIKm6WLNxgk5YvuCxprdpfE5tTmV9/t+t3Uao7TRsLPl2o
|
||||
qAKz8Fvq0el5RW3EtAgd4A==
|
||||
-----END PRIVATE KEY-----
|
28
tests/certs/TSA.pem
Normal file
28
tests/certs/TSA.pem
Normal file
@ -0,0 +1,28 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIEzTCCA7WgAwIBAgIUfRjXKciCGA4XbhbhxbAwfpcLGmowDQYJKoZIhvcNAQEL
|
||||
BQAwYDELMAkGA1UEBhMCUEwxFTATBgNVBAoMDG9zc2xzaWduY29kZTEkMCIGA1UE
|
||||
CwwbVGltZXN0YW1wIEF1dGhvcml0eSBSb290IENBMRQwEgYDVQQDDAtUU0EgUm9v
|
||||
dCBDQTAeFw0xODAxMDEwMDAwMDBaFw0yODAxMDEwMDAwMDBaMFUxCzAJBgNVBAYT
|
||||
AlBMMRUwEwYDVQQKDAxvc3Nsc2lnbmNvZGUxHDAaBgNVBAsME1RpbWVzdGFtcCBB
|
||||
dXRob3JpdHkxETAPBgNVBAMMCFRlc3QgVFNBMIIBIjANBgkqhkiG9w0BAQEFAAOC
|
||||
AQ8AMIIBCgKCAQEAor220wp2zqj6Fe1VT/yic4LJcfMn1/ZWhsE7L86krULRvI+N
|
||||
JY0fOVg/24MtyOXbnm7nYOyYTlR9n2kqm4fEgsz+GDQxXLHgyLh3aF4ueDzoFt0v
|
||||
8G3vJfD+4N27XAYJ5V4f4s4VJRDIm0P/BvFGY9J/zICjC83F3OLdnkOD88O8QD6q
|
||||
FwWdtBYNqxQX1LAwy3ORe5aTubdVkHV02JhdKAC/xy5nfhynuV4KfYyel2nHrI1i
|
||||
54UXWdOrlD/XIKPiXpuEGcXhYTrTHigH+yR9ybs9hotGvuHTEjcxEuJvEQJX+qV4
|
||||
eJAIexITDW/yK+maWPLijO3bZ9/JodX+fRCnPQIDAQABo4IBiDCCAYQwDAYDVR0T
|
||||
AQH/BAIwADAWBgNVHSUBAf8EDDAKBggrBgEFBQcDCDAdBgNVHQ4EFgQUKWCqogni
|
||||
6SseJ/P6LXo0M2cK++QwHwYDVR0jBBgwFoAU/5nNuG4Tm4v2y9uKf428/4fVQesw
|
||||
gYQGCCsGAQUFBwEBBHgwdjA5BggrBgEFBQcwAoYtaHR0cDovL1RTQUNBLnRpbWVz
|
||||
dGFtcGF1dGhvcml0eS5jb20vVFNBQ0EuY3J0MDkGCCsGAQUFBzABhi1odHRwOi8v
|
||||
b2NzcC5UU0FDQS50aW1lc3RhbXBhdXRob3JpdHkuY29tOjkwODAwPgYDVR0fBDcw
|
||||
NTAzoDGgL4YtaHR0cDovL1RTQUNBLnRpbWVzdGFtcGF1dGhvcml0eS5jb20vVFNB
|
||||
Q0EuY3JsMFUGA1UdHgROMEygGDAKggh0ZXN0LmNvbTAKggh0ZXN0Lm9yZ6EwMAqH
|
||||
CAAAAAAAAAAAMCKHIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMA0G
|
||||
CSqGSIb3DQEBCwUAA4IBAQB4YXa5nVWUzWSsUDMfYFTEETOe8boUErwfrDNBuj6z
|
||||
B5en20FhI49i6PCYEfNq3vrAtPOEFJj+KPomN3C46VLxbUEvqWLdq6EyzWvVVmXK
|
||||
VLeC0qV0m6CFM8GplaWzZdfFTQaaLUhgY08ZU2gp4QsoS2YjAosxlZrNSm6pBbv3
|
||||
q+Og1KeSK8gKS0V89k+6e3LOEF6KaNWKSkoz5xDniQY//mTjiDcNmYUh0KhHfhdU
|
||||
eO92M82uJSaDqnRs5HsWPs6z6qdfpuvj++OtQ1VCM2p5SEH2sEomdeN3YYChuG4h
|
||||
yzn0mYAdbTyGJHlFm17AH+SQRbVqCKYdHDaqsMb+fWzi
|
||||
-----END CERTIFICATE-----
|
22
tests/certs/TSACA.pem
Normal file
22
tests/certs/TSACA.pem
Normal file
@ -0,0 +1,22 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDkDCCAnigAwIBAgIUJ0nfE+EVsIThltlY2LHVWMJVIq4wDQYJKoZIhvcNAQEL
|
||||
BQAwYDELMAkGA1UEBhMCUEwxFTATBgNVBAoMDG9zc2xzaWduY29kZTEkMCIGA1UE
|
||||
CwwbVGltZXN0YW1wIEF1dGhvcml0eSBSb290IENBMRQwEgYDVQQDDAtUU0EgUm9v
|
||||
dCBDQTAeFw0xNzAxMDEwMDAwMDBaFw0yNjExMTAwMDAwMDBaMGAxCzAJBgNVBAYT
|
||||
AlBMMRUwEwYDVQQKDAxvc3Nsc2lnbmNvZGUxJDAiBgNVBAsMG1RpbWVzdGFtcCBB
|
||||
dXRob3JpdHkgUm9vdCBDQTEUMBIGA1UEAwwLVFNBIFJvb3QgQ0EwggEiMA0GCSqG
|
||||
SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDGOTX1f9dmtUiyzlsUInRIGfRMya338SVx
|
||||
vYGeOwdpTSSGlYUVwR9AuFewQF5+klelstCJe+SoUG0AdzS30mRWlQrhip4UdvdW
|
||||
T2gkNKbSn6DQzlWoQej9izqRLxAsbuszgkvnLOBEmPaLimDsCgu0bAN95Hp0Hls9
|
||||
O/fVmzh8VuV4iscxc7q13ZB7CylWgwd55CFEGd/jpJ6kMwSHbOLoBWp4GQ3KxR+c
|
||||
ASAo0FapU2WSZB2EYWszRiyq91X+AvIYN4ypTv7RccgfUvnZ2qFykJAkf/wgkynu
|
||||
Qg7rCUNfUEpDc7jlqtDWR7iLrtHBkA17C3IU8ymmKQYWfw3ZyBwvAgMBAAGjQjBA
|
||||
MA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFP+ZzbhuE5uL9svbin+NvP+H1UHr
|
||||
MA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsFAAOCAQEAbj3aFwIUxvzwgywO
|
||||
gj01JM8GNbw1E4MGdkaNI8rgeY8ay15ZXhR9NpRWWb6Y7IXPq5XhuEktVte5Z4Kf
|
||||
XLBrr7Xe9VVqJL9zd1tMzOEM/zG77rZf/iXBTZLkCtQc/GOEY4TTWKNEl5hiWVE0
|
||||
po97GX5XHoeyHlWQ75sd9z6MxFxmvdp9/uyYD700e9sd5gcD8LGvHw2DNy8vntYV
|
||||
ia9h95N9i1umffxU460o8W5GoIcsD13B3YftvnWhGSXqovBRFgcPAQZ4eW9Qh/zA
|
||||
4zQBQrRvmREPihXVdgtWVpbRchP99oSZBrYr7Hh/P69rycklquqxJl1ol1wbT6dK
|
||||
S5Gmng==
|
||||
-----END CERTIFICATE-----
|
BIN
tests/certs/cert.der
Normal file
BIN
tests/certs/cert.der
Normal file
Binary file not shown.
BIN
tests/certs/cert.p12
Normal file
BIN
tests/certs/cert.p12
Normal file
Binary file not shown.
46
tests/certs/cert.pem
Normal file
46
tests/certs/cert.pem
Normal file
@ -0,0 +1,46 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIID7jCCAtagAwIBAgIUdLInHjkevRVCr7I78r5++6eSrZ0wDQYJKoZIhvcNAQEL
|
||||
BQAwYDELMAkGA1UEBhMCUEwxFTATBgNVBAoMDG9zc2xzaWduY29kZTEgMB4GA1UE
|
||||
CwwXQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxGDAWBgNVBAMMD0ludGVybWVkaWF0
|
||||
ZSBDQTAeFw0xODAxMDEwMDAwMDBaFw0yNDEyMzEwMDAwMDBaMIGdMQswCQYDVQQG
|
||||
EwJQTDEZMBcGA1UECAwQTWF6b3ZpYSBQcm92aW5jZTEPMA0GA1UEBwwGV2Fyc2F3
|
||||
MRUwEwYDVQQKDAxvc3Nsc2lnbmNvZGUxDDAKBgNVBAsMA0NTUDEUMBIGA1UEAwwL
|
||||
Q2VydGlmaWNhdGUxJzAlBgkqhkiG9w0BCQEWGG9zc2xzaWduY29kZUBleGFtcGxl
|
||||
LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALJLJ3Vty2lgJw+5
|
||||
ouAV4ZqkIwvfWPcE7zD1CfQIL2802jVuCSTkN9cfFVYMKFEPJxQWJAKoCzr/Ux8z
|
||||
Yt9BXO5o39+z7umLKmc6pfrZJ6kG4msrMjZv36LsCQyfjUc1O9H1aiOQEvRQY2pF
|
||||
2v5dfqRMrAqH1ESQHCggUBjElWj9oMFax8jyO7JxTzuttOb6mhDmqz4q2u4LwZGH
|
||||
lBofgOAB54Mlv41x7dDh85i/jayXuYYmsjRwCuBAn14+D2zImyPDx5UaUJJMzujo
|
||||
QriOZ4KU2dHRgy0+vd7ZbrL1kRY1axyNQ+jBk7UHnlZZ2CCkhBoZIM6ez3ljPwgr
|
||||
cpg0RtcCAwEAAaNiMGAwCQYDVR0TBAIwADAdBgNVHQ4EFgQUBxPEs09WXDxGqb+D
|
||||
WTFgcUQd0AEwHwYDVR0jBBgwFoAUngWsC1vhQH9qDvTZRE+KJ33vOIswEwYDVR0l
|
||||
BAwwCgYIKwYBBQUHAwMwDQYJKoZIhvcNAQELBQADggEBAKK2e1s1puUFbNjglopi
|
||||
mKZ4Pks2zb6LVUGG6Q4XQ1dWe25ovt68jWv56HFyCMI1N+L8q0+Ku2eOfLObS7Ej
|
||||
FFRUWEIXDgipryDTGzoWRM380fuYpL/j7Rt1/xmIHWTFibf/6gK/naRXsFH3dEbb
|
||||
7DDWQ5pAd2d60dB+ThUEIZQTQd/926Kuk5oESvP08fXMYTuiYARypG1gmiuvxQ9N
|
||||
mDJP6CHxyJR/LB4tb0RAqnLkVsXVBDnRYWdEvkuhoqTtbhVzVbL3mPeEmVYypxxd
|
||||
NdrHpU5zmxFSin2T3F0TneNcT+MDV+dQcWyTGNYs/fnmo85LsiakJixGv1qx8PTs
|
||||
8iE=
|
||||
-----END CERTIFICATE-----
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDrDCCApSgAwIBAgIUUPCDF21g2spK7557HZUhqSxBltMwDQYJKoZIhvcNAQEL
|
||||
BQAwWDELMAkGA1UEBhMCUEwxFTATBgNVBAoMDG9zc2xzaWduY29kZTEgMB4GA1UE
|
||||
CwwXQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxEDAOBgNVBAMMB1Jvb3QgQ0EwHhcN
|
||||
MTgwMTAxMDAwMDAwWhcNMjYwMTAxMDAwMDAwWjBgMQswCQYDVQQGEwJQTDEVMBMG
|
||||
A1UECgwMb3NzbHNpZ25jb2RlMSAwHgYDVQQLDBdDZXJ0aWZpY2F0aW9uIEF1dGhv
|
||||
cml0eTEYMBYGA1UEAwwPSW50ZXJtZWRpYXRlIENBMIIBIjANBgkqhkiG9w0BAQEF
|
||||
AAOCAQ8AMIIBCgKCAQEAyMs1XoC0NUT5YgydibOrE5SWBKk5C47B6tv6gA4t3zZJ
|
||||
wejaiPkj+aTIU3Ww5DO/Gpz0GuqCHNBczIw92Cfvv8kyWzUy46bRkpBJLFav0JXS
|
||||
B3xQaPlHWeXqMfVAGuM5ExT4CjjYKFsrgV1Q300thCHBhvr8TPekDIf+6J7NSz1P
|
||||
062pYgypfqsA8OwKaQbgOL9v4QRmHoolnEDc1dK/FS4f3p9dlifl7kcSVGQK0yit
|
||||
7Uncn250icCxMxS3MOE2NfuplUOSN6h6poWNGUsx00O7Dy9nUndUwJRpFfKXTV3v
|
||||
GtlmFLNoho+ss/usnxjxggWBcRtKhqd8nGSJUlzs0wIDAQABo2YwZDASBgNVHRMB
|
||||
Af8ECDAGAQH/AgEAMB0GA1UdDgQWBBSeBawLW+FAf2oO9NlET4onfe84izAfBgNV
|
||||
HSMEGDAWgBTp7DHcMiltHw6m0SYMWVg0QtGo/jAOBgNVHQ8BAf8EBAMCAYYwDQYJ
|
||||
KoZIhvcNAQELBQADggEBAD/FBa4stJGd/Acg2E2soI071B/l9B7FiqIRpCFuLVC4
|
||||
1m7TIcjioIpZrxXwE1Egf8A9/6D/kKZtWnOljcxtPBEb+1/gB61M381RIgoMQ/Pf
|
||||
7XX2yakk6mscUjbSTR//Mj1sYOs2r6ueZBp0whzF9nVvA43G6WMpf6XZqmhlg/oV
|
||||
ynytW1Iu1SPoru3y8dX/lsukvKCak7MAp1eBcuUJxS56DnKcV9xgC30m3g+CErI3
|
||||
qsOJ7lcfDP6fDjy7MfBsZBiY64MqwlDjjn7+Pleo69JedMwurHLhKnfm07DBPy8X
|
||||
+EnQk61xHEjQtTsddXyQGQV3yjqylOF2AgsAf256uuA=
|
||||
-----END CERTIFICATE-----
|
BIN
tests/certs/cert.spc
Normal file
BIN
tests/certs/cert.spc
Normal file
Binary file not shown.
23
tests/certs/crosscert.pem
Normal file
23
tests/certs/crosscert.pem
Normal file
@ -0,0 +1,23 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDzjCCAragAwIBAgIUGjZdQYlcAtlqZOsQ7eWRimQ9PIcwDQYJKoZIhvcNAQEL
|
||||
BQAwbzELMAkGA1UEBhMCUEwxFTATBgNVBAoMDG9zc2xzaWduY29kZTEMMAoGA1UE
|
||||
CwwDQ1NQMRIwEAYDVQQDDAljcm9zc2NlcnQxJzAlBgkqhkiG9w0BCQEWGG9zc2xz
|
||||
aWduY29kZUBleGFtcGxlLmNvbTAeFw0xODAxMDEwMDAwMDBaFw0yMDA2MTkwMDAw
|
||||
MDBaMG8xCzAJBgNVBAYTAlBMMRUwEwYDVQQKDAxvc3Nsc2lnbmNvZGUxDDAKBgNV
|
||||
BAsMA0NTUDESMBAGA1UEAwwJY3Jvc3NjZXJ0MScwJQYJKoZIhvcNAQkBFhhvc3Ns
|
||||
c2lnbmNvZGVAZXhhbXBsZS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
|
||||
AoIBAQDJU6WNMOEoErLYb5Qc7jsvVgruPM7DJTZ4vUpJNYAyprSDHciaKSa4SiYS
|
||||
84Mxc6tzBoJvKOAwpxzzONOqPVWUd5J244urgvfHgSGWsbA8bakiIYlETopnecFk
|
||||
B3ZELR33CPqIbpYYMYujhPGFa1xxZxFykJ1iBhZ8Gh3W4wHi/2kW6hTQkihMtUPP
|
||||
Xxc2XWACj/tz22OSdgNZcIfhXiy2HOuPch+0UlDR4UmlJIR5aet1y832hHoeeevo
|
||||
qfhfGOm9rRf9nyxKDwTyaN7JVOb7A1k6KJEJoe1zfIwT56mgoA433iUWFMLB6hKU
|
||||
be3zV1vGjk77Kk7atcvEMTRq+rwHAgMBAAGjYjBgMAkGA1UdEwQCMAAwHQYDVR0O
|
||||
BBYEFEXgglEcDh+8oCCvjlxrN/Y7C4YwMB8GA1UdIwQYMBaAFEXgglEcDh+8oCCv
|
||||
jlxrN/Y7C4YwMBMGA1UdJQQMMAoGCCsGAQUFBwMDMA0GCSqGSIb3DQEBCwUAA4IB
|
||||
AQBo8UqUEjxGQCVU/IgphwKA8Rb/uAyBYm+AjqFDs82lA6ze0n08Bj+eciVkxscA
|
||||
0deivOC1sDD88QkLzSQ9CPk4e7+m7nx5SFUnUWY+o3ln+cTbGSM0jW9hme0LtHXX
|
||||
QxDSKDBhQonRQk7lQ+TwFR7ol+y5SdZy7YQ+v/25qO6MMQgSPykJIa4vF7lwrYhu
|
||||
qL+1MJx/ryTbCUExcKNNkWHZJRc9ZvtdWEHYpBSZl5xmJdKMLnHAu5uv8N2pezzp
|
||||
PfujldZky7bnERaTM+bf/LvKXS8RfQGrCLu9QjgPVa6ysZV6gXTsEtwYh64vucjS
|
||||
s7IhdLxfiT0xYkK4JWrRLc38
|
||||
-----END CERTIFICATE-----
|
45
tests/certs/expired.pem
Normal file
45
tests/certs/expired.pem
Normal file
@ -0,0 +1,45 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIID6jCCAtKgAwIBAgIUdtBZJAw8/6JVNMiQpN3PEROI8rowDQYJKoZIhvcNAQEL
|
||||
BQAwYDELMAkGA1UEBhMCUEwxFTATBgNVBAoMDG9zc2xzaWduY29kZTEgMB4GA1UE
|
||||
CwwXQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxGDAWBgNVBAMMD0ludGVybWVkaWF0
|
||||
ZSBDQTAeFw0xODAxMDEwMDAwMDBaFw0xOTAxMDEwMDAwMDBaMIGZMQswCQYDVQQG
|
||||
EwJQTDEZMBcGA1UECAwQTWF6b3ZpYSBQcm92aW5jZTEPMA0GA1UEBwwGV2Fyc2F3
|
||||
MRUwEwYDVQQKDAxvc3Nsc2lnbmNvZGUxDDAKBgNVBAsMA0NTUDEQMA4GA1UEAwwH
|
||||
RXhwaXJlZDEnMCUGCSqGSIb3DQEJARYYb3NzbHNpZ25jb2RlQGV4YW1wbGUuY29t
|
||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsksndW3LaWAnD7mi4BXh
|
||||
mqQjC99Y9wTvMPUJ9AgvbzTaNW4JJOQ31x8VVgwoUQ8nFBYkAqgLOv9THzNi30Fc
|
||||
7mjf37Pu6YsqZzql+tknqQbiaysyNm/fouwJDJ+NRzU70fVqI5AS9FBjakXa/l1+
|
||||
pEysCofURJAcKCBQGMSVaP2gwVrHyPI7snFPO6205vqaEOarPira7gvBkYeUGh+A
|
||||
4AHngyW/jXHt0OHzmL+NrJe5hiayNHAK4ECfXj4PbMibI8PHlRpQkkzO6OhCuI5n
|
||||
gpTZ0dGDLT693tlusvWRFjVrHI1D6MGTtQeeVlnYIKSEGhkgzp7PeWM/CCtymDRG
|
||||
1wIDAQABo2IwYDAJBgNVHRMEAjAAMB0GA1UdDgQWBBQHE8SzT1ZcPEapv4NZMWBx
|
||||
RB3QATAfBgNVHSMEGDAWgBSeBawLW+FAf2oO9NlET4onfe84izATBgNVHSUEDDAK
|
||||
BggrBgEFBQcDAzANBgkqhkiG9w0BAQsFAAOCAQEAX1Ar7jRAXdcA0Wu37yRi58QN
|
||||
hpa1VLXadqfB+i5Y4e3DzqnMbpkLWsFzreC1AG0RjLe52s4PRUE6boGlpUeAyfFC
|
||||
Qu2Gl/REVWwMCYV8bq3vQZkYQjklAXCQLWFk5TrzuDmBcV8+fY518nWw+xmcYwW5
|
||||
5oehLsvB4nxoBzlHgcdDwS5b2dmpCKCbZFLU9aA9DjAVvY/9B8emyj7Sh2sEK0Yf
|
||||
xwHlATTVq5O0/9tvVZQmYsbpS0iCRGBM+spTEhDT4WGsaRO6wP+Ucgp6Ym3ahMvz
|
||||
tHME3uUanKWVoDb69sguGZ6KlnZZZdIX1AJ3dlTXCrzEO9xsoAzqzsxVJGrraQ==
|
||||
-----END CERTIFICATE-----
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDrDCCApSgAwIBAgIUUPCDF21g2spK7557HZUhqSxBltMwDQYJKoZIhvcNAQEL
|
||||
BQAwWDELMAkGA1UEBhMCUEwxFTATBgNVBAoMDG9zc2xzaWduY29kZTEgMB4GA1UE
|
||||
CwwXQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxEDAOBgNVBAMMB1Jvb3QgQ0EwHhcN
|
||||
MTgwMTAxMDAwMDAwWhcNMjYwMTAxMDAwMDAwWjBgMQswCQYDVQQGEwJQTDEVMBMG
|
||||
A1UECgwMb3NzbHNpZ25jb2RlMSAwHgYDVQQLDBdDZXJ0aWZpY2F0aW9uIEF1dGhv
|
||||
cml0eTEYMBYGA1UEAwwPSW50ZXJtZWRpYXRlIENBMIIBIjANBgkqhkiG9w0BAQEF
|
||||
AAOCAQ8AMIIBCgKCAQEAyMs1XoC0NUT5YgydibOrE5SWBKk5C47B6tv6gA4t3zZJ
|
||||
wejaiPkj+aTIU3Ww5DO/Gpz0GuqCHNBczIw92Cfvv8kyWzUy46bRkpBJLFav0JXS
|
||||
B3xQaPlHWeXqMfVAGuM5ExT4CjjYKFsrgV1Q300thCHBhvr8TPekDIf+6J7NSz1P
|
||||
062pYgypfqsA8OwKaQbgOL9v4QRmHoolnEDc1dK/FS4f3p9dlifl7kcSVGQK0yit
|
||||
7Uncn250icCxMxS3MOE2NfuplUOSN6h6poWNGUsx00O7Dy9nUndUwJRpFfKXTV3v
|
||||
GtlmFLNoho+ss/usnxjxggWBcRtKhqd8nGSJUlzs0wIDAQABo2YwZDASBgNVHRMB
|
||||
Af8ECDAGAQH/AgEAMB0GA1UdDgQWBBSeBawLW+FAf2oO9NlET4onfe84izAfBgNV
|
||||
HSMEGDAWgBTp7DHcMiltHw6m0SYMWVg0QtGo/jAOBgNVHQ8BAf8EBAMCAYYwDQYJ
|
||||
KoZIhvcNAQELBQADggEBAD/FBa4stJGd/Acg2E2soI071B/l9B7FiqIRpCFuLVC4
|
||||
1m7TIcjioIpZrxXwE1Egf8A9/6D/kKZtWnOljcxtPBEb+1/gB61M381RIgoMQ/Pf
|
||||
7XX2yakk6mscUjbSTR//Mj1sYOs2r6ueZBp0whzF9nVvA43G6WMpf6XZqmhlg/oV
|
||||
ynytW1Iu1SPoru3y8dX/lsukvKCak7MAp1eBcuUJxS56DnKcV9xgC30m3g+CErI3
|
||||
qsOJ7lcfDP6fDjy7MfBsZBiY64MqwlDjjn7+Pleo69JedMwurHLhKnfm07DBPy8X
|
||||
+EnQk61xHEjQtTsddXyQGQV3yjqylOF2AgsAf256uuA=
|
||||
-----END CERTIFICATE-----
|
22
tests/certs/intermediate.pem
Normal file
22
tests/certs/intermediate.pem
Normal file
@ -0,0 +1,22 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDrDCCApSgAwIBAgIUUPCDF21g2spK7557HZUhqSxBltMwDQYJKoZIhvcNAQEL
|
||||
BQAwWDELMAkGA1UEBhMCUEwxFTATBgNVBAoMDG9zc2xzaWduY29kZTEgMB4GA1UE
|
||||
CwwXQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxEDAOBgNVBAMMB1Jvb3QgQ0EwHhcN
|
||||
MTgwMTAxMDAwMDAwWhcNMjYwMTAxMDAwMDAwWjBgMQswCQYDVQQGEwJQTDEVMBMG
|
||||
A1UECgwMb3NzbHNpZ25jb2RlMSAwHgYDVQQLDBdDZXJ0aWZpY2F0aW9uIEF1dGhv
|
||||
cml0eTEYMBYGA1UEAwwPSW50ZXJtZWRpYXRlIENBMIIBIjANBgkqhkiG9w0BAQEF
|
||||
AAOCAQ8AMIIBCgKCAQEAyMs1XoC0NUT5YgydibOrE5SWBKk5C47B6tv6gA4t3zZJ
|
||||
wejaiPkj+aTIU3Ww5DO/Gpz0GuqCHNBczIw92Cfvv8kyWzUy46bRkpBJLFav0JXS
|
||||
B3xQaPlHWeXqMfVAGuM5ExT4CjjYKFsrgV1Q300thCHBhvr8TPekDIf+6J7NSz1P
|
||||
062pYgypfqsA8OwKaQbgOL9v4QRmHoolnEDc1dK/FS4f3p9dlifl7kcSVGQK0yit
|
||||
7Uncn250icCxMxS3MOE2NfuplUOSN6h6poWNGUsx00O7Dy9nUndUwJRpFfKXTV3v
|
||||
GtlmFLNoho+ss/usnxjxggWBcRtKhqd8nGSJUlzs0wIDAQABo2YwZDASBgNVHRMB
|
||||
Af8ECDAGAQH/AgEAMB0GA1UdDgQWBBSeBawLW+FAf2oO9NlET4onfe84izAfBgNV
|
||||
HSMEGDAWgBTp7DHcMiltHw6m0SYMWVg0QtGo/jAOBgNVHQ8BAf8EBAMCAYYwDQYJ
|
||||
KoZIhvcNAQELBQADggEBAD/FBa4stJGd/Acg2E2soI071B/l9B7FiqIRpCFuLVC4
|
||||
1m7TIcjioIpZrxXwE1Egf8A9/6D/kKZtWnOljcxtPBEb+1/gB61M381RIgoMQ/Pf
|
||||
7XX2yakk6mscUjbSTR//Mj1sYOs2r6ueZBp0whzF9nVvA43G6WMpf6XZqmhlg/oV
|
||||
ynytW1Iu1SPoru3y8dX/lsukvKCak7MAp1eBcuUJxS56DnKcV9xgC30m3g+CErI3
|
||||
qsOJ7lcfDP6fDjy7MfBsZBiY64MqwlDjjn7+Pleo69JedMwurHLhKnfm07DBPy8X
|
||||
+EnQk61xHEjQtTsddXyQGQV3yjqylOF2AgsAf256uuA=
|
||||
-----END CERTIFICATE-----
|
BIN
tests/certs/key.der
Normal file
BIN
tests/certs/key.der
Normal file
Binary file not shown.
27
tests/certs/key.pem
Normal file
27
tests/certs/key.pem
Normal file
@ -0,0 +1,27 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEogIBAAKCAQEAsksndW3LaWAnD7mi4BXhmqQjC99Y9wTvMPUJ9AgvbzTaNW4J
|
||||
JOQ31x8VVgwoUQ8nFBYkAqgLOv9THzNi30Fc7mjf37Pu6YsqZzql+tknqQbiaysy
|
||||
Nm/fouwJDJ+NRzU70fVqI5AS9FBjakXa/l1+pEysCofURJAcKCBQGMSVaP2gwVrH
|
||||
yPI7snFPO6205vqaEOarPira7gvBkYeUGh+A4AHngyW/jXHt0OHzmL+NrJe5hiay
|
||||
NHAK4ECfXj4PbMibI8PHlRpQkkzO6OhCuI5ngpTZ0dGDLT693tlusvWRFjVrHI1D
|
||||
6MGTtQeeVlnYIKSEGhkgzp7PeWM/CCtymDRG1wIDAQABAoIBACR/jgxT9ZgUvupR
|
||||
Li6BTDXD9AiyKBwpPm3fO7JhGpTBVQorBGQw891t14hN5NLzLyTFg4mnrOTe770r
|
||||
X8okL0n+3hWFWBsnCf8n2mKHob7QUfluVlEehcFsYE3dO6agFybb/mZZUAgDjNZs
|
||||
hnAb45juuSlOtP10Is90DfGEDLH5IeY1xjzc7Qv/CFxCffIAC8QmQYUTihJ2m5aE
|
||||
7Hvs79oEcSvbRJDYbykzrJ0eeIaEvfOxkWJnnJHrhiONzb8qgj3DLiZdX1qeo1Ao
|
||||
ldNxEG9n3Axd6M0nhajz0qbDV11S8YiKfP10XRQh5xv7lZi7MjvrRxFTFYpSrXwi
|
||||
YYyFNoECgYEA6YnIYg1nIe3qaI3Me1RQQTGRl8M/dQc2d98Pz5mez9vN3TIW6nEs
|
||||
QYw/9OKG1ercbD+YnuaV+1izuAcA3mNlSDReTtzInAotJjTH1V3WYqvBTVUZSb6T
|
||||
5qSBfRDC3AULFvHeX5c5wqgfB3U9KLDfVBfaHnMerg6dAGsYZPhPMrkCgYEAw3Eg
|
||||
5BRTzbqG0WXF25rycTeHCcylMZRjI+TVcIa8AGqNSCK4HgAWp89XPIV3WceVqe2R
|
||||
Lyn1jtA2MgGGcMBDFlOWF+h9j2/j27Z+pyIbBF9LAraJuBOG6dezd50y5Ur6HK/f
|
||||
e5lnjvElIYdz+RX+rmw8NFcIUbSAfE7rGinDvg8CgYBDx86VzsgJC/FFySn4/X6R
|
||||
fV6BSpTHVYGUhvQiz7ZNI8F7GoeWIaSznY4OeBSkT5cL/+U+8TPEkHkQx0+UPArw
|
||||
Suq4PtImn7l85kK9hY+scacX18QQKDTq8wH2F4BGtVwDm81rtwt3mK3wzzEh9zvK
|
||||
P2X6AnV8FReyQGMDIyJxWQKBgD6nu9WitqMTkzj6GY4nhGXLWV1I4ASe/5F4QPzM
|
||||
FOVFQ3nGt6PWf2zYyay7VOHRXCeX451tJC3ejiFF3+WxnVBBB7Muc2JSiofbX4sR
|
||||
Ifwq2I9MGaaLjArXfc9w8+oSOVCNCWZEbbCjmjW/iOxnorgkNsDIzf/zj+VKH5DJ
|
||||
ptj9AoGAUpB6nPES3Nnj8DsbpHCnShYMl/rFxzxg2pJJosXzuS/ttuBT2DlT5eiY
|
||||
aZcL1DGSp2CD4QXbVuDHPkQMPzVfZzKAuCZlotEMR9byK46aYIkQueym45e0PGZP
|
||||
djKZm+cxF+W55jBkBBhV6wSOLNRWCUYiIIq3RmwWjkopNvSlwY4=
|
||||
-----END RSA PRIVATE KEY-----
|
BIN
tests/certs/key.pvk
Normal file
BIN
tests/certs/key.pvk
Normal file
Binary file not shown.
30
tests/certs/keyp.pem
Normal file
30
tests/certs/keyp.pem
Normal file
@ -0,0 +1,30 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
Proc-Type: 4,ENCRYPTED
|
||||
DEK-Info: DES-EDE3-CBC,6DB255395263EDD5
|
||||
|
||||
A83CH4mv7u89RbT8Tpz4gxImKGBw69Zr3LstRXlliGYobby5YBx/YimkA9wFCZK/
|
||||
B1eitWwy0F6axDZQYHKi+yvUJDPB9arXtClvYknMhwrHV1GHLSYeqb9oZJeqNyDZ
|
||||
Qd3lxTbUtkMVJgJNrl2kOezm6/srnAw4uA7NyAvrs2vEzB48q4VlysrJq+f9mLXj
|
||||
vCmrfUwY999lSifRmoxqeWlqNUQ2tgHHXYMNagpvxYXsfe1UvEH9aa6+UsO9S0py
|
||||
7dyfSu95QpWyVNqkWi1VAtNbo2VpjJ6NJLAk+dy/rNqN3a4KnWeIzkYssWTsKB08
|
||||
VyHrRLePPx5qdarsczZtf+M2PxhHHnl/09+Nrp5BUcMV31j3v3VSM0K+CHEucAk7
|
||||
95rUtSUNywKUQeSgXrG1eLX7kXwRQ7PPCz3sPtvmJRIvQlGgLiTbKPsG52m3kAIw
|
||||
zgXPcH2lYb3855occznl72jMUucxXq8gq0bC4xbEg/yJV8p1IuUEFhLGI9s9T4JV
|
||||
cO9NKwmSjpHFo1ULhB7o6uMmV2rYDK+5GbQHxZgHj3ES+i53eFMWGubPEEOmqSh3
|
||||
9K7gtW9y971tNfhp9ba8RnYXT6xW2nMTM4koO9b4ptdwRo5bMKFvWY8eecXfsDAG
|
||||
OJ+aXkDr8jsn1Xauq1m4TM71wn2wUx95KaCpL55UNBEn7aH9qlNFfxdyzXMPYS36
|
||||
zgWK44BV3PTSIGgW61NVwHwzi3bFfymortVxGpelzy2dggWVvI3uzKocLFQ8f4oe
|
||||
Y0HWSmGVPF3uFHNCZtCB/Tpbz6YwP/YYStqAcryeS5Yo9Hdkh8pBVnYiKdTFEUW2
|
||||
RbClgeB2MV+zttsqvmodfkviS4BjWgoIV5szxWOePnO8kQAHA/Ml3CyDPOX6rqI5
|
||||
lDKiUojEMLgir/3YWWcmigEIgRsyF3CL1s+kTR3S8e9QRe8RiliRUKW5gXrLEa6j
|
||||
eUjs4kgCrvmQvwyZYJjWl+r7ycmk+yB/EZs8P39KRR/pfeZDUCZIOx8vkJBt57hC
|
||||
oTNJ5llFzRcmEraElXmDOAuvmj3Lx/4qzY545rtzll3mFHJEX4qITslIX1ksZz1p
|
||||
DncuqgIECzmZIeHPbnw7Nkv6EkoPzTOlccqnCH/SumFr2fhctv9x13gGcO4kSsqO
|
||||
63yZCFHjMz/mos3l51aIAizj5wQO3BOo+RyKoSQohvPzVtSgjhYMZsAPzXKxF0/H
|
||||
9VH0DekEb1WwPSbGZw8kpx9ePlglGqOBinTL6QW8YmFPbjy9RDd1di+fxh4Qe024
|
||||
8gERZpdSsMoZ+NP0nr/TSbDISFPqcLzzMpC+V8Fc/QkNvSkR1GLlNQrxLoyfK0VX
|
||||
0evysXDxqIWK9+TH7hIS1lf3i2gMkLMppMso1v2Cqf0zRj1oM3MI743QE9XTXKRz
|
||||
iAwaEDDPZWS/00T9fqNrHgtSPNpsbeYZQPYaC2lq1kTIEOlUfZZvMy5lxVPVZ8y2
|
||||
foit+0DewZsqLDJwbjZ3wYMERVEY7KagoInQa3A1ZC9SkFiCb4fNEbRF13gfjrSz
|
||||
muRbKAhEhkzJDFRocIaTKZPIWdvC73tAW66v1Zha74mxuckgnQPPqQ==
|
||||
-----END RSA PRIVATE KEY-----
|
@ -1,218 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
result=0
|
||||
|
||||
test_result() {
|
||||
if test "$1" -eq 0
|
||||
then
|
||||
printf "Succeeded\n" >> "makecerts.log"
|
||||
else
|
||||
printf "Failed\n" >> "makecerts.log"
|
||||
fi
|
||||
}
|
||||
|
||||
make_certs() {
|
||||
password=passme
|
||||
result_path=$(pwd)
|
||||
cd $(dirname "$0")
|
||||
script_path=$(pwd)
|
||||
cd "${result_path}"
|
||||
mkdir "tmp/"
|
||||
|
||||
# OpenSSL settings
|
||||
CONF="${script_path}/openssl_intermediate.cnf"
|
||||
TEMP_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
|
||||
if test -n "$1"
|
||||
then
|
||||
OPENSSL="$1/bin/openssl"
|
||||
LD_LIBRARY_PATH="$1/lib"
|
||||
else
|
||||
OPENSSL=openssl
|
||||
fi
|
||||
|
||||
mkdir "demoCA/" 2>> "makecerts.log" 1>&2
|
||||
touch "demoCA/index.txt"
|
||||
touch "demoCA/index.txt.attr"
|
||||
echo 1000 > "demoCA/serial"
|
||||
date > "makecerts.log"
|
||||
$OPENSSL version 2>> "makecerts.log" 1>&2
|
||||
echo -n "$password" > "password.txt"
|
||||
|
||||
printf "\nGenerate root CA certificate\n" >> "makecerts.log"
|
||||
$OPENSSL genrsa -out demoCA/CA.key \
|
||||
2>> "makecerts.log" 1>&2
|
||||
TZ=GMT faketime -f '@2017-01-01 00:00:00' /bin/bash -c '
|
||||
script_path=$(pwd)
|
||||
OPENSSL=openssl
|
||||
CONF="${script_path}/openssl_root.cnf"
|
||||
$OPENSSL req -config $CONF -new -x509 -days 3600 -key demoCA/CA.key -out tmp/CACert.pem \
|
||||
-subj "/C=PL/O=osslsigncode/OU=Certification Authority/CN=Root CA" \
|
||||
2>> "makecerts.log" 1>&2'
|
||||
test_result $?
|
||||
|
||||
printf "\nGenerate intermediate CA certificate\n" >> "makecerts.log"
|
||||
$OPENSSL genrsa -out demoCA/intermediate.key \
|
||||
2>> "makecerts.log" 1>&2
|
||||
TZ=GMT faketime -f '@2017-01-01 00:00:00' /bin/bash -c '
|
||||
script_path=$(pwd)
|
||||
OPENSSL=openssl
|
||||
CONF="${script_path}/openssl_intermediate.cnf"
|
||||
$OPENSSL req -config $CONF -new -key demoCA/intermediate.key -out demoCA/intermediate.csr \
|
||||
-subj "/C=PL/O=osslsigncode/OU=Certification Authority/CN=Intermediate CA" \
|
||||
2>> "makecerts.log" 1>&2'
|
||||
test_result $?
|
||||
TZ=GMT faketime -f '@2017-01-01 00:00:00' /bin/bash -c '
|
||||
script_path=$(pwd)
|
||||
OPENSSL=openssl
|
||||
CONF="${script_path}/openssl_root.cnf"
|
||||
$OPENSSL ca -config $CONF -batch -in demoCA/intermediate.csr -out demoCA/intermediate.cer \
|
||||
2>> "makecerts.log" 1>&2'
|
||||
test_result $?
|
||||
$OPENSSL x509 -in demoCA/intermediate.cer -out tmp/intermediate.pem \
|
||||
2>> "makecerts.log" 1>&2
|
||||
|
||||
printf "\nGenerate private RSA encrypted key\n" >> "makecerts.log"
|
||||
$OPENSSL genrsa -des3 -out demoCA/private.key -passout pass:$password \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
cat demoCA/private.key >> tmp/keyp.pem 2>> "makecerts.log"
|
||||
|
||||
printf "\nGenerate private RSA decrypted key\n" >> "makecerts.log"
|
||||
$OPENSSL rsa -in demoCA/private.key -passin pass:$password -out tmp/key.pem \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
|
||||
printf "\nGenerate a certificate to revoke\n" >> "makecerts.log"
|
||||
$OPENSSL req -config $CONF -new -key demoCA/private.key -passin pass:$password -out demoCA/revoked.csr \
|
||||
-subj "/C=PL/O=osslsigncode/OU=CSP/CN=Revoked/emailAddress=osslsigncode@example.com" \
|
||||
2>> "makecerts.log" 1>&2
|
||||
$OPENSSL ca -config $CONF -batch -in demoCA/revoked.csr -out demoCA/revoked.cer \
|
||||
2>> "makecerts.log" 1>&2
|
||||
$OPENSSL x509 -in demoCA/revoked.cer -out tmp/revoked.pem \
|
||||
2>> "makecerts.log" 1>&2
|
||||
|
||||
printf "\nRevoke above certificate\n" >> "makecerts.log"
|
||||
$OPENSSL ca -config $CONF -revoke demoCA/1001.pem \
|
||||
2>> "makecerts.log" 1>&2
|
||||
|
||||
printf "\nAttach intermediate certificate to revoked certificate\n" >> "makecerts.log"
|
||||
cat tmp/intermediate.pem >> tmp/revoked.pem
|
||||
|
||||
printf "\nGenerate CRL file\n" >> "makecerts.log"
|
||||
TZ=GMT faketime -f '@2019-01-01 00:00:00' /bin/bash -c '
|
||||
script_path=$(pwd)
|
||||
OPENSSL=openssl
|
||||
CONF="${script_path}/openssl_intermediate.cnf"
|
||||
$OPENSSL ca -config $CONF -gencrl -crldays 8766 -out tmp/CACertCRL.pem \
|
||||
2>> "makecerts.log" 1>&2'
|
||||
|
||||
printf "\nConvert revoked certificate to SPC format\n" >> "makecerts.log"
|
||||
$OPENSSL crl2pkcs7 -in tmp/CACertCRL.pem -certfile tmp/revoked.pem -outform DER -out tmp/revoked.spc \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
|
||||
printf "\nGenerate CSP Cross-Certificate\n" >> "makecerts.log"
|
||||
$OPENSSL genrsa -out demoCA/cross.key \
|
||||
2>> "makecerts.log" 1>&2
|
||||
TZ=GMT faketime -f '@2018-01-01 00:00:00' /bin/bash -c '
|
||||
script_path=$(pwd)
|
||||
OPENSSL=openssl
|
||||
CONF="${script_path}/openssl_intermediate.cnf"
|
||||
$OPENSSL req -config $CONF -new -x509 -days 900 -key demoCA/cross.key -out tmp/crosscert.pem \
|
||||
-subj "/C=PL/O=osslsigncode/OU=CSP/CN=crosscert/emailAddress=osslsigncode@example.com" \
|
||||
2>> "makecerts.log" 1>&2'
|
||||
test_result $?
|
||||
|
||||
printf "\nGenerate code signing certificate\n" >> "makecerts.log"
|
||||
$OPENSSL req -config $CONF -new -key demoCA/private.key -passin pass:$password -out demoCA/cert.csr \
|
||||
-subj "/C=PL/ST=Mazovia Province/L=Warsaw/O=osslsigncode/OU=CSP/CN=Certificate/emailAddress=osslsigncode@example.com" \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
$OPENSSL ca -config $CONF -batch -in demoCA/cert.csr -out demoCA/cert.cer \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
$OPENSSL x509 -in demoCA/cert.cer -out tmp/cert.pem \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
|
||||
printf "\nConvert the key to DER format\n" >> "makecerts.log"
|
||||
$OPENSSL rsa -in tmp/key.pem -outform DER -out tmp/key.der -passout pass:$password \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
|
||||
printf "\nConvert the key to PVK format\n" >> "makecerts.log"
|
||||
$OPENSSL rsa -in tmp/key.pem -outform PVK -out tmp/key.pvk -pvk-none \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
|
||||
printf "\nConvert the certificate to DER format\n" >> "makecerts.log"
|
||||
$OPENSSL x509 -in tmp/cert.pem -outform DER -out tmp/cert.der \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
|
||||
printf "\nAttach intermediate certificate to code signing certificate\n" >> "makecerts.log"
|
||||
cat tmp/intermediate.pem >> tmp/cert.pem
|
||||
|
||||
printf "\nConvert the certificate to SPC format\n" >> "makecerts.log"
|
||||
$OPENSSL crl2pkcs7 -nocrl -certfile tmp/cert.pem -outform DER -out tmp/cert.spc \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
|
||||
printf "\nConvert the certificate and the key into a PKCS#12 container\n" >> "makecerts.log"
|
||||
$OPENSSL pkcs12 -export -in tmp/cert.pem -inkey tmp/key.pem -out tmp/cert.p12 -passout pass:$password \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
|
||||
printf "\nGenerate expired certificate\n" >> "makecerts.log"
|
||||
$OPENSSL req -config $CONF -new -key demoCA/private.key -passin pass:$password -out demoCA/expired.csr \
|
||||
-subj "/C=PL/ST=Mazovia Province/L=Warsaw/O=osslsigncode/OU=CSP/CN=Expired/emailAddress=osslsigncode@example.com" \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
$OPENSSL ca -config $CONF -enddate "190101000000Z" -batch -in demoCA/expired.csr -out demoCA/expired.cer \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
$OPENSSL x509 -in demoCA/expired.cer -out tmp/expired.pem \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
|
||||
printf "\nAttach intermediate certificate to expired certificate\n" >> "makecerts.log"
|
||||
cat tmp/intermediate.pem >> tmp/expired.pem
|
||||
|
||||
# copy new files
|
||||
if test -s tmp/intermediate.pem -a -s tmp/CACert.pem -a -s tmp/CACertCRL.pem \
|
||||
-a -s tmp/key.pem -a -s tmp/keyp.pem -a -s tmp/key.der -a -s tmp/key.pvk \
|
||||
-a -s tmp/cert.pem -a -s tmp/cert.p12 -a -s tmp/cert.der -a -s tmp/cert.spc \
|
||||
-a -s tmp/crosscert.pem -a -s tmp/expired.pem -a -s tmp/revoked.pem -a -s tmp/revoked.spc
|
||||
then
|
||||
cp tmp/* ./
|
||||
printf "%s\n" "keys & certificates successfully generated"
|
||||
printf "%s\n" "makecerts.sh finished"
|
||||
rm -f "makecerts.log"
|
||||
else
|
||||
printf "%s\n" "makecerts.sh failed"
|
||||
printf "%s\n" "error logs ${result_path}/makecerts.log"
|
||||
result=1
|
||||
fi
|
||||
|
||||
# remove the working directory
|
||||
rm -rf "demoCA/"
|
||||
rm -rf "tmp/"
|
||||
|
||||
# restore settings
|
||||
LD_LIBRARY_PATH=$TEMP_LD_LIBRARY_PATH
|
||||
|
||||
exit $result
|
||||
}
|
||||
|
||||
# Tests requirement
|
||||
if test -n "$(command -v faketime)"
|
||||
then
|
||||
make_certs $1
|
||||
result=$?
|
||||
else
|
||||
printf "%s\n" "faketime not found in \$PATH"
|
||||
printf "%s\n" "tests skipped, please install faketime package"
|
||||
result=1
|
||||
fi
|
||||
|
||||
exit $result
|
@ -1,61 +0,0 @@
|
||||
# OpenSSL root CA configuration file
|
||||
|
||||
[ ca ]
|
||||
default_ca = CA_default
|
||||
|
||||
[ CA_default ]
|
||||
# Directory and file locations.
|
||||
dir = .
|
||||
certs = $dir/demoCA
|
||||
crl_dir = $dir/demoCA
|
||||
new_certs_dir = $dir/demoCA
|
||||
database = $dir/demoCA/index.txt
|
||||
serial = $dir/demoCA/serial
|
||||
crl_extensions = crl_ext
|
||||
default_md = sha256
|
||||
preserve = no
|
||||
policy = policy_match
|
||||
x509_extensions = usr_cert
|
||||
private_key = $dir/demoCA/CA.key
|
||||
certificate = $dir/tmp/CACert.pem
|
||||
default_startdate = 180101000000Z
|
||||
default_enddate = 210101000000Z
|
||||
|
||||
[ req ]
|
||||
encrypt_key = no
|
||||
default_bits = 2048
|
||||
default_md = sha256
|
||||
string_mask = utf8only
|
||||
x509_extensions = ca_extensions
|
||||
distinguished_name = req_distinguished_name
|
||||
|
||||
[ crl_ext ]
|
||||
authorityKeyIdentifier = keyid:always
|
||||
|
||||
[ usr_cert ]
|
||||
basicConstraints = CA:FALSE
|
||||
subjectKeyIdentifier = hash
|
||||
authorityKeyIdentifier = keyid, issuer
|
||||
extendedKeyUsage = codeSigning
|
||||
|
||||
[ ca_extensions ]
|
||||
basicConstraints = critical, CA:true
|
||||
subjectKeyIdentifier = hash
|
||||
authorityKeyIdentifier = keyid:always,issuer
|
||||
keyUsage = critical, digitalSignature, cRLSign, keyCertSign
|
||||
|
||||
[ policy_match ]
|
||||
countryName = match
|
||||
organizationName = match
|
||||
organizationalUnitName = optional
|
||||
commonName = supplied
|
||||
emailAddress = optional
|
||||
|
||||
[ req_distinguished_name ]
|
||||
countryName = Country Name (2 letter code)
|
||||
stateOrProvinceName = State or Province Name
|
||||
localityName = Locality Name
|
||||
0.organizationName = Organization Name
|
||||
organizationalUnitName = Organizational Unit Name
|
||||
commonName = Common Name
|
||||
emailAddress = Email Address
|
1
tests/certs/password.txt
Normal file
1
tests/certs/password.txt
Normal file
@ -0,0 +1 @@
|
||||
passme
|
45
tests/certs/revoked.pem
Normal file
45
tests/certs/revoked.pem
Normal file
@ -0,0 +1,45 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDvTCCAqWgAwIBAgIUOpY5wp7DtqsdxII7sxculedk0PYwDQYJKoZIhvcNAQEL
|
||||
BQAwYDELMAkGA1UEBhMCUEwxFTATBgNVBAoMDG9zc2xzaWduY29kZTEgMB4GA1UE
|
||||
CwwXQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxGDAWBgNVBAMMD0ludGVybWVkaWF0
|
||||
ZSBDQTAeFw0xODAxMDEwMDAwMDBaFw0yNDEyMzEwMDAwMDBaMG0xCzAJBgNVBAYT
|
||||
AlBMMRUwEwYDVQQKDAxvc3Nsc2lnbmNvZGUxDDAKBgNVBAsMA0NTUDEQMA4GA1UE
|
||||
AwwHUmV2b2tlZDEnMCUGCSqGSIb3DQEJARYYb3NzbHNpZ25jb2RlQGV4YW1wbGUu
|
||||
Y29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsksndW3LaWAnD7mi
|
||||
4BXhmqQjC99Y9wTvMPUJ9AgvbzTaNW4JJOQ31x8VVgwoUQ8nFBYkAqgLOv9THzNi
|
||||
30Fc7mjf37Pu6YsqZzql+tknqQbiaysyNm/fouwJDJ+NRzU70fVqI5AS9FBjakXa
|
||||
/l1+pEysCofURJAcKCBQGMSVaP2gwVrHyPI7snFPO6205vqaEOarPira7gvBkYeU
|
||||
Gh+A4AHngyW/jXHt0OHzmL+NrJe5hiayNHAK4ECfXj4PbMibI8PHlRpQkkzO6OhC
|
||||
uI5ngpTZ0dGDLT693tlusvWRFjVrHI1D6MGTtQeeVlnYIKSEGhkgzp7PeWM/CCty
|
||||
mDRG1wIDAQABo2IwYDAJBgNVHRMEAjAAMB0GA1UdDgQWBBQHE8SzT1ZcPEapv4NZ
|
||||
MWBxRB3QATAfBgNVHSMEGDAWgBSeBawLW+FAf2oO9NlET4onfe84izATBgNVHSUE
|
||||
DDAKBggrBgEFBQcDAzANBgkqhkiG9w0BAQsFAAOCAQEAYVJiPrkACW/tK487fYS/
|
||||
gYzU3fYVCTfHpAv3njarNzy8UBNqBYr0kDg0DLoOWqGV7ogTtlbQP4IIjAQI/kW6
|
||||
cEreW8yU5VxO+kxDo+7oG9VEbR85i6kQW2ubJsXV6yBtf5aAbXEqImYrtjh7UObb
|
||||
BbQiUI1ll2dXWqvZGxr3Fz1uz8nPMYlBpVjpCh6JF8otdWwABmxRnqUvoLO6BZbH
|
||||
/gdUkouXfio9BlWkWaJXJGXMW8B7ozpjuCHSHyfvGKDA3YIfa7++A1BIKxW72jIF
|
||||
jRJDw/rwnV59tiEcBWmp2T6vV+rD8yaS+LotRPYD/ck/jEj/mV+N077KLmuZpdJF
|
||||
ag==
|
||||
-----END CERTIFICATE-----
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDrDCCApSgAwIBAgIUUPCDF21g2spK7557HZUhqSxBltMwDQYJKoZIhvcNAQEL
|
||||
BQAwWDELMAkGA1UEBhMCUEwxFTATBgNVBAoMDG9zc2xzaWduY29kZTEgMB4GA1UE
|
||||
CwwXQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxEDAOBgNVBAMMB1Jvb3QgQ0EwHhcN
|
||||
MTgwMTAxMDAwMDAwWhcNMjYwMTAxMDAwMDAwWjBgMQswCQYDVQQGEwJQTDEVMBMG
|
||||
A1UECgwMb3NzbHNpZ25jb2RlMSAwHgYDVQQLDBdDZXJ0aWZpY2F0aW9uIEF1dGhv
|
||||
cml0eTEYMBYGA1UEAwwPSW50ZXJtZWRpYXRlIENBMIIBIjANBgkqhkiG9w0BAQEF
|
||||
AAOCAQ8AMIIBCgKCAQEAyMs1XoC0NUT5YgydibOrE5SWBKk5C47B6tv6gA4t3zZJ
|
||||
wejaiPkj+aTIU3Ww5DO/Gpz0GuqCHNBczIw92Cfvv8kyWzUy46bRkpBJLFav0JXS
|
||||
B3xQaPlHWeXqMfVAGuM5ExT4CjjYKFsrgV1Q300thCHBhvr8TPekDIf+6J7NSz1P
|
||||
062pYgypfqsA8OwKaQbgOL9v4QRmHoolnEDc1dK/FS4f3p9dlifl7kcSVGQK0yit
|
||||
7Uncn250icCxMxS3MOE2NfuplUOSN6h6poWNGUsx00O7Dy9nUndUwJRpFfKXTV3v
|
||||
GtlmFLNoho+ss/usnxjxggWBcRtKhqd8nGSJUlzs0wIDAQABo2YwZDASBgNVHRMB
|
||||
Af8ECDAGAQH/AgEAMB0GA1UdDgQWBBSeBawLW+FAf2oO9NlET4onfe84izAfBgNV
|
||||
HSMEGDAWgBTp7DHcMiltHw6m0SYMWVg0QtGo/jAOBgNVHQ8BAf8EBAMCAYYwDQYJ
|
||||
KoZIhvcNAQELBQADggEBAD/FBa4stJGd/Acg2E2soI071B/l9B7FiqIRpCFuLVC4
|
||||
1m7TIcjioIpZrxXwE1Egf8A9/6D/kKZtWnOljcxtPBEb+1/gB61M381RIgoMQ/Pf
|
||||
7XX2yakk6mscUjbSTR//Mj1sYOs2r6ueZBp0whzF9nVvA43G6WMpf6XZqmhlg/oV
|
||||
ynytW1Iu1SPoru3y8dX/lsukvKCak7MAp1eBcuUJxS56DnKcV9xgC30m3g+CErI3
|
||||
qsOJ7lcfDP6fDjy7MfBsZBiY64MqwlDjjn7+Pleo69JedMwurHLhKnfm07DBPy8X
|
||||
+EnQk61xHEjQtTsddXyQGQV3yjqylOF2AgsAf256uuA=
|
||||
-----END CERTIFICATE-----
|
BIN
tests/certs/revoked.spc
Normal file
BIN
tests/certs/revoked.spc
Normal file
Binary file not shown.
50
tests/certs/tsa-chain.pem
Normal file
50
tests/certs/tsa-chain.pem
Normal file
@ -0,0 +1,50 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIEzTCCA7WgAwIBAgIUfRjXKciCGA4XbhbhxbAwfpcLGmowDQYJKoZIhvcNAQEL
|
||||
BQAwYDELMAkGA1UEBhMCUEwxFTATBgNVBAoMDG9zc2xzaWduY29kZTEkMCIGA1UE
|
||||
CwwbVGltZXN0YW1wIEF1dGhvcml0eSBSb290IENBMRQwEgYDVQQDDAtUU0EgUm9v
|
||||
dCBDQTAeFw0xODAxMDEwMDAwMDBaFw0yODAxMDEwMDAwMDBaMFUxCzAJBgNVBAYT
|
||||
AlBMMRUwEwYDVQQKDAxvc3Nsc2lnbmNvZGUxHDAaBgNVBAsME1RpbWVzdGFtcCBB
|
||||
dXRob3JpdHkxETAPBgNVBAMMCFRlc3QgVFNBMIIBIjANBgkqhkiG9w0BAQEFAAOC
|
||||
AQ8AMIIBCgKCAQEAor220wp2zqj6Fe1VT/yic4LJcfMn1/ZWhsE7L86krULRvI+N
|
||||
JY0fOVg/24MtyOXbnm7nYOyYTlR9n2kqm4fEgsz+GDQxXLHgyLh3aF4ueDzoFt0v
|
||||
8G3vJfD+4N27XAYJ5V4f4s4VJRDIm0P/BvFGY9J/zICjC83F3OLdnkOD88O8QD6q
|
||||
FwWdtBYNqxQX1LAwy3ORe5aTubdVkHV02JhdKAC/xy5nfhynuV4KfYyel2nHrI1i
|
||||
54UXWdOrlD/XIKPiXpuEGcXhYTrTHigH+yR9ybs9hotGvuHTEjcxEuJvEQJX+qV4
|
||||
eJAIexITDW/yK+maWPLijO3bZ9/JodX+fRCnPQIDAQABo4IBiDCCAYQwDAYDVR0T
|
||||
AQH/BAIwADAWBgNVHSUBAf8EDDAKBggrBgEFBQcDCDAdBgNVHQ4EFgQUKWCqogni
|
||||
6SseJ/P6LXo0M2cK++QwHwYDVR0jBBgwFoAU/5nNuG4Tm4v2y9uKf428/4fVQesw
|
||||
gYQGCCsGAQUFBwEBBHgwdjA5BggrBgEFBQcwAoYtaHR0cDovL1RTQUNBLnRpbWVz
|
||||
dGFtcGF1dGhvcml0eS5jb20vVFNBQ0EuY3J0MDkGCCsGAQUFBzABhi1odHRwOi8v
|
||||
b2NzcC5UU0FDQS50aW1lc3RhbXBhdXRob3JpdHkuY29tOjkwODAwPgYDVR0fBDcw
|
||||
NTAzoDGgL4YtaHR0cDovL1RTQUNBLnRpbWVzdGFtcGF1dGhvcml0eS5jb20vVFNB
|
||||
Q0EuY3JsMFUGA1UdHgROMEygGDAKggh0ZXN0LmNvbTAKggh0ZXN0Lm9yZ6EwMAqH
|
||||
CAAAAAAAAAAAMCKHIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMA0G
|
||||
CSqGSIb3DQEBCwUAA4IBAQB4YXa5nVWUzWSsUDMfYFTEETOe8boUErwfrDNBuj6z
|
||||
B5en20FhI49i6PCYEfNq3vrAtPOEFJj+KPomN3C46VLxbUEvqWLdq6EyzWvVVmXK
|
||||
VLeC0qV0m6CFM8GplaWzZdfFTQaaLUhgY08ZU2gp4QsoS2YjAosxlZrNSm6pBbv3
|
||||
q+Og1KeSK8gKS0V89k+6e3LOEF6KaNWKSkoz5xDniQY//mTjiDcNmYUh0KhHfhdU
|
||||
eO92M82uJSaDqnRs5HsWPs6z6qdfpuvj++OtQ1VCM2p5SEH2sEomdeN3YYChuG4h
|
||||
yzn0mYAdbTyGJHlFm17AH+SQRbVqCKYdHDaqsMb+fWzi
|
||||
-----END CERTIFICATE-----
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDkDCCAnigAwIBAgIUJ0nfE+EVsIThltlY2LHVWMJVIq4wDQYJKoZIhvcNAQEL
|
||||
BQAwYDELMAkGA1UEBhMCUEwxFTATBgNVBAoMDG9zc2xzaWduY29kZTEkMCIGA1UE
|
||||
CwwbVGltZXN0YW1wIEF1dGhvcml0eSBSb290IENBMRQwEgYDVQQDDAtUU0EgUm9v
|
||||
dCBDQTAeFw0xNzAxMDEwMDAwMDBaFw0yNjExMTAwMDAwMDBaMGAxCzAJBgNVBAYT
|
||||
AlBMMRUwEwYDVQQKDAxvc3Nsc2lnbmNvZGUxJDAiBgNVBAsMG1RpbWVzdGFtcCBB
|
||||
dXRob3JpdHkgUm9vdCBDQTEUMBIGA1UEAwwLVFNBIFJvb3QgQ0EwggEiMA0GCSqG
|
||||
SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDGOTX1f9dmtUiyzlsUInRIGfRMya338SVx
|
||||
vYGeOwdpTSSGlYUVwR9AuFewQF5+klelstCJe+SoUG0AdzS30mRWlQrhip4UdvdW
|
||||
T2gkNKbSn6DQzlWoQej9izqRLxAsbuszgkvnLOBEmPaLimDsCgu0bAN95Hp0Hls9
|
||||
O/fVmzh8VuV4iscxc7q13ZB7CylWgwd55CFEGd/jpJ6kMwSHbOLoBWp4GQ3KxR+c
|
||||
ASAo0FapU2WSZB2EYWszRiyq91X+AvIYN4ypTv7RccgfUvnZ2qFykJAkf/wgkynu
|
||||
Qg7rCUNfUEpDc7jlqtDWR7iLrtHBkA17C3IU8ymmKQYWfw3ZyBwvAgMBAAGjQjBA
|
||||
MA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFP+ZzbhuE5uL9svbin+NvP+H1UHr
|
||||
MA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsFAAOCAQEAbj3aFwIUxvzwgywO
|
||||
gj01JM8GNbw1E4MGdkaNI8rgeY8ay15ZXhR9NpRWWb6Y7IXPq5XhuEktVte5Z4Kf
|
||||
XLBrr7Xe9VVqJL9zd1tMzOEM/zG77rZf/iXBTZLkCtQc/GOEY4TTWKNEl5hiWVE0
|
||||
po97GX5XHoeyHlWQ75sd9z6MxFxmvdp9/uyYD700e9sd5gcD8LGvHw2DNy8vntYV
|
||||
ia9h95N9i1umffxU460o8W5GoIcsD13B3YftvnWhGSXqovBRFgcPAQZ4eW9Qh/zA
|
||||
4zQBQrRvmREPihXVdgtWVpbRchP99oSZBrYr7Hh/P69rycklquqxJl1ol1wbT6dK
|
||||
S5Gmng==
|
||||
-----END CERTIFICATE-----
|
260
tests/conf/makecerts.sh
Executable file
260
tests/conf/makecerts.sh
Executable file
@ -0,0 +1,260 @@
|
||||
#!/bin/sh
|
||||
|
||||
result=0
|
||||
|
||||
test_result() {
|
||||
if test "$1" -eq 0
|
||||
then
|
||||
printf "Succeeded\n" >> "makecerts.log"
|
||||
else
|
||||
printf "Failed\n" >> "makecerts.log"
|
||||
fi
|
||||
}
|
||||
|
||||
make_certs() {
|
||||
password=passme
|
||||
result_path=$(pwd)
|
||||
cd $(dirname "$0")
|
||||
script_path=$(pwd)
|
||||
cd "${result_path}"
|
||||
mkdir "tmp/"
|
||||
rm -rf "../certs"
|
||||
|
||||
# OpenSSL settings
|
||||
CONF="${script_path}/openssl_intermediate.cnf"
|
||||
if test -n "$1"
|
||||
then
|
||||
OPENSSL="$1/bin/openssl"
|
||||
export LD_LIBRARY_PATH="$1/lib:$1/lib64"
|
||||
else
|
||||
OPENSSL=openssl
|
||||
fi
|
||||
|
||||
mkdir "CA/" 2>> "makecerts.log" 1>&2
|
||||
touch "CA/index.txt"
|
||||
echo -n "unique_subject = no" > "CA/index.txt.attr"
|
||||
$OPENSSL rand -hex 16 > "CA/serial"
|
||||
$OPENSSL rand -hex 16 > "tsa-serial"
|
||||
echo 1001 > "CA/crlnumber"
|
||||
date > "makecerts.log"
|
||||
"$OPENSSL" version 2>> "makecerts.log" 1>&2
|
||||
echo -n "$password" > tmp/password.txt
|
||||
|
||||
printf "\nGenerate root CA certificate\n" >> "makecerts.log"
|
||||
"$OPENSSL" genrsa -out CA/CA.key \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
TZ=GMT faketime -f '@2017-01-01 00:00:00' /bin/bash -c '
|
||||
script_path=$(pwd)
|
||||
OPENSSL="$0"
|
||||
export LD_LIBRARY_PATH="$1"
|
||||
CONF="${script_path}/openssl_root.cnf"
|
||||
"$OPENSSL" req -config "$CONF" -new -x509 -days 3600 -key CA/CA.key -out tmp/CACert.pem \
|
||||
-subj "/C=PL/O=osslsigncode/OU=Certification Authority/CN=Root CA" \
|
||||
2>> "makecerts.log" 1>&2' "$OPENSSL" "$LD_LIBRARY_PATH"
|
||||
test_result $?
|
||||
|
||||
printf "\nGenerate intermediate CA certificate\n" >> "makecerts.log"
|
||||
"$OPENSSL" genrsa -out CA/intermediate.key \
|
||||
2>> "makecerts.log" 1>&2
|
||||
TZ=GMT faketime -f '@2017-01-01 00:00:00' /bin/bash -c '
|
||||
script_path=$(pwd)
|
||||
OPENSSL="$0"
|
||||
export LD_LIBRARY_PATH="$1"
|
||||
CONF="${script_path}/openssl_intermediate.cnf"
|
||||
"$OPENSSL" req -config "$CONF" -new -key CA/intermediate.key -out CA/intermediate.csr \
|
||||
-subj "/C=PL/O=osslsigncode/OU=Certification Authority/CN=Intermediate CA" \
|
||||
2>> "makecerts.log" 1>&2' "$OPENSSL" "$LD_LIBRARY_PATH"
|
||||
test_result $?
|
||||
TZ=GMT faketime -f '@2017-01-01 00:00:00' /bin/bash -c '
|
||||
script_path=$(pwd)
|
||||
OPENSSL="$0"
|
||||
export LD_LIBRARY_PATH="$1"
|
||||
CONF="${script_path}/openssl_root.cnf"
|
||||
"$OPENSSL" ca -config "$CONF" -batch -in CA/intermediate.csr -out CA/intermediate.cer \
|
||||
2>> "makecerts.log" 1>&2' "$OPENSSL" "$LD_LIBRARY_PATH"
|
||||
test_result $?
|
||||
"$OPENSSL" x509 -in CA/intermediate.cer -out tmp/intermediate.pem \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
|
||||
printf "\nGenerate private RSA encrypted key\n" >> "makecerts.log"
|
||||
"$OPENSSL" genrsa -des3 -out CA/private.key -passout pass:"$password" \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
cat CA/private.key >> tmp/keyp.pem 2>> "makecerts.log"
|
||||
test_result $?
|
||||
|
||||
printf "\nGenerate private RSA decrypted key\n" >> "makecerts.log"
|
||||
"$OPENSSL" rsa -in CA/private.key -passin pass:"$password" -out tmp/key.pem \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
|
||||
printf "\nGenerate a certificate to revoke\n" >> "makecerts.log"
|
||||
"$OPENSSL" req -config "$CONF" -new -key CA/private.key -passin pass:"$password" -out CA/revoked.csr \
|
||||
-subj "/C=PL/O=osslsigncode/OU=CSP/CN=Revoked/emailAddress=osslsigncode@example.com" \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
"$OPENSSL" ca -config "$CONF" -batch -in CA/revoked.csr -out CA/revoked.cer \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
"$OPENSSL" x509 -in CA/revoked.cer -out tmp/revoked.pem \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
|
||||
printf "\nRevoke above certificate\n" >> "makecerts.log"
|
||||
"$OPENSSL" ca -config "$CONF" -revoke CA/revoked.cer \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
|
||||
printf "\nAttach intermediate certificate to revoked certificate\n" >> "makecerts.log"
|
||||
cat tmp/intermediate.pem >> tmp/revoked.pem 2>> "makecerts.log"
|
||||
test_result $?
|
||||
|
||||
printf "\nGenerate CRL file\n" >> "makecerts.log"
|
||||
TZ=GMT faketime -f '@2019-01-01 00:00:00' /bin/bash -c '
|
||||
script_path=$(pwd)
|
||||
OPENSSL="$0"
|
||||
export LD_LIBRARY_PATH="$1"
|
||||
CONF="${script_path}/openssl_intermediate.cnf"
|
||||
"$OPENSSL" ca -config "$CONF" -gencrl -crldays 8766 -out tmp/CACertCRL.pem \
|
||||
2>> "makecerts.log" 1>&2' "$OPENSSL" "$LD_LIBRARY_PATH"
|
||||
test_result $?
|
||||
|
||||
printf "\nConvert revoked certificate to SPC format\n" >> "makecerts.log"
|
||||
"$OPENSSL" crl2pkcs7 -in tmp/CACertCRL.pem -certfile tmp/revoked.pem -outform DER -out tmp/revoked.spc \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
|
||||
printf "\nGenerate CSP Cross-Certificate\n" >> "makecerts.log"
|
||||
"$OPENSSL" genrsa -out CA/cross.key \
|
||||
2>> "makecerts.log" 1>&2
|
||||
TZ=GMT faketime -f '@2018-01-01 00:00:00' /bin/bash -c '
|
||||
script_path=$(pwd)
|
||||
OPENSSL="$0"
|
||||
export LD_LIBRARY_PATH="$1"
|
||||
CONF="${script_path}/openssl_intermediate.cnf"
|
||||
"$OPENSSL" req -config "$CONF" -new -x509 -days 900 -key CA/cross.key -out tmp/crosscert.pem \
|
||||
-subj "/C=PL/O=osslsigncode/OU=CSP/CN=crosscert/emailAddress=osslsigncode@example.com" \
|
||||
2>> "makecerts.log" 1>&2' "$OPENSSL" "$LD_LIBRARY_PATH"
|
||||
test_result $?
|
||||
|
||||
printf "\nGenerate code signing certificate\n" >> "makecerts.log"
|
||||
"$OPENSSL" req -config "$CONF" -new -key CA/private.key -passin pass:"$password" -out CA/cert.csr \
|
||||
-subj "/C=PL/ST=Mazovia Province/L=Warsaw/O=osslsigncode/OU=CSP/CN=Certificate/emailAddress=osslsigncode@example.com" \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
"$OPENSSL" ca -config "$CONF" -batch -in CA/cert.csr -out CA/cert.cer \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
"$OPENSSL" x509 -in CA/cert.cer -out tmp/cert.pem \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
|
||||
printf "\nConvert the key to DER format\n" >> "makecerts.log"
|
||||
"$OPENSSL" rsa -in tmp/key.pem -outform DER -out tmp/key.der -passout pass:"$password" \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
|
||||
printf "\nConvert the key to PVK format\n" >> "makecerts.log"
|
||||
"$OPENSSL" rsa -in tmp/key.pem -outform PVK -out tmp/key.pvk -pvk-none \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
|
||||
printf "\nConvert the certificate to DER format\n" >> "makecerts.log"
|
||||
"$OPENSSL" x509 -in tmp/cert.pem -outform DER -out tmp/cert.der \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
|
||||
printf "\nAttach intermediate certificate to code signing certificate\n" >> "makecerts.log"
|
||||
cat tmp/intermediate.pem >> tmp/cert.pem 2>> "makecerts.log"
|
||||
test_result $?
|
||||
|
||||
printf "\nConvert the certificate to SPC format\n" >> "makecerts.log"
|
||||
"$OPENSSL" crl2pkcs7 -nocrl -certfile tmp/cert.pem -outform DER -out tmp/cert.spc \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
|
||||
printf "\nConvert the certificate and the key into a PKCS#12 container\n" >> "makecerts.log"
|
||||
"$OPENSSL" pkcs12 -export -in tmp/cert.pem -inkey tmp/key.pem -out tmp/cert.p12 -passout pass:"$password" \
|
||||
-keypbe aes-256-cbc -certpbe aes-256-cbc \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
|
||||
printf "\nGenerate expired certificate\n" >> "makecerts.log"
|
||||
"$OPENSSL" req -config "$CONF" -new -key CA/private.key -passin pass:"$password" -out CA/expired.csr \
|
||||
-subj "/C=PL/ST=Mazovia Province/L=Warsaw/O=osslsigncode/OU=CSP/CN=Expired/emailAddress=osslsigncode@example.com" \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
"$OPENSSL" ca -config "$CONF" -enddate "190101000000Z" -batch -in CA/expired.csr -out CA/expired.cer \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
"$OPENSSL" x509 -in CA/expired.cer -out tmp/expired.pem \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
|
||||
printf "\nAttach intermediate certificate to expired certificate\n" >> "makecerts.log"
|
||||
cat tmp/intermediate.pem >> tmp/expired.pem 2>> "makecerts.log"
|
||||
test_result $?
|
||||
|
||||
printf "\nGenerate Root CA TSA certificate\n" >> "makecerts.log"
|
||||
"$OPENSSL" genrsa -out CA/TSACA.key \
|
||||
2>> "makecerts.log" 1>&2
|
||||
TZ=GMT faketime -f '@2017-01-01 00:00:00' /bin/bash -c '
|
||||
script_path=$(pwd)
|
||||
OPENSSL="$0"
|
||||
export LD_LIBRARY_PATH="$1"
|
||||
CONF="${script_path}/openssl_tsa_root.cnf"
|
||||
"$OPENSSL" req -config "$CONF" -new -x509 -days 3600 -key CA/TSACA.key -out tmp/TSACA.pem \
|
||||
2>> "makecerts.log" 1>&2' "$OPENSSL" "$LD_LIBRARY_PATH"
|
||||
test_result $?
|
||||
|
||||
printf "\nGenerate TSA certificate\n" >> "makecerts.log"
|
||||
CONF="${script_path}/openssl_tsa.cnf"
|
||||
"$OPENSSL" req -config "$CONF" -new -nodes -keyout tmp/TSA.key -out CA/TSA.csr \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
CONF="${script_path}/openssl_tsa_root.cnf"
|
||||
"$OPENSSL" ca -config "$CONF" -batch -in CA/TSA.csr -out CA/TSA.cer \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
"$OPENSSL" x509 -in CA/TSA.cer -out tmp/TSA.pem \
|
||||
2>> "makecerts.log" 1>&2
|
||||
test_result $?
|
||||
|
||||
printf "\nSave the chain to be included in the TSA response\n" >> "makecerts.log"
|
||||
cat tmp/TSA.pem tmp/TSACA.pem > tmp/tsa-chain.pem 2>> "makecerts.log"
|
||||
|
||||
# copy new files
|
||||
if test -s tmp/intermediate.pem -a -s tmp/CACert.pem -a -s tmp/CACertCRL.pem \
|
||||
-a -s tmp/key.pem -a -s tmp/keyp.pem -a -s tmp/key.der -a -s tmp/key.pvk \
|
||||
-a -s tmp/cert.pem -a -s tmp/cert.p12 -a -s tmp/cert.der -a -s tmp/cert.spc \
|
||||
-a -s tmp/crosscert.pem -a -s tmp/expired.pem -a -s tmp/revoked.pem -a -s tmp/revoked.spc \
|
||||
-a -s tmp/TSA.pem -a -s tmp/TSA.key -a -s tmp/tsa-chain.pem
|
||||
then
|
||||
mkdir "../certs"
|
||||
cp tmp/* ../certs
|
||||
printf "%s" "keys & certificates successfully generated"
|
||||
else
|
||||
printf "%s" "error logs ${result_path}/makecerts.log"
|
||||
result=1
|
||||
fi
|
||||
|
||||
# remove the working directory
|
||||
rm -rf "CA/"
|
||||
rm -rf "tmp/"
|
||||
|
||||
exit "$result"
|
||||
}
|
||||
|
||||
# Tests requirement
|
||||
if test -n "$(command -v faketime)"
|
||||
then
|
||||
make_certs "$1"
|
||||
result=$?
|
||||
else
|
||||
printf "%s" "faketime not found in \$PATH, please install faketime package"
|
||||
result=1
|
||||
fi
|
||||
|
||||
exit "$result"
|
@ -1,18 +1,20 @@
|
||||
# OpenSSL intermediate CA configuration file
|
||||
|
||||
[ ca ]
|
||||
[ default ]
|
||||
name = intermediate
|
||||
default_ca = CA_default
|
||||
|
||||
[ CA_default ]
|
||||
# Directory and file locations
|
||||
dir = .
|
||||
certs = $dir/demoCA
|
||||
crl_dir = $dir/demoCA
|
||||
new_certs_dir = $dir/demoCA
|
||||
database = $dir/demoCA/index.txt
|
||||
serial = $dir/demoCA/serial
|
||||
private_key = $dir/demoCA/intermediate.key
|
||||
certificate = $dir/tmp/intermediate.pem
|
||||
certs = $dir/CA
|
||||
crl_dir = $dir/CA
|
||||
new_certs_dir = $dir/CA
|
||||
database = $dir/CA/index.txt
|
||||
serial = $dir/CA/serial
|
||||
rand_serial = yes
|
||||
private_key = $dir/CA/$name.key
|
||||
certificate = $dir/tmp/$name.pem
|
||||
crl_extensions = crl_ext
|
||||
default_md = sha256
|
||||
preserve = no
|
||||
@ -20,6 +22,8 @@ policy = policy_loose
|
||||
default_startdate = 180101000000Z
|
||||
default_enddate = 241231000000Z
|
||||
x509_extensions = v3_req
|
||||
email_in_dn = yes
|
||||
default_days = 2200
|
||||
|
||||
[ req ]
|
||||
# Options for the `req` tool
|
@ -6,12 +6,13 @@ default_ca = CA_default
|
||||
[ CA_default ]
|
||||
# Directory and file locations.
|
||||
dir = .
|
||||
certs = $dir/demoCA
|
||||
crl_dir = $dir/demoCA
|
||||
new_certs_dir = $dir/demoCA
|
||||
database = $dir/demoCA/index.txt
|
||||
serial = $dir/demoCA/serial
|
||||
private_key = $dir/demoCA/CA.key
|
||||
certs = $dir/CA
|
||||
crl_dir = $dir/CA
|
||||
new_certs_dir = $dir/CA
|
||||
database = $dir/CA/index.txt
|
||||
serial = $dir/CA/serial
|
||||
rand_serial = yes
|
||||
private_key = $dir/CA/CA.key
|
||||
certificate = $dir/tmp/CACert.pem
|
||||
crl_extensions = crl_ext
|
||||
default_md = sha256
|
||||
@ -20,6 +21,9 @@ policy = policy_match
|
||||
default_startdate = 180101000000Z
|
||||
default_enddate = 260101000000Z
|
||||
x509_extensions = v3_intermediate_ca
|
||||
email_in_dn = yes
|
||||
default_days = 3000
|
||||
unique_subject = no
|
||||
|
||||
[ req ]
|
||||
# Options for the `req` tool
|
46
tests/conf/openssl_tsa.cnf
Normal file
46
tests/conf/openssl_tsa.cnf
Normal file
@ -0,0 +1,46 @@
|
||||
# OpenSSL Timestamp Authority configuration file
|
||||
|
||||
oid_section = new_oids
|
||||
|
||||
[ new_oids ]
|
||||
tsa_policy1 = 1.2.3.4.1
|
||||
tsa_policy2 = 1.2.3.4.5.6
|
||||
tsa_policy3 = 1.2.3.4.5.7
|
||||
|
||||
[ req ]
|
||||
# Options for the `req` tool
|
||||
default_bits = 2048
|
||||
encrypt_key = yes
|
||||
default_md = sha256
|
||||
utf8 = yes
|
||||
string_mask = utf8only
|
||||
prompt = no
|
||||
distinguished_name = ca_distinguished_name
|
||||
|
||||
[ ca_distinguished_name ]
|
||||
countryName = "PL"
|
||||
organizationName = "osslsigncode"
|
||||
organizationalUnitName = "Timestamp Authority"
|
||||
commonName = "Test TSA"
|
||||
|
||||
|
||||
# Time Stamping Authority command "openssl-ts"
|
||||
|
||||
[ tsa ]
|
||||
default_tsa = tsa_config
|
||||
|
||||
[ tsa_config ]
|
||||
dir = ./Testing/certs
|
||||
signer_cert = $dir/TSA.pem
|
||||
signer_key = $dir/TSA.key
|
||||
certs = $dir/tsa-chain.pem
|
||||
serial = $dir/tsa-serial
|
||||
default_policy = tsa_policy1
|
||||
other_policies = tsa_policy2, tsa_policy3
|
||||
signer_digest = sha256
|
||||
digests = sha256, sha384, sha512
|
||||
accuracy = secs:1, millisecs:500, microsecs:100
|
||||
ordering = yes
|
||||
tsa_name = yes
|
||||
ess_cert_id_chain = yes
|
||||
ess_cert_id_alg = sha256
|
83
tests/conf/openssl_tsa_root.cnf
Normal file
83
tests/conf/openssl_tsa_root.cnf
Normal file
@ -0,0 +1,83 @@
|
||||
# OpenSSL Root Timestamp Authority configuration file
|
||||
|
||||
[ default ]
|
||||
name = TSACA
|
||||
domain_suffix = timestampauthority.com
|
||||
aia_url = http://$name.$domain_suffix/$name.crt
|
||||
crl_url = http://$name.$domain_suffix/$name.crl
|
||||
ocsp_url = http://ocsp.$name.$domain_suffix:9080
|
||||
name_opt = utf8, esc_ctrl, multiline, lname, align
|
||||
default_ca = CA_default
|
||||
|
||||
[ CA_default ]
|
||||
dir = .
|
||||
certs = $dir/CA
|
||||
crl_dir = $dir/CA
|
||||
new_certs_dir = $dir/CA
|
||||
database = $dir/CA/index.txt
|
||||
serial = $dir/CA/serial
|
||||
crlnumber = $dir/CA/crlnumber
|
||||
rand_serial = yes
|
||||
private_key = $dir/CA/$name.key
|
||||
certificate = $dir/tmp/$name.pem
|
||||
default_md = sha256
|
||||
default_days = 3650
|
||||
default_crl_days = 365
|
||||
policy = policy_match
|
||||
default_startdate = 20180101000000Z
|
||||
default_enddate = 20280101000000Z
|
||||
unique_subject = no
|
||||
x509_extensions = tsa_extensions
|
||||
|
||||
[ policy_match ]
|
||||
countryName = match
|
||||
stateOrProvinceName = optional
|
||||
organizationName = match
|
||||
organizationalUnitName = optional
|
||||
commonName = supplied
|
||||
emailAddress = optional
|
||||
|
||||
[ tsa_extensions ]
|
||||
basicConstraints = critical, CA:false
|
||||
extendedKeyUsage = critical, timeStamping
|
||||
subjectKeyIdentifier = hash
|
||||
authorityKeyIdentifier = keyid:always
|
||||
authorityInfoAccess = @issuer_info
|
||||
crlDistributionPoints = @crl_info
|
||||
nameConstraints = @name_constraints
|
||||
|
||||
[ issuer_info ]
|
||||
caIssuers;URI.0 = $aia_url
|
||||
OCSP;URI.0 = $ocsp_url
|
||||
|
||||
[ crl_info ]
|
||||
URI.0 = $crl_url
|
||||
|
||||
[ name_constraints ]
|
||||
permitted;DNS.0=test.com
|
||||
permitted;DNS.1=test.org
|
||||
excluded;IP.0=0.0.0.0/0.0.0.0
|
||||
excluded;IP.1=0:0:0:0:0:0:0:0/0:0:0:0:0:0:0:0
|
||||
|
||||
[ req ]
|
||||
# Options for the `req` tool
|
||||
default_bits = 2048
|
||||
encrypt_key = yes
|
||||
default_md = sha256
|
||||
utf8 = yes
|
||||
string_mask = utf8only
|
||||
prompt = no
|
||||
distinguished_name = ca_distinguished_name
|
||||
x509_extensions = ca_extensions
|
||||
|
||||
[ ca_distinguished_name ]
|
||||
countryName = "PL"
|
||||
organizationName = "osslsigncode"
|
||||
organizationalUnitName = "Timestamp Authority Root CA"
|
||||
commonName = "TSA Root CA"
|
||||
|
||||
[ ca_extensions ]
|
||||
# Extension to add when the -x509 option is used
|
||||
basicConstraints = critical, CA:true
|
||||
subjectKeyIdentifier = hash
|
||||
keyUsage = critical, keyCertSign, cRLSign
|
BIN
tests/files/unsigned.cat
Executable file
BIN
tests/files/unsigned.cat
Executable file
Binary file not shown.
BIN
tests/files/unsigned.ex_
Normal file
BIN
tests/files/unsigned.ex_
Normal file
Binary file not shown.
BIN
tests/files/unsigned.exe
Executable file
BIN
tests/files/unsigned.exe
Executable file
Binary file not shown.
BIN
tests/files/unsigned.msi
Normal file
BIN
tests/files/unsigned.msi
Normal file
Binary file not shown.
@ -1,53 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Sign a file with a certificate and a private key in the PEM format.
|
||||
# -st 1556668800 is the Unix time of May 1 00:00:00 2019 GMT
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=1
|
||||
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") filetype=CAT; format_nr=1 ;;
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Sign a $filetype$desc file with a certificate and a private key in the PEM format"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"sha256sum" "osslsigncode" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,53 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Sign a file with an encrypted private key in the PEM format.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=2
|
||||
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") filetype=CAT; format_nr=1 ;;
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Sign a $filetype$desc file with an encrypted private key in the PEM format"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/keyp.pem" \
|
||||
-pass passme \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"sha256sum" "osslsigncode" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,54 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Sign a file with an encrypted private key in the DER format.
|
||||
# Requires OpenSSL 1.0.0 or later
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=3
|
||||
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") filetype=CAT; format_nr=1 ;;
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Sign a $filetype$desc file with an encrypted private key in the DER format"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.der" \
|
||||
-pass passme \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"sha256sum" "osslsigncode" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,54 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Sign a file with a certificate in the SPC format
|
||||
# and a private key in the Microsoft Private Key (PVK) format.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=4
|
||||
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") filetype=CAT; format_nr=1 ;;
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Sign a $filetype$desc file with a SPC certificate and a PVK private key"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-spc "${script_path}/../certs/cert.spc" -key "${script_path}/../certs/key.pvk" \
|
||||
-pass passme \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"sha256sum" "osslsigncode" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,53 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Sign a file with a certificate and a key stored in a PKCS#12 container.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=5
|
||||
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") filetype=CAT; format_nr=1 ;;
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Sign a $filetype$desc file with a certificate and a key stored in a PKCS#12 container"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-pkcs12 "${script_path}/../certs/cert.p12" \
|
||||
-pass passme \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"sha256sum" "osslsigncode" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,34 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Checking SHA256 message digests for 01x-05x tests
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
result=0
|
||||
test_nr=6
|
||||
|
||||
for file in ${script_path}/../logs/sha256sum/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
case $name in
|
||||
"cat.log") filetype=CAT; format_nr=1 ;;
|
||||
"msi.log") filetype=MSI; format_nr=2 ;;
|
||||
"ex_.log") filetype=CAB; format_nr=3 ;;
|
||||
"exe.log") filetype=PE; format_nr=4 ;;
|
||||
"ps1.log") filetype=TXT; format_nr=5 ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Checking SHA256 message digests for a $filetype file test"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
if test $(cat "sha256sum/$name" | cut -d' ' -f1 | uniq | wc -l) -ne 1
|
||||
then
|
||||
result=1
|
||||
cat "sha256sum/$name" >> "results.log"
|
||||
printf "Non-unique SHA256 message digests found\n" >> "results.log"
|
||||
fi
|
||||
rm -f "sha256sum/$name"
|
||||
test_result "$result" "$number" "$test_name"
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,61 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Sign a file with Authenticode timestamping
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=7
|
||||
|
||||
if ! grep -q "no libcurl available" "results.log"; then
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") filetype=CAT; format_nr=1 ;;
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Sign a $filetype$desc file with Authenticode timestamping"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-t http://time.certum.pl/ \
|
||||
-t http://timestamp.digicert.com/ \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"UNUSED_PATTERN" "osslsigncode" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
else
|
||||
format_nr=0
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Sign a file with Authenticode timestamping"
|
||||
printf "\n%03d. %s\nTest skipped\n" "$number" "$test_name"
|
||||
fi
|
||||
|
||||
exit 0
|
@ -1,65 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Sign a file with RFC 3161 timestamping
|
||||
# An RFC3161 timestamp server provides an essential function in protecting
|
||||
# data records for the long-term. It provides proof that the data existed
|
||||
# at a particular moment in time and that it has not changed, even by
|
||||
# a single binary bit, since it was notarized and time-stamped.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=8
|
||||
|
||||
if ! grep -q "no libcurl available" "results.log"; then
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") filetype=CAT; format_nr=1 ;;
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Sign a $filetype$desc file with RFC 3161 timestamping"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-ts http://time.certum.pl/ \
|
||||
-ts http://timestamp.digicert.com/ \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"UNUSED_PATTERN" "osslsigncode" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
else
|
||||
format_nr=0
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Sign a file with RFC 3161 timestamping"
|
||||
printf "\n%03d. %s\nTest skipped\n" "$number" "$test_name"
|
||||
fi
|
||||
|
||||
exit 0
|
@ -1,33 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Generate page hashes for a file
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=9
|
||||
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
*) continue ;; # Warning: -ph option is only valid for PE files
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Generate page hashes for a $filetype file"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 -ph \
|
||||
-st "1556668800" \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"UNUSED_PATTERN" "osslsigncode" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,53 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Sign a file with addUnauthenticatedBlob.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=10
|
||||
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") filetype=CAT; format_nr=1 ;;
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Sign a $filetype$desc file with addUnauthenticatedBlob"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-addUnauthenticatedBlob \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"UNUSED_PATTERN" "osslsigncode" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,42 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Sign a file twice with the "nest" flag in the second time
|
||||
# in order to add the new signature instead of replacing the first one.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=11
|
||||
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") continue;; # Warning: CAT files do not support nesting
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1") continue;; # Warning: TXT files do not support nesting
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Sign a $filetype$desc file with the nest flag"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-in "notsigned/$name" -out "signed_$number.$ext"
|
||||
../../osslsigncode sign -h sha512 \
|
||||
-nest \
|
||||
-st "1556668800" \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-in "signed_$number.$ext" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"UNUSED_PATTERN" "osslsigncode" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,54 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Sign a file with a PEM key and a password read from password.txt file.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=12
|
||||
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") filetype=CAT; format_nr=1 ;;
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Sign a $filetype$desc file with a PEM key and a password read from password.txt file"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-addUnauthenticatedBlob \
|
||||
-readpass "${script_path}/../certs/password.txt" \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/keyp.pem" \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"UNUSED_PATTERN" "osslsigncode" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,54 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Sign a file with the certificate and key stored in a PKCS#12 container
|
||||
# and a password read from password.txt file.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=13
|
||||
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") filetype=CAT; format_nr=1 ;;
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Sign a $filetype$desc file with a PKCS#12 container and the file with a password"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-readpass "${script_path}/../certs/password.txt" \
|
||||
-pkcs12 "${script_path}/../certs/cert.p12" \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"UNUSED_PATTERN" "osslsigncode" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,53 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Sign a file with a descryption.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=14
|
||||
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") filetype=CAT; format_nr=1 ;;
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Sign a $filetype$desc file with a descryption"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-n "DESCRYPTION_TEXT" \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"UNUSED_PATTERN" "DESCRYPTION_TEXT" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,54 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Sign a file with specified URL for expanded description of the signed content
|
||||
# https://docs.microsoft.com/en-us/windows-hardware/drivers/install/authenticode-signing-of-csps
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=15
|
||||
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") filetype=CAT; format_nr=1 ;;
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Sign a $filetype$desc file with specified URL"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-i "https://www.osslsigncode.com/" \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"UNUSED_PATTERN" "https://www.osslsigncode.com/" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,58 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Sign a file with Microsoft Commercial Code Signing purpose set for SPC_STATEMENT_TYPE_OBJID
|
||||
# object ID numbers (OIDs) "1.3.6.1.4.1.311.2.1.11"
|
||||
# changes default Microsoft Individual Code Signing:
|
||||
# "0x30, 0x0c, x06, 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x02, 0x01, 0x15"
|
||||
# sets Microsoft Commercial Code Signing:
|
||||
# "0x30, 0x0c, x06, 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x02, 0x01, 0x16"
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=16
|
||||
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") filetype=CAT; format_nr=1 ;;
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Sign a $filetype$desc file with the common purpose set"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-comm \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"UNUSED_PATTERN" "Microsoft Commercial Code Signing" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,55 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Add an additional certificate to the signature block of the file.
|
||||
# https://docs.microsoft.com/en-us/windows-hardware/drivers/install/authenticode-signing-of-csps
|
||||
# https://docs.microsoft.com/en-us/windows/win32/seccertenroll/about-cross-certification
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=17
|
||||
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") filetype=CAT; format_nr=1 ;;
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Add an additional certificate to the signature block of a $filetype$desc file"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-ac "${script_path}/../certs/crosscert.pem" \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"UNUSED_PATTERN" "crosscert" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,52 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Sign a file with MD5 set of cryptographic hash functions.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=21
|
||||
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") filetype=CAT; format_nr=1 ;;
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Sign a $filetype$desc file with MD5 set of cryptographic hash functions"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h md5 \
|
||||
-st "1556668800" \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"UNUSED_PATTERN" "MD5" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,52 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Sign a file with SHA1 set of cryptographic hash functions.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=22
|
||||
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") filetype=CAT; format_nr=1 ;;
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Sign a $filetype$desc file with SHA1 set of cryptographic hash functions"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha1 \
|
||||
-st "1556668800" \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"UNUSED_PATTERN" "SHA1" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,52 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Signing a file with SHA2 set of cryptographic hash functions.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=23
|
||||
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") filetype=CAT; format_nr=1 ;;
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Sign a $filetype$desc file with SHA2 set of cryptographic hash functions"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha2 \
|
||||
-st "1556668800" \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"UNUSED_PATTERN" "SHA2" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,52 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Sign a file with SHA384 set of cryptographic hash functions.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=24
|
||||
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") filetype=CAT; format_nr=1 ;;
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Sign a $filetype$desc file with SHA384 set of cryptographic hash functions"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha384 \
|
||||
-st "1556668800" \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"UNUSED_PATTERN" "SHA384" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,52 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Sign a file with SHA512 set of cryptographic hash functions.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=25
|
||||
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") filetype=CAT; format_nr=1 ;;
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Sign a $filetype$desc file with SHA512 set of cryptographic hash functions"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha512 \
|
||||
-st "1556668800" \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"UNUSED_PATTERN" "SHA512" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,55 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Extract the signature in the PEM format.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=26
|
||||
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") continue;; # Unsupported command
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Extract the PEM signature from the $filetype$desc file"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha512 \
|
||||
-st "1556668800" \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
../../osslsigncode extract-signature \
|
||||
-pem \
|
||||
-in "test_$number.$ext" -out "sign_$format_nr.pem"
|
||||
result=$?
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"sha256sum" "SHA512" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,54 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Extract the signature in the DER format.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=27
|
||||
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") continue;; # Unsupported command
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Extract the DER signature from the $filetype$desc file"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha512 \
|
||||
-st "1556668800" \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
../../osslsigncode extract-signature\
|
||||
-in "test_$number.$ext" -out "sign_$format_nr.der"
|
||||
result=$?
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"sha256sum" "SHA512" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,58 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Attach the DER signature to the file.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=31
|
||||
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") continue;; # Unsupported command
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Attach the DER signature to the $filetype$desc file"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode attach-signature \
|
||||
-sigin "sign_$format_nr.der" \
|
||||
-CAfile "${script_path}/../certs/CACert.pem" \
|
||||
-CRLfile "${script_path}/../certs/CACertCRL.pem" \
|
||||
-TSA-CAfile "${script_path}/../certs/ca-bundle.crt" \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
if test "$result" -ne 0; then
|
||||
cp "sign_$format_nr.der" "sign_$number.der"
|
||||
fi
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"sha256sum" "SHA512" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,58 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Attach the PEM signature to the file.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=32
|
||||
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") continue;; # Unsupported command
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Attach the PEM signature to the $filetype$desc file"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode attach-signature \
|
||||
-sigin "sign_$format_nr.pem" \
|
||||
-CAfile "${script_path}/../certs/CACert.pem" \
|
||||
-CRLfile "${script_path}/../certs/CACertCRL.pem" \
|
||||
-TSA-CAfile "${script_path}/../certs/ca-bundle.crt" \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
if test "$result" -ne 0; then
|
||||
cp "sign_$format_nr.der" "sign_$number.der"
|
||||
fi
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"sha256sum" "SHA512" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,58 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Attach the signature to the signed file.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=33
|
||||
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") continue;; # Unsupported command
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Attach the PEM signature to the signed $filetype$desc file"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-in "notsigned/$name" -out "signed_$number.$ext"
|
||||
../../osslsigncode attach-signature \
|
||||
-sigin "sign_$format_nr.pem" \
|
||||
-CAfile "${script_path}/../certs/CACert.pem" \
|
||||
-CRLfile "${script_path}/../certs/CACertCRL.pem" \
|
||||
-TSA-CAfile "${script_path}/../certs/ca-bundle.crt" \
|
||||
-in "signed_$number.$ext" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"sha256sum" "SHA512" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,44 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Attach the signature to the signed file with the "nest" flag in order to
|
||||
# attach the new signature instead of replacing the first one.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=34
|
||||
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") continue;; # Warning: CAT files do not support nesting
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1") continue;; # Warning: TXT files do not support nesting
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Attach the PEM signature to the signed $filetype$desc file with the nest flag"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-in "notsigned/$name" -out "signed_$number.$ext"
|
||||
../../osslsigncode attach-signature \
|
||||
-sigin "sign_$format_nr.pem" \
|
||||
-nest \
|
||||
-CAfile "${script_path}/../certs/CACert.pem" \
|
||||
-CRLfile "${script_path}/../certs/CACertCRL.pem" \
|
||||
-TSA-CAfile "${script_path}/../certs/ca-bundle.crt" \
|
||||
-in "signed_$number.$ext" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"UNUSED_PATTERN" "SHA512" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,54 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Remove the signature from the file.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=35
|
||||
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") continue;; # Unsupported command
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Remove the signature from the $filetype$desc file"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-in "notsigned/$name" -out "signed_$number.$ext"
|
||||
../../osslsigncode remove-signature \
|
||||
-in "signed_$number.$ext" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "fail" "@2019-09-01 12:00:00" \
|
||||
"UNUSED_PATTERN" "UNUSED_PATTERN" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,34 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Checking SHA256 message digests for "extract" and "attach" tests.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
result=0
|
||||
test_nr=36
|
||||
|
||||
for file in ${script_path}/../logs/sha256sum/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
case $name in
|
||||
"cat.log") filetype=CAT; format_nr=1 ;;
|
||||
"msi.log") filetype=MSI; format_nr=2 ;;
|
||||
"ex_.log") filetype=CAB; format_nr=3 ;;
|
||||
"exe.log") filetype=PE; format_nr=4 ;;
|
||||
"ps1.log") filetype=TXT; format_nr=5 ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Checking SHA256 message digests for a $filetype file test"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
if test $(cat "sha256sum/$name" | cut -d' ' -f1 | uniq | wc -l) -ne 1
|
||||
then
|
||||
result=1
|
||||
cat "sha256sum/$name" >> "results.log"
|
||||
printf "Non-unique SHA256 message digests found\n" >> "results.log"
|
||||
fi
|
||||
rm -f "sha256sum/$name"
|
||||
test_result "$result" "$number" "$test_name"
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,64 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Add an authenticode timestamp to the signed file.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=37
|
||||
|
||||
if ! grep -q "no libcurl available" "results.log"; then
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") filetype=CAT; format_nr=1 ;;
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Add an authenticode timestamp to the $filetype$desc signed file"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-in "notsigned/$name" -out "signed_$number.$ext"
|
||||
../../osslsigncode add \
|
||||
-t http://time.certum.pl/ \
|
||||
-t http://timestamp.digicert.com/ \
|
||||
-verbose \
|
||||
-in "signed_$number.$ext" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"UNUSED_PATTERN" "Timestamp Server Signature" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
else
|
||||
format_nr=0
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Add an authenticode timestamp to the signed file"
|
||||
printf "\n%03d. %s\nTest skipped\n" "$number" "$test_name"
|
||||
fi
|
||||
|
||||
exit 0
|
@ -1,64 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Add a RFC 3161 timestamp to the signed file.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=38
|
||||
|
||||
if ! grep -q "no libcurl available" "results.log"; then
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") filetype=CAT; format_nr=1 ;;
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Add a RFC 3161 timestamp to the $filetype$desc signed file"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-in "notsigned/$name" -out "signed_$number.$ext"
|
||||
../../osslsigncode add \
|
||||
-ts http://time.certum.pl/ \
|
||||
-ts http://timestamp.digicert.com/ \
|
||||
-verbose \
|
||||
-in "signed_$number.$ext" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"UNUSED_PATTERN" "Timestamp Server Signature" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
else
|
||||
format_nr=0
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Add a RFC 3161 timestamp to the signed file"
|
||||
printf "\n%03d. %s\nTest skipped\n" "$number" "$test_name"
|
||||
fi
|
||||
|
||||
exit 0
|
@ -1,55 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Add an unauthenticated blob to the signed file.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=39
|
||||
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") filetype=CAT; format_nr=1 ;;
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Add an unauthenticated blob to the $filetype$desc signed file"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-in "notsigned/$name" -out "signed_$number.$ext"
|
||||
../../osslsigncode add \
|
||||
-addUnauthenticatedBlob \
|
||||
-in "signed_$number.$ext" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"UNUSED_PATTERN" "Unauthenticated Data Blob" "MODIFY"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,51 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Compare the leaf certificate hash against specified SHA256 message digest for the file
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=40
|
||||
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") filetype=CAT; format_nr=1 ;;
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Compare the leaf hash against SHA256 message digest for the $filetype$desc file"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.der" \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_leaf_hash "$result" "$number" "$ext" "@2019-05-01 00:00:00"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,41 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Sign a MSI file with the add-msi-dse option.
|
||||
# MsiDigitalSignatureEx (msi-dse) is an enhanced signature type that can be used
|
||||
# when signing MSI files. In addition to file content, it also hashes some file metadata,
|
||||
# specifically file names, file sizes, creation times and modification times.
|
||||
# https://www.unboundtech.com/docs/UKC/UKC_Code_Signing_IG/HTML/Content/Products/UKC-EKM/UKC_Code_Signing_IG/Sign_Windows_PE_and_msi_Files.htm
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=41
|
||||
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") continue;; # Warning: -add-msi-dse option is only valid for MSI files
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") continue;; # Warning: -add-msi-dse option is only valid for MSI files
|
||||
"exe") continue;; # Warning: -add-msi-dse option is only valid for MSI files
|
||||
"ps1") continue;; # Warning: -add-msi-dse option is only valid for MSI files
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Sign a $filetype$desc file with the add-msi-dse option"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-add-msi-dse \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"UNUSED_PATTERN" "MsiDigitalSignatureEx" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,38 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Sign a CAB file with "low" level of permissions in Microsoft Internet Explorer 4.x for CAB files
|
||||
# https://support.microsoft.com/en-us/help/193877
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=42
|
||||
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") continue;; # Warning: -jp option is only valid for CAB files
|
||||
"msi") continue;; # Warning: -jp option is only valid for CAB files
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") continue;; # Warning: -jp option is only valid for CAB files
|
||||
"ps1") continue;; # Warning: -jp option is only valid for CAB files
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Sign a $filetype$desc file with the jp low option"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-jp low \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"UNUSED_PATTERN" "Low level of permissions" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,36 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Verify changed file after signing.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=45
|
||||
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") continue;; # Test is not supported for non-PE files
|
||||
"msi") continue;; # Test is not supported for non-PE files
|
||||
"ex_") continue;; # Test is not supported for non-PE files
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1") continue;; # Test is not supported for non-PE files
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Verify changed $filetype$desc file after signing"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
verify_signature "$result" "$number" "$ext" "fail" "@2019-09-01 12:00:00" \
|
||||
"UNUSED_PATTERN" "Hello world!" "MODIFY"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,46 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Verify changed file after signing with Authenticode timestamping.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=46
|
||||
|
||||
if ! grep -q "no libcurl available" "results.log"; then
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") continue;; # Test is not supported for non-PE files
|
||||
"msi") continue;; # Test is not supported for non-PE files
|
||||
"ex_") continue;; # Test is not supported for non-PE files
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1") continue;; # Test is not supported for non-PE files
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Verify changed $filetype$desc file after signing with Authenticode timestamping"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-t http://time.certum.pl/ \
|
||||
-t http://timestamp.digicert.com/ \
|
||||
-verbose \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
verify_signature "$result" "$number" "$ext" "fail" "@2019-09-01 12:00:00" \
|
||||
"UNUSED_PATTERN" "Hello world!" "MODIFY"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
done
|
||||
else
|
||||
format_nr=0
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Verify changed file after signing with Authenticode timestamping"
|
||||
printf "\n%03d. %s\nTest skipped\n" "$number" "$test_name"
|
||||
fi
|
||||
|
||||
exit 0
|
@ -1,46 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Verify changed file after signing with RFC 3161 timestamping.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=47
|
||||
|
||||
if ! grep -q "no libcurl available" "results.log"; then
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") continue;; # Test is not supported for non-PE files
|
||||
"msi") continue;; # Test is not supported for non-PE files
|
||||
"ex_") continue;; # Test is not supported for non-PE files
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1") continue;; # Test is not supported for non-PE files
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Verify changed $filetype$desc file after signing with RFC 3161 timestamping"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-ts http://time.certum.pl/ \
|
||||
-ts http://timestamp.digicert.com/ \
|
||||
-verbose \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
verify_signature "$result" "$number" "$ext" "fail" "@2019-09-01 12:00:00" \
|
||||
"UNUSED_PATTERN" "Hello world!" "MODIFY"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
done
|
||||
else
|
||||
format_nr=0
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Verify changed file after signing with RFC 3161 timestamping"
|
||||
printf "\n%03d. %s\nTest skipped\n" "$number" "$test_name"
|
||||
fi
|
||||
|
||||
exit 0
|
@ -1,52 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Verify a file signed after the cert has been expired.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=51
|
||||
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") filetype=CAT; format_nr=1 ;;
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Verify $filetype$desc file signed after the cert has been expired"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "fail" "@2025-01-01 12:00:00" \
|
||||
"UNUSED_PATTERN" "UNUSED_PATTERN" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,62 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Verify a file signed with Authenticode timestamping after the cert has been expired.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=52
|
||||
|
||||
if ! grep -q "no libcurl available" "results.log"; then
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") filetype=CAT; format_nr=1 ;;
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Verify a $filetype$desc file signed with Authenticode after the cert has been expired"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-t http://time.certum.pl/ \
|
||||
-t http://timestamp.digicert.com/ \
|
||||
-verbose \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2025-01-01 12:00:00" \
|
||||
"UNUSED_PATTERN" "UNUSED_PATTERN" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
else
|
||||
format_nr=0
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Verify a file signed with Authenticode after the cert has been expired"
|
||||
printf "\n%03d. %s\nTest skipped\n" "$number" "$test_name"
|
||||
fi
|
||||
|
||||
exit 0
|
@ -1,62 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Verify a file signed with RFC3161 timestamping after the cert has been expired.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=53
|
||||
|
||||
if ! grep -q "no libcurl available" "results.log"; then
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") filetype=CAT; format_nr=1 ;;
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Verify a $filetype$desc file signed with RFC3161 after the cert has been expired"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-ts http://time.certum.pl/ \
|
||||
-ts http://timestamp.digicert.com/ \
|
||||
-verbose \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2025-01-01 12:00:00" \
|
||||
"UNUSED_PATTERN" "UNUSED_PATTERN" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
else
|
||||
format_nr=0
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Verify a file signed with RFC3161 after the cert has been expired"
|
||||
printf "\n%03d. %s\nTest skipped\n" "$number" "$test_name"
|
||||
fi
|
||||
|
||||
exit 0
|
@ -1,62 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Verify a file signed with the expired cert.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=54
|
||||
|
||||
if ! grep -q "no libcurl available" "results.log"; then
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") filetype=CAT; format_nr=1 ;;
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Verify a $filetype$desc file signed with the expired cert"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-certs "${script_path}/../certs/expired.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-ts http://time.certum.pl/ \
|
||||
-ts http://timestamp.digicert.com/ \
|
||||
-verbose \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "fail" "@2025-01-01 12:00:00" \
|
||||
"UNUSED_PATTERN" "UNUSED_PATTERN" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
else
|
||||
format_nr=0
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Verify a file signed with the expired cert"
|
||||
printf "\n%03d. %s\nTest skipped\n" "$number" "$test_name"
|
||||
fi
|
||||
|
||||
exit 0
|
@ -1,62 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Verify a file signed with the revoked cert.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=55
|
||||
|
||||
if ! grep -q "no libcurl available" "results.log"; then
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") filetype=CAT; format_nr=1 ;;
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1")
|
||||
filetype=TXT
|
||||
if xxd -p -l 2 "notsigned/$name" | grep -q "fffe"; then
|
||||
format_nr=5
|
||||
desc=" UTF-16LE(BOM)"
|
||||
elif xxd -p -l 3 "notsigned/$name" | grep -q "efbbbf"; then
|
||||
format_nr=6
|
||||
desc=" UTF-8(BOM)"
|
||||
else
|
||||
format_nr=7
|
||||
desc=" UTF-8"
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Verify a $filetype$desc file signed with the revoked cert"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-certs "${script_path}/../certs/revoked.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-ts http://time.certum.pl/ \
|
||||
-ts http://timestamp.digicert.com/ \
|
||||
-verbose \
|
||||
-in "notsigned/$name" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
if test "$filetype" = "TXT" && ! cmp -l -n 3 "notsigned/$name" "test_$number.$ext"; then
|
||||
printf "%s\n" "Compare file prefix failed"
|
||||
test_result "1" "$number" "$test_name"
|
||||
else
|
||||
verify_signature "$result" "$number" "$ext" "fail" "@2019-09-01 12:00:00" \
|
||||
"UNUSED_PATTERN" "UNUSED_PATTERN" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
fi
|
||||
done
|
||||
else
|
||||
format_nr=0
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Verify a file signed with the revoked cert"
|
||||
printf "\n%03d. %s\nTest skipped\n" "$number" "$test_name"
|
||||
fi
|
||||
|
||||
exit 0
|
@ -1,60 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Verify a file signed with the multiple signature.
|
||||
|
||||
. $(dirname $0)/../test_library
|
||||
script_path=$(pwd)
|
||||
test_nr=56
|
||||
|
||||
if ! grep -q "no libcurl available" "results.log"; then
|
||||
for file in ${script_path}/../logs/notsigned/*.*
|
||||
do
|
||||
name="${file##*/}"
|
||||
ext="${file##*.}"
|
||||
desc=""
|
||||
case $ext in
|
||||
"cat") continue;; # Warning: CAT files do not support nesting
|
||||
"msi") filetype=MSI; format_nr=2 ;;
|
||||
"ex_") filetype=CAB; format_nr=3 ;;
|
||||
"exe") filetype=PE; format_nr=4 ;;
|
||||
"ps1") continue;; # Warning: TXT files do not support nesting
|
||||
esac
|
||||
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Verify a $filetype$desc file signed with the multiple signature"
|
||||
printf "\n%03d. %s\n" "$number" "$test_name"
|
||||
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-certs "${script_path}/../certs/expired.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-verbose \
|
||||
-in "notsigned/$name" -out "signed1_$number.$ext"
|
||||
../../osslsigncode sign -h sha384 \
|
||||
-st "1556668800" \
|
||||
-nest \
|
||||
-certs "${script_path}/../certs/revoked.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-t http://time.certum.pl/ \
|
||||
-t http://timestamp.digicert.com/ \
|
||||
-verbose \
|
||||
-in "signed1_$number.$ext" -out "signed2_$number.$ext"
|
||||
../../osslsigncode sign -h sha256 \
|
||||
-st "1556668800" \
|
||||
-nest \
|
||||
-certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
|
||||
-ts http://time.certum.pl/ \
|
||||
-ts http://timestamp.digicert.com/ \
|
||||
-verbose \
|
||||
-in "signed2_$number.$ext" -out "test_$number.$ext"
|
||||
result=$?
|
||||
|
||||
verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
|
||||
"UNUSED_PATTERN" "SHA384" "UNUSED_PATTERN"
|
||||
test_result "$?" "$number" "$test_name"
|
||||
done
|
||||
else
|
||||
format_nr=0
|
||||
number="$test_nr$format_nr"
|
||||
test_name="Verify a file signed with the multiple signature"
|
||||
printf "\n%03d. %s\nTest skipped\n" "$number" "$test_name"
|
||||
fi
|
||||
|
||||
exit 0
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user