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

483 Commits

Author SHA1 Message Date
Kent Yoder
23955a041d soft token mechanism flag changes
Removed CKF_HW flags from all soft token mechanisms and added the
CKF_GENERATE flag to the AES keygen mechanism.

Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
2010-07-28 16:11:09 -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
Kent Yoder
94571bcbd4 soft token mechanism list issues
It looks like the soft token is reporting that it does SHA256 in its
mechanism list, although its not implemented in the code. A
patch to fix that follows.

Also I noticed that all the soft token mechanisms report that
they're implemented in hardware by returning the CKF_HW
flag in their mechanism info flags.  I can also submit a
patch to correct that as well...

Thanks,
Kent

Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
2010-07-27 17:54:27 -03:00
Klaus Heinrich Kiwi
78d4d0b1b2 Fix TPM token:undefined symbol
As happened with the CCA token, the TPM token broke due to the changes
introduced with the handle performance patches.
Fix by propagating the necessary changes to the TPM token

The symptom:
libpkcs11_tpm.so: undefined symbol: session_mgr_readonly_exists

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-07-20 13:43:02 -03:00
Klaus Heinrich Kiwi
f49a1f5c64 Fix CCA token: undefined symbol
The CCA token broke after the recent session/object handlers patches.
This patch replicates some of the changes introduced in the common code,
thus fixing the issue.

The symptom:
libpkcs11_cca.so: undefined symbol: session_mgr_readonly_exists

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-07-20 13:42:52 -03:00
Klaus Heinrich Kiwi
b94638fd93 RPM Spec files refactor
Clean-up and refacor the RPM file. Main changes are:
 * Use separate packages for each token STDLL
 * Track directories (including /var/lib/opencryptki/*) more closely

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-07-20 13:39:58 -03:00
Klaus Heinrich Kiwi
ceee7028f8 Move specific documentation to doc/
Documentation files were scattered across different places. Consolidate
them in doc/ to make packaging easier, while avoiding collisions.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-07-20 13:39:33 -03:00
Klaus Heinrich Kiwi
93ada245fd Create local state directories when installing
* Create the local state directory for opencryptoki (usually
  $prefix/var/lib/opencryptoki) when installing pkcs_slot.
  pkcs_slot can take care of creating it on the first execution,
  but creating it on 'make install' allow us to proper package
  it.

* The pkcs_slot script already creates those directories
  if not present, but explicitly creating them in 'make install'
  allows us to better packaging

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-07-20 13:38:59 -03:00
Klaus Heinrich Kiwi
53b3cb942b Autoconf target fixes
* GNU autoconf documentation says we should use $host instead of
  $target if we're not building a compiler. It turns out that
  RPM seems to have a different interpretation of that.
  Reverting to the previous behavior.

* Don't touch CFLAGS based on the $target_cpu when ./configure'ing, as it
  should already contain everything necessary from the configure script
  command line or environment.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-07-20 13:38:49 -03:00
Klaus Heinrich Kiwi
3ac6f16653 Don't use $DESTDIR in references
* The loader cache configuration files in ld.so.conf.d must use an absolute
   path for the librarie

 * Use relative links for installing the API symlinks

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-07-20 13:38:39 -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
270231a997 Use pointer as session handler in common library layer
Avoid iterating through the common library layer's session list
by assigning the session's own pointer as the handler.

This is similar to commit "Use pointer as session handler
in API layer", although unlikely to cause segfaults due to tracking
being done in the API layer.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-07-05 09:34:31 -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
89bfcc1015 Optimize tracking for Read-Only sessions and login state
* Use counter to track number of read-only sessions:
   Use global "ro_session_count" counter to track the number
   of existing read-only sessions, since this information
   is necessary to check if the SO can perform log-in

 * Adjust session_mgr_so_session_exists() and
   session_mgr_user_session_exists() to take advantage of
   the global login state: All sessions must be either logged
   in as user, as SO or are public sessions. This patch
   makes use of global login state infrastructure that was
   already there.

 * Rename session_mgr_readonly_exists() to
   session_mgr_readonly_session_exists() for consistency.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-07-05 09:34:05 -03:00
Klaus Heinrich Kiwi
d89df88ca3 Remove duplicate object_mgr_remove_from_map() function
object_mgr_remove_from_map() is doing the exact same thing
as object_mgr_invalidate_handle().

This patch removes object_mgr_remove_from_map() and changes
all of it's callers to call object_mgr_invalidate_handle1()
instead

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-07-05 09:33:29 -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
Kent Yoder
ad9d1c67fa Print readable mechanism info in pkcsconf -m output, round 2
This patch adds the text of the mechanism type and its flags to the output of pkcsconf -m.

Old:
Mechanism #2
        Mechanism: 0x131
        Key Size: 24-24
        Flags: 0x8001
Mechanism #3
        Mechanism: 0x1
        Key Size: 512-2048
        Flags: 0x67B01

New:
Mechanism #2
        Mechanism: 0x131 (CKM_DES3_KEY_GEN)
        Key Size: 24-24
        Flags: 0x8001 (CKF_HW|CKF_GENERATE)
Mechanism #3
        Mechanism: 0x1 (CKM_RSA_PKCS)
        Key Size: 512-2048
        Flags: 0x67B01 (CKF_HW|CKF_ENCRYPT|CKF_DECRYPT|CKF_SIGN|CKF_SIGN_RECOVER|CKF_VERIFY|CKF_VERIFY_RECOVER|CKF_WRAP|CKF_UNWRAP)

Addressed Klaus Kiwi's concerns on using the mechanism and flag values from pkcs11types.h.

This patch should apply cleanly to the opencryptoki-next branch.

signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
2010-06-23 13:23:03 -03:00
Klaus Heinrich Kiwi
d32e657e12 Misc Autoconf/automake fixes
* Rework configure.in to enable tokens automatically if requirements
   are met. The reason for this is to allow opencryptoki to build
   with the most features possible while still allowing consistency and
   unambiguity across architectures.

 * Get rid of S390 macro, don't have additional conditionals in the
   token stdll Makefiles

 * Use $host_cpu instead of $target

 * Not bringing -m64 or -m32 explicitly in CFLAGS causes gcc
   to build files for whatever architecture it was configured
   to, not paying attention to --host flags.  This may cause confusion
   interpreting why some autoconf tests failed (namely: OpenSSL on ppc64)

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-06-21 15:16:41 -03:00
Klaus Heinrich Kiwi
43fd4c64d1 Autoconf: Check for expect when building testcases
Explicitly check for 'expect' presence when --enable-testcases is
enabled.

Plus a couple of braces in autoconf macros just for consistency

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-06-21 15:12:35 -03:00
Klaus Heinrich Kiwi
f6fc519f77 Automake: Exclude ica_stdll from build, use ica_s390_stdll instead
ica_stdll is legacy and not being activelly maintained. Exclude it from
the build system (the code is still there), simplifying Automake.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-06-21 15:12:29 -03:00
Klaus Heinrich Kiwi
7bf357dc42 Automake: Use hardcoded path for ld.so.conf
use /etc instead of automake macros for ld.so.conf, since this file
really only makes sense there.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-06-21 15:12:21 -03:00
Klaus Heinrich Kiwi
2336e1f667 Important fixes to the RSA mechanisms
The last couple of commits refactored some of the RSA mechanisms in
common/mech_rsa.c, mainly around PKCS#1 v1.5 padding handling. Those
also introduced a couple of issues that are being resolved by this
patch:

 * Segfault when rsa_format_block() was called with block type '2',
   caused by un-initialized 'i'
 * Possible presence of null-padding bytes generated by rng_generate()
   rsa_format_block(), which would cause an invalid padding. Both this
   and the above item were fixed by generating the random padding bytes
   one-by-one, and replacing 0x00 by 0xff when needed.
 * RSA Verify and VerifyRecover were calling rsa_format_block() with
   block type '2', when the PKCS#1 specified block type '1'.
 * rsa_parse_block() may return 'CKR_ENCRYPTED_DATA_INVALID' when it
   verifies that the signature is invalid. PKCS#1 specifies that the
   caller shouldn't be able to distinguish between padding errors and
   invalid signatures. Fixed by adjusting some return codes as well as
   the calling functions. RSA Verify and VerifyRecover should return
   'CKR_SIGNATURE_INVALID'
 * Remove the '195 - RSA Parse block failed' log message as it may
   indicate failure in decoding PKCS#1 v.1.5 padding, thus breaking the
   spec.

With the above, all tests in testcases/drivers/rsa_func.c are now
passing.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-06-19 10:16:39 -03:00
Ramon de Carvalho Valle
932015234c Add rsa_parse_block error message
Add the "RSA Parse Block Failed" error message at index 195 in the error
messages array. However, I think this should go at index 130 to replace
the "Random Number Generate Failed" error message, which appears to out
of place.

Signed-off-by: Ramon de Carvalho Valle <rcvalle@linux.vnet.ibm.com>
2010-06-18 12:58:27 -03:00
Ramon de Carvalho Valle
17aa95cd4d Modify PKCS functions to use rsa_parse_block
Modify rsa_pkcs_verify and rsa_pkcs_verify_recover functions in RSA
mechanisms to use rsa_parse_block function.

Signed-off-by: Ramon de Carvalho Valle <rcvalle@linux.vnet.ibm.com>
2010-06-18 12:58:27 -03:00
Ramon de Carvalho Valle
5589c2d592 Repl rsa_format_block function in RSA mechanisms
Replace rsa_format_block function in RSA mechanisms. The
rsa_format_block function formats an encryption block according to
PKCS #1: RSA Encryption, Version 1.5.

Signed-off-by: Ramon de Carvalho Valle <rcvalle@linux.vnet.ibm.com>
2010-06-18 12:58:16 -03:00
Ramon de Carvalho Valle
d9696ecd8c Fix CKR_BUFFER_TOO_SMALL error messages
Fix CKR_BUFFER_TOO_SMALL error messages used by st_err_log function in
RSA mechanisms.

Signed-off-by: Ramon de Carvalho Valle <rcvalle@linux.vnet.ibm.com>
2010-06-18 11:38:15 -03:00
Ramon de Carvalho Valle
04a44ecb38 Add rsa_parse_block function to RSA mechanisms
Add rsa_parse_block function to RSA mechanisms. The rsa_parse_block
function parses an encryption block according to PKCS #1: RSA
Encryption, Version 1.5.

Signed-off-by: Ramon de Carvalho Valle <rcvalle@linux.vnet.ibm.com>
2010-06-18 11:37:53 -03:00
Ramon de Carvalho Valle
2fee6b773a Check the return values of RSA functions
Check the return values of RSA_public_encrypt and RSA_private_decrypt
functions appropriately.

Signed-off-by: Ramon de Carvalho Valle <rcvalle@linux.vnet.ibm.com>
2010-06-18 11:37:04 -03:00
Klaus Heinrich Kiwi
8444db63db Fix minor typo in pkcsconf output
Fix minor typo in pkcsconf ouput when no slots were found.
C_GetSlotCount is in reality C_GetSlotList

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-06-11 12:03:14 -03:00
Dan Horák
248606bef0 print usage information when no option is given
When no option is given pkcsconf does nothing and quits silently with a zero
return code. It should output the usage information and return non-zero code.

Signed-off-by: Dan Horák <dan@danny.cz>
2010-05-19 17:00:22 -03:00
Dan Horák
d0c56c2b21 add -h command line option
The recent code treats -h as unknown options and throws an error.

Signed-off-by: Dan Horák <dan@danny.cz>
2010-05-19 17:00:16 -03:00
Dan Horák
5532243e95 don't set TERM signal explicitely when calling killproc
The TERM signal is sent by default when the killproc function is called.
Also the pid file created by the pkcsslotd executable is removed by the
initscript (resp. by the killproc function) only when no signal is set.
Other solution how to remove the pid file is to remove it directly by the
executable.

Signed-off-by: Dan Horák <dan@danny.cz>
2010-05-04 13:33:07 -03:00
Dan Horák
f49465135c sync pidfile path between pkcsslotd initscript and executable
pkcsslotd executable creates a pidfile as /var/lib/opencryptoki/.slotpid
(CONFIG_PATH + "/.slotpid"), but the corresponding initscipt expects the
pidfile at /var/run/pkcsslotd.pid and this one is used to check whether
the service is running etc. The attached patch switches pkcsslotd to using
the /var/run/pkcsslotd.pid one and also simplifies the logic in the initscript
because the daemon function takes care of the checked cases.

Signed-off-by: Dan Horák <dan@danny.cz>
2010-05-04 13:32:32 -03:00
Dan Horák
14582a5292 add force-reload action to pkcsslotd initscript
force-reload action is added to the pkcsslotd initscript and also
it's documented in usage message together with reload action

Signed-off-by: Dan Horák <dan@danny.cz>
2010-05-04 13:31:49 -03:00
Klaus Heinrich Kiwi
789d86ee16 Merge branch 'master' into opencryptoki-next
* master:
  Fixed the pkcsslotd init script to make it return codes according to LSB specification.
  Version update.
  Fix wrong log message for "API already initialized" condition
  Check for vendor-defined object classes
  Fix public exponent attribute endianness bug
  AES support included into the CCA token.
  Makes pkcscca_migrate tool link dynamically to libcsulcca.so by using dlopen() instead.

Conflicts:
	configure.in - took version number from master ("2.3.1")

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-05-04 10:51:38 -03:00
Rajiv Andrade
54a2a77172 Fixed the pkcsslotd init script to make it return codes according to LSB specification.
Signed-off-by: Dan Horák <dhorak@redhat.com>
2010-04-15 16:56:07 -03:00
Rajiv Andrade
5852a772f5 Version update.
Signed-off-by: Rajiv Andrade <srajiv@linux.vnet.ibm.com>
2010-04-15 16:56:03 -03:00
Klaus Heinrich Kiwi
badd112599 Fix wrong log message for "API already initialized" condition
Trivial fix to log "API already initialized" instead of "API not initialized".

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-01-26 11:51:56 -02:00
Ramon de Carvalho Valle
c6fc188f68 Check for vendor-defined object classes
Check for vendor-defined object classes and return
CKR_ATTRIBUTE_TYPE_INVALID when trying to create a vendor-defined
object.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-01-26 11:01:16 -02:00
Ramon de Carvalho Valle
fd5fe76c60 Fix public exponent attribute endianness bug
Fix a endianness bug while reading the public exponent attribute from
public template.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
Signed-off-by: Ramon de Carvalho Valle <rcvalle@linux.vnet.ibm.com>
2010-01-26 11:01:15 -02:00
Rajiv Andrade
7094f60892 AES support included into the CCA token.
- Key generation
  - CBC mode with and without padding
  - ECB mode

4096 bit RSA keys support included.

Signed-off-by: Rajiv Andrade <srajiv@linux.vnet.ibm.com>
2010-01-26 11:00:35 -02:00
Rajiv Andrade
d335aa391e Makes pkcscca_migrate tool link dynamically to libcsulcca.so by using dlopen() instead.
Removed its TODO entry.

Signed-off-by: Rajiv Andrade <srajiv@linux.vnet.ibm.com>
2010-01-26 00:35:07 -02:00
Klaus Heinrich Kiwi
e1956cf493 configure.in: complete refactor.
Unfortunately I couldn't split this patch in a sane way, because
essentially we're rewriting configure.in here.

In summary, the main changes are:

 * Use AC_ARG_ENABLE() only to enable/disable building certain parts
   of the code
 * Use AC_ARG_WITH() only to specify libraries that may be needed by
   certain portions of the code
 * All AC_ARG_ENABLE() macros comes with architecture-independent
   defaults. This means that we won't be trying to guess what
   features (tokens) we should or should not be building.
 * All AC_ARG_WITH() macros have 'check' as the default (check for
   that library in the default search path)
 * IMPORTANT: Separate pkcscca_migrate from cca token build, as only
   the former requires the CCA libraries to link.
 * No more dependencies of what stdll can be built based on arch.
   Theoretically all stdll can be built on all archs, given that
   it has the relevant libraries also (we know this is not always
   true, so sometimes the user needs to explicitly disable a token
   with --without-FEATURE to build on certain archs)
 * The (special case of) ica stdll: builds ica_s390_stdll on s390
   archs while using ica_stdll on any other arch.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-01-12 16:09:31 -02:00
Klaus Heinrich Kiwi
f485dfacbd software token: use compiler flags (C macro) to resolve directories
Same as other patches in this series, use C macros defined at
build time to resolve directories.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-01-12 16:09:28 -02:00
Klaus Heinrich Kiwi
886b96da8b TPM token: use compiler flags (C macro) to resolve directories
Same as other patches in this series, use C macros defined at
build time to resolve directories.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-01-12 16:09:25 -02:00
Klaus Heinrich Kiwi
37880f443f Minor fixes and cleanups to API Makefile.am
Don't use AM_FLAGS, use -hook instead of -local target, use
more standardized dir variables and don't do any of the
groupadd, and mkdir, chown, chmod in the database dir (as
this is already being done each time pkcs11_startup is called)

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-01-12 16:03:02 -02:00
Klaus Heinrich Kiwi
9661b7f83d 4758_status: Standardize Makefile.am
Install 4758_status on libexec dir. No need to make arch-specific
checks here either.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-01-12 16:02:59 -02:00
Klaus Heinrich Kiwi
4e1b271193 ica token: use compiler flags (C macro) to resolve directories
Same as other patches in this series, use C macros defined at
build time to resolve directories.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-01-12 16:02:56 -02:00
Klaus Heinrich Kiwi
18d76f7096 ica (s390) token: use compiler flags (C macro) to resolve directories
Same as other patches in this series, use C macros defined at
build time to resolve directories.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-01-12 16:02:52 -02:00
Klaus Heinrich Kiwi
0c9e4e78c1 Corrent token: use compiler flags (C macro) to resolve directories
Same as other patches in this series, use C macros defined at
build time to resolve directories.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-01-12 16:02:18 -02:00