1
0
mirror of https://github.com/opencryptoki/opencryptoki.git synced 2026-10-24 05:39:17 +03:00

47 Commits

Author SHA1 Message Date
Akash Kulhalli
d1785b5e54 testcases: miscellaneous updates
`random` returns a number within a range that includes 0; but the code does not
always handle that, leading to misleading error messages ("malloc failed" but
it was a request for a memory buffer of size 0) on test run. Those should now
be fixed.

The `ock_tests.sh.in` file has been slightly tweaked to account for some flags
that are not available on AIX. No functional differences expected across all
supported platforms.

On Linux, a null pointer is printed as "(null)", whereas on AIX nothing is
printed. Since this is only for tests, AIX now also prints the same string as
Linux when a nullptr is attempted to be printed.

Signed-off-by: Akash Kulhalli <akash.kulhalli@ibm.com>
2024-04-24 09:48:07 +02:00
Ingo Franzki
2bd0b1fcc1 TESTCASES: Remove unused argument of testcase_setup()
Argument 'total' of macro testcase_setup() is not used for anything.
Remove it.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
2022-03-22 09:32:27 +01:00
Juergen Christ
3b0a198aa9 Exploit mechanism table
Make use of mechanism table to translate between string and numeric format of
mechanisms.  Remove duplicated code dealing with mechanism translations.

Signed-off-by: Juergen Christ <jchrist@linux.ibm.com>
2021-11-08 16:29:24 +01:00
Ingo Franzki
b57644843c TESTCASES: Ensure testcase exits with non-zero on failure
If at least one test step ends with ERROR or FAILURE, exit the
process with a non-zero return code to let the caller easily detect
if the testcase showed any errors.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
2021-08-13 19:59:16 +02:00
Patrick Steuer
2749f80687 Conform to PKCS 11 v3.0 Baseline Provider profile - part 1
Add required constants and declarations and implement the
required functions.

Signed-off-by: Patrick Steuer <patrick.steuer@de.ibm.com>
2020-10-14 10:59:54 +02:00
Juergen Christ
ef62794ca1 Replace deprecated ftime
Use gettimeofday instead.

Fixes #317

Signed-off-by: Juergen Christ <jchrist@linux.ibm.com>
2020-10-12 15:56:23 +02:00
Ingo Franzki
33e58bc69b Fix build issue with gcc 10 and -fno-common
With gcc 10 -fno-common is the default.

Fixes: https://github.com/opencryptoki/opencryptoki/issues/271

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
2020-02-03 13:08:59 +01:00
Ingo Franzki
88f8f55b5a COMMON: Add IBM-CMAC mechanism definitions to common code
EP11 supports the vendor (IBM) specific mechanism CKM_IBM_CMAC.
With older EP11 firmware this is the only CMAC mechanism supported
by EP11.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
2019-10-09 16:23:53 +02:00
Ingo Franzki
7e5e68862b COMMON: Add IBM specific SHA-3 mechanisms
PKCS#11 v2.4 does not define any mechanisms for SHA3.
To support SHA3 anyway, add support for the vendor (IBM) specific
mechanisms CKM_IBM_SHA3_224, CKM_IBM_SHA3_256, CKM_IBM_SHA3_384,
CKM_IBM_SHA3_512, CKM_IBM_SHA3_224_HMAC, CKM_IBM_SHA3_256_HMAC,
CKM_IBM_SHA3_384_HMAC, and CKM_IBM_SHA3_512_HMAC.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
2019-10-09 16:23:53 +02:00
Ingo Franzki
fa2889928e COMMON: Add defines for CMAC mechanisms
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
2019-09-20 12:06:02 +02:00
Patrick Steuer
2b36533cb8 Expand %C% and %D% in makefiles
Old autotools dont know %C% and %D%.

Signed-off-by: Patrick Steuer <patrick.steuer@de.ibm.com>
2018-11-06 17:22:29 +01:00
Ingo Franzki
2726d91de3 TESTCASE: Correct testcase cleanup handling
Prevent a loop if testcase_user_logout() is called after
label testcase_cleanup and the session handle is invalid
or C_Logout returns an error.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
2018-10-10 14:55:48 +02:00
Patrick Steuer
e6d7071e89 Autotools rework: get rid of recursive make
Signed-off-by: Patrick Steuer <patrick.steuer@de.ibm.com>
2018-10-08 10:48:42 +02:00
Patrick Steuer
d78f417db8 Fix dist and distcheck make targets
Signed-off-by: Patrick Steuer <patrick.steuer@de.ibm.com>
2018-09-25 17:40:31 +02:00
Ingo Franzki
a075a3bd2b TESTCASE: Display total elapsed time together with summary
testcase_pass() already displays the elapsed time since the
corresponding testcase_begin(). This patch adds code to also
display the total elapsed time in testcase_print_result()
since the corresponding testcase_setup().

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
2018-08-20 10:34:58 +02:00
Eduardo Barretto
2ea647a7da Testcases/include: Fix coding style
Signed-off-by: Eduardo Barretto <ebarretto@linux.vnet.ibm.com>
2018-08-08 17:27:53 +02:00
Ingo Franzki
25455537fa Add SHA512_224/256 mechanisms to common code and EP11 token
Add mechanisms CKM_SHA512_224, CKM_SHA512_224_HMAC, CKM_SHA512_224_HMAC_GENERAL
CKM_SHA512_256, CKM_SHA512_256_HMAC, and CKM_SHA512_256_HMAC_GENERAL
to common code and the EP11 token.

Signed-off-by: Ingo Franzki <ifranzki@linux.vnet.ibm.com>
2018-01-31 10:20:07 -02:00
Ingo Franzki
e4e77e5eff Add SHA-2 based key derivation mechanisms to common code and EP11
Add mechanisms CKM_SHA224_KEY_DERIVATION, CKM_SHA384_KEY_DERIVATION,
and CKM_SHA512_KEY_DERIVATION to common code and EP11.

Signed-off-by: Ingo Franzki <ifranzki@linux.vnet.ibm.com>
2018-01-31 10:20:07 -02:00
Ingo Franzki
b8db846b96 Update rsa testcase to test SHA224_RSA_PKCS mechanism
The rsa testcase (rsa_func.c) will now also test
mechanism CKM_SHA224_RSA_PKCS.

Signed-off-by: Ingo Franzki <ifranzki@linux.vnet.ibm.com>
2018-01-31 10:20:07 -02:00
Ingo Franzki
ad3c195ccd Update ec testcase to test ECDSA_SHA224 mechanism
The ec testcase (ec_func.c) will now also test
mechanism CKM_ECDSA_SHA224.

Signed-off-by: Ingo Franzki <ifranzki@linux.vnet.ibm.com>
2018-01-31 10:20:07 -02:00
Ingo Franzki
a2efbdc80f Update digest testcase to test SHA224 mechanisms
The digest testcase (digest_func.c) will now also test
mechanisms CKM_SHA224, CKM_SHA224_HMAC, and
CKM_SHA224_HMAC_GENERAL.

Signed-off-by: Ingo Franzki <ifranzki@linux.vnet.ibm.com>
2018-01-31 10:20:07 -02:00
Eduardo Barretto
90b2b52915 Remove unnecessary executable permission
Some files had a legacy executable permission that in not necessary. So, removed
it.

Signed-off-by: Eduardo Barretto <ebarretto@linux.vnet.ibm.com>
2017-10-31 15:57:12 -02:00
Ingo Franzki
d509a33528 ep11 token, cca token: Add ECDSA SHA2 support
Slightly adapted version of Ingo's patch:
Patch hunks needed relocation because of previous commits
in some files. Removed some trailing whitespaces.
Tested, works.

Signed-off-by: Ingo Franzki <ifranzki@de.ibm.com>
Signed-off-by: Harald Freudenberger <freude@linux.vnet.ibm.com>
2017-04-05 13:33:48 -03:00
Paulo Vital
54eb5f946a Add CPL-1.0 license header to source code files.
Add the license header in those source code files are missing it.

Signed-off-by: Paulo Vital <pvital@linux.vnet.ibm.com>
2017-03-15 16:37:46 -03:00
Harald Freudenberger
90129185f8 Fixed sess_mgnt testcase failure on CCA and EP11 tokens
Signed-off-by:Harald Freudenberger <freude@linux.vnet.ibm.com>
Signed-off-by: Vineetha Pai <vpishar@us.ibm.com>
2016-01-11 15:06:52 -05:00
Harald Freudenberger
cf264e2e40 Some small fixes and improvements on the digest testcase:
- multipart digest update now really breaks down the data
  into chunks.
- fix in regress.h: macro testcase_pass prints out timev differences
  but start time was nowhere set (causing to print just some kind of
  random time). Now the testcase_begin* macros set start time and thus
  the time values printed out make sense.

Signed-off-by: Joy Latten <jmlatten@linux.vnet.ibm.com>
2014-08-21 16:39:23 -05:00
Joy Latten
34ddc70f6f Changed symmetric testcases to accept "-securekey" if using securekey token.
This ensures only published test vectors are not run on secure key tokens.
Before we were checking for securekey based on mode name, but this won't
work for ICSF whose model name is not hardcoded or set by OCK.

Signed-off-by: Joy Latten <latten@linux.vnet.ibm.com>
Reviewed-by: Debora Babb
Reviewed-by: Marcelo Cerri
2013-05-21 00:10:51 +02:00
Marcelo Cerri
609bf299c7 Fix: remove warnings
Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
Reviewed-by: Debora Babb <dvelarde@us.ibm.com>
Reviewed-by: Joy Latten <jmlatten@linux.vnet.ibm.com>
2013-05-20 21:12:32 +02:00
Marcelo Cerri
24a96a91a7 Fix: infinite loop when a test case fails to login
Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
Reviewed-by: Joy Latten <jmlatten@linux.vnet.ibm.com>
2013-05-20 20:31:46 +02:00
Joy Latten
9f2b30fc1f Removed old testcases and restructured testcase subdirectories.
Signed-off-by: Joy Latten <jmlatten@users.sourceforge.net>
2012-01-25 11:52:55 -06:00
Fionnuala Gunter
79d74b43d2 Fixes looping through all the testcases when user pin is not set.
Now we exit first time it occurs.

Signed-off-by: Fionnuala Gunter <fin@linux.vnet.ibm.com>
2011-08-18 11:31:42 -05:00
Fionnuala Gunter
e696654f01 Added t_error to count number of errors encountered.
Errors are tallied, and included in summary results.
Total number of tests don't need to be hardcoded;
instead total = run + skipped.

Signed-off-by: Fionnuala Gunter <fin@linux.vnet.ibm.com>
2011-07-08 16:08:54 -05:00
Ashley Lai
ef0ec85a58 Added Elliptic Curve support
Signed-off-by: Ashley Lai <adlai@us.ibm.com>
2011-05-11 15:17:08 -05:00
Klaus Heinrich Kiwi
0f2514cd23 testsuite: Proper session handling in regress.h macros
If we fail to create a session, invalidade the session
  handler and check that when closing sessions.

  Trying to C_CloseSession() on an invalid handle may
  segfault the caller.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-12-18 17:32:50 -02:00
Klaus Heinrich Kiwi
8a05dedc86 testsuite: add a bunch of new macros to regress.h
Add many new macros with the aim of simplifying
    testcases.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-12-08 17:56:39 -02:00
Klaus Heinrich Kiwi
7c632b898c testsuite: Introduce standard pass/fail/skip/error macros
Introduce testcase_[pass|fail|skip|error] macros to be used
  across the testsuite and thus standardize testcases format and
  output.

  The macros will also try to time the operation execution, now
  with microsecond resolution.

  I've also provided testcase_*_f alternatives for cases where
  we need to manually identify the test (instead of just using
  __func__).

  This patch also "converts" obj_mgmt.c tests to use the new
  macros.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-08-30 12:38:19 -03:00
Klaus Heinrich Kiwi
47571bbeab Start consolidating pkcs#11 utility functions
Opencryptoki has a number of places which use misc pkcs#11 utility
  functions.

  This patch creates p11util.c which to start consolidating those
  functions in one place.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-08-17 12:31:47 -03:00
Kent Yoder
2ea423f04e driver testcase updates: regress.h
- remove incorrect/unused prototypes

Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>

 testcases/include/regress.h |   13 -------------
 1 files changed, 0 insertions(+), 13 deletions(-)
2010-08-13 16:50:01 -03:00
Kent Yoder
02d045d533 update show_error to print file and line numbers for any test errors
This patch makes the show_error() function used by the testcases a macro, then adds printing of a file and line number wherever its called.  This patch also changes the file descriptor these strings print to from stdout to stderr.  This will make finding errors in automated test runs easier.

Thanks,
Kent

Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
2010-07-31 01:26:20 -03:00
phreakz
d0de9a0d29 Testcases improvements:
- Now testcases inside testcases/driver can be run separatedly
- ock-tests.sh now calls individual tests instead of testcases/driver/driver binary
- since all usage() were the same inside testcases/driver, this is now located at testcases/common.c. To avoid namespace conflict, the other usage() ones were renamed to <testcase_binary_name>_usage()
- skip_token_obj, no_stop and no_init are now declared in testcases/include/regress,h
2008-11-11 13:17:22 +00:00
danielhjones
02ee059e58 Cleanup compiler warnings. 2006-06-15 21:23:18 +00:00
kyoder
e5c16edfe6 testcase complete rework 2006-04-21 15:14:30 +00:00
kyoder
f789042d44 merge with cleanup branch 2006-04-05 20:07:40 +00:00
mhalcrow
e168a9fce9 Set the testcase pins correctly 2005-11-03 20:02:13 +00:00
kyoder
1fe8ca54f5 tie all passwords into on #define in include/regress.h 2005-06-17 15:35:16 +00:00
mhalcrow
8ae034954c Set of patches from Kent Yoder:
- libtoolize
 - configurable paths
 - lib/*.so64 -> lib64/*.so
 - nix AIX #ifdef's
 - nix LINUX #ifdef's
 - Genral cleanup
2005-02-22 20:45:39 +00:00
kyoder
9961353e5b Initial revision 2005-01-18 16:08:12 +00:00