asn1 der length: accomodate for other machine architecture

This commit is contained in:
occheung 2020-10-23 17:25:12 +08:00
parent d241e93d8e
commit f0e0b3d434
1 changed files with 2 additions and 1 deletions

View File

@ -370,7 +370,8 @@ pub fn parse_asn1_der_header(bytes: &[u8]) -> IResult<&[u8], (u8, usize)> {
for array_index in 0..length_slice.len() {
length_array[array_index + 8 - length_slice.len()] = length_slice[array_index];
}
Ok((rem, (tag[0], usize::from_be_bytes(length_array))))
let (_, length_array) = length_array.split_at(8 - core::mem::size_of::<usize>());
Ok((rem, (tag[0], usize::from_be_bytes((*length_array).try_into().unwrap()))))
}
}