Skip to content

Commit

Permalink
BytesKeyEC2: Use BytesP256ElemLen alias
Browse files Browse the repository at this point in the history
  • Loading branch information
chrysn committed Nov 27, 2024
1 parent b985932 commit 5d170df
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions shared/src/cred.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ pub type BufferIdCred = EdhocBuffer<192>; // variable size, can contain either t
pub type BytesKeyAES128 = [u8; 16];

#[derive(Debug, Copy, Clone, PartialEq)]
pub struct BytesKeyEC2([u8; 32]);
pub struct BytesKeyEC2(BytesP256ElemLen);

impl TryFrom<[u8; 32]> for BytesKeyEC2 {
impl TryFrom<BytesP256ElemLen> for BytesKeyEC2 {
type Error = EDHOCError;

fn try_from(value: [u8; 32]) -> Result<Self, Self::Error> {
fn try_from(value: BytesP256ElemLen) -> Result<Self, Self::Error> {
// Not performing any validation yet
Ok(Self(value))
}
Expand All @@ -23,7 +23,7 @@ impl TryFrom<&[u8]> for BytesKeyEC2 {
type Error = EDHOCError;

fn try_from(value: &[u8]) -> Result<Self, Self::Error> {
let slice: [u8; 32] = value.try_into().map_err(|_| EDHOCError::ParsingError)?;
let slice: BytesP256ElemLen = value.try_into().map_err(|_| EDHOCError::ParsingError)?;
slice.try_into()
}
}
Expand Down

0 comments on commit 5d170df

Please sign in to comment.