feat: add rpgp-demo
This commit is contained in:
@@ -19,8 +19,10 @@ Project or files:
|
|||||||
├── __cpu
|
├── __cpu
|
||||||
│ └── x86
|
│ └── x86
|
||||||
├── __crypto
|
├── __crypto
|
||||||
|
│ ├── aes_gcm_crypto
|
||||||
│ ├── btc-address
|
│ ├── btc-address
|
||||||
│ ├── crypto
|
│ ├── crypto
|
||||||
|
│ ├── crypto2-demo
|
||||||
│ ├── curve25519
|
│ ├── curve25519
|
||||||
│ ├── efficient_sm2
|
│ ├── efficient_sm2
|
||||||
│ ├── highwayhash
|
│ ├── highwayhash
|
||||||
@@ -31,6 +33,7 @@ Project or files:
|
|||||||
│ ├── pwhash
|
│ ├── pwhash
|
||||||
│ ├── random
|
│ ├── random
|
||||||
│ ├── ring
|
│ ├── ring
|
||||||
|
│ ├── rpgp-demo
|
||||||
│ ├── rsa
|
│ ├── rsa
|
||||||
│ ├── secp256k1
|
│ ├── secp256k1
|
||||||
│ ├── shamir-demo
|
│ ├── shamir-demo
|
||||||
@@ -264,6 +267,6 @@ Project or files:
|
|||||||
├── vec.rs
|
├── vec.rs
|
||||||
└── while.rs
|
└── while.rs
|
||||||
|
|
||||||
233 directories, 39 files
|
236 directories, 39 files
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
1204
__crypto/rpgp-demo/Cargo.lock
generated
Normal file
1204
__crypto/rpgp-demo/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
10
__crypto/rpgp-demo/Cargo.toml
Normal file
10
__crypto/rpgp-demo/Cargo.toml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
[package]
|
||||||
|
name = "rpgp-demo"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
pgp = "0.9.0"
|
||||||
|
smallvec = "1.10.0"
|
||||||
34
__crypto/rpgp-demo/src/main.rs
Normal file
34
__crypto/rpgp-demo/src/main.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
// use pgp::composed::{key::SecretKeyParamsBuilder, KeyDetails, KeyType, SecretKey, SecretSubkey};
|
||||||
|
// use pgp::packet::{KeyFlags, UserAttribute, UserId};
|
||||||
|
// use pgp::types::{CompressionAlgorithm, PublicKeyTrait, SecretKeyTrait};
|
||||||
|
use pgp::composed::{key::SecretKeyParamsBuilder, KeyType};
|
||||||
|
use pgp::crypto::{hash::HashAlgorithm, sym::SymmetricKeyAlgorithm};
|
||||||
|
use pgp::types::{CompressionAlgorithm, SecretKeyTrait};
|
||||||
|
use smallvec::*;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let mut key_params = SecretKeyParamsBuilder::default();
|
||||||
|
key_params
|
||||||
|
.key_type(KeyType::Rsa(2048))
|
||||||
|
.can_create_certificates(false)
|
||||||
|
.can_sign(true)
|
||||||
|
.primary_user_id("Me <me@example.com>".into())
|
||||||
|
.preferred_symmetric_algorithms(smallvec![
|
||||||
|
SymmetricKeyAlgorithm::AES256,
|
||||||
|
])
|
||||||
|
.preferred_hash_algorithms(smallvec![
|
||||||
|
HashAlgorithm::SHA2_256,
|
||||||
|
])
|
||||||
|
.preferred_compression_algorithms(smallvec![
|
||||||
|
CompressionAlgorithm::ZLIB,
|
||||||
|
]);
|
||||||
|
let secret_key_params = key_params.build().expect("Must be able to create secret key params");
|
||||||
|
let secret_key = secret_key_params.generate().expect("Failed to generate a plain key.");
|
||||||
|
let passwd_fn = || String::new();
|
||||||
|
let signed_secret_key = secret_key.sign(passwd_fn).expect("Must be able to sign its own metadata");
|
||||||
|
let public_key = signed_secret_key.public_key();
|
||||||
|
|
||||||
|
// println!("{:?}", secret_key);
|
||||||
|
println!("{:?}", signed_secret_key);
|
||||||
|
println!("{:?}", public_key);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user