mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
refactor: use KeyPair::new() in create_keypair()
This commit is contained in:
19
src/pgp.rs
19
src/pgp.rs
@@ -14,9 +14,7 @@ use pgp::composed::{
|
||||
use pgp::crypto::ecc_curve::ECCCurve;
|
||||
use pgp::crypto::hash::HashAlgorithm;
|
||||
use pgp::crypto::sym::SymmetricKeyAlgorithm;
|
||||
use pgp::types::{
|
||||
CompressionAlgorithm, KeyTrait, Mpi, PublicKeyTrait, SecretKeyTrait, StringToKey,
|
||||
};
|
||||
use pgp::types::{CompressionAlgorithm, KeyTrait, Mpi, PublicKeyTrait, StringToKey};
|
||||
use rand::{thread_rng, CryptoRng, Rng};
|
||||
use tokio::runtime::Handle;
|
||||
|
||||
@@ -142,7 +140,6 @@ pub struct KeyPair {
|
||||
pub secret: SignedSecretKey,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
impl KeyPair {
|
||||
/// Creates new keypair from a secret key.
|
||||
///
|
||||
@@ -211,18 +208,12 @@ pub(crate) fn create_keypair(addr: EmailAddress, keygen_type: KeyGenType) -> Res
|
||||
.verify()
|
||||
.context("invalid secret key generated")?;
|
||||
|
||||
let public_key = secret_key
|
||||
.public_key()
|
||||
.sign(&secret_key, || "".into())
|
||||
.context("failed to sign public key")?;
|
||||
public_key
|
||||
let key_pair = KeyPair::new(secret_key)?;
|
||||
key_pair
|
||||
.public
|
||||
.verify()
|
||||
.context("invalid public key generated")?;
|
||||
|
||||
Ok(KeyPair {
|
||||
public: public_key,
|
||||
secret: secret_key,
|
||||
})
|
||||
Ok(key_pair)
|
||||
}
|
||||
|
||||
/// Select public key or subkey to use for encryption.
|
||||
|
||||
Reference in New Issue
Block a user