Struct sequoia_openpgp::cert::raw::RawCert
source · pub struct RawCert<'a> { /* private fields */ }
Expand description
A mostly unparsed Cert
.
This data structure contains the unparsed packets for a certificate or key. The packet sequence is well formed in the sense that the sequence of tags conforms to the Transferable Public Key grammar or Transferable Secret Key grammar, and that it can extract the primary key’s fingerprint. Beyond that, the packets are not guaranteed to be valid.
This data structure exists to quickly split a large keyring, and only parse those certificates that appear to be relevant.
Implementations§
source§impl<'a> RawCert<'a>
impl<'a> RawCert<'a>
sourcepub fn as_bytes(&'a self) -> &'a [u8] ⓘ
pub fn as_bytes(&'a self) -> &'a [u8] ⓘ
Returns the certificate’s bytes.
If you want an individual packet’s bytes, use
RawCert::packet
or RawCert::packets
, and then call
RawPacket::as_bytes
.
sourcepub fn fingerprint(&self) -> Fingerprint
pub fn fingerprint(&self) -> Fingerprint
Returns the certificate’s fingerprint.
sourcepub fn packets(&self) -> impl Iterator<Item = RawPacket<'_>>
pub fn packets(&self) -> impl Iterator<Item = RawPacket<'_>>
Returns an iterator over each raw packet.
sourcepub fn keys(&self) -> KeyIter<'_, PublicParts, UnspecifiedRole> ⓘ
pub fn keys(&self) -> KeyIter<'_, PublicParts, UnspecifiedRole> ⓘ
Returns an iterator over the certificate’s keys.
Note: this parses the key packets, but it does not verify any
binding signatures. As such, this can only be used as part of
a precheck. If the certificate appears to match, then the
caller must convert the RawCert
to a Cert
or a
ValidCert
, depending on the requirements, and perform the
check again.
Use subkeys
to just return the subkeys. This function
also changes the return type. Instead of the iterator
returning a Key
whose role is key::UnspecifiedRole
,
the role is key::SubordinateRole
.
§Examples
use sequoia_openpgp as openpgp;
use openpgp::cert::raw::RawCertParser;
use openpgp::parse::Parse;
for cert in RawCertParser::from_bytes(&bytes)? {
/// Ignore corrupt and invalid certificates.
let cert = if let Ok(cert) = cert {
cert
} else {
continue;
};
// Iterate over the keys. Note: this parses the Key
// packets.
for key in cert.keys() {
println!("{}", key.fingerprint());
}
}
sourcepub fn primary_key(&self) -> Key<PublicParts, PrimaryRole>
pub fn primary_key(&self) -> Key<PublicParts, PrimaryRole>
Returns the certificate’s primary key.
Note: this parses the primary key packet, but it does not
verify any binding signatures. As such, this can only be used
as part of a precheck. If the certificate appears to match,
then the caller must convert the RawCert
to a Cert
or
a ValidCert
, depending on the requirements, and perform
the check again.
sourcepub fn userids(&self) -> impl Iterator<Item = UserID> + '_
pub fn userids(&self) -> impl Iterator<Item = UserID> + '_
Returns the certificate’s User IDs.
Note: this parses the User ID packets, but it does not verify
any binding signatures. That is, there is no guarantee that
the User IDs should actually be associated with the primary
key. As such, this can only be used as part of a precheck.
If a User ID appears to match, then the caller must convert
the RawCert
to a Cert
or a ValidCert
, depending on
the requirements, and perform the check again.
Trait Implementations§
source§impl<'a> Parse<'a, RawCert<'a>> for RawCert<'a>
impl<'a> Parse<'a, RawCert<'a>> for RawCert<'a>
source§fn from_buffered_reader<R>(reader: R) -> Result<RawCert<'a>>where
R: BufferedReader<Cookie> + 'a,
fn from_buffered_reader<R>(reader: R) -> Result<RawCert<'a>>where
R: BufferedReader<Cookie> + 'a,
Returns the first RawCert encountered in the reader.
Returns an error if there are multiple certificates.
source§impl<'a> PartialEq for RawCert<'a>
impl<'a> PartialEq for RawCert<'a>
impl<'a> Eq for RawCert<'a>
Auto Trait Implementations§
impl<'a> !Freeze for RawCert<'a>
impl<'a> RefUnwindSafe for RawCert<'a>
impl<'a> Send for RawCert<'a>
impl<'a> Sync for RawCert<'a>
impl<'a> Unpin for RawCert<'a>
impl<'a> UnwindSafe for RawCert<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)