Skip to content

Commit e23541e

Browse files
client_pin: Add permissions
1 parent f0db7ac commit e23541e

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
- Allow missing algorithms in COSE keys ([#8][])
1818
- Remove unused `REALISTIC_MAX_MESSAGE_SIZE` constant
1919
- Handle overlong `icon` values in `PublicKeyCredentialUserEntity` ([#27][])
20+
- Add support for permissions in `ctap2::client_pin`
2021

2122
[#8]: https://github.com/trussed-dev/ctap-types/pull/8
2223
[#9]: https://github.com/solokeys/ctap-types/issues/9

src/ctap2/client_pin.rs

+41-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
use crate::Bytes;
1+
use crate::{Bytes, String};
2+
use bitflags::bitflags;
23
use serde_indexed::{DeserializeIndexed, SerializeIndexed};
34
use serde_repr::{Deserialize_repr, Serialize_repr};
45

@@ -17,6 +18,18 @@ pub enum PinV1Subcommand {
1718
GetPinUvAuthTokenUsingPinWithPermissions = 0x09,
1819
}
1920

21+
bitflags! {
22+
#[derive(Default)]
23+
pub struct Permissions: u8 {
24+
const MAKE_CREDENTIAL = 0x01;
25+
const GET_ASSERTION = 0x02;
26+
const CREDENTIAL_MANAGEMENT = 0x04;
27+
const BIO_ENROLLMENT = 0x08;
28+
const LARGE_BLOB_WRITE = 0x10;
29+
const AUTHENTICATOR_CONFIGURATION = 0x20;
30+
}
31+
}
32+
2033
// minimum PIN length: 4 unicode
2134
// maximum PIN length: UTF-8 represented by <= 63 bytes
2235
// maximum consecutive incorrect PIN attempts: 8
@@ -55,9 +68,27 @@ pub struct Request {
5568
// Encrypted first 16 bytes of SHA-256 of PIN using `sharedSecret`.
5669
#[serde(skip_serializing_if = "Option::is_none")]
5770
pub pin_hash_enc: Option<Bytes<64>>,
71+
72+
// 0x07
73+
#[serde(skip_serializing_if = "Option::is_none")]
74+
_placeholder07: Option<()>,
75+
76+
// 0x08
77+
#[serde(skip_serializing_if = "Option::is_none")]
78+
_placeholder08: Option<()>,
79+
80+
// 0x09
81+
// Bitfield of permissions
82+
#[serde(skip_serializing_if = "Option::is_none")]
83+
pub permissions: Option<u8>,
84+
85+
// 0x0A
86+
// The RP ID to assign as the permissions RP ID
87+
#[serde(skip_serializing_if = "Option::is_none")]
88+
pub rp_id: Option<String<256>>,
5889
}
5990

60-
#[derive(Clone, Debug, Eq, PartialEq, SerializeIndexed, DeserializeIndexed)]
91+
#[derive(Clone, Debug, Default, Eq, PartialEq, SerializeIndexed, DeserializeIndexed)]
6192
#[serde_indexed(offset = 1)]
6293
pub struct Response {
6394
// 0x01, like ClientPinParameters::key_agreement
@@ -71,6 +102,14 @@ pub struct Response {
71102
// 0x03, number of PIN attempts remaining before lockout
72103
#[serde(skip_serializing_if = "Option::is_none")]
73104
pub retries: Option<u8>,
105+
106+
// 0x04, whether a power cycle is required before any future PIN operation
107+
#[serde(skip_serializing_if = "Option::is_none")]
108+
pub power_cycle_state: Option<bool>,
109+
110+
// 0x05, number of uv attempts remaining before lockout
111+
#[serde(skip_serializing_if = "Option::is_none")]
112+
pub uv_retries: Option<u8>,
74113
}
75114

76115
#[cfg(test)]

0 commit comments

Comments
 (0)