summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Matuszewski <igor@sequoia-pgp.org>2020-10-06 21:05:28 +0200
committerIgor Matuszewski <igor@sequoia-pgp.org>2020-10-08 15:11:22 +0200
commit582355043aeb20223b46178140e7e44b0854697d (patch)
treee74abc93d5d48712fb497b33abe39451da2caffc
parent31da7811453ce3976485367d1d8e6159fb09ff2e (diff)
openpgp: Don't use Pin for Box-allocated secrets
The pointed-to buffer is already immovable and *pinned* by `Box<[u8]>`. Moving `Box` value itself only moves the pointer and does not involve moving the backing storage.
-rw-r--r--openpgp/src/crypto/mem.rs7
1 files changed, 3 insertions, 4 deletions
diff --git a/openpgp/src/crypto/mem.rs b/openpgp/src/crypto/mem.rs
index 3000f00b..9ad839f7 100644
--- a/openpgp/src/crypto/mem.rs
+++ b/openpgp/src/crypto/mem.rs
@@ -25,7 +25,6 @@ use std::cmp::{min, Ordering};
use std::fmt;
use std::hash::{Hash, Hasher};
use std::ops::{Deref, DerefMut};
-use std::pin::Pin;
use memsec;
@@ -47,7 +46,7 @@ use memsec;
/// // p is cleared once it goes out of scope.
/// ```
#[derive(Clone)]
-pub struct Protected(Pin<Box<[u8]>>);
+pub struct Protected(Box<[u8]>);
impl PartialEq for Protected {
fn eq(&self, other: &Self) -> bool {
@@ -98,13 +97,13 @@ impl DerefMut for Protected {
impl From<Vec<u8>> for Protected {
fn from(v: Vec<u8>) -> Self {
- Protected(Pin::new(v.into_boxed_slice()))
+ Protected(v.into_boxed_slice())
}
}
impl From<Box<[u8]>> for Protected {
fn from(v: Box<[u8]>) -> Self {
- Protected(Pin::new(v))
+ Protected(v)
}
}