Merge pull request #17 from kedars/bugfix/incorrect_asn1_time
Bugfix/incorrect asn1 time
This commit is contained in:
commit
5bcb80af8a
5 changed files with 39 additions and 33 deletions
|
@ -32,7 +32,7 @@ fn main() {
|
||||||
// vid/pid should match those in the DAC
|
// vid/pid should match those in the DAC
|
||||||
let dev_info = BasicInfoConfig {
|
let dev_info = BasicInfoConfig {
|
||||||
vid: 0xFFF1,
|
vid: 0xFFF1,
|
||||||
pid: 0x8002,
|
pid: 0x8000,
|
||||||
hw_ver: 2,
|
hw_ver: 2,
|
||||||
sw_ver: 1,
|
sw_ver: 1,
|
||||||
sw_ver_str: "1".to_string(),
|
sw_ver_str: "1".to_string(),
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
use super::{CertConsumer, MAX_DEPTH};
|
use super::{CertConsumer, MAX_DEPTH};
|
||||||
use crate::error::Error;
|
use crate::error::Error;
|
||||||
use chrono::{TimeZone, Utc};
|
use chrono::{Datelike, TimeZone, Utc};
|
||||||
use log::warn;
|
use log::warn;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -277,7 +277,13 @@ impl<'a> CertConsumer for ASN1Writer<'a> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let time_str = format!("{}Z", dt.format("%y%m%d%H%M%S"));
|
if dt.year() >= 2050 {
|
||||||
self.write_str(0x17, time_str.as_bytes())
|
// If year is >= 2050, ASN.1 requires it to be Generalised Time
|
||||||
|
let time_str = format!("{}Z", dt.format("%Y%m%d%H%M%S"));
|
||||||
|
self.write_str(0x18, time_str.as_bytes())
|
||||||
|
} else {
|
||||||
|
let time_str = format!("{}Z", dt.format("%y%m%d%H%M%S"));
|
||||||
|
self.write_str(0x17, time_str.as_bytes())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -668,7 +668,7 @@ impl<'a> CertVerifier<'a> {
|
||||||
let k = KeyPair::new_from_public(parent.get_pubkey())?;
|
let k = KeyPair::new_from_public(parent.get_pubkey())?;
|
||||||
k.verify_msg(asn1, self.cert.get_signature()).map_err(|e| {
|
k.verify_msg(asn1, self.cert.get_signature()).map_err(|e| {
|
||||||
error!(
|
error!(
|
||||||
"Error in signature verification of certificate: {:#02x?}",
|
"Error in signature verification of certificate: {:x?}",
|
||||||
self.cert.get_subject_key_id()
|
self.cert.get_subject_key_id()
|
||||||
);
|
);
|
||||||
e
|
e
|
||||||
|
@ -706,7 +706,7 @@ pub trait CertConsumer {
|
||||||
}
|
}
|
||||||
|
|
||||||
const MAX_DEPTH: usize = 10;
|
const MAX_DEPTH: usize = 10;
|
||||||
const MAX_ASN1_CERT_SIZE: usize = 800;
|
const MAX_ASN1_CERT_SIZE: usize = 1000;
|
||||||
|
|
||||||
mod asn1_writer;
|
mod asn1_writer;
|
||||||
mod printer;
|
mod printer;
|
||||||
|
@ -1025,8 +1025,8 @@ mod tests {
|
||||||
0xbf, 0x68, 0x18, 0x59, 0x7f, 0xf7, 0xe8, 0xaf, 0x88, 0x91, 0x1c, 0x72, 0x32, 0xf7,
|
0xbf, 0x68, 0x18, 0x59, 0x7f, 0xf7, 0xe8, 0xaf, 0x88, 0x91, 0x1c, 0x72, 0x32, 0xf7,
|
||||||
0x52,
|
0x52,
|
||||||
];
|
];
|
||||||
pub const ASN1_OUTPUT_TXT_IN_DN: [u8; 427] = [
|
pub const ASN1_OUTPUT_TXT_IN_DN: [u8; 429] = [
|
||||||
0x30, 0x82, 0x01, 0xa7, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x30, 0x0a,
|
0x30, 0x82, 0x01, 0xa9, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x30, 0x0a,
|
||||||
0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x30, 0x56, 0x31, 0x0b,
|
0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x30, 0x56, 0x31, 0x0b,
|
||||||
0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x0f, 0x30,
|
0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x0f, 0x30,
|
||||||
0x0d, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x06, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
|
0x0d, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x06, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
|
||||||
|
@ -1034,29 +1034,29 @@ mod tests {
|
||||||
0x74, 0x65, 0x72, 0x20, 0x52, 0x6f, 0x6f, 0x74, 0x31, 0x20, 0x30, 0x1e, 0x06, 0x0a,
|
0x74, 0x65, 0x72, 0x20, 0x52, 0x6f, 0x6f, 0x74, 0x31, 0x20, 0x30, 0x1e, 0x06, 0x0a,
|
||||||
0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0xa2, 0x7c, 0x01, 0x04, 0x0c, 0x10, 0x46, 0x46,
|
0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0xa2, 0x7c, 0x01, 0x04, 0x0c, 0x10, 0x46, 0x46,
|
||||||
0x46, 0x46, 0x46, 0x46, 0x46, 0x45, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31,
|
0x46, 0x46, 0x46, 0x46, 0x46, 0x45, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31,
|
||||||
0x30, 0x1e, 0x17, 0x0d, 0x32, 0x31, 0x31, 0x32, 0x30, 0x38, 0x32, 0x30, 0x33, 0x30,
|
0x30, 0x20, 0x17, 0x0d, 0x32, 0x31, 0x31, 0x32, 0x30, 0x38, 0x32, 0x30, 0x33, 0x30,
|
||||||
0x35, 0x35, 0x5a, 0x17, 0x0d, 0x32, 0x31, 0x31, 0x32, 0x30, 0x38, 0x32, 0x30, 0x33,
|
0x35, 0x35, 0x5a, 0x18, 0x0f, 0x32, 0x31, 0x32, 0x31, 0x31, 0x32, 0x30, 0x38, 0x32,
|
||||||
0x30, 0x35, 0x35, 0x5a, 0x30, 0x56, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04,
|
0x30, 0x33, 0x30, 0x35, 0x35, 0x5a, 0x30, 0x56, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03,
|
||||||
0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x0f, 0x30, 0x0d, 0x06, 0x03, 0x55, 0x04, 0x0a,
|
0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x0f, 0x30, 0x0d, 0x06, 0x03, 0x55,
|
||||||
0x0c, 0x06, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x31, 0x14, 0x30, 0x12, 0x06, 0x03,
|
0x04, 0x0a, 0x0c, 0x06, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x31, 0x14, 0x30, 0x12,
|
||||||
0x55, 0x04, 0x03, 0x0c, 0x0b, 0x4d, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x52, 0x6f,
|
0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0b, 0x4d, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20,
|
||||||
0x6f, 0x74, 0x31, 0x20, 0x30, 0x1e, 0x06, 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82,
|
0x52, 0x6f, 0x6f, 0x74, 0x31, 0x20, 0x30, 0x1e, 0x06, 0x0a, 0x2b, 0x06, 0x01, 0x04,
|
||||||
0xa2, 0x7c, 0x01, 0x04, 0x0c, 0x10, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x45,
|
0x01, 0x82, 0xa2, 0x7c, 0x01, 0x04, 0x0c, 0x10, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46,
|
||||||
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07,
|
0x46, 0x45, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x30, 0x59, 0x30, 0x13,
|
||||||
0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d,
|
0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48,
|
||||||
0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0x5b, 0x37, 0xdf, 0x65, 0x49, 0xc2, 0x0d,
|
0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0x5b, 0x37, 0xdf, 0x65, 0x49,
|
||||||
0xc8, 0xd7, 0x22, 0xa6, 0xb8, 0xac, 0xb6, 0x60, 0xa8, 0xa7, 0x64, 0xce, 0x7b, 0xaf,
|
0xc2, 0x0d, 0xc8, 0xd7, 0x22, 0xa6, 0xb8, 0xac, 0xb6, 0x60, 0xa8, 0xa7, 0x64, 0xce,
|
||||||
0x6c, 0x6c, 0x22, 0x4f, 0x7e, 0xe8, 0x43, 0x49, 0x68, 0x4a, 0xd7, 0xd8, 0x09, 0xff,
|
0x7b, 0xaf, 0x6c, 0x6c, 0x22, 0x4f, 0x7e, 0xe8, 0x43, 0x49, 0x68, 0x4a, 0xd7, 0xd8,
|
||||||
0x65, 0x00, 0x33, 0xd1, 0x52, 0x7d, 0xcf, 0x1f, 0xba, 0xac, 0x6a, 0x9c, 0x3a, 0xd8,
|
0x09, 0xff, 0x65, 0x00, 0x33, 0xd1, 0x52, 0x7d, 0xcf, 0x1f, 0xba, 0xac, 0x6a, 0x9c,
|
||||||
0xb4, 0x1e, 0xda, 0xc9, 0x09, 0xf7, 0xb5, 0xc7, 0x60, 0xfd, 0x54, 0x2c, 0x89, 0x23,
|
0x3a, 0xd8, 0xb4, 0x1e, 0xda, 0xc9, 0x09, 0xf7, 0xb5, 0xc7, 0x60, 0xfd, 0x54, 0x2c,
|
||||||
0x75, 0xa3, 0x66, 0x30, 0x64, 0x30, 0x12, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01,
|
0x89, 0x23, 0x75, 0xa3, 0x66, 0x30, 0x64, 0x30, 0x12, 0x06, 0x03, 0x55, 0x1d, 0x13,
|
||||||
0xff, 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x01, 0x30, 0x0e, 0x06,
|
0x01, 0x01, 0xff, 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x01, 0x30,
|
||||||
0x03, 0x55, 0x1d, 0x0f, 0x01, 0x01, 0xff, 0x04, 0x04, 0x03, 0x02, 0x01, 0x06, 0x30,
|
0x0e, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x01, 0x01, 0xff, 0x04, 0x04, 0x03, 0x02, 0x01,
|
||||||
0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x72, 0xc2, 0x01, 0xf7,
|
0x06, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x72, 0xc2,
|
||||||
0x57, 0x19, 0x13, 0xb3, 0x48, 0xca, 0x00, 0xca, 0x7b, 0x45, 0xf4, 0x77, 0x46, 0x68,
|
0x01, 0xf7, 0x57, 0x19, 0x13, 0xb3, 0x48, 0xca, 0x00, 0xca, 0x7b, 0x45, 0xf4, 0x77,
|
||||||
0xc9, 0x7e, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80,
|
0x46, 0x68, 0xc9, 0x7e, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30,
|
||||||
0x14, 0x72, 0xc2, 0x01, 0xf7, 0x57, 0x19, 0x13, 0xb3, 0x48, 0xca, 0x00, 0xca, 0x7b,
|
0x16, 0x80, 0x14, 0x72, 0xc2, 0x01, 0xf7, 0x57, 0x19, 0x13, 0xb3, 0x48, 0xca, 0x00,
|
||||||
0x45, 0xf4, 0x77, 0x46, 0x68, 0xc9, 0x7e,
|
0xca, 0x7b, 0x45, 0xf4, 0x77, 0x46, 0x68, 0xc9, 0x7e,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ use crate::{
|
||||||
tlv::{OctetStr, TLVWriter, TagType, ToTLV, UtfStr},
|
tlv::{OctetStr, TLVWriter, TagType, ToTLV, UtfStr},
|
||||||
};
|
};
|
||||||
|
|
||||||
const MAX_CERT_TLV_LEN: usize = 300;
|
const MAX_CERT_TLV_LEN: usize = 350;
|
||||||
const COMPRESSED_FABRIC_ID_LEN: usize = 8;
|
const COMPRESSED_FABRIC_ID_LEN: usize = 8;
|
||||||
|
|
||||||
macro_rules! fb_key {
|
macro_rules! fb_key {
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
//!
|
//!
|
||||||
//! /// The basic information about this device
|
//! /// The basic information about this device
|
||||||
//! let dev_info = BasicInfoConfig {
|
//! let dev_info = BasicInfoConfig {
|
||||||
//! vid: 0x8002,
|
//! vid: 0x8000,
|
||||||
//! pid: 0xFFF1,
|
//! pid: 0xFFF1,
|
||||||
//! hw_ver: 2,
|
//! hw_ver: 2,
|
||||||
//! sw_ver: 1,
|
//! sw_ver: 1,
|
||||||
|
|
Loading…
Add table
Reference in a new issue