Get rid of heapless-bytes: use hopefully soon to be upstreamed heapless additions

This commit is contained in:
Nicolas Stalder
2020-05-22 01:51:09 +02:00
parent 3b4b1ffafd
commit c2216b5070
55 changed files with 289 additions and 294 deletions
+2 -1
View File
@@ -1,5 +1,6 @@
[target.thumbv8m.main-none-eabi]
runner = "gdb-multiarch -q -x jlink.gdb"
# runner = "gdb-multiarch -q -x jlink.gdb"
runner = "arm-none-eabi-gdb -q -x jlink.gdb"
rustflags = [
"-C", "link-arg=-Tlink.x",
]
+4 -4
View File
@@ -19,7 +19,7 @@ path = "src/app_rtfm.rs"
cortex-m-funnel = { version = "0.1.0-alpha.1" }
cortex-m-rtfm = "0.5.1"
cortex-m-semihosting = { version = "0.3.5", optional = true }
heapless = "0.5.5"
heapless = { version = "0.5.5", features = ["ufmt"] }
ufmt = "0.1.0"
usb-device = "0.2.3"
# usbd-ctaphid = { git = "https://github.com/nickray/usbd-ctaphid", branch = "main", features = ["logging"] }
@@ -98,14 +98,14 @@ ufmt = { git = "https://github.com/nickray/ufmt", branch = "nickray-derive-empty
ufmt-macros = { git = "https://github.com/nickray/ufmt", branch = "nickray-derive-empty-enums" }
# ufmt-macros = { git = "https://github.com/nickray/ufmt/macros", branch = "nickray-derive-empty-enums" }
# lpc55s6x-pac = { path = "../../lpc55-pacs" }
heapless = { git = "https://github.com/nickray/heapless", branch = "nickray-udebug" }
# heapless = { git = "https://github.com/nickray/heapless", branch = "nickray-udebug" }
heapless = { git = "https://github.com/nicolas-solokeys/heapless", branch = "bytebuf" }
cortex-m-semihosting = { git = "https://github.com/nickray/cortex-m-semihosting", branch = "no-semihosting" }
# micro-ecc-sys = { path = "../../micro-ecc-sys" }
[profile.release]
codegen-units = 1
lto = true
opt-level = "s"
# codegen-units = 1
incremental = false
debug = true
# lto = true
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -265,7 +265,7 @@ pub fn init_board(device_peripherals: hal::raw::Peripherals, core_peripherals: r
// to identify us as a smartcard.
// let usbd = UsbDeviceBuilder::new(usb_bus, UsbVidPid(0x072f, 0x90cc))
.manufacturer("SoloKeys")
.product("Solo 🐝")
.product("Solo Bee")
.serial_number("20/20")
.device_release(0x0123)
// #[cfg(feature = "highspeed")]
+1 -1
View File
@@ -12,7 +12,7 @@ cortex-m-semihosting = "0.3.5"
cosey = "0.1.0-alpha.0" # { git = "https://github.com/ycrypto/cosey", branch = "main" }
heapless = { version = "0.5.5", default-features = false, features = ["serde"] }
serde = { version = "1.0", default-features = false, features = ["derive"] }
serde-indexed = "0.0.3"
serde-indexed = "0.0.4"
serde_repr = "0.1"
ufmt = "0.1.0"
ufmt-macros = "0.1.0"
+7 -7
View File
@@ -42,7 +42,7 @@
}
*/
use crate::{consts, Bytes};
use crate::{consts, ByteBuf};
use serde::Serialize;
use serde_repr::{Deserialize_repr, Serialize_repr};
@@ -131,8 +131,8 @@ trait PublicKeyConstants {
#[derive(Clone, Debug, uDebug, Eq, PartialEq)]
pub struct P256PublicKey {
pub x: Bytes<consts::U32>,
pub y: Bytes<consts::U32>,
pub x: ByteBuf<consts::U32>,
pub y: ByteBuf<consts::U32>,
}
impl PublicKeyConstants for P256PublicKey {
@@ -143,8 +143,8 @@ impl PublicKeyConstants for P256PublicKey {
#[derive(Clone, Debug, uDebug, Eq, PartialEq)]
pub struct EcdhEsHkdf256PublicKey {
pub x: Bytes<consts::U32>,
pub y: Bytes<consts::U32>,
pub x: ByteBuf<consts::U32>,
pub y: ByteBuf<consts::U32>,
}
impl PublicKeyConstants for EcdhEsHkdf256PublicKey {
@@ -155,7 +155,7 @@ impl PublicKeyConstants for EcdhEsHkdf256PublicKey {
#[derive(Clone, Debug, uDebug, Eq, PartialEq)]
pub struct Ed25519PublicKey {
pub x: Bytes<consts::U32>,
pub x: ByteBuf<consts::U32>,
}
impl PublicKeyConstants for Ed25519PublicKey {
@@ -166,7 +166,7 @@ impl PublicKeyConstants for Ed25519PublicKey {
#[derive(Clone, Debug, uDebug, Eq, PartialEq)]
pub struct X25519PublicKey {
pub pub_key: Bytes<consts::U32>,
pub pub_key: ByteBuf<consts::U32>,
}
// impl serde::Serialize for PublicKey {
+12 -12
View File
@@ -5,7 +5,7 @@
use core::convert::TryInto;
// use cortex_m_semihosting::hprintln;
use crate::{Bytes, consts};
use crate::{ByteBuf, consts};
// pub struct WrongData;
pub const NO_ERROR: u16 = 0x9000;
@@ -64,8 +64,8 @@ pub type Result<T> = core::result::Result<T, Error>;
#[derive(Clone,Debug,uDebug,Eq,PartialEq)]
pub struct Register {
client_data_hash: Bytes<consts::U32>,
app_id_hash: Bytes<consts::U32>,
client_data_hash: ByteBuf<consts::U32>,
app_id_hash: ByteBuf<consts::U32>,
max_response: usize,
}
@@ -106,7 +106,7 @@ pub struct Register {
// }
// },
// user: PublicKeyCredentialUserEntity {
// id: Bytes::new(),
// id: ByteBuf::new(),
// icon: None, name: None, display_name: None,
// },
// pub_key_cred_params,
@@ -122,9 +122,9 @@ pub struct Register {
#[derive(Clone,Debug,uDebug,Eq,PartialEq)]
pub struct Authenticate {
control_byte: ControlByte,
client_data_hash: Bytes<consts::U32>,
app_id_hash: Bytes<consts::U32>,
key_handle: Bytes<consts::U255>,
client_data_hash: ByteBuf<consts::U32>,
app_id_hash: ByteBuf<consts::U32>,
key_handle: ByteBuf<consts::U255>,
max_response: usize,
}
@@ -228,8 +228,8 @@ impl core::convert::TryFrom<&[u8]> for Command {
return Err(Error::WrongData);
}
Ok(Command::Register(Register {
client_data_hash: Bytes::try_from_slice(&request[..32]).unwrap(),
app_id_hash: Bytes::try_from_slice(&request[32..]).unwrap(),
client_data_hash: ByteBuf::from_slice(&request[..32]).unwrap(),
app_id_hash: ByteBuf::from_slice(&request[32..]).unwrap(),
max_response,
}))
},
@@ -246,9 +246,9 @@ impl core::convert::TryFrom<&[u8]> for Command {
}
Ok(Command::Authenticate(Authenticate {
control_byte,
client_data_hash: Bytes::try_from_slice(&request[..32]).unwrap(),
app_id_hash: Bytes::try_from_slice(&request[32..]).unwrap(),
key_handle: Bytes::try_from_slice(&request[65..]).unwrap(),
client_data_hash: ByteBuf::from_slice(&request[..32]).unwrap(),
app_id_hash: ByteBuf::from_slice(&request[32..]).unwrap(),
key_handle: ByteBuf::from_slice(&request[65..]).unwrap(),
max_response,
}))
},
+12 -12
View File
@@ -1,7 +1,7 @@
use bitflags::bitflags;
use serde::{Deserialize, Serialize};
use crate::{Bytes, consts};
use crate::{ByteBuf, consts};
use crate::sizes::*;
pub mod client_pin;
@@ -45,14 +45,14 @@ pub struct AuthenticatorOptions {
// #[serde_indexed(offset = 1)]
// pub struct GetAssertionParameters {
// pub rp_id: String<consts::U64>,
// pub client_data_hash: Bytes<consts::U32>,
// pub client_data_hash: ByteBuf<consts::U32>,
// pub allow_list: Vec<PublicKeyCredentialDescriptor, consts::U8>,
// #[serde(skip_serializing_if = "Option::is_none")]
// pub extensions: Option<AuthenticatorExtensions>,
// #[serde(skip_serializing_if = "Option::is_none")]
// pub options: Option<AuthenticatorOptions>,
// #[serde(skip_serializing_if = "Option::is_none")]
// pub pin_auth: Option<Bytes<consts::U16>>,
// pub pin_auth: Option<ByteBuf<consts::U16>>,
// #[serde(skip_serializing_if = "Option::is_none")]
// pub pin_protocol: Option<u32>,
// }
@@ -82,21 +82,21 @@ pub struct AuthenticatorOptions {
//pub struct CredentialPublicKey {
//}
pub type PinAuth = Bytes<consts::U16>;
pub type PinAuth = ByteBuf<consts::U16>;
// #[derive(Clone,Debug,Eq,PartialEq)]
// // #[serde(rename_all = "camelCase")]
// pub struct AuthenticatorData {
// pub rp_id_hash: Bytes<consts::U32>,
// pub rp_id_hash: ByteBuf<consts::U32>,
// pub flags: u8,
// pub sign_count: u32,
// // this can get pretty long
// pub attested_credential_data: Option<Bytes<ATTESTED_CREDENTIAL_DATA_LENGTH>>,
// pub attested_credential_data: Option<ByteBuf<ATTESTED_CREDENTIAL_DATA_LENGTH>>,
// // pub extensions: ?
// }
// impl AuthenticatorData {
// pub fn serialize(&self) -> Bytes<AUTHENTICATOR_DATA_LENGTH> {
// pub fn serialize(&self) -> ByteBuf<AUTHENTICATOR_DATA_LENGTH> {
// let mut bytes = Vec::<u8, AUTHENTICATOR_DATA_LENGTH>::new();
// // 32 bytes, the RP id's hash
@@ -113,7 +113,7 @@ pub type PinAuth = Bytes<consts::U16>;
// None => {},
// }
// Bytes::from(bytes)
// ByteBuf::from(bytes)
// }
// }
@@ -127,22 +127,22 @@ bitflags! {
}
pub trait SerializeAttestedCredentialData {
fn serialize(&self) -> Bytes<ATTESTED_CREDENTIAL_DATA_LENGTH>;
fn serialize(&self) -> ByteBuf<ATTESTED_CREDENTIAL_DATA_LENGTH>;
}
#[derive(Clone,Debug,Eq,PartialEq)]
// #[serde(rename_all = "camelCase")]
pub struct AuthenticatorData<A, E> {
pub rp_id_hash: Bytes<consts::U32>,
pub rp_id_hash: ByteBuf<consts::U32>,
pub flags: AuthenticatorDataFlags,
pub sign_count: u32,
// this can get pretty long
// pub attested_credential_data: Option<Bytes<ATTESTED_CREDENTIAL_DATA_LENGTH>>,
// pub attested_credential_data: Option<ByteBuf<ATTESTED_CREDENTIAL_DATA_LENGTH>>,
pub attested_credential_data: Option<A>,
pub extensions: Option<E>
}
pub type SerializedAuthenticatorData = Bytes<AUTHENTICATOR_DATA_LENGTH>;
pub type SerializedAuthenticatorData = ByteBuf<AUTHENTICATOR_DATA_LENGTH>;
// The reason for this non-use of CBOR is for compatibility with
// FIDO U2F authentication signatures.
@@ -1,4 +1,4 @@
use crate::{Bytes, consts};
use crate::{ByteBuf, consts};
use serde_indexed::{DeserializeIndexed, SerializeIndexed};
use serde_repr::{Deserialize_repr, Serialize_repr};
@@ -40,18 +40,18 @@ pub struct Parameters {
// First 16 bytes of HMAC-SHA-256 of encrypted contents
// using `sharedSecret`.
#[serde(skip_serializing_if = "Option::is_none")]
pub pin_auth: Option<Bytes<consts::U16>>,
pub pin_auth: Option<ByteBuf<consts::U16>>,
// 0x05
// Encrypted new PIN using `sharedSecret`.
// (Encryption over UTF-8 representation of new PIN).
#[serde(skip_serializing_if = "Option::is_none")]
pub new_pin_enc: Option<Bytes<consts::U64>>,
pub new_pin_enc: Option<ByteBuf<consts::U64>>,
// 0x06
// Encrypted first 16 bytes of SHA-256 of PIN using `sharedSecret`.
#[serde(skip_serializing_if = "Option::is_none")]
pub pin_hash_enc: Option<Bytes<consts::U64>>,
pub pin_hash_enc: Option<ByteBuf<consts::U64>>,
}
@@ -64,7 +64,7 @@ pub struct Response {
// 0x02, encrypted `pinToken` using `sharedSecret`
#[serde(skip_serializing_if = "Option::is_none")]
pub pin_token: Option<Bytes<consts::U32>>,
pub pin_token: Option<ByteBuf<consts::U32>>,
// 0x03, number of PIN attempts remaining before lockout
#[serde(skip_serializing_if = "Option::is_none")]
@@ -1,4 +1,4 @@
use crate::{Bytes16, Bytes32};
use crate::{ByteBuf16, ByteBuf32};
use serde_indexed::{DeserializeIndexed, SerializeIndexed};
use serde_repr::{Deserialize_repr, Serialize_repr};
@@ -28,7 +28,7 @@ pub enum Subcommand {
pub struct SubcommandParameters {
// 0x01
#[serde(skip_serializing_if = "Option::is_none")]
pub rp_id_hash: Option<Bytes32>,
pub rp_id_hash: Option<ByteBuf32>,
// 0x02
#[serde(skip_serializing_if = "Option::is_none")]
pub credential_id: Option<PublicKeyCredentialDescriptor>,
@@ -47,7 +47,7 @@ pub struct Parameters {
pub pin_protocol: Option<u8>,
// 0x04
#[serde(skip_serializing_if = "Option::is_none")]
pub pin_auth: Option<Bytes16>,
pub pin_auth: Option<ByteBuf16>,
}
#[derive(Clone,Debug,uDebug,Default,Eq,PartialEq,SerializeIndexed)]
@@ -71,7 +71,7 @@ pub struct Response {
pub rp: Option<PublicKeyCredentialRpEntity>,
// 0x04
#[serde(skip_serializing_if = "Option::is_none")]
pub rp_id_hash: Option<Bytes32>,
pub rp_id_hash: Option<ByteBuf32>,
// 0x05
#[serde(skip_serializing_if = "Option::is_none")]
pub total_rps: Option<u32>,
@@ -87,7 +87,7 @@ pub struct Response {
// 0x08
#[serde(skip_serializing_if = "Option::is_none")]
pub public_key: Option<PublicKey>,
// pub public_key: Option<Bytes<COSE_KEY_LENGTH>>, // <-- AAAAHH. no Bytes, just COSE_Key
// pub public_key: Option<ByteBuf<COSE_KEY_LENGTH>>, // <-- AAAAHH. no ByteBuf, just COSE_Key
// 0x09
#[serde(skip_serializing_if = "Option::is_none")]
pub total_credentials: Option<u32>,
@@ -1,4 +1,4 @@
use crate::{Bytes, consts, String, Vec};
use crate::{ByteBuf, consts, String, Vec};
use serde::{Deserialize, Serialize};
use serde_indexed::{DeserializeIndexed, SerializeIndexed};
@@ -19,8 +19,8 @@ use crate::webauthn::*;
pub struct HmacSecretInput {
pub key_agreement: P256PublicKey,
// *either* enc(salt1) *or* enc(salt1 || salt2)
pub salt_enc: Bytes<consts::U64>,
pub salt_auth: Bytes<consts::U16>,
pub salt_enc: ByteBuf<consts::U64>,
pub salt_auth: ByteBuf<consts::U16>,
}
@@ -34,8 +34,8 @@ pub struct Extensions {
pub struct NoAttestedCredentialData (core::marker::PhantomData<()>);
impl super::SerializeAttestedCredentialData for NoAttestedCredentialData {
fn serialize(&self) -> Bytes<ATTESTED_CREDENTIAL_DATA_LENGTH> {
Bytes::new()
fn serialize(&self) -> ByteBuf<ATTESTED_CREDENTIAL_DATA_LENGTH> {
ByteBuf::new()
}
}
@@ -48,7 +48,7 @@ pub type AllowList = Vec<PublicKeyCredentialDescriptor, MAX_CREDENTIAL_COUNT_IN_
#[serde_indexed(offset = 1)]
pub struct Parameters {
pub rp_id: String<consts::U64>,
pub client_data_hash: Bytes<consts::U32>,
pub client_data_hash: ByteBuf<consts::U32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub allow_list: Option<AllowList>,
#[serde(skip_serializing_if = "Option::is_none")]
@@ -69,8 +69,8 @@ pub struct Parameters {
pub struct Response {
#[serde(skip_serializing_if = "Option::is_none")]
pub credential: Option<PublicKeyCredentialDescriptor>,
pub auth_data: Bytes<AUTHENTICATOR_DATA_LENGTH>,
pub signature: Bytes<ASN1_SIGNATURE_LENGTH>,
pub auth_data: ByteBuf<AUTHENTICATOR_DATA_LENGTH>,
pub signature: ByteBuf<ASN1_SIGNATURE_LENGTH>,
#[serde(skip_serializing_if = "Option::is_none")]
pub user: Option<PublicKeyCredentialUserEntity>,
#[serde(skip_serializing_if = "Option::is_none")]
+4 -4
View File
@@ -1,4 +1,4 @@
use crate::{Bytes, consts, String, Vec};
use crate::{ByteBuf, consts, String, Vec};
use serde::{Deserialize, Serialize};
use serde_indexed::{DeserializeIndexed, SerializeIndexed};
@@ -20,7 +20,7 @@ pub struct Response {
// #[serde(serialize_with = "serde_bytes::serialize", deserialize_with = "serde_bytes::deserialize")]
// #[serde(serialize_with = "serde_bytes::serialize")]
// pub(crate) aaguid: Vec<u8, consts::U16>,
pub aaguid: Bytes<consts::U16>,
pub aaguid: ByteBuf<consts::U16>,
// 0x04
#[serde(skip_serializing_if = "Option::is_none")]
@@ -49,7 +49,7 @@ pub struct Response {
// only in FIDO_2_1_PRE, see https://git.io/JeNxG
// can be: usb, nfc, ble, internal
#[serde(skip_serializing_if = "Option::is_none")]
pub transports: Option<Vec<Bytes<consts::U8>, consts::U4>>,
pub transports: Option<Vec<ByteBuf<consts::U8>, consts::U4>>,
// #[serde(skip_serializing_if = "Option::is_none")]
// pub(crate) algorithms: Option<&'l[u8]>,
@@ -59,7 +59,7 @@ impl Default for Response {
fn default() -> Self {
let mut zero_aaguid = Vec::<u8, consts::U16>::new();
zero_aaguid.resize_default(16).unwrap();
let aaguid = Bytes::<consts::U16>::from(zero_aaguid);
let aaguid = ByteBuf::<consts::U16>::from(zero_aaguid);
Self {
versions: Vec::new(),
@@ -1,4 +1,4 @@
use crate::{Bytes, consts, String, Vec};
use crate::{ByteBuf, consts, String, Vec};
use serde::{Deserialize, Serialize};
use serde_indexed::{DeserializeIndexed, SerializeIndexed};
@@ -90,7 +90,7 @@ pub struct Extensions {
// #[serde(rename_all = "camelCase")]
#[serde_indexed(offset = 1)]
pub struct Parameters {
pub client_data_hash: Bytes<consts::U32>,
pub client_data_hash: ByteBuf<consts::U32>,
pub rp: PublicKeyCredentialRpEntity,
pub user: PublicKeyCredentialUserEntity,
// e.g. webauthn.io sends 10
@@ -117,7 +117,7 @@ pub type AttestationObject = Response;
// #[derive(Clone,Debug,Eq,PartialEq,Serialize)]
// #[serde(into = "ResponseExplicitEnumOption")]
// pub struct Response {
// pub auth_data: Bytes<AUTHENTICATOR_DATA_LENGTH>,
// pub auth_data: ByteBuf<AUTHENTICATOR_DATA_LENGTH>,
// pub att_stmt: Option<AttestationStatement>,
// }
@@ -126,16 +126,16 @@ pub type AuthenticatorData = super::AuthenticatorData<AttestedCredentialData, Ex
// #[derive(Clone,Debug,Eq,PartialEq)]
// // #[serde(rename_all = "camelCase")]
// pub struct AuthenticatorData {
// pub rp_id_hash: Bytes<consts::U32>,
// pub rp_id_hash: ByteBuf<consts::U32>,
// pub flags: Flags,
// pub sign_count: u32,
// // this can get pretty long
// // pub attested_credential_data: Option<Bytes<ATTESTED_CREDENTIAL_DATA_LENGTH>>,
// // pub attested_credential_data: Option<ByteBuf<ATTESTED_CREDENTIAL_DATA_LENGTH>>,
// pub attested_credential_data: Option<AttestedCredentialData>,
// pub extensions: Option<Extensions>
// }
// pub type SerializedAuthenticatorData = Bytes<AUTHENTICATOR_DATA_LENGTH>;
// pub type SerializedAuthenticatorData = ByteBuf<AUTHENTICATOR_DATA_LENGTH>;
// // The reason for this non-use of CBOR is for compatibility with
// // FIDO U2F authentication signatures.
@@ -171,16 +171,16 @@ pub type AuthenticatorData = super::AuthenticatorData<AttestedCredentialData, Ex
// https://www.w3.org/TR/webauthn/#sec-attested-credential-data
#[derive(Clone,Debug,Eq,PartialEq)]
pub struct AttestedCredentialData {
pub aaguid: Bytes<consts::U16>,
pub aaguid: ByteBuf<consts::U16>,
// this is where "unlimited non-resident keys" get stored
// TODO: Model as actual credential ID, with ser/de to bytes (format is up to authenticator)
pub credential_id: Bytes<MAX_CREDENTIAL_ID_LENGTH>,
// pub credential_public_key: crate::cose::PublicKey,//Bytes<COSE_KEY_LENGTH>,
pub credential_public_key: Bytes<COSE_KEY_LENGTH>,
pub credential_id: ByteBuf<MAX_CREDENTIAL_ID_LENGTH>,
// pub credential_public_key: crate::cose::PublicKey,//ByteBuf<COSE_KEY_LENGTH>,
pub credential_public_key: ByteBuf<COSE_KEY_LENGTH>,
}
impl super::SerializeAttestedCredentialData for AttestedCredentialData {
fn serialize(&self) -> Bytes<ATTESTED_CREDENTIAL_DATA_LENGTH> {
fn serialize(&self) -> ByteBuf<ATTESTED_CREDENTIAL_DATA_LENGTH> {
let mut bytes = Vec::<u8, ATTESTED_CREDENTIAL_DATA_LENGTH>::new();
// 16 bytes, the aaguid
bytes.extend_from_slice(&self.aaguid).unwrap();
@@ -198,7 +198,7 @@ impl super::SerializeAttestedCredentialData for AttestedCredentialData {
// bytes.extend_from_slice(&cbor_key[..l]).unwrap();
bytes.extend_from_slice(&self.credential_public_key).unwrap();
Bytes::from(bytes)
ByteBuf::from(bytes)
}
}
@@ -207,7 +207,7 @@ impl super::SerializeAttestedCredentialData for AttestedCredentialData {
pub struct Response {
pub fmt: String<consts::U32>,
pub auth_data: super::SerializedAuthenticatorData,
// pub att_stmt: Bytes<consts::U64>,
// pub att_stmt: ByteBuf<consts::U64>,
pub att_stmt: AttestationStatement,
}
@@ -235,7 +235,7 @@ pub struct NoneAttestationStatement {}
#[derive(Clone,Debug,uDebug,Eq,PartialEq,Serialize)]
pub struct PackedAttestationStatement {
pub alg: i32,
pub sig: Bytes<ASN1_SIGNATURE_LENGTH>,
pub sig: ByteBuf<ASN1_SIGNATURE_LENGTH>,
#[serde(skip_serializing_if = "Option::is_none")]
pub x5c: Option<Vec<Bytes<consts::U1024>, consts::U1>>,
pub x5c: Option<Vec<ByteBuf<consts::U1024>, consts::U1>>,
}
+3 -1
View File
@@ -20,7 +20,9 @@ extern crate ufmt_macros;
pub use heapless::{consts, ArrayLength, String, Vec};
pub use heapless::spsc::{Consumer, Producer, Queue};
pub use heapless_bytes::{Bytes, Bytes16, Bytes32};
pub use heapless::ByteBuf;
pub type ByteBuf16 = ByteBuf<consts::U16>;
pub type ByteBuf32 = ByteBuf<consts::U32>;
pub mod authenticator;
pub mod cose;
+2 -2
View File
@@ -24,9 +24,9 @@ pub fn cbor_serialize<'a, 'b, T: serde::Serialize>(
}
pub fn cbor_serialize_bytes<'a, 'b, N: heapless_bytes::ArrayLength<u8>, T: serde::Serialize>(
pub fn cbor_serialize_bytes<'a, 'b, N: heapless::ArrayLength<u8>, T: serde::Serialize>(
object: &'a T,
bytes: &'b mut heapless_bytes::Bytes<N>,
bytes: &'b mut heapless::ByteBuf<N>,
) -> Result<usize> {
let len_before = bytes.len();
let mut ser = ser::Serializer::new(bytes);
+5 -5
View File
@@ -913,10 +913,10 @@ mod tests {
let mut buf = [0u8; 64];
let slice = b"thank you postcard!";
let bytes = heapless_bytes::Bytes::<U64>::try_from_slice(slice).unwrap();
let bytes = heapless::ByteBuf::<U64>::from_slice(slice).unwrap();
let ser = cbor_serialize(&bytes, &mut buf).unwrap();
println!("serialized bytes = {:?}", ser);
let de: heapless_bytes::Bytes::<U64> = from_bytes(&buf).unwrap();
let de: heapless::ByteBuf::<U64> = from_bytes(&buf).unwrap();
println!("deserialized bytes = {:?}", &de);
assert_eq!(&de, slice);
}
@@ -965,13 +965,13 @@ mod tests {
#[test]
fn de_credential_id() {
use heapless_bytes::{Bytes, consts::{U32, U64}};
use heapless::{ByteBuf, consts::{U32, U64}};
use serde_indexed::{DeserializeIndexed, SerializeIndexed};
#[derive(Clone,Debug,Eq,PartialEq,SerializeIndexed,DeserializeIndexed)]
pub struct CredentialInner {
pub user_id: Bytes<U64>,
pub user_id: ByteBuf<U64>,
pub alg: i8,
pub seed: Bytes<U32>,
pub seed: ByteBuf<U32>,
}
let input = b"\xa3\x00Gnickray\x01&\x02X @7\xbf\xa6\x98j\xb9\x0e8nB\x92\xd8\xf2\x1bK\xef\x92\xe87\xfe2`\x92%\xff\x98jR\xd1\xc8\xc1";
+1 -1
View File
@@ -127,7 +127,7 @@ impl serde::de::Error for Error {
// Particularly helpful would be better errors when receiving
// structures are undersized.
//
// E.g. if there is a `Bytes<N>` and more than N bytes are delivered,
// E.g. if there is a `ByteBuf<N>` and more than N bytes are delivered,
// currently the error _msg: T is:
//
// `invalid length 297, expected a sequence`
+2 -2
View File
@@ -55,9 +55,9 @@ impl<'a> Writer for SliceWriter<'a> {
}
}
impl<'a, N> Writer for &'a mut heapless_bytes::Bytes<N>
impl<'a, N> Writer for &'a mut heapless::ByteBuf<N>
where
N: heapless_bytes::ArrayLength<u8>,
N: heapless::ArrayLength<u8>,
{
type Error = Error;
+4 -4
View File
@@ -1,5 +1,5 @@
use serde::{Deserialize, Serialize};
use crate::{Bytes, consts, String};
use crate::{ByteBuf, consts, String};
use crate::sizes::*;
#[derive(Clone,Debug,uDebug,Eq,PartialEq,Serialize,Deserialize)]
@@ -14,7 +14,7 @@ pub struct PublicKeyCredentialRpEntity {
#[derive(Clone,Debug,uDebug,Eq,PartialEq,Serialize,Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PublicKeyCredentialUserEntity {
pub id: Bytes<consts::U64>,
pub id: ByteBuf<consts::U64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub icon: Option<String<consts::U64>>,
#[serde(skip_serializing_if = "Option::is_none")]
@@ -24,7 +24,7 @@ pub struct PublicKeyCredentialUserEntity {
}
impl PublicKeyCredentialUserEntity {
pub fn from(id: Bytes<consts::U64>) -> Self {
pub fn from(id: ByteBuf<consts::U64>) -> Self {
Self { id, icon: None, name: None, display_name: None }
}
}
@@ -41,7 +41,7 @@ pub struct PublicKeyCredentialParameters {
pub struct PublicKeyCredentialDescriptor {
// NB: if this is too small, get a nasty error
// See serde::error/custom for more info
pub id: Bytes<MAX_CREDENTIAL_ID_LENGTH>,
pub id: ByteBuf<MAX_CREDENTIAL_ID_LENGTH>,
#[serde(rename = "type")]
pub key_type: String<consts::U10>,
// https://w3c.github.io/webauthn/#enumdef-authenticatortransport

Some files were not shown because too many files have changed in this diff Show More