|
@@ -132,8 +132,10 @@ enum HandshakeType {
|
|
|
|
|
|
enum class HandshakeExtension : u16 {
|
|
|
ServerName = 0x00,
|
|
|
- ApplicationLayerProtocolNegotiation = 0x10,
|
|
|
+ EllipticCurves = 0x0a,
|
|
|
+ ECPointFormats = 0x0b,
|
|
|
SignatureAlgorithms = 0x0d,
|
|
|
+ ApplicationLayerProtocolNegotiation = 0x10,
|
|
|
};
|
|
|
|
|
|
enum class NameType : u8 {
|
|
@@ -160,19 +162,25 @@ enum ClientVerificationStaus {
|
|
|
VerificationNeeded,
|
|
|
};
|
|
|
|
|
|
+enum class ECCurveType : u8 {
|
|
|
+ NamedCurve = 3,
|
|
|
+};
|
|
|
+
|
|
|
// Note for the 16 iv length instead of 8:
|
|
|
// 4 bytes of fixed IV, 8 random (nonce) bytes, 4 bytes for counter
|
|
|
// GCM specifically asks us to transmit only the nonce, the counter is zero
|
|
|
// and the fixed IV is derived from the premaster key.
|
|
|
-#define ENUMERATE_CIPHERS(C) \
|
|
|
- C(true, CipherSuite::RSA_WITH_AES_128_CBC_SHA, KeyExchangeAlgorithm::RSA, CipherAlgorithm::AES_128_CBC, Crypto::Hash::SHA1, 16, false) \
|
|
|
- C(true, CipherSuite::RSA_WITH_AES_256_CBC_SHA, KeyExchangeAlgorithm::RSA, CipherAlgorithm::AES_256_CBC, Crypto::Hash::SHA1, 16, false) \
|
|
|
- C(true, CipherSuite::RSA_WITH_AES_128_CBC_SHA256, KeyExchangeAlgorithm::RSA, CipherAlgorithm::AES_128_CBC, Crypto::Hash::SHA256, 16, false) \
|
|
|
- C(true, CipherSuite::RSA_WITH_AES_256_CBC_SHA256, KeyExchangeAlgorithm::RSA, CipherAlgorithm::AES_256_CBC, Crypto::Hash::SHA256, 16, false) \
|
|
|
- C(true, CipherSuite::RSA_WITH_AES_128_GCM_SHA256, KeyExchangeAlgorithm::RSA, CipherAlgorithm::AES_128_GCM, Crypto::Hash::SHA256, 8, true) \
|
|
|
- C(true, CipherSuite::RSA_WITH_AES_256_GCM_SHA384, KeyExchangeAlgorithm::RSA, CipherAlgorithm::AES_256_GCM, Crypto::Hash::SHA384, 8, true) \
|
|
|
- C(true, CipherSuite::DHE_RSA_WITH_AES_128_GCM_SHA256, KeyExchangeAlgorithm::DHE_RSA, CipherAlgorithm::AES_128_GCM, Crypto::Hash::SHA256, 8, true) \
|
|
|
- C(true, CipherSuite::DHE_RSA_WITH_AES_256_GCM_SHA384, KeyExchangeAlgorithm::DHE_RSA, CipherAlgorithm::AES_256_GCM, Crypto::Hash::SHA384, 8, true)
|
|
|
+#define ENUMERATE_CIPHERS(C) \
|
|
|
+ C(true, CipherSuite::RSA_WITH_AES_128_CBC_SHA, KeyExchangeAlgorithm::RSA, CipherAlgorithm::AES_128_CBC, Crypto::Hash::SHA1, 16, false) \
|
|
|
+ C(true, CipherSuite::RSA_WITH_AES_256_CBC_SHA, KeyExchangeAlgorithm::RSA, CipherAlgorithm::AES_256_CBC, Crypto::Hash::SHA1, 16, false) \
|
|
|
+ C(true, CipherSuite::RSA_WITH_AES_128_CBC_SHA256, KeyExchangeAlgorithm::RSA, CipherAlgorithm::AES_128_CBC, Crypto::Hash::SHA256, 16, false) \
|
|
|
+ C(true, CipherSuite::RSA_WITH_AES_256_CBC_SHA256, KeyExchangeAlgorithm::RSA, CipherAlgorithm::AES_256_CBC, Crypto::Hash::SHA256, 16, false) \
|
|
|
+ C(true, CipherSuite::RSA_WITH_AES_128_GCM_SHA256, KeyExchangeAlgorithm::RSA, CipherAlgorithm::AES_128_GCM, Crypto::Hash::SHA256, 8, true) \
|
|
|
+ C(true, CipherSuite::RSA_WITH_AES_256_GCM_SHA384, KeyExchangeAlgorithm::RSA, CipherAlgorithm::AES_256_GCM, Crypto::Hash::SHA384, 8, true) \
|
|
|
+ C(true, CipherSuite::DHE_RSA_WITH_AES_128_GCM_SHA256, KeyExchangeAlgorithm::DHE_RSA, CipherAlgorithm::AES_128_GCM, Crypto::Hash::SHA256, 8, true) \
|
|
|
+ C(true, CipherSuite::DHE_RSA_WITH_AES_256_GCM_SHA384, KeyExchangeAlgorithm::DHE_RSA, CipherAlgorithm::AES_256_GCM, Crypto::Hash::SHA384, 8, true) \
|
|
|
+ C(true, CipherSuite::ECDHE_RSA_WITH_AES_128_GCM_SHA256, KeyExchangeAlgorithm::ECDHE_RSA, CipherAlgorithm::AES_128_GCM, Crypto::Hash::SHA256, 8, true) \
|
|
|
+ C(true, CipherSuite::ECDHE_RSA_WITH_AES_256_GCM_SHA384, KeyExchangeAlgorithm::ECDHE_RSA, CipherAlgorithm::AES_256_GCM, Crypto::Hash::SHA384, 8, true)
|
|
|
|
|
|
constexpr KeyExchangeAlgorithm get_key_exchange_algorithm(CipherSuite suite)
|
|
|
{
|
|
@@ -233,6 +241,8 @@ struct Options {
|
|
|
{ HashAlgorithm::SHA384, SignatureAlgorithm::RSA },
|
|
|
{ HashAlgorithm::SHA256, SignatureAlgorithm::RSA },
|
|
|
{ HashAlgorithm::SHA1, SignatureAlgorithm::RSA });
|
|
|
+ OPTION_WITH_DEFAULTS(Vector<NamedCurve>, elliptic_curves, NamedCurve::x25519)
|
|
|
+ OPTION_WITH_DEFAULTS(Vector<ECPointFormat>, supported_ec_point_formats, ECPointFormat::Uncompressed)
|
|
|
|
|
|
OPTION_WITH_DEFAULTS(bool, use_sni, true)
|
|
|
OPTION_WITH_DEFAULTS(bool, use_compression, false)
|
|
@@ -448,6 +458,7 @@ private:
|
|
|
ByteBuffer build_verify_request();
|
|
|
void build_rsa_pre_master_secret(PacketBuilder&);
|
|
|
void build_dhe_rsa_pre_master_secret(PacketBuilder&);
|
|
|
+ void build_ecdhe_rsa_pre_master_secret(PacketBuilder&);
|
|
|
|
|
|
ErrorOr<bool> flush();
|
|
|
void write_into_socket();
|
|
@@ -461,6 +472,7 @@ private:
|
|
|
ssize_t handle_certificate(ReadonlyBytes);
|
|
|
ssize_t handle_server_key_exchange(ReadonlyBytes);
|
|
|
ssize_t handle_dhe_rsa_server_key_exchange(ReadonlyBytes);
|
|
|
+ ssize_t handle_ecdhe_rsa_server_key_exchange(ReadonlyBytes);
|
|
|
ssize_t handle_server_hello_done(ReadonlyBytes);
|
|
|
ssize_t handle_certificate_verify(ReadonlyBytes);
|
|
|
ssize_t handle_handshake_payload(ReadonlyBytes);
|