update tls-core and -aio

This commit is contained in:
sinuio
2022-06-08 10:03:03 -07:00
parent 98391d58b5
commit 5f36ba00a0
3 changed files with 35 additions and 4 deletions

View File

@@ -1,7 +1,4 @@
use tls_core::{
key::PublicKey,
msgs::{handshake::Random, message::PlainMessage},
};
use tls_core::{key::PublicKey, msgs::handshake::Random};
use async_trait::async_trait;

View File

@@ -1,5 +1,7 @@
use std::fmt;
use crate::msgs::enums::NamedGroup;
/// This type contains a private key by value.
///
/// The private key must be DER-encoded ASN.1 in either
@@ -33,6 +35,31 @@ impl fmt::Debug for Certificate {
}
}
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct PublicKey {
pub group: NamedGroup,
pub key: Vec<u8>,
}
impl PublicKey {
pub fn new(group: NamedGroup, key: &[u8]) -> Self {
Self {
group,
key: Vec::from(key),
}
}
}
impl From<crate::msgs::handshake::KeyShareEntry> for PublicKey {
#[inline]
fn from(k: crate::msgs::handshake::KeyShareEntry) -> Self {
Self {
group: k.group,
key: k.payload.0,
}
}
}
#[cfg(test)]
mod test {
use super::Certificate;

View File

@@ -403,6 +403,13 @@ impl Codec for KeyShareEntry {
}
}
impl From<crate::key::PublicKey> for KeyShareEntry {
#[inline]
fn from(k: crate::key::PublicKey) -> Self {
Self::new(k.group, &k.key)
}
}
// --- TLS 1.3 PresharedKey offers ---
#[derive(Clone, Debug)]
pub struct PresharedKeyIdentity {