Skip to content

Commit b5e14d3

Browse files
committed
function copy_from_slice requires both source and destination to be of same size
1 parent 9ebcf7a commit b5e14d3

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

rustls-wolfcrypt-provider/src/aead/aes128gcm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ impl Tls12AeadAlgorithm for Aes128Gcm {
6565
) -> Result<ConnectionTrafficSecrets, UnsupportedOperationError> {
6666
let mut iv_as_vec = vec![0u8; GCM_NONCE_LENGTH];
6767

68-
iv_as_vec.copy_from_slice(iv);
69-
iv_as_vec.copy_from_slice(explicit);
68+
iv_as_vec[..iv.len()].copy_from_slice(iv);
69+
iv_as_vec[iv.len()..].copy_from_slice(explicit);
7070

7171
Ok(ConnectionTrafficSecrets::Aes128Gcm {
7272
key,

rustls-wolfcrypt-provider/src/aead/aes256gcm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ impl Tls12AeadAlgorithm for Aes256Gcm {
6565
) -> Result<ConnectionTrafficSecrets, UnsupportedOperationError> {
6666
let mut iv_as_vec = vec![0u8; GCM_NONCE_LENGTH];
6767

68-
iv_as_vec.copy_from_slice(iv);
69-
iv_as_vec.copy_from_slice(explicit);
68+
iv_as_vec[..iv.len()].copy_from_slice(iv);
69+
iv_as_vec[iv.len()..].copy_from_slice(explicit);
7070

7171
Ok(ConnectionTrafficSecrets::Aes256Gcm {
7272
key,

0 commit comments

Comments
 (0)