@@ -5,17 +5,14 @@ use core::ops::Deref;
55
66use chacha20poly1305:: ChaCha8Poly1305 ;
77use hmac:: { Hmac , Mac } ;
8- use littlefs2_core:: path;
8+ use littlefs2_core:: { path, Path } ;
9+ use rand_core:: { CryptoRng , RngCore } ;
910use serde:: { Deserialize , Serialize } ;
1011use serde_byte_array:: ByteArray ;
1112use sha2:: { Digest as _, Sha256 } ;
1213use subtle:: ConstantTimeEq as _;
13- use trussed:: {
14- platform:: { CryptoRng , RngCore } ,
15- store:: filestore:: Filestore ,
16- types:: { Location , Path } ,
17- Bytes ,
18- } ;
14+ use trussed:: store:: Filestore ;
15+ use trussed_core:: types:: { Bytes , Location } ;
1916
2017use super :: Error ;
2118use trussed_auth:: { Pin , PinId , MAX_PIN_LENGTH } ;
@@ -223,14 +220,14 @@ impl PinData {
223220 . read :: < SIZE > ( & path, location)
224221 . map_err ( |_| Error :: ReadFailed ) ?;
225222 let mut data: Self =
226- trussed :: cbor_deserialize ( & data) . map_err ( |_| Error :: DeserializationFailed ) ?;
223+ cbor_smol :: cbor_deserialize ( & data) . map_err ( |_| Error :: DeserializationFailed ) ?;
227224 data. id = id;
228225 Ok ( data)
229226 }
230227
231228 pub fn save < S : Filestore > ( & self , fs : & mut S , location : Location ) -> Result < ( ) , Error > {
232- let data = trussed :: cbor_serialize_bytes :: < _ , SIZE > ( self )
233- . map_err ( |_| Error :: SerializationFailed ) ?;
229+ let mut data: Bytes < SIZE > = Bytes :: new ( ) ;
230+ cbor_smol :: cbor_serialize_to ( self , & mut data ) . map_err ( |_| Error :: SerializationFailed ) ?;
234231 fs. write ( & self . id . path ( ) , location, & data)
235232 . map_err ( |_| Error :: WriteFailed )
236233 }
@@ -520,7 +517,7 @@ pub(crate) fn get_app_salt<S: Filestore, R: CryptoRng + RngCore>(
520517pub ( crate ) fn delete_app_salt < S : Filestore > (
521518 fs : & mut S ,
522519 location : Location ,
523- ) -> Result < ( ) , trussed :: Error > {
520+ ) -> Result < ( ) , trussed_core :: Error > {
524521 if fs. exists ( APP_SALT_PATH , location) {
525522 fs. remove_file ( APP_SALT_PATH , location)
526523 } else {
@@ -573,7 +570,8 @@ mod tests {
573570 salt : [ u8:: MAX ; SALT_LEN ] . into ( ) ,
574571 data : KeyOrHash :: Hash ( [ u8:: MAX ; HASH_LEN ] . into ( ) ) ,
575572 } ;
576- let serialized = trussed:: cbor_serialize_bytes :: < _ , 1024 > ( & data) . unwrap ( ) ;
573+ let mut serialized: Bytes < 1024 > = Bytes :: new ( ) ;
574+ cbor_smol:: cbor_serialize_to ( & data, & mut serialized) . unwrap ( ) ;
577575 assert ! ( serialized. len( ) <= SIZE ) ;
578576 }
579577
@@ -582,7 +580,8 @@ mod tests {
582580 fn test_salt_size ( ) {
583581 // We allow one byte overhead for byte array serialization
584582 let salt = Salt :: from ( [ u8:: MAX ; SALT_LEN ] ) ;
585- let serialized = trussed:: cbor_serialize_bytes :: < _ , 1024 > ( & salt) . unwrap ( ) ;
583+ let mut serialized: Bytes < 1024 > = Bytes :: new ( ) ;
584+ cbor_smol:: cbor_serialize_to ( & salt, & mut serialized) . unwrap ( ) ;
586585 assert ! ( serialized. len( ) <= SALT_LEN + 1 , "{}" , serialized. len( ) ) ;
587586 }
588587
0 commit comments