Remove cbor_serialize_message helper

The cbor_serialize_message helper mixed re-exports of cbor-smol from
trussed and ctap-types.  This can be problematic if both select
different versions.  It could be fixed by keeping both in sync, but to
avoid this problem entirely, we can also just use cbor_serialize_bytes
from Trussed directly.
This commit is contained in:
Robin Krahl
2024-10-25 13:50:57 +02:00
parent 5b6ae97b5f
commit c145a451ef
3 changed files with 6 additions and 16 deletions
+3 -3
View File
@@ -1,8 +1,8 @@
use crate::{cbor_serialize_message, TrussedRequirements};
use crate::TrussedRequirements;
use cosey::EcdhEsHkdf256PublicKey;
use ctap_types::{ctap2::client_pin::Permissions, Error, Result};
use trussed::{
cbor_deserialize,
cbor_deserialize, cbor_serialize_bytes,
client::{CryptoClient, HmacSha256, P256},
syscall, try_syscall,
types::{
@@ -312,7 +312,7 @@ impl<'a, T: TrussedRequirements> PinProtocol<'a, T> {
}
fn shared_secret_impl(&mut self, peer_key: &EcdhEsHkdf256PublicKey) -> Option<SharedSecret> {
let serialized_peer_key = cbor_serialize_message(peer_key).ok()?;
let serialized_peer_key: Message = cbor_serialize_bytes(peer_key).ok()?;
let peer_key = try_syscall!(self.trussed.deserialize_p256_key(
&serialized_peer_key,
KeySerialization::EcdhEsHkdf256,
+1 -11
View File
@@ -20,11 +20,7 @@ generate_macros!();
use core::time::Duration;
use trussed::{
client, syscall,
types::{Location, Message},
Client as TrussedClient,
};
use trussed::{client, syscall, types::Location, Client as TrussedClient};
use trussed_fs_info::{FsInfoClient, FsInfoReply};
use trussed_hkdf::HkdfClient;
@@ -252,12 +248,6 @@ impl UserPresence for Conforming {
}
}
fn cbor_serialize_message<T: serde::Serialize>(
object: &T,
) -> core::result::Result<Message, ctap_types::serde::Error> {
trussed::cbor_serialize_bytes(object)
}
impl<UP, T> Authenticator<UP, T>
where
UP: UserPresence,
+2 -2
View File
@@ -11,7 +11,7 @@ use ctap_types::{
};
use littlefs2_core::path;
use trussed::{
client, syscall, try_syscall,
cbor_serialize_bytes, client, syscall, try_syscall,
types::{KeyId, Location, Mechanism, Path, PathBuf},
Client as TrussedClient,
};
@@ -299,7 +299,7 @@ impl PersistentState {
}
pub fn save<T: TrussedClient>(&self, trussed: &mut T) -> Result<()> {
let data = crate::cbor_serialize_message(self).unwrap();
let data = cbor_serialize_bytes(self).unwrap();
syscall!(trussed.write_file(
Location::Internal,