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

Fix Trussed imports #78

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
14 changes: 7 additions & 7 deletions src/credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub enum CtapVersion {
pub struct CredentialId(pub Bytes<MAX_CREDENTIAL_ID_LENGTH>);

impl CredentialId {
fn new<T: client::Chacha8Poly1305 + client::Sha256, C: Serialize>(
fn new<T: client::mechanisms::Chacha8Poly1305 + client::mechanisms::Sha256, C: Serialize>(
trussed: &mut T,
credential: &C,
key_encryption_key: KeyId,
Expand Down Expand Up @@ -115,15 +115,15 @@ pub enum Credential {
}

impl Credential {
pub fn try_from<UP: UserPresence, T: client::Client + client::Chacha8Poly1305>(
pub fn try_from<UP: UserPresence, T: client::Client + client::mechanisms::Chacha8Poly1305>(
authnr: &mut Authenticator<UP, T>,
rp_id_hash: &Bytes<32>,
descriptor: &PublicKeyCredentialDescriptorRef,
) -> Result<Self> {
Self::try_from_bytes(authnr, rp_id_hash, descriptor.id)
}

pub fn try_from_bytes<UP: UserPresence, T: client::Client + client::Chacha8Poly1305>(
pub fn try_from_bytes<UP: UserPresence, T: client::Client + client::mechanisms::Chacha8Poly1305>(
authnr: &mut Authenticator<UP, T>,
rp_id_hash: &Bytes<32>,
id: &[u8],
Expand Down Expand Up @@ -158,7 +158,7 @@ impl Credential {
.map_err(|_| Error::InvalidCredential)
}

pub fn id<T: client::Chacha8Poly1305 + client::Sha256>(
pub fn id<T: client::mechanisms::Chacha8Poly1305 + client::mechanisms::Sha256>(
&self,
trussed: &mut T,
key_encryption_key: KeyId,
Expand Down Expand Up @@ -371,7 +371,7 @@ impl FullCredential {
// the ID will stay below 255 bytes.
//
// Existing keyhandles can still be decoded
pub fn id<T: client::Chacha8Poly1305 + client::Sha256>(
pub fn id<T: client::mechanisms::Chacha8Poly1305 + client::mechanisms::Sha256>(
&self,
trussed: &mut T,
key_encryption_key: KeyId,
Expand Down Expand Up @@ -468,7 +468,7 @@ impl StrippedCredential {
}
}

pub fn id<T: client::Chacha8Poly1305 + client::Sha256>(
pub fn id<T: client::mechanisms::Chacha8Poly1305 + client::mechanisms::Sha256>(
&self,
trussed: &mut T,
key_encryption_key: KeyId,
Expand Down Expand Up @@ -499,7 +499,7 @@ mod test {
use super::*;
use ctap_types::webauthn::{PublicKeyCredentialRpEntity, PublicKeyCredentialUserEntity};
use trussed::{
client::{Chacha8Poly1305, Sha256},
client::mechanisms::{Chacha8Poly1305, Sha256},
types::Location,
};

Expand Down
4 changes: 2 additions & 2 deletions src/ctap2/pin.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::{cbor_serialize_message, TrussedRequirements};
use ctap_types::{cose::EcdhEsHkdf256PublicKey, ctap2::client_pin::Permissions, Error, Result};
use heapless::String;
use trussed::{
cbor_deserialize,
client::{CryptoClient, HmacSha256, P256},
client::{CryptoClient, mechanisms::{HmacSha256, P256}},
syscall, try_syscall,
types::{
Bytes, KeyId, KeySerialization, Location, Mechanism, Message, ShortData, StorageAttributes,
String,
},
};
use trussed_hkdf::{KeyOrData, OkmId};
Expand Down
26 changes: 13 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ generate_macros!();

use core::time::Duration;

use trussed::{client, syscall, types::Message, Client as TrussedClient};
use trussed::{client, syscall, types::Message, client::Client as TrussedClient};
use trussed_hkdf::HkdfClient;

use ctap_types::heapless_bytes::Bytes;
Expand Down Expand Up @@ -53,25 +53,25 @@ pub type Result<T> = core::result::Result<T, Error>;
/// [`ExtensionRequirements`][].
pub trait TrussedRequirements:
client::Client
+ client::P256
+ client::Chacha8Poly1305
+ client::Aes256Cbc
+ client::Sha256
+ client::HmacSha256
+ client::Ed255 // + client::Totp
+ client::mechanisms::P256
+ client::mechanisms::Chacha8Poly1305
+ client::mechanisms::Aes256Cbc
+ client::mechanisms::Sha256
+ client::mechanisms::HmacSha256
+ client::mechanisms::Ed255 // + client::Totp
+ HkdfClient
+ ExtensionRequirements
{
}

impl<T> TrussedRequirements for T where
T: client::Client
+ client::P256
+ client::Chacha8Poly1305
+ client::Aes256Cbc
+ client::Sha256
+ client::HmacSha256
+ client::Ed255 // + client::Totp
+ client::mechanisms::P256
+ client::mechanisms::Chacha8Poly1305
+ client::mechanisms::Aes256Cbc
+ client::mechanisms::Sha256
+ client::mechanisms::HmacSha256
+ client::mechanisms::Ed255 // + client::Totp
+ HkdfClient
+ ExtensionRequirements
{
Expand Down
14 changes: 7 additions & 7 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use ctap_types::{
use trussed::{
client, syscall, try_syscall,
types::{KeyId, Location, Mechanism, PathBuf},
Client as TrussedClient,
client::Client as TrussedClient,
};

use heapless::binary_heap::{BinaryHeap, Max};
Expand Down Expand Up @@ -273,7 +273,7 @@ impl PersistentState {
const RESET_RETRIES: u8 = 8;
const FILENAME: &'static [u8] = b"persistent-state.cbor";

pub fn load<T: client::Client + client::Chacha8Poly1305>(trussed: &mut T) -> Result<Self> {
pub fn load<T: client::Client + client::mechanisms::Chacha8Poly1305>(trussed: &mut T) -> Result<Self> {
// TODO: add "exists_file" method instead?
let result =
try_syscall!(trussed.read_file(Location::Internal, PathBuf::from(Self::FILENAME),))
Expand Down Expand Up @@ -324,7 +324,7 @@ impl PersistentState {
self.save(trussed)
}

pub fn load_if_not_initialised<T: client::Client + client::Chacha8Poly1305>(
pub fn load_if_not_initialised<T: client::Client + client::mechanisms::Chacha8Poly1305>(
&mut self,
trussed: &mut T,
) {
Expand All @@ -349,7 +349,7 @@ impl PersistentState {
Ok(now)
}

pub fn key_encryption_key<T: client::Client + client::Chacha8Poly1305>(
pub fn key_encryption_key<T: client::Client + client::mechanisms::Chacha8Poly1305>(
&mut self,
trussed: &mut T,
) -> Result<KeyId> {
Expand All @@ -359,7 +359,7 @@ impl PersistentState {
}
}

pub fn rotate_key_encryption_key<T: client::Client + client::Chacha8Poly1305>(
pub fn rotate_key_encryption_key<T: client::Client + client::mechanisms::Chacha8Poly1305>(
&mut self,
trussed: &mut T,
) -> Result<KeyId> {
Expand All @@ -372,7 +372,7 @@ impl PersistentState {
Ok(key)
}

pub fn key_wrapping_key<T: client::Client + client::Chacha8Poly1305>(
pub fn key_wrapping_key<T: client::Client + client::mechanisms::Chacha8Poly1305>(
&mut self,
trussed: &mut T,
) -> Result<KeyId> {
Expand All @@ -382,7 +382,7 @@ impl PersistentState {
}
}

pub fn rotate_key_wrapping_key<T: client::Client + client::Chacha8Poly1305>(
pub fn rotate_key_wrapping_key<T: client::Client + client::mechanisms::Chacha8Poly1305>(
&mut self,
trussed: &mut T,
) -> Result<KeyId> {
Expand Down
Loading