Skip to content

Commit

Permalink
ssh-key: introduce private::SkEd25519::new() constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
jviki committed Mar 7, 2024
1 parent 79bf8a4 commit 9ad171b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions ssh-key/src/private/sk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,30 @@ pub struct SkEd25519 {
}

impl SkEd25519 {
/// Construct new instance of SkEd25519.
#[cfg(feature = "alloc")]
pub fn new(
public: public::SkEd25519,
flags: u8,
key_handle: impl Into<Vec<u8>>
) -> Result<Self> {
let key_handle = key_handle.into();

if key_handle.len() <= 255 {
Ok(SkEd25519 {
public,
flags,
key_handle: key_handle.to_vec(),
reserved: Vec::<u8>::new(),
})
}
else {
Err(Error::TooLong {
bad_len: key_handle.len()
})
}
}

/// Get the Ed25519 public key.
pub fn public(&self) -> &public::SkEd25519 {
&self.public
Expand Down

0 comments on commit 9ad171b

Please sign in to comment.