wycheproof: hide debug output behind -v flag
This commit is contained in:
parent
e62534925b
commit
afc2e4b721
@ -18,7 +18,7 @@ tests-aead:
|
|||||||
@echo Undefined WYCHEPROOF_DIR; false
|
@echo Undefined WYCHEPROOF_DIR; false
|
||||||
.endif
|
.endif
|
||||||
.for p in ${AEAD}
|
.for p in ${AEAD}
|
||||||
perl ${.CURDIR}/aead.pl -x ./${p} \
|
perl ${.CURDIR}/aead.pl ${TESTOPTS} -x ./${p} \
|
||||||
${WYCHEPROOF_DIR}/testvectors/chacha20_poly1305_test.json \
|
${WYCHEPROOF_DIR}/testvectors/chacha20_poly1305_test.json \
|
||||||
${WYCHEPROOF_DIR}/testvectors_v1/chacha20_poly1305_test.json
|
${WYCHEPROOF_DIR}/testvectors_v1/chacha20_poly1305_test.json
|
||||||
.endfor
|
.endfor
|
||||||
|
@ -21,7 +21,7 @@ sub main ()
|
|||||||
my %opts;
|
my %opts;
|
||||||
my $rc = 0;
|
my $rc = 0;
|
||||||
|
|
||||||
getopts("x:", \%opts) && @ARGV > 0 or usage;
|
getopts("vx:", \%opts) && @ARGV > 0 or usage;
|
||||||
usage unless defined $opts{"x"};
|
usage unless defined $opts{"x"};
|
||||||
|
|
||||||
for my $f (@ARGV) {
|
for my $f (@ARGV) {
|
||||||
@ -42,6 +42,7 @@ sub main ()
|
|||||||
push(@args, "-m", $test->{msg});
|
push(@args, "-m", $test->{msg});
|
||||||
push(@args, "-T", $testgroup->{tagSize});
|
push(@args, "-T", $testgroup->{tagSize});
|
||||||
push(@args, "-t", $test->{tag});
|
push(@args, "-t", $test->{tag});
|
||||||
|
push(@args, "-v") if $opts{"v"};
|
||||||
|
|
||||||
open(my $th, "-|", $opts{"x"}, @args) or die;
|
open(my $th, "-|", $opts{"x"}, @args) or die;
|
||||||
my $result = slurp($th);
|
my $result = slurp($th);
|
||||||
|
@ -159,7 +159,7 @@ main(int argc, char *argv[])
|
|||||||
size_t l, encoutlen, decoutlen;
|
size_t l, encoutlen, decoutlen;
|
||||||
int aflag, cflag, Iflag, iflag, Kflag, kflag, mflag,
|
int aflag, cflag, Iflag, iflag, Kflag, kflag, mflag,
|
||||||
Tflag, tflag;
|
Tflag, tflag;
|
||||||
int ch;
|
int ch, verbose;
|
||||||
|
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
usage();
|
usage();
|
||||||
@ -171,7 +171,8 @@ main(int argc, char *argv[])
|
|||||||
optind = 2;
|
optind = 2;
|
||||||
aflag = cflag = Iflag = iflag = Kflag = kflag = mflag = Tflag = tflag =
|
aflag = cflag = Iflag = iflag = Kflag = kflag = mflag = Tflag = tflag =
|
||||||
0;
|
0;
|
||||||
while ((ch = getopt(argc, argv, "a:c:I:i:K:k:m:T:t:")) != -1) {
|
verbose = 0;
|
||||||
|
while ((ch = getopt(argc, argv, "a:c:I:i:K:k:m:T:t:v")) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'a':
|
case 'a':
|
||||||
aflag = 1;
|
aflag = 1;
|
||||||
@ -268,6 +269,9 @@ main(int argc, char *argv[])
|
|||||||
if (!hexparse(optarg, tag, &l) || l != taglen)
|
if (!hexparse(optarg, tag, &l) || l != taglen)
|
||||||
errx(1, "invalid hex string: %s", optarg);
|
errx(1, "invalid hex string: %s", optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'v':
|
||||||
|
verbose = 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
break;
|
break;
|
||||||
@ -298,25 +302,30 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (ctlen != encoutlen - LC_POLY1305_TAGLEN ||
|
if (ctlen != encoutlen - LC_POLY1305_TAGLEN ||
|
||||||
lc_ct_cmp(encout, ct, ctlen) != 0) {
|
lc_ct_cmp(encout, ct, ctlen) != 0) {
|
||||||
fprintf(stderr, "ct (%zu, %zu)\n", ctlen,
|
if (verbose) {
|
||||||
encoutlen - LC_POLY1305_TAGLEN);
|
fprintf(stderr, "ct (%zu, %zu)\n", ctlen,
|
||||||
hexdump(stderr, msg, msglen);
|
encoutlen - LC_POLY1305_TAGLEN);
|
||||||
fprintf(stderr, "\n");
|
hexdump(stderr, msg, msglen);
|
||||||
hexdump(stderr, ct, ctlen);
|
fprintf(stderr, "\n");
|
||||||
fprintf(stderr, "\n");
|
hexdump(stderr, ct, ctlen);
|
||||||
hexdump(stderr, encout, encoutlen - LC_POLY1305_TAGLEN);
|
fprintf(stderr, "\n");
|
||||||
fprintf(stderr, "\n");
|
hexdump(stderr, encout,
|
||||||
|
encoutlen - LC_POLY1305_TAGLEN);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
}
|
||||||
puts("invalid");
|
puts("invalid");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (taglenarg != LC_POLY1305_TAGLEN ||
|
if (taglenarg != LC_POLY1305_TAGLEN ||
|
||||||
lc_ct_cmp(encout + ctlen, tag, LC_POLY1305_TAGLEN) != 0) {
|
lc_ct_cmp(encout + ctlen, tag, LC_POLY1305_TAGLEN) != 0) {
|
||||||
fprintf(stderr, "tag (%zu, %zu)\n", taglenarg,
|
if (verbose) {
|
||||||
(size_t)LC_POLY1305_TAGLEN);
|
fprintf(stderr, "tag (%zu, %zu)\n", taglenarg,
|
||||||
hexdump(stderr, tag, taglen);
|
(size_t)LC_POLY1305_TAGLEN);
|
||||||
fprintf(stderr, "\n");
|
hexdump(stderr, tag, taglen);
|
||||||
hexdump(stderr, encout + ctlen, LC_POLY1305_TAGLEN);
|
fprintf(stderr, "\n");
|
||||||
fprintf(stderr, "\n");
|
hexdump(stderr, encout + ctlen, LC_POLY1305_TAGLEN);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
}
|
||||||
puts("invalid");
|
puts("invalid");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -344,13 +353,15 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (msglen != decoutlen || lc_ct_cmp(decout, msg, msglen) != 0) {
|
if (msglen != decoutlen || lc_ct_cmp(decout, msg, msglen) != 0) {
|
||||||
fprintf(stderr, "ct (%zu, %zu)\n", msglen, decoutlen);
|
if (verbose) {
|
||||||
hexdump(stderr, msg, msglen);
|
fprintf(stderr, "ct (%zu, %zu)\n", msglen, decoutlen);
|
||||||
fprintf(stderr, "\n");
|
hexdump(stderr, msg, msglen);
|
||||||
hexdump(stderr, ct, ctlen);
|
fprintf(stderr, "\n");
|
||||||
fprintf(stderr, "\n");
|
hexdump(stderr, ct, ctlen);
|
||||||
hexdump(stderr, decout, decoutlen);
|
fprintf(stderr, "\n");
|
||||||
fprintf(stderr, "\n");
|
hexdump(stderr, decout, decoutlen);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
}
|
||||||
puts("invalid");
|
puts("invalid");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user