From 10bdfc15474e6f5456f956df18998844049d218e Mon Sep 17 00:00:00 2001 From: Nick Zana Date: Wed, 14 Jun 2023 14:46:52 -0400 Subject: [PATCH] ctap2-proto: Add authenticator::client_pin::raw::RawSubcommand This type is used for serialization and deserialization of subcommands as raw u8s. --- .../src/authenticator/client_pin/raw/mod.rs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/crates/ctap2-proto/src/authenticator/client_pin/raw/mod.rs b/crates/ctap2-proto/src/authenticator/client_pin/raw/mod.rs index 587d7ea..50848e1 100644 --- a/crates/ctap2-proto/src/authenticator/client_pin/raw/mod.rs +++ b/crates/ctap2-proto/src/authenticator/client_pin/raw/mod.rs @@ -2,5 +2,25 @@ //! possible in CBOR format while maintaining ergonomic enum variants for public //! API. +use serde::{Deserialize, Serialize}; mod public_key; +#[derive(Clone, Serialize, Deserialize)] +#[serde(into = "u8")] +pub(crate) enum RawSubcommand { + GetPinRetries = 0x01, + GetKeyAgreement = 0x02, + SetPin = 0x03, + ChangePin = 0x04, + GetPinToken = 0x05, + GetPinUvAuthTokenUsingUvWithPermissions = 0x06, + GetUvRetries = 0x07, + GetPinUvAuthTokenUsingPinWithPermissions = 0x09, +} + +impl From for u8 { + fn from(value: RawSubcommand) -> Self { + value as u8 + } +} +