summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2020-07-11 01:31:51 +0000
committerbrian m. carlson <sandals@crustytoothpaste.net>2020-07-11 01:31:51 +0000
commitc3acedce15085482c9b3c97104e937843b696150 (patch)
treef351fc5baace060557af3feaa73bdbb3bc176394
parent817644ece9e2a4dfe4bacac55e859a8f0b149821 (diff)
tools/canonicalize-vectors: add --oneline optionHEADmaster
Add an option to print each test vector on its own line for compatibility with shell scripting environments. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
-rwxr-xr-xtools/canonicalize-vectors16
1 files changed, 12 insertions, 4 deletions
diff --git a/tools/canonicalize-vectors b/tools/canonicalize-vectors
index 82096a7..f8ab6d4 100755
--- a/tools/canonicalize-vectors
+++ b/tools/canonicalize-vectors
@@ -13,7 +13,7 @@ sub script {
my $args = {};
- Getopt::Long::GetOptionsFromArray(\@argv, $args, 'help', 'type|t=s');
+ Getopt::Long::GetOptionsFromArray(\@argv, $args, 'help', 'type|t=s', 'oneline');
return usage(0) if $args->{help};
@@ -23,6 +23,7 @@ sub script {
my $flags = {
plength => $args->{type} && $args->{type} =~ /^pk/ ? 2 : 1,
silentk => $args->{type} && $args->{type} eq 'kdf',
+ oneline => $args->{oneline},
};
process($infh, \*STDOUT, $flags);
@@ -52,7 +53,12 @@ sub emit_line {
}
sub emit_block {
- my ($block, $outfh) = @_;
+ my ($block, $outfh, $flags) = @_;
+
+ if ($flags->{oneline}) {
+ emit_line($block, $outfh, qw/a m g r R C F K k N n S E p d c/);
+ return;
+ }
# Algorithm description and parameters; repetition and iteration counts.
emit_line($block, $outfh, qw/a m g r R C F/);
@@ -87,7 +93,7 @@ sub process {
elsif ($line =~ /^T(\S+)/) {
my $tag = $1;
if ($curtag ne $tag) {
- emit_block($block, $outfh) if $curtag;
+ emit_block($block, $outfh, $flags) if $curtag;
my @reject = map { /^s/ || ref $block->{$_} } keys %$block;
delete $block->{@reject};
$outfh->print($comment);
@@ -120,7 +126,7 @@ sub usage {
my ($ret) = @_;
print <<EOM;
-canonicalize-vectors [--type ALGOTYPE] [FILE]
+canonicalize-vectors [--type ALGOTYPE] [--oneline] [FILE]
Take vectors which may be missing parameters and fill them in using the last set
value for that parameter.
@@ -129,6 +135,8 @@ ALGOTYPE is the type of vector (e.g. block, stream) to canonicalize. If not
specified, it defaults to a mode that works on all algorithm types except public
key types.
+If --oneline is specified, print each vector on its own line.
+
If FILE is not specified, defaults to stdin.
The code preserves comments, and outputs parameters in as sane an order as