Skip to content

Commit 2bea779

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 39ccc08 + e47a445 commit 2bea779

19 files changed

+83
-102
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rust-crypto"
3-
version = "0.2.27"
3+
version = "0.2.29"
44
authors = ["The Rust-Crypto Project Developers"]
55
license = "MIT/Apache-2.0"
66
homepage = "https://github.com/DaGenix/rust-crypto/"

src/aes_gcm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl<'a> AesGcm<'a> {
3333
// earlier preventing the use of generic CTR mode.
3434

3535
let mut iv = [0u8; 16];
36-
copy_memory(&mut iv, nonce);
36+
copy_memory(nonce, &mut iv);
3737
iv[15] = 1u8;
3838
let mut cipher = ctr(key_size,key,&iv);
3939
let temp_block = [0u8; 16];

src/aessafe.rs

-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ finite field which allows for efficient computation of the AES S-Boxes. See [7]
124124
*/
125125

126126
use std::ops::{BitAnd, BitXor, Not};
127-
use std::num::Int;
128127
use std::default::Default;
129128

130129
use cryptoutil::{read_u32v_le, write_u32_le};

src/blake2b.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// except according to those terms.
66

77
use std::iter::repeat;
8-
use std::num::Int;
98
use cryptoutil::{read_u64v_le, write_u64v_le};
109
use std::slice::bytes::{copy_memory};
1110
use std::intrinsics::volatile_set_memory;
@@ -122,7 +121,7 @@ impl Blake2b {
122121
key: [0; BLAKE2B_KEYBYTES],
123122
key_length: key.len() as u8
124123
};
125-
copy_memory(&mut b.key, key);
124+
copy_memory(key, &mut b.key);
126125
b
127126
}
128127

@@ -184,7 +183,7 @@ impl Blake2b {
184183

185184
fn apply_key(&mut self) {
186185
let mut block : [u8; BLAKE2B_BLOCKBYTES] = [0; BLAKE2B_BLOCKBYTES];
187-
copy_memory(&mut block, &self.key[..self.key_length as usize]);
186+
copy_memory(&self.key[..self.key_length as usize], &mut block);
188187
self.update(&block);
189188
unsafe {
190189
volatile_set_memory(block.as_mut_ptr(), 0, block.len());
@@ -256,20 +255,20 @@ impl Blake2b {
256255
let fill = 2 * BLAKE2B_BLOCKBYTES - left;
257256

258257
if input.len() > fill {
259-
copy_memory( &mut self.buf[left..], &input[0..fill] ); // Fill buffer
258+
copy_memory(&input[0..fill], &mut self.buf[left..]); // Fill buffer
260259
self.buflen += fill;
261260
self.increment_counter( BLAKE2B_BLOCKBYTES as u64);
262261
self.compress();
263262

264263
let mut halves = self.buf.chunks_mut(BLAKE2B_BLOCKBYTES);
265264
let first_half = halves.next().unwrap();
266265
let second_half = halves.next().unwrap();
267-
copy_memory(first_half, second_half);
266+
copy_memory(second_half, first_half);
268267

269268
self.buflen -= BLAKE2B_BLOCKBYTES;
270269
input = &input[fill..input.len()];
271270
} else { // inlen <= fill
272-
copy_memory(&mut self.buf[left..], input);
271+
copy_memory(input, &mut self.buf[left..]);
273272
self.buflen += input.len();
274273
break;
275274
}
@@ -287,7 +286,7 @@ impl Blake2b {
287286
let mut halves = self.buf.chunks_mut(BLAKE2B_BLOCKBYTES);
288287
let first_half = halves.next().unwrap();
289288
let second_half = halves.next().unwrap();
290-
copy_memory(first_half, second_half);
289+
copy_memory(second_half, first_half);
291290
}
292291

293292
let incby = self.buflen as u64;
@@ -304,7 +303,7 @@ impl Blake2b {
304303
self.computed = true;
305304
}
306305
let outlen = out.len();
307-
copy_memory(out, &self.buf[0..outlen]);
306+
copy_memory(&self.buf[0..outlen], out);
308307
}
309308

310309
pub fn blake2b(out: &mut[u8], input: &[u8], key: &[u8]) {

src/blockmodes.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,14 @@ fn update_history(in_hist: &mut [u8], out_hist: &mut [u8], last_in: &[u8], last_
9494
let in_hist_len = in_hist.len();
9595
if in_hist_len > 0 {
9696
slice::bytes::copy_memory(
97-
in_hist,
98-
&last_in[last_in.len() - in_hist_len..]);
97+
&last_in[last_in.len() - in_hist_len..],
98+
in_hist);
9999
}
100100
let out_hist_len = out_hist.len();
101101
if out_hist_len > 0 {
102102
slice::bytes::copy_memory(
103-
out_hist,
104-
&last_out[last_out.len() - out_hist_len..]);
103+
&last_out[last_out.len() - out_hist_len..],
104+
out_hist);
105105
}
106106
}
107107

@@ -412,8 +412,8 @@ impl <P: BlockProcessor, X: PaddingProcessor> BlockEngine<P, X> {
412412
}
413413
fn reset_with_history(&mut self, in_hist: &[u8], out_hist: &[u8]) {
414414
self.reset();
415-
slice::bytes::copy_memory(&mut self.in_hist, in_hist);
416-
slice::bytes::copy_memory(&mut self.out_hist, out_hist);
415+
slice::bytes::copy_memory(in_hist, &mut self.in_hist);
416+
slice::bytes::copy_memory(out_hist, &mut self.out_hist);
417417
}
418418
}
419419

@@ -690,7 +690,7 @@ impl <A: BlockEncryptor> CtrMode<A> {
690690
}
691691
}
692692
pub fn reset(&mut self, ctr: &[u8]) {
693-
slice::bytes::copy_memory(&mut self.ctr, ctr);
693+
slice::bytes::copy_memory(ctr, &mut self.ctr);
694694
self.bytes.reset();
695695
}
696696
fn process(&mut self, input: &[u8], output: &mut [u8]) {
@@ -744,7 +744,7 @@ pub struct CtrModeX8<A> {
744744

745745
fn construct_ctr_x8(in_ctr: &[u8], out_ctr_x8: &mut [u8]) {
746746
for (i, ctr_i) in out_ctr_x8.chunks_mut(in_ctr.len()).enumerate() {
747-
slice::bytes::copy_memory(ctr_i, in_ctr);
747+
slice::bytes::copy_memory(in_ctr, ctr_i);
748748
add_ctr(ctr_i, i as u8);
749749
}
750750
}

src/buffer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub trait ReadBuffer {
3737

3838
fn push_to<W: WriteBuffer>(&mut self, output: &mut W) {
3939
let count = cmp::min(output.remaining(), self.remaining());
40-
slice::bytes::copy_memory(output.take_next(count), self.take_next(count));
40+
slice::bytes::copy_memory(self.take_next(count), output.take_next(count));
4141
}
4242
}
4343

0 commit comments

Comments
 (0)