Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ keywords = ["cryptography"]
categories = ["cryptography"] # https://crates.io/category_slugs

[dependencies]
bc-rand = "^0.4.0"
rand = "^0.8.5"
sha2 = "^0.10.6"
hmac = "^0.12.1"
pbkdf2 = "^0.12.1"
hkdf = "^0.12.3"
bc-rand = { git = "https://github.com/willrnch/bc-rand-rust.git", rev = "f6c187b211a39f159567fc6981d1676f015f88d7" }
rand = "^0.9.2"
sha2 = "0.11.0-rc.2"
hmac = "0.13.0-rc.1"
pbkdf2 = "0.13.0-rc.1"
hkdf = "0.13.0-rc.1"
crc32fast = "^1.3.2"
chacha20poly1305 = "^0.10.1"
chacha20poly1305 = "0.11.0-rc.1"
secp256k1 = "^0.30.0"
x25519-dalek = { version = "2.0.0-rc.2", features = ["static_secrets"] }
x25519-dalek = { version = "3.0.0-pre.1", features = ["static_secrets"] }
thiserror = "^2.0"
hex = "^0.4.3"
ed25519-dalek = { version = "2.1.1", features = ["rand_core"] }
ed25519-dalek = { version = "3.0.0-pre.1", features = ["rand_core"] }
scrypt = { version = "0.11.0", default-features = false }
argon2 = "0.5.3"
argon2 = "0.6.0-rc.1"

[dev-dependencies]
hex-literal = "^0.4.1"
hex-literal = "^1.0.0"
hex = "^0.4.3"
version-sync = "^0.9"
4 changes: 2 additions & 2 deletions src/ed25519_signing.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use chacha20poly1305::aead::rand_core::CryptoRngCore;
use ed25519_dalek::ed25519::signature::Signer;
use ed25519_dalek::SigningKey;
use ed25519_dalek::Signature;
use rand::CryptoRng;

pub const ED25519_PUBLIC_KEY_SIZE: usize = ed25519_dalek::PUBLIC_KEY_LENGTH;
pub const ED25519_PRIVATE_KEY_SIZE: usize = ed25519_dalek::SECRET_KEY_LENGTH;
pub const ED25519_SIGNATURE_SIZE: usize = ed25519_dalek::SIGNATURE_LENGTH;

pub fn ed25519_new_private_key_using(rng: &mut impl CryptoRngCore) -> [u8; ED25519_PRIVATE_KEY_SIZE] {
pub fn ed25519_new_private_key_using(rng: &mut impl CryptoRng) -> [u8; ED25519_PRIVATE_KEY_SIZE] {
SigningKey::generate(rng).to_bytes()
}

Expand Down
2 changes: 1 addition & 1 deletion src/hash.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use sha2::{Digest, Sha256, Sha512};
use hmac::{Hmac, Mac};
use hmac::{Hmac, KeyInit, Mac};
use pbkdf2::pbkdf2_hmac;
use hkdf::Hkdf;

Expand Down
7 changes: 4 additions & 3 deletions src/symmetric_encryption.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use chacha20poly1305::{ChaCha20Poly1305, KeyInit, AeadInPlace};
use chacha20poly1305::{AeadInOut, ChaCha20Poly1305, KeyInit};

use crate::Result;

pub const SYMMETRIC_KEY_SIZE: usize = 32;
Expand All @@ -17,7 +18,7 @@ pub fn aead_chacha20_poly1305_encrypt_with_aad(
) -> (Vec<u8>, [u8; SYMMETRIC_AUTH_SIZE]) {
let cipher = ChaCha20Poly1305::new(key.into());
let mut buffer = plaintext.as_ref().to_vec();
let auth = cipher.encrypt_in_place_detached(nonce.into(), aad.as_ref(), &mut buffer).unwrap();
let auth = cipher.encrypt_inout_detached(nonce.into(), aad.as_ref(), buffer.as_mut_slice().into()).unwrap();
(buffer, auth.to_vec().try_into().unwrap())
}

Expand Down Expand Up @@ -49,7 +50,7 @@ pub fn aead_chacha20_poly1305_decrypt_with_aad<D1, D2>(
{
let cipher = ChaCha20Poly1305::new(key.into());
let mut buffer = ciphertext.as_ref().to_vec();
cipher.decrypt_in_place_detached(nonce.into(), aad.as_ref(), &mut buffer, auth.into())?;
cipher.decrypt_inout_detached(nonce.into(), aad.as_ref(), buffer.as_mut_slice().into(), auth.into())?;
Ok(buffer)
}

Expand Down