pub struct Uake {
pub shared_secret: SharedSecret,
pub send_a: UakeSendInit,
pub send_b: UakeSendResponse,
pub temp_key: [u8; 32],
pub eska: [u8; 2400],
}
Expand description
Represents unilaterally authenticated key exchange between two parties.
§Example:
let mut rng = rand::thread_rng();
let mut alice = Uake::new();
let mut bob = Uake::new();
let bob_keys = keypair(&mut rng)?;
let client_init = alice.client_init(&bob_keys.public, &mut rng)?;
let server_send = bob.server_receive(client_init, &bob_keys.secret, &mut rng)?;
let client_confirm = alice.client_confirm(server_send)?;
assert_eq!(alice.shared_secret, bob.shared_secret);
Fields§
The resulting shared secret from a key exchange
send_a: UakeSendInit
Sent when initiating a key exchange
send_b: UakeSendResponse
Response to a key exchange initiation
temp_key: [u8; 32]
Ephemeral keys for the key exchange
eska: [u8; 2400]
Ephemeral secret key
Implementations§
Source§impl Uake
impl Uake
Sourcepub fn client_init<R>(
&mut self,
pubkey: &PublicKey,
rng: &mut R,
) -> Result<UakeSendInit, KyberLibError>
pub fn client_init<R>( &mut self, pubkey: &PublicKey, rng: &mut R, ) -> Result<UakeSendInit, KyberLibError>
Initiates a Unilaterally Authenticated Key Exchange.
§Example:
let mut rng = rand::thread_rng();
let mut alice = Uake::new();
let bob_keys = keypair(&mut rng)?;
let client_init = alice.client_init(&bob_keys.public, &mut rng)?;
Sourcepub fn server_receive<R>(
&mut self,
send_a: UakeSendInit,
secretkey: &SecretKey,
rng: &mut R,
) -> Result<UakeSendResponse, KyberLibError>
pub fn server_receive<R>( &mut self, send_a: UakeSendInit, secretkey: &SecretKey, rng: &mut R, ) -> Result<UakeSendResponse, KyberLibError>
Handles the output of a client_init()
request.
§Example:
let mut alice = Uake::new();
let mut bob = Uake::new();
let mut bob_keys = keypair(&mut rng)?;
let client_init = alice.client_init(&bob_keys.public, &mut rng)?;
let server_send = bob.server_receive(client_init, &bob_keys.secret, &mut rng)?;
Sourcepub fn client_confirm(
&mut self,
send_b: UakeSendResponse,
) -> Result<(), KyberLibError>
pub fn client_confirm( &mut self, send_b: UakeSendResponse, ) -> Result<(), KyberLibError>
Decapsulates and authenticates the shared secret from the output of
server_receive()
.
§Example:
let client_init = alice.client_init(&bob_keys.public, &mut rng)?;
let server_send = bob.server_receive(client_init, &bob_keys.secret, &mut rng)?;
let client_confirm = alice.client_confirm(server_send)?;
assert_eq!(alice.shared_secret, bob.shared_secret);
Trait Implementations§
impl Eq for Uake
impl StructuralPartialEq for Uake
Auto Trait Implementations§
impl Freeze for Uake
impl RefUnwindSafe for Uake
impl Send for Uake
impl Sync for Uake
impl Unpin for Uake
impl UnwindSafe for Uake
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