Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fips202 keccak_absorb does not absorb properly #75

Closed
bwesterb opened this issue Apr 11, 2023 · 1 comment · Fixed by #76
Closed

fips202 keccak_absorb does not absorb properly #75

bwesterb opened this issue Apr 11, 2023 · 1 comment · Fixed by #76

Comments

@bwesterb
Copy link
Contributor

The current implementation is flawed:

pub(crate) fn keccak_absorb(
  s: &mut[u64], 
  mut pos: usize, 
  r: usize, 
  input: &[u8], 
  mut inlen: usize
) -> usize
{
  let mut idx = 0usize;
  while pos+inlen >= r {
    for i in pos..r {
      s[i/8] ^= (input[idx] as u64) << 8 * (i%8);
      idx += 1;
    }
    inlen -= r-pos;
    keccakf1600_statepermute(s);
    pos = 0;
  }
  let new_pos = pos+inlen;
  for i in pos..new_pos {
    s[i/8] ^= (input[idx] as u64) << 8 * (i%8);
  }
  new_pos
}

Note that idx is not incremented in the final loop.

@bwesterb
Copy link
Contributor Author

As far as I can tell keccak_absorb isn't actually used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant