aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-04-02 13:59:02 -0400
committerJack Lloyd <[email protected]>2018-04-02 13:59:02 -0400
commit9325140ff48e4140145cd215ca48e6d04ddf4787 (patch)
treedd4316cd7b6c90eb49b5b5f9c3b5a5f34ae31192
parentc1e5b7193c493ec3d8946fadeb89c05c912b10c5 (diff)
parentc94c227a71e8a0dd2c2796deb0b4f8aa921ea07b (diff)
Merge GH #1508 Support labels in OAEP
-rw-r--r--src/lib/pk_pad/eme.cpp9
-rw-r--r--src/tests/data/pubkey/rsa_decrypt.vec7
2 files changed, 12 insertions, 4 deletions
diff --git a/src/lib/pk_pad/eme.cpp b/src/lib/pk_pad/eme.cpp
index 23c444506..5164157f7 100644
--- a/src/lib/pk_pad/eme.cpp
+++ b/src/lib/pk_pad/eme.cpp
@@ -43,12 +43,13 @@ EME* get_eme(const std::string& algo_spec)
req.algo_name() == "EME-OAEP" ||
req.algo_name() == "EME1")
{
- if(req.arg_count() == 1 ||(req.arg_count() == 2 && req.arg(1) == "MGF1"))
+ if(req.arg_count() == 1 ||
+ ((req.arg_count() == 2 || req.arg_count() == 3) && req.arg(1) == "MGF1"))
{
if(auto hash = HashFunction::create(req.arg(0)))
- return new OAEP(hash.release());
+ return new OAEP(hash.release(), req.arg(2, ""));
}
- else if(req.arg_count() == 2)
+ else if(req.arg_count() == 2 || req.arg_count() == 3)
{
auto mgf_params = parse_algorithm_name(req.arg(1));
@@ -59,7 +60,7 @@ EME* get_eme(const std::string& algo_spec)
if(hash && mgf1_hash)
{
- return new OAEP(hash.release(), mgf1_hash.release());
+ return new OAEP(hash.release(), mgf1_hash.release(), req.arg(2, ""));
}
}
}
diff --git a/src/tests/data/pubkey/rsa_decrypt.vec b/src/tests/data/pubkey/rsa_decrypt.vec
index 9af5e4b5b..b702b6310 100644
--- a/src/tests/data/pubkey/rsa_decrypt.vec
+++ b/src/tests/data/pubkey/rsa_decrypt.vec
@@ -95,4 +95,11 @@ Msg = 8da89fd9e5f974a29feffb462b49180f6cf9e802
Ciphertext = 9230e0034ae35f8e3d182d3b354cbc3a35a0d5c6ef4f2160f54dce86f9def8218d9f670d43900a4192ef1420a48968d7df7e157a533e3d839471ff0f2d523b8a5b2f4c3e69be7986d910f77886d1b6bb314d05b940ea2cee1ab4735d303af6e6f6ec442facc604654eeeb37b380bf2813376665a7ca31d8251a7af7d71fcd74311cc4ee99d4525983abcb3929f3c25051f23e06be5dff023e4359e2e574dbe1fc6ac6d5290ab4324b7ad9f99dfa2fcebb07ef35a578b2bab98c4d7108a24ef11c45bc78a141ee8ad7aaf91aa1f9da27ead96efe8241f7752337b8a2b03de84df8f18b9316fdafbe6472a7c61fde7621e8dbf8c268d8be8b3e8b645d82785b9ce
Msg = 26521050844271
+[OAEP(SHA-512,MGF1(SHA-512),TCPA)]
+E = 0x010001
+P = 0x00e138af11ccf541325933cbedf53e8a96e5e15b70780d9aded44a07ad22fca082b35b70a70394d67d7153040bf9ec9cf7c3cfb1c632cca02a531b47fbbf8009277fb665172f5e120234bf14a7116bb4a36a22fa0b9f43dd4ca0242732258f01eb10e89fe85f2c022f768db8d809870d8c909f63d5f07f913cb2b39b46d86f7b65
+Q = 0x00da40db13075051666cf0c810ccbf8fa3712d82235747115af316169bd92dd0f463f17dc4e0578cb659e3ba428de7e319d04736ddd6fe7d9ddd63964821b25f011ecc7435997186513fd18c0dc049b96fbee1de6376414c582f16d0d477f8a9ccfccdbf882abd568d57c6a8118a5721722ceca1064267218adf1fabcbc22ee555
+
+Ciphertext = 2c0427880d39bcdc613f0d5861933ff7cfc9363fd2d51b001f6871e55bc980ca6d75ab2d0fd5c6b5d5faa5c3c6f5926af019ef0de0d3d050a743740702426970ec01c47881f7f87a04ae189183fced48bff326086c819cd6b84b062e97b514ebc0c3b189e2a3bd909682646c7cfe5a169efc7d264ea79547b595f9daf3cf38ff770562416dbcc91efd39eb0285fd83cf43c3d8352f73a19052c453673a6680625be6851c648daa49d1d1411a73fd236577627caf62ca4359916e3daba2f3cc67d76851194c24ff27a0f74a118629d7d85c13a30aeb8be8d45760306a083f4d8e16fa4bf419c1b93c63cc63cb763cfe1935a63c8f0c4f70a96f8c91d0272b55a3
+Msg = 48656c6c6f20576f726c64da \ No newline at end of file