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

110 Commits

Author SHA1 Message Date
Klaus Heinrich Kiwi
909b54cc9d testsuite - rsa_func.c: Deal with X.509 Unwrap for AES keys corner case
We must provide a CKA_VALUE_LEN in the key template when unwrapping
  AES keys using X.509 RSA mechanism, otherwise there is no way to tell
  the size of the key being unwrapped.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-12-18 17:32:50 -02: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
f7fb829c61 Fix rsa_keygen testcase
Using an invalid public exponent should yield
  a CKR_TEMPLATE_INCONSISTENT error

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-12-18 15:18:55 -02:00
Kent Yoder
cd4366e0f7 Bug 67985 - correctly derivate CKA_MODULUS_BITS in RSA C_ObjectCreate
On Wed, Nov 10, 2010 at 03:09:03PM -0200, Klaus Heinrich Kiwi wrote:
>    OpenCryptoki is not correctly derivating CKA_MODULUS_BITS when
>    creating an object with C_ObjectCreate(). This value must be
>    derivated from CKA_MODULUS which is a required attribute for
>    C_ObjectCreate() when dealing with RSA Public Keys.
>
>    The most obvios symptom is a CKR_FUNCTION_FAILED for the
>    C_VerifyRecover() function when using NSS to create a
>    self-signed certificate (NSS tries to import the public
>    key into a session object using C_ObjectCreate())

  Looks good to me, Klaus.  template_attribute_find will correctly
return 0 when the base template passed in is NULL, so that should be
safe.

  I noticed that the rsa_keygen test tries that validate that
CKR_FUNCTION_FAILED is returned when an even RSA public exponent is
passed in.  That test now fails, did that check change recently?

  Attached is an updated rsa_keygen.c that tests the stuff in this
patch.

Acked-by: Kent Yoder <key@linux.vnet.ibm.com>
2010-12-18 15:18:55 -02:00
Klaus Heinrich Kiwi
3a88c92125 testsuite: Use testcase_notice() instead of _skip() for warnings
testsuite_notice() should be more appropriate in this case, but
   this file needs refactoring anyway.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-12-08 18:34:27 -02:00
Klaus Heinrich Kiwi
93ef265dc4 Testsuite: Completely refactor the rsa_func.c tests
Complete rewrite for RSA tests:
    - Encrypt/Decrypt
    - Single-part Sign/Verify (Recover)
    - Multi-part Sign/Verify (Recover)
    - Wrap/Unwrap

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-12-08 17:56: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
9c792d5634 init_cca.sh: A simple script to initialize CCA card (for tests)
The script loads synthethic RSA, AES and SYM keys in a CCA
    card.

    Warning: This *will* replace you card keys with insecure
    version only aimed for testing!

    Do NOT use those keys for production purposes.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-12-06 17:20:30 -02:00
Kent Yoder
a36be282cd remove md2 in rsa_sign_test
The header file for MD2 has disappeared in openssl-1.0, breaking the
build when it hits rsa_sign_test.  It looks like MD2 is fairly
irrelevant -- all but 2 of the tokens define NOMD2 explicitly, the other
2 don't use it and should probably define NOMD2 themselves. This patch
just removes the MD2 portion of rsa_sign_test so that the test can
build.

Kent

Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
2010-12-06 17:10:20 -02:00
Kent Yoder
743a386892 testsuite: Check unextractable and sensitive attributes for Secret keys
Klaus, attached is an addition to the misc_func.c driver testcase to
test extractable and sesitive secret keys.  It shows that Matteo's patch
does fix the issue.  Private keys will still need to be tested.

Kent

Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
2010-11-26 16:22:28 -02:00
Klaus Heinrich Kiwi
cc84b667fc Testsuite: skip token in case of errors with pkcsconf
Make pkcsconf errors non-fatal when querying the token type,
    so that the testsuite can continue with the other tokens

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-09-13 22:39:06 -03: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
ee2206e7a0 testcases: create separate 'benchmarks' bucket
Create a special category for 'benchmarks' test, and don't run
  them by default unless we are told to.

  Also some really minor cosmetic changes to the ock_test.sh script

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-08-30 12:14:12 -03:00
Klaus Heinrich Kiwi
404053d495 testsuite: Make ock_tests.sh more resilient
Make the ock_tests.sh script more resilient by skipping tokens
  which failed to initialize.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-08-30 12:13:43 -03:00
Kent Yoder
187581024a run make installcheck tests as an unprivileged user
This patch will look for the PKCS11_TEST_USER environemnt variable and if set, will run the testsuite as that user instead of root.  If the env var is missing, the tests are run as root.

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

 testcases/Makefile.am |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
2010-08-30 12:11:20 -03:00
Kent Yoder
f230185893 Add tests for SHA2 HMAC
Update digest_func.c to test SHA256 and SHA512 HMAC algorithms.  The
  patch also adds the p11_get_ckm() function to the new p11util.c file,
  which converts a CK_ULONG mechanism into a string.

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

 testcases/driver/digest_func.c  | 3215 +++++++++++----------------------------
 usr/lib/pkcs11/common/p11util.c |  194 +++
 usr/lib/pkcs11/common/p11util.h |    5 +
 3 files changed, 1055 insertions(+), 2359 deletions(-)
2010-08-19 18:50:15 -03:00
Kent Yoder
4be48a087a Test AES 128/192 in ECB and CBC modes
Modify the aes_func.c test to test all modes using key lens 128, 192 and 256.

Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
2010-08-19 09:25:00 -03:00
Kent Yoder
d37f5ab951 minor testcase fixes
This patch makes 3 minor functional fixes:

testcases/common/common.c:
Print hexdumps to stderr instead of stdout, since most uses of hex dumps in the testcases are to show a mismatch when a test fails.

testcases/driver/des_func.c:
Fix a bad check on a return code

testcases/driver/md5.c:
add a real prototype to the Transform function

Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
2010-08-18 21:49:36 -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
f228b4cf26 driver testcase updates: ssl3_func.c
- fix compile warnings generated by -Wall
- always return a non-zero error code to the command line on test error
- use a macro to send output to stderr when appropriate
- print file/line numbers for any failures

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

 testcases/driver/ssl3_func.c |  182 +++++++++++++++++++++---------------------
 1 files changed, 92 insertions(+), 90 deletions(-)
2010-08-13 16:50:01 -03:00
Kent Yoder
0db82d0eac driver testcase updates: sess_perf.c
- fix compile warnings generated by -Wall
- always return a non-zero error code to the command line on test error
- use a macro to send output to stderr when appropriate
- print file/line numbers for any failures

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

 testcases/driver/sess_perf.c |   23 ++++++++++++-----------
 1 files changed, 12 insertions(+), 11 deletions(-)
2010-08-13 16:50:01 -03:00
Kent Yoder
861bd9fff8 driver testcase updates: sess_mgmt.c
- fix compile warnings generated by -Wall
- always return a non-zero error code to the command line on test error
- use a macro to send output to stderr when appropriate
- print file/line numbers for any failures

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

 testcases/driver/sess_mgmt.c |  414 +++++++++++++++++++++---------------------
 1 files changed, 208 insertions(+), 206 deletions(-)
2010-08-13 16:50:01 -03:00
Kent Yoder
15f525c198 driver testcase updates: rsa_func.c
- fix compile warnings generated by -Wall
- always return a non-zero error code to the command line on test error
- use a macro to send output to stderr when appropriate
- print file/line numbers for any failures

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

 testcases/driver/rsa_func.c |  442 ++++++++++++++++++++++---------------------
 1 files changed, 223 insertions(+), 219 deletions(-)
2010-08-13 16:50:01 -03:00
Kent Yoder
344878843d driver testcase updates: rijndael_func.c
- fix compile warnings generated by -Wall
- always return a non-zero error code to the command line on test error
- use a macro to send output to stderr when appropriate
- print file/line numbers for any failures

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

 testcases/driver/rijndael_func.c |  194 +++++++++++++++++++-------------------
 1 files changed, 98 insertions(+), 96 deletions(-)
2010-08-13 16:50:01 -03:00
Kent Yoder
1f785271b0 driver testcase updates: obj_mgmt.c
- fix compile warnings generated by -Wall
- always return a non-zero error code to the command line on test error
- use a macro to send output to stderr when appropriate
- print file/line numbers for any failures

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

 testcases/driver/obj_mgmt.c |  440 ++++++++++++++++++++++---------------------
 1 files changed, 226 insertions(+), 214 deletions(-)
2010-08-13 16:50:01 -03:00
Kent Yoder
41a5b47e9f driver testcase updates: misc_func.c
- fix compile warnings generated by -Wall
- always return a non-zero error code to the command line on test error
- use a macro to send output to stderr when appropriate
- print file/line numbers for any failures

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

 testcases/driver/misc_func.c |  388 +++++++++++++++++++++---------------------
 1 files changed, 195 insertions(+), 193 deletions(-)
2010-08-13 16:50:01 -03:00
Kent Yoder
1c466c4e34 driver testcase updates: md5.h
- corrected prototypes

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

 testcases/driver/md5.h |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
2010-08-13 16:50:00 -03:00
Kent Yoder
0ecc3ead71 driver testcase updates: dsa_func.c
- fix compile warnings generated by -Wall
- always return a non-zero error code to the command line on test error
- use a macro to send output to stderr when appropriate
- print file/line numbers for any failures

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

 testcases/driver/dsa_func.c |   96 +++++++++++++++++++++----------------------
 1 files changed, 47 insertions(+), 49 deletions(-)
2010-08-13 16:50:00 -03:00
Kent Yoder
bb7ff839e9 driver testcase updates: digest_func.c
- fix compile warnings generated by -Wall
- always return a non-zero error code to the command line on test error
- use a macro to send output to stderr when appropriate
- print file/line numbers for any failures

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

 testcases/driver/digest_func.c |  959 ++++++++++++++++++++--------------------
 1 files changed, 481 insertions(+), 478 deletions(-)
2010-08-13 16:50:00 -03:00
Kent Yoder
8c1690a2c0 driver testcase updates: dh_func.c
- fix compile warnings generated by -Wall
- always return a non-zero error code to the command line on test error
- use a macro to send output to stderr when appropriate
- print file/line numbers for any failures

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

 testcases/driver/dh_func.c |  103 ++++++++++++++++++++++---------------------
 1 files changed, 53 insertions(+), 50 deletions(-)
2010-08-13 16:50:00 -03:00
Kent Yoder
de6f902c61 driver testcase updates: des_func.c
- fix compile warnings generated by -Wall
- always return a non-zero error code to the command line on test error
- use a macro to send output to stderr when appropriate
- print file/line numbers for any failures

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

 testcases/driver/des_func.c |  474 ++++++++++++++++++++++---------------------
 1 files changed, 238 insertions(+), 236 deletions(-)
2010-08-13 16:50:00 -03:00
Kent Yoder
c608aaa9e7 driver testcase updates: des3_func.c
- fix compile warnings generated by -Wall
- always return a non-zero error code to the command line on test error
- use a macro to send output to stderr when appropriate
- print file/line numbers for any failures

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

 testcases/driver/des3_func.c |  450 +++++++++++++++++++++---------------------
 1 files changed, 226 insertions(+), 224 deletions(-)
2010-08-13 16:50:00 -03:00
Kent Yoder
29830f5050 driver testcase updates: aes_func.c
- fix compile warnings generated by -Wall
- always return a non-zero error code to the command line on test error
- use a macro to send output to stderr when appropriate
- print file/line numbers for any failures

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

 testcases/driver/aes_func.c |  463 ++++++++++++++++++++++---------------------
 1 files changed, 237 insertions(+), 226 deletions(-)
2010-08-13 16:50:00 -03:00
Kent Yoder
2e88c7ad6f driver testcase updates: Makefile.am
Add -Wall to the compile of the driver/ testcases.

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

 testcases/driver/Makefile.am |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
2010-08-13 16:50:00 -03:00
Klaus Heinrich Kiwi
e233c0c8e7 Use correct slot in ock_tests.sh script
Add missing parameter to call init_token.sh script.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-08-13 09:39:34 -03:00
Kent Yoder
0d4508421c fix loop variable in test script
This patch fixes a loop variable name, which prevented printing the name of the test being executed.

Thanks,
Kent

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

 testcases/ock_tests.sh.in |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
2010-08-10 10:46:39 -03:00
Kent Yoder
b5a4e6b106 correct prototype in test_crypto.c
This patch updates an incorrect function prototype in test_crypto.c.

Thanks,
Kent

Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
2010-08-10 09:13:35 -03:00
Klaus Heinrich Kiwi
39d495872d Clean-up ock_tests.sh script
Hopefully make ock_tests.sh more resilient.

Also introduces a init_tpmtoken.sh script that is used
to initialize the TPM token.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-07-31 02:15:44 -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
Kent Yoder
7495fa34ba digest_test.sh changes to run as part of the auotmated tests
This patch modifies testcases/oc-digest/digest_test.sh as needed to run as part of the automated tests and adds it to the list of tests to run in ock_tests.sh.in.

Changes to digest_test.sh:
o respect the -nostop flag on the command line
o use the path to the oc-digest executable as needed by make installcheck
o couple of formatting chages (sorry)

Changes to ock_tests.sh.in:
o add oc-digest/digest_tests.sh to the list of test to run
o use 'ls -U' to preserve test ordering in the list

Thanks,
Kent

Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
2010-07-31 01:26:10 -03:00
Kent Yoder
ee79ff21d4 add digest testing script for oc-digest
This patch adds testcases/oc-digest/digest_test.sh, which gives a flexible way to test new digests against opencryptoki.  It also modifies testcases/oc-digest.c to return a non-zero return code to the command line when it fails.  This enables the script to detect when opencryptoki doesn't support a specific digest on the slot being tested.

The script:
1. Checks that the algorithm is supported in the slot being tested
2. Generates (from /dev/urandom) a set of files to test based on the block size of the supported algorithm
3. Hashes those files using oc-digest and validates the output
4. Deletes the test files

This initial version of the script supports testing md5, sha1, sha256, sha384 and sha512.

Thanks,
Kent

Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
2010-07-31 01:25:55 -03:00
Kent Yoder
1ede72ea17 automate testing
This patch enables the make installcheck target to do an automated test run against opencryptoki.  In order to make installcheck you must be root, and make will fail if the token is already initialized.  To allow a test run to succeed for a $TOKEN, you need to first run rm -rf @localstatedir@/opencryptoki/$TOKEN/*.  Requiring this ensures that a user cannot blow away an in-use token accidentally.  make installcheck will kill a running pkcsslotd.

This patch modifies
- testcases/Makefile.am
o add the installcheck target
o pre-process init_token.sh.in
- testcases/init_token.sh -> testcases/init_token.sh.in
- testcases/init_token.sh.in
o have the build fill-in the full path to pkcsconf
o return an error code to the command line if pkcsconf fails
-  testcases/ock_tests.sh.in:
o put a list of tests to run at the top
o process spaces in the output of $PKCONF parsing
o call init_token.sh for each slot we test and fail if it fails

Thanks,
Kent

Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
2010-07-31 01:25:42 -03:00
Kent Yoder
5156ba9940 session perf testcase returning buffer too small
Hi Klaus,

  While running sess_perf.c, I routinely got CKR_BUFFER_TOO_SMALL as the test
called encrypt_DATA during its run.

  I believe this patch fixes the issue, which is that an uninitialized outlen
parameter was being passed into C_EncryptUpdate and C_EncryptFile.  I also
added a return code value from main in this patch.

  Please consider for inclusion in opencryptoki-next.

Thanks,
Kent

Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
2010-07-27 18:26:35 -03:00
Klaus Heinrich Kiwi
11c859e94f Use pointer as object handler
This avoids interating through a list of objects attached to
some particular process every time the object is needed.

As previous commits did with session object, this commit applies to
object handles. This MAY cause segfaults if the caller application
passes invalid handles, but this is often caused by buggy applications.

Also remote tests with invalid object handlers from obj_mgmt.c

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-07-05 09:34:44 -03:00
Klaus Heinrich Kiwi
afcea384cf Use pointer as session handler in API layer
To avoid iterating through the API Session list Anchor->SessListBeg
every time we need a session reference, use the session's own
pointer as handle.

This change MAY introduce segfaults if the caller application
passes invalid session handlers that cannot be directly dereferenced,
but that usually only means that the application is buggy and needs
fixing.

Also removes tests with invalid session handlers from obj_mgmt.c

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-07-05 09:34:16 -03:00
Klaus Heinrich Kiwi
24caf4325a New "sess_perf.c" testcase
New testcase (derived from sess_obj.c) aimed at benchmarking
opencryptoki's performance under a high number of open sessions.
This test should be relatively long running (about 1 hour
each run). It measures the time it takes to perform two
encryption operations for various counts of currently open
sessions.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-07-05 09:33:03 -03:00
Klaus Heinrich Kiwi
3941dca37c Use a ock_tests.sh.in to use the correct paths at build time
This patch removes moves ock_tests.sh to ock_tests.sh.in in
order to have it processed at build time. Time allow us to
use the pathnames used by the overall build process.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-01-12 15:37:12 -02:00
Klaus Heinrich Kiwi
a537933920 Minor fixes/enhancements to the ock_tests.sh script
ock_tests.sh is currently with always-on logging (due to a typo in
"if [ "$LOGGING"="1" ]".
Fix that behavior and also make every output either go to the log or to
the stdout (by enclosing the script with a function that can have it's
output redirected)

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2009-07-28 09:20:10 -03:00
phreakz
7104e9195e Now able to log tests errors
Signed-off-by: Rajiv Andrade <srajiv@linux.vnet.ibm.com>
2009-02-04 16:28:41 +00:00