Skip to content

Commit d2e5e7d

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 9401af2 commit d2e5e7d

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 EcKdf<'_> {
9393
}
9494
}
9595

96+
/// The key derivation function based on sha256 as defined in the ANSI X9.63 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 fill the `CKA_VALUE_LEN` of the derived key.
100+
pub fn sha256() -> 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)