Skip to content

Commit 1931bc1

Browse files
committed
pkcs11-tool.c - acceept ECPOINT as OCTET STRING or BIT STRING
Changes to be committed: modified: tools/pkcs11-tool.c
1 parent 256187a commit 1931bc1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/tools/pkcs11-tool.c

+7-2
Original file line numberDiff line numberDiff line change
@@ -6332,9 +6332,14 @@ static int read_object(CK_SESSION_HANDLE session)
63326332

63336333
value = getEC_POINT(session, obj, &len);
63346334
/* PKCS#11-compliant modules should return ASN1_OCTET_STRING */
6335-
/* TODO DEE Should be returned encoded in BIT STRING, Need to accept both */
6335+
/* DEE Should be returned encoded in BIT STRING, Need to accept both */
63366336
a = value;
63376337
os = d2i_ASN1_OCTET_STRING(NULL, &a, (long)len);
6338+
if (!os) {
6339+
os = d2i_ASN1_BIT_STRING(NULL, &a, (long)&len);
6340+
len = (len + 7) / 8;
6341+
}
6342+
63386343
#if OPENSSL_VERSION_NUMBER < 0x30000000L
63396344
group = EC_KEY_get0_group(EVP_PKEY_get0_EC_KEY(pkey));
63406345
#else
@@ -6439,7 +6444,7 @@ static int read_object(CK_SESSION_HANDLE session)
64396444

64406445
value = getEC_POINT(session, obj, &len);
64416446
/* PKCS#11-compliant modules should return ASN1_OCTET_STRING */
6442-
/* TODO DEE should be in BIT STRING accept both */
6447+
/* DEE should be in BIT STRING accept both */
64436448
a = value;
64446449
os = d2i_ASN1_OCTET_STRING(NULL, &a, (long)len);
64456450
if (!os) {

0 commit comments

Comments
 (0)