Remove ECPointFormatList trait in favor of associated const

This commit is contained in:
Dirkjan Ochtman 2023-03-24 12:25:53 +01:00
parent 4b5578d9bd
commit 06191773c4
5 changed files with 14 additions and 21 deletions

View File

@ -16,7 +16,6 @@ use crate::msgs::handshake::{CertificateStatusRequest, ClientSessionTicket, SCTL
use crate::msgs::handshake::{ClientExtension, HasServerExtensions};
use crate::msgs::handshake::{ClientHelloPayload, HandshakeMessagePayload, HandshakePayload};
use crate::msgs::handshake::{ConvertProtocolNameList, ProtocolNameList};
use crate::msgs::handshake::{ECPointFormatList, SupportedPointFormats};
use crate::msgs::handshake::{HelloRetryRequest, KeyShareEntry};
use crate::msgs::handshake::{Random, SessionID};
use crate::msgs::message::{Message, MessagePayload};
@ -225,7 +224,7 @@ fn emit_client_hello_for_retry(
let mut exts = vec![
ClientExtension::SupportedVersions(supported_versions),
ClientExtension::ECPointFormats(ECPointFormatList::supported()),
ClientExtension::ECPointFormats(ECPointFormat::SUPPORTED.to_vec()),
ClientExtension::NamedGroups(
config
.kx_groups

View File

@ -210,6 +210,10 @@ enum_builder! {
}
}
impl ECPointFormat {
pub const SUPPORTED: [Self; 1] = [Self::Uncompressed];
}
enum_builder! {
/// The `HeartbeatMode` TLS protocol enum. Values in this enum are taken
/// from the various RFCs covering TLS, and are listed by IANA.

View File

@ -213,16 +213,6 @@ impl TlsListElement for ECPointFormat {
const SIZE_LEN: ListLength = ListLength::U8;
}
pub trait SupportedPointFormats {
fn supported() -> ECPointFormatList;
}
impl SupportedPointFormats for ECPointFormatList {
fn supported() -> ECPointFormatList {
vec![ECPointFormat::Uncompressed]
}
}
declare_u16_vec!(NamedGroups, NamedGroup);
impl TlsListElement for NamedGroup {

View File

@ -3,20 +3,20 @@ use crate::key::Certificate;
use crate::msgs::base::{Payload, PayloadU16, PayloadU24, PayloadU8};
use crate::msgs::codec::{put_u16, Codec, Reader};
use crate::msgs::enums::{
ClientCertificateType, Compression, ECCurveType, ExtensionType, KeyUpdateRequest, NamedGroup,
PSKKeyExchangeMode, ServerNameType,
ClientCertificateType, Compression, ECCurveType, ECPointFormat, ExtensionType,
KeyUpdateRequest, NamedGroup, PSKKeyExchangeMode, ServerNameType,
};
use crate::msgs::handshake::{
CertReqExtension, CertificateEntry, CertificateExtension, CertificatePayloadTLS13,
CertificateRequestPayload, CertificateRequestPayloadTLS13, CertificateStatus,
CertificateStatusRequest, ClientExtension, ClientHelloPayload, ClientSessionTicket,
ConvertProtocolNameList, ConvertServerNameList, DistinguishedName, ECDHEServerKeyExchange,
ECParameters, ECPointFormatList, EncryptedExtensions, HandshakeMessagePayload,
HandshakePayload, HasServerExtensions, HelloRetryExtension, HelloRetryRequest, KeyShareEntry,
ECParameters, EncryptedExtensions, HandshakeMessagePayload, HandshakePayload,
HasServerExtensions, HelloRetryExtension, HelloRetryRequest, KeyShareEntry,
NewSessionTicketExtension, NewSessionTicketPayload, NewSessionTicketPayloadTLS13,
PresharedKeyBinder, PresharedKeyIdentity, PresharedKeyOffer, ProtocolName, Random, Sct,
ServerECDHParams, ServerExtension, ServerHelloPayload, ServerKeyExchangePayload, SessionID,
SupportedPointFormats, UnknownExtension,
UnknownExtension,
};
use crate::verify::DigitallySignedStruct;
@ -367,7 +367,7 @@ fn get_sample_clienthellopayload() -> ClientHelloPayload {
cipher_suites: vec![CipherSuite::TLS_NULL_WITH_NULL_NULL],
compression_methods: vec![Compression::Null],
extensions: vec![
ClientExtension::ECPointFormats(ECPointFormatList::supported()),
ClientExtension::ECPointFormats(ECPointFormat::SUPPORTED.to_vec()),
ClientExtension::NamedGroups(vec![NamedGroup::X25519]),
ClientExtension::SignatureAlgorithms(vec![SignatureScheme::ECDSA_NISTP256_SHA256]),
ClientExtension::make_sni(DnsNameRef::try_from_ascii_str("hello").unwrap()),
@ -760,7 +760,7 @@ fn get_sample_serverhellopayload() -> ServerHelloPayload {
cipher_suite: CipherSuite::TLS_NULL_WITH_NULL_NULL,
compression_method: Compression::Null,
extensions: vec![
ServerExtension::ECPointFormats(ECPointFormatList::supported()),
ServerExtension::ECPointFormats(ECPointFormat::SUPPORTED.to_vec()),
ServerExtension::ServerNameAck,
ServerExtension::SessionTicketAck,
ServerExtension::RenegotiationInfo(PayloadU8(vec![0])),

View File

@ -34,11 +34,11 @@ mod client_hello {
use crate::enums::SignatureScheme;
use crate::msgs::enums::ECPointFormat;
use crate::msgs::enums::{ClientCertificateType, Compression};
use crate::msgs::handshake::ServerECDHParams;
use crate::msgs::handshake::{CertificateRequestPayload, ClientSessionTicket, Random};
use crate::msgs::handshake::{CertificateStatus, ECDHEServerKeyExchange};
use crate::msgs::handshake::{ClientExtension, SessionID};
use crate::msgs::handshake::{ClientHelloPayload, ServerHelloPayload};
use crate::msgs::handshake::{ECPointFormatList, ServerECDHParams, SupportedPointFormats};
use crate::msgs::handshake::{ServerExtension, ServerKeyExchangePayload};
use crate::sign;
use crate::verify::DigitallySignedStruct;
@ -168,7 +168,7 @@ mod client_hello {
.cloned()
.ok_or_else(|| hs::incompatible(cx.common, PeerIncompatible::NoKxGroupsInCommon))?;
let ecpoint = ECPointFormatList::supported()
let ecpoint = ECPointFormat::SUPPORTED
.iter()
.find(|format| ecpoints_ext.contains(format))
.cloned()