From cfe1f7fdd12e202fa2d056c7fd731cfeee378a98 Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Wed, 15 Jul 2020 18:12:32 +0200 Subject: [PATCH] Unbreak negative mechanism lists in slots.mechanisms + testcase Previously, when the list for slots.mechanisms was prefixed with minus sign "-", the first mechanism was skipped as invalid and therefore the tool was presenting wrong list of algorithms. This fixes the initial index for selection of first algorithm and adds unit test for this scenario. --- .gitignore | 1 + configure.ac | 1 + src/lib/SoftHSM.cpp | 9 ++- src/lib/test/InfoTests.cpp | 70 ++++++++++++++++++- src/lib/test/InfoTests.h | 2 + src/lib/test/Makefile.am | 1 + src/lib/test/softhsm2-negative-mech.conf.in | 8 +++ .../test/softhsm2-negative-mech.conf.win32 | 7 ++ win32/p11test/p11test.vcxproj.in | 2 + 9 files changed, 97 insertions(+), 4 deletions(-) create mode 100644 src/lib/test/softhsm2-negative-mech.conf.in create mode 100644 src/lib/test/softhsm2-negative-mech.conf.win32 diff --git a/configure.ac b/configure.ac index d4dad435..c6a51c7a 100644 --- a/configure.ac +++ b/configure.ac @@ -217,6 +217,7 @@ AC_CONFIG_FILES([ src/lib/test/softhsm2-alt.conf src/lib/test/softhsm2-reset-on-fork.conf src/lib/test/softhsm2-mech.conf + src/lib/test/softhsm2-negative-mech.conf src/lib/test/tokens/dummy src/bin/Makefile src/bin/common/Makefile diff --git a/src/lib/SoftHSM.cpp b/src/lib/SoftHSM.cpp index 0a0c32cc..cac724e6 100644 --- a/src/lib/SoftHSM.cpp +++ b/src/lib/SoftHSM.cpp @@ -791,12 +791,17 @@ void SoftHSM::prepareSupportedMecahnisms(std::map @@ -99,6 +100,7 @@ copy ..\..\src\lib\test\softhsm2.conf.win32 "$(TargetDir)\softhsm2.conf" copy ..\..\src\lib\test\softhsm2-alt.conf.win32 "$(TargetDir)\softhsm2-alt.conf" copy ..\..\src\lib\test\softhsm2-reset-on-fork.conf.win32 "$(TargetDir)\softhsm2-reset-on-fork.conf" copy ..\..\src\lib\test\softhsm2-mech.conf.win32 "$(TargetDir)\softhsm2-mech.conf" +copy ..\..\src\lib\test\softhsm2-negative-mech.conf.win32 "$(TargetDir)\softhsm2-negative-mech.conf" mkdir "$(TargetDir)\tokens" 2> nul copy ..\..\src\lib\test\tokens\dummy.in "$(TargetDir)\tokens\dummy"