mkvectors 1.53 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#! /bin/bash

set -e

vector () {
    nonce="$1"
    length="$2"
    data="$3"
    echo "nonce:" $nonce
    echo "msg length:" $length
    echo "data (repeated):" $data
    for tag_len in 32 64 96 128 ; do
	tag=`python repeat.py "$data" "$length" | python umac.py "$tag_len" "$nonce"`
	echo "tag$tag_len:" $tag
    done
    echo
}

NONCE=bcdefghi

# RFC 4418 test vectors
vector $NONCE 0 ""
vector $NONCE 3 "a"
vector $NONCE 1024 "a"
vector $NONCE 32768 "a"
vector $NONCE 1048576 "a"
vector $NONCE 33554432 "a"
vector $NONCE 3 "abc"
vector $nonce 1500 "abc"

DATA=def
NONCE=bcdefghijklmnopq

vector ${NONCE:0:1} 0 $DATA
vector ${NONCE:0:2} 1 $DATA
vector ${NONCE:0:3} 2 $DATA
vector ${NONCE:0:4} 3 $DATA
vector ${NONCE:0:5} 4 $DATA

vector ${NONCE:0:6} 1020 $DATA
vector ${NONCE:0:7} 1021 $DATA
vector ${NONCE:0:8} 1022 $DATA
vector ${NONCE:0:9} 1023 $DATA
vector ${NONCE:0:10} 1024 $DATA
vector ${NONCE:0:11} 1025 $DATA
vector ${NONCE:0:12} 1026 $DATA
vector ${NONCE:0:13} 1027 $DATA

vector ${NONCE:0:14} 2046 $DATA
vector ${NONCE:0:15} 2047 $DATA
vector ${NONCE:0:16} 2048 $DATA
vector ${NONCE:0:1} 2049 $DATA
vector ${NONCE:0:2} 2050 $DATA

vector ${NONCE:0:3} 16777212 $DATA
vector ${NONCE:0:4} 16777213 $DATA
vector ${NONCE:0:5} 16777214 $DATA
vector ${NONCE:0:6} 16777215 $DATA
vector ${NONCE:0:7} 16777216 $DATA
vector ${NONCE:0:8} 16777217 $DATA

vector ${NONCE:0:9} 16778239 $DATA
vector ${NONCE:0:10} 16778240 $DATA
vector ${NONCE:0:11} 16778241 $DATA
vector ${NONCE:0:12} 16778242 $DATA
vector ${NONCE:0:13} 16778243 $DATA
vector ${NONCE:0:14} 16778244 $DATA