aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/pk_ops.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-03-19 22:52:48 -0400
committerJack Lloyd <[email protected]>2016-03-20 09:38:22 -0400
commitb8966d0f89e520cecf3e822241aef38ed9a6d876 (patch)
tree9b5c0f6afa89e8e91ef230e3d7824b10e037802c /src/lib/pubkey/pk_ops.cpp
parentada363473a9491a3b07e3bb6fa2b5fd9f12aec98 (diff)
Clean up PK decryption encoding.
Previously RSA and ElGamal stripped off leading zeros which were then assumed by the padding decoders. Instead have them produce ciphertexts with leading zeros. Changes EME_Raw to strip leading zeros to match existing behavior.
Diffstat (limited to 'src/lib/pubkey/pk_ops.cpp')
-rw-r--r--src/lib/pubkey/pk_ops.cpp7
1 files changed, 1 insertions, 6 deletions
diff --git a/src/lib/pubkey/pk_ops.cpp b/src/lib/pubkey/pk_ops.cpp
index 37c31777d..654b68255 100644
--- a/src/lib/pubkey/pk_ops.cpp
+++ b/src/lib/pubkey/pk_ops.cpp
@@ -31,12 +31,7 @@ secure_vector<byte> PK_Ops::Encryption_with_EME::encrypt(const byte msg[], size_
RandomNumberGenerator& rng)
{
const size_t max_raw = max_raw_input_bits();
-
const std::vector<byte> encoded = unlock(m_eme->encode(msg, msg_len, max_raw, rng));
-
- if(8*(encoded.size() - 1) + high_bit(encoded[0]) > max_raw)
- throw Exception("Input is too large to encrypt with this key");
-
return raw_encrypt(encoded.data(), encoded.size(), rng);
}
@@ -60,7 +55,7 @@ PK_Ops::Decryption_with_EME::decrypt(byte& valid_mask,
size_t ciphertext_len)
{
const secure_vector<byte> raw = raw_decrypt(ciphertext, ciphertext_len);
- return m_eme->unpad(valid_mask, raw.data(), raw.size(), max_raw_input_bits());
+ return m_eme->unpad(valid_mask, raw.data(), raw.size());
}
PK_Ops::Key_Agreement_with_KDF::Key_Agreement_with_KDF(const std::string& kdf)