| 449 | |
| 450 | #ifdef _DEBUG |
| 451 | bool 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 |
nothing calls this directly
no test coverage detected