/// Container for parsed Asn1 objects
#[derive(Debug)]
-pub struct Asn1(Vec<BerObject<'static>>);
+pub struct Asn1<'a>(Vec<BerObject<'a>>);
/// Errors possible during decoding of Asn1
#[derive(Debug)]
}
}
-impl Asn1 {
+impl<'a> Asn1<'a> {
/// Checks each BerObject contained in self with the provided detection
/// data, returns the first successful match if one occurs
fn check(&self, ad: &DetectAsn1Data) -> Result<Option<Asn1Check>, Asn1CheckError> {
None
}
- fn from_slice(input: &'static [u8], ad: &DetectAsn1Data) -> Result<Asn1, Asn1DecodeError> {
+ fn from_slice(input: &'a [u8], ad: &DetectAsn1Data) -> Result<Asn1<'a>, Asn1DecodeError> {
let mut results = Vec::new();
let mut rest = input;
/// Decodes Asn1 objects from an input + length while applying the offset
/// defined in the asn1 keyword options
-fn asn1_decode(
- buffer: &'static [u8],
+fn asn1_decode<'a>(
+ buffer: &'a [u8],
buffer_offset: u32,
ad: &DetectAsn1Data,
-) -> Result<Asn1, Asn1DecodeError> {
+) -> Result<Asn1<'a>, Asn1DecodeError> {
// Get offset
let offset = if let Some(absolute_offset) = ad.absolute_offset {
absolute_offset
/// input must be a valid buffer of at least input_len bytes
/// pointer must be freed using `rs_asn1_free`
#[no_mangle]
-pub unsafe extern "C" fn rs_asn1_decode(
+pub extern "C" fn rs_asn1_decode(
input: *const u8,
input_len: u16,
buffer_offset: u32,
ad_ptr: *const DetectAsn1Data,
-) -> *mut Asn1 {
+) -> *mut Asn1<'static> {
if input.is_null() || input_len == 0 || ad_ptr.is_null() {
return std::ptr::null_mut();
}
let slice = build_slice!(input, input_len as usize);
- let ad = &*ad_ptr;
+ let ad = unsafe { &*ad_ptr };
let res = asn1_decode(slice, buffer_offset, ad);