Skip to content

Commit

Permalink
Add test vectors for Curve448
Browse files Browse the repository at this point in the history
  • Loading branch information
Legrandin committed Sep 8, 2024
1 parent 8f58ac4 commit 76d7a83
Show file tree
Hide file tree
Showing 20 changed files with 110 additions and 13 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
-----BEGIN PRIVATE KEY-----
MC4CAQAwBQYDK2VuBCIEIKidnb+OLl6wrioGG+TGdIE/r0HdYmIxWOj8d7kvuW5f
MEYCAQAwBQYDK2VvBDoEOHxZhQFreFDMrRfsYFwh4JWoFIuB3ImZp2OET4L8E1Cv
ARzv49/Z1j81t2onGC1y6PXlRaL0ynXW
-----END PRIVATE KEY-----
X25519 Private-Key:
X448 Private-Key:
priv:
a8:9d:9d:bf:8e:2e:5e:b0:ae:2a:06:1b:e4:c6:74:
81:3f:af:41:dd:62:62:31:58:e8:fc:77:b9:2f:b9:
6e:5f
7c:59:85:01:6b:78:50:cc:ad:17:ec:60:5c:21:e0:
95:a8:14:8b:81:dc:89:99:a7:63:84:4f:82:fc:13:
50:af:01:1c:ef:e3:df:d9:d6:3f:35:b7:6a:27:18:
2d:72:e8:f5:e5:45:a2:f4:ca:75:d6
pub:
ff:75:61:ef:60:c9:c8:a7:57:f6:d6:37:2e:c1:41:
42:c9:be:20:8d:0e:71:91:36:d8:d3:c7:15:df:cf:
7e:15
2c:b5:a2:77:ae:7c:3c:27:6c:c2:9d:6a:b7:d9:08:
1a:7f:83:24:a5:a6:9f:3d:1a:a9:cb:7d:d8:49:a1:
2c:0e:e2:01:9b:15:0f:75:4a:67:b3:81:ed:a7:1d:
6c:37:17:91:12:0d:fa:8c:a4:40:62
Binary file not shown.
15 changes: 15 additions & 0 deletions test_vectors/pycryptodome_test_vectors/PublicKey/ECC/ecc_x448.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-----BEGIN PRIVATE KEY-----
MEYCAQAwBQYDK2VvBDoEOJDBPevSG2MlrgTa4pql0YvTlh5Hzp6Fuavy3i6jzuSD
PRRK5A6X7BoYjM125vp4DrCU45KRCf36
-----END PRIVATE KEY-----
X448 Private-Key:
priv:
90:c1:3d:eb:d2:1b:63:25:ae:04:da:e2:9a:a5:d1:
8b:d3:96:1e:47:ce:9e:85:b9:ab:f2:de:2e:a3:ce:
e4:83:3d:14:4a:e4:0e:97:ec:1a:18:8c:cd:76:e6:
fa:78:0e:b0:94:e3:92:91:09:fd:fa
pub:
e2:ab:ae:24:ab:8f:65:b0:19:69:e6:1f:84:fe:e6:
15:b5:25:f4:13:a9:0e:3d:72:7f:71:d0:ff:e6:0f:
b1:d0:a1:a0:28:5f:2a:7f:d8:87:89:20:6e:0a:a4:
f3:e9:fc:b9:e4:ba:5d:64:4e:69:1e
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-----BEGIN PRIVATE KEY-----
MEYCAQAwBQYDK2VvBDoEOJDBPevSG2MlrgTa4pql0YvTlh5Hzp6Fuavy3i6jzuSD
PRRK5A6X7BoYjM125vp4DrCU45KRCf36
-----END PRIVATE KEY-----
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-----BEGIN ENCRYPTED PRIVATE KEY-----
MIGzMF8GCSqGSIb3DQEFDTBSMDEGCSqGSIb3DQEFDDAkBBBQ7Mf5XTNvz29/8327
CPJnAgIIADAMBggqhkiG9w0CCQUAMB0GCWCGSAFlAwQBAgQQcW/DczxeFx/Ce5jT
d9hwrQRQIGQh8W2qjJVKZImjlAgzcJlgy1jeaf3daRiOvIKjAI3JKmGr488V1ZAh
pMKQDETpsRcYXpVxyUiWOinRAQ7Re+u/nl7f7MOgAVi/HR3Ck4A=
-----END ENCRYPTED PRIVATE KEY-----
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-----BEGIN ENCRYPTED PRIVATE KEY-----
MIGzMF8GCSqGSIb3DQEFDTBSMDEGCSqGSIb3DQEFDDAkBBD/cVlQHKbtFhaFKrX2
j7oAAgIIADAMBggqhkiG9w0CCQUAMB0GCWCGSAFlAwQBFgQQIq13svdowTVAzngt
pN8G4wRQIFLu09Oy3JYLarIr3ni4WzdJ6S1rYafc/F+pP2jjO+IJQPJtdwZCr9Gm
S6Y5sNmJW5JhTe1DezZfVfbEeSTaLkp2r6qMtbJpNgXx3WvXgjU=
-----END ENCRYPTED PRIVATE KEY-----
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-----BEGIN ENCRYPTED PRIVATE KEY-----
MIGzMF8GCSqGSIb3DQEFDTBSMDEGCSqGSIb3DQEFDDAkBBAZApDfg8ejc8MGKUki
BzmSAgIIADAMBggqhkiG9w0CCQUAMB0GCWCGSAFlAwQBKgQQQayW1hBosjvzPXpp
gMh7JARQsNqbhRpzcDVlkNadsQeyKXCrmv+G7nijW2AThhtS6qBXMz7T8mY2hdAg
afetkM4b5t77B7NClpYlo74y0YMGAQSKBxZ9X+A6LHL+f0UmYS4=
-----END ENCRYPTED PRIVATE KEY-----
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-----BEGIN ENCRYPTED PRIVATE KEY-----
MIGqMFYGCSqGSIb3DQEFDTBJMDEGCSqGSIb3DQEFDDAkBBCdsQ4bhTililZtF+Jg
gh5oAgIIADAMBggqhkiG9w0CCQUAMBQGCCqGSIb3DQMHBAiHdfp7KsDjKQRQ396N
vyE7Y1Miii3u5lNoAkpuxj6+s/uPkuCQ3lAZdRCq+wtXlfYmDJh//kMh+iuoyh/a
u2tsVLzHEx0RXS2LIhK1+78CnqNeOB8CBioIQKc=
-----END ENCRYPTED PRIVATE KEY-----
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-----BEGIN ENCRYPTED PRIVATE KEY-----
MIGzMF8GCSqGSIb3DQEFDTBSMDEGCSqGSIb3DQEFDDAkBBATVxmribVgJ6GBOca+
K1hQAgIIADAMBggqhkiG9w0CCQUAMB0GCWCGSAFlAwQBKgQQN/1in1U1KOewtmjD
ugXEPwRQ7VLN5b48+pw7ee83Dw1rhIlRy6jJCmlGOCRZ1Yw8i3zsmYX+cL5NqmVD
BpXperwJ27+LHI2kcFHHtRmgsUqdt2H+yJBBGvvpEOtL9s8L0YI=
-----END ENCRYPTED PRIVATE KEY-----
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-----BEGIN PUBLIC KEY-----
MEIwBQYDK2VvAzkA4quuJKuPZbAZaeYfhP7mFbUl9BOpDj1yf3HQ/+YPsdChoChf
Kn/Yh4kgbgqk8+n8ueS6XWROaR4=
-----END PUBLIC KEY-----
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-----BEGIN CERTIFICATE-----
MIIBSjCB8aADAgECAhQxUGC7WASZ9QBOhZ+n0dFfsFkttTAKBggqhkjOPQQDAjAN
MQswCQYDVQQDDAJDQTAeFw0yNDA5MDgwNzQyMDdaFw0yNDEwMDgwNzQyMDdaMBEx
DzANBgNVBAMMBkNsaWVudDBCMAUGAytlbwM5AOKrriSrj2WwGWnmH4T+5hW1JfQT
qQ49cn9x0P/mD7HQoaAoXyp/2IeJIG4KpPPp/Lnkul1kTmkeo0IwQDAdBgNVHQ4E
FgQUl8fXhCM6h6OGK7zUZ192iNX5QnIwHwYDVR0jBBgwFoAUAhU+lVYBIpp6Qqbg
GpG8ccBMqrkwCgYIKoZIzj0EAwIDSAAwRQIgQNixKUOcZ6mR7hCgmcK29TTuH31l
ig2Rarao0ESAy2UCIQD/Lk/tAoSIsx1KUeQ9EvtcT0fIlqXZXxU/86biw0mscg==
-----END CERTIFICATE-----
35 changes: 35 additions & 0 deletions test_vectors/pycryptodome_test_vectors/PublicKey/ECC/gen_x448.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/sh

set -e
set -x

openssl version | tee openssl_version_x448.txt

# Private key (PKCS#8)
openssl genpkey -algorithm x448 -outform PEM -out ecc_x448_private.pem
openssl pkey -inform PEM -in ecc_x448_private.pem -outform DER -out ecc_x448_private.der
openssl pkey -in ecc_x448_private.pem -text -out ecc_x448.txt

# Encrypted private key
# Traditional format (PEM enveloped) is unsupported for x448, so we only use encrypted PKCS#8
openssl pkcs8 -in ecc_x448_private.der -inform DER -passout 'pass:secret' -out ecc_x448_private_p8.der -outform DER -topk8
openssl pkcs8 -in ecc_x448_private.der -inform DER -passout 'pass:secret' -out ecc_x448_private_p8.pem -outform PEM -topk8
openssl pkcs8 -in ecc_x448_private.der -inform DER -passout 'pass:secret' -out ecc_x448_private_p8_2.der -outform DER -topk8 -iter 12345 -v2 aes256 -v2prf hmacWithSHA512
openssl pkey -in ecc_x448_private.pem -des3 -out ecc_x448_private_enc_des3.pem -passout 'pass:secret' -outform PEM
openssl pkey -in ecc_x448_private.pem -aes128 -out ecc_x448_private_enc_aes128.pem -passout 'pass:secret' -outform PEM
openssl pkey -in ecc_x448_private.pem -aes192 -out ecc_x448_private_enc_aes192.pem -passout 'pass:secret' -outform PEM
openssl pkey -in ecc_x448_private.pem -aes256 -out ecc_x448_private_enc_aes256.pem -passout 'pass:secret' -outform PEM
# GCM is not supported by openssl in this case...
#openssl pkey -in ecc_x448_private.pem -aes-256-gcm -out ecc_x448_private_enc_aes256_gcm.pem -passout 'pass:secret' -outform PEM

# Public key
openssl pkey -in ecc_x448_private.pem -pubout -out ecc_x448_public.pem
openssl pkey -pubin -in ecc_x448_public.pem -outform DER -out ecc_x448_public.der

# X.509 cert
openssl ecparam -genkey -name prime256v1 -out ecc-p256-key-temp.pem
openssl req -new -x509 -key ecc-p256-key-temp.pem -out ecc-p256-cert-temp.pem -days 365 -subj "/CN=CA"
openssl req -new -key ecc-p256-key-temp.pem -out ecc-p256-temp.csr -subj "/CN=CA"
openssl x509 -req -in ecc-p256-temp.csr -CAkey ecc-p256-key-temp.pem -CA ecc-p256-cert-temp.pem -force_pubkey ecc_x448_public.pem -out ecc_x448_x509.pem -subj "/CN=Client"
openssl x509 -in ecc_x448_x509.pem -out ecc_x448_x509.der -outform DER
rm -f ecc-p256-key-temp.pem ecc-p256-cert-temp.pem ecc-p256-temp.csr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
OpenSSL 3.2.2 4 Jun 2024 (Library: OpenSSL 3.2.2 4 Jun 2024)
2 changes: 1 addition & 1 deletion test_vectors/pycryptodome_test_vectors/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.0.16"
__version__ = "1.0.17"

0 comments on commit 76d7a83

Please sign in to comment.