@@ -16,7 +16,7 @@ use crate::{BLOCK_SIZE, Block, Key, Tag};
1616use core:: {
1717 fmt:: { self , Debug } ,
1818 num:: Wrapping ,
19- ops:: { Add , BitAnd , BitOr , BitXor , Mul } ,
19+ ops:: { Add , BitAnd , BitOr , BitXor , Mul , Shl } ,
2020} ;
2121use soft_impl:: { karatsuba, mont_reduce} ;
2222use universal_hash:: {
@@ -229,21 +229,22 @@ impl Zeroize for FieldElement {
229229
230230/// Multiplication in GF(2)[X], implemented generically and wrapped as `bmul32` and `bmul64`.
231231///
232- /// Uses "holes" (sequences of zeroes) to avoid carry spilling, as specified in the four masking
233- /// operands ( `m0`-`m4`), which should have full-width values with the following bit patterns :
232+ /// Uses "holes" (sequences of zeroes) to avoid carry spilling, as specified in the mask operand
233+ /// `m0` which should have a full-width value with the following bit pattern :
234234///
235- /// - `m0`: `0b100010001...0001` (e.g. `0x1111_1111u32`)
236- /// - `m1`: `0b100010001...00010` (e.g. `0x2222_2222u32`)
237- /// - `m2`: `0b100010001...000100` (e.g. `0x4444_4444u32`)
238- /// - `m3`: `0b100010001...0001000` (e.g. `0x8888_8888u32`)
235+ /// `0b100010001...0001` (e.g. `0x1111_1111u32`)
239236///
240237/// When carries do occur, they wind up in a "hole" and are subsequently masked out of the result.
241238#[ inline]
242- fn bmul < T > ( x : T , y : T , m0 : T , m1 : T , m2 : T , m3 : T ) -> T
239+ fn bmul < T > ( x : T , y : T , m0 : T ) -> T
243240where
244- T : BitAnd < Output = T > + BitOr < Output = T > + Copy ,
241+ T : BitAnd < Output = T > + BitOr < Output = T > + Copy + Shl < u32 , Output = T > ,
245242 Wrapping < T > : BitXor < Output = Wrapping < T > > + Mul < Output = Wrapping < T > > ,
246243{
244+ let m1 = m0 << 1 ;
245+ let m2 = m1 << 1 ;
246+ let m3 = m2 << 1 ;
247+
247248 let x0 = Wrapping ( x & m0) ;
248249 let x1 = Wrapping ( x & m1) ;
249250 let x2 = Wrapping ( x & m2) ;
0 commit comments