chiark / gitweb /
base/dispatch.c: Recognize `CPUFEAT_ARM_NEON' as requesting ARM64 SIMD.
[catacomb] / symm / sha3-trans
1 #! /bin/sh
2
3 prog=`echo $0 | sed 's:.*/::'`
4
5 cat <<EOF
6 # Test vectors for SHA3
7 #
8 # Generated on `date +%Y-%m-%d` by $prog
9
10 EOF
11
12 for i in "$@"; do
13   base=${i##*/}
14   case $base in
15     SHA3_*) tail=${base#SHA3_}; alg=sha3 sep=- hex=-hex ;;
16     SHAKE*) tail=${base#SHAKE}; alg=shake sep= hex= ;;
17     *) echo >&2 "$0: bad filename \`$i'"; exit 2 ;;
18   esac
19   case $tail in
20     *LongMsg.rsp) hack=kat; bits=${tail%LongMsg.rsp} ;;
21     *ShortMsg.rsp) hack=kat; bits=${tail%ShortMsg.rsp} ;;
22     *VariableOut.rsp) hack=kat; bits=${tail%VariableOut.rsp} ;;
23     *Monte.rsp) hack=mct; bits=${tail%Monte.rsp} ;;
24     *) echo >&2 "$0: bad filename \`$i'"; exit 2 ;;
25   esac
26
27   case $hack,$alg in
28     kat,*)
29       echo "$alg$sep$bits$hex {"
30       awk '
31         BEGIN { FS = "[ \t\r]+"; len = 8; }
32         /^Len = / { len = $3; }
33         /^Msg = / { msg = tolower($3); if (!len) msg = "\"\""; }
34         /^(MD|Output) = / {
35           h = tolower($3);
36           if (len%8 == 0) printf("  %s\n    %s;\n", msg, h);
37         }
38       ' <"$i"
39       echo "}"
40       ;;
41     mct,sha3)
42       echo "$alg$sep$bits-mct {"
43       awk '
44         BEGIN { FS = "[ \t\r]+"; }
45         BEGIN { prev = ""; }
46         /MD = / {
47           if (prev != "") printf("  1000\n    %s\n    %s;\n", prev, $3);
48           prev = $3;
49         }
50       ' <"$i"
51       echo "}"
52       ;;
53     *)
54       echo >&2 "$0: unsupported test kind $hack/$alg"; exit 2 ;;
55   esac
56 done