@@ -8,8 +8,9 @@ use std::io::Write;
8
8
use std:: { cmp, convert:: TryInto , fmt} ;
9
9
10
10
use crypto_box:: {
11
- aead:: { generic_array:: GenericArray , Aead , NewAead } ,
11
+ aead:: { generic_array:: GenericArray , Aead , KeyInit } ,
12
12
rand_core:: OsRng ,
13
+ SalsaBox ,
13
14
} ;
14
15
use data_encoding:: { HEXLOWER , HEXLOWER_PERMISSIVE } ;
15
16
use serde:: {
@@ -151,7 +152,7 @@ impl KeyPair {
151
152
nonce : Nonce ,
152
153
other_key : & PublicKey ,
153
154
) -> SignalingResult < Vec < u8 > > {
154
- let cbox = crypto_box :: Box :: new ( other_key, & self . private_key ) ;
155
+ let cbox = SalsaBox :: new ( other_key, & self . private_key ) ;
155
156
cbox. encrypt ( & nonce. into ( ) , data)
156
157
. map_err ( |_| SignalingError :: Crypto ( "Could not encrypt data" . to_string ( ) ) )
157
158
}
@@ -167,7 +168,7 @@ impl KeyPair {
167
168
nonce : Nonce ,
168
169
other_key : & PublicKey ,
169
170
) -> SignalingResult < Vec < u8 > > {
170
- let cbox = crypto_box :: Box :: new ( other_key, & self . private_key ) ;
171
+ let cbox = SalsaBox :: new ( other_key, & self . private_key ) ;
171
172
cbox. decrypt ( & nonce. into ( ) , data)
172
173
. map_err ( |_| SignalingError :: Crypto ( "Could not decrypt data" . to_string ( ) ) )
173
174
}
@@ -287,7 +288,7 @@ impl UnsignedKeys {
287
288
( & mut bytes[ 32 ..64 ] )
288
289
. write_all ( self . client_public_permanent_key . as_bytes ( ) )
289
290
. unwrap ( ) ;
290
- let cbox = crypto_box :: Box :: new (
291
+ let cbox = SalsaBox :: new (
291
292
client_public_permanent_key,
292
293
server_session_keypair. private_key ( ) ,
293
294
) ;
@@ -315,7 +316,7 @@ impl SignedKeys {
315
316
nonce : Nonce ,
316
317
) -> SignalingResult < UnsignedKeys > {
317
318
// Decrypt bytes
318
- let cbox = crypto_box :: Box :: new ( server_public_permanent_key, permanent_key. private_key ( ) ) ;
319
+ let cbox = SalsaBox :: new ( server_public_permanent_key, permanent_key. private_key ( ) ) ;
319
320
let decrypted = cbox
320
321
. decrypt ( & nonce. into ( ) , & self . 0 [ ..] )
321
322
. map_err ( |_| SignalingError :: Crypto ( "Could not decrypt signed keys" . to_string ( ) ) ) ?;
@@ -633,7 +634,7 @@ mod tests {
633
634
. sign ( & kp_server, kp_client. public_key ( ) , unsafe { nonce. clone ( ) } ) ;
634
635
635
636
// Decrypt directly
636
- let cbox = crypto_box :: Box :: new ( kp_server. public_key ( ) , kp_client. private_key ( ) ) ;
637
+ let cbox = SalsaBox :: new ( kp_server. public_key ( ) , kp_client. private_key ( ) ) ;
637
638
let decrypted = cbox
638
639
. decrypt ( & unsafe { nonce. clone ( ) } . into ( ) , & signed. 0 [ ..] )
639
640
. unwrap ( ) ;
0 commit comments