Skip to content

Commit 02a9518

Browse files
committed
style: add header, change match style
Signed-off-by: Direktor799 <[email protected]>
1 parent 6ff4c8a commit 02a9518

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

cryptoki/src/mechanism/hkdf.rs

+12-9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Copyright 2021 Contributors to the Parsec project.
2+
// SPDX-License-Identifier: Apache-2.0
13
//! Mechanisms of hash-based key derive function (HKDF)
24
//! See: <https://docs.oasis-open.org/pkcs11/pkcs11-curr/v3.0/os/pkcs11-curr-v3.0-os.html#_Toc30061597>
35
@@ -9,8 +11,8 @@ use crate::object::ObjectHandle;
911

1012
use super::MechanismType;
1113

12-
#[derive(Debug, Clone, Copy)]
1314
/// The salt for the extract stage.
15+
#[derive(Debug, Clone, Copy)]
1416
pub enum HkdfSalt<'a> {
1517
/// CKF_HKDF_SALT_NULL no salt is supplied.
1618
Null,
@@ -62,16 +64,17 @@ impl<'a> HkdfParams<'a> {
6264
HkdfSalt::Data(_) => CKF_HKDF_SALT_DATA,
6365
HkdfSalt::Key(_) => CKF_HKDF_SALT_KEY,
6466
},
65-
pSalt: match salt {
66-
HkdfSalt::Data(data) => data.as_ptr() as *mut _,
67-
_ => null_mut(),
67+
pSalt: if let HkdfSalt::Data(data) = salt {
68+
data.as_ptr() as *mut _
69+
} else {
70+
null_mut()
6871
},
69-
ulSaltLen: match salt {
70-
HkdfSalt::Data(data) => data
71-
.len()
72+
ulSaltLen: if let HkdfSalt::Data(data) = salt {
73+
data.len()
7274
.try_into()
73-
.expect("salt length does not fit in CK_ULONG"),
74-
_ => 0,
75+
.expect("salt length does not fit in CK_ULONG")
76+
} else {
77+
0
7578
},
7679
hSaltKey: match salt {
7780
HkdfSalt::Key(key) => key.handle(),

0 commit comments

Comments
 (0)