File tree Expand file tree Collapse file tree 4 files changed +26
-22
lines changed Expand file tree Collapse file tree 4 files changed +26
-22
lines changed Original file line number Diff line number Diff line change @@ -12,23 +12,23 @@ keywords = ["cryptography"]
1212categories = [" cryptography" ] # https://crates.io/category_slugs
1313
1414[dependencies ]
15- bc-rand = " ^0.4.1 "
16- rand = " ^0.8.5 "
17- sha2 = " ^0.10.6 "
18- hmac = " ^0.12 .1"
19- pbkdf2 = " ^0.12 .1"
20- hkdf = " ^0.12.3 "
15+ bc-rand = { git = " https://github.com/willrnch/bc-rand-rust.git " , rev = " 4013ca45388a9bc1c8ca822ba09b551886857e31 " }
16+ rand = " ^0.9.2 "
17+ sha2 = " 0.11.0-rc.2 "
18+ hmac = " 0.13.0-rc .1"
19+ pbkdf2 = " 0.13.0-rc .1"
20+ hkdf = " 0.13.0-rc.1 "
2121crc32fast = " ^1.3.2"
22- chacha20poly1305 = " ^0.10 .1"
22+ chacha20poly1305 = " 0.11.0-rc .1"
2323secp256k1 = " ^0.30.0"
24- x25519-dalek = { version = " 2 .0.0-rc.2 " , features = [" static_secrets" ] }
24+ x25519-dalek = { version = " 3 .0.0-pre.1 " , features = [" static_secrets" ] }
2525thiserror = " ^2.0"
2626hex = " ^0.4.3"
27- ed25519-dalek = { version = " 2.1 .1" , features = [" rand_core" ] }
27+ ed25519-dalek = { version = " 3.0.0-pre .1" , features = [" rand_core" ] }
2828scrypt = { version = " 0.11.0" , default-features = false }
29- argon2 = " 0.5.3 "
29+ argon2 = " 0.6.0-rc.1 "
3030
3131[dev-dependencies ]
32- hex-literal = " ^0.4.1 "
32+ hex-literal = " ^1.0.0 "
3333hex = " ^0.4.3"
3434version-sync = " ^0.9"
Original file line number Diff line number Diff line change 1- use chacha20poly1305:: aead:: rand_core:: CryptoRngCore ;
2- use ed25519_dalek:: { Signature , SigningKey , ed25519:: signature:: Signer } ;
1+ use ed25519_dalek:: ed25519:: signature:: Signer ;
2+ use ed25519_dalek:: SigningKey ;
3+ use ed25519_dalek:: Signature ;
4+ use rand:: CryptoRng ;
35
46pub const ED25519_PUBLIC_KEY_SIZE : usize = ed25519_dalek:: PUBLIC_KEY_LENGTH ;
57pub const ED25519_PRIVATE_KEY_SIZE : usize = ed25519_dalek:: SECRET_KEY_LENGTH ;
68pub const ED25519_SIGNATURE_SIZE : usize = ed25519_dalek:: SIGNATURE_LENGTH ;
79
8- pub fn ed25519_new_private_key_using (
9- rng : & mut impl CryptoRngCore ,
10- ) -> [ u8 ; ED25519_PRIVATE_KEY_SIZE ] {
10+ pub fn ed25519_new_private_key_using ( rng : & mut impl CryptoRng ) -> [ u8 ; ED25519_PRIVATE_KEY_SIZE ] {
1111 SigningKey :: generate ( rng) . to_bytes ( )
1212}
1313
Original file line number Diff line number Diff line change 11use hkdf:: Hkdf ;
2- use hmac:: { Hmac , Mac } ;
2+ use hmac:: { Hmac , KeyInit , Mac } ;
33use pbkdf2:: pbkdf2_hmac;
44use sha2:: { Digest , Sha256 , Sha512 } ;
55
Original file line number Diff line number Diff line change 1- use chacha20poly1305:: { AeadInPlace , ChaCha20Poly1305 , KeyInit } ;
1+ use chacha20poly1305:: { AeadInOut , ChaCha20Poly1305 , KeyInit } ;
22
33use crate :: Result ;
44
@@ -19,7 +19,11 @@ pub fn aead_chacha20_poly1305_encrypt_with_aad(
1919 let cipher = ChaCha20Poly1305 :: new ( key. into ( ) ) ;
2020 let mut buffer = plaintext. as_ref ( ) . to_vec ( ) ;
2121 let auth = cipher
22- . encrypt_in_place_detached ( nonce. into ( ) , aad. as_ref ( ) , & mut buffer)
22+ . encrypt_inout_detached (
23+ nonce. into ( ) ,
24+ aad. as_ref ( ) ,
25+ buffer. as_mut_slice ( ) . into ( )
26+ )
2327 . unwrap ( ) ;
2428 ( buffer, auth. to_vec ( ) . try_into ( ) . unwrap ( ) )
2529}
@@ -52,11 +56,11 @@ where
5256{
5357 let cipher = ChaCha20Poly1305 :: new ( key. into ( ) ) ;
5458 let mut buffer = ciphertext. as_ref ( ) . to_vec ( ) ;
55- cipher. decrypt_in_place_detached (
59+ cipher. decrypt_inout_detached (
5660 nonce. into ( ) ,
5761 aad. as_ref ( ) ,
58- & mut buffer,
59- auth. into ( ) ,
62+ buffer. as_mut_slice ( ) . into ( ) ,
63+ auth. into ( )
6064 ) ?;
6165 Ok ( buffer)
6266}
You can’t perform that action at this time.
0 commit comments