Skip to content

Commit c882db3

Browse files
committed
tests: use optional propquery for pkcs11prov to allow decoder fallback
1 parent d4b318e commit c882db3

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

tests/check-all-prov.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,13 @@ int main(int argc, char *argv[])
5151
return ret;
5252
}
5353

54-
/* Load private key, public key and certificate */
55-
load_objects(argv[1], "provider=pkcs11prov", NULL, obj_set);
54+
/*
55+
* Load private key, public key and certificate.
56+
* Use "?provider=pkcs11prov" to prefer pkcs11prov but allow fallback to default.
57+
* This enables default provider decoders (e.g. for SubjectPublicKeyInfo (SPKI))
58+
* to construct EVP_PKEY from X509 when pkcs11prov does not implement them.
59+
*/
60+
load_objects(argv[1], "?provider=pkcs11prov", NULL, obj_set);
5661

5762
if (!obj_set->private_key) {
5863
printf("Cannot load private key: %s\n", argv[1]);

tests/provider-pkcs11-uri-without-token.softhsm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ fi
6767

6868
# Verify the signature using the public without specifying the token
6969
${OPENSSL} pkeyutl -provider pkcs11prov -provider default -pubin \
70+
-propquery "provider=pkcs11prov" \
7071
-inkey ${PUBLIC_KEY} -verify -sigfile "${outdir}/signature.bin" \
7172
-in "${outdir}/in.txt"
7273
if [[ $? -ne 0 ]]; then
@@ -75,7 +76,12 @@ if [[ $? -ne 0 ]]; then
7576
fi
7677

7778
# Verify the signature using a certificate without specifying the token
79+
#
80+
# Use "?provider=pkcs11prov" to prefer pkcs11prov but allow fallback to default.
81+
# This enables default provider decoders (e.g. for SubjectPublicKeyInfo (SPKI))
82+
# to construct EVP_PKEY from X509 when pkcs11prov does not implement them.
7883
${OPENSSL} pkeyutl -provider pkcs11prov -provider default -certin \
84+
-propquery "?provider=pkcs11prov" \
7985
-inkey ${PUBLIC_KEY} -verify -sigfile "${outdir}/signature.bin" \
8086
-in "${outdir}/in.txt"
8187
if [[ $? -ne 0 ]]; then
@@ -88,6 +94,7 @@ ${OPENSSL} dgst -sha256 -binary -out "${outdir}/hash.bin" "${outdir}/in.txt"
8894

8995
# Sign the SHA-256 digest with an RSA key using RSA-PSS (raw input)
9096
${OPENSSL} pkeyutl -provider pkcs11prov -provider default \
97+
-propquery "provider=pkcs11prov" \
9198
-inkey ${PRIVATE_KEY} -sign -rawin -pkeyopt rsa_padding_mode:pss \
9299
-out "${outdir}/signature.bin" -in "${outdir}/hash.bin"
93100

0 commit comments

Comments
 (0)