pub enum Connection {
Handshake {
ephemeral_key: EphemeralSecret,
},
Initialized {
shared_key: ChaCha20Poly1305,
},
}Expand description
A simplified, bespoke RA-TLS connection It can be in two possible states:
Handshake- initializing session between two partiesInitialized- ready for communicating messages securely
Variants§
Implementations§
Source§impl Connection
impl Connection
Sourcepub fn new(rng: impl CryptoRng + RngCore) -> Self
pub fn new(rng: impl CryptoRng + RngCore) -> Self
Create a new connection, which creates and ephemeral key for Diffie-Hellman
Sourcepub fn client_send(&self, nonce: u64) -> Result<ClientMsg, RatlsError>
pub fn client_send(&self, nonce: u64) -> Result<ClientMsg, RatlsError>
The client side sends its ephemeral public key
Sourcepub fn enclave_reply(&self, report: Vec<u8>) -> Result<MsgToHost, RatlsError>
pub fn enclave_reply(&self, report: Vec<u8>) -> Result<MsgToHost, RatlsError>
The enclave replies with its Attestation report, which contains its ephemeral public key and a session id.
Sourcepub fn initialize(self, pk: PublicKey) -> Result<Self, RatlsError>
pub fn initialize(self, pk: PublicKey) -> Result<Self, RatlsError>
Compute the shared ChaCha20 public key for the connection.
Sourcepub fn encrypt_msg<T: CryptoRng + RngCore>(
&self,
payload: &[u8],
rng: &mut T,
) -> Result<TlsCiphertext, RatlsError>
pub fn encrypt_msg<T: CryptoRng + RngCore>( &self, payload: &[u8], rng: &mut T, ) -> Result<TlsCiphertext, RatlsError>
Encrypt a message with the session key
Sourcepub fn decrypt_msg<T: DeserializeOwned>(
&self,
msg: &TlsCiphertext,
) -> Result<T, RatlsError>
pub fn decrypt_msg<T: DeserializeOwned>( &self, msg: &TlsCiphertext, ) -> Result<T, RatlsError>
Decrypt and deserialize message
Auto Trait Implementations§
impl Freeze for Connection
impl RefUnwindSafe for Connection
impl Send for Connection
impl Sync for Connection
impl Unpin for Connection
impl UnwindSafe for Connection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more