···3939 }
40404141 /// Performs the keccakf\[1600\] permutation on an aligned byte buffer
4242+ #[inline]
4243 pub(crate) fn permute_f1600(&mut self) {
4344 let mut keccak_block = [0u64; KECCAK_BLOCK_SIZE];
4445
+17-10
wharrgarbl-strobe/src/strobe.rs
···4646 pub fn $name(&mut self, data: &mut [u8]) {
4747 let flags = $flags;
4848 let prev_flags = self.prev_flags;
4949- let more = prev_flags.ct_eq(&flags);
4949+ let more = prev_flags == flags;
5050 self.operate(flags, data, more);
5151 }
5252 )*
···6262 pub fn $name(&mut self, data: &[u8]) {
6363 let flags = $flags;
6464 let prev_flags = self.prev_flags;
6565- let more = prev_flags.ct_eq(&flags);
6565+ let more = prev_flags == flags;
6666 self.operate_no_mutate(flags, data, more);
6767 }
6868 )*
···147147 ///
148148 /// This is a modification to the Strobe API surface to prevent misuse of op calls,
149149 /// preventing panics/errors so that the compiler can optimise better.
150150+ #[inline]
150151 pub fn reset_ops(&mut self) {
151152 // This prevents streaming so to always make the prev_flags == flags
152153 // comparison always fail
···154155 }
155156156157 // Runs the permutation function on the internal state
158158+ #[inline]
157159 fn permutation_f(&mut self) {
158160 self.state.0[self.position] ^= self.start as u8;
159161 self.state.0[self.position + 1] ^= 0x04;
···168170 fn increment_position(&mut self, increment: usize) {
169171 self.position += increment;
170172171171- if self.position.ct_eq(&self.rate).to_bool() {
173173+ if self.position == self.rate {
172174 self.permutation_f();
173175 }
174176 }
···268270269271 /// Mixes the current state index and flags into the state, accounting for whether we are
270272 /// sending or receiving
273273+ #[inline]
271274 fn begin_op(&mut self, mut flags: OpFlags) {
272275 if flags.contains(OpFlags::TRANSPORT).to_bool() {
273276 let op_role = role::SENDER.ct_select(&role::RECEIVER, flags.contains(OpFlags::INBOUND));
···293296 /// Performs the state / data transformation that corresponds to the given flags. If `more` is
294297 /// given, this will treat `data` as a continuation of the data given in the previous
295298 /// call to `operate`.
296296- fn operate(&mut self, mut flags: OpFlags, data: &mut [u8], more: Choice) {
299299+ #[inline]
300300+ fn operate(&mut self, mut flags: OpFlags, data: &mut [u8], more: bool) {
297301 self.prev_flags = flags;
298302299303 // If `more` isn't set, this is a new operation. Do the begin_op sequence
300300- if !more.to_bool() {
304304+ if !more {
301305 self.begin_op(flags);
302306 }
303307···334338 /// Performs the state transformation that corresponds to the given flags. If `more` is given,
335339 /// this will treat `data` as a continuation of the data given in the previous call to
336340 /// `operate`. This uses non-mutating variants of the specializations of the `duplex` function.
337337- fn operate_no_mutate(&mut self, mut flags: OpFlags, data: &[u8], more: Choice) {
341341+ #[inline]
342342+ fn operate_no_mutate(&mut self, mut flags: OpFlags, data: &[u8], more: bool) {
338343 self.prev_flags = flags;
339344340345 // If `more` isn't set, this is a new operation. Do the begin_op sequence
341341- if !more.to_bool() {
346346+ if !more {
342347 self.begin_op(flags);
343348 }
344349···356361 ops[index](self, data);
357362 }
358363364364+ #[inline]
359365 fn recv_mac_inner(&mut self, flags: OpFlags, mac_copy: &mut [u8]) -> Result<(), aead::Error> {
360366 // recv_mac can never be streamed
361361- self.operate(flags, mac_copy, Choice::FALSE);
367367+ self.operate(flags, mac_copy, false);
362368363369 // Constant-time MAC check. This accumulates the truth values of byte == 0
364370 let all_zero = mac_copy
···384390 self.recv_mac_inner(ops::META_RECV_MAC, &mut mac_copy)
385391 }
386392393393+ #[inline]
387394 fn ratchet_inner(&mut self, mut flags: OpFlags, num_bytes_to_zero: usize) {
388388- let more = self.prev_flags.ct_eq(&flags);
395395+ let more = self.prev_flags == flags;
389396390397 // We don't make an `operate` call, since this is a super special case. That means we have
391398 // to make the `begin_op` call manually.
392399 self.prev_flags = flags;
393400394394- if !more.to_bool() {
401401+ if !more {
395402 self.begin_op(flags);
396403 }
397404