LibCrypto: Cleanup Crypto::PK::RSA constructors to avoid pitfalls

- Removed the constructor taking a (n, d, e) tuple and moved
  it to `RSAPrivateKey`
- Removed default constructor with key generation because it was always
  misused and the default key size is quite small
- Added utility constructors to accept a key pair, public key, private
  key or both
- Made constructor parameters const
- Updated test to use generated random keys where possible
This commit is contained in:
devgianlu 2024-12-15 16:13:31 +01:00 committed by Ali Mohammad Pur
commit ec990d620f
Notes: github-actions[bot] 2024-12-15 22:32:47 +00:00
5 changed files with 31 additions and 30 deletions

View file

@ -189,7 +189,7 @@ void TLSv12::build_rsa_pre_master_secret(PacketBuilder& builder)
print_buffer(m_context.premaster_key);
}
Crypto::PK::RSA_PKCS1_EME rsa(certificate.public_key.rsa.modulus(), 0, certificate.public_key.rsa.public_exponent());
Crypto::PK::RSA_PKCS1_EME rsa(certificate.public_key.rsa);
Vector<u8, 32> out;
out.resize(rsa.output_size());