logo
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

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.

Returns the certificate’s fingerprint.

Returns the certificate’s Key ID.

Returns the ith packet.

Returns an iterator over each raw packet.

Returns the number of packets.

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());
    }
}

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.

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Writes a serialized version of the object to o.

Exports a serialized version of the object to o. Read more

Returns the first RawCert encountered in the reader.

Returns an error if there are multiple certificates.

Reads from the given file. Read more

Reads from the given slice. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.