ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/Crypt-Ed25519/t/01_python.t
Revision: 1.2
Committed: Sat Mar 28 19:42:35 2015 UTC (9 years, 3 months ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: rel-0_9
Changes since 1.1: +3 -3 lines
Log Message:
0.2

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, "<:raw", "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 $notvalid = !Crypt::Ed25519::eddsa_verify "x$m", $pub, $s;
31 print $notvalid ? "" : "not ", "ok ", ++$i, "\n";
32 }
33