#! /usr/bin/perl $s = undef; $what = undef; $sep = "\n"; while (<>) { if (/^Primitive Name: (.*)$/) { print $sep, lc $1, " {\n"; $sep = "}\n\n"; } next unless /^ /; @f = split; if (@f == 3 && $f[1] == "=") { if (defined $s) { die "not a block boundary" if $pos % 64; $hp = sprintf "%016x", $pos/64; print " $k\n $n $hp 0 \"\"\n $s;\n"; undef $s; undef $what; } if ($f[0] eq "key") { $k = lc $f[2]; $what = \$k; } elsif ($f[0] eq "IV") { $n = lc $f[2]; } elsif ($f[0] =~ /^stream\[(\d+)\.\.(\d+)]$/) { $pos = $1; $s = lc $f[2]; $what = \$s; } } elsif (@f == 1) { if (defined $what) { $$what .= lc $f[0]; } } else { die "incomprehensible line"; } } print $sep;