pub struct Subkey<'key> { /* private fields */ }Expand description
Borrowed handle to a subkey. Behaves like a Key via Deref.
Implementations§
Methods from Deref<Target = Key<'key>>§
Sourcepub fn export(&self, flags: ExportFlags) -> Result<Vec<u8>>
pub fn export(&self, flags: ExportFlags) -> Result<Vec<u8>>
Export this key as raw bytes. Pass ExportFlags::ARMORED for ASCII
armor, otherwise binary OpenPGP packets are produced.
pub fn raw_public_data(&self) -> Result<Vec<u8>>
pub fn raw_secret_data(&self) -> Result<Vec<u8>>
Sourcepub fn export_autocrypt(
&self,
subkey: Option<&Key<'_>>,
uid: Option<&str>,
flags: ExportFlags,
) -> Result<Vec<u8>>
pub fn export_autocrypt( &self, subkey: Option<&Key<'_>>, uid: Option<&str>, flags: ExportFlags, ) -> Result<Vec<u8>>
Export an Autocrypt-compatible form of this key (a single-UID
public key suitable for inclusion in email headers). subkey may
be None for the primary-only case.
Sourcepub fn export_revocation(
&self,
flags: ExportFlags,
reason: RevocationReason,
hash: Hash,
) -> Result<Vec<u8>>
pub fn export_revocation( &self, flags: ExportFlags, reason: RevocationReason, hash: Hash, ) -> Result<Vec<u8>>
Export a revocation certificate for this key. The hash algorithm
and revocation reason are configured by hash and reason; the
password (if needed) is obtained from the configured password
provider.
Sourcepub fn primary_uid(&self) -> Result<Option<String>>
pub fn primary_uid(&self) -> Result<Option<String>>
The key’s primary user id, if any.
Sourcepub fn bits(&self) -> Result<u32>
pub fn bits(&self) -> Result<u32>
Key size in bits. Returns 0 for curves where the concept doesn’t apply.
Sourcepub fn curve(&self) -> Result<Option<String>>
pub fn curve(&self) -> Result<Option<String>>
Curve name (e.g. "NIST P-256", "Ed25519"). Returns None if the
algorithm is not curve-based.
Sourcepub fn version(&self) -> Result<u32>
pub fn version(&self) -> Result<u32>
Key version (4 or 6 in current OpenPGP; legacy v3 possible).
Sourcepub fn expiration(&self) -> Result<u32>
pub fn expiration(&self) -> Result<u32>
Expiration in seconds from creation. 0 means no expiration.
Sourcepub fn fingerprint(&self) -> Result<String>
pub fn fingerprint(&self) -> Result<String>
Hex fingerprint (40 chars for v4 SHA-1, 64 for v6 SHA-256).
Sourcepub fn grip(&self) -> Result<String>
pub fn grip(&self) -> Result<String>
Hex key grip (librnp’s SHA-1-based identifier used for keyring lookups).
Sourcepub fn primary_fprint(&self) -> Result<Option<String>>
pub fn primary_fprint(&self) -> Result<Option<String>>
Fingerprint of the primary key that this subkey belongs to. None
if this is itself a primary.
Sourcepub fn primary_grip(&self) -> Result<Option<String>>
pub fn primary_grip(&self) -> Result<Option<String>>
Grip of the primary key that this subkey belongs to. None if this
is itself a primary.
Sourcepub fn allows_usage(&self, usage: KeyUsage) -> Result<bool>
pub fn allows_usage(&self, usage: KeyUsage) -> Result<bool>
Key usage flags word (ORed RNP_KEY_USAGE_* constants). Use
Self::allows_usage to test individual usages.
pub fn have_secret(&self) -> Result<bool>
pub fn have_public(&self) -> Result<bool>
pub fn is_primary(&self) -> Result<bool>
pub fn is_sub(&self) -> Result<bool>
pub fn is_valid(&self) -> Result<bool>
pub fn is_revoked(&self) -> Result<bool>
pub fn is_locked(&self) -> Result<bool>
Sourcepub fn is_compromised(&self) -> Result<bool>
pub fn is_compromised(&self) -> Result<bool>
True if the key was revoked with a “key compromised” reason code.
Wraps rnp_key_is_compromised. Upstream reports
RNP_ERROR_BAD_PARAMETERS for keys that are not revoked at all;
that case is reported as Ok(false) — the answer to “was it
compromised?” is simply no.
Sourcepub fn is_retired(&self) -> Result<bool>
pub fn is_retired(&self) -> Result<bool>
True if the key was retired (revocation reason “no longer used”).
Wraps rnp_key_is_retired; see Self::is_compromised for the
not-revoked mapping.
Sourcepub fn is_superseded(&self) -> Result<bool>
pub fn is_superseded(&self) -> Result<bool>
True if the key was superseded (revocation reason “superseded by
another key”). Wraps rnp_key_is_superseded; see
Self::is_compromised for the not-revoked mapping.
Sourcepub fn uid_string_at(&self, idx: usize) -> Result<Option<String>>
pub fn uid_string_at(&self, idx: usize) -> Result<Option<String>>
The userid string at idx, without going through a Uid handle
(the handle-returning variant is Self::uid_at). None when
idx is out of range. Wraps rnp_key_get_uid_at.
Sourcepub fn revocation_signature(&self) -> Result<Option<Signature<'_>>>
pub fn revocation_signature(&self) -> Result<Option<Signature<'_>>>
The key’s direct revocation signature, if the key is revoked.
Wraps rnp_key_get_revocation_signature.
pub fn is_protected(&self) -> Result<bool>
Sourcepub fn valid_till(&self) -> Result<u32>
pub fn valid_till(&self) -> Result<u32>
Last time the key is valid, as a 32-bit seconds-since-epoch. Returns
u32::MAX if the key never expires.
Sourcepub fn valid_till64(&self) -> Result<u64>
pub fn valid_till64(&self) -> Result<u64>
Same as Self::valid_till but 64-bit (y2038-safe).
Sourcepub fn is_expired(&self) -> Result<bool>
pub fn is_expired(&self) -> Result<bool>
Whether the key’s validity window has passed, as computed by
librnp itself (accounts for self-signature expiry, not just the
expiration field). Wraps rnp_key_is_expired.
pub fn protection_type(&self) -> Result<String>
pub fn protection_mode(&self) -> Result<String>
pub fn protection_cipher(&self) -> Result<String>
pub fn protection_hash(&self) -> Result<String>
pub fn protection_iterations(&self) -> Result<usize>
Sourcepub fn revocation_reason(&self) -> Result<Option<String>>
pub fn revocation_reason(&self) -> Result<Option<String>>
Textual reason for the key’s revocation, if any.
Sourcepub fn revoker_count(&self) -> Result<usize>
pub fn revoker_count(&self) -> Result<usize>
Number of revokers (third-party keys authorized to revoke this key).
Sourcepub fn revoker_at(&self, idx: usize) -> Result<String>
pub fn revoker_at(&self, idx: usize) -> Result<String>
Revocation key specification at idx (a string of the form
"1:FINGERPRINT").
pub fn is_25519_bits_tweaked(&self) -> Result<bool>
pub fn uid_count(&self) -> Result<usize>
pub fn uid_at(&self, idx: usize) -> Result<Option<Uid<'_>>>
pub fn uids(&self) -> Result<Vec<Uid<'_>>>
pub fn subkey_count(&self) -> Result<usize>
pub fn subkey_at(&self, idx: usize) -> Result<Option<Subkey<'_>>>
pub fn subkeys(&self) -> Result<Vec<Subkey<'_>>>
pub fn signature_count(&self) -> Result<usize>
pub fn signature_at(&self, idx: usize) -> Result<Option<Signature<'_>>>
pub fn signatures(&self) -> Result<Vec<Signature<'_>>>
Sourcepub fn default_key_for(&self, usage: KeyUsage) -> Result<Option<Key<'_>>>
pub fn default_key_for(&self, usage: KeyUsage) -> Result<Option<Key<'_>>>
Find the default subkey for a given usage. Returns None if no
subkey is suitable. Wraps rnp_key_get_default_key.
pub fn to_json(&self, flags: JsonFlags) -> Result<String>
pub fn packets_to_json( &self, secret: bool, flags: JsonDumpFlags, ) -> Result<String>
Sourcepub fn protect(&self, options: &ProtectOptions) -> Result<()>
pub fn protect(&self, options: &ProtectOptions) -> Result<()>
Protect (encrypt) the secret material with options.password.
Sourcepub fn unprotect(&self, password: Option<&str>) -> Result<()>
pub fn unprotect(&self, password: Option<&str>) -> Result<()>
Remove the secret-key protection. password is required if the key
is protected; pass None to use the configured password provider.
Sourcepub fn lock(&self) -> Result<()>
pub fn lock(&self) -> Result<()>
Lock the key — discard the in-memory decrypted secret material.
Sourcepub fn unlock(&self, password: Option<&str>) -> Result<()>
pub fn unlock(&self, password: Option<&str>) -> Result<()>
Unlock the key (decrypt secret material in memory).
Sourcepub fn add_uid(&self, uid: &str, options: &AddUidOptions) -> Result<()>
pub fn add_uid(&self, uid: &str, options: &AddUidOptions) -> Result<()>
Add a user ID to this key. The key must be unlocked if protected.
Sourcepub fn revoke(&self, reason: RevocationReason, hash: Hash) -> Result<()>
pub fn revoke(&self, reason: RevocationReason, hash: Hash) -> Result<()>
Revoke this key. The hash algorithm and reason are configured; if the secret key is locked, the password is obtained from the password provider.
Sourcepub fn set_expiration(&self, seconds: u32) -> Result<()>
pub fn set_expiration(&self, seconds: u32) -> Result<()>
Update the key’s expiration. seconds is from creation. Requires
an unlocked key.
Sourcepub fn remove(&self, flags: RemoveFlags) -> Result<()>
pub fn remove(&self, flags: RemoveFlags) -> Result<()>
Remove the key from its keyring.
Sourcepub fn remove_signatures(&self, flags: RemoveSignaturesFlags) -> Result<()>
pub fn remove_signatures(&self, flags: RemoveSignaturesFlags) -> Result<()>
Remove signatures matching flags. The optional callback is not
surfaced — callers can re-inspect remaining signatures after the call.
Sourcepub fn set_25519_bits_tweak(&self) -> Result<()>
pub fn set_25519_bits_tweak(&self) -> Result<()>
Apply the v6 25519 bit-tweak (HKP fingerprint masking).