Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

[Unreleased]: https://github.com/trussed-dev/ctap-types/compare/0.3.2...HEAD
[Unreleased]: https://github.com/trussed-dev/ctap-types/compare/0.4.0...HEAD

-

## [0.4.0] 2025-05-09

[0.4.0]: https://github.com/trussed-dev/ctap-types/compare/0.3.2...0.4.0

- Make `pin_protocol` optional in `ctap2::client_pin::Request` for compliance with CTAP 2.1.

## [0.3.2] 2024-10-24

[0.3.2]: https://github.com/trussed-dev/ctap-types/compare/0.3.1...0.3.2
Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ctap-types"
version = "0.3.2"
version = "0.4.0"
authors = ["Nicolas Stalder <n@stalder.io>", "The Trussed developers"]
edition = "2021"
license = "Apache-2.0 OR MIT"
Expand Down Expand Up @@ -38,6 +38,7 @@ third-party-payment = []

log-all = []
log-none = []
log-trace = []
log-info = []
log-debug = []
log-warn = []
Expand Down
4 changes: 2 additions & 2 deletions src/ctap1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,15 @@ impl Response {

impl<'a, const S: usize> TryFrom<&'a iso7816::Command<S>> for Request<'a> {
type Error = Error;
fn try_from(apdu: &'a iso7816::Command<S>) -> Result<Request> {
fn try_from(apdu: &'a iso7816::Command<S>) -> Result<Request<'a>> {
apdu.as_view().try_into()
}
}

impl<'a> TryFrom<iso7816::command::CommandView<'a>> for Request<'a> {
type Error = Error;
#[inline(never)]
fn try_from(apdu: iso7816::command::CommandView<'a>) -> Result<Request> {
fn try_from(apdu: iso7816::command::CommandView<'a>) -> Result<Request<'a>> {
let cla = apdu.class().into_inner();
let ins = match apdu.instruction() {
iso7816::Instruction::Unknown(ins) => ins,
Expand Down
4 changes: 2 additions & 2 deletions src/ctap2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ pub type SerializedAuthenticatorData = Bytes<AUTHENTICATOR_DATA_LENGTH>;

// The reason for this non-use of CBOR is for compatibility with
// FIDO U2F authentication signatures.
impl<'a, A: SerializeAttestedCredentialData, E: serde::Serialize> AuthenticatorData<'a, A, E> {
impl<A: SerializeAttestedCredentialData, E: serde::Serialize> AuthenticatorData<'_, A, E> {
#[inline(never)]
pub fn serialize(&self) -> Result<SerializedAuthenticatorData> {
let mut bytes = SerializedAuthenticatorData::new();
Expand Down Expand Up @@ -544,7 +544,7 @@ pub trait Authenticator {
}
}

impl<'a, A: Authenticator> crate::Rpc<Error, Request<'a>, Response> for A {
impl<A: Authenticator> crate::Rpc<Error, Request<'_>, Response> for A {
/// Dispatches the enum of possible requests into the appropriate trait method.
#[inline(never)]
fn call(&mut self, request: &Request) -> Result<Response> {
Expand Down
22 changes: 11 additions & 11 deletions src/ctap2/client_pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ bitflags! {
pub struct Request<'a> {
// 0x01
// PIN protocol version chosen by the client.
// For this version of the spec, this SHALL be the number 1.
pub pin_protocol: u8,
#[serde(skip_serializing_if = "Option::is_none")]
pub pin_protocol: Option<u8>,

// 0x02
// The authenticator Client PIN sub command currently being requested
Expand Down Expand Up @@ -119,7 +119,7 @@ pub struct Response {
mod tests {
use super::*;
use hex_literal::hex;
use serde_test::{assert_de_tokens, assert_ser_tokens, assert_tokens, Token};
use serde_test::{assert_de_tokens, assert_ser_tokens, Token};

const KEY_AGREEMENT: &[u8] = &hex!("b174bc49c7ca254b70d2e5c207cee9cf174820ebd77ea3c65508c26da51b657c1cc6b952f8621697936482da0a6d3d3826a59095daf6cd7c03e2e60385d2f6d9");
const NEW_PIN_ENC: &[u8] = &[0xde; 64];
Expand All @@ -130,7 +130,7 @@ mod tests {
#[test]
fn test_de_request_get_retries() {
let request = Request {
pin_protocol: 1,
pin_protocol: Some(1),
sub_command: PinV1Subcommand::GetRetries,
key_agreement: None,
pin_auth: None,
Expand All @@ -141,7 +141,7 @@ mod tests {
permissions: None,
rp_id: None,
};
assert_tokens(
assert_de_tokens(
&request,
&[
Token::Map { len: Some(2) },
Expand All @@ -159,7 +159,7 @@ mod tests {
#[test]
fn test_de_request_get_key_agreement() {
let request = Request {
pin_protocol: 1,
pin_protocol: Some(1),
sub_command: PinV1Subcommand::GetKeyAgreement,
key_agreement: None,
pin_auth: None,
Expand All @@ -170,7 +170,7 @@ mod tests {
permissions: None,
rp_id: None,
};
assert_tokens(
assert_de_tokens(
&request,
&[
Token::Map { len: Some(2) },
Expand All @@ -192,7 +192,7 @@ mod tests {
y: Bytes::from_slice(&KEY_AGREEMENT[32..]).unwrap(),
};
let request = Request {
pin_protocol: 1,
pin_protocol: Some(1),
sub_command: PinV1Subcommand::SetPin,
key_agreement: Some(key_agreement),
pin_auth: Some(serde_bytes::Bytes::new(PIN_AUTH)),
Expand Down Expand Up @@ -250,7 +250,7 @@ mod tests {
y: Bytes::from_slice(&KEY_AGREEMENT[32..]).unwrap(),
};
let request = Request {
pin_protocol: 1,
pin_protocol: Some(1),
sub_command: PinV1Subcommand::ChangePin,
key_agreement: Some(key_agreement),
pin_auth: Some(serde_bytes::Bytes::new(PIN_AUTH)),
Expand Down Expand Up @@ -311,7 +311,7 @@ mod tests {
y: Bytes::from_slice(&KEY_AGREEMENT[32..]).unwrap(),
};
let request = Request {
pin_protocol: 1,
pin_protocol: Some(1),
sub_command: PinV1Subcommand::GetPinToken,
key_agreement: Some(key_agreement),
pin_auth: None,
Expand Down Expand Up @@ -366,7 +366,7 @@ mod tests {
y: Bytes::from_slice(&KEY_AGREEMENT[32..]).unwrap(),
};
let request = Request {
pin_protocol: 1,
pin_protocol: Some(1),
sub_command: PinV1Subcommand::GetPinUvAuthTokenUsingPinWithPermissions,
key_agreement: Some(key_agreement),
pin_auth: None,
Expand Down
2 changes: 1 addition & 1 deletion src/ctap2/make_credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub struct AttestedCredentialData<'a> {
pub credential_public_key: &'a [u8],
}

impl<'a> super::SerializeAttestedCredentialData for AttestedCredentialData<'a> {
impl super::SerializeAttestedCredentialData for AttestedCredentialData<'_> {
fn serialize(&self, buffer: &mut super::SerializedAuthenticatorData) -> Result<(), Error> {
// TODO: validate lengths of credential ID and credential public key
// 16 bytes, the aaguid
Expand Down
Loading