Padding implementation is not constant-time

Open
#626 11 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Quiet
Tech stack
rust

Research direction

Review this crate's RSA padding-mode implementation alongside the RSA guidance draft and the Marvin Toolkit analysis linked in the issue. Focus on PKCS#1 v1.5 depadding and error handling, then use static analysis and Marvin Toolkit results to verify that the implementation follows constant-time guidance and avoids the reported sidechannels.

Written by the indexing model from the issue text.

Description

security

This is a followup to #19, which was originally about the modular exponentiation implementation not being constant-time, and also became our general tracking issue for the subsequent Marvin Attack.

We've gone to great lengths in crypto-bigint to produce the closest thing we can to a constant-time implementation of modular exponentiation, and while we still need to e.g. verify that's truly the case via static analysis tooling, based on the latest analysis from the Marvin Toolkit it seems like the remaining sidechannels in our implementation are probably no longer coming from crypto-bigint, but are instead in this crate's implementation of RSA padding modes.

PKCS#1 v1.5 in particular notably has a long history of sidechannels going back to Bleichenbacher's original 1998 attack, and attacks like Marvin can be seen as an evolution of that attack.

This I-D contains guidance for implementing RSA in constant-time, including things like handling depadding errors using strategies like implicit rejection:

https://datatracker.ietf.org/doc/draft-irtf-cfrg-rsa-guidance/

Dominant language
Rust
Stars
673
Forks
190
PR merge metrics
No merged PRs in 30d

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 RustCrypto/RSA

All issues in RustCrypto/RSA

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.