Skip to content

Commit

Permalink
fixup! Implement largeBlobs command
Browse files Browse the repository at this point in the history
  • Loading branch information
robin-nitrokey committed Nov 21, 2023
1 parent 38d4caa commit 681d730
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/ctap2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1894,22 +1894,22 @@ impl<UP: UserPresence, T: TrussedRequirements> crate::Authenticator<UP, T> {
.try_into()
.map_err(|_| Error::PinAuthInvalid)?;

let mut data: Bytes<70> = Bytes::new();
let mut auth_data: Bytes<70> = Bytes::new();
// 32x 0xff
data.resize(32, 0xff).unwrap();
auth_data.resize(32, 0xff).unwrap();
// h'0c00'
data.push(0x0c).unwrap();
data.push(0x00).unwrap();
auth_data.push(0x0c).unwrap();
auth_data.push(0x00).unwrap();
// uint32LittleEndian(offset)
data.extend_from_slice(&request.offset.to_le_bytes())
auth_data.extend_from_slice(&request.offset.to_le_bytes())
.unwrap();
// SHA-256(data)
let mut hash_input = Message::new();
hash_input.extend_from_slice(&data).unwrap();
let hash = syscall!(self.trussed.hash(Mechanism::Sha256, hash_input)).hash;
data.extend_from_slice(&hash).unwrap();
auth_data.extend_from_slice(&hash).unwrap();

self.verify_pin(&pin_auth, &data)?;
self.verify_pin(&pin_auth, &auth_data)?;
}

// 6. Validate data length
Expand Down

0 comments on commit 681d730

Please sign in to comment.