Merge remote-tracking branch 'ssadler/fix/13' into fix/13
This commit is contained in:
19
src/lib.rs
19
src/lib.rs
@@ -401,7 +401,7 @@ pub enum ASN1EncodeErr {
|
|||||||
|
|
||||||
impl fmt::Display for ASN1EncodeErr {
|
impl fmt::Display for ASN1EncodeErr {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
f.write_str(self.description())
|
f.write_str(&self.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1684,4 +1684,21 @@ mod tests {
|
|||||||
]))))])]),
|
]))))])]),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn encode_unknowns() {
|
||||||
|
fn encode_structure(bufs: &[Vec<u8>]) -> Vec<u8> {
|
||||||
|
let mut body = Vec::new();
|
||||||
|
for (i, buf) in bufs.iter().enumerate() {
|
||||||
|
let mut der = to_der(&ASN1Block::Unknown(ASN1Class::ContextSpecific, false, 0, BigUint::from_usize(i).unwrap(), buf.to_vec())).unwrap();
|
||||||
|
body.append(&mut der);
|
||||||
|
}
|
||||||
|
let block = ASN1Block::Unknown(ASN1Class::ContextSpecific, true, 0, BigUint::from_u8(0).unwrap(), body);
|
||||||
|
to_der(&block).unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
let decoded = from_der(&encode_structure(&vec![vec![0]])).unwrap();
|
||||||
|
let expected = [ASN1Block::Unknown(ASN1Class::ContextSpecific, true, 0, BigUint::from_u8(0).unwrap(), vec![128, 1, 0])];
|
||||||
|
assert_eq!(decoded, expected);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user