opencryptoki/opencryptoki-3.2-missing-sources-and-libraries.patch

409 lines
15 KiB
Diff
Raw Normal View History

diff --git a/configure.in b/configure.in
--- a/configure.in
+++ b/configure.in
@@ -4,7 +4,7 @@ AC_INIT([openCryptoki],[3.2],[opencryptoki-tech@lists.sourceforge.net])
dnl Needed for $target!
AC_CANONICAL_SYSTEM
-AM_INIT_AUTOMAKE([foreign 1.6])
+AM_INIT_AUTOMAKE([foreign 1.6 subdir-objects])
dnl Checks for header files.
AC_DISABLE_STATIC
diff --git a/usr/lib/pkcs11/cca_stdll/cca_specific.c b/usr/lib/pkcs11/cca_stdll/cca_specific.c
--- a/usr/lib/pkcs11/cca_stdll/cca_specific.c
+++ b/usr/lib/pkcs11/cca_stdll/cca_specific.c
@@ -2352,40 +2352,3 @@ token_specific_object_add(OBJECT *object)
return CKR_OK;
}
-
-CK_RV
-get_ecsiglen(OBJECT *key_obj, CK_ULONG *size)
-{
- CK_BBOOL flag;
- CK_ATTRIBUTE *attr = NULL;
- int i;
-
- flag = template_attribute_find( key_obj->template,
- CKA_ECDSA_PARAMS, &attr );
- if (flag == FALSE) {
- OCK_LOG_ERR(ERR_FUNCTION_FAILED);
- return CKR_FUNCTION_FAILED;
- }
-
- /* loop thru supported curves to find the size.
- * both pkcs#11v2.20 and CCA expect the signature length to be
- * twice the length of p.
- * (See EC Signatures in pkcs#11v2.20 and docs for CSNDDSG.)
- */
- for (i = 0; i < NUMEC; i++) {
- if ((memcmp(attr->pValue, der_ec_supported[i].data,
- attr->ulValueLen) == 0)) {
- *size = der_ec_supported[i].len_bits;
- /* round up if necessary */
- if ((*size % 8) == 0)
- *size = (*size / 8) * 2;
- else
- *size = ((*size / 8) + 1) * 2;
- OCK_LOG_DEBUG("getlen, curve = %d, size = %d\n", der_ec_supported[i].len_bits, *size);
- return CKR_OK;
- }
- }
-
- OCK_LOG_ERR(ERR_MECHANISM_PARAM_INVALID);
- return CKR_MECHANISM_PARAM_INVALID;
-}
diff --git a/usr/lib/pkcs11/common/mech_ec.c b/usr/lib/pkcs11/common/mech_ec.c
--- a/usr/lib/pkcs11/common/mech_ec.c
+++ b/usr/lib/pkcs11/common/mech_ec.c
@@ -19,6 +19,8 @@
#include "host_defs.h"
#include "h_extern.h"
#include "tok_spec_struct.h"
+#include <stdint.h>
+#include "ec_defs.h"
CK_RV
ckm_ec_key_pair_gen( TEMPLATE * publ_tmpl,
@@ -65,6 +67,43 @@ ckm_ec_sign( CK_BYTE *in_data,
}
CK_RV
+get_ecsiglen(OBJECT *key_obj, CK_ULONG *size)
+{
+ CK_BBOOL flag;
+ CK_ATTRIBUTE *attr = NULL;
+ int i;
+
+ flag = template_attribute_find( key_obj->template,
+ CKA_ECDSA_PARAMS, &attr );
+ if (flag == FALSE) {
+ OCK_LOG_ERR(ERR_FUNCTION_FAILED);
+ return CKR_FUNCTION_FAILED;
+ }
+
+ /* loop thru supported curves to find the size.
+ * both pkcs#11v2.20 and CCA expect the signature length to be
+ * twice the length of p.
+ * (See EC Signatures in pkcs#11v2.20 and docs for CSNDDSG.)
+ */
+ for (i = 0; i < NUMEC; i++) {
+ if ((memcmp(attr->pValue, der_ec_supported[i].data,
+ attr->ulValueLen) == 0)) {
+ *size = der_ec_supported[i].len_bits;
+ /* round up if necessary */
+ if ((*size % 8) == 0)
+ *size = (*size / 8) * 2;
+ else
+ *size = ((*size / 8) + 1) * 2;
+ OCK_LOG_DEBUG("getlen, curve = %d, size = %d\n", der_ec_supported[i].len_bits, *size);
+ return CKR_OK;
+ }
+ }
+
+ OCK_LOG_ERR(ERR_MECHANISM_PARAM_INVALID);
+ return CKR_MECHANISM_PARAM_INVALID;
+}
+
+CK_RV
ec_sign( SESSION *sess,
CK_BBOOL length_only,
SIGN_VERIFY_CONTEXT *ctx,
diff --git a/usr/lib/pkcs11/icsf_stdll/Makefile.am b/usr/lib/pkcs11/icsf_stdll/Makefile.am
--- a/usr/lib/pkcs11/icsf_stdll/Makefile.am
+++ b/usr/lib/pkcs11/icsf_stdll/Makefile.am
@@ -24,7 +24,8 @@ opencryptoki_stdll_libpkcs11_icsf_la_LDFLAGS = -shared \
-lcrypto \
-lldap \
-lpthread \
- -lrt
+ -lrt \
+ -llber
opencryptoki_stdll_libpkcs11_icsf_la_SOURCES = ../common/asn1.c \
../common/btree.c \
@@ -34,6 +35,7 @@ opencryptoki_stdll_libpkcs11_icsf_la_SOURCES = ../common/asn1.c \
../common/key.c \
../common/mech_dh.c \
../common/mech_rng.c \
+ ../common/mech_ec.c \
../common/new_host.c \
../common/sign_mgr.c \
../common/cert.c \
@@ -51,6 +53,7 @@ opencryptoki_stdll_libpkcs11_icsf_la_SOURCES = ../common/asn1.c \
../common/object.c \
../common/decr_mgr.c \
../common/globals.c \
+ ../common/sw_crypt.c \
../common/loadsave.c \
../common/utility.c \
../common/mech_des.c \
diff --git a/usr/lib/pkcs11/icsf_stdll/icsf.c b/usr/lib/pkcs11/icsf_stdll/icsf.c
--- a/usr/lib/pkcs11/icsf_stdll/icsf.c
+++ b/usr/lib/pkcs11/icsf_stdll/icsf.c
@@ -14,6 +14,7 @@
#include <string.h>
#include <ctype.h>
#include "icsf.h"
+#include <lber.h>
/* For logging functions: */
#include "defs.h"
diff --git a/usr/lib/pkcs11/soft_stdll/Makefile.am b/usr/lib/pkcs11/soft_stdll/Makefile.am
--- a/usr/lib/pkcs11/soft_stdll/Makefile.am
+++ b/usr/lib/pkcs11/soft_stdll/Makefile.am
@@ -23,6 +23,7 @@ opencryptoki_stdll_libpkcs11_sw_la_SOURCES = ../common/asn1.c \
../common/dig_mgr.c \
../common/encr_mgr.c \
../common/globals.c \
+ ../common/sw_crypt.c \
../common/loadsave.c \
../common/key.c \
../common/key_mgr.c \
@@ -36,6 +37,7 @@ opencryptoki_stdll_libpkcs11_sw_la_SOURCES = ../common/asn1.c \
../common/mech_rsa.c \
../common/mech_sha.c \
../common/mech_ssl3.c \
+ ../common/mech_ec.c \
../common/new_host.c \
../common/obj_mgr.c \
../common/object.c \
diff --git a/usr/lib/pkcs11/tpm_stdll/Makefile.am b/usr/lib/pkcs11/tpm_stdll/Makefile.am
--- a/usr/lib/pkcs11/tpm_stdll/Makefile.am
+++ b/usr/lib/pkcs11/tpm_stdll/Makefile.am
@@ -28,6 +28,7 @@ opencryptoki_stdll_libpkcs11_tpm_la_SOURCES = ../common/asn1.c \
../common/key.c \
../common/mech_dh.c \
../common/mech_rng.c \
+ ../common/mech_ec.c \
../common/new_host.c \
../common/sign_mgr.c \
../common/cert.c \
@@ -46,6 +47,7 @@ opencryptoki_stdll_libpkcs11_tpm_la_SOURCES = ../common/asn1.c \
../common/object.c \
../common/decr_mgr.c \
../common/globals.c \
+ ../common/sw_crypt.c \
../common/loadsave.c \
../common/utility.c \
../common/mech_des.c \
diff --git a/usr/lib/pkcs11/common/btree.c b/usr/lib/pkcs11/common/btree.c
--- a/usr/lib/pkcs11/common/btree.c
+++ b/usr/lib/pkcs11/common/btree.c
@@ -242,7 +242,7 @@ bt_node_free(struct btree *t, unsigned long node_num, void (*delete_func)(void *
*
* return 0 if binary tree has at least 1 node in use, !0 otherwise
*/
-inline int
+extern inline int
bt_is_empty(struct btree *t)
{
return (t->free_nodes == t->size);
diff --git a/usr/lib/pkcs11/common/ec_defs.h b/usr/lib/pkcs11/common/ec_defs.h
index 12e16c9..fd499de 100644
--- a/usr/lib/pkcs11/common/ec_defs.h
+++ b/usr/lib/pkcs11/common/ec_defs.h
@@ -30,18 +30,18 @@
/* Supported Elliptic Curves */
#define NUMEC 12 /* number of supported curves */
-CK_BYTE brainpoolP160r1[] = { 0x06, 0x09, 0x2B, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x01 };
-CK_BYTE brainpoolP192r1[] = { 0x06, 0x09, 0x2B, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x03 };
-CK_BYTE brainpoolP224r1[] = { 0x06, 0x09, 0x2B, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x05 };
-CK_BYTE brainpoolP256r1[] = { 0x06, 0x09, 0x2B, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x07 };
-CK_BYTE brainpoolP320r1[] = { 0x06, 0x09, 0x2B, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x09 };
-CK_BYTE brainpoolP384r1[] = { 0x06, 0x09, 0x2B, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x0B };
-CK_BYTE brainpoolP512r1[] = { 0x06, 0x09, 0x2B, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x0D };
-CK_BYTE prime192[] = { 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x01 };
-CK_BYTE secp224[] = { 0x06, 0x05, 0x2B, 0x81, 0x04, 0x00, 0x21 };
-CK_BYTE prime256[] = { 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07 };
-CK_BYTE secp384[] = { 0x06, 0x05, 0x2B, 0x81, 0x04, 0x00, 0x22 };
-CK_BYTE secp521[] = { 0x06, 0x05, 0x2B, 0x81, 0x04, 0x00, 0x23 };
+extern CK_BYTE brainpoolP160r1[];
+extern CK_BYTE brainpoolP192r1[];
+extern CK_BYTE brainpoolP224r1[];
+extern CK_BYTE brainpoolP256r1[];
+extern CK_BYTE brainpoolP320r1[];
+extern CK_BYTE brainpoolP384r1[];
+extern CK_BYTE brainpoolP512r1[];
+extern CK_BYTE prime192[];
+extern CK_BYTE secp224[];
+extern CK_BYTE prime256[];
+extern CK_BYTE secp384[];
+extern CK_BYTE secp521[];
// structure of supported Elliptic Curves
@@ -52,19 +52,5 @@ struct _ec {
CK_VOID_PTR data;
}__attribute__ ((__packed__));
-struct _ec der_ec_supported[NUMEC] = {
- {BRAINPOOL_CURVE, CURVE160, sizeof(brainpoolP160r1), &brainpoolP160r1},
- {BRAINPOOL_CURVE, CURVE192, sizeof(brainpoolP192r1), &brainpoolP192r1},
- {BRAINPOOL_CURVE, CURVE224, sizeof(brainpoolP224r1), &brainpoolP224r1},
- {BRAINPOOL_CURVE, CURVE256, sizeof(brainpoolP256r1), &brainpoolP256r1},
- {BRAINPOOL_CURVE, CURVE320, sizeof(brainpoolP320r1), &brainpoolP320r1},
- {BRAINPOOL_CURVE, CURVE384, sizeof(brainpoolP384r1), &brainpoolP384r1},
- {BRAINPOOL_CURVE, CURVE512, sizeof(brainpoolP512r1), &brainpoolP512r1},
- {PRIME_CURVE, CURVE192, sizeof(prime192), &prime192},
- {PRIME_CURVE, CURVE224, sizeof(secp224), &secp224},
- {PRIME_CURVE, CURVE256, sizeof(prime256), &prime256},
- {PRIME_CURVE, CURVE384, sizeof(secp384), &secp384},
- {PRIME_CURVE, CURVE521, sizeof(secp521), &secp521},
-};
-
+extern struct _ec der_ec_supported[NUMEC];
#endif
diff --git a/usr/lib/pkcs11/common/mech_ec.c b/usr/lib/pkcs11/common/mech_ec.c
index b9cb009..759af61 100644
--- a/usr/lib/pkcs11/common/mech_ec.c
+++ b/usr/lib/pkcs11/common/mech_ec.c
@@ -22,6 +22,34 @@
#include <stdint.h>
#include "ec_defs.h"
+CK_BYTE brainpoolP160r1[] = { 0x06, 0x09, 0x2B, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x01 };
+CK_BYTE brainpoolP192r1[] = { 0x06, 0x09, 0x2B, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x03 };
+CK_BYTE brainpoolP224r1[] = { 0x06, 0x09, 0x2B, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x05 };
+CK_BYTE brainpoolP256r1[] = { 0x06, 0x09, 0x2B, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x07 };
+CK_BYTE brainpoolP320r1[] = { 0x06, 0x09, 0x2B, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x09 };
+CK_BYTE brainpoolP384r1[] = { 0x06, 0x09, 0x2B, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x0B };
+CK_BYTE brainpoolP512r1[] = { 0x06, 0x09, 0x2B, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x0D };
+CK_BYTE prime192[] = { 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x01 };
+CK_BYTE secp224[] = { 0x06, 0x05, 0x2B, 0x81, 0x04, 0x00, 0x21 };
+CK_BYTE prime256[] = { 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07 };
+CK_BYTE secp384[] = { 0x06, 0x05, 0x2B, 0x81, 0x04, 0x00, 0x22 };
+CK_BYTE secp521[] = { 0x06, 0x05, 0x2B, 0x81, 0x04, 0x00, 0x23 };
+
+struct _ec der_ec_supported[NUMEC] = {
+ {BRAINPOOL_CURVE, CURVE160, sizeof(brainpoolP160r1), &brainpoolP160r1},
+ {BRAINPOOL_CURVE, CURVE192, sizeof(brainpoolP192r1), &brainpoolP192r1},
+ {BRAINPOOL_CURVE, CURVE224, sizeof(brainpoolP224r1), &brainpoolP224r1},
+ {BRAINPOOL_CURVE, CURVE256, sizeof(brainpoolP256r1), &brainpoolP256r1},
+ {BRAINPOOL_CURVE, CURVE320, sizeof(brainpoolP320r1), &brainpoolP320r1},
+ {BRAINPOOL_CURVE, CURVE384, sizeof(brainpoolP384r1), &brainpoolP384r1},
+ {BRAINPOOL_CURVE, CURVE512, sizeof(brainpoolP512r1), &brainpoolP512r1},
+ {PRIME_CURVE, CURVE192, sizeof(prime192), &prime192},
+ {PRIME_CURVE, CURVE224, sizeof(secp224), &secp224},
+ {PRIME_CURVE, CURVE256, sizeof(prime256), &prime256},
+ {PRIME_CURVE, CURVE384, sizeof(secp384), &secp384},
+ {PRIME_CURVE, CURVE521, sizeof(secp521), &secp521},
+};
+
CK_RV
ckm_ec_key_pair_gen( TEMPLATE * publ_tmpl,
TEMPLATE * priv_tmpl )
diff --git a/usr/lib/pkcs11/ep11_stdll/Makefile.am b/usr/lib/pkcs11/ep11_stdll/Makefile.am
index d587fd2..fba4889 100644
--- a/usr/lib/pkcs11/ep11_stdll/Makefile.am
+++ b/usr/lib/pkcs11/ep11_stdll/Makefile.am
@@ -31,6 +31,7 @@ opencryptoki_stdll_libpkcs11_ep11_la_SOURCES = ../common/asn1.c \
../common/mech_des.c \
../common/mech_des3.c \
../common/mech_aes.c \
+ ../common/mech_ec.c \
../common/mech_md5.c \
../common/mech_md2.c \
../common/mech_rng.c \
diff --git a/usr/lib/pkcs11/ica_s390_stdll/Makefile.am b/usr/lib/pkcs11/ica_s390_stdll/Makefile.am
index 6d1c3e8..5d17f81 100644
--- a/usr/lib/pkcs11/ica_s390_stdll/Makefile.am
+++ b/usr/lib/pkcs11/ica_s390_stdll/Makefile.am
@@ -28,12 +28,14 @@ opencryptoki_stdll_libpkcs11_ica_la_SOURCES = ../common/asn1.c \
../common/dig_mgr.c \
../common/encr_mgr.c \
../common/globals.c \
+ ../common/sw_crypt.c \
../common/loadsave.c \
../common/key.c \
../common/key_mgr.c \
../common/mech_des.c \
../common/mech_des3.c \
../common/mech_aes.c \
+ ../common/mech_ec.c \
../common/mech_md5.c \
../common/mech_md2.c \
../common/mech_rng.c \
diff --git a/usr/sbin/pkcsicsf/pkcsicsf.c b/usr/sbin/pkcsicsf/pkcsicsf.c
index 55efc4f..ec05edf 100644
--- a/usr/sbin/pkcsicsf/pkcsicsf.c
+++ b/usr/sbin/pkcsicsf/pkcsicsf.c
@@ -8,6 +8,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <strings.h>
#include "icsf.h"
#include "slotmgr.h"
diff --git a/usr/sbin/pkcsslotd/mutex.c b/usr/sbin/pkcsslotd/mutex.c
index c517e66..b3f6309 100755
--- a/usr/sbin/pkcsslotd/mutex.c
+++ b/usr/sbin/pkcsslotd/mutex.c
@@ -292,6 +292,9 @@
#include <stdarg.h>
#include <sys/types.h>
#include <sys/file.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <unistd.h>
#include <grp.h>
#include "log.h"
diff --git a/usr/lib/pkcs11/common/mech_rng.c b/usr/lib/pkcs11/common/mech_rng.c
index be3e858..f3bd861 100755
--- a/usr/lib/pkcs11/common/mech_rng.c
+++ b/usr/lib/pkcs11/common/mech_rng.c
@@ -301,6 +301,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <unistd.h>
#include "pkcs11types.h"
diff --git a/usr/sbin/pkcsslotd/garbage_linux.c b/usr/sbin/pkcsslotd/garbage_linux.c
index 90492ce..c3c5564 100755
--- a/usr/sbin/pkcsslotd/garbage_linux.c
+++ b/usr/sbin/pkcsslotd/garbage_linux.c
@@ -294,6 +294,7 @@
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
+#include <unistd.h>
#include "log.h"
#include "slotmgr.h"
diff --git a/usr/sbin/pkcsslotd/log.c b/usr/sbin/pkcsslotd/log.c
index 859a421..f6112d2 100755
--- a/usr/sbin/pkcsslotd/log.c
+++ b/usr/sbin/pkcsslotd/log.c
@@ -294,6 +294,8 @@
#include <syslog.h>
#include <stdarg.h>
#include <sys/types.h>
+#include <unistd.h>
+#include <stdlib.h>
#include "log.h"
#include "err.h"
diff --git a/usr/sbin/pkcsslotd/slotmgr.c b/usr/sbin/pkcsslotd/slotmgr.c
index b164e42..f8667d1 100755
--- a/usr/sbin/pkcsslotd/slotmgr.c
+++ b/usr/sbin/pkcsslotd/slotmgr.c
@@ -292,9 +292,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
+#include <unistd.h>
#include "log.h"
#include "slotmgr.h"
+#include "pkcsslotd.h"
+#include "parser.h"
Slot_Mgr_Shr_t *shmp; // pointer to the shared memory region.
int shmid;