MCPcopy Create free account
hub / github.com/LUX-Core/lux / DoTest

Method DoTest

src/cryptopp/fipsalgt.cpp:423–1052  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

421 }
422
423 virtual void DoTest()
424 {
425 std::string output;
426
427 if (m_algorithm == "DSA")
428 {
429 if (m_test == "KeyPair")
430 {
431 DL_GroupParameters_DSA pqg;
432 int modLen = atol(m_bracketString.substr(6).c_str());
433 pqg.GenerateRandomWithKeySize(m_rng, modLen);
434
435 OutputData(output, "P ", pqg.GetModulus());
436 OutputData(output, "Q ", pqg.GetSubgroupOrder());
437 OutputData(output, "G ", pqg.GetSubgroupGenerator());
438
439 int n = atol(m_data["N"].c_str());
440 for (int i=0; i<n; i++)
441 {
442 DSA::Signer priv;
443 priv.AccessKey().GenerateRandom(m_rng, pqg);
444 DSA::Verifier pub(priv);
445
446 OutputData(output, "X ", priv.GetKey().GetPrivateExponent());
447 OutputData(output, "Y ", pub.GetKey().GetPublicElement());
448 AttachedTransformation()->Put((byte *)output.data(), output.size());
449 output.resize(0);
450 }
451 }
452 else if (m_test == "PQGGen")
453 {
454 int n = atol(m_data["N"].c_str());
455 for (int i=0; i<n; i++)
456 {
457 Integer p, q, h, g;
458 int counter;
459
460 SecByteBlock seed(SHA::DIGESTSIZE);
461 do
462 {
463 m_rng.GenerateBlock(seed, seed.size());
464 }
465 while (!DSA::GeneratePrimes(seed, seed.size()*8, counter, p, 1024, q));
466 h.Randomize(m_rng, 2, p-2);
467 g = a_exp_b_mod_c(h, (p-1)/q, p);
468
469 OutputData(output, "P ", p);
470 OutputData(output, "Q ", q);
471 OutputData(output, "G ", g);
472 OutputData(output, "Seed ", seed);
473 OutputData(output, "c ", counter);
474 OutputData(output, "H ", h, p.ByteCount());
475 AttachedTransformation()->Put((byte *)output.data(), output.size());
476 output.resize(0);
477 }
478 }
479 else if (m_test == "SigGen")
480 {

Callers

nothing calls this directly

Calls 15

AttachedTransformationFunction · 0.85
memcpyFunction · 0.85
IntToStringFunction · 0.85
MakeParametersFunction · 0.85
ByteCountMethod · 0.80
MessageEndMethod · 0.80
CleanNewMethod · 0.80
ProcessBlockMethod · 0.80
StringSourceFunction · 0.70
ExceptionFunction · 0.70
GenerateRandomMethod · 0.45

Tested by

no test coverage detected