pub struct Signature {
pub config: SignatureConfig,
pub signed_hash_value: [u8; 2],
pub signature: SignatureBytes,
/* private fields */
}
Expand description
Fields§
§config: SignatureConfig
§signed_hash_value: [u8; 2]
§signature: SignatureBytes
Implementations§
Source§impl Signature
impl Signature
Sourcepub fn from_slice(packet_version: Version, input: &[u8]) -> Result<Self>
pub fn from_slice(packet_version: Version, input: &[u8]) -> Result<Self>
Parses a Signature
packet from the given slice.
Source§impl Signature
impl Signature
Sourcepub fn v2(
packet_version: Version,
typ: SignatureType,
pub_alg: PublicKeyAlgorithm,
hash_alg: HashAlgorithm,
created: DateTime<Utc>,
issuer: KeyId,
signed_hash_value: [u8; 2],
signature: SignatureBytes,
) -> Self
pub fn v2( packet_version: Version, typ: SignatureType, pub_alg: PublicKeyAlgorithm, hash_alg: HashAlgorithm, created: DateTime<Utc>, issuer: KeyId, signed_hash_value: [u8; 2], signature: SignatureBytes, ) -> Self
Constructor for an OpenPGP v2 signature packet. Note: This is a historical packet version!
Sourcepub fn v3(
packet_version: Version,
typ: SignatureType,
pub_alg: PublicKeyAlgorithm,
hash_alg: HashAlgorithm,
created: DateTime<Utc>,
issuer: KeyId,
signed_hash_value: [u8; 2],
signature: SignatureBytes,
) -> Self
pub fn v3( packet_version: Version, typ: SignatureType, pub_alg: PublicKeyAlgorithm, hash_alg: HashAlgorithm, created: DateTime<Utc>, issuer: KeyId, signed_hash_value: [u8; 2], signature: SignatureBytes, ) -> Self
Constructor for an OpenPGP v3 signature packet. Note: This is a historical packet version!
Sourcepub fn v4(
packet_version: Version,
typ: SignatureType,
pub_alg: PublicKeyAlgorithm,
hash_alg: HashAlgorithm,
signed_hash_value: [u8; 2],
signature: SignatureBytes,
hashed_subpackets: Vec<Subpacket>,
unhashed_subpackets: Vec<Subpacket>,
) -> Self
pub fn v4( packet_version: Version, typ: SignatureType, pub_alg: PublicKeyAlgorithm, hash_alg: HashAlgorithm, signed_hash_value: [u8; 2], signature: SignatureBytes, hashed_subpackets: Vec<Subpacket>, unhashed_subpackets: Vec<Subpacket>, ) -> Self
Constructor for an OpenPGP v4 signature packet.
OpenPGP v4 signatures are typically used with OpenPGP v4 keys, as specified in RFC 9580 (and formerly in 4880 and 2440).
Sourcepub fn v6(
packet_version: Version,
typ: SignatureType,
pub_alg: PublicKeyAlgorithm,
hash_alg: HashAlgorithm,
signed_hash_value: [u8; 2],
signature: SignatureBytes,
hashed_subpackets: Vec<Subpacket>,
unhashed_subpackets: Vec<Subpacket>,
salt: Vec<u8>,
) -> Self
pub fn v6( packet_version: Version, typ: SignatureType, pub_alg: PublicKeyAlgorithm, hash_alg: HashAlgorithm, signed_hash_value: [u8; 2], signature: SignatureBytes, hashed_subpackets: Vec<Subpacket>, unhashed_subpackets: Vec<Subpacket>, salt: Vec<u8>, ) -> Self
Constructor for an OpenPGP v6 signature packet.
OpenPGP v6 signatures are specified in RFC 9580 and only used with OpenPGP v6 keys.
pub fn from_config( config: SignatureConfig, signed_hash_value: [u8; 2], signature: SignatureBytes, ) -> Self
Sourcepub fn typ(&self) -> SignatureType
pub fn typ(&self) -> SignatureType
Returns what kind of signature this is.
Sourcepub fn hash_alg(&self) -> HashAlgorithm
pub fn hash_alg(&self) -> HashAlgorithm
The used HashAlgorithm
.
Sourcepub fn verify<R>(&self, key: &impl PublicKeyTrait, data: R) -> Result<()>where
R: Read,
pub fn verify<R>(&self, key: &impl PublicKeyTrait, data: R) -> Result<()>where
R: Read,
Verify this signature.
Sourcepub fn verify_certification(
&self,
key: &impl PublicKeyTrait,
tag: Tag,
id: &impl Serialize,
) -> Result<()>
pub fn verify_certification( &self, key: &impl PublicKeyTrait, tag: Tag, id: &impl Serialize, ) -> Result<()>
Verifies a certification signature type (for self-signatures).
Sourcepub fn verify_third_party_certification(
&self,
signee: &impl PublicKeyTrait,
signer: &impl PublicKeyTrait,
tag: Tag,
id: &impl Serialize,
) -> Result<()>
pub fn verify_third_party_certification( &self, signee: &impl PublicKeyTrait, signer: &impl PublicKeyTrait, tag: Tag, id: &impl Serialize, ) -> Result<()>
Verifies a certification signature type (for third-party signatures).
Sourcepub fn verify_key_binding(
&self,
signing_key: &impl PublicKeyTrait,
key: &impl PublicKeyTrait,
) -> Result<()>
pub fn verify_key_binding( &self, signing_key: &impl PublicKeyTrait, key: &impl PublicKeyTrait, ) -> Result<()>
Verifies a key binding (which binds a subkey to the primary key).
“Subkey Binding Signature (type ID 0x18)”
Sourcepub fn verify_backwards_key_binding(
&self,
signing_key: &impl PublicKeyTrait,
key: &impl PublicKeyTrait,
) -> Result<()>
pub fn verify_backwards_key_binding( &self, signing_key: &impl PublicKeyTrait, key: &impl PublicKeyTrait, ) -> Result<()>
Verifies a primary key binding signature, or “back signature” (which links the primary to a signing subkey).
“Primary Key Binding Signature (type ID 0x19)”
Sourcepub fn verify_key(&self, key: &impl PublicKeyTrait) -> Result<()>
pub fn verify_key(&self, key: &impl PublicKeyTrait) -> Result<()>
Verifies a direct key signature or a revocation.
Sourcepub fn is_certification(&self) -> bool
pub fn is_certification(&self) -> bool
Returns if the signature is a certification or not.
pub fn key_expiration_time(&self) -> Option<&Duration>
pub fn signature_expiration_time(&self) -> Option<&Duration>
pub fn created(&self) -> Option<&DateTime<Utc>>
pub fn issuer(&self) -> Vec<&KeyId>
pub fn issuer_fingerprint(&self) -> Vec<&Fingerprint>
pub fn preferred_symmetric_algs(&self) -> &[SymmetricKeyAlgorithm]
pub fn preferred_aead_algs(&self) -> &[(SymmetricKeyAlgorithm, AeadAlgorithm)]
pub fn preferred_hash_algs(&self) -> &[HashAlgorithm]
pub fn preferred_compression_algs(&self) -> &[CompressionAlgorithm]
pub fn key_server_prefs(&self) -> &[u8] ⓘ
pub fn key_flags(&self) -> KeyFlags
pub fn features(&self) -> &[u8] ⓘ
pub fn revocation_reason_code(&self) -> Option<&RevocationCode>
pub fn revocation_reason_string(&self) -> Option<&BStr>
pub fn is_primary(&self) -> bool
pub fn is_revocable(&self) -> bool
pub fn embedded_signature(&self) -> Option<&Signature>
pub fn preferred_key_server(&self) -> Option<&str>
pub fn notations(&self) -> Vec<&Notation>
pub fn revocation_key(&self) -> Option<&RevocationKey>
Sourcepub fn signers_userid(&self) -> Option<&BStr>
pub fn signers_userid(&self) -> Option<&BStr>
Gets the user id of the signer
Note that the user id may not be valid utf-8, if it was created using a different encoding. But since the RFC describes every text as utf-8 it is up to the caller whether to error on non utf-8 data.