Skip to content

Commit

Permalink
Merge pull request #4467 from randombit/jack/ref-4465
Browse files Browse the repository at this point in the history
Add a set of test vectors for odd sized RSA keys
  • Loading branch information
randombit authored Dec 6, 2024
2 parents f987b23 + 64c4544 commit 4725c2d
Show file tree
Hide file tree
Showing 5 changed files with 1,373 additions and 67 deletions.
9 changes: 6 additions & 3 deletions src/lib/pubkey/pk_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ size_t PK_Ops::Encryption_with_EME::max_input_bits() const {
}

std::vector<uint8_t> PK_Ops::Encryption_with_EME::encrypt(std::span<const uint8_t> msg, RandomNumberGenerator& rng) {
const size_t max_raw = max_ptext_input_bits();
secure_vector<uint8_t> eme_output((max_raw + 7) / 8);
size_t written = m_eme->pad(eme_output, msg, max_raw, rng);
const size_t max_input_bits = max_ptext_input_bits();
const size_t max_input_bytes = (max_input_bits + 7) / 8;
BOTAN_ARG_CHECK(msg.size() <= max_input_bytes, "Plaintext too large");

secure_vector<uint8_t> eme_output(max_input_bits);
const size_t written = m_eme->pad(eme_output, msg, max_input_bits, rng);
return raw_encrypt(std::span{eme_output}.first(written), rng);
}

Expand Down
Loading

0 comments on commit 4725c2d

Please sign in to comment.