mirror of
https://github.com/trussed-dev/piv-authenticator.git
synced 2026-06-20 04:16:15 -07:00
Add support for Aes key management in tests
This commit is contained in:
committed by
Nicolas Stalder
parent
2ef4a7db4a
commit
b38ae6a654
@@ -41,6 +41,7 @@ hex = "0.4"
|
||||
test-log = "0.2"
|
||||
ron = "0.8"
|
||||
des = "0.8"
|
||||
aes = "0.8.2"
|
||||
|
||||
|
||||
[features]
|
||||
|
||||
+4
-2
@@ -9,7 +9,7 @@ use trussed::{
|
||||
api::reply::Metadata,
|
||||
config::MAX_MESSAGE_LENGTH,
|
||||
syscall, try_syscall,
|
||||
types::{KeyId, Location, Mechanism, PathBuf},
|
||||
types::{KeyId, KeySerialization, Location, Mechanism, PathBuf},
|
||||
};
|
||||
|
||||
use crate::constants::*;
|
||||
@@ -455,9 +455,11 @@ impl Persistent {
|
||||
pub fn initialize(client: &mut impl trussed::Client) -> Self {
|
||||
info!("initializing PIV state");
|
||||
let management_key = ManagementKey {
|
||||
id: syscall!(client.unsafe_inject_shared_key(
|
||||
id: syscall!(client.unsafe_inject_key(
|
||||
YUBICO_DEFAULT_MANAGEMENT_KEY_ALG.mechanism(),
|
||||
YUBICO_DEFAULT_MANAGEMENT_KEY,
|
||||
trussed::types::Location::Internal,
|
||||
KeySerialization::Raw
|
||||
))
|
||||
.key,
|
||||
alg: YUBICO_DEFAULT_MANAGEMENT_KEY_ALG,
|
||||
|
||||
@@ -6,6 +6,7 @@ mod setup;
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
||||
use aes::Aes256Enc;
|
||||
use hex_literal::hex;
|
||||
use serde::Deserialize;
|
||||
use trussed::types::GenericArray;
|
||||
@@ -348,7 +349,10 @@ impl IoCmd {
|
||||
let cipher = TdesEde3::new(GenericArray::from_slice(&key));
|
||||
cipher.encrypt_block(GenericArray::from_mut_slice(challenge));
|
||||
}
|
||||
Algorithm::Aes256 => todo!(),
|
||||
Algorithm::Aes256 => {
|
||||
let cipher = Aes256Enc::new(GenericArray::from_slice(&key));
|
||||
cipher.encrypt_block(GenericArray::from_mut_slice(challenge));
|
||||
}
|
||||
_ => panic!(),
|
||||
}
|
||||
let second_data = tlv(&[0x7C], &tlv(&[0x82], challenge));
|
||||
|
||||
Reference in New Issue
Block a user