From: Pierre Chifflier Date: Mon, 1 Nov 2021 13:44:11 +0000 (+0100) Subject: rust/x509: update dependency on x509-parser X-Git-Tag: suricata-7.0.0-beta1~169 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3aace496492758eeac01ceccb6ed487dd2dedc2b;p=thirdparty%2Fsuricata.git rust/x509: update dependency on x509-parser --- diff --git a/rust/Cargo.toml.in b/rust/Cargo.toml.in index 4a4990a57d..8661dc0b34 100644 --- a/rust/Cargo.toml.in +++ b/rust/Cargo.toml.in @@ -47,7 +47,7 @@ ntp-parser = "~0.6.0" ipsec-parser = "~0.7.0" snmp-parser = "~0.6.0" tls-parser = "~0.11.0" -x509-parser = "~0.6.5" +x509-parser = "~0.12.0" libc = "~0.2.82" sha2 = "~0.10.2" digest = "~0.10.3" diff --git a/rust/src/rdp/log.rs b/rust/src/rdp/log.rs index f8f08f5c38..a9bba49320 100644 --- a/rust/src/rdp/log.rs +++ b/rust/src/rdp/log.rs @@ -21,7 +21,7 @@ use super::rdp::{RdpTransaction, RdpTransactionItem}; use crate::jsonbuilder::{JsonBuilder, JsonError}; use crate::rdp::parser::*; use crate::rdp::windows; -use x509_parser::parse_x509_der; +use x509_parser::prelude::{X509Certificate, FromDer}; #[no_mangle] pub extern "C" fn rs_rdp_to_json(tx: &mut RdpTransaction, js: &mut JsonBuilder) -> bool { @@ -50,7 +50,7 @@ fn log(tx: &RdpTransaction, js: &mut JsonBuilder) -> Result<(), JsonError> { js.set_string("event_type", "tls_handshake")?; js.open_array("x509_serials")?; for blob in chain { - match parse_x509_der(&blob.data) { + match X509Certificate::from_der(&blob.data) { Ok((_, cert)) => { js.append_string(&cert.tbs_certificate.serial.to_str_radix(16))?; } diff --git a/rust/src/x509/mod.rs b/rust/src/x509/mod.rs index 428e667935..25518387f9 100644 --- a/rust/src/x509/mod.rs +++ b/rust/src/x509/mod.rs @@ -18,10 +18,9 @@ // written by Pierre Chifflier use crate::common::rust_string_to_c; -use nom; use std; use std::os::raw::c_char; -use x509_parser::{error::X509Error, parse_x509_der, X509Certificate}; +use x509_parser::prelude::*; #[repr(u32)] pub enum X509DecodeError { @@ -54,7 +53,7 @@ pub unsafe extern "C" fn rs_x509_decode( err_code: *mut u32, ) -> *mut X509 { let slice = std::slice::from_raw_parts(input, input_len as usize); - let res = parse_x509_der(slice); + let res = X509Certificate::from_der(slice); match res { Ok((_rem, cert)) => Box::into_raw(Box::new(X509(cert))), Err(e) => { @@ -112,8 +111,8 @@ pub unsafe extern "C" fn rs_x509_get_validity( return -1; } let x509 = &*ptr; - let n_b = x509.0.tbs_certificate.validity.not_before.to_timespec().sec; - let n_a = x509.0.tbs_certificate.validity.not_after.to_timespec().sec; + let n_b = x509.0.validity().not_before.timestamp(); + let n_a = x509.0.validity().not_after.timestamp(); *not_before = n_b; *not_after = n_a; 0