44
55use aes_gcm:: {
66 aead:: { Aead , AeadCore , KeyInit , OsRng , Payload } ,
7- Aes256Gcm , Key ,
7+ Aes256Gcm ,
88} ;
99use authenticator:: {
1010 authenticatorservice:: { AuthenticatorService , RegisterArgs , SignArgs } ,
@@ -21,6 +21,7 @@ use authenticator::{
2121 statecallback:: StateCallback ,
2222 Pin , StatusPinUv , StatusUpdate ,
2323} ;
24+ use generic_array:: GenericArray ;
2425use getopts:: { Matches , Options } ;
2526use sha2:: { Digest , Sha256 } ;
2627use std:: sync:: mpsc:: { channel, RecvError } ;
@@ -157,8 +158,14 @@ fn register_user(
157158 // Let nonce be a fresh, random, 12-byte value.
158159 let nonce = Aes256Gcm :: generate_nonce ( & mut OsRng ) ;
159160 // Let ciphertext be the AEAD_AES_256_GCM authenticated encryption of plaintext using key, nonce, and the associated data as specified above.
160- let gcm_key = Key :: < Aes256Gcm > :: from_slice ( & key) ;
161- let cipher = Aes256Gcm :: new ( gcm_key) ;
161+ //
162+ // Note: Because of bug https://github.com/RustCrypto/traits/issues/2036 and/or https://github.com/fizyk20/generic-array/issues/158 we can't use the
163+ // simple version below, but have to request the new generic-array 1.x in
164+ // our Cargo.toml and use it directly here, as aes_gcm uses the old version
165+ // that got 'broken' by a dot-release
166+ // let gcm_key = Key::<Aes256Gcm>::from_slice(&key);
167+ // let cipher = Aes256Gcm::new(gcm_key);
168+ let cipher = Aes256Gcm :: new ( GenericArray :: from_slice ( & key) . as_ref ( ) ) ;
162169 let mut payload = Payload :: from ( plaintext. as_ref ( ) ) ;
163170 // Associated data: The value 0x626c6f62 ("blob") || uint64LittleEndian(origSize).
164171 let mut aad = b"blob" . to_vec ( ) ;
@@ -259,8 +266,13 @@ fn extract_associated_large_blobs(key: Vec<u8>, array: Vec<LargeBlobArrayElement
259266 let valid_elements = array
260267 . iter ( )
261268 . filter_map ( |e| {
262- let gcm_key = Key :: < Aes256Gcm > :: from_slice ( & key) ;
263- let cipher = Aes256Gcm :: new ( gcm_key) ;
269+ // Note: Because of bug https://github.com/RustCrypto/traits/issues/2036 and/or https://github.com/fizyk20/generic-array/issues/158 we can't use the
270+ // simple version below, but have to request the new generic-array 1.x in
271+ // our Cargo.toml and use it directly here, as aes_gcm uses the old version
272+ // that got 'broken' by a dot-release
273+ // let gcm_key = Key::<Aes256Gcm>::from_slice(&key);
274+ // let cipher = Aes256Gcm::new(gcm_key);
275+ let cipher = Aes256Gcm :: new ( GenericArray :: from_slice ( & key) . as_ref ( ) ) ;
264276 let mut payload = Payload :: from ( e. ciphertext . as_slice ( ) ) ;
265277 // Associated data: The value 0x626c6f62 ("blob") || uint64LittleEndian(origSize).
266278 let mut aad = b"blob" . to_vec ( ) ;
0 commit comments