mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-16 06:02:18 +02:00
Initial Noise states and encryptors/decryptors for ML-KEM-768 and ML-KEM-1024
Some checks are pending
Build Debian packages / bookworm (push) Waiting to run
Build Debian packages / bullseye (push) Waiting to run
Build Debian packages / buster (push) Waiting to run
Build on FreeBSD / with UPnP (push) Waiting to run
Build on OSX / With USE_UPNP=no (push) Waiting to run
Build on OSX / With USE_UPNP=yes (push) Waiting to run
Build on Windows / clang-x86_64 (push) Waiting to run
Build on Windows / i686 (push) Waiting to run
Build on Windows / ucrt-x86_64 (push) Waiting to run
Build on Windows / x86_64 (push) Waiting to run
Build on Windows / CMake clang-x86_64 (push) Waiting to run
Build on Windows / CMake i686 (push) Waiting to run
Build on Windows / CMake ucrt-x86_64 (push) Waiting to run
Build on Windows / CMake x86_64 (push) Waiting to run
Build on Windows / XP (push) Waiting to run
Build on Ubuntu / Make with USE_UPNP=no (push) Waiting to run
Build on Ubuntu / Make with USE_UPNP=yes (push) Waiting to run
Build on Ubuntu / CMake with -DWITH_UPNP=OFF (push) Waiting to run
Build on Ubuntu / CMake with -DWITH_UPNP=ON (push) Waiting to run
Build containers / Building container for linux/amd64 (push) Waiting to run
Build containers / Building container for linux/arm64 (push) Waiting to run
Build containers / Building container for linux/arm/v7 (push) Waiting to run
Build containers / Building container for linux/386 (push) Waiting to run
Build containers / Pushing merged manifest (push) Blocked by required conditions
Some checks are pending
Build Debian packages / bookworm (push) Waiting to run
Build Debian packages / bullseye (push) Waiting to run
Build Debian packages / buster (push) Waiting to run
Build on FreeBSD / with UPnP (push) Waiting to run
Build on OSX / With USE_UPNP=no (push) Waiting to run
Build on OSX / With USE_UPNP=yes (push) Waiting to run
Build on Windows / clang-x86_64 (push) Waiting to run
Build on Windows / i686 (push) Waiting to run
Build on Windows / ucrt-x86_64 (push) Waiting to run
Build on Windows / x86_64 (push) Waiting to run
Build on Windows / CMake clang-x86_64 (push) Waiting to run
Build on Windows / CMake i686 (push) Waiting to run
Build on Windows / CMake ucrt-x86_64 (push) Waiting to run
Build on Windows / CMake x86_64 (push) Waiting to run
Build on Windows / XP (push) Waiting to run
Build on Ubuntu / Make with USE_UPNP=no (push) Waiting to run
Build on Ubuntu / Make with USE_UPNP=yes (push) Waiting to run
Build on Ubuntu / CMake with -DWITH_UPNP=OFF (push) Waiting to run
Build on Ubuntu / CMake with -DWITH_UPNP=ON (push) Waiting to run
Build containers / Building container for linux/amd64 (push) Waiting to run
Build containers / Building container for linux/arm64 (push) Waiting to run
Build containers / Building container for linux/arm/v7 (push) Waiting to run
Build containers / Building container for linux/386 (push) Waiting to run
Build containers / Pushing merged manifest (push) Blocked by required conditions
This commit is contained in:
parent
1a04b59585
commit
9c46ff2449
3 changed files with 50 additions and 10 deletions
|
@ -167,7 +167,11 @@ namespace crypto
|
||||||
case i2p::data::CRYPTO_KEY_TYPE_ELGAMAL: return 256;
|
case i2p::data::CRYPTO_KEY_TYPE_ELGAMAL: return 256;
|
||||||
case i2p::data::CRYPTO_KEY_TYPE_ECIES_P256_SHA256_AES256CBC: return 32;
|
case i2p::data::CRYPTO_KEY_TYPE_ECIES_P256_SHA256_AES256CBC: return 32;
|
||||||
case i2p::data::CRYPTO_KEY_TYPE_ECIES_X25519_AEAD: return 32;
|
case i2p::data::CRYPTO_KEY_TYPE_ECIES_X25519_AEAD: return 32;
|
||||||
case i2p::data::CRYPTO_KEY_TYPE_ECIES_MLKEM512_X25519_AEAD: return 32;
|
// ML-KEM hybrid
|
||||||
|
case i2p::data::CRYPTO_KEY_TYPE_ECIES_MLKEM512_X25519_AEAD:
|
||||||
|
case i2p::data::CRYPTO_KEY_TYPE_ECIES_MLKEM768_X25519_AEAD:
|
||||||
|
case i2p::data::CRYPTO_KEY_TYPE_ECIES_MLKEM1024_X25519_AEAD:
|
||||||
|
return 32;
|
||||||
};
|
};
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -179,7 +183,11 @@ namespace crypto
|
||||||
case i2p::data::CRYPTO_KEY_TYPE_ELGAMAL: return 256;
|
case i2p::data::CRYPTO_KEY_TYPE_ELGAMAL: return 256;
|
||||||
case i2p::data::CRYPTO_KEY_TYPE_ECIES_P256_SHA256_AES256CBC: return 32;
|
case i2p::data::CRYPTO_KEY_TYPE_ECIES_P256_SHA256_AES256CBC: return 32;
|
||||||
case i2p::data::CRYPTO_KEY_TYPE_ECIES_X25519_AEAD: return 32;
|
case i2p::data::CRYPTO_KEY_TYPE_ECIES_X25519_AEAD: return 32;
|
||||||
case i2p::data::CRYPTO_KEY_TYPE_ECIES_MLKEM512_X25519_AEAD: return 32;
|
// ML-KEM hybrid
|
||||||
|
case i2p::data::CRYPTO_KEY_TYPE_ECIES_MLKEM512_X25519_AEAD:
|
||||||
|
case i2p::data::CRYPTO_KEY_TYPE_ECIES_MLKEM768_X25519_AEAD:
|
||||||
|
case i2p::data::CRYPTO_KEY_TYPE_ECIES_MLKEM1024_X25519_AEAD:
|
||||||
|
return 32;
|
||||||
};
|
};
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -419,7 +419,9 @@ namespace data
|
||||||
return std::make_shared<i2p::crypto::ElGamalEncryptor>(key);
|
return std::make_shared<i2p::crypto::ElGamalEncryptor>(key);
|
||||||
break;
|
break;
|
||||||
case CRYPTO_KEY_TYPE_ECIES_X25519_AEAD:
|
case CRYPTO_KEY_TYPE_ECIES_X25519_AEAD:
|
||||||
case CRYPTO_KEY_TYPE_ECIES_MLKEM512_X25519_AEAD:
|
case CRYPTO_KEY_TYPE_ECIES_MLKEM512_X25519_AEAD:
|
||||||
|
case CRYPTO_KEY_TYPE_ECIES_MLKEM768_X25519_AEAD:
|
||||||
|
case CRYPTO_KEY_TYPE_ECIES_MLKEM1024_X25519_AEAD:
|
||||||
return std::make_shared<i2p::crypto::ECIESX25519AEADRatchetEncryptor>(key);
|
return std::make_shared<i2p::crypto::ECIESX25519AEADRatchetEncryptor>(key);
|
||||||
break;
|
break;
|
||||||
case CRYPTO_KEY_TYPE_ECIES_P256_SHA256_AES256CBC:
|
case CRYPTO_KEY_TYPE_ECIES_P256_SHA256_AES256CBC:
|
||||||
|
@ -686,7 +688,9 @@ namespace data
|
||||||
return std::make_shared<i2p::crypto::ElGamalDecryptor>(key);
|
return std::make_shared<i2p::crypto::ElGamalDecryptor>(key);
|
||||||
break;
|
break;
|
||||||
case CRYPTO_KEY_TYPE_ECIES_X25519_AEAD:
|
case CRYPTO_KEY_TYPE_ECIES_X25519_AEAD:
|
||||||
case CRYPTO_KEY_TYPE_ECIES_MLKEM512_X25519_AEAD:
|
case CRYPTO_KEY_TYPE_ECIES_MLKEM512_X25519_AEAD:
|
||||||
|
case CRYPTO_KEY_TYPE_ECIES_MLKEM768_X25519_AEAD:
|
||||||
|
case CRYPTO_KEY_TYPE_ECIES_MLKEM1024_X25519_AEAD:
|
||||||
return std::make_shared<i2p::crypto::ECIESX25519AEADRatchetDecryptor>(key);
|
return std::make_shared<i2p::crypto::ECIESX25519AEADRatchetDecryptor>(key);
|
||||||
break;
|
break;
|
||||||
case CRYPTO_KEY_TYPE_ECIES_P256_SHA256_AES256CBC:
|
case CRYPTO_KEY_TYPE_ECIES_P256_SHA256_AES256CBC:
|
||||||
|
@ -774,7 +778,9 @@ namespace data
|
||||||
i2p::crypto::CreateECIESP256RandomKeys (priv, pub);
|
i2p::crypto::CreateECIESP256RandomKeys (priv, pub);
|
||||||
break;
|
break;
|
||||||
case CRYPTO_KEY_TYPE_ECIES_X25519_AEAD:
|
case CRYPTO_KEY_TYPE_ECIES_X25519_AEAD:
|
||||||
case CRYPTO_KEY_TYPE_ECIES_MLKEM512_X25519_AEAD:
|
case CRYPTO_KEY_TYPE_ECIES_MLKEM512_X25519_AEAD:
|
||||||
|
case CRYPTO_KEY_TYPE_ECIES_MLKEM768_X25519_AEAD:
|
||||||
|
case CRYPTO_KEY_TYPE_ECIES_MLKEM1024_X25519_AEAD:
|
||||||
i2p::crypto::CreateECIESX25519AEADRatchetRandomKeys (priv, pub);
|
i2p::crypto::CreateECIESX25519AEADRatchetRandomKeys (priv, pub);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -64,7 +64,7 @@ namespace crypto
|
||||||
EVP_PKEY_CTX_free (ctx);
|
EVP_PKEY_CTX_free (ctx);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogError, "MLKEM512 can't create PKEY context");
|
LogPrint (eLogError, "MLKEM can't create PKEY context");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MLKEMKeys::Encaps (uint8_t * ciphertext, uint8_t * shared)
|
void MLKEMKeys::Encaps (uint8_t * ciphertext, uint8_t * shared)
|
||||||
|
@ -79,7 +79,7 @@ namespace crypto
|
||||||
EVP_PKEY_CTX_free (ctx);
|
EVP_PKEY_CTX_free (ctx);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogError, "MLKEM512 can't create PKEY context");
|
LogPrint (eLogError, "MLKEM can't create PKEY context");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MLKEMKeys::Decaps (const uint8_t * ciphertext, uint8_t * shared)
|
void MLKEMKeys::Decaps (const uint8_t * ciphertext, uint8_t * shared)
|
||||||
|
@ -94,7 +94,7 @@ namespace crypto
|
||||||
EVP_PKEY_CTX_free (ctx);
|
EVP_PKEY_CTX_free (ctx);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogError, "MLKEM512 can't create PKEY context");
|
LogPrint (eLogError, "MLKEM can't create PKEY context");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<MLKEMKeys> CreateMLKEMKeys (i2p::data::CryptoKeyType type)
|
std::unique_ptr<MLKEMKeys> CreateMLKEMKeys (i2p::data::CryptoKeyType type)
|
||||||
|
@ -104,7 +104,7 @@ namespace crypto
|
||||||
return std::make_unique<MLKEMKeys>((MLKEMTypes)(type - i2p::data::CRYPTO_KEY_TYPE_ECIES_X25519_AEAD - 1));
|
return std::make_unique<MLKEMKeys>((MLKEMTypes)(type - i2p::data::CRYPTO_KEY_TYPE_ECIES_X25519_AEAD - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr std::array<std::pair<std::array<uint8_t, 32>, std::array<uint8_t, 32> >, 1> NoiseIKInitMLKEMKeys =
|
static constexpr std::array<std::pair<std::array<uint8_t, 32>, std::array<uint8_t, 32> >, 3> NoiseIKInitMLKEMKeys =
|
||||||
{
|
{
|
||||||
std::make_pair
|
std::make_pair
|
||||||
(
|
(
|
||||||
|
@ -118,7 +118,33 @@ namespace crypto
|
||||||
0x95, 0x8d, 0xf6, 0x6c, 0x95, 0xce, 0xa9, 0xf7, 0x42, 0xfc, 0xfa, 0x62, 0x71, 0x36, 0x1e, 0xa7,
|
0x95, 0x8d, 0xf6, 0x6c, 0x95, 0xce, 0xa9, 0xf7, 0x42, 0xfc, 0xfa, 0x62, 0x71, 0x36, 0x1e, 0xa7,
|
||||||
0xdc, 0x7a, 0xc0, 0x75, 0x01, 0xcf, 0xf9, 0xfc, 0x9f, 0xdb, 0x4c, 0x68, 0x3a, 0x53, 0x49, 0xeb
|
0xdc, 0x7a, 0xc0, 0x75, 0x01, 0xcf, 0xf9, 0xfc, 0x9f, 0xdb, 0x4c, 0x68, 0x3a, 0x53, 0x49, 0xeb
|
||||||
} // SHA256 (first)
|
} // SHA256 (first)
|
||||||
)
|
),
|
||||||
|
std::make_pair
|
||||||
|
(
|
||||||
|
std::array<uint8_t, 32>
|
||||||
|
{
|
||||||
|
0x36, 0x03, 0x90, 0x2d, 0xf9, 0xa2, 0x2a, 0x5e, 0xc9, 0x3d, 0xdb, 0x8f, 0xa8, 0x1b, 0xdb, 0x4b,
|
||||||
|
0xae, 0x9d, 0x93, 0x9c, 0xdf, 0xaf, 0xde, 0x55, 0x49, 0x13, 0xfe, 0x98, 0xf8, 0x4a, 0xd4, 0xbd
|
||||||
|
}, // SHA256("Noise_IKhfselg2_25519+MLKEM768_ChaChaPoly_SHA256")
|
||||||
|
std::array<uint8_t, 32>
|
||||||
|
{
|
||||||
|
0x15, 0x44, 0x89, 0xbf, 0x30, 0xf0, 0xc9, 0x77, 0x66, 0x10, 0xcb, 0xb1, 0x57, 0x3f, 0xab, 0x68,
|
||||||
|
0x79, 0x57, 0x39, 0x57, 0x0a, 0xe7, 0xc0, 0x31, 0x8a, 0xa2, 0x96, 0xef, 0xbf, 0xa9, 0x6a, 0xbb
|
||||||
|
} // SHA256 (first)
|
||||||
|
),
|
||||||
|
std::make_pair
|
||||||
|
(
|
||||||
|
std::array<uint8_t, 32>
|
||||||
|
{
|
||||||
|
0x86, 0xa5, 0x36, 0x44, 0xc6, 0x12, 0xd5, 0x71, 0xa1, 0x2d, 0xd8, 0xb6, 0x0a, 0x00, 0x9f, 0x2c,
|
||||||
|
0x1a, 0xa8, 0x7d, 0x22, 0xa4, 0xff, 0x2b, 0xcd, 0x61, 0x34, 0x97, 0x6d, 0xa1, 0x49, 0xeb, 0x4a
|
||||||
|
}, // SHA256("Noise_IKhfselg2_25519+MLKEM1024_ChaChaPoly_SHA256")
|
||||||
|
std::array<uint8_t, 32>
|
||||||
|
{
|
||||||
|
0x42, 0x0d, 0xc2, 0x1c, 0x7b, 0x18, 0x61, 0xb7, 0x4a, 0x04, 0x3d, 0xae, 0x0f, 0xdc, 0xf2, 0x71,
|
||||||
|
0xb9, 0xba, 0x19, 0xbb, 0xbd, 0x5f, 0xd4, 0x9c, 0x3f, 0x4b, 0x01, 0xed, 0x6d, 0x13, 0x1d, 0xa2
|
||||||
|
} // SHA256 (first)
|
||||||
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
void InitNoiseIKStateMLKEM (NoiseSymmetricState& state, i2p::data::CryptoKeyType type, const uint8_t * pub)
|
void InitNoiseIKStateMLKEM (NoiseSymmetricState& state, i2p::data::CryptoKeyType type, const uint8_t * pub)
|
||||||
|
|
Loading…
Add table
Reference in a new issue