summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2026-08-29 16:15:22 +0200
committerSander Vrijders <sander@ouroboros.rocks>2026-08-31 08:31:46 +0200
commitafb0e1c4ab6732727c5231ed330f42d7f8db71f1 (patch)
treec1fef4c31e9eae700ee83ddafe064635a8f9a0d8
parent596bb667d49ff0bc89c8d0b8011a6f7bdba26f75 (diff)
downloadouroboros-afb0e1c4ab6732727c5231ed330f42d7f8db71f1.tar.gz
ouroboros-afb0e1c4ab6732727c5231ed330f42d7f8db71f1.zip
lib: Reject peer keys of another algorithmtestingbe
The openssl_dhe_derive() function decoded the peer public key from the wire with d2i_PUBKEY() and handed it straight to EVP_PKEY_derive_set_peer(). A peer offering a key of a type other than the one negotiated was only caught inside OpenSSL. This aborts in OpenSSL debug builds, which tripped integration. Now we check the decoded key type against the type of the local key pair first. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
-rw-r--r--src/lib/crypt/openssl.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/lib/crypt/openssl.c b/src/lib/crypt/openssl.c
index 1ee2318e..9c488b9d 100644
--- a/src/lib/crypt/openssl.c
+++ b/src/lib/crypt/openssl.c
@@ -1057,8 +1057,9 @@ int openssl_dhe_derive(EVP_PKEY * pkp,
int kdf,
uint8_t * s)
{
- uint8_t * pos;
- EVP_PKEY * pub;
+ uint8_t * pos;
+ EVP_PKEY * pub;
+ const char * name;
assert(pkp != NULL);
assert(pk.data != NULL);
@@ -1070,6 +1071,11 @@ int openssl_dhe_derive(EVP_PKEY * pkp,
if (pub == NULL)
goto fail_decode;
+ /* A peer key of another type must not reach the derivation */
+ name = EVP_PKEY_get0_type_name(pkp);
+ if (name == NULL || EVP_PKEY_is_a(pub, name) != 1)
+ goto fail_derive;
+
if (__openssl_dhe_derive(pkp, pub, pk, kdf, s) < 0)
goto fail_derive;