Commit d03ed0b
committed
Ed25519 support in the OpenSSL compatibility layer
wolfCrypt has full Ed25519 (keygen, sign/verify, ASN.1 import/export) and
the TLS 1.3 stack already authenticates with Ed25519 certificates, but the
OpenSSL-compatibility surface was missing the dispatch for several common
operations, so an application driving Ed25519 purely through the OpenSSL
API (EVP_PKEY_keygen, i2d_PUBKEY, X509_sign of an in-memory self-signed
cert, then loading it into an SSL_CTX) could not use it. Fill those gaps,
each mirroring the adjacent RSA/ECC/X25519 case:
- EVP_PKEY_keygen (wolfcrypt/src/evp.c): generate an Ed25519 key and cache
the PKCS#8 PrivateKeyInfo DER, like the EC/RSA cases.
- wolfSSL_i2d_PublicKey / i2d_PUBKEY (wolfcrypt/src/evp_pk.c): encode an
Ed25519 SubjectPublicKeyInfo.
- pkcs8_encode (src/pk.c): return the already-PKCS#8 cached DER for
Ed25519 (as the DH case does), so i2d_PKCS8_PRIV_KEY_INFO works.
- d2iTryEd25519Key (wolfcrypt/src/evp_pk.c): derive the public key after
decoding a PKCS#8 private key (v1 carries only the seed) so the decoded
EVP_PKEY is complete.
- d2i_AutoPrivateKey (wolfcrypt/src/evp_pk.c): detect Ed25519 by its
algorithm id and decode the full PKCS#8 (its inner key is an OCTET
STRING, which the RSA/ECC sequence-counting heuristic cannot classify).
- X509_sign / X509_resign_cert / sigTypeFromPKEY / wolfssl_x509_make_der
(src/x509.c): sign a certificate with an Ed25519 key (NULL digest),
resolving the signature OID as ED25519k and building the SubjectPublicKey
from an ed25519_key.
- X509_set_pubkey / X509_get_pubkey (src/x509.c): set and retrieve an
Ed25519 public key, keeping the X.509 public-key buffer as the raw key
bytes to match how DecodeCert/StoreKey store it.
tests/api.c gains test_wolfSSL_EVP_PKEY_ED25519_openssl, which exercises
the whole sequence (keygen, i2d_PUBKEY, i2d_PKCS8_PRIV_KEY_INFO,
d2i_AutoPrivateKey, self-signed X509_sign with a NULL digest, X509_get_pubkey
round-trip, and loading the key+cert into an SSL_CTX).
Requires --enable-ed25519 --enable-certgen.
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>1 parent 5929586 commit d03ed0b
5 files changed
Lines changed: 371 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7373 | 7373 | | |
7374 | 7374 | | |
7375 | 7375 | | |
| 7376 | + | |
| 7377 | + | |
| 7378 | + | |
| 7379 | + | |
| 7380 | + | |
| 7381 | + | |
| 7382 | + | |
| 7383 | + | |
| 7384 | + | |
| 7385 | + | |
| 7386 | + | |
| 7387 | + | |
| 7388 | + | |
| 7389 | + | |
| 7390 | + | |
| 7391 | + | |
7376 | 7392 | | |
7377 | 7393 | | |
7378 | 7394 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6481 | 6481 | | |
6482 | 6482 | | |
6483 | 6483 | | |
| 6484 | + | |
| 6485 | + | |
| 6486 | + | |
| 6487 | + | |
| 6488 | + | |
6484 | 6489 | | |
6485 | 6490 | | |
6486 | 6491 | | |
| |||
6572 | 6577 | | |
6573 | 6578 | | |
6574 | 6579 | | |
| 6580 | + | |
| 6581 | + | |
| 6582 | + | |
| 6583 | + | |
| 6584 | + | |
| 6585 | + | |
| 6586 | + | |
| 6587 | + | |
| 6588 | + | |
| 6589 | + | |
| 6590 | + | |
| 6591 | + | |
| 6592 | + | |
| 6593 | + | |
| 6594 | + | |
| 6595 | + | |
| 6596 | + | |
| 6597 | + | |
| 6598 | + | |
| 6599 | + | |
| 6600 | + | |
| 6601 | + | |
| 6602 | + | |
| 6603 | + | |
| 6604 | + | |
| 6605 | + | |
| 6606 | + | |
| 6607 | + | |
| 6608 | + | |
| 6609 | + | |
| 6610 | + | |
6575 | 6611 | | |
6576 | 6612 | | |
6577 | 6613 | | |
| |||
12225 | 12261 | | |
12226 | 12262 | | |
12227 | 12263 | | |
| 12264 | + | |
| 12265 | + | |
| 12266 | + | |
| 12267 | + | |
| 12268 | + | |
| 12269 | + | |
| 12270 | + | |
| 12271 | + | |
12228 | 12272 | | |
12229 | 12273 | | |
12230 | 12274 | | |
| |||
12337 | 12381 | | |
12338 | 12382 | | |
12339 | 12383 | | |
| 12384 | + | |
| 12385 | + | |
| 12386 | + | |
12340 | 12387 | | |
12341 | 12388 | | |
12342 | 12389 | | |
| |||
12472 | 12519 | | |
12473 | 12520 | | |
12474 | 12521 | | |
| 12522 | + | |
| 12523 | + | |
| 12524 | + | |
| 12525 | + | |
| 12526 | + | |
| 12527 | + | |
| 12528 | + | |
| 12529 | + | |
| 12530 | + | |
| 12531 | + | |
| 12532 | + | |
| 12533 | + | |
| 12534 | + | |
| 12535 | + | |
| 12536 | + | |
| 12537 | + | |
| 12538 | + | |
| 12539 | + | |
| 12540 | + | |
| 12541 | + | |
| 12542 | + | |
| 12543 | + | |
| 12544 | + | |
| 12545 | + | |
| 12546 | + | |
| 12547 | + | |
| 12548 | + | |
| 12549 | + | |
| 12550 | + | |
| 12551 | + | |
12475 | 12552 | | |
12476 | 12553 | | |
12477 | 12554 | | |
| |||
12723 | 12800 | | |
12724 | 12801 | | |
12725 | 12802 | | |
| 12803 | + | |
| 12804 | + | |
| 12805 | + | |
| 12806 | + | |
| 12807 | + | |
| 12808 | + | |
12726 | 12809 | | |
12727 | 12810 | | |
12728 | 12811 | | |
| |||
12807 | 12890 | | |
12808 | 12891 | | |
12809 | 12892 | | |
| 12893 | + | |
| 12894 | + | |
| 12895 | + | |
| 12896 | + | |
| 12897 | + | |
| 12898 | + | |
12810 | 12899 | | |
12811 | 12900 | | |
12812 | 12901 | | |
| |||
12895 | 12984 | | |
12896 | 12985 | | |
12897 | 12986 | | |
12898 | | - | |
| 12987 | + | |
| 12988 | + | |
| 12989 | + | |
| 12990 | + | |
| 12991 | + | |
| 12992 | + | |
| 12993 | + | |
| 12994 | + | |
12899 | 12995 | | |
12900 | 12996 | | |
12901 | 12997 | | |
| |||
16408 | 16504 | | |
16409 | 16505 | | |
16410 | 16506 | | |
| 16507 | + | |
| 16508 | + | |
| 16509 | + | |
| 16510 | + | |
| 16511 | + | |
| 16512 | + | |
| 16513 | + | |
| 16514 | + | |
| 16515 | + | |
| 16516 | + | |
| 16517 | + | |
| 16518 | + | |
| 16519 | + | |
| 16520 | + | |
| 16521 | + | |
| 16522 | + | |
| 16523 | + | |
| 16524 | + | |
| 16525 | + | |
| 16526 | + | |
| 16527 | + | |
| 16528 | + | |
| 16529 | + | |
| 16530 | + | |
16411 | 16531 | | |
16412 | 16532 | | |
16413 | 16533 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10074 | 10074 | | |
10075 | 10075 | | |
10076 | 10076 | | |
| 10077 | + | |
| 10078 | + | |
| 10079 | + | |
| 10080 | + | |
| 10081 | + | |
| 10082 | + | |
| 10083 | + | |
| 10084 | + | |
| 10085 | + | |
| 10086 | + | |
| 10087 | + | |
| 10088 | + | |
| 10089 | + | |
| 10090 | + | |
| 10091 | + | |
| 10092 | + | |
| 10093 | + | |
| 10094 | + | |
| 10095 | + | |
| 10096 | + | |
| 10097 | + | |
| 10098 | + | |
| 10099 | + | |
| 10100 | + | |
| 10101 | + | |
| 10102 | + | |
| 10103 | + | |
| 10104 | + | |
| 10105 | + | |
| 10106 | + | |
| 10107 | + | |
| 10108 | + | |
| 10109 | + | |
| 10110 | + | |
| 10111 | + | |
| 10112 | + | |
| 10113 | + | |
| 10114 | + | |
| 10115 | + | |
| 10116 | + | |
| 10117 | + | |
| 10118 | + | |
| 10119 | + | |
| 10120 | + | |
| 10121 | + | |
| 10122 | + | |
| 10123 | + | |
| 10124 | + | |
| 10125 | + | |
| 10126 | + | |
| 10127 | + | |
| 10128 | + | |
| 10129 | + | |
| 10130 | + | |
| 10131 | + | |
| 10132 | + | |
| 10133 | + | |
| 10134 | + | |
| 10135 | + | |
| 10136 | + | |
| 10137 | + | |
| 10138 | + | |
| 10139 | + | |
| 10140 | + | |
| 10141 | + | |
| 10142 | + | |
| 10143 | + | |
| 10144 | + | |
| 10145 | + | |
| 10146 | + | |
| 10147 | + | |
| 10148 | + | |
| 10149 | + | |
| 10150 | + | |
| 10151 | + | |
| 10152 | + | |
| 10153 | + | |
| 10154 | + | |
| 10155 | + | |
| 10156 | + | |
| 10157 | + | |
| 10158 | + | |
| 10159 | + | |
| 10160 | + | |
| 10161 | + | |
| 10162 | + | |
| 10163 | + | |
| 10164 | + | |
| 10165 | + | |
| 10166 | + | |
| 10167 | + | |
| 10168 | + | |
| 10169 | + | |
| 10170 | + | |
| 10171 | + | |
| 10172 | + | |
| 10173 | + | |
| 10174 | + | |
| 10175 | + | |
| 10176 | + | |
| 10177 | + | |
| 10178 | + | |
| 10179 | + | |
| 10180 | + | |
| 10181 | + | |
| 10182 | + | |
| 10183 | + | |
| 10184 | + | |
| 10185 | + | |
| 10186 | + | |
| 10187 | + | |
10077 | 10188 | | |
10078 | 10189 | | |
10079 | 10190 | | |
| |||
35068 | 35179 | | |
35069 | 35180 | | |
35070 | 35181 | | |
| 35182 | + | |
35071 | 35183 | | |
35072 | 35184 | | |
35073 | 35185 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3820 | 3820 | | |
3821 | 3821 | | |
3822 | 3822 | | |
| 3823 | + | |
| 3824 | + | |
| 3825 | + | |
3823 | 3826 | | |
3824 | 3827 | | |
3825 | 3828 | | |
| |||
3932 | 3935 | | |
3933 | 3936 | | |
3934 | 3937 | | |
| 3938 | + | |
| 3939 | + | |
| 3940 | + | |
| 3941 | + | |
| 3942 | + | |
| 3943 | + | |
| 3944 | + | |
| 3945 | + | |
| 3946 | + | |
| 3947 | + | |
| 3948 | + | |
| 3949 | + | |
| 3950 | + | |
| 3951 | + | |
| 3952 | + | |
| 3953 | + | |
| 3954 | + | |
| 3955 | + | |
| 3956 | + | |
| 3957 | + | |
| 3958 | + | |
| 3959 | + | |
| 3960 | + | |
| 3961 | + | |
| 3962 | + | |
| 3963 | + | |
| 3964 | + | |
| 3965 | + | |
| 3966 | + | |
| 3967 | + | |
| 3968 | + | |
| 3969 | + | |
| 3970 | + | |
| 3971 | + | |
| 3972 | + | |
| 3973 | + | |
| 3974 | + | |
| 3975 | + | |
| 3976 | + | |
| 3977 | + | |
| 3978 | + | |
| 3979 | + | |
| 3980 | + | |
| 3981 | + | |
| 3982 | + | |
| 3983 | + | |
3935 | 3984 | | |
3936 | 3985 | | |
3937 | 3986 | | |
| |||
0 commit comments