5757#endif
5858
5959#if defined(LIBRESSL_VERSION_NUMBER)
60- #if LIBRESSL_VERSION_NUMBER >= 0x3050300fL
60+ #if LIBRESSL_VERSION_NUMBER >= 0x3070100fL // 3.7.1 - EdDSA support
61+ #define JWT_OPENSSL_1_1_1
62+ #elif LIBRESSL_VERSION_NUMBER >= 0x3050300fL // 3.5.3
6163#define JWT_OPENSSL_1_1_0
6264#else
6365#define JWT_OPENSSL_1_0_0
@@ -1806,6 +1808,7 @@ namespace jwt {
18061808 *
18071809 * The EdDSA algorithms were introduced in [OpenSSL v1.1.1](https://www.openssl.org/news/openssl-1.1.1-notes.html),
18081810 * so these algorithms are only available when building against this version or higher.
1811+ * LibreSSL added EdDSA (Ed25519) functionality in [LibreSSL 3.7.1](https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.7.1-relnotes.txt)
18091812 */
18101813 struct eddsa {
18111814 /* *
@@ -1849,10 +1852,9 @@ namespace jwt {
18491852 size_t len = EVP_PKEY_size (pkey.get ());
18501853 std::string res (len, ' \0 ' );
18511854
1852- // LibreSSL is the special kid in the block, as it does not support EVP_DigestSign.
1853- // OpenSSL on the otherhand does not support using EVP_DigestSignUpdate for eddsa, which is why we end up with this
1854- // mess.
1855- #if defined(LIBRESSL_VERSION_NUMBER) || defined(LIBWOLFSSL_VERSION_HEX)
1855+ // LibreSSL and OpenSSL, require the oneshot EVP_DigestSign API.
1856+ // wolfSSL uses the Update/Final pattern.
1857+ #if defined(LIBWOLFSSL_VERSION_HEX)
18561858 ERR_clear_error ();
18571859 if (EVP_DigestSignUpdate (ctx.get (), reinterpret_cast <const unsigned char *>(data.data ()), data.size ()) !=
18581860 1 ) {
@@ -1893,10 +1895,9 @@ namespace jwt {
18931895 ec = error::signature_verification_error::verifyinit_failed;
18941896 return ;
18951897 }
1896- // LibreSSL is the special kid in the block, as it does not support EVP_DigestVerify.
1897- // OpenSSL on the otherhand does not support using EVP_DigestVerifyUpdate for eddsa, which is why we end up with this
1898- // mess.
1899- #if defined(LIBRESSL_VERSION_NUMBER) || defined(LIBWOLFSSL_VERSION_HEX)
1898+ // LibreSSL and OpenSSL, require the oneshot EVP_DigestVerify API.
1899+ // wolfSSL uses the Update/Final pattern.
1900+ #if defined(LIBWOLFSSL_VERSION_HEX)
19001901 if (EVP_DigestVerifyUpdate (ctx.get (), reinterpret_cast <const unsigned char *>(data.data ()),
19011902 data.size ()) != 1 ) {
19021903 ec = error::signature_verification_error::verifyupdate_failed;
@@ -2210,7 +2211,7 @@ namespace jwt {
22102211 *
22112212 * https://en.wikipedia.org/wiki/EdDSA#Ed25519
22122213 *
2213- * Requires at least OpenSSL 1.1.1.
2214+ * Requires at least OpenSSL 1.1.1 or LibreSSL 3.7.1 .
22142215 */
22152216 struct ed25519 : public eddsa {
22162217 /* *
@@ -2227,12 +2228,13 @@ namespace jwt {
22272228 : eddsa(public_key, private_key, public_key_password, private_key_password, " EdDSA" ) {}
22282229 };
22292230
2231+ #if !defined(LIBRESSL_VERSION_NUMBER)
22302232 /* *
22312233 * Ed448 algorithm
22322234 *
22332235 * https://en.wikipedia.org/wiki/EdDSA#Ed448
22342236 *
2235- * Requires at least OpenSSL 1.1.1.
2237+ * Requires at least OpenSSL 1.1.1. Note: Not supported by LibreSSL.
22362238 */
22372239 struct ed448 : public eddsa {
22382240 /* *
@@ -2248,7 +2250,8 @@ namespace jwt {
22482250 const std::string& public_key_password = " " , const std::string& private_key_password = " " )
22492251 : eddsa(public_key, private_key, public_key_password, private_key_password, " EdDSA" ) {}
22502252 };
2251- #endif
2253+ #endif // !LIBRESSL_VERSION_NUMBER
2254+ #endif // !JWT_OPENSSL_1_0_0 && !JWT_OPENSSL_1_1_0
22522255
22532256 /* *
22542257 * PS256 algorithm
0 commit comments