Compare commits
No commits in common. 'i10c-beta' and 'c9' have entirely different histories.
@ -1,2 +1,2 @@
|
|||||||
SOURCES/gpgkey-8E1F50C1.gpg
|
SOURCES/gpgkey-8E1F50C1.gpg
|
||||||
SOURCES/tpm2-pkcs11-1.9.0.tar.gz
|
SOURCES/tpm2-pkcs11-1.5.0.tar.gz
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
46f82c0fdf30219e0d95c6e9291bbc708b315080 SOURCES/gpgkey-8E1F50C1.gpg
|
46f82c0fdf30219e0d95c6e9291bbc708b315080 SOURCES/gpgkey-8E1F50C1.gpg
|
||||||
fe9fc7b023d56791ac1b03e5021ff21955b4f134 SOURCES/tpm2-pkcs11-1.9.0.tar.gz
|
9d4ad805203f0f063772f0c737bed949dfff52bd SOURCES/tpm2-pkcs11-1.5.0.tar.gz
|
||||||
|
@ -0,0 +1,100 @@
|
|||||||
|
diff -urN tpm2-pkcs11-1.5.0/src/lib/ssl_util.c tpm2-pkcs11-1.5.0-fix/src/lib/ssl_util.c
|
||||||
|
--- tpm2-pkcs11-1.5.0/src/lib/ssl_util.c 2020-11-03 17:36:45.000000000 -0700
|
||||||
|
+++ tpm2-pkcs11-1.5.0-fix/src/lib/ssl_util.c 2021-05-26 10:17:23.723128758 -0700
|
||||||
|
@@ -438,82 +438,29 @@
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static CK_RV create_ecdsa_sig(CK_BYTE_PTR sig, CK_ULONG siglen, ECDSA_SIG **outsig) {
|
||||||
|
-
|
||||||
|
- if (siglen & 1) {
|
||||||
|
- LOGE("Expected ECDSA signature length to be even, got : %lu",
|
||||||
|
- siglen);
|
||||||
|
- return CKR_SIGNATURE_LEN_RANGE;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- size_t len = siglen >> 1;
|
||||||
|
-
|
||||||
|
- unsigned char *rbuf = sig;
|
||||||
|
- unsigned char *sbuf = &sig[len];
|
||||||
|
-
|
||||||
|
- BIGNUM *r = BN_bin2bn(rbuf, len, NULL);
|
||||||
|
- if (!r) {
|
||||||
|
- LOGE("Could not make bignum for r");
|
||||||
|
- return CKR_GENERAL_ERROR;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- BIGNUM *s = BN_bin2bn(sbuf, len, NULL);
|
||||||
|
- if (!s) {
|
||||||
|
- LOGE("Could not make bignum for s");
|
||||||
|
- BN_free(r);
|
||||||
|
- return CKR_GENERAL_ERROR;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- ECDSA_SIG *ossl_sig = ECDSA_SIG_new();
|
||||||
|
- if (!ossl_sig) {
|
||||||
|
- LOGE("oom");
|
||||||
|
- return CKR_HOST_MEMORY;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- int rc = ECDSA_SIG_set0(ossl_sig, r, s);
|
||||||
|
- if (!rc) {
|
||||||
|
- LOGE("Could not call ECDSA_SIG_set0");
|
||||||
|
- ECDSA_SIG_free(ossl_sig);
|
||||||
|
- return CKR_GENERAL_ERROR;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- *outsig = ossl_sig;
|
||||||
|
-
|
||||||
|
- return CKR_OK;
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
static CK_RV do_sig_verify_ec(EVP_PKEY *pkey,
|
||||||
|
CK_BYTE_PTR digest, CK_ULONG digest_len,
|
||||||
|
CK_BYTE_PTR signature, CK_ULONG signature_len) {
|
||||||
|
|
||||||
|
- EC_KEY *eckey = EVP_PKEY_get0_EC_KEY(pkey);
|
||||||
|
- if (!eckey) {
|
||||||
|
- LOGE("Expected EC Key");
|
||||||
|
- return CKR_GENERAL_ERROR;
|
||||||
|
- }
|
||||||
|
+ int rc = CKR_OK;
|
||||||
|
+ EVP_PKEY_CTX *pctx = NULL;
|
||||||
|
|
||||||
|
- /*
|
||||||
|
- * OpenSSL expects ASN1 framed signatures, PKCS11 does flate
|
||||||
|
- * R + S signatures, so convert it to ASN1 framing.
|
||||||
|
- * See:
|
||||||
|
- * https://github.com/tpm2-software/tpm2-pkcs11/issues/277
|
||||||
|
- * For details.
|
||||||
|
- */
|
||||||
|
- ECDSA_SIG *ossl_sig = NULL;
|
||||||
|
- CK_RV rv = create_ecdsa_sig(signature, signature_len, &ossl_sig);
|
||||||
|
- if (rv != CKR_OK) {
|
||||||
|
- return rv;
|
||||||
|
+ if ((pctx = EVP_PKEY_CTX_new(pkey, NULL)) == NULL) {
|
||||||
|
+ rc = CKR_HOST_MEMORY;
|
||||||
|
+ goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
- int rc = ECDSA_do_verify(digest, digest_len, ossl_sig, eckey);
|
||||||
|
- if (rc < 0) {
|
||||||
|
- ECDSA_SIG_free(ossl_sig);
|
||||||
|
- SSL_UTIL_LOGE("ECDSA_do_verify failed");
|
||||||
|
- return CKR_GENERAL_ERROR;
|
||||||
|
+ if (EVP_PKEY_verify_init(pctx) != 1 ||
|
||||||
|
+ EVP_PKEY_verify(pctx, signature, signature_len,
|
||||||
|
+ digest, digest_len) != 1) {
|
||||||
|
+ rc = CKR_SIGNATURE_INVALID;
|
||||||
|
+ goto fail;
|
||||||
|
}
|
||||||
|
- ECDSA_SIG_free(ossl_sig);
|
||||||
|
|
||||||
|
- return rc == 1 ? CKR_OK : CKR_SIGNATURE_INVALID;
|
||||||
|
+fail:
|
||||||
|
+ if (pctx)
|
||||||
|
+ EVP_PKEY_CTX_free(pctx);
|
||||||
|
+ return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
CK_RV ssl_util_sig_verify(EVP_PKEY *pkey,
|
@ -0,0 +1,16 @@
|
|||||||
|
-----BEGIN PGP SIGNATURE-----
|
||||||
|
|
||||||
|
iQIzBAABCgAdFiEEW0grjj4Z2nyXjh0BbeLpB44fUMEFAl+ysTkACgkQbeLpB44f
|
||||||
|
UMGhSBAAx2FY2flB6vuetgdKoh4G85Zgq8+xsmjsTRoXT8/4tS8wPL64ESYo89pG
|
||||||
|
mhVr4KBb5tNVwntA73aQ/ko82zPnVSTFW0nHODTICME1NRnAZQpUJ1emZtRQdnxL
|
||||||
|
ByZPNx2ub41zepsorqABxYZlugVX4j9GRK7HpyC3OKxw51Cvua8Ciww1u2uSELlU
|
||||||
|
JjUbhUXJICAYcn31hKYcASHsYB7fio2QrmjGG8ZHiz2Dh1hW1kn5ezsgUKUIMYxQ
|
||||||
|
bFcPmWcZF1N9GD5PB/LxE0V25ZiRxXUCfG0YfYR6fWY2uIfIW4izcgLZJI07KGnM
|
||||||
|
rkW1nnBvzRvKTm6JALHoqnycIyfXJFYY/eJtXT0Yom1HKXEFEc4r9w5lor2pu6HP
|
||||||
|
oE6z0pwLPXpbGhoOQ7m5IY6xfCmYtnMeb6f0qrEayGO4B9nAR4GUr6lagVeFK2Af
|
||||||
|
0cOh2lyu2zo7qvgJxEk3DxYruiO3ivLMxm6h5Bt6UgkS605qNYb3R22hFR8uq3em
|
||||||
|
ospbRcoxOaaIvxkIwqFm45sWNJOtxj25p0uPKEMmKKiBIbXadjSKoPcTFf2ihla3
|
||||||
|
bRdg5zs8Sph4PkiESjR9UebNXvTL1h/ZTsrpM2BjprC9a4Aqyx8K/FTOVWFcXOim
|
||||||
|
L/pa8fqwfI72BdasPtB+J+afP+bFQ+lxnrGHuPLHB4MjfVdvzyQ=
|
||||||
|
=V8As
|
||||||
|
-----END PGP SIGNATURE-----
|
@ -1,16 +0,0 @@
|
|||||||
-----BEGIN PGP SIGNATURE-----
|
|
||||||
|
|
||||||
iQIzBAABCgAdFiEEW0grjj4Z2nyXjh0BbeLpB44fUMEFAmPZLrwACgkQbeLpB44f
|
|
||||||
UMG/fxAAq6LcxojU451o7FavO481TX3zq3qyYTmEkrTtRO2rnbKEyOcDP75FOYG7
|
|
||||||
8gFFEZYNgucFU9qW9vzqe7d4whokijozNVcUy7+Wz/qr2e2DTEom8jC/1FIrBwQT
|
|
||||||
Ahn6w+vCjYm8ZBcBO5w97U8ZDOB7FOovFRZBMaDuyWeEVsVxN3xWupAmth4B6L2h
|
|
||||||
W8CmuQZTDAX2SmbbjnmBSCDkW8/hyuSIcHzsTRUxeRsVe2WVoGKUkl39zDHOJsOi
|
|
||||||
Fo/uEkZiwVGFQtNo7LxCXooXZfcpfKDK2AL9fto03Rl4DTB7CW5xqEK3ybECa89i
|
|
||||||
8sed2wMQLMibwzbln2GGfOu/Lr6We3nd98FEitKKXeSuMraDp5m0r+JMLvx43d9J
|
|
||||||
vGHVLJoEQ3JabUUctxOi5R2ZYYEalBRzuBwpDt1qWhGqwt0VAOKVrW3NMs3vJci5
|
|
||||||
bFG2sVxiekTK26S2ozsr0Pivl6mAlZRDGVAoff1iiLWJAr10hmGV7etSsARR87Ag
|
|
||||||
lSnGBCqwk1d9RzI1VigXIbR0ZdHotry2B4CjIQDm4y71JLJopc4hpjD5tDFz5PZ6
|
|
||||||
bLCV4jVrBq5kjgABMcIY/MmMPQ+2oE2x2Manqbj2T18mHQYj7rKhJ94ZRlJxILE4
|
|
||||||
C29jS025HtEsYc+FVO2qfCok5p0p6v4n1aBrkzr4S6/RGUwy19s=
|
|
||||||
=9JcL
|
|
||||||
-----END PGP SIGNATURE-----
|
|
@ -0,0 +1,51 @@
|
|||||||
|
diff --git a/src/lib/slot.c b/src/lib/slot.c
|
||||||
|
index b3c7c82..f0a4f2e 100644
|
||||||
|
--- a/src/lib/slot.c
|
||||||
|
+++ b/src/lib/slot.c
|
||||||
|
@@ -120,7 +120,9 @@ CK_RV slot_get_info (CK_SLOT_ID slot_id, CK_SLOT_INFO *info) {
|
||||||
|
}
|
||||||
|
|
||||||
|
str_padded_copy(info->manufacturerID, token_info.manufacturerID, sizeof(info->manufacturerID));
|
||||||
|
- str_padded_copy(info->slotDescription, token_info.label, sizeof(info->slotDescription));
|
||||||
|
+ size_t to_copy = sizeof (token_info.label);
|
||||||
|
+ to_copy = (to_copy > sizeof (info->slotDescription)) ? sizeof (info->slotDescription) : to_copy;
|
||||||
|
+ str_padded_copy(info->slotDescription, token_info.label, to_copy);
|
||||||
|
|
||||||
|
info->hardwareVersion = token_info.hardwareVersion;
|
||||||
|
info->firmwareVersion = token_info.firmwareVersion;
|
||||||
|
diff --git a/src/lib/tpm.c b/src/lib/tpm.c
|
||||||
|
index 90fb3c3..1bce3ac 100644
|
||||||
|
--- a/src/lib/tpm.c
|
||||||
|
+++ b/src/lib/tpm.c
|
||||||
|
@@ -732,7 +732,9 @@ CK_RV tpm_get_token_info (tpm_ctx *ctx, CK_TOKEN_INFO *info) {
|
||||||
|
unsigned char manufacturerID[sizeof(UINT32)+1] = {0}; // 4 bytes + '\0' as temp storage
|
||||||
|
UINT32 manufacturer = ntohl(tpmProperties[TPM2_PT_MANUFACTURER - TPM2_PT_FIXED].value);
|
||||||
|
memcpy(manufacturerID, (unsigned char*) &manufacturer, sizeof(uint32_t));
|
||||||
|
- str_padded_copy(info->manufacturerID, manufacturerID, sizeof(info->manufacturerID));
|
||||||
|
+ size_t to_copy = sizeof (manufacturerID);
|
||||||
|
+ to_copy = (to_copy > sizeof (info->manufacturerID)) ? sizeof (info->manufacturerID) : to_copy;
|
||||||
|
+ str_padded_copy(info->manufacturerID, manufacturerID, to_copy);
|
||||||
|
|
||||||
|
// Map human readable Manufacturer String, if available,
|
||||||
|
// otherwise 4 byte ID was already padded and will be used.
|
||||||
|
diff --git a/test/unit/test_twist.c b/test/unit/test_twist.c
|
||||||
|
index ec66f69..54ec883 100644
|
||||||
|
--- a/test/unit/test_twist.c
|
||||||
|
+++ b/test/unit/test_twist.c
|
||||||
|
@@ -311,6 +311,8 @@ void test_twistbin_aappend_null_array(void **state) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_twistbin_aappend_twist_null(void **state) {
|
||||||
|
+#pragma GCC diagnostic push
|
||||||
|
+#pragma GCC diagnostic ignored "-Wstringop-overflow="
|
||||||
|
(void) state;
|
||||||
|
|
||||||
|
twist expected = twist_new("foo");
|
||||||
|
@@ -322,6 +324,7 @@ void test_twistbin_aappend_twist_null(void **state) {
|
||||||
|
assert_ptr_equal((void * )actual, (void * )expected);
|
||||||
|
|
||||||
|
twist_free(actual);
|
||||||
|
+#pragma GCC diagnostic pop
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_twistbin_create_null(void **state) {
|
@ -0,0 +1,86 @@
|
|||||||
|
From 78f4e2b47d02cb8215f252e77c68a81dfe4afa30 Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?SZ=20Lin=20=28=E6=9E=97=E4=B8=8A=E6=99=BA=29?=
|
||||||
|
<szlin@debian.org>
|
||||||
|
Date: Fri, 22 Jan 2021 14:38:03 +0800
|
||||||
|
Subject: [PATCH] Fix endian issue on s390x platform
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
7 tests from test_db.c used an int type for sqlite3_last_insert_rowid,
|
||||||
|
which caused endian issue and test failed on s390 platform
|
||||||
|
|
||||||
|
Signed-off-by: SZ Lin (林上智) <szlin@debian.org>
|
||||||
|
Link: https://buildd.debian.org/status/fetch.php?pkg=tpm2-pkcs11&arch=s390x&ver=1.5.0-3&stamp=1611234144&raw=0
|
||||||
|
---
|
||||||
|
test/unit/test_db.c | 14 +++++++-------
|
||||||
|
1 file changed, 7 insertions(+), 7 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/test/unit/test_db.c b/test/unit/test_db.c
|
||||||
|
index 7f11a487..d490d02f 100644
|
||||||
|
--- a/test/unit/test_db.c
|
||||||
|
+++ b/test/unit/test_db.c
|
||||||
|
@@ -2503,7 +2503,7 @@ static void test_db_add_token_sqlite3_finalize_fail(void **state) {
|
||||||
|
{ .rc = SQLITE_OK }, /* sqlite3_bind_text */
|
||||||
|
{ .rc = SQLITE_OK }, /* sqlite3_bind_text */
|
||||||
|
{ .rc = SQLITE_DONE }, /* sqlite3_step */
|
||||||
|
- { .rc = 42 }, /* sqlite3_last_insert_rowid*/
|
||||||
|
+ { .u64 = 42 }, /* sqlite3_last_insert_rowid*/
|
||||||
|
{ .rc = SQLITE_ERROR }, /* sqlite3_finalize */
|
||||||
|
{ .rc = SQLITE_OK }, /* TRANSACTION_END */
|
||||||
|
{ .rc = SQLITE_OK }, /* sqlite3_finalize */
|
||||||
|
@@ -2544,7 +2544,7 @@ static void test_db_add_token_sqlite3_prepare_v2_2_fail(void **state) {
|
||||||
|
{ .rc = SQLITE_OK }, /* sqlite3_bind_text */
|
||||||
|
{ .rc = SQLITE_OK }, /* sqlite3_bind_text */
|
||||||
|
{ .rc = SQLITE_DONE }, /* sqlite3_step */
|
||||||
|
- { .rc = 42 }, /* sqlite3_last_insert_rowid*/
|
||||||
|
+ { .u64 = 42 }, /* sqlite3_last_insert_rowid*/
|
||||||
|
{ .rc = SQLITE_OK }, /* sqlite3_finalize */
|
||||||
|
{ .rc = SQLITE_ERROR }, /* sqlite3_prepare_v2 */
|
||||||
|
{ .rc = SQLITE_OK }, /* TRANSACTION_END */
|
||||||
|
@@ -2586,7 +2586,7 @@ static void test_db_add_token_sqlite3_bind_int_2_fail(void **state) {
|
||||||
|
{ .rc = SQLITE_OK }, /* sqlite3_bind_text */
|
||||||
|
{ .rc = SQLITE_OK }, /* sqlite3_bind_text */
|
||||||
|
{ .rc = SQLITE_DONE }, /* sqlite3_step */
|
||||||
|
- { .rc = 42 }, /* sqlite3_last_insert_rowid*/
|
||||||
|
+ { .u64 = 42 }, /* sqlite3_last_insert_rowid*/
|
||||||
|
{ .rc = SQLITE_OK }, /* sqlite3_finalize */
|
||||||
|
{ .rc = SQLITE_OK }, /* sqlite3_prepare_v2 */
|
||||||
|
{ .rc = SQLITE_ERROR }, /* sqlite3_bind_int */
|
||||||
|
@@ -2631,7 +2631,7 @@ static void test_db_add_token_sqlite3_bind_text_3_fail(void **state) {
|
||||||
|
{ .rc = SQLITE_OK }, /* sqlite3_bind_text */
|
||||||
|
{ .rc = SQLITE_OK }, /* sqlite3_bind_text */
|
||||||
|
{ .rc = SQLITE_DONE }, /* sqlite3_step */
|
||||||
|
- { .rc = 42 }, /* sqlite3_last_insert_rowid*/
|
||||||
|
+ { .u64 = 42 }, /* sqlite3_last_insert_rowid*/
|
||||||
|
{ .rc = SQLITE_OK }, /* sqlite3_finalize */
|
||||||
|
{ .rc = SQLITE_OK }, /* sqlite3_prepare_v2 */
|
||||||
|
{ .rc = SQLITE_OK }, /* sqlite3_bind_int */
|
||||||
|
@@ -2687,7 +2687,7 @@ static void test_db_add_token_sqlite3_bind_blob_1_fail(void **state) {
|
||||||
|
{ .rc = SQLITE_OK }, /* sqlite3_bind_text */
|
||||||
|
{ .rc = SQLITE_OK }, /* sqlite3_bind_text */
|
||||||
|
{ .rc = SQLITE_DONE }, /* sqlite3_step */
|
||||||
|
- { .rc = 42 }, /* sqlite3_last_insert_rowid*/
|
||||||
|
+ { .u64 = 42 }, /* sqlite3_last_insert_rowid*/
|
||||||
|
{ .rc = SQLITE_OK }, /* sqlite3_finalize */
|
||||||
|
{ .rc = SQLITE_OK }, /* sqlite3_prepare_v2 */
|
||||||
|
{ .rc = SQLITE_OK }, /* sqlite3_bind_int */
|
||||||
|
@@ -2746,7 +2746,7 @@ static void test_db_add_token_sqlite3_bind_blob_2_fail(void **state) {
|
||||||
|
{ .rc = SQLITE_OK }, /* sqlite3_bind_text */
|
||||||
|
{ .rc = SQLITE_OK }, /* sqlite3_bind_text */
|
||||||
|
{ .rc = SQLITE_DONE }, /* sqlite3_step */
|
||||||
|
- { .rc = 42 }, /* sqlite3_last_insert_rowid*/
|
||||||
|
+ { .u64 = 42 }, /* sqlite3_last_insert_rowid*/
|
||||||
|
{ .rc = SQLITE_OK }, /* sqlite3_finalize */
|
||||||
|
{ .rc = SQLITE_OK }, /* sqlite3_prepare_v2 */
|
||||||
|
{ .rc = SQLITE_OK }, /* sqlite3_bind_int */
|
||||||
|
@@ -2807,7 +2807,7 @@ static void test_db_add_token_sqlite3_step_2_fail(void **state) {
|
||||||
|
{ .rc = SQLITE_OK }, /* sqlite3_bind_text */
|
||||||
|
{ .rc = SQLITE_OK }, /* sqlite3_bind_text */
|
||||||
|
{ .rc = SQLITE_DONE }, /* sqlite3_step */
|
||||||
|
- { .rc = 42 }, /* sqlite3_last_insert_rowid*/
|
||||||
|
+ { .u64 = 42 }, /* sqlite3_last_insert_rowid*/
|
||||||
|
{ .rc = SQLITE_OK }, /* sqlite3_finalize */
|
||||||
|
{ .rc = SQLITE_OK }, /* sqlite3_prepare_v2 */
|
||||||
|
{ .rc = SQLITE_OK }, /* sqlite3_bind_int */
|
||||||
|
|
Loading…
Reference in new issue