takes slices
This commit is contained in:
parent
a07f32e032
commit
bf1504cca6
@ -31,7 +31,7 @@ pub trait HmacExtension {
|
||||
"hmac-secret"
|
||||
}
|
||||
|
||||
fn get_dict(&mut self, salt: [u8; 32], salt2: Option<[u8; 32]>) -> FidoResult<Value> {
|
||||
fn get_dict(&mut self, salt: &[u8; 32], salt2: Option<&[u8; 32]>) -> FidoResult<Value> {
|
||||
let mut map = BTreeMap::new();
|
||||
map.insert(
|
||||
Key::Text(Text::Text(Self::extension_name().to_owned())),
|
||||
@ -40,15 +40,15 @@ pub trait HmacExtension {
|
||||
Ok(Value::Map(map))
|
||||
}
|
||||
|
||||
fn get_data(&mut self, salt: [u8; 32], salt2: Option<[u8; 32]>) -> FidoResult<Value>;
|
||||
fn get_data(&mut self, salt: &[u8; 32], salt2: Option<&[u8; 32]>) -> FidoResult<Value>;
|
||||
|
||||
fn make_hmac_credential(&mut self) -> FidoResult<FidoHmacCredential>;
|
||||
|
||||
fn get_hmac_assertion(
|
||||
&mut self,
|
||||
credential: &FidoHmacCredential,
|
||||
salt: [u8; 32],
|
||||
salt2: Option<[u8; 32]>,
|
||||
salt: &[u8; 32],
|
||||
salt2: Option<&[u8; 32]>,
|
||||
) -> FidoResult<([u8; 32], Option<[u8; 32]>)>;
|
||||
|
||||
fn hmac_challange(
|
||||
@ -60,21 +60,21 @@ pub trait HmacExtension {
|
||||
let mut digest = Sha256::new();
|
||||
digest.input(input);
|
||||
digest.result(&mut salt);
|
||||
self.get_hmac_assertion(credential, salt, None).map(|secret| secret.0)
|
||||
self.get_hmac_assertion(credential, &salt, None).map(|secret| secret.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl HmacExtension for FidoDevice {
|
||||
fn get_data(&mut self, salt: [u8; 32], salt2: Option<[u8; 32]>) -> FidoResult<Value> {
|
||||
fn get_data(&mut self, salt: &[u8; 32], salt2: Option<&[u8; 32]>) -> FidoResult<Value> {
|
||||
let shared_secret = self.shared_secret.as_ref().unwrap();
|
||||
let mut encryptor = shared_secret.encryptor();
|
||||
let mut salt_enc = [0u8; 64];
|
||||
let mut output = RefWriteBuffer::new(&mut salt_enc);
|
||||
let mut encrypt = || {
|
||||
encryptor.encrypt(&mut RefReadBuffer::new(&salt), &mut output, salt2.is_none())?;
|
||||
encryptor.encrypt(&mut RefReadBuffer::new(salt), &mut output, salt2.is_none())?;
|
||||
if let Some(salt2) = salt2 {
|
||||
encryptor
|
||||
.encrypt(&mut RefReadBuffer::new(&salt2), &mut output, true)
|
||||
.encrypt(&mut RefReadBuffer::new(salt2), &mut output, true)
|
||||
.map(|_| ())
|
||||
} else {
|
||||
Ok(())
|
||||
@ -124,8 +124,8 @@ impl HmacExtension for FidoDevice {
|
||||
fn get_hmac_assertion(
|
||||
&mut self,
|
||||
credential: &FidoHmacCredential,
|
||||
salt: [u8; 32],
|
||||
salt2: Option<[u8; 32]>,
|
||||
salt: &[u8; 32],
|
||||
salt2: Option<&[u8; 32]>,
|
||||
) -> FidoResult<([u8; 32], Option<[u8; 32]>)> {
|
||||
let client_data_hash = [0u8; 32];
|
||||
while self.shared_secret.is_none() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user