/* * Test Diffie-Hellman in RFC-7748. * * Note that it's not like the ECDH of OpenPGP, where we use * ephemeral public key. */ static void test_dh (int testno, const char *a_priv_str, const char *a_pub_str, const char *b_priv_str, const char *b_pub_str, const char *result_str) { /* Test A for private key corresponds to public key. */ test_cv (testno, a_priv_str, G_X, a_pub_str); /* Test B for private key corresponds to public key. */ test_cv (testno, b_priv_str, G_X, b_pub_str); /* Test DH with A's private key and B's public key. */ test_cv (testno, a_priv_str, b_pub_str, result_str); /* Test DH with B's private key and A's public key. */ test_cv (testno, b_priv_str, a_pub_str, result_str); }
TEST_F(CVTest, epsilon_svr){ SvmParam param; param.svm_type = SvmParam::EPSILON_SVR; param.gamma = 0.125; EXPECT_NEAR(test_cv(param), 0.044, 1e-3); }
TEST_F(CVTest, nu_svr){ SvmParam param; param.svm_type = SvmParam::NU_SVR; param.gamma = 0.125; EXPECT_NEAR(test_cv(param), 0.045, 1e-3); }
void instanitate() { test_non_cv(& C::non_cv); test_c_non_v(& C::c_non_v); test_v_non_c(& C::v_non_c); test_cv(& C::cv); }
TEST_F(CVTest, cv_nu_svc){ SvmParam param; param.svm_type = SvmParam::NU_SVC; param.kernel_type = SvmParam::RBF; param.gamma = 0.125; EXPECT_NEAR(test_cv(param), 0.660, 1e-3); }
TEST_F(CVTest, cv_c_svc){ SvmParam param; param.svm_type = SvmParam::C_SVC; param.C = 10; param.kernel_type = SvmParam::RBF; param.gamma = 0.125; EXPECT_NEAR(test_cv(param), 0.973, 1e-3); }
int main(int argc, char **argv) { thread_init(); register_interrupt_handler(0); /* Test cv */ test_cv(); return 0; }
int _tmain(int argc, _TCHAR* argv[]) { LOG_F("xTest main(), 测试 \n"); int arg = 1018; switch(arg) { case 1000: { test_util_ex(); }break; case 1: { test_util(); }break; case 2: { test_container(); }break; case 3: { test_thread(); }break; case 4: { test_net(true); }break; case 5: { test_boost(); }break; case 6: { test_kbe(); }break; case 1001: { test_db(); }break; case 1002: { test_math(); }break; case 1003: { test_design(); }break; case 1005: { //test_net(false); test_async(true); }break; case 1006: { test_lua(); }break; case 1007: { test_js(); }break; case 1008: { test_proto(); }break; case 1010: { test_graph(); }break; case 1011: { test_graph_d3d(); }break; case 1013: { test_cv(); }break; case 1015: { test_battle(); }break; case 1016: { test_hacker(); }break; case 1017: { test_yh(); }break; case 1018: { test_ai(); } case 1900: { test_tool(); }break; default: { MainEx(argc, argv); }break; } // { // int n = X::Init(NULL); // LOGD_F(" n = %d", n); // // X_HSER->Init(); // X_HSER->Start(); // // X_HSER->Stop(); // X_HSER->Destroy(); // } // { // // [4/26/2015 Administrator] // HINSTANCE hnst=LoadLibrary(_T("xService.dll")); // FreeLibrary(hnst); // // HINSTANCE hnst2=LoadLibrary(_T("xService.dll")); // FreeLibrary(hnst); // // } LOG_F("xTest main(), end"); while(true) { X::Sleep_f(1); } return 0; }
static void check_cv25519 (void) { int ntests; info ("Checking Curve25519.\n"); ntests = 0; /* * Values are cited from RFC-7748: 5.2. Test Vectors. * Following two tests are for the first type test. */ test_cv (1, "a546e36bf0527c9d3b16154b82465edd62144c0ac1fc5a18506a2244ba449ac4", "e6db6867583030db3594c1a424b15f7c726624ec26b3353b10a903a6d0ab1c4c", "c3da55379de9c6908e94ea4df28d084f32eccf03491c71f754b4075577a28552"); ntests++; test_cv (2, "4b66e9d4d1b4673c5ad22691957d6af5c11b6421e0ea01d42ca4169e7918ba0d", "e5210f12786811d3f4b7959d0538ae2c31dbe7106fc03c3efc4cd549c715a493", "95cbde9476e8907d7aade45cb4b873f88b595a68799fa152e6f8f7647aac7957"); ntests++; /* * Additional test. Value is from second type test. */ test_cv (3, G_X, G_X, "422c8e7a6227d7bca1350b3e2bb7279f7897b87bb6854b783c60e80311ae3079"); ntests++; /* * Following two tests are for the second type test, * with one iteration and 1,000 iterations. (1,000,000 iterations * takes too long.) */ test_it (4, G_X, 1, "422c8e7a6227d7bca1350b3e2bb7279f7897b87bb6854b783c60e80311ae3079"); ntests++; test_it (5, G_X, 1000, "684cf59ba83309552800ef566f2f4d3c1c3887c49360e3875f2eb94d99532c51"); ntests++; /* * Last test is from: 6. Diffie-Hellman, 6.1. Curve25519 */ test_dh (6, /* Alice's private key, a */ "77076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c2a", /* Alice's public key, X25519(a, 9) */ "8520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6a", /* Bob's private key, b */ "5dab087e624a8a4b79e17f8b83800ee66f3bb1292618b6fd1c2f8b27ff88e0eb", /* Bob's public key, X25519(b, 9) */ "de9edb7d7b7dc1b4d35b61c2ece435373f8343c85b78674dadfc7e146f882b4f", /* Their shared secret, K */ "4a5d9d5ba4ce2de1728e3bf480350f25e07e21c947d19e3376f09b3c1e161742"); ntests++; /* Seven tests which results 0. */ test_cv (7, "a546e36bf0527c9d3b16154b82465edd62144c0ac1fc5a18506a2244ba449ac4", "0000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000000"); ntests++; test_cv (8, "a546e36bf0527c9d3b16154b82465edd62144c0ac1fc5a18506a2244ba449ac4", "0100000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000000"); ntests++; test_cv (9, "a546e36bf0527c9d3b16154b82465edd62144c0ac1fc5a18506a2244ba449ac4", "e0eb7a7c3b41b8ae1656e3faf19fc46ada098deb9c32b1fd866205165f49b800", "0000000000000000000000000000000000000000000000000000000000000000"); ntests++; test_cv (10, "a546e36bf0527c9d3b16154b82465edd62144c0ac1fc5a18506a2244ba449ac4", "5f9c95bca3508c24b1d0b1559c83ef5b04445cc4581c8e86d8224eddd09f1157", "0000000000000000000000000000000000000000000000000000000000000000"); ntests++; test_cv (11, "a546e36bf0527c9d3b16154b82465edd62144c0ac1fc5a18506a2244ba449ac4", "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f", "0000000000000000000000000000000000000000000000000000000000000000"); ntests++; test_cv (12, "a546e36bf0527c9d3b16154b82465edd62144c0ac1fc5a18506a2244ba449ac4", "edffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f", "0000000000000000000000000000000000000000000000000000000000000000"); ntests++; test_cv (13, "a546e36bf0527c9d3b16154b82465edd62144c0ac1fc5a18506a2244ba449ac4", "eeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f", "0000000000000000000000000000000000000000000000000000000000000000"); ntests++; /* Five tests which resulted 0 if decodeUCoordinate didn't change MSB. */ test_cv (14, "a546e36bf0527c9d3b16154b82465edd62144c0ac1fc5a18506a2244ba449ac4", "cdeb7a7c3b41b8ae1656e3faf19fc46ada098deb9c32b1fd866205165f49b880", "7ce548bc4919008436244d2da7a9906528fe3a6d278047654bd32d8acde9707b"); ntests++; test_cv (15, "a546e36bf0527c9d3b16154b82465edd62144c0ac1fc5a18506a2244ba449ac4", "4c9c95bca3508c24b1d0b1559c83ef5b04445cc4581c8e86d8224eddd09f11d7", "e17902e989a034acdf7248260e2c94cdaf2fe1e72aaac7024a128058b6189939"); ntests++; test_cv (16, "a546e36bf0527c9d3b16154b82465edd62144c0ac1fc5a18506a2244ba449ac4", "d9ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "ea6e6ddf0685c31e152d5818441ac9ac8db1a01f3d6cb5041b07443a901e7145"); ntests++; test_cv (17, "a546e36bf0527c9d3b16154b82465edd62144c0ac1fc5a18506a2244ba449ac4", "daffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "845ddce7b3a9b3ee01a2f1fd4282ad293310f7a232cbc5459fb35d94bccc9d05"); ntests++; test_cv (18, "a546e36bf0527c9d3b16154b82465edd62144c0ac1fc5a18506a2244ba449ac4", "dbffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "6989e2cb1cea159acf121b0af6bf77493189c9bd32c2dac71669b540f9488247"); ntests++; if (ntests != N_TESTS) fail ("did %d tests but expected %d", ntests, N_TESTS); else if ((ntests % 256)) show_note ("%d tests done\n", ntests); }