diff options
author | Jesse Luehrs <doy@tozt.net> | 2019-04-18 02:23:35 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2019-04-18 02:23:35 -0400 |
commit | caaf7016fcecd3a95df53e65150666d50bd0fbcf (patch) | |
tree | 319811626f9554cf839ff7ee5e687ec779f73f6e /src/dh.rs | |
parent | df9d05b74ef79671d4421bf6134b204fdc7a5ee3 (diff) | |
download | matasano-caaf7016fcecd3a95df53e65150666d50bd0fbcf.tar.gz matasano-caaf7016fcecd3a95df53e65150666d50bd0fbcf.zip |
problem 34
Diffstat (limited to 'src/dh.rs')
-rw-r--r-- | src/dh.rs | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -1,10 +1,13 @@ use num_bigint::RandBigInt; +use serde_derive::{Deserialize, Serialize}; +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct DHKeyPair { pub p: num_bigint::BigUint, pub g: num_bigint::BigUint, pub pubkey: num_bigint::BigUint, - privkey: num_bigint::BigUint, + #[serde(skip)] + privkey: Option<num_bigint::BigUint>, } impl DHKeyPair { @@ -15,7 +18,7 @@ impl DHKeyPair { p, g, pubkey, - privkey, + privkey: Some(privkey), } } @@ -23,6 +26,6 @@ impl DHKeyPair { &self, other_pubkey: &num_bigint::BigUint, ) -> num_bigint::BigUint { - other_pubkey.modpow(&self.privkey, &self.p) + other_pubkey.modpow(self.privkey.as_ref().unwrap(), &self.p) } } |