Alt-Crypt-RSA-BigInt

 view release on metacpan or  search on metacpan

t/11-wrapper.t  view on Meta::CPAN

    ignorant of what greatness is promised thee. Lay it to thy heart,
    and farewell.

    Glamis thou art, and Cawdor, and shalt be
    What thou art promised. Yet do I fear thy nature.
    It is too full o' the milk of human kindness
    To catch the nearest way. Thou wouldst be great;
    Art not without ambition, but without
    The illness should attend it. What thou wouldst highly,
    That wouldst thou holily; wouldst not play false,
    And yet wouldst wrongly win. Thou'ldst have, great Glamis,
    That which cries, "Thus thou must do, if thou have it;
    And that which rather thou dost fear to do
    Than wishest should be undone." Hie thee hither,
    That I may pour my spirits in thine ear,
    And chastise with the valor of my tongue
    All that impedes thee from the golden round,
    Which fate and metaphysical aid doth seem
    To have thee crown'd withal."

EOM

for my $keysize (@keysizes) {

    # $plaintext = "" if $keysize == 512;

    my ($pub, $pri) = $rsa->keygen (
                        Size      => $keysize,
                        Identity  => "Lord Macbeth",
                        Password  => "xx"
                      ) or die $rsa->errstr();

    my $ctxt = $rsa->encrypt (
                        Message => $plaintext,
                        Key     => $pub,
                        Armour  => 1,
                     ) || die $rsa->errstr();

    # diag($ctxt);
    like( $ctxt, qr/Scheme: Crypt::RSA::ES::OAEP/, "Encrypted $keysize bits with armor" );

    my $ptxt = $rsa->decrypt (
                        Cyphertext => $ctxt,
                        Key        => $pri,
                        Armour     => 1,
                     );
    die $rsa->errstr() if $rsa->errstr();

    # diag($ptxt);
    is($ptxt, $plaintext, "Decrypted with armor");

    my $signature = $rsa->sign (
                        Message => $plaintext,
                        Key => $pri,
                        Armour => 1,
                    ) || die $rsa->errstr();

    # diag($signature);
    like( $signature, qr/Scheme: Crypt::RSA::SS::PSS/, "RSA signature" );

    my $verify = $rsa->verify (
                    Message => $plaintext,
                    Key => $pub,
                    Signature => $signature,
                    Armour => 1,
                 );

    ok($verify, "Verified RSA signature");

}



( run in 0.619 second using v1.01-cache-2.11-cpan-df04353d9ac )