summaryrefslogtreecommitdiffstats
path: root/openpgp/src/crypto/mod.rs
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-02-06 14:06:32 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-02-06 14:06:32 +0100
commit55018aa2b8f3b0ce045e262a05127d49308710b4 (patch)
treeef39120f01a31b3be31a27dfa9058475bfa78ec0 /openpgp/src/crypto/mod.rs
parent2a75428b44fd56616342a786cc33dd66145f6228 (diff)
openpgp: Improve secret key handling.
- Use curve25519::secret_key() to generate keys in crypto::ecdh. - Wrap the secret keys into SessionKey objects to make sure they are zeroed when dropped.
Diffstat (limited to 'openpgp/src/crypto/mod.rs')
-rw-r--r--openpgp/src/crypto/mod.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/openpgp/src/crypto/mod.rs b/openpgp/src/crypto/mod.rs
index 33f27078..9dfec48e 100644
--- a/openpgp/src/crypto/mod.rs
+++ b/openpgp/src/crypto/mod.rs
@@ -1,7 +1,7 @@
//! Cryptographic primitives.
use std::io::Read;
-use std::ops::Deref;
+use std::ops::{Deref, DerefMut};
use std::fmt;
use std::cmp::Ordering;
@@ -54,6 +54,12 @@ impl Deref for SessionKey {
}
}
+impl DerefMut for SessionKey {
+ fn deref_mut(&mut self) -> &mut [u8] {
+ &mut self.0
+ }
+}
+
impl From<Vec<u8>> for SessionKey {
fn from(v: Vec<u8>) -> Self {
SessionKey(v.into_boxed_slice())