From 1db6dd29b042394b299696e611d346ab6cb9cfc7 Mon Sep 17 00:00:00 2001 From: "John M. Schanck" Date: Wed, 14 Jun 2023 13:11:58 -0700 Subject: [PATCH] Allow COSEAlgorithm::ECDH_ES_HKDF256 in COSEKey::generate --- src/crypto/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crypto/mod.rs b/src/crypto/mod.rs index 091fde3..1bde6db 100644 --- a/src/crypto/mod.rs +++ b/src/crypto/mod.rs @@ -887,13 +887,13 @@ impl COSEKey { /// Generates a new key pair for the specified algorithm. /// Returns an PKCS#8 encoding of the private key, and the public key as a COSEKey. pub fn generate(alg: COSEAlgorithm) -> Result<(Vec, Self), CryptoError> { - if alg != COSEAlgorithm::ES256 { + if alg != COSEAlgorithm::ES256 && alg != COSEAlgorithm::ECDH_ES_HKDF256 { return Err(CryptoError::UnsupportedAlgorithm(alg)); } let (private, public) = gen_p256()?; let cose_ec2_key = COSEEC2Key::from_sec1_uncompressed(Curve::SECP256R1, &public)?; let public = COSEKey { - alg: COSEAlgorithm::ES256, + alg, key: COSEKeyType::EC2(cose_ec2_key), }; Ok((private, public))