aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/data/pubkey/mce.vec58
-rw-r--r--src/tests/test_gf2m.cpp46
-rw-r--r--src/tests/test_mce.cpp96
-rw-r--r--src/tests/test_mceliece.cpp91
-rw-r--r--src/tests/tests.cpp2
-rw-r--r--src/tests/tests.h2
6 files changed, 213 insertions, 82 deletions
diff --git a/src/tests/data/pubkey/mce.vec b/src/tests/data/pubkey/mce.vec
new file mode 100644
index 000000000..44817949b
--- /dev/null
+++ b/src/tests/data/pubkey/mce.vec
@@ -0,0 +1,58 @@
+
+McElieceSeed = C9A3649B5AC1AAFCE2E15B8C74FB0F2C776B10AB6C52F69AEB70700341479428
+KeyN = 1632
+KeyT = 33
+PublicKeyFingerprint = 2F5C0F9FF3E46D40E21AA4165B63DE2780F424438F9106D9C798801B7FAD05F5
+PrivateKeyFingerprint = 89AFCE27857051AF842A58FC903324414470AB0876A9FB8F739FB43485823CD9
+EncryptPRNGSeed = AABF99BAD11411A430D0AA2940148EE67D77DC44BE8734DA4A8B274561CBA2EC
+SharedKey = A656D63F7FC8EF345AFBEE89B121BF5E45D301C5F5FF17DCDB227D84F22CF3D9DED9B00F5495B81CA41789549691BF4D6CF3E7069857E1CBFE9D63855949A89A
+Ciphertext = E053B0773BDADE3C7625E108CC0B3746C36386E283F931970B7F4FE39F24498248458891A7843A843C4CAE3CAABB4CD0A80B1F944685A09CFFD944BFC9E41473769B8310E0BEED9E6C174E3C1E8A9E84A54C3120B5440B1F0F669830FAABA53FA2F00FD45CBC0522E647A5CDDC9135E805A88DCFB97ECAEEA2FF9577B2319F3828FB31C7D6470850DEC5B919FF5F3DC21C0BEC42DFADFDDE2675E03380222A480D0002B1C9D70F6C0A6D8F452FC556EDA9753C71BDC2DD530CE3314AB515F5118AD338A2165ED13DE0626707
+
+McElieceSeed = C9A3649B5AC1AAFCE2E15B8C74FB0F2C776B10AB6C52F69AEB70700341479429
+KeyN = 2480
+KeyT = 45
+PublicKeyFingerprint = DDAC6EDF03B982E85FD60414E6C608F88694BB0C0FCCE99FCB044838E0C9CC9D
+PrivateKeyFingerprint = 1949DFF555144AA0E2ED17CB4A3C71F4D7EEC1CCD9A3199D11E49BCA7FC81E4E
+EncryptPRNGSeed = AABF99BAD11411A430D0AA2940148EE67D77DC44BE8734DA4A8B274561CBA2ED
+SharedKey = 8F533C41E820EB0A6763FCC6AA88FE4FFFB2BAB1567639E8DB0E239CC4F595A1C6041B4EE3362D332A87FD81B9A81E413D4168CF67AE50519D2E5E698990CB0D
+Ciphertext = 0CADE39676249382B1216579A4E4825325E13BE3198EDF913C4F35911DB3DD7CAE7D42158A9DC7599E2324B04A164E247BD5EA0CCDF964955AFF150561FB8CBB8A3FD712CEA114699FA2CEBC2CE837B1115D3E93819BBBB01785007B5380421266D8C3D2B802C8A4ECD5207EC675FFDBD8499A344E29E781A4E15C973D03130819D9B238A2596F68A59ED6628E49FE4ABEBAA5A0D4EACDA4DF1816F1C82F44025A2734FCE26FB7592B0BADF4D9FEDFAB37D54F2CA92D65A876D0E0F18A2FB586A80BD647D465190290FD856B1A8EED967BD77CD1637FD11655D1B135591A2D52B2D83E4A48B5777BB18D0E4D5E6392875AF9CF13B36AB4BBAE80073C8740B4987C3B28AC7778CFE6CDCE5E1ACBB05BB9E142B7C2239E1A41152F3617052D6EF96186CB6C2B4F684438CBA4F59954465466CD67E4457F
+
+
+McElieceSeed = C9A3649B5AC1AAFCE2E15B8C74FB0F2C776B10AB6C52F69AEB70700341479430
+KeyN = 2960
+KeyT = 57
+PublicKeyFingerprint = 05707644DAE98856D432C24C19C41CDA333E36C04C81413E2D15E88EE129B4F7
+PrivateKeyFingerprint = 7BA1FEDF2E520945EC0321CE84F2A07B8407FFEC42EC715839AC0941BA1E9404
+EncryptPRNGSeed = AABF99BAD11411A430D0AA2940148EE67D77DC44BE8734DA4A8B274561CBA2EF
+SharedKey = DEDFB2DBA755E94AD609F1DCA7F81D4BC5A39A4E07BF108D88A031F9E4CD2F46708EF1F9FDD27AAE56318928A5D89FA16C5F7F8D6ABF8019B549139E25142D2B
+Ciphertext = AD9D75F29BD735082E95611DD8C1B9897FB35ABBA968AE8C66E99CECB679BB19344369404E73BA5C6549A8BFA25A2C3F90D3DC3C82E3B06815B0F02E013B3A9FB8EA9C38FEC8C61E58D260989D774DE0DBC8AE27A4C0B2AEAAC2EF43589A2F66D07FDA9B288C5F9DE5E9A59EB00A4C0A69581F7997830BAA9C6D77816DD78D574AD7BD732EA5A7F44E31FE6A30E4CC34896EB45D16C5227F3E31E1F3185614F5157F4D2B3A4B765BC9E3C24EC6D0AF02EDDDED78FB3874F0DAF7FF960FFF7E9445EEBE049200A43412AE99E16CB11BC7BD86BD61A0DB0402092E1D77153E24B5855D736125FDAE5957FBB79F7A5488CF53912681C80E58AF5DA31326A525342A60FAFD1B06E350A01209F7F77FCA2D66B13F17EC8880247F1B975F70A3CC96B5B90F418DE14D445BFC4897FAAFF52931306E84980B23F5D632AF0437AFBD4E6AF672B51AA2862BBDA3340EE77F2FDC4BEE06DB41592136549B55721CDD14FE06F475175EA15598EC65274B02D7D183A66622
+
+McElieceSeed = C9A3649B5AC1AAFCE2E15B8C74FB0F2C776B10AB6C52F69AEB70700341479431
+KeyN = 3408
+KeyT = 67
+PublicKeyFingerprint = 87D94945188A898EFE3F62DDBB083DED2FAF74D83614F811DEE44ED1195B8DD4
+PrivateKeyFingerprint = D774748F55B9678D21A4234CF4141C073F5A389D52B64497E517EEE447B1762C
+EncryptPRNGSeed = AABF99BAD11411A430D0AA2940148EE67D77DC44BE8734DA4A8B274561CBA2EF
+SharedKey = E958F5A7EC2E284927BA6678169343359FE0768F9D1B2C0BDABA2D6E22FBD46BAE9C9FF0DA8238D2AAF9A125CC60F2FC757C47987850293934303D206DFBE06C
+Ciphertext = AD9D75F09BD635082EB5611DD9C1E9897FB35E33E168AE0C66E9DCECA679BB19344369484E73AA5E6549A8BFA25A2C5F90D3D43C82E3B4681790F02E017B3A8FB8EA9C38FEC8C60E58D270989F774DE0DB48AE37A4C0B28EAAC2EF43589A0F66D07F5A9B2888DF9DE5E9A59EB00A4C0A6B581F7997838BAA9C6D67814DD68D574AD7BD732EA5A7F44C31FE6E30E4CC34896EB47D5685227F3E31C1D35A5614F5157F4D6B324B7E59C9E3C34CC6D0AF02EDDCEF78FB3874F2DAF7FF9607FF7E9445EEBE049210A53412AF99C16CB11BC7BD8EBD61A0FB0402896F1D57153E243585DD7B6125FDBE5957FBB79F7A5488CF13952681C00E59AF5DA31326A525142A60FAFD5B06E350A41209F7F77FC22D66B12F13EC8A80207B1B975F70F26A400CCCFC8A4AE20053EF1F8A3E7D2099AFE09A5812D50191461CABADE85E2249BFC78509CD45655AA1CBDF37707634F95A3818629AB4BA13AA3C2D78937CD05B38AFA01FADD1E7C558A5BEA03A022E7A61A7CCEDF3F78C12C888DFF3442033797CCECDC6A7006BFA1E5F17F23E4396DD5E18A324394E30A4B508D511E55C14DD89296085904E280D1E71970E
+
+McElieceSeed = 31C9A3649B5AC1AAFCE2E15B8C74FB0F2C776B10AB6C52F69AEB707003414794
+KeyN = 4624
+KeyT = 95
+PublicKeyFingerprint = E37CF72DE6ECD0E540316C1F4BC6F0391983D4E7B60C8ED13DCA801EEFA9A4E9
+PrivateKeyFingerprint = CDD13DFD3B067DE0A50D37C7CE97CF30E5024CDEF6A20043C09F81219B14B03E
+EncryptPRNGSeed = CCBF99BAD11411A430D0AA2940148EE67D77DC44BE8734DA4A8B274561CBA22E
+SharedKey = 8102784D063499813404A5FBEE50D64122E2C46217C9BAA76AE9021479B0E36D026809C8AEE2443772CEA7C13335017F9825E8BBA67D13786930C474771673FB
+Ciphertext = BE6802091325EF912BC47FC694A0E26F015700F5987C057A70F2D984D3FF589FD6A3DC541912AF4DEA19F6A1C155972578CEA9F5C3A5AD02F85E28E5667FF129222A9585B85FD25A956A572487FBF3B62BBB0A96D360336D4DCBBBD194FC352837028C97F63C6BEBAC5D76A36968DD384F9F884594566E833AB87A8B9EEE5AA0CC9F0D45BE5E61C98C57DD52487F7EFD0AB085EB6D2DA652F7F1BAF6700EA52265412DBA0098B8055C82A46A43C7E89734371ADFB0FFD24D450BE5CE2477BC79BB2F6D85017289C582576AB95CCA9D3B10C4C60111AC9CEDE47294F476CEEF7611A189A5866151A6BA5EB6C362FB6F5A32CF930EFD9ED0CBD110D47060330AB71D9AB00403BF1CF7CDACFA2B1F373FF11B05E3820C93F6BD9D118161A585587A91AF356EF8254CD4CC2CEED87DE3724DDD5F2BDCFB0B75D230779A0D9E4AED49D630ACCFEC81DBF94064A21197BAC57AFFB2D82A637F36F7E64B7336B98288C65EAF18E37B0F8C06457BDA61FA3931480296BB32AACCECEC08E0FF6705352EA69BF12E64C1E6F837E857465148174915E1F1E7714739BED8133FB638ACC6F0D49392080B9E54E7386B430F6BC06DE38C2C92C351B7FCD7F247CB793DBB4E9430F8184C50213C02A9B32B7034A6E30B59CEEFCFA57DB0FE122F7B5A1B9D3EB290BCA9FDB9A2DF9C1638CE3AD84CA2267613D503F210A1A23E5B98B1CE1314FACDBC9C2D45278C312F9CC1A00CFC5086676ED2E9A67965F23D157C350DCFFD98511A4853F3BE54F5109B3D9C98EBB6558E14A427BE6AC73158454E5DDFA402CA3C2E45
+
+McElieceSeed = 31C9A3649B5AC1AAFCE2E15B8C74FB0F2C776B10AB6C52F69AEB707003414795
+KeyN = 6624
+KeyT = 115
+PublicKeyFingerprint = 29A7BE3A3181534ABD5FF006EB8D5CCE71FDD27E0FD62E774A3C75C20BE84268
+PrivateKeyFingerprint = AA75AFB38ADA856FBEE6C973D53DF0AD07395C54AE83805BE59D57112A9EF6A3
+EncryptPRNGSeed = CCBF99BAD11411A430D0AA2940148EE67D77DC44BE8734DA4A8B274561CBA22F
+SharedKey = F50F3E58A4788C03C44DBDE2C61ACC97A7CA8ADC6CC1D371416A7D6250BB3DD7526C55E666C9FCA31ADC5FA79CBEF72AA24B5BDC5F2E7AD255A0091A0DB7D127
+Ciphertext = 4A69DFA02182A20C59FD3D1291D110749C4BA57F38CE66D90485588C2CC4E1548180E9CBB58517479B978DF62A9B4E583D2D1C9BA3E61EDCF4D0249C54160E8547B8A91C5A2FE0E00FE95EF18FC865BFCD39EEE81DD79CAC36885AD2454FCFF4AB740CABD34563E08FA203FF96CEEF5E4FBA43DEC6C316E503B033DD4034F0E432DF646833603EEB8693843727F9F007CD78300A434BD379AA64BC1E1A04282C0BC23ACC6316DBC4919EFD123E4C87BF45F56E43C440453F85F93B014AEEB36CA0DCF9A7543C16C47625057B22A5E6E5681E3C2919225466DF16A32D32D475DF842E4D85C23DD9BD49BAC8D759B96FCBA00086095B7E3CCA2FD30AB884948003CDD64FD1E68AA7B36B2B740BAE029794193284AA4C1CF6DFC2916D2EA1AA20B64A81EEEF815456E260B77DC20C900F874E47962B0995E33A0832ED458EABDAE495B21178EDCBD3A973668E9C8F171139168B1AC442A387C9AA3D1ED9A6583A807BBCBF1A1A94E04B7638695D6F0C09F18B0732A2B5F4111C0D5F84E2F175280DE43525AEE72C036932927B3DDC4FD526B9DBD117C9CD37D64B0F77C103644FD7073977BB69F7367417E79D6A901686DB00E8E7C16C889E566CFB44D1C66E9C84251CB9CAFFB6FCA9B88999B08F8EC6203DEAF668E86689621D5BD56A1FB89623E2388FC93A92F9269ED2ADB70BC92E5F77D1DFE8805039F71A8132535110D1F1E4384BD2C21817DBB7D03DD88035D154106E2E3F7E1C3D4BD15C7F5AE469AC8BD016F98C9B01A66B8D8A0F72C7C9C176C2AEDC967B9AB4FCBF0FD99D0BEF8B151B224DCDA3691885414BC36B3707D2C97D44EE9F83A4F2F194E57533B16FBE673176E1FFC21C9F9A35AB35BDF94B9FDDDA179D035AA282DEE80DBC55489C6DE676C2B6D24790CCC15044AE952CACE8E7B4AA75C51632ACB52F75EE6A660979C46E89354C92C1FE60BDB7140BAAF7D22CAB8FC8865A1FA070416A28FEF51262E27E5F7C06CB46D68682BF2731014BB17CD18940563818EBA720A85A78E08491E7379E071A7B92253DF2BF6A8C14473D7247B81CBD565057BBF45116F1AD2045C6685257C39B12764DD0AAF8A9857D35960E41E44985DA2CC4E4A06D26157E01BAC866E40A3C1B28DED234129B89DEE47A2E22724F766876E6986B8C65
+
+
+
diff --git a/src/tests/test_gf2m.cpp b/src/tests/test_gf2m.cpp
new file mode 100644
index 000000000..7557672a6
--- /dev/null
+++ b/src/tests/test_gf2m.cpp
@@ -0,0 +1,46 @@
+/*
+* (C) 2015 Jack Lloyd
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#include "tests.h"
+
+#if defined(BOTAN_HAS_MCELIECE)
+
+#include <botan/gf2m_small_m.h>
+
+BOTAN_TEST_CASE(gf2m, "GF(2^m)", {
+
+ using namespace Botan;
+
+ for(size_t degree = 2; degree <= 16; ++degree)
+ {
+ GF2m_Field field(degree);
+
+ for(size_t i = 0; i <= field.gf_ord(); ++i)
+ {
+ gf2m a = i;
+
+ BOTAN_TEST(field.gf_square(a), field.gf_mul(a, a), "Square and multiply");
+
+ /*
+ * This sequence is from the start of gf2m_decomp_rootfind_state::calc_Fxj_j_neq_0
+ */
+ {
+ const gf2m jl_gray = field.gf_l_from_n(a);
+ gf2m xl_j_tt_5 = field.gf_square_rr(jl_gray);
+ const gf2m xl_gray_tt_3 = field.gf_mul_rrr(xl_j_tt_5, jl_gray);
+ xl_j_tt_5 = field.gf_mul_rrr(xl_j_tt_5, xl_gray_tt_3);
+ gf2m s = field.gf_mul_nrr(xl_gray_tt_3, field.gf_ord());
+ BOTAN_CONFIRM(s <= field.gf_ord(), "Less than order");
+ }
+ }
+ }
+ });
+
+#else
+
+SKIP_TEST(gf2m);
+
+#endif
diff --git a/src/tests/test_mce.cpp b/src/tests/test_mce.cpp
new file mode 100644
index 000000000..cd85cdab1
--- /dev/null
+++ b/src/tests/test_mce.cpp
@@ -0,0 +1,96 @@
+/*
+* (C) 2015 Jack Lloyd
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#include "tests.h"
+
+#include <botan/mceliece.h>
+#include <botan/mce_kem.h>
+#include <botan/hmac_drbg.h>
+#include <botan/hash.h>
+#include <botan/hex.h>
+#include <iostream>
+#include <fstream>
+
+using namespace Botan;
+
+namespace {
+
+std::string hash_bytes(const byte b[], size_t len)
+ {
+ std::unique_ptr<HashFunction> hash(HashFunction::create("SHA-256"));
+ hash->update(b, len);
+ return hex_encode(hash->final());
+ }
+
+template<typename A>
+std::string hash_bytes(const std::vector<byte, A>& v)
+ {
+ return hash_bytes(v.data(), v.size());
+ }
+
+size_t mce_test(const std::string& key_seed_hex,
+ size_t n, size_t t,
+ const std::string& exp_fingerprint_pub,
+ const std::string& exp_fingerprint_priv,
+ const std::string& encrypt_rng_seed_hex,
+ const std::string& ct_hex,
+ const std::string& shared_key_hex)
+ {
+ const secure_vector<byte> keygen_seed = hex_decode_locked(key_seed_hex);
+ const secure_vector<byte> encrypt_seed = hex_decode_locked(encrypt_rng_seed_hex);
+
+ Test_State _test;
+
+ HMAC_DRBG rng("HMAC(SHA-384)");
+
+ rng.add_entropy(keygen_seed.data(), keygen_seed.size());
+
+ McEliece_PrivateKey mce_priv(rng, n, t);
+
+ const std::string f_pub = hash_bytes(mce_priv.x509_subject_public_key());
+ const std::string f_priv = hash_bytes(mce_priv.pkcs8_private_key());
+
+ BOTAN_TEST(f_pub, exp_fingerprint_pub, "Public fingerprint");
+ BOTAN_TEST(f_priv, exp_fingerprint_priv, "Private fingerprint");
+
+ rng.clear();
+ rng.add_entropy(encrypt_seed.data(), encrypt_seed.size());
+
+ McEliece_KEM_Encryptor kem_enc(mce_priv);
+ McEliece_KEM_Decryptor kem_dec(mce_priv);
+
+ const std::pair<secure_vector<byte>,secure_vector<byte> > ciphertext__sym_key = kem_enc.encrypt(rng);
+ const secure_vector<byte>& ciphertext = ciphertext__sym_key.first;
+ const secure_vector<byte>& sym_key_encr = ciphertext__sym_key.second;
+
+ const secure_vector<byte> sym_key_decr = kem_dec.decrypt(ciphertext.data(), ciphertext.size());
+
+ BOTAN_TEST(ct_hex, hex_encode(ciphertext), "Ciphertext");
+ BOTAN_TEST(hex_encode(sym_key_encr), shared_key_hex, "Encrypted key");
+ BOTAN_TEST(hex_encode(sym_key_decr), shared_key_hex, "Decrypted key");
+
+ return _test.failed();
+ }
+
+}
+
+size_t test_mce()
+ {
+
+ std::ifstream vec(TEST_DATA_DIR "/pubkey/mce.vec");
+ return run_tests_bb(vec, "McElieceSeed", "Ciphertext", true,
+ [](std::map<std::string, std::string> m) -> size_t
+ {
+ return mce_test(m["McElieceSeed"],
+ to_u32bit(m["KeyN"]),
+ to_u32bit(m["KeyT"]),
+ m["PublicKeyFingerprint"],
+ m["PrivateKeyFingerprint"],
+ m["EncryptPRNGSeed"],
+ m["Ciphertext"],
+ m["SharedKey"]);
+ });
+ }
diff --git a/src/tests/test_mceliece.cpp b/src/tests/test_mceliece.cpp
index 616f64be9..a82588a8f 100644
--- a/src/tests/test_mceliece.cpp
+++ b/src/tests/test_mceliece.cpp
@@ -13,6 +13,7 @@
#include <botan/pubkey.h>
#include <botan/oids.h>
#include <botan/mceliece.h>
+#include <botan/internal/code_based_util.h>
#include <botan/mce_kem.h>
#include <botan/loadstor.h>
#include <botan/hex.h>
@@ -32,35 +33,6 @@ namespace {
const size_t MCE_RUNS = 5;
-size_t test_mceliece_message_parts(RandomNumberGenerator& rng, size_t code_length, size_t error_weight)
- {
- secure_vector<gf2m> err_pos1 = create_random_error_positions(code_length, error_weight, rng);
- secure_vector<byte> message1((code_length+7)/8);
- rng.randomize(message1.data(), message1.size() - 1);
- mceliece_message_parts parts1(err_pos1, message1, code_length);
- secure_vector<byte> err_vec1 = parts1.get_error_vector();
-
- secure_vector<byte> concat1 = parts1.get_concat();
-
- mceliece_message_parts parts2( concat1.data(), concat1.size(), code_length);
-
- secure_vector<byte> err_vec2 = parts2.get_error_vector();
- if(err_vec1 != err_vec2)
- {
- std::cout << "error with error vector from message parts" << std::endl;
- return 1;
- }
-
- secure_vector<byte> message2 = parts2.get_message_word();
- if(message1 != message2)
- {
- std::cout << "error with message word from message parts" << std::endl;
- return 1;
- }
-
- return 0;
- }
-
size_t test_mceliece_kem(const McEliece_PrivateKey& sk,
const McEliece_PublicKey& pk,
RandomNumberGenerator& rng)
@@ -83,50 +55,26 @@ size_t test_mceliece_kem(const McEliece_PrivateKey& sk,
std::cout << "mce KEM test failed, error during encryption/decryption" << std::endl;
++fails;
}
-
-#if 0
- // takes a long time:
- for(size_t j = 0; j < code_length; j++)
- {
- // flip the j-th bit in the ciphertext
- secure_vector<byte> wrong_ct(ciphertext);
- size_t byte_pos = j/8;
- size_t bit_pos = j % 8;
- wrong_ct[byte_pos] ^= 1 << bit_pos;
- try
- {
- secure_vector<byte> decrypted = priv_op.decrypt(wrong_ct.data(), wrong_ct.size());
- }
- catch(const Integrity_Failure)
- {
- continue;
- }
- std::cout << "manipulation in ciphertext not detected" << std::endl;
- err_cnt++;
- }
-#endif
-
}
return fails;
}
+/*
size_t test_mceliece_raw(const McEliece_PrivateKey& sk,
const McEliece_PublicKey& pk,
RandomNumberGenerator& rng)
{
const size_t code_length = pk.get_code_length();
McEliece_Private_Operation priv_op(sk);
- McEliece_Public_Operation pub_op(pk, code_length);
+ McEliece_Public_Operation pub_op(pk);
size_t err_cnt = 0;
for(size_t i = 0; i != MCE_RUNS; i++)
{
- secure_vector<byte> plaintext((pk.get_message_word_bit_length()+7)/8);
- rng.randomize(plaintext.data(), plaintext.size() - 1);
+ const secure_vector<byte> plaintext = pk.random_plaintext_element(rng);
secure_vector<gf2m> err_pos = create_random_error_positions(code_length, pk.get_t(), rng);
-
mceliece_message_parts parts(err_pos, plaintext, code_length);
secure_vector<byte> message_and_error_input = parts.get_concat();
secure_vector<byte> ciphertext = pub_op.encrypt(message_and_error_input.data(), message_and_error_input.size(), rng);
@@ -158,6 +106,7 @@ size_t test_mceliece_raw(const McEliece_PrivateKey& sk,
return err_cnt;
}
+*/
#if defined(BOTAN_HAS_MCEIES)
size_t test_mceies(const McEliece_PrivateKey& sk,
@@ -173,8 +122,8 @@ size_t test_mceies(const McEliece_PrivateKey& sk,
const size_t ad_len = sizeof(ad);
const secure_vector<byte> pt = rng.random_vec(rng.next_byte());
- const secure_vector<byte> ct = mceies_encrypt(pk, pt, ad, ad_len, rng);
- const secure_vector<byte> dec = mceies_decrypt(sk, ct, ad, ad_len);
+ const secure_vector<byte> ct = mceies_encrypt(pk, pt.data(), pt.size(), ad, ad_len, rng);
+ const secure_vector<byte> dec = mceies_decrypt(sk, ct.data(), ct.size(), ad, ad_len);
if(pt != dec)
{
@@ -195,7 +144,7 @@ size_t test_mceies(const McEliece_PrivateKey& sk,
try
{
- mceies_decrypt(sk, bad_ct, ad, ad_len);
+ mceies_decrypt(sk, bad_ct.data(), bad_ct.size(), ad, ad_len);
std::cout << "Successfully decrypted manipulated ciphertext!" << std::endl;
++fails;
}
@@ -232,18 +181,7 @@ size_t test_mceliece()
size_t code_length = params__n__t_min_max[i];
for(size_t t = params__n__t_min_max[i+1]; t <= params__n__t_min_max[i+2]; t++)
{
- //std::cout << "testing parameters n = " << code_length << ", t = " << t << std::endl;
-
- try
- {
- fails += test_mceliece_message_parts(rng, code_length, t);
- }
- catch(std::exception& e)
- {
- std::cout << e.what() << std::endl;
- fails++;
- }
- tests += 1;
+ std::cout << "testing parameters n = " << code_length << ", t = " << t << std::endl;
McEliece_PrivateKey sk1(rng, code_length, t);
const McEliece_PublicKey& pk1 = sk1;
@@ -274,17 +212,6 @@ size_t test_mceliece()
try
{
- fails += test_mceliece_raw(sk, pk, rng);
- }
- catch(std::exception& e)
- {
- std::cout << e.what() << std::endl;
- fails++;
- }
- tests += 1;
-
- try
- {
fails += test_mceliece_kem(sk, pk, rng);
}
catch(std::exception& e)
diff --git a/src/tests/tests.cpp b/src/tests/tests.cpp
index 763417209..d213b6a3a 100644
--- a/src/tests/tests.cpp
+++ b/src/tests/tests.cpp
@@ -301,7 +301,9 @@ int main(int argc, char* argv[])
DEF_TEST(ecdsa);
DEF_TEST(gost_3410);
DEF_TEST(curve25519);
+ DEF_TEST(gf2m);
DEF_TEST(mceliece);
+ DEF_TEST(mce);
DEF_TEST(ecc_unit);
DEF_TEST(ecc_randomized);
diff --git a/src/tests/tests.h b/src/tests/tests.h
index 14ec5a17b..6d6a2d34c 100644
--- a/src/tests/tests.h
+++ b/src/tests/tests.h
@@ -142,7 +142,9 @@ size_t test_ecc_random();
size_t test_ecdsa();
size_t test_gost_3410();
size_t test_curve25519();
+size_t test_gf2m();
size_t test_mceliece();
+size_t test_mce();
// One off tests
size_t test_ocb();