aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/pbes2
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-05-22 23:49:45 -0400
committerJack Lloyd <[email protected]>2018-05-22 23:50:16 -0400
commit2b19386ae79141377f0b3026a5705884da397b92 (patch)
tree576c146f71a497d11fd380afa549c874f25a0ec1 /src/lib/pubkey/pbes2
parentf87b9e4128698951c10e47dca01811a677577ca0 (diff)
Add OIDS for Camellia and SM4 in GCM and CBC modes
Making them usable for private key encryption
Diffstat (limited to 'src/lib/pubkey/pbes2')
-rw-r--r--src/lib/pubkey/pbes2/pbes2.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/lib/pubkey/pbes2/pbes2.cpp b/src/lib/pubkey/pbes2/pbes2.cpp
index 384fb1e6a..cfac722d7 100644
--- a/src/lib/pubkey/pbes2/pbes2.cpp
+++ b/src/lib/pubkey/pbes2/pbes2.cpp
@@ -179,10 +179,14 @@ pbes2_encrypt_shared(const secure_vector<uint8_t>& key_bits,
{
const std::vector<std::string> cipher_spec = split_on(cipher, '/');
if(cipher_spec.size() != 2)
- throw Decoding_Error("PBE-PKCS5 v2.0: Invalid cipher spec " + cipher);
+ throw Encoding_Error("PBE-PKCS5 v2.0: Invalid cipher spec " + cipher);
if(cipher_spec[1] != "CBC" && cipher_spec[1] != "GCM")
- throw Decoding_Error("PBE-PKCS5 v2.0: Don't know param format for " + cipher);
+ throw Encoding_Error("PBE-PKCS5 v2.0: Don't know param format for " + cipher);
+
+ const OID cipher_oid = OIDS::lookup(cipher);
+ if(cipher_oid.empty())
+ throw Encoding_Error("PBE-PKCS5 v2.0: No OID assigned for " + cipher);
std::unique_ptr<Cipher_Mode> enc = Cipher_Mode::create(cipher, ENCRYPTION);