Skip to content
Open
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
134 changes: 102 additions & 32 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions libwebauthn/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ hidapi = { version = "2.4.1", default-features = false, features = [
bitflags = "2.4.1"
rand = "0.8.5"
p256 = { version = "0.13.2", features = ["ecdh", "arithmetic", "serde"] }
heapless = "0.7"
cosey = "0.3.2"
cosey = "0.4.0"
spki = { version = "0.7", default-features = false, features = ["alloc"] }
der = { version = "0.7", default-features = false, features = ["alloc", "derive", "oid"] }
aes = "0.8.2"
Expand All @@ -100,7 +99,7 @@ tokio-tungstenite = { version = "0.26", features = [
rustls = { version = "0.23.27", default-features = false, features = ["ring"] }
tokio-stream = "0.1"
snow = { version = "0.10", features = ["use-p256"] }
ctap-types = { version = "0.4.0" }
ctap-types = { version = "0.5.0" }
btleplug = "0.11.7"
bluer = { version = "0.17", default-features = false, features = ["l2cap"] }
thiserror = "2.0.12"
Expand Down
27 changes: 11 additions & 16 deletions libwebauthn/src/ops/u2f.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,17 @@ impl UpgradableResponse<MakeCredentialResponse, MakeCredentialRequest> for Regis
"public key is identity or compressed".into(),
))
})?;
let x: heapless::Vec<u8, 32> =
heapless::Vec::from_slice(x_bytes.as_bytes()).map_err(|_| {
WebAuthnError::Platform(PlatformError::CryptoError(
"x coordinate exceeds 32 bytes".into(),
))
})?;
let y: heapless::Vec<u8, 32> =
heapless::Vec::from_slice(y_bytes.as_bytes()).map_err(|_| {
WebAuthnError::Platform(PlatformError::CryptoError(
"y coordinate exceeds 32 bytes".into(),
))
})?;
let cose_public_key = cose::PublicKey::P256Key(cose::P256PublicKey {
x: x.into(),
y: y.into(),
});
let x = cose::Bytes::<32>::try_from(x_bytes.as_bytes()).map_err(|_| {
WebAuthnError::Platform(PlatformError::CryptoError(
"x coordinate exceeds 32 bytes".into(),
))
})?;
let y = cose::Bytes::<32>::try_from(y_bytes.as_bytes()).map_err(|_| {
WebAuthnError::Platform(PlatformError::CryptoError(
"y coordinate exceeds 32 bytes".into(),
))
})?;
let cose_public_key = cose::PublicKey::P256Key(cose::P256PublicKey { x, y });
let cose_encoded_public_key = cbor::to_vec(&cose_public_key)?;
// Canonical CBOR encoding of the COSE P-256 key is 77 bytes for the
// fields we set; return a typed error if a future encoder change
Expand Down
8 changes: 4 additions & 4 deletions libwebauthn/src/ops/webauthn/make_credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1787,8 +1787,8 @@ mod tests {
// Minimal COSE_Key for a P-256 ES256 credential, used as opaque
// bytes by the test harness.
let cose_public_key = cosey::PublicKey::P256Key(cosey::P256PublicKey {
x: Bytes::from_slice(&[0u8; 32]).unwrap(),
y: Bytes::from_slice(&[0u8; 32]).unwrap(),
x: Bytes::from(&[0u8; 32]),
y: Bytes::from(&[0u8; 32]),
});
let credential_public_key = cbor::to_vec(&cose_public_key).unwrap();

Expand Down Expand Up @@ -2095,8 +2095,8 @@ mod tests {
use serde_bytes::ByteBuf;

let cose_public_key = cosey::PublicKey::P256Key(cosey::P256PublicKey {
x: Bytes::from_slice(&[0u8; 32]).unwrap(),
y: Bytes::from_slice(&[0u8; 32]).unwrap(),
x: Bytes::from(&[0u8; 32]),
y: Bytes::from(&[0u8; 32]),
});
let credential_public_key = cbor::to_vec(&cose_public_key).unwrap();

Expand Down
Loading
Loading