File tree 1 file changed +10
-6
lines changed
src/librustc_data_structures
1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -113,17 +113,20 @@ fn blake2b_compress(ctx: &mut Blake2bCtx, last: bool) {
113
113
}
114
114
115
115
{
116
- // Re-interpret the input buffer in the state as u64s
116
+ // Re-interpret the input buffer in the state as an array
117
+ // of little-endian u64s, converting them to machine
118
+ // endianness. It's OK to modify the buffer in place
119
+ // since this is the last time this data will be accessed
120
+ // before it's overwritten.
121
+
117
122
let m: & mut [ u64 ; 16 ] = unsafe {
118
123
let b: & mut [ u8 ; 128 ] = & mut ctx. b ;
119
124
:: std:: mem:: transmute ( b)
120
125
} ;
121
126
122
- // It's OK to modify the buffer in place since this is the last time
123
- // this data will be accessed before it's overwritten
124
127
if cfg ! ( target_endian = "big" ) {
125
128
for word in & mut m[ ..] {
126
- * word = word . to_be ( ) ;
129
+ * word = u64 :: from_le ( * word ) ;
127
130
}
128
131
}
129
132
@@ -209,9 +212,10 @@ fn blake2b_final(ctx: &mut Blake2bCtx)
209
212
210
213
blake2b_compress ( ctx, true ) ;
211
214
215
+ // Modify our buffer to little-endian format as it will be read
216
+ // as a byte array. It's OK to modify the buffer in place since
217
+ // this is the last time this data will be accessed.
212
218
if cfg ! ( target_endian = "big" ) {
213
- // Make sure that the data is in memory in little endian format, as is
214
- // demanded by BLAKE2
215
219
for word in & mut ctx. h {
216
220
* word = word. to_le ( ) ;
217
221
}
You can’t perform that action at this time.
0 commit comments