skip post-quantum keys if not supported

This commit is contained in:
orignal 2025-03-25 18:55:28 -04:00
parent a40fa57ed4
commit ecf19278e8
2 changed files with 22 additions and 12 deletions

View file

@ -1022,10 +1022,15 @@ namespace client
{ {
try try
{ {
i2p::data::CryptoKeyType preferredCryptoType = std::stoi(it1); i2p::data::CryptoKeyType cryptoType = std::stoi(it1);
if (!m_PreferredCryptoType && preferredCryptoType) #if !OPENSSL_PQ
m_PreferredCryptoType = preferredCryptoType; // first non-zero in the list if (cryptoType <= i2p::data::CRYPTO_KEY_TYPE_ECIES_X25519_AEAD) // skip PQ keys if not supported
encryptionKeyTypes.insert (preferredCryptoType); #endif
{
if (!m_PreferredCryptoType && cryptoType)
m_PreferredCryptoType = cryptoType; // first non-zero in the list
encryptionKeyTypes.insert (cryptoType);
}
} }
catch (std::exception& ex) catch (std::exception& ex)
{ {

View file

@ -413,15 +413,20 @@ namespace data
if (IsStoreLeases () && !preferredKeyFound) // create encryptor with leases only if (IsStoreLeases () && !preferredKeyFound) // create encryptor with leases only
{ {
// we pick max key type if preferred not found // we pick max key type if preferred not found
if (keyType == preferredKeyType || !m_Encryptor || keyType > m_EncryptionType) #if !OPENSSL_PQ
{ if (keyType <= i2p::data::CRYPTO_KEY_TYPE_ECIES_X25519_AEAD) // skip PQ keys if not supported
auto encryptor = i2p::data::IdentityEx::CreateEncryptor (keyType, buf + offset); #endif
if (encryptor) {
if (keyType == preferredKeyType || !m_Encryptor || keyType > m_EncryptionType)
{ {
m_Encryptor = encryptor; // TODO: atomic auto encryptor = i2p::data::IdentityEx::CreateEncryptor (keyType, buf + offset);
m_EncryptionType = keyType; if (encryptor)
if (keyType == preferredKeyType) preferredKeyFound = true; {
} m_Encryptor = encryptor; // TODO: atomic
m_EncryptionType = keyType;
if (keyType == preferredKeyType) preferredKeyFound = true;
}
}
} }
} }
offset += encryptionKeyLen; offset += encryptionKeyLen;