MCPcopy Create free account
hub / github.com/amule-project/amule / Debug_CheckCrypting

Method Debug_CheckCrypting

src/ClientCreditsList.cpp:451–489  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

449
450#ifdef _DEBUG
451bool CClientCreditsList::Debug_CheckCrypting(){
452 // create random key
453 CryptoPP::AutoSeededX917RNG<CryptoPP::DES_EDE3> rng;
454
455 CryptoPP::RSASSA_PKCS1v15_SHA_Signer priv(rng, 384);
456 CryptoPP::RSASSA_PKCS1v15_SHA_Verifier pub(priv);
457
458 uint8_t abyPublicKey[80];
459 CryptoPP::ArraySink asink(abyPublicKey, 80);
460 pub.DEREncode(asink);
461 int8 PublicKeyLen = asink.TotalPutLength();
462 asink.MessageEnd();
463 uint32 challenge = rand();
464 // create fake client which pretends to be this emule
465 CreditStruct* newcstruct = new CreditStruct();
466 CClientCredits newcredits(newcstruct);
467 newcredits.SetSecureIdent(m_abyMyPublicKey,m_nMyPublicKeyLen);
468 newcredits.m_dwCryptRndChallengeFrom = challenge;
469 // create signature with fake priv key
470 uint8_t pachSignature[200];
471 memset(pachSignature,0,200);
472 uint8 sigsize = CreateSignature(&newcredits,pachSignature,200,0,false, &priv);
473
474
475 // next fake client uses the random created public key
476 CreditStruct* newcstruct2 = new CreditStruct();
477 CClientCredits newcredits2(newcstruct2);
478 newcredits2.m_dwCryptRndChallengeFor = challenge;
479
480 // if you uncomment one of the following lines the check has to fail
481 //abyPublicKey[5] = 34;
482 //m_abyMyPublicKey[5] = 22;
483 //pachSignature[5] = 232;
484
485 newcredits2.SetSecureIdent(abyPublicKey,PublicKeyLen);
486
487 //now verify this signature - if it's true everything is fine
488 return VerifyIdent(&newcredits2,pachSignature,sigsize,0,0);
489}
490#endif
491// File_checked_for_headers

Callers

nothing calls this directly

Calls 1

SetSecureIdentMethod · 0.80

Tested by

no test coverage detected