aboutsummaryrefslogtreecommitdiffstats
path: root/src/access
diff options
context:
space:
mode:
Diffstat (limited to 'src/access')
-rw-r--r--src/access/sshsig.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/access/sshsig.rs b/src/access/sshsig.rs
index e25d8a7..740a727 100644
--- a/src/access/sshsig.rs
+++ b/src/access/sshsig.rs
@@ -198,7 +198,12 @@ pub(crate) fn sign(key: &SigningKey, namespace: &str, message: &[u8]) -> String
}
/// What a signature is made over.
-fn signed_data(namespace: &[u8], reserved: &[u8], algorithm: &[u8], hash: &[u8]) -> Vec<u8> {
+pub(crate) fn signed_data(
+ namespace: &[u8],
+ reserved: &[u8],
+ algorithm: &[u8],
+ hash: &[u8],
+) -> Vec<u8> {
let mut signed = MAGIC.to_vec();
string(&mut signed, namespace);
string(&mut signed, reserved);
@@ -207,13 +212,14 @@ fn signed_data(namespace: &[u8], reserved: &[u8], algorithm: &[u8], hash: &[u8])
signed
}
-fn string(out: &mut Vec<u8>, bytes: &[u8]) {
+/// `bytes` as SSH's string: a big-endian `u32` length, then the bytes.
+pub(crate) fn string(out: &mut Vec<u8>, bytes: &[u8]) {
out.extend_from_slice(&(bytes.len() as u32).to_be_bytes());
out.extend_from_slice(bytes);
}
/// Reads SSH's encoding.
-struct Reader<'a>(&'a [u8]);
+pub(crate) struct Reader<'a>(pub(crate) &'a [u8]);
impl<'a> Reader<'a> {
fn u32(&mut self) -> Result<u32, String> {
@@ -222,7 +228,7 @@ impl<'a> Reader<'a> {
Ok(u32::from_be_bytes(*bytes))
}
- fn string(&mut self) -> Result<&'a [u8], String> {
+ pub(crate) fn string(&mut self) -> Result<&'a [u8], String> {
let length = self.u32()? as usize;
if self.0.len() < length {
return Err("cut short".to_owned());
@@ -232,7 +238,7 @@ impl<'a> Reader<'a> {
Ok(bytes)
}
- fn end(&self) -> Result<(), String> {
+ pub(crate) fn end(&self) -> Result<(), String> {
if self.0.is_empty() {
Ok(())
} else {