LibTLS: Move ECCurveType to Extensions.h

Also add missing values from the IANA registry
This commit is contained in:
stelar7 2023-04-14 00:11:40 +02:00 committed by Sam Atkins
parent 0fea6e7f13
commit 6df3ffaf45
3 changed files with 11 additions and 5 deletions

View file

@ -166,6 +166,16 @@ enum class NameType : u8 {
__ENUM_NAME_TYPES
};
// https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-10
#define __ENUM_EC_CURVE_TYPES \
_ENUM_KEY_VALUE(EXPLICIT_PRIME, 1) \
_ENUM_KEY_VALUE(EXPLICIT_CHAR2, 2) \
_ENUM_KEY_VALUE(NAMED_CURVE, 3)
enum class ECCurveType : u8 {
__ENUM_EC_CURVE_TYPES
};
#undef _ENUM_KEY
#undef _ENUM_KEY_VALUE

View file

@ -298,7 +298,7 @@ ssize_t TLSv12::handle_ecdhe_rsa_server_key_exchange(ReadonlyBytes buffer)
return (i8)Error::NeedMoreData;
auto curve_type = buffer[3];
if (curve_type != (u8)ECCurveType::NamedCurve)
if (curve_type != (u8)ECCurveType::NAMED_CURVE)
return (i8)Error::NotUnderstood;
auto curve = static_cast<NamedCurve>(AK::convert_between_host_and_network_endian(ByteReader::load16(buffer.offset_pointer(4))));

View file

@ -133,10 +133,6 @@ 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