ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Crypt-Ed25519/t/02_native.t
Revision: 1.3
Committed: Sun Mar 29 06:19:46 2015 UTC (11 years, 5 months ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: rel-1_0, rel-1_02, rel-1_03, rel-1_01, rel-1_04, rel-1_05, HEAD
Changes since 1.2: +6 -2 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 BEGIN { $| = 1; print "1..1537\n"; }
2
3 use Crypt::Ed25519;
4
5 print "ok 1\n";
6
7 my $i = 1;
8
9 for (0..511) {
10 my $secret = Crypt::Ed25519::eddsa_secret_key;
11 my ($pub, $priv) = Crypt::Ed25519::generate_keypair $secret;
12 my $m = Crypt::Ed25519::eddsa_secret_key;
13
14 $m = substr "$m$m", 0, rand 64;
15
16 my $s = Crypt::Ed25519::sign $m, $pub, $priv;
17
18 my $s2 = Crypt::Ed25519::eddsa_sign $m, $pub, $secret;
19 print $s eq $s2 ? "" : "not ", "ok ", ++$i, "\n";
20
21 my $valid = Crypt::Ed25519::verify $m, $pub, $s;
22 print $valid ? "" : "not ", "ok ", ++$i, "\n";
23
24 my $notvalid = !Crypt::Ed25519::verify "x$m", $pub, $s;
25 print $notvalid ? "" : "not ", "ok ", ++$i, "\n";
26 }
27