ecdsa private key

This commit is contained in:
nora 2024-08-26 18:14:21 +02:00
parent dcba4931e5
commit 1a093aa536
8 changed files with 147 additions and 28 deletions

View file

@ -81,8 +81,15 @@ impl<'a> Reader<'a> {
Ok(NameList(list))
}
pub fn mpint(&mut self) -> Result<MpInt<'a>> {
todo!("do correctly")
pub fn mpint(&mut self) -> Result<&'a [u8]> {
let mut s = self.string()?;
if s.first() == Some(&0) {
// Skip the leading zero byte in case the number is negative.
s = &s[1..];
}
Ok(s)
}
pub fn string(&mut self) -> Result<&'a [u8]> {
@ -152,6 +159,10 @@ impl Writer {
self.u8(v as u8);
}
pub fn current_length(&self) -> usize {
self.0.len()
}
pub fn finish(self) -> Vec<u8> {
self.0
}