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>
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>
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>
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>
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>
* 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>
* 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>
* 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>
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>
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>
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>
* 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>
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>
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>
* 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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
* 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>
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>
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>
- 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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
This patch moves tok_struct.h.in to tok_stuct.h in the aep token
directory as we won't be relying on configure to process this
file anymore.
Instead, use CONFIG_PATH macro that should be defined by at
build time by the compiler (and underlying build system).
Use #warnings and default values in case this is not explicitly
defined.
Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
Like other patches in this series, this patch avoids doing pathname
resolution at configure time by using sed to process scripts at
build time.
Also fixed to use standard directories and utilities variables
Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
Don't use AM_FLAGS, add a post-installation step to create
a PKCS11_TPM.so softlink (like other stdlls do)
Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
Don't use AM_FLAGS, use -hook instead of -local in install
targets, avoid redefining the libdir variable by using the
nobase_ prefix (like every other stdll is doing)
Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>