ocb3: improve handling of L values
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 961
- Forks
- 200
- Avg merge
- 1h 30m
- Merged PRs (30d)
- 6
Description
Right now we pre-compute L values during cipher initialization. Size of the table is regulated by the const generic parameter and the mode instance can not process messages which require larger tables. Arguably, it's a quite leaky API especially considering somewhat subpar handling of default constants/types in Rust. The cached table can also significantly increase size of the mode struct.
Computation of one L value is just a relatively cheap DBL operation, so I think improve handling in one of the following ways:
- Re-compute the L table on each encrypt/decrypt call with table size computed at runtime depending on the message/AAD size. Since we don't have alloca in Rust, we can allocate a sufficiently large array on stack and initialize it only partially.
- Pre-compute a small table (e.g. sufficient for 1 MiB) and compute additional values at runtime if necessary by copying cached values to stack-based array and re-computing the rest.
- Pre-compute a small table and re-compute additional values on the fly if necessary from the last cached value.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating cipher initialization and the encrypt/decrypt paths that use the pre-computed L table. Compare the three proposed strategies for runtime table sizing, stack allocation, and on-the-fly computation. Done means messages needing larger tables are handled without the current fixed-size limitation and the mode struct/API concerns are addressed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cryptography
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100