Skip to content

Factor out message digest calculation in internal RSA padding interface #348

Closed

Description

@briansmith

When reviewing PR #262, I noticed that it almost definitely a good idea to refactor the padding API like so:

/// The term "Encoding" comes from RFC 3447.
#[cfg(feature = "rsa_signing")]
pub trait Encoding: Sync {
    fn encode(&self, m_hash: &digest::Digest, m_out: &mut [u8],
              mod_bits: bits::BitLength, rng: &rand::SecureRandom)
              -> Result<(), error::Unspecified>;
}

/// The term "Verification" comes from RFC 3447.
pub trait Verification: Sync {
    fn verify(&self, m_hash: &digest::Digest, m: &mut untrusted::Reader,
              mod_bits: bits::BitLength) -> Result<(), error::Unspecified>;
}

Notice in particular that we do digest::digest(digest_alg, msg) in both PKCS#1 and PSS padding, for both encoding and verification, so it makes sense to do the digesting in the callers, verify_rsa() and RSASigningState::sign().

Activity

  1. briansmith commented on Nov 15, 2016

    @briansmith
    OwnerAuthor
  2. briansmith commented on Nov 23, 2016

    @briansmith
    OwnerAuthor

    This was done in 5a96fa8.

  3. self-assigned this
    on Nov 23, 2016
  4. added this to the 0.6 milestone on Nov 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions