Skip to content

Commit 074c21b

Browse files
Removed pinned boxes
Signed-off-by: Jacob Prud'homme <2160185+jacobprudhomme@users.noreply.github.com>
1 parent bea29ba commit 074c21b

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

cryptoki/src/mechanism/kbkdf.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! Mechanisms of NIST key-based key derive functions (SP 800-108, informally KBKDF)
44
//! See: <https://docs.oasis-open.org/pkcs11/pkcs11-curr/v3.0/os/pkcs11-curr-v3.0-os.html#_Toc30061446>
55
6-
use core::{convert::TryInto, marker::PhantomData, pin::Pin, ptr};
6+
use core::{convert::TryInto, marker::PhantomData, ptr};
77
use std::num::NonZeroUsize;
88

99
use cryptoki_sys::{
@@ -182,7 +182,9 @@ impl<'a> PrfDataParam<'a> {
182182
/// Container for information on an additional key to be derived.
183183
#[derive(Debug)]
184184
pub struct DerivedKey {
185-
template: Pin<Box<[CK_ATTRIBUTE]>>,
185+
/// Holds own data so that we have a contiguous memory region for backend to reference.
186+
/// Because of this, the address of this allocation must remain stable during its lifetime.
187+
template: Box<[CK_ATTRIBUTE]>,
186188
handle: CK_OBJECT_HANDLE,
187189
}
188190

@@ -194,7 +196,6 @@ impl DerivedKey {
194196
/// * `template` - The template for the key to be derived.
195197
pub fn new(template: &[Attribute]) -> Self {
196198
let template: Box<[CK_ATTRIBUTE]> = template.iter().map(Into::into).collect();
197-
let template = Pin::new(template);
198199

199200
Self {
200201
template,
@@ -231,8 +232,9 @@ impl From<&mut DerivedKey> for CK_DERIVED_KEY {
231232
/// This structure wraps a `CK_SP800_108_KDF_PARAMS` structure.
232233
#[derive(Debug)]
233234
pub struct KbkdfParams<'a> {
234-
/// Holds own data so that we have a contiguous memory region to give to backend
235-
_additional_derived_keys: Option<Pin<Box<[CK_DERIVED_KEY]>>>,
235+
/// Holds own data so that we have a contiguous memory region for backend to reference.
236+
/// Because of this, the address of this allocation must remain stable during its lifetime.
237+
_additional_derived_keys: Option<Box<[CK_DERIVED_KEY]>>,
236238

237239
inner: CK_SP800_108_KDF_PARAMS,
238240
/// Marker type to ensure we don't outlive the data
@@ -260,8 +262,7 @@ impl<'a> KbkdfParams<'a> {
260262
keys.iter_mut()
261263
.map(Into::into)
262264
.collect::<Box<[CK_DERIVED_KEY]>>()
263-
})
264-
.map(Pin::new);
265+
});
265266

266267
let inner = CK_SP800_108_KDF_PARAMS {
267268
prfType: prf_mechanism.into(),
@@ -300,8 +301,9 @@ impl<'a> KbkdfParams<'a> {
300301
/// This structure wraps a `CK_SP800_108_FEEDBACK_KDF_PARAMS` structure.
301302
#[derive(Debug)]
302303
pub struct KbkdfFeedbackParams<'a> {
303-
/// Holds own data so that we have a contiguous memory region to give to backend
304-
_additional_derived_keys: Option<Pin<Box<[CK_DERIVED_KEY]>>>,
304+
/// Holds own data so that we have a contiguous memory region for backend to reference.
305+
/// Because of this, the address of this allocation must remain stable during its lifetime.
306+
_additional_derived_keys: Option<Box<[CK_DERIVED_KEY]>>,
305307

306308
inner: CK_SP800_108_FEEDBACK_KDF_PARAMS,
307309
/// Marker type to ensure we don't outlive the data
@@ -332,8 +334,7 @@ impl<'a> KbkdfFeedbackParams<'a> {
332334
keys.iter_mut()
333335
.map(Into::into)
334336
.collect::<Box<[CK_DERIVED_KEY]>>()
335-
})
336-
.map(Pin::new);
337+
});
337338

338339
let inner = CK_SP800_108_FEEDBACK_KDF_PARAMS {
339340
prfType: prf_mechanism.into(),

0 commit comments

Comments
 (0)