Skip to content

Commit

Permalink
Add function to validate parsed V4DocumentHeader (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
giarc3 authored Apr 29, 2024
1 parent 2e8bc5f commit f71f628
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/v4/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use crate::icl_header_v4::V4DocumentHeader;

pub mod aes;
pub mod attached;

Expand All @@ -14,3 +16,11 @@ pub mod attached;
pub(crate) const PRE_HEADER_LEN: usize = 7;
pub(crate) const MAGIC: &[u8; 4] = b"IRON";
pub(crate) const V4: u8 = 4u8;

// Checks that the proto header has a signature, had a valid signature_type, has a signed_payload, and has at least one EDEK
pub fn validate_v4_header(header: &V4DocumentHeader) -> bool {
header.signature_info.is_some()
&& header.signature_info.signature_type.enum_value().is_ok()
&& header.signed_payload.is_some()
&& !header.signed_payload.edeks.is_empty()
}

0 comments on commit f71f628

Please sign in to comment.