Reduce allocations and copying by decrypting into a buffer

Open
#62 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust
Domain
security

Research direction

Start by locating the Cryptographer trait and the existing openssl backend, then trace the decryption callers that currently receive a Vec. Check how the backend already writes into a buffer and identify the API and call sites that must change. Done means decryption writes directly into caller-provided output storage without the temporary allocation or copy, with the existing behavior preserved.

Written by the indexing model from the issue text.

Description

Our current Cryptographer trait decrypts from a &[u8] and returns a Vec<u8>, for simplicity. This means that each decryption operation must allocate a new Vec to hold the result, and then we copy the bytes out of that temporary Vec and into the final output Vec.

We could reduce the amount of allocation and copying going on here if our Cryptographer trait instead accepted an output buffer as argument and decrypted into it. That's actually out the existing openssl backend works under the hood already, we just wrap it in automatic creation of the Vec.

Not urgent, but could be a nice little improvement.

Dominant language
Rust
Stars
29
Forks
14
Avg merge
3h 15m
Merged PRs (30d)
2

Contributor guide

No contributing guide indexed for this repository

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.

More from mozilla/rust-ece

All issues in mozilla/rust-ece

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.