Skip to content

Commit

Permalink
Review: check if the target key is symmetric before use
Browse files Browse the repository at this point in the history
  • Loading branch information
szszszsz committed Jun 29, 2023
1 parent 8329b12 commit fdc90f3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/hmacsha256p256/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use trussed::{
types::{Bytes, CoreContext, KeyId, Location, Mechanism},
Error,
};
use trussed::key::Kind::Symmetric;

#[derive(Debug, Default)]
pub struct HmacSha256P256Extension;
Expand Down Expand Up @@ -147,7 +148,7 @@ pub fn derive_key_from_hash(
type HmacSha256P256 = Hmac<sha2::Sha256>;

let key_id = request.key;
let key = keystore.load_key(key::Secrecy::Secret, None, &key_id)?;
let key = keystore.load_key(key::Secrecy::Secret, Some(Symmetric(32)), &key_id)?;
let shared_secret = key.material;

let mut mac =
Expand Down

0 comments on commit fdc90f3

Please sign in to comment.