mirror of https://github.com/ctz/rustls
Clippy cleanups
This commit is contained in:
parent
46ceafd9eb
commit
1287510bec
|
@ -399,7 +399,7 @@ impl ExpectServerHello {
|
|||
fn into_expect_tls13_encrypted_extensions(self, key_schedule: KeyScheduleHandshake) -> NextState {
|
||||
Box::new(tls13::ExpectEncryptedExtensions {
|
||||
handshake: self.handshake,
|
||||
key_schedule: key_schedule,
|
||||
key_schedule,
|
||||
server_cert: self.server_cert,
|
||||
hello: self.hello,
|
||||
})
|
||||
|
|
|
@ -45,7 +45,7 @@ use ring::constant_time;
|
|||
use webpki;
|
||||
|
||||
// Extensions we expect in plaintext in the ServerHello.
|
||||
static ALLOWED_PLAINTEXT_EXTS: &'static [ExtensionType] = &[
|
||||
static ALLOWED_PLAINTEXT_EXTS: &[ExtensionType] = &[
|
||||
ExtensionType::KeyShare,
|
||||
ExtensionType::PreSharedKey,
|
||||
ExtensionType::SupportedVersions,
|
||||
|
@ -53,7 +53,7 @@ static ALLOWED_PLAINTEXT_EXTS: &'static [ExtensionType] = &[
|
|||
|
||||
// Only the intersection of things we offer, and those disallowed
|
||||
// in TLS1.3
|
||||
static DISALLOWED_TLS13_EXTS: &'static [ExtensionType] = &[
|
||||
static DISALLOWED_TLS13_EXTS: &[ExtensionType] = &[
|
||||
ExtensionType::ECPointFormats,
|
||||
ExtensionType::SessionTicket,
|
||||
ExtensionType::RenegotiationInfo,
|
||||
|
@ -813,8 +813,8 @@ impl ExpectFinished {
|
|||
sig_verified: verify::HandshakeSignatureValid,
|
||||
fin_verified: verify::FinishedMessageVerified) -> ExpectTraffic {
|
||||
ExpectTraffic {
|
||||
handshake: handshake,
|
||||
key_schedule: key_schedule,
|
||||
handshake,
|
||||
key_schedule,
|
||||
want_write_key_update: false,
|
||||
_cert_verified: cert_verified,
|
||||
_sig_verified: sig_verified,
|
||||
|
|
|
@ -43,7 +43,7 @@ impl<'a> Reader<'a> {
|
|||
}
|
||||
|
||||
pub fn sub(&mut self, len: usize) -> Option<Reader> {
|
||||
self.take(len).and_then(|bytes| Some(Reader::init(bytes)))
|
||||
self.take(len).map(Reader::init)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -989,7 +989,7 @@ impl ClientHelloPayload {
|
|||
|
||||
pub fn psk_mode_offered(&self, mode: PSKKeyExchangeMode) -> bool {
|
||||
self.get_psk_modes()
|
||||
.and_then(|modes| Some(modes.contains(&mode)))
|
||||
.map(|modes| modes.contains(&mode))
|
||||
.or(Some(false))
|
||||
.unwrap()
|
||||
}
|
||||
|
@ -1661,7 +1661,7 @@ impl Codec for ServerKeyExchangePayload {
|
|||
fn read(r: &mut Reader) -> Option<ServerKeyExchangePayload> {
|
||||
// read as Unknown, fully parse when we know the
|
||||
// KeyExchangeAlgorithm
|
||||
Payload::read(r).and_then(|x| Some(ServerKeyExchangePayload::Unknown(x)))
|
||||
Payload::read(r).map(ServerKeyExchangePayload::Unknown)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1673,7 +1673,7 @@ impl ServerKeyExchangePayload {
|
|||
let result = match *kxa {
|
||||
KeyExchangeAlgorithm::ECDHE => {
|
||||
ECDHEServerKeyExchange::read(&mut rd)
|
||||
.and_then(|x| Some(ServerKeyExchangePayload::ECDHE(x)))
|
||||
.map(ServerKeyExchangePayload::ECDHE)
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
|
|
|
@ -218,33 +218,32 @@ impl ExtensionProcessing {
|
|||
self.exts.push(ServerExtension::ServerNameAck);
|
||||
}
|
||||
|
||||
// Send status_request response if we have one. This is not allowed
|
||||
// if we're resuming, and is only triggered if we have an OCSP response
|
||||
// to send.
|
||||
if !for_resume &&
|
||||
hello.find_extension(ExtensionType::StatusRequest).is_some() &&
|
||||
server_key.is_some() &&
|
||||
server_key.as_ref().unwrap().has_ocsp() {
|
||||
self.send_cert_status = true;
|
||||
if let Some(server_key) = server_key {
|
||||
// Send status_request response if we have one. This is not allowed
|
||||
// if we're resuming, and is only triggered if we have an OCSP response
|
||||
// to send.
|
||||
if !for_resume &&
|
||||
hello.find_extension(ExtensionType::StatusRequest).is_some() &&
|
||||
server_key.has_ocsp() {
|
||||
self.send_cert_status = true;
|
||||
|
||||
if !sess.common.is_tls13() {
|
||||
// Only TLS1.2 sends confirmation in ServerHello
|
||||
self.exts.push(ServerExtension::CertificateStatusAck);
|
||||
if !sess.common.is_tls13() {
|
||||
// Only TLS1.2 sends confirmation in ServerHello
|
||||
self.exts.push(ServerExtension::CertificateStatusAck);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !for_resume &&
|
||||
hello.find_extension(ExtensionType::SCT).is_some() &&
|
||||
server_key.is_some() &&
|
||||
server_key.as_ref().unwrap().has_sct_list() {
|
||||
self.send_sct = true;
|
||||
if !for_resume &&
|
||||
hello.find_extension(ExtensionType::SCT).is_some() &&
|
||||
server_key.has_sct_list() {
|
||||
self.send_sct = true;
|
||||
|
||||
if !sess.common.is_tls13() {
|
||||
let sct_list = server_key
|
||||
.unwrap()
|
||||
.take_sct_list()
|
||||
.unwrap();
|
||||
self.exts.push(ServerExtension::make_sct(sct_list));
|
||||
if !sess.common.is_tls13() {
|
||||
let sct_list = server_key
|
||||
.take_sct_list()
|
||||
.unwrap();
|
||||
self.exts.push(ServerExtension::make_sct(sct_list));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -472,12 +472,9 @@ impl SessionCommon {
|
|||
}
|
||||
|
||||
let rc = self.record_layer.decrypt_incoming(encr);
|
||||
match rc {
|
||||
Err(TLSError::PeerSentOversizedRecord) => {
|
||||
self.send_fatal_alert(AlertDescription::RecordOverflow);
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
if let Err(TLSError::PeerSentOversizedRecord) = rc {
|
||||
self.send_fatal_alert(AlertDescription::RecordOverflow);
|
||||
}
|
||||
rc
|
||||
}
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@ pub struct RSASigningKey {
|
|||
key: Arc<RsaKeyPair>,
|
||||
}
|
||||
|
||||
static ALL_RSA_SCHEMES: &'static [SignatureScheme] = &[
|
||||
static ALL_RSA_SCHEMES: &[SignatureScheme] = &[
|
||||
SignatureScheme::RSA_PSS_SHA512,
|
||||
SignatureScheme::RSA_PSS_SHA384,
|
||||
SignatureScheme::RSA_PSS_SHA256,
|
||||
|
|
|
@ -375,7 +375,7 @@ pub static TLS13_AES_128_GCM_SHA256: SupportedCipherSuite = SupportedCipherSuite
|
|||
};
|
||||
|
||||
/// A list of all the cipher suites supported by rustls.
|
||||
pub static ALL_CIPHERSUITES: [&'static SupportedCipherSuite; 9] =
|
||||
pub static ALL_CIPHERSUITES: [&SupportedCipherSuite; 9] =
|
||||
[// TLS1.3 suites
|
||||
&TLS13_CHACHA20_POLY1305_SHA256,
|
||||
&TLS13_AES_256_GCM_SHA384,
|
||||
|
|
|
@ -133,10 +133,12 @@ impl WebPKIVerifier {
|
|||
}
|
||||
}
|
||||
|
||||
type CertChainAndRoots<'a, 'b> = (webpki::EndEntityCert<'a>,
|
||||
Vec<&'a [u8]>,
|
||||
Vec<webpki::TrustAnchor<'b>>);
|
||||
|
||||
fn prepare<'a, 'b>(roots: &'b RootCertStore, presented_certs: &'a [Certificate])
|
||||
-> Result<(webpki::EndEntityCert<'a>,
|
||||
Vec<&'a [u8]>,
|
||||
Vec<webpki::TrustAnchor<'b>>), TLSError> {
|
||||
-> Result<CertChainAndRoots<'a, 'b>, TLSError> {
|
||||
if presented_certs.is_empty() {
|
||||
return Err(TLSError::NoCertificatesPresented);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue