Module packet

Module packet 

Source
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 vpgp::crypto::{self, sym::SymmetricKeyAlgorithm, hash::HashAlgorithm, public_key::PublicKeyAlgorithm};
use vpgp::types::{self, PublicKeyTrait, SecretKeyTrait, CompressionAlgorithm};
use smallvec::*;
use vpgp::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§

config
de
ser
types

Structs§

CompressedData
KeyFlags
LiteralData
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
ModDetectionCode
Modification Detection Code Packet https://www.rfc-editor.org/rfc/rfc9580.html#version-one-seipd
Notation
OnePassSignature
One-Pass Signature Packet https://www.rfc-editor.org/rfc/rfc9580.html#name-one-pass-signature-packet-t
PacketParser
Padding
Padding Packet
PublicKey
PublicSubkey
SecretKey
SecretSubkey
Signature
Signature Packet https://www.rfc-editor.org/rfc/rfc9580.html#name-signature-packet-type-id-2
SignatureConfig
Subpacket
SymEncryptedData
Symmetrically Encrypted Data Packet https://www.rfc-editor.org/rfc/rfc9580.html#name-symmetrically-encrypted-dat
SymEncryptedProtectedData
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
DataMode
Decompressor
OpsVersionSpecific
Version-specific elements of a One-Pass Signature Packet:
Packet
PublicKeyEncryptedSessionKey
Public Key Encrypted Session Key Packet (PKESK) https://www.rfc-editor.org/rfc/rfc9580.html#name-public-key-encrypted-sessio
RevocationCode
Codes for revocation reasons
SignatureType
SignatureVersion
SignatureVersionSpecific
SubpacketData
SubpacketType
Available signature subpacket types
SymKeyEncryptedSessionKey
Symmetric-Key Encrypted Session Key Packet https://www.rfc-editor.org/rfc/rfc9580.html#name-symmetric-key-encrypted-ses
UserAttribute
User Attribute Packet https://www.rfc-editor.org/rfc/rfc9580.html#name-user-attribute-packet-type-

Traits§

PacketTrait

Functions§

write_packet