Fix a bug where eddsa mechanism isnt recognized in generate-keypair
Signed-off-by: Zoltan Fridrich <zfridric@redhat.com>
This commit is contained in:
parent
746a6f073b
commit
fe686569c4
59
p11-kit-0.25.3-generate-keypair-eddsa.patch
Normal file
59
p11-kit-0.25.3-generate-keypair-eddsa.patch
Normal file
@ -0,0 +1,59 @@
|
||||
diff --color -ruNp a/doc/manual/p11-kit.xml b/doc/manual/p11-kit.xml
|
||||
--- a/doc/manual/p11-kit.xml 2023-10-26 11:56:44.000000000 +0200
|
||||
+++ b/doc/manual/p11-kit.xml 2024-05-15 16:49:22.058423419 +0200
|
||||
@@ -211,7 +211,7 @@ $ p11-kit generate-keypair --type=algori
|
||||
<varlistentry>
|
||||
<term><option>--type=<algorithm></option></term>
|
||||
<listitem><para>Specify the type of keys to generate.
|
||||
- Supported values are rsa, ecdsa and ed25519.
|
||||
+ Supported values are rsa, ecdsa and eddsa.
|
||||
This option is required.</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
diff --color -ruNp a/p11-kit/generate-keypair.c b/p11-kit/generate-keypair.c
|
||||
--- a/p11-kit/generate-keypair.c 2024-05-15 16:45:43.883280385 +0200
|
||||
+++ b/p11-kit/generate-keypair.c 2024-05-15 16:48:40.499637246 +0200
|
||||
@@ -84,8 +84,7 @@ get_mechanism (const char *type)
|
||||
m.mechanism = CKM_RSA_PKCS_KEY_PAIR_GEN;
|
||||
else if (p11_ascii_strcaseeq (type, "ecdsa"))
|
||||
m.mechanism = CKM_ECDSA_KEY_PAIR_GEN;
|
||||
- else if (p11_ascii_strcaseeq (type, "ed25519") ||
|
||||
- p11_ascii_strcaseeq (type, "ed448"))
|
||||
+ else if (p11_ascii_strcaseeq (type, "eddsa"))
|
||||
m.mechanism = CKM_EC_EDWARDS_KEY_PAIR_GEN;
|
||||
|
||||
return m;
|
||||
diff --color -ruNp a/p11-kit/test-generate-keypair.sh b/p11-kit/test-generate-keypair.sh
|
||||
--- a/p11-kit/test-generate-keypair.sh 2023-10-31 09:47:26.000000000 +0100
|
||||
+++ b/p11-kit/test-generate-keypair.sh 2024-05-15 16:48:40.499637246 +0200
|
||||
@@ -42,8 +42,8 @@ test_generate_keypair_ecdsa() {
|
||||
if "$abs_top_builddir"/p11-kit/p11-kit-testable generate-keypair --login --label="ecdsa-$curve" --type=ecdsa --curve="$curve" "pkcs11:token=PUBKEY%20LABEL?pin-value=booo" 2> err.out; then
|
||||
assert_fail "expected to fail: p11-kit generate-keypair"
|
||||
fi
|
||||
+ assert_contains err.out "key-pair generation failed: The crypto mechanism is invalid or unrecognized"
|
||||
done
|
||||
- assert_contains err.out "key-pair generation failed: The crypto mechanism is invalid or unrecognized"
|
||||
|
||||
if "$abs_top_builddir"/p11-kit/p11-kit-testable generate-keypair --login --label="ecdsa-unknown" --type=ecdsa --curve=unknown "pkcs11:token=PUBKEY%20LABEL?pin-value=booo" 2> err.out; then
|
||||
assert_fail "p11-kit generate-keypair succeeded for unknown ecdsa curve"
|
||||
@@ -54,16 +54,16 @@ test_generate_keypair_ecdsa() {
|
||||
test_generate_keypair_eddsa() {
|
||||
for curve in ed25519 ed448; do
|
||||
if "$abs_top_builddir"/p11-kit/p11-kit-testable generate-keypair --login --label="eddsa-$curve" --type=eddsa --curve="$curve" "pkcs11:token=PUBKEY%20LABEL?pin-value=booo" 2> err.out; then
|
||||
- assert_fail "unable to run: p11-kit generate-keypair"
|
||||
+ assert_fail "expected to fail: p11-kit generate-keypair"
|
||||
fi
|
||||
+ assert_contains err.out "key-pair generation failed: The crypto mechanism is invalid or unrecognized"
|
||||
done
|
||||
- assert_contains err.out "key-pair generation failed: The crypto mechanism is invalid or unrecognized"
|
||||
|
||||
- if "$abs_top_builddir"/p11-kit/p11-kit-testable generate-keypair --login --label="eddsa-unknown" --type=eddsa --curve=unknown "pkcs11:token=PUBKEY%20LABEL?pin-value=booo"; then
|
||||
+ if "$abs_top_builddir"/p11-kit/p11-kit-testable generate-keypair --login --label="eddsa-unknown" --type=eddsa --curve=unknown "pkcs11:token=PUBKEY%20LABEL?pin-value=booo" 2> err.out; then
|
||||
assert_fail "p11-kit generate-keypair succeeded for unknown eddsa curve"
|
||||
fi
|
||||
assert_contains err.out "unknown curve name: unknown"
|
||||
}
|
||||
|
||||
run test_generate_keypair_mock test_generate_keypair_rsa \
|
||||
- test_generate_keypair_ecdsa test_generate_keypair_ecdsa
|
||||
+ test_generate_keypair_ecdsa test_generate_keypair_eddsa
|
@ -14,6 +14,7 @@ Source4: p11-kit-client.service
|
||||
Patch: p11-kit-0.25.3-import-object.patch
|
||||
Patch: p11-kit-0.25.3-list-tokens-message.patch
|
||||
Patch: p11-kit-0.25.3-static-analysis.patch
|
||||
Patch: p11-kit-0.25.3-generate-keypair-eddsa.patch
|
||||
|
||||
BuildRequires: gcc
|
||||
BuildRequires: libtasn1-devel >= 2.3
|
||||
|
Loading…
Reference in New Issue
Block a user