[−][src]Struct sequoia_openpgp::packet::key::Key4
Holds a public key, public subkey, private key or private subkey packet.
See Section 5.5 of RFC 4880 for details.
Methods
impl Key4
[src]
pub fn public_cmp(a: &Self, b: &Self) -> Ordering
[src]
Compares the public bits of two keys.
This returns Ordering::Equal if the public MPIs,
creation time and algorithm of the two Key4
s match. This
does not consider the packet's encoding, packet's tag or the
secret key material.
impl Key4
[src]
pub fn new(
creation_time: Tm,
pk_algo: PublicKeyAlgorithm,
mpis: PublicKey,
secret: Option<SecretKey>
) -> Result<Self>
[src]
creation_time: Tm,
pk_algo: PublicKeyAlgorithm,
mpis: PublicKey,
secret: Option<SecretKey>
) -> Result<Self>
Creates a new OpenPGP key packet.
pub fn import_public_cv25519<H, S, T>(
public_key: &[u8],
hash: H,
sym: S,
ctime: T
) -> Result<Self> where
H: Into<Option<HashAlgorithm>>,
S: Into<Option<SymmetricAlgorithm>>,
T: Into<Option<Tm>>,
[src]
public_key: &[u8],
hash: H,
sym: S,
ctime: T
) -> Result<Self> where
H: Into<Option<HashAlgorithm>>,
S: Into<Option<SymmetricAlgorithm>>,
T: Into<Option<Tm>>,
Creates a new OpenPGP public key packet for an existing X25519 key.
The ECDH key will use hash algorithm hash
and symmetric
algorithm sym
. If one or both are None
secure defaults
will be used. The key will have it's creation date set to
ctime
or the current time if None
is given.
pub fn import_secret_cv25519<H, S, T>(
private_key: &[u8],
hash: H,
sym: S,
ctime: T
) -> Result<Self> where
H: Into<Option<HashAlgorithm>>,
S: Into<Option<SymmetricAlgorithm>>,
T: Into<Option<Tm>>,
[src]
private_key: &[u8],
hash: H,
sym: S,
ctime: T
) -> Result<Self> where
H: Into<Option<HashAlgorithm>>,
S: Into<Option<SymmetricAlgorithm>>,
T: Into<Option<Tm>>,
Creates a new OpenPGP secret key packet for an existing X25519 key.
The ECDH key will use hash algorithm hash
and symmetric
algorithm sym
. If one or both are None
secure defaults
will be used. The key will have it's creation date set to
ctime
or the current time if None
is given.
pub fn import_public_ed25519<T>(public_key: &[u8], ctime: T) -> Result<Self> where
T: Into<Option<Tm>>,
[src]
T: Into<Option<Tm>>,
Creates a new OpenPGP public key packet for an existing Ed25519 key.
The ECDH key will use hash algorithm hash
and symmetric
algorithm sym
. If one or both are None
secure defaults
will be used. The key will have it's creation date set to
ctime
or the current time if None
is given.
pub fn import_secret_ed25519<T>(private_key: &[u8], ctime: T) -> Result<Self> where
T: Into<Option<Tm>>,
[src]
T: Into<Option<Tm>>,
Creates a new OpenPGP secret key packet for an existing Ed25519 key.
The ECDH key will use hash algorithm hash
and symmetric
algorithm sym
. If one or both are None
secure defaults
will be used. The key will have it's creation date set to
ctime
or the current time if None
is given.
pub fn import_public_rsa<T>(e: &[u8], n: &[u8], ctime: T) -> Result<Self> where
T: Into<Option<Tm>>,
[src]
T: Into<Option<Tm>>,
Creates a new OpenPGP public key packet for an existing RSA key.
The RSA key will use public exponent e
and modulo n
. The key will
have it's creation date set to ctime
or the current time if None
is given.
pub fn import_secret_rsa<T>(
d: &[u8],
p: &[u8],
q: &[u8],
ctime: T
) -> Result<Self> where
T: Into<Option<Tm>>,
[src]
d: &[u8],
p: &[u8],
q: &[u8],
ctime: T
) -> Result<Self> where
T: Into<Option<Tm>>,
Creates a new OpenPGP public key packet for an existing RSA key.
The RSA key will use public exponent e
and modulo n
. The key will
have it's creation date set to ctime
or the current time if None
is given.
pub fn generate_rsa(bits: usize) -> Result<Self>
[src]
Generates a new RSA key with a public modulos of size bits
.
pub fn generate_ecc(for_signing: bool, curve: Curve) -> Result<Self>
[src]
Generates a new ECC key over curve
.
If for_signing
is false a ECDH key, if it's true either a
EdDSA or ECDSA key is generated. Giving for_signing == true
and curve == Cv25519
will produce an error. Similar for
for_signing == false
and curve == Ed25519
.
signing/encryption
pub fn creation_time(&self) -> &Tm
[src]
Gets the key packet's creation time field.
pub fn set_creation_time(&mut self, timestamp: Tm) -> Tm
[src]
Sets the key packet's creation time field.
pub fn pk_algo(&self) -> PublicKeyAlgorithm
[src]
Gets the public key algorithm.
pub fn set_pk_algo(&mut self, pk_algo: PublicKeyAlgorithm) -> PublicKeyAlgorithm
[src]
Sets the public key algorithm.
pub fn mpis(&self) -> &PublicKey
[src]
Gets the key packet's MPIs.
pub fn mpis_mut(&mut self) -> &mut PublicKey
[src]
Gets a mutable reference to the key packet's MPIs.
pub fn set_mpis(&mut self, mpis: PublicKey) -> PublicKey
[src]
Sets the key packet's MPIs.
pub fn secret(&self) -> Option<&SecretKey>
[src]
Gets the key packet's SecretKey.
pub fn secret_mut(&mut self) -> Option<&mut SecretKey>
[src]
Gets a mutable reference to the key packet's SecretKey.
pub fn set_secret(&mut self, secret: Option<SecretKey>) -> Option<SecretKey>
[src]
Sets the key packet's SecretKey.
Returns the old value.
pub fn fingerprint(&self) -> Fingerprint
[src]
Computes and returns the key's fingerprint as per Section 12.2 of RFC 4880.
pub fn keyid(&self) -> KeyID
[src]
Computes and returns the key's key ID as per Section 12.2 of RFC 4880.
pub fn into_packet(self, tag: Tag) -> Result<Packet>
[src]
Convert the Key
struct to a Packet
.
pub fn into_keypair(self) -> Result<KeyPair>
[src]
Converts this packet with an unencrypted secret key into a KeyPair
.
Errors
Fails if the secret key is missing, or encrypted.
Trait Implementations
impl Clone for Key4
[src]
impl Debug for Key4
[src]
impl Display for Key4
[src]
impl Eq for Key4
[src]
impl From<Key4> for Key
[src]
impl Hash for Key4
[src]
impl Hash for Key4
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl PartialEq<Key4> for Key4
[src]
impl Serialize for Key4
[src]
impl SerializeInto for Key4
[src]
fn serialized_len(&self) -> usize
[src]
fn serialize_into(&self, buf: &mut [u8]) -> Result<usize>
[src]
fn to_vec(&self) -> Result<Vec<u8>>
[src]
impl StructuralEq for Key4
[src]
impl StructuralPartialEq for Key4
[src]
Auto Trait Implementations
impl !RefUnwindSafe for Key4
impl Send for Key4
impl !Sync for Key4
impl Unpin for Key4
impl !UnwindSafe for Key4
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,