Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove cbor_serialize_message helper #106

Merged
merged 1 commit into from
Oct 25, 2024
Merged
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
6 changes: 3 additions & 3 deletions src/ctap2/pin.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down Expand Up @@ -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,
Expand Down
12 changes: 1 addition & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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,
Expand Down
Loading