~ubuntu-branches/ubuntu/jaunty/libcrypto++/jaunty

« back to all changes in this revision

Viewing changes to validat2.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jens Peter Secher
  • Date: 2006-03-16 23:08:48 UTC
  • mfrom: (3.1.2 dapper)
  • Revision ID: james.westby@ubuntu.com-20060316230848-wwtupzit1dy23s7s
Tags: 5.2.1c2a-3
* Patch source so that it compiles with GCC 4.1 .  More specifically,
  avoid mixing implicit calls to base classes and free-standing
  functions.
  (Closes: #356170).
* Use LDFLAGS=-pthread to fix linking errors.

Show diffs side-by-side

added added

removed removed

Lines of Context:
269
269
                        "\x69\x94\xac\x04\xf3\x41\xb5\x7d\x05\x20\x2d\x42\x8f\xb2\xa2\x7b"
270
270
                        "\x5c\x77\xdf\xd9\xb1\x5b\xfc\x3d\x55\x93\x53\x50\x34\x10\xc1\xe1";
271
271
 
272
 
                FileSource keys(PKGDATA("rsa512a.dat"), true, new HexDecoder);
 
272
                FileSource keys("rsa512a.dat", true, new HexDecoder);
273
273
                RSASSA_PKCS1v15_MD2_Signer rsaPriv(keys);
274
274
                RSASSA_PKCS1v15_MD2_Verifier rsaPub(rsaPriv);
275
275
 
294
294
                cout << "invalid signature verification\n";
295
295
        }
296
296
        {
297
 
                FileSource keys(PKGDATA("rsa1024.dat"), true, new HexDecoder);
 
297
                FileSource keys("rsa1024.dat", true, new HexDecoder);
298
298
                RSAES_PKCS1v15_Decryptor rsaPriv(keys);
299
299
                RSAES_PKCS1v15_Encryptor rsaPub(rsaPriv);
300
300
 
315
315
                bq.Put(oaepSeed, 20);
316
316
                FixedRNG rng(bq);
317
317
 
318
 
                FileSource privFile(PKGDATA("rsa400pv.dat"), true, new HexDecoder);
319
 
                FileSource pubFile(PKGDATA("rsa400pb.dat"), true, new HexDecoder);
 
318
                FileSource privFile("rsa400pv.dat", true, new HexDecoder);
 
319
                FileSource pubFile("rsa400pb.dat", true, new HexDecoder);
320
320
                RSAES_OAEP_SHA_Decryptor rsaPriv;
321
321
                rsaPriv.AccessKey().BERDecodeKey(privFile);
322
322
                RSAES_OAEP_SHA_Encryptor rsaPub(pubFile);
339
339
{
340
340
        cout << "\nDH validation suite running...\n\n";
341
341
 
342
 
        FileSource f(PKGDATA("dh1024.dat"), true, new HexDecoder());
 
342
        FileSource f("dh1024.dat", true, new HexDecoder());
343
343
        DH dh(f);
344
344
        return SimpleKeyAgreementValidate(dh);
345
345
}
348
348
{
349
349
        cout << "\nMQV validation suite running...\n\n";
350
350
 
351
 
        FileSource f(PKGDATA("mqv1024.dat"), true, new HexDecoder());
 
351
        FileSource f("mqv1024.dat", true, new HexDecoder());
352
352
        MQV mqv(f);
353
353
        return AuthenticatedKeyAgreementValidate(mqv);
354
354
}
357
357
{
358
358
        cout << "\nLUC-DH validation suite running...\n\n";
359
359
 
360
 
        FileSource f(PKGDATA("lucd512.dat"), true, new HexDecoder());
 
360
        FileSource f("lucd512.dat", true, new HexDecoder());
361
361
        LUC_DH dh(f);
362
362
        return SimpleKeyAgreementValidate(dh);
363
363
}
366
366
{
367
367
        cout << "\nXTR-DH validation suite running...\n\n";
368
368
 
369
 
        FileSource f(PKGDATA("xtrdh171.dat"), true, new HexDecoder());
 
369
        FileSource f("xtrdh171.dat", true, new HexDecoder());
370
370
        XTR_DH dh(f);
371
371
        return SimpleKeyAgreementValidate(dh);
372
372
}
376
376
        cout << "\nElGamal validation suite running...\n\n";
377
377
        bool pass = true;
378
378
        {
379
 
                FileSource fc(PKGDATA("elgc1024.dat"), true, new HexDecoder);
 
379
                FileSource fc("elgc1024.dat", true, new HexDecoder);
380
380
                ElGamalDecryptor privC(fc);
381
381
                ElGamalEncryptor pubC(privC);
382
382
                privC.AccessKey().Precompute();
394
394
        cout << "\nDLIES validation suite running...\n\n";
395
395
        bool pass = true;
396
396
        {
397
 
                FileSource fc(PKGDATA("dlie1024.dat"), true, new HexDecoder);
 
397
                FileSource fc("dlie1024.dat", true, new HexDecoder);
398
398
                DLIES<>::Decryptor privC(fc);
399
399
                DLIES<>::Encryptor pubC(privC);
400
400
                pass = CryptoSystemValidate(privC, pubC) && pass;
417
417
        cout << "\nNR validation suite running...\n\n";
418
418
        bool pass = true;
419
419
        {
420
 
                FileSource f(PKGDATA("nr2048.dat"), true, new HexDecoder);
 
420
                FileSource f("nr2048.dat", true, new HexDecoder);
421
421
                NR<SHA>::Signer privS(f);
422
422
                privS.AccessKey().Precompute();
423
423
                NR<SHA>::Verifier pubS(privS);
440
440
 
441
441
        bool pass = true, fail;
442
442
        {
443
 
        FileSource fs(PKGDATA("dsa512.dat"), true, new HexDecoder());
 
443
        FileSource fs("dsa512.dat", true, new HexDecoder());
444
444
        GDSA<SHA>::Signer priv(fs);
445
445
        priv.AccessKey().Precompute(16);
446
446
        GDSA<SHA>::Verifier pub(priv);
482
482
        fail = pub.VerifyMessage((byte *)"xyz", 3, sig, sizeof(sig));
483
483
        pass = pass && !fail;
484
484
        }
485
 
        FileSource fs1(PKGDATA("dsa1024.dat"), true, new HexDecoder());
 
485
        FileSource fs1("dsa1024.dat", true, new HexDecoder());
486
486
        DSA::Signer priv(fs1);
487
487
        DSA::Verifier pub(priv);
488
 
        FileSource fs2(PKGDATA("dsa1024b.dat"), true, new HexDecoder());
 
488
        FileSource fs2("dsa1024b.dat", true, new HexDecoder());
489
489
        DSA::Verifier pub1(fs2);
490
490
        assert(pub.GetKey() == pub1.GetKey());
491
491
        pass = SignatureValidate(priv, pub, thorough) && pass;
498
498
        bool pass=true;
499
499
 
500
500
        {
501
 
                FileSource f(PKGDATA("luc1024.dat"), true, new HexDecoder);
 
501
                FileSource f("luc1024.dat", true, new HexDecoder);
502
502
                LUCSSA_PKCS1v15_SHA_Signer priv(f);
503
503
                LUCSSA_PKCS1v15_SHA_Verifier pub(priv);
504
504
                pass = SignatureValidate(priv, pub) && pass;
515
515
{
516
516
        cout << "\nLUC-HMP validation suite running...\n\n";
517
517
 
518
 
        FileSource f(PKGDATA("lucs512.dat"), true, new HexDecoder);
 
518
        FileSource f("lucs512.dat", true, new HexDecoder);
519
519
        LUC_HMP<SHA>::Signer privS(f);
520
520
        LUC_HMP<SHA>::Verifier pubS(privS);
521
521
        bool pass = SignatureValidate(privS, pubS);
522
522
 
523
523
        cout << "\nLUC-IES validation suite running...\n\n";
524
524
 
525
 
        FileSource fc(PKGDATA("lucc512.dat"), true, new HexDecoder);
 
525
        FileSource fc("lucc512.dat", true, new HexDecoder);
526
526
        LUC_IES<>::Decryptor privC(fc);
527
527
        LUC_IES<>::Encryptor pubC(privC);
528
528
        pass = CryptoSystemValidate(privC, pubC) && pass;
536
536
        bool pass=true;
537
537
 
538
538
        {
539
 
                FileSource f(PKGDATA("rabi1024.dat"), true, new HexDecoder);
 
539
                FileSource f("rabi1024.dat", true, new HexDecoder);
540
540
                RabinSS<PSSR, SHA>::Signer priv(f);
541
541
                RabinSS<PSSR, SHA>::Verifier pub(priv);
542
542
                pass = SignatureValidate(priv, pub) && pass;
553
553
{
554
554
        cout << "\nRW validation suite running...\n\n";
555
555
 
556
 
        FileSource f(PKGDATA("rw1024.dat"), true, new HexDecoder);
 
556
        FileSource f("rw1024.dat", true, new HexDecoder);
557
557
        RWSS<PSSR, SHA>::Signer priv(f);
558
558
        RWSS<PSSR, SHA>::Verifier pub(priv);
559
559
 
565
565
{
566
566
        cout << "\nBlumGoldwasser validation suite running...\n\n";
567
567
 
568
 
        FileSource f(PKGDATA("blum512.dat"), true, new HexDecoder);
 
568
        FileSource f("blum512.dat", true, new HexDecoder);
569
569
        BlumGoldwasserPrivateKey priv(f);
570
570
        BlumGoldwasserPublicKey pub(priv);
571
571
 
735
735
                "\x74\x02\x37\x0E\xED\x0A\x06\xAD\xF4\x15\x65\xB8\xE1\xD1\x45\xAE\x39\x19\xB4\xFF\x5D\xF1\x45\x7B\xE0\xFE\x72\xED\x11\x92\x8F\x61\x41\x4F\x02\x00\xF2\x76\x6F\x7C"
736
736
                "\x79\xA2\xE5\x52\x20\x5D\x97\x5E\xFE\x39\xAE\x21\x10\xFB\x35\xF4\x80\x81\x41\x13\xDD\xE8\x5F\xCA\x1E\x4F\xF8\x9B\xB2\x68\xFB\x28";
737
737
 
738
 
        FileSource keys(PKGDATA("esig1536.dat"), true, new HexDecoder);
 
738
        FileSource keys("esig1536.dat", true, new HexDecoder);
739
739
        ESIGN<SHA>::Signer signer(keys);
740
740
        ESIGN<SHA>::Verifier verifier(signer);
741
741