Skip to content

Commit

Permalink
ssh-key: make out the last param of public::SshFormat::encode (#38)
Browse files Browse the repository at this point in the history
More consistent with other function signatures that put the output
buffer as the last argument.
  • Loading branch information
tarcieri authored Oct 24, 2022
1 parent cc9fa69 commit 1b429ab
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ssh-key/src/public.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ impl PublicKey {
/// Encode OpenSSH-formatted public key.
pub fn encode_openssh<'o>(&self, out: &'o mut [u8]) -> Result<&'o str> {
SshFormat::encode(
out,
self.algorithm().as_str(),
&self.key_data,
self.comment(),
out,
)
}

Expand Down
4 changes: 2 additions & 2 deletions ssh-key/src/public/ssh_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ impl<'a> SshFormat<'a> {

/// Encode data with OpenSSH public key encapsulation.
pub(crate) fn encode<'o, K>(
out: &'o mut [u8],
algorithm_id: &str,
key: &K,
comment: &str,
out: &'o mut [u8],
) -> Result<&'o str>
where
K: Encode<Error = Error>,
Expand Down Expand Up @@ -97,7 +97,7 @@ impl<'a> SshFormat<'a> {
.checked_sum()?;

let mut out = vec![0u8; encoded_len];
let actual_len = Self::encode(&mut out, algorithm_id, key, comment)?.len();
let actual_len = Self::encode(algorithm_id, key, comment, &mut out)?.len();
out.truncate(actual_len);
Ok(String::from_utf8(out)?)
}
Expand Down

0 comments on commit 1b429ab

Please sign in to comment.