Skip to content

Commit 3c59039

Browse files
committed
Define CKD_SHA256_KDF transformation
Define CKD_SHA256_KDF transformation to be used with CKM_ECDH1_DERIVE. Some HSM with FIPS restriction will refuse to derive keys with CKD_NULL. CKD_SHA256_KDF will do fine though. Unfortunately this is not implemented on softHSM (softhsm/SoftHSMv2#599) so I provide no test. This was tested fine against Thales DPOD. Signed-off-by: François Rigault <[email protected]>
1 parent b2839f5 commit 3c59039

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

cryptoki/src/mechanism/elliptic_curve.rs

+11
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,17 @@ impl<'a> EcKdf<'a> {
9393
}
9494
}
9595

96+
/// The sha256 transformation as defined in the x9 standard. The
97+
/// derived key is produced by concatenating hashes of the shared
98+
/// value followed by 00000001, 00000002, etc. until we find
99+
/// enough bytes to feel the CKA_VALUE_LEN of the derived key.
100+
pub fn sha256_x9() -> Self {
101+
Self {
102+
kdf_type: CKD_SHA256_KDF,
103+
shared_data: None,
104+
}
105+
}
106+
96107
// The intention here is to be able to support other methods with
97108
// shared data, without it being a breaking change, by just adding
98109
// additional constructors here.

0 commit comments

Comments
 (0)