Fix the KEYNID2TYPE macro
authorMatt Caswell <matt@openssl.org>
Fri, 24 Apr 2020 16:40:31 +0000 (17:40 +0100)
committerMatt Caswell <matt@openssl.org>
Mon, 4 May 2020 08:30:55 +0000 (09:30 +0100)
This macro was not correctly handling Ed25519 keys

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11635)

crypto/ec/ecx_backend.h

index 50ece17abb920a6d9a01daef6c8c8397e68a23d3..2c01294789b3f02ae620565dab5eb1c0885f0493 100644 (file)
@@ -13,8 +13,8 @@
                                      : ((id) == EVP_PKEY_X448 ? X448_KEYLEN \
                                                               : ED448_KEYLEN))
 #define KEYNID2TYPE(id) \
-    (IS25519(id) ?  ECX_KEY_TYPE_X25519 \
+    (IS25519(id) ? ((id) == EVP_PKEY_X25519 ? ECX_KEY_TYPE_X25519 \
+                                            : ECX_KEY_TYPE_ED25519) \
                  : ((id) == EVP_PKEY_X448 ? ECX_KEY_TYPE_X448 \
-                                          : ((id) == EVP_PKEY_ED25519 ? ECX_KEY_TYPE_ED25519 \
-                                                                      : ECX_KEY_TYPE_ED448)))
+                                          : ECX_KEY_TYPE_ED448))
 #define KEYLEN(p)       KEYLENID((p)->ameth->pkey_id)