Skip to content

Commit 880c225

Browse files
committed
key: return a u64 from key.id()
Key IDs are specified as 8-byte scalars in the spec, so we don't have to treat them like opaque blobs of bytes.
1 parent 2d6d921 commit 880c225

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/key.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::time::Duration;
22

3-
use byteorder::{BigEndian, WriteBytesExt};
3+
use byteorder::{BigEndian, ByteOrder, WriteBytesExt};
44
use digest::Digest;
55
use failure::Error;
66
use md5::Md5;
@@ -306,8 +306,8 @@ impl Key {
306306
}
307307
}
308308

309-
pub fn id(&self) -> Result<Vec<u8>, Error> {
310-
match self.version {
309+
pub fn id(&self) -> Result<u64, Error> {
310+
let bytes = match self.version {
311311
KeyVersion::V3 => match self.key_material {
312312
KeyMaterial::Rsa(ref pubkey, _) => {
313313
let n = pubkey.n.to_bytes_be();
@@ -320,7 +320,9 @@ impl Key {
320320
let len = f.len();
321321
f.split_off(len - 8)
322322
}),
323-
}
323+
}?;
324+
325+
Ok(BigEndian::read_u64(&bytes))
324326
}
325327
}
326328

0 commit comments

Comments
 (0)