Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
OnkelDe authored Jun 22, 2024
1 parent 67e1463 commit dae3404
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ sudo apt-get install libssl-dev
## Usage:

Dependencies
[dependencies]
yubikey = "0.5"
base64 = "0.13"
openssl = "0.10"
rsa = "0.5"
sha2 = "0.9"
tracing = "0.1"
x509-cert = "0.5"

To use the cryptographic functionalities, ensure you have the following dependencies in your Cargo.toml:

Expand All @@ -49,7 +57,7 @@ This module provides cryptographic operations for asymmetric keys on a YubiKey,

First, ensure you have a `YubiKeyProvider` instance initialized. This example assumes that you have a YubiKey device connected and appropriate libraries installed.

```rust

let yubi_key_provider = YubiKeyProvider {
yubikey: Some(Arc::new(Mutex::new(Yubikey::new()))),
key_algo: Some(AsymmetricEncryption::Rsa(KeyBits::Bits2048)),
Expand All @@ -58,6 +66,7 @@ let yubi_key_provider = YubiKeyProvider {
slot_id: Some(20),
};

# Sign Data
To sign data using the YubiKey:
let data = b"Hello, world!";
let signature = yubi_key_provider.sign_data(data);
Expand All @@ -66,7 +75,7 @@ match signature {
Err(e) => println!("Error signing data: {:?}", e),
}

Decrypting Data
# Decrypting Data
To decrypt data that was previously encrypted with the corresponding public key:
let encrypted_data = vec![...]; // Your encrypted data here
let decrypted_data = yubi_key_provider.decrypt_data(&encrypted_data);
Expand All @@ -75,7 +84,7 @@ match decrypted_data {
Err(e) => println!("Error decrypting data: {:?}", e),
}

Encrypting Data
# Encrypting Data
To encrypt data using the YubiKey:
let data = b"Secure this!";
let encrypted_data = yubi_key_provider.encrypt_data(data);
Expand All @@ -84,7 +93,7 @@ match encrypted_data {
Err(e) => println!("Error encrypting data: {:?}", e),
}

Verifying a Signature
# Verifying a Signature
To verify a signature against the original data:
let original_data = b"Hello, world!";
let signature = vec![...]; // Your signature here
Expand Down

0 comments on commit dae3404

Please sign in to comment.