summaryrefslogtreecommitdiffstats
path: root/openpgp/examples/test-vectors-dump-s2k.rs
blob: 52cf358490e01fa864bae438d47f230b95f37aa9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use sequoia_openpgp::{
    fmt::hex,
    Packet,
    packet::SKESK,
    PacketPile,
    Result,
    parse::Parse,
};

fn main() -> Result<()> {
    let pp = PacketPile::from_file("seipv2.txt")?;
    if let Some(Packet::SKESK(SKESK::V5(v))) = pp.path_ref(&[0]) {
        hex::dump_rfc("s2k derived key", &v.s2k().derive_key(&"password".into(), 16)?);
        hex::dump_rfc("ecrypted key", &v.decrypt(&"password".into())?.1);
    } else {
        panic!()
    }

    Ok(())
}