#![cfg_attr(docsrs, feature(doc_cfg))]
#![forbid(unsafe_code)]
#![allow(unknown_lints)]
#![warn(absolute_paths_not_starting_with_crate)]
#![warn(elided_lifetimes_in_paths)]
#![warn(explicit_outlives_requirements)]
#![warn(meta_variable_misuse)]
#![warn(missing_copy_implementations)]
#![warn(missing_debug_implementations)]
#![warn(missing_docs)]
#![warn(non_ascii_idents)]
#![warn(noop_method_call)]
#![warn(rust_2018_idioms)]
#![warn(single_use_lifetimes)]
#![warn(trivial_casts)]
#![warn(unreachable_pub)]
#![warn(unused_crate_dependencies)]
#![warn(unused_extern_crates)]
#![warn(unused_lifetimes)]
#![warn(unused_results)]
#![doc = include_str!("../README.md")]
#[cfg(feature = "sign")]
pub mod sign;
#[cfg(feature = "verify")]
pub mod verify;
use std::io::{copy, Read};
#[doc(no_inline)]
pub use ed25519_dalek::{
Digest, Sha512, Signature, SignatureError, SigningKey, VerifyingKey, KEYPAIR_LENGTH,
PUBLIC_KEY_LENGTH, SIGNATURE_LENGTH,
};
pub const MAGIC_HEADER: &[u8; 14] = b"\x0c\x04\x01ed25519ph\x00\x00";
pub const HEADER_SIZE: usize = 16;
pub type SignatureCountLeInt = u16;
const EPOCH: u32 = 978_307_200; pub const GZIP_START: &[u8; 10] = {
let [m1, m2, m3, m4] = EPOCH.to_le_bytes();
&[
0x1f, 0x8b, 0x08, 0x10, m1, m2, m3, m4, 0x00, 0xff, ]
};
pub const GZIP_END: &[u8; 14] = &[
0x00, 0x01, 0x00, 0x00, 0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, ];
pub const GZIP_EXTRA: usize = GZIP_START.len() + GZIP_END.len() + u64::BITS as usize / 4;
pub const BUF_LIMIT: usize = 1 << 16; pub fn prehash<I>(input: &mut I) -> std::io::Result<Sha512>
where
I: ?Sized + Read,
{
let mut prehashed_message = Sha512::new();
let _: u64 = copy(input, &mut prehashed_message)?;
Ok(prehashed_message)
}
#[non_exhaustive]
#[derive(Debug, thiserror::Error)]
#[error(transparent)]
pub enum ZipsignError {
#[cfg(feature = "sign")]
#[cfg_attr(docsrs, doc(cfg(feature = "sign")))]
GatherSignatureData(#[from] self::sign::GatherSignatureDataError),
#[cfg(feature = "sign")]
#[cfg_attr(docsrs, doc(cfg(feature = "sign")))]
ReadSigningKeys(#[from] self::sign::ReadSigningKeysError),
#[cfg(feature = "sign-tar")]
#[cfg_attr(docsrs, doc(cfg(feature = "sign-tar")))]
SignTar(#[from] self::sign::SignTarError),
#[cfg(feature = "sign-zip")]
#[cfg_attr(docsrs, doc(cfg(feature = "sign-zip")))]
SignZip(#[from] self::sign::SignZipError),
#[cfg(feature = "verify")]
#[cfg_attr(docsrs, doc(cfg(feature = "verify")))]
NoMatch(#[from] self::verify::NoMatch),
#[cfg(feature = "verify")]
#[cfg_attr(docsrs, doc(cfg(feature = "verify")))]
CollectKeys(#[from] self::verify::CollectKeysError),
#[cfg(feature = "verify")]
#[cfg_attr(docsrs, doc(cfg(feature = "verify")))]
ReadSignatures(#[from] self::verify::ReadSignaturesError),
#[cfg(feature = "verify-tar")]
#[cfg_attr(docsrs, doc(cfg(feature = "verify-tar")))]
VerifyTar(#[from] self::verify::VerifyTarError),
#[cfg(feature = "verify-zip")]
#[cfg_attr(docsrs, doc(cfg(feature = "verify-zip")))]
VerifyZip(#[from] self::verify::VerifyZipError),
Io(#[from] std::io::Error),
}