Expand description
§zar
XAR archive reader/writer library that is fuzz-tested agains MacOS xar
.
Supports signing and verifying archives.
§Installation
The easiest way to use zar
is via command line interface.
cargo install zar-cli
§Usage
§As a command-line application
# archive tmp dir
zar -cf tmp.xar /tmp
# extract the archive
zar -xf tmp.xar /tmp/extracted
# archive tmp dir and sign the archive
openssl genrsa -traditional -out private-key.pem 2048
openssl req -x509 -sha1 -days 1 -noenc -key private-key.pem -out cert.pem -subj /CN=Zar
zar --sign private-key.pem --cert cert.pem -cf tmp.xar /tmp
# verify and extract the archive
zar --trust cert.pem -xf tmp.xar /tmp/extracted
§As a library
use std::fs::File;
use std::io::Error;
use zar::NoSigner;
fn create_archive() -> Result<(), Error> {
let file = File::create("archive.xar")?;
let mut builder = zar::UnsignedBuilder::new_unsigned(file);
builder.append_dir_all("/tmp", zar::Compression::default(), zar::no_extra_contents)?;
builder.finish()?;
Ok(())
}
fn extract_archive() -> Result<(), Error> {
let file = File::open("archive.xar")?;
let mut archive = zar::Archive::new(file)?;
for i in 0..archive.num_entries() {
let mut entry = archive.entry(i);
println!("{:?}", entry.file());
if let Some(mut reader) = entry.reader()? {
// read the entry...
}
}
Ok(())
}
Re-exports§
Structs§
- Apple
Root Cert Verifier - A
RootCertVerifier
that trusts only Apple root certificate. - Archive
Options - Archive reading and extraction options.
- Builder
Options - Builder options.
- Device
- Character device or block device information.
- Encoding
- Compression codec.
- Entry
- File entry that is currently being read.
- Extended
Archive - XAR archive with extra data.
- Extended
Builder - XAR archive builder with extra data.
- File
- File entry.
- File
Checksum - File hash.
- File
Data - Additional file entry data.
- File
Mode - File mode.
- Link
- Symbolic link information.
- NoSigner
- Archive
Signer
that produces unsigned archives. - RsaSigner
- Archive
Signer
that uses RSA key to sign the archive. - Timestamp
- UNIX timestamp.
- Trust
Any - A
RootCertVerifier
that trusts any certificate. - Trust
Certs - A
RootCertVerifier
that trusts the supplied list of certificates.
Enums§
- Checksum
- A hash that is used to verify archive metadata and file contents.
- Checksum
Algo - Hash algorithm of
Checksum
. - Compression
- Compression codec that is used to compress files and table of contents.
- File
Type - File type.
- Hard
Link - A hard link.
- XarDecoder
- Decoder for
Compression
codec.
Traits§
- Root
Cert Verifier - Root certificate verifier.
- Signer
- Archive signer.
Functions§
- no_
extra_ contents - Use this function as
extra
argument toBuilder::append_dir_all
andBuilder::append_raw
calls to not append any extra data to the archive.
Type Aliases§
- Archive
- XAR archive without any extra data.
- Builder
- Signed XAR archive builder without extra data.
- Unsigned
Builder - Unsigned XAR archive builder without extra data.