Convert AES test vector files to mLib format.
authormdw <mdw>
Sat, 17 Jun 2000 12:12:05 +0000 (12:12 +0000)
committermdw <mdw>
Sat, 17 Jun 2000 12:12:05 +0000 (12:12 +0000)
tests/aes-trans [new file with mode: 0755]

diff --git a/tests/aes-trans b/tests/aes-trans
new file mode 100755 (executable)
index 0000000..a869d16
--- /dev/null
@@ -0,0 +1,36 @@
+#! /bin/sh
+
+prog=`echo $0 | sed 's:.*/::'`
+alg=${1?}; shift
+lc=`echo $alg | tr A-Z a-z`
+
+cat <<EOF
+# Test vectors for $alg
+#
+# Generated on `date +%Y-%m-%d` by $prog
+
+$lc {
+EOF
+
+awk "$@" '
+function mangle(x, y) {
+  if (!rev)
+    return x;
+  y = "";
+  while (length(x) > 1) {
+    y = y substr(x, length(x) - 1);
+    x = substr(x, 1, length(x) - 2);
+  }
+  return y;
+}
+
+BEGIN { FS = "="; }
+/^KEY=/ { key = mangle($2); }
+/^PT=/ { pt = mangle($2); }
+/^CT=/ {
+  ct = mangle($2);
+  printf("  %s\n    %s\n    %s;\n", key, pt, ct);
+}
+'
+echo }
+