From 8769d0615a97ddde04cf95b9a380a68a93ceed65 Mon Sep 17 00:00:00 2001 From: orignal Date: Wed, 16 Sep 2026 07:27:26 -0400 Subject: [PATCH] Revert "LeaseSet2: check declared key length before creating an encryptor" --- libi2pd/CryptoKey.h | 2 +- libi2pd/LeaseSet.cpp | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/libi2pd/CryptoKey.h b/libi2pd/CryptoKey.h index 0cd105f0..099bdd56 100644 --- a/libi2pd/CryptoKey.h +++ b/libi2pd/CryptoKey.h @@ -181,7 +181,7 @@ namespace crypto switch (type) { case i2p::data::CRYPTO_KEY_TYPE_ELGAMAL: return 256; - case i2p::data::CRYPTO_KEY_TYPE_ECIES_P256_SHA256_AES256CBC: return 64; // x and y, 32 bytes each + case i2p::data::CRYPTO_KEY_TYPE_ECIES_P256_SHA256_AES256CBC: return 32; case i2p::data::CRYPTO_KEY_TYPE_ECIES_X25519_AEAD: return 32; // ML-KEM hybrid case i2p::data::CRYPTO_KEY_TYPE_ECIES_MLKEM512_X25519_AEAD: diff --git a/libi2pd/LeaseSet.cpp b/libi2pd/LeaseSet.cpp index dd4eba83..7934abde 100644 --- a/libi2pd/LeaseSet.cpp +++ b/libi2pd/LeaseSet.cpp @@ -423,12 +423,7 @@ namespace data if (keyType <= i2p::data::CRYPTO_KEY_TYPE_ECIES_X25519_AEAD) // skip PQ keys if not supported #endif { - // encryptionKeyLen is the length the publisher declares, and it was - // checked against the buffer. The encryptor reads a length fixed by - // the key type instead, so a section declaring a short ElGamal key - // makes it read 256 bytes out of a few - if (encryptionKeyLen >= i2p::crypto::GetCryptoPublicKeyLen (keyType) && - (keyType == m_PreferredEncryptionType || !newEncryptor || keyType > newEncryptionType) && + if ((keyType == m_PreferredEncryptionType || !newEncryptor || keyType > newEncryptionType) && (!dest || dest->SupportsEncryptionType (keyType))) { auto encryptor = i2p::data::IdentityEx::CreateEncryptor (keyType, buf + offset);