#[path = "sign_cms.rs"]
mod cms;
#[path = "sign_der.rs"]
mod der;
#[path = "sign_pdf.rs"]
mod pdf;
#[cfg(test)]
#[path = "sign_tests.rs"]
mod tests;
pub use pdf::{sign_pdf, verify_pdf_signature};
pub(super) const OID_SIGNED_DATA_DER: &[u8] = &[
0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x02,
];
pub(super) const OID_DATA_DER: &[u8] = &[
0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01,
];
pub(super) const OID_SHA256_DER: &[u8] = &[
0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01,
];
pub(super) const OID_SHA256_WITH_RSA_DER: &[u8] = &[
0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0B,
];
pub(super) const OID_SIGNED_DATA_VAL: &[u8] =
&[0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x02];
pub struct PdfSigner {
pub certificate: Vec<u8>,
pub private_key: Vec<u8>,
pub reason: Option<String>,
pub location: Option<String>,
pub contact_info: Option<String>,
pub timestamp_url: Option<String>,
}
impl PdfSigner {
#[must_use]
pub fn new(certificate: Vec<u8>, private_key: Vec<u8>) -> Self {
Self {
certificate,
private_key,
reason: None,
location: None,
contact_info: None,
timestamp_url: None,
}
}
#[must_use]
pub fn with_reason(mut self, reason: impl Into<String>) -> Self {
self.reason = Some(reason.into());
self
}
#[must_use]
pub fn with_location(mut self, location: impl Into<String>) -> Self {
self.location = Some(location.into());
self
}
#[must_use]
pub fn with_contact_info(mut self, info: impl Into<String>) -> Self {
self.contact_info = Some(info.into());
self
}
#[must_use]
pub fn with_timestamp_url(mut self, url: impl Into<String>) -> Self {
self.timestamp_url = Some(url.into());
self
}
}
#[derive(Debug, Clone)]
pub struct SignatureInfo {
pub signer_cert: Vec<u8>,
pub signed_at: Option<String>,
pub reason: Option<String>,
pub location: Option<String>,
pub is_valid: bool,
pub signer_name: Option<String>,
pub issuer: Option<String>,
pub cert_not_before: Option<String>,
pub cert_not_after: Option<String>,
}