Expand description
§Packet module
Handles everything in relationship to packets.
Key generation is handled separately as well as signing and verifying with external hashing applied.
use pgp::crypto::{self, sym::SymmetricKeyAlgorithm, hash::HashAlgorithm, public_key::PublicKeyAlgorithm};
use pgp::types::{self, PublicKeyTrait, SecretKeyTrait, CompressionAlgorithm};
use smallvec::*;
use pgp::packet::{Signature, SignatureConfig};
let signing_key = signed_secret_key;
let verification_key = public_key;
let passwd_fn = || String::new();
let now = chrono::Utc::now();
let mut sig_cfg = SignatureConfig::v4(packet::SignatureType::Binary, PublicKeyAlgorithm::RSA, HashAlgorithm::SHA2_256);
sig_cfg.hashed_subpackets = vec![
packet::Subpacket::regular(packet::SubpacketData::SignatureCreationTime(now)),
packet::Subpacket::regular(packet::SubpacketData::Issuer(signing_key.key_id())),
];
let signature_packet = sig_cfg
.sign(&signing_key, passwd_fn, DATA)
.expect("Should sign");
let mut signature_bytes = Vec::with_capacity(1024);
packet::write_packet(&mut signature_bytes, &signature_packet).expect("Write must succeed");
signature_packet
.verify(&verification_key, DATA)
.expect("Failed to validate signature");
Modules§
Structs§
- Compressed
Data - KeyFlags
- Literal
Data - Literal Data Packet https://www.rfc-editor.org/rfc/rfc9580.html#name-literal-data-packet-type-id
- Marker
- Marker Packet https://www.rfc-editor.org/rfc/rfc9580.html#name-marker-packet-type-id-10
- ModDetection
Code - Modification Detection Code Packet https://www.rfc-editor.org/rfc/rfc9580.html#version-one-seipd
- Notation
- OnePass
Signature - One-Pass Signature Packet https://www.rfc-editor.org/rfc/rfc9580.html#name-one-pass-signature-packet-t
- Packet
Parser - Padding
- Padding Packet
- Public
Key - Public
Subkey - Secret
Key - Secret
Subkey - Signature
- Signature Packet https://www.rfc-editor.org/rfc/rfc9580.html#name-signature-packet-type-id-2
- Signature
Config - Subpacket
- SymEncrypted
Data - Symmetrically Encrypted Data Packet https://www.rfc-editor.org/rfc/rfc9580.html#name-symmetrically-encrypted-dat
- SymEncrypted
Protected Data - Symmetrically Encrypted Integrity Protected Data Packet https://www.rfc-editor.org/rfc/rfc9580.html#name-symmetrically-encrypted-and
- Trust
- Trust Packet https://www.rfc-editor.org/rfc/rfc9580.html#name-trust-packet-type-id-12
- UserId
- User ID Packet https://www.rfc-editor.org/rfc/rfc9580.html#name-user-id-packet-type-id-13
Enums§
- Data
- Data
Mode - Decompressor
- OpsVersion
Specific - Version-specific elements of a One-Pass Signature Packet:
- Packet
- Public
KeyEncrypted Session Key - Public Key Encrypted Session Key Packet (PKESK) https://www.rfc-editor.org/rfc/rfc9580.html#name-public-key-encrypted-sessio
- Revocation
Code - Codes for revocation reasons
- Signature
Type - Signature
Version - Signature
Version Specific - Subpacket
Data - Subpacket
Type - Available signature subpacket types
- SymKey
Encrypted Session Key - Symmetric-Key Encrypted Session Key Packet https://www.rfc-editor.org/rfc/rfc9580.html#name-symmetric-key-encrypted-ses
- User
Attribute - User Attribute Packet https://www.rfc-editor.org/rfc/rfc9580.html#name-user-attribute-packet-type-