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

423 Commits

Author SHA1 Message Date
Kent Yoder
3400be830f Add ability to EC to combine both hash and sign.
Also includes a check in EC to ensure the output buffer is
big enough.

Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
2011-05-17 15:32:15 -05:00
Joy Latten
8ecae97c7a Add the mode the debug file should be created with.
Signed-off-by: Joy Latten <jmlatten@users.sourceforge.net>
2011-05-17 14:39:32 -05:00
Joy Latten
0992aa4e85 Revert "dlopen(3) assumes relative path, but..."
This patch prevents linux from having 32bit and 64bit
apps on the same system. A more specific FreeBSD patch
is required instead.

This reverts commit f22421a0ad.

Signed-off-by: Joy Latten <jmlatten@users.sourceforge.net>
2011-05-17 11:27:01 -05:00
Kent Yoder
123e179201 Ensure modular bits are valid.
Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
2011-05-16 17:42:33 -05:00
Kent Yoder
31a01017de SF #3301770
Due to a common function being used for unwrap, des and 3des key
unwrapping was looking for a specific template required only for AES keys,
and additionally were being unpacked into the CKA_VALUE attribute
instead of the CKA_IBM_OPAQUE attribute.

Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
2011-05-16 17:32:57 -05:00
Kent Yoder
ca86e08288 CCA AES128 keygen fix.
Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
2011-05-16 17:27:02 -05:00
Joy Latten
7f52b1ac5e Cleanup logging. Debug messages now go to a debug file that
is identified with OPENCRYPTOKI_DEBUG_FILE environ variable
when debug is enabled. syslog messages are logged regardless.

Signed-off-by: Joy Latten <jmlatten@users.sourceforge.net>
2011-05-16 17:08:05 -05:00
Kent Yoder
e3ddaa6f47 Allow pkcsconf to print supported mechanisms for a slot.
Also add testcases/driver/ec_tests to the git ignore list.

Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
2011-05-12 16:37:42 -05:00
Kent Yoder
d42505c679 Cleanup and remove unsupported mechanisms from the various stdlls.
Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
2011-05-12 16:30:22 -05:00
Kent Yoder
2701e1fe86 Add aes ctr to token specific structure for the STDLLs.
Also check that token supports aes ctr mechanism for encrypt
and decrypt before calling.

Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
2011-05-12 16:15:57 -05:00
Richa Marwaha
db6b9679b9 Added support for AES-Counter Mode
Signed-off-by: Richa Marwaha <rmarwah@linux.vnet.ibm.com>
2011-05-12 15:40:06 -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
Joy Latten
4642b81f35 SF1415656 - Update PKCS#11 API version number to 2.20.
Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
2011-05-03 10:57:51 -05:00
Joy Latten
7def346e5d Fixes issue where public exponent passed to software token became
corrupt on s390x. Fix memcpy's public exponent into a CK_ULONG
(size of the openssl RSA_generate_key argument) and call correct
endianess macro.

Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
2011-05-03 10:20:51 -05:00
Joy Latten
8c00420f7d SF3196229 This fixes an issue in object mgmt rewrite in which
the wrong handle was being returned by object_mgr_find_in_map2.

Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
2011-05-02 16:36:46 -05:00
Joy Latten
684acad6f3 SF3196229 TPM has a custom logout that was being missed.
Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
2011-05-02 16:13:59 -05:00
Joy Latten
7f0c29dede SF3131950: The public exponent needs to be added to the private key
for rsa. Also includes a new testcase to test for this.

Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
2011-05-02 15:15:38 -05:00
Joy Latten
039dabd216 Fix for SF3196185. template_check_exportability should return
TRUE/FALSE (CK_BBOOL) instead of CKR_ATTRIBUTE_VALUE_INVALID.

Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
2011-04-28 11:31:50 -05:00
Joy Latten
cbd1f6d494 Revert "Soft token: Better public-exponent validation"
The memcpy can blow away the app's public exponent, so
reverting the patch.

Signed-off-by: Joy Latten <jmlatten@users.sourceforge.net>

This reverts commit 08fe158617.
2011-04-27 14:48:01 -05:00
Joy Latten
96ee90cb56 Prior patches allowed sessions to be stored in a btree.
This patch leverages that to also store pkcs#11 objects in a btree.

Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
2011-04-19 12:25:12 -05:00
Joy Latten
80c8b46d2c Two additional fixes for session odject handle found
during testing.

Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
2011-04-18 17:03:30 -05:00
Joy Latten
47b3f49649 pkcs_slot should create missing directories and ensure group
pkcs11 perms.

Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
2011-04-18 16:09:03 -05:00
Joy Latten
f3dabf9817 Forgot to add Kent's btree.c file for his session object handle changes.
Signed-off-by: Joy Latten <jmlatten@users.sourceforge.net>
2011-04-18 12:35:50 -05:00
Joy Latten
1fc76cd39a SF Bug #3196229 session handle issue
Change from using a reference to memory to using a handle which
references a binary tree node.

Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
2011-04-15 15:48:18 -05:00
Joy Latten
106d0eb301 strip_pkcs_padding() was missing parenthesis, thus always resulting
in an error message.

Signed-off-by: Joy Latten <jmlatten@users.sourceforge.net>
2011-04-14 17:10:15 -05:00
Diego Elio Pettenò
8012e21645 Fix implicit declarations in p11util.c
The sources require an inclusion of <string.h> for memmove() and of
<stdio.h> for sprintf().

Implicit declarations both cannot be properly validated by the compiler and
will stop fortified sources in modern glibc from working.
2011-01-14 15:25:08 -02:00
Klaus Heinrich Kiwi
5dd800c05f Minor TPM token build fix
* TPM token, contrary to other tokens, wasn't symlink PKCS11_TPM.so
    to the library upon make install.
  * Also added uninstall hooks for consistency

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2011-01-13 15:26:36 -02:00
Diego Elio Pettenò
3ebee4d44f Make sure to create directories before trying to install anything.
This solves parallel build issues.
2011-01-13 10:57:04 -02:00
Nathan Williams
eaf724913d Patch out the recursive chmod -R in pkcs_slot 2011-01-13 10:56:23 -02:00
Chris Masone
64a9232029 Make pkcsslotd grab the shared memory it needs, even if it wasnt freed by a previous instance 2011-01-13 10:53:59 -02:00
Petre Rodan
e61b4fa153 Define 64-bit unsigned integer 2011-01-13 10:53:02 -02:00
Norikatsu Shigemura
e238c83f49 Add support more signal informations
Hi Klaus.

	Add support more signal informations to pkcsslotd/err.c.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2011-01-04 16:52:41 -02:00
Norikatsu Shigemura
3d5d733164 Fix any constructor/destructor issue
Hi Klaus.

	According to BSSSD[*] folks, there are any problems on constructor
	and destructor.  I can't provide an exlanation of thus, but I think
	this is significant.

[*] http://bsssd.sourceforge.net/

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2011-01-04 16:38:03 -02:00
Norikatsu Shigemura
f22421a0ad dlopen(3) assumes relative path, but...
Hi Klaus.

	On openCryptoki, dlopen(3) assumes that resolve relative path
	by /etc/ld.so.conf.d/opencryptoki.conf.  However, on FreeBSD,
	even if 'ldconfig -m /usr/local/lib/opencryptoki/stdll' (same
	as /etc/ld.so.conf.d/opencryptoki.conf), dlopen(3) doesn't
	resolve relative path (path name required .so.1 suffix).  So
	libopencryptoki.so can't load STDLLs.

	I made a patch to fix this issue by absolute path instead of
	relative path.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2011-01-04 15:46:02 -02:00
Norikatsu Shigemura
331bfb666a reduce diff other OS
Hi Klaus.

	There are some linux/limits.h, but it isn't always used.  I think
	that should be used limits.h instead of linux/limits.h.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$ grep -r limits.h .
./usr/sbin/pkcsslotd/pkcsslotd.h:#include <linux/limits.h>
./usr/sbin/pkcsslotd/slotd_msg.h:#include <limits.h>
./usr/sbin/pkcsconf/pkcsconf_msg.h:#include <limits.h>
./usr/lib/pkcs11/common/linuxdef.h:  #include <limits.h>
./usr/lib/pkcs11/cca_stdll/cca_specific.c:#include <limits.h>
./usr/include/pkcs11/apictl.h:#include <linux/limits.h>
./usr/include/pkcs11/slotmgr.h:#include <linux/limits.h>
./usr/include/pkcs11/stdll.h:#include <linux/limits.h>
./configure.in:AC_CHECK_HEADERS([fcntl.h limits.h strings.h sys/file.h syslog.h unistd.h])
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

	So reduce different from other OS like FreeBSD, I made a patch.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2011-01-04 15:35:53 -02:00
Klaus Heinrich Kiwi
cbea187c9c Remove CCA stdll ´Makefile.in´
Makefile.in is automatically generated from Makefile.am.
  It has no business in VCS

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-12-18 17:32:49 -02:00
Klaus Heinrich Kiwi
baaf15f3b1 Clean-up digest context inside digest_mgr functions - CCA part
Same function as previous patch, but the CCA-specific part.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-12-18 15:18:55 -02:00
Klaus Heinrich Kiwi
f117bbfdde Clean-up digest context inside digest_mgr functions - TPM part
Same function as previous patch, but the TPM-specific part.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-12-18 15:18:55 -02:00
Klaus Heinrich Kiwi
8b73b1c613 Clean-up digest context inside digest_mgr functions
For most C_Digest* functions (exception is C_DigestKey), the spec
   specified the scenarios in which a digest operation should
   terminate (either due to error or normal finalization).

   This patch brings the digest_mgr_cleanup() function to be called
   from *inside* the digest_mgr_* functions, so we can better manage
   resources from a single place.

   This patch is for the `common` part, and also fix at least one
   memory leak in the software-fallback SHA1 code (where
   ckm_sha1_init could continuously allocate contexts without
   being properly cleaned-up)

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-12-18 15:18:55 -02:00
Klaus Heinrich Kiwi
12174ea2d8 Minor adjustments to inner-functions error condition propagation
There are functions which may return error conditions that are
  not being checked on return, and others which are being checked
  but always return the same value.

  This patch probably covers only a small fraction of them, but
  its a start.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-12-18 15:18:55 -02:00
Klaus Heinrich Kiwi
28375cb979 Minor changes to some (debugging) log messages
A set of fixes to some existing log messages, plus a bit of
  suppressing messages if the lower-level function is already
  logging error conditions in some way.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-12-18 15:18:55 -02:00
Klaus Heinrich Kiwi
41b41b23b0 Consolidate around p11_attribute_trim()
remove_leading_zeros() was incorrectly using memcpy() for
  overlapping memory segments. Replace it by a more-central
  p11_attribute_trim() function in the p11util.c file, and
  use memmove() instead.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-12-18 15:18:55 -02:00
Klaus Heinrich Kiwi
430394696c Properly dlclose() in 64 bit systems
If there ever was a bug with dlclose() in 64 bit systems,
 I dont see it happening anymore.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-12-18 15:18:55 -02:00
Klaus Heinrich Kiwi
966b333bf8 Create general-purpose hex-dump function in p11util.c
Create p11_ahex_dump() in p11util.c, that could be used
    elsewhere (for debugging purposes mostly).

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-12-08 17:56:27 -02:00
Klaus Heinrich Kiwi
b34b58026d Soft token: close file descriptor in RNG function
Fix leakage that may cause the process to run out of FDs when
   more than a certain number of sessions was opened.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-12-08 17:53:30 -02:00
Klaus Heinrich Kiwi
419c711816 ICA token: More robust validation for public exponent
Libica might hang if we provide an even public exponent for
  RSA keypair generation.

  Convert to a local representation (long int) so we can check.

  Also use p11_bignum_trim() to (possibly) trim-down the field
  sizes for the generated key.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-12-08 14:24:43 -02:00
Klaus Heinrich Kiwi
04dd6dc156 CCA token: Do better public exponent validation
The CCA token (as of Oct/2010, CCA library 4.0) can only support 3
  and 65537 (0x010001) as public exponents. It also supports specifying
  a 0x00 (zero) as a way to indicate that a random public exponent
  should be used, but even then this is only possible for key modulus
  lenghts up to 2048 bits.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-12-08 14:24:32 -02:00
Klaus Heinrich Kiwi
08fe158617 Soft token: Better public-exponent validation
OpenSSL might loop indefinitely if we provide an even or
    zero public exponent (e).

    * Fix byte-order issue for Little-endian archs
    * Explicitly fail with even numbers
    * Generate random odd number when e=0

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-12-08 14:24:23 -02:00
Klaus Heinrich Kiwi
9ae8ba0498 p11util.c: Introduce p11_bigint_trim() that can be used across the code
p11_bigint_trim() will trim a Big Integer (using the BIG ENDIAN
  PKCS#11 representation), taking unnecessary leading zeros.

  This function will be useful in properly converting PKCS#11
  numbers to native formats so we can check their contents.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-12-08 14:24:10 -02:00
Klaus Heinrich Kiwi
1e678c3d2e Revert "AES Unwrap: Fix CKA_VALUE_LEN handling"
This reverts commit 8f19afe291, which is causing some
odd memory-corruption issues, probably related to updating the CKA_VALUE_LEN
attribute of the AES key template without being sure it where/if it was
allocated.

Will need to come back with a different strategy.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-12-08 14:04:00 -02:00