add std support, wording changes, code improvements
This commit is contained in:
parent
45916848ad
commit
2b559b79f9
7 changed files with 65 additions and 36 deletions
|
|
@ -24,7 +24,7 @@ impl PartialEq for DhKeyPair {
|
|||
impl Debug for DhKeyPair {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
|
||||
f.debug_struct("DhKeyPair")
|
||||
.field("private_key", &self.private_key.to_bytes())
|
||||
.field("private_key", self.private_key.as_bytes())
|
||||
.field("public_key", self.public_key.as_bytes())
|
||||
.finish()
|
||||
}
|
||||
|
|
@ -38,7 +38,7 @@ impl Default for DhKeyPair {
|
|||
|
||||
impl DhKeyPair {
|
||||
pub fn new() -> Self {
|
||||
let secret = StaticSecret::random_from_rng(&mut OsRng);
|
||||
let secret = StaticSecret::random_from_rng(OsRng);
|
||||
let public = PublicKey::from(&secret);
|
||||
DhKeyPair {
|
||||
private_key: secret,
|
||||
|
|
@ -58,11 +58,6 @@ pub fn gen_shared_secret() -> SharedSecret {
|
|||
alice_pair.key_agreement(&bob_pair.public_key)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub fn gen_key_pair() -> DhKeyPair {
|
||||
DhKeyPair::new()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::dh::DhKeyPair;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue