ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Crypt-Ed25519/t/01_python.t
Revision: 1.1
Committed: Fri Mar 27 20:23:13 2015 UTC (11 years, 5 months ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: rel-0_1
Log Message:
*** empty log message ***

File Contents

# Content
1 BEGIN { $| = 1; print "1..1081\n"; }
2
3 use Crypt::Ed25519;
4
5 # test vectors generated from ed25519's website sign.input via extract-sign.input
6
7 my @tv = unpack "(a32 a32 a64 w/a*)*", do {
8 open my $fh, "<t/sign.input"
9 or die "t/sign.input: $!";
10 local $/;
11 readline $fh
12 };
13
14 print "ok 1\n";
15
16 my $i = 1;
17
18 while (@tv) {
19 my ($seed, $pub, $s, $m) = splice @tv, -4, 4;
20
21 my $pub_ = Crypt::Ed25519::eddsa_public_key $seed;
22 print $pub_ eq $pub ? "" : "not ", "ok ", ++$i, "\n";
23
24 my $s_ = Crypt::Ed25519::eddsa_sign $m, $pub, $seed;
25 print $s eq $s_ ? "" : "not ", "ok ", ++$i, "\n";
26
27 my $valid = Crypt::Ed25519::eddsa_verify $m, $pub, $s;
28 print $valid ? "" : "not ", "ok ", ++$i, "\n";
29
30 my $valid = !Crypt::Ed25519::eddsa_verify "x$m", $pub, $s;
31 print $valid ? "" : "not ", "ok ", ++$i, "\n";
32 }
33