openwall / openwall/john

Argon2: Precompute or cache 2i/2id indices

Open
#5,559 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C
Stars
13.6k
Forks
2.6k
PR merge metrics
No merged PRs in 30d

Description

As I wrote in https://github.com/openwall/john/issues/2738#issuecomment-328273076

-- cut --
... potential optimization for 2i and 2id, where the data-independent indices can be reused across hash computations, rather than recomputed each time like upstream does. In our current hack of older upstream code, we're already passing the pseudo_rands array from the application, yet somehow we don't appear to be making this optimization. In latest upstream code, this array is gone - as far as I can tell, the data-independent indices are being calculated in smaller portions, which makes sense for that approach - but we'll probably need to reintroduce an equivalent of the array (as an option), to be written-to (if for the first time or when invoked with higher parameters) and reused (on subsequent calls with same or lower parameters) where the new upstream code normally does these things (so that we won't deviate from upstream too much). This probably means in next_addresses().

I think https://gitlab.com/omos/argon2-gpu already has this optimization (for GPU) - grep it for "precompute".
-- cut --

However, now that we got a revision of the above OpenCL implementation into our tree here, it doesn't appear to have this optimization. Maybe it was dropped at some point, or maybe I was wrong that it was there, or am wrong that it isn't now. But right now it looks to me that we'd need to try implementing this for both CPU and OpenCL.

The pseudo_rands array is indeed gone from our tree with #5557.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the current Argon2 implementation around next_addresses() and the history in #5557; compare the OpenCL revision with omos/argon2-gpu's references to "precompute". Done means the data-independent indices can be reused for both CPU and OpenCL computations without diverging unnecessarily from upstream.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
performance, security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.