Fix bug in key::generate and document weirdness

Bug was introduced in #73 when starting offsets were overlooked. Digging
into why they were there led to uncovering the weird not-quite-ASN.1
format that the YubiKey returns generated pubkeys in.
This commit is contained in:
Jack Grigg
2019-12-11 02:24:18 +00:00
parent 41b10d1f23
commit 2eff313064
2 changed files with 40 additions and 2 deletions
+2
View File
@@ -156,6 +156,8 @@ pub(crate) fn set_length(buffer: &mut [u8], length: usize) -> Result<usize, Erro
/// Parse length tag, returning the size of the length tag itself as the
/// returned value, and setting the len parameter to the parsed length.
pub(crate) fn get_length(buffer: &[u8], len: &mut usize) -> usize {
// This is not valid ASN.1 (0x80 is the indefinite length marker).
// See comment in key::generate for more context.
if buffer[0] < 0x81 {
*len = buffer[0] as usize;
1