Skip to content

Commit 79e4b28

Browse files
Add Hybrid variant to Ctap2Transport enum (#108)
* Fixes casing of CTAP1 and CTAP2 transport enums, as per Rust's official naming conventions. Note this applies even to acronyms - examples are IpAddr, TcpStream, Utf8Error from std. * Adds Hybrid transport variant.
1 parent 97ba35b commit 79e4b28

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

libwebauthn/src/proto/ctap1/model.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,21 @@ use crate::webauthn::CtapError;
1212

1313
#[derive(Debug, Clone, Copy)]
1414
pub enum Ctap1Transport {
15-
BT,
16-
BLE,
17-
NFC,
18-
USB,
15+
Bt,
16+
Ble,
17+
Nfc,
18+
Usb,
1919
}
2020

2121
impl TryFrom<&Ctap2Transport> for Ctap1Transport {
2222
type Error = CtapError;
2323
fn try_from(ctap2: &Ctap2Transport) -> Result<Ctap1Transport, Self::Error> {
2424
match ctap2 {
25-
Ctap2Transport::BLE => Ok(Ctap1Transport::BLE),
26-
Ctap2Transport::USB => Ok(Ctap1Transport::USB),
27-
Ctap2Transport::NFC => Ok(Ctap1Transport::NFC),
28-
Ctap2Transport::INTERNAL => Err(CtapError::UnsupportedOption),
25+
Ctap2Transport::Ble => Ok(Ctap1Transport::Ble),
26+
Ctap2Transport::Usb => Ok(Ctap1Transport::Usb),
27+
Ctap2Transport::Nfc => Ok(Ctap1Transport::Nfc),
28+
Ctap2Transport::Internal => Err(CtapError::UnsupportedOption),
29+
Ctap2Transport::Hybrid => Err(CtapError::UnsupportedOption),
2930
}
3031
}
3132
}

libwebauthn/src/proto/ctap2/model.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -121,19 +121,20 @@ pub enum Ctap2PublicKeyCredentialType {
121121
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
122122
#[serde(rename_all = "lowercase")]
123123
pub enum Ctap2Transport {
124-
BLE,
125-
NFC,
126-
USB,
127-
INTERNAL,
124+
Ble,
125+
Nfc,
126+
Usb,
127+
Internal,
128+
Hybrid,
128129
}
129130

130131
impl From<&Ctap1Transport> for Ctap2Transport {
131132
fn from(ctap1: &Ctap1Transport) -> Ctap2Transport {
132133
match ctap1 {
133-
Ctap1Transport::BT => Ctap2Transport::BLE,
134-
Ctap1Transport::BLE => Ctap2Transport::BLE,
135-
Ctap1Transport::USB => Ctap2Transport::USB,
136-
Ctap1Transport::NFC => Ctap2Transport::NFC,
134+
Ctap1Transport::Bt => Ctap2Transport::Ble,
135+
Ctap1Transport::Ble => Ctap2Transport::Ble,
136+
Ctap1Transport::Usb => Ctap2Transport::Usb,
137+
Ctap1Transport::Nfc => Ctap2Transport::Nfc,
137138
}
138139
}
139140
}
@@ -211,13 +212,13 @@ pub enum Ctap2UserVerificationOperation {
211212
mod tests {
212213
use crate::proto::ctap2::Ctap2PublicKeyCredentialDescriptor;
213214

214-
use super::{Ctap2CredentialType, Ctap2COSEAlgorithmIdentifier, Ctap2PublicKeyCredentialType};
215+
use super::{Ctap2COSEAlgorithmIdentifier, Ctap2CredentialType, Ctap2PublicKeyCredentialType};
216+
use hex;
215217
use serde_bytes::ByteBuf;
216218
use serde_cbor;
217-
use hex;
218219

219220
#[test]
220-
/// Verify CBOR serialization conforms to CTAP canonical standard, including ordering (see #95)
221+
/// Verify CBOR serialization conforms to CTAP canonical standard, including ordering (see #95)
221222
pub fn credential_type_field_serialization() {
222223
let credential_type = Ctap2CredentialType {
223224
algorithm: Ctap2COSEAlgorithmIdentifier::ES256,
@@ -230,7 +231,7 @@ mod tests {
230231
}
231232

232233
#[test]
233-
/// Verify CBOR serialization conforms to CTAP canonical standard, including ordering (see #95)
234+
/// Verify CBOR serialization conforms to CTAP canonical standard, including ordering (see #95)
234235
pub fn credential_descriptor_serialization() {
235236
let credential_descriptor = Ctap2PublicKeyCredentialDescriptor {
236237
id: ByteBuf::from(vec![0x42]),
@@ -242,4 +243,4 @@ mod tests {
242243
let expected = hex::decode("a2626964414264747970656a7075626c69632d6b6579").unwrap();
243244
assert_eq!(serialized, expected);
244245
}
245-
}
246+
}

0 commit comments

Comments
 (0)