aead: Support custom AEAD salt sizes
[strongswan.git] / src / libstrongswan / plugins / test_vectors / test_vectors / aes_ccm.c
1 /*
2 * Copyright (C) 2010 Martin Willi
3 * Copyright (C) 2010 revosec AG
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the Licenseor (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be usefulbut
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 #include <crypto/crypto_tester.h>
17
18 /**
19 * Test vectors with 11 bytes nonces are hard to find, neither RFC3610 nor
20 * NIST 800-38C has one. These vectors are taken from the Linux kernel,
21 * originally from "fips cavs fax files on hand at Red Hat".
22 */
23 aead_test_vector_t aes_ccm1 = {
24 .alg = ENCR_AES_CCM_ICV16, .key_size = 16, .salt_size = 3,
25 .len = 32, .alen = 0,
26 .key = "\x83\xac\x54\x66\xc2\xeb\xe5\x05\x2e\x01\xd1\xfc\x5d\x82\x66\x2e"
27 "\x96\xac\x59",
28 .iv = "\x30\x07\xa1\xe2\xa2\xc7\x55\x24",
29 .plain = "\x19\xc8\x81\xf6\xe9\x86\xff\x93\x0b\x78\x67\xe5\xbb\xb7\xfc\x6e"
30 "\x83\x77\xb3\xa6\x0c\x8c\x9f\x9c\x35\x2e\xad\xe0\x62\xf9\x91\xa1",
31 .cipher = "\xab\x6f\xe1\x69\x1d\x19\x99\xa8\x92\xa0\xc4\x6f\x7e\xe2\x8b\xb1"
32 "\x70\xbb\x8c\xa6\x4c\x6e\x97\x8a\x57\x2b\xbe\x5d\x98\xa6\xb1\x32"
33 "\xda\x24\xea\xd9\xa1\x39\x98\xfd\xa4\xbe\xd9\xf2\x1a\x6d\x22\xa8",
34 };
35
36 aead_test_vector_t aes_ccm2 = {
37 .alg = ENCR_AES_CCM_ICV16, .key_size = 16, .salt_size = 3,
38 .len = 32, .alen = 32,
39 .key = "\x1e\x2c\x7e\x01\x41\x9a\xef\xc0\x0d\x58\x96\x6e\x5c\xa2\x4b\xd3"
40 "\x4f\xa3\x19",
41 .iv = "\xd3\x01\x5a\xd8\x30\x60\x15\x56",
42 .adata = "\xda\xe6\x28\x9c\x45\x2d\xfd\x63\x5e\xda\x4c\xb6\xe6\xfc\xf9\xb7"
43 "\x0c\x56\xcb\xe4\xe0\x05\x7a\xe1\x0a\x63\x09\x78\xbc\x2c\x55\xde",
44 .plain = "\x87\xa3\x36\xfd\x96\xb3\x93\x78\xa9\x28\x63\xba\x12\xa3\x14\x85"
45 "\x57\x1e\x06\xc9\x7b\x21\xef\x76\x7f\x38\x7e\x8e\x29\xa4\x3e\x7e",
46 .cipher = "\x8a\x1e\x11\xf0\x02\x6b\xe2\x19\xfc\x70\xc4\x6d\x8e\xb7\x99\xab"
47 "\xc5\x4b\xa2\xac\xd3\xf3\x48\xff\x3b\xb5\xce\x53\xef\xde\xbb\x02"
48 "\xa9\x86\x15\x6c\x13\xfe\xda\x0a\x22\xb8\x29\x3d\xd8\x39\x9a\x23",
49 };
50
51 aead_test_vector_t aes_ccm3 = {
52 .alg = ENCR_AES_CCM_ICV16, .key_size = 24, .salt_size = 3,
53 .len = 0, .alen = 32,
54 .key = "\xf4\x6b\xc2\x75\x62\xfe\xb4\xe1\xa3\xf0\xff\xdd\x4e\x4b\x12\x75"
55 "\x53\x14\x73\x66\x8d\x88\xf6\x80\xa0\x20\x35",
56 .iv = "\x26\xf2\x21\x8d\x50\x20\xda\xe2",
57 .adata = "\x5b\x9e\x13\x67\x02\x5e\xef\xc1\x6c\xf9\xd7\x1e\x52\x8f\x7a\x47"
58 "\xe9\xd4\xcf\x20\x14\x6e\xf0\x2d\xd8\x9e\x2b\x56\x10\x23\x56\xe7",
59 .cipher = "\x36\xea\x7a\x70\x08\xdc\x6a\xbc\xad\x0c\x7a\x63\xf6\x61\xfd\x9b",
60 };
61
62 aead_test_vector_t aes_ccm4 = {
63 .alg = ENCR_AES_CCM_ICV16, .key_size = 24, .salt_size = 3,
64 .len = 32, .alen = 32,
65 .key = "\x56\xdf\x5c\x8f\x26\x3f\x0e\x42\xef\x7a\xd3\xce\xfc\x84\x60\x62"
66 "\xca\xb4\x40\xaf\x5f\xc9\xc9\x01\xd6\x3c\x8c",
67 .iv = "\x86\x84\xb6\xcd\xef\x09\x2e\x94",
68 .adata = "\x02\x65\x78\x3c\xe9\x21\x30\x91\xb1\xb9\xda\x76\x9a\x78\x6d\x95"
69 "\xf2\x88\x32\xa3\xf2\x50\xcb\x4c\xe3\x00\x73\x69\x84\x69\x87\x79",
70 .plain = "\x9f\xd2\x02\x4b\x52\x49\x31\x3c\x43\x69\x3a\x2d\x8e\x70\xad\x7e"
71 "\xe0\xe5\x46\x09\x80\x89\x13\xb2\x8c\x8b\xd9\x3f\x86\xfb\xb5\x6b",
72 .cipher = "\x39\xdf\x7c\x3c\x5a\x29\xb9\x62\x5d\x51\xc2\x16\xd8\xbd\x06\x9f"
73 "\x9b\x6a\x09\x70\xc1\x51\x83\xc2\x66\x88\x1d\x4f\x9a\xda\xe0\x1e"
74 "\xc7\x79\x11\x58\xe5\x6b\x20\x40\x7a\xea\x46\x42\x8b\xe4\x6f\xe1",
75 };
76
77 aead_test_vector_t aes_ccm5 = {
78 .alg = ENCR_AES_CCM_ICV8, .key_size = 32, .salt_size = 3,
79 .len = 32, .alen = 32,
80 .key = "\xe0\x8d\x99\x71\x60\xd7\x97\x1a\xbd\x01\x99\xd5\x8a\xdf\x71\x3a"
81 "\xd3\xdf\x24\x4b\x5e\x3d\x4b\x4e\x30\x7a\xb9\xd8\x53\x0a\x5e\x2b"
82 "\x1e\x29\x91",
83 .iv = "\xad\x8e\xc1\x53\x0a\xcf\x2d\xbe",
84 .adata = "\x19\xb6\x1f\x57\xc4\xf3\xf0\x8b\x78\x2b\x94\x02\x29\x0f\x42\x27"
85 "\x6b\x75\xcb\x98\x34\x08\x7e\x79\xe4\x3e\x49\x0d\x84\x8b\x22\x87",
86 .plain = "\xe1\xd9\xd8\x13\xeb\x3a\x75\x3f\x9d\xbd\x5f\x66\xbe\xdc\xbb\x66"
87 "\xbf\x17\x99\x62\x4a\x39\x27\x1f\x1d\xdc\x24\xae\x19\x2f\x98\x4c",
88 .cipher = "\x19\xb8\x61\x33\x45\x2b\x43\x96\x6f\x51\xd0\x20\x30\x7d\x9b\xc6"
89 "\x26\x3d\xf8\xc9\x65\x16\xa8\x9f\xf0\x62\x17\x34\xf2\x1e\x8d\x75"
90 "\x4e\x13\xcc\xc0\xc3\x2a\x54\x2d",
91 };
92
93 aead_test_vector_t aes_ccm6 = {
94 .alg = ENCR_AES_CCM_ICV12, .key_size = 32, .salt_size = 3,
95 .len = 32, .alen = 32,
96 .key = "\x7c\xc8\x18\x3b\x8d\x99\xe0\x7c\x45\x41\xb8\xbd\x5c\xa7\xc2\x32"
97 "\x8a\xb8\x02\x59\xa4\xfe\xa9\x2c\x09\x75\x9a\x9b\x3c\x9b\x27\x39"
98 "\xf9\xd9\x4e",
99 .iv = "\x63\xb5\x3d\x9d\x43\xf6\x1e\x50",
100 .adata = "\x57\xf5\x6b\x8b\x57\x5c\x3d\x3b\x13\x02\x01\x0c\x83\x4c\x96\x35"
101 "\x8e\xd6\x39\xcf\x7d\x14\x9b\x94\xb0\x39\x36\xe6\x8f\x57\xe0\x13",
102 .plain = "\x3b\x6c\x29\x36\xb6\xef\x07\xa6\x83\x72\x07\x4f\xcf\xfa\x66\x89"
103 "\x5f\xca\xb1\xba\xd5\x8f\x2c\x27\x30\xdb\x75\x09\x93\xd4\x65\xe4",
104 .cipher = "\xb0\x88\x5a\x33\xaa\xe5\xc7\x1d\x85\x23\xc7\xc6\x2f\xf4\x1e\x3d"
105 "\xcc\x63\x44\x25\x07\x78\x4f\x9e\x96\xb8\x88\xeb\xbc\x48\x1f\x06"
106 "\x39\xaf\x39\xac\xd8\x4a\x80\x39\x7b\x72\x8a\xf7",
107 };
108
109 aead_test_vector_t aes_ccm7 = {
110 .alg = ENCR_AES_CCM_ICV16, .key_size = 32, .salt_size = 3,
111 .len = 32, .alen = 32,
112 .key = "\xab\xd0\xe9\x33\x07\x26\xe5\x83\x8c\x76\x95\xd4\xb6\xdc\xf3\x46"
113 "\xf9\x8f\xad\xe3\x02\x13\x83\x77\x3f\xb0\xf1\xa1\xa1\x22\x0f\x2b"
114 "\x24\xa7\x8b",
115 .iv = "\x07\xcb\xcc\x0e\xe6\x33\xbf\xf5",
116 .adata = "\xd4\xdb\x30\x1d\x03\xfe\xfd\x5f\x87\xd4\x8c\xb6\xb6\xf1\x7a\x5d"
117 "\xab\x90\x65\x8d\x8e\xca\x4d\x4f\x16\x0c\x40\x90\x4b\xc7\x36\x73",
118 .plain = "\xf5\xc6\x7d\x48\xc1\xb7\xe6\x92\x97\x5a\xca\xc4\xa9\x6d\xf9\x3d"
119 "\x6c\xde\xbc\xf1\x90\xea\x6a\xb2\x35\x86\x36\xaf\x5c\xfe\x4b\x3a",
120 .cipher = "\x83\x6f\x40\x87\x72\xcf\xc1\x13\xef\xbb\x80\x21\x04\x6c\x58\x09"
121 "\x07\x1b\xfc\xdf\xc0\x3f\x5b\xc7\xe0\x79\xa8\x6e\x71\x7c\x3f\xcf"
122 "\x5c\xda\xb2\x33\xe5\x13\xe2\x0d\x74\xd1\xef\xb5\x0f\x3a\xb5\xf8",
123 };
124
125 aead_test_vector_t aes_ccm8 = {
126 .alg = ENCR_AES_CCM_ICV8, .key_size = 16, .salt_size = 3,
127 .len = 0, .alen = 0,
128 .key = "\xab\x2f\x8a\x74\xb7\x1c\xd2\xb1\xff\x80\x2e\x48\x7d\x82\xf8\xb9"
129 "\xaf\x94\x87",
130 .iv = "\x78\x35\x82\x81\x7f\x88\x94\x68",
131 .cipher = "\x41\x3c\xb8\x87\x73\xcb\xf3\xf3",
132 };
133
134 aead_test_vector_t aes_ccm9 = {
135 .alg = ENCR_AES_CCM_ICV8, .key_size = 24, .salt_size = 3,
136 .len = 0, .alen = 32,
137 .key = "\x39\xbb\xa7\xbe\x59\x97\x9e\x73\xa2\xbc\x6b\x98\xd7\x75\x7f\xe3"
138 "\xa4\x48\x93\x39\x26\x71\x4a\xc6\xee\x49\x83",
139 .iv = "\xe9\xa9\xff\xe9\x57\xba\xfd\x9e",
140 .adata = "\x44\xa6\x2c\x05\xe9\xe1\x43\xb1\x58\x7c\xf2\x5c\x6d\x39\x0a\x64"
141 "\xa4\xf0\x13\x05\xd1\x77\x99\x67\x11\xc4\xc6\xdb\x00\x56\x36\x61",
142 .cipher = "\x71\x99\xfa\xf4\x44\x12\x68\x9b",
143 };
144
145 aead_test_vector_t aes_ccm10 = {
146 .alg = ENCR_AES_CCM_ICV8, .key_size = 32, .salt_size = 3,
147 .len = 0, .alen = 0,
148 .key = "\xa4\x4b\x54\x29\x0a\xb8\x6d\x01\x5b\x80\x2a\xcf\x25\xc4\xb7\x5c"
149 "\x20\x2c\xad\x30\xc2\x2b\x41\xfb\x0e\x85\xbc\x33\xad\x0f\x2b\xff"
150 "\xee\x49\x83",
151 .iv = "\xe9\xa9\xff\xe9\x57\xba\xfd\x9e",
152 .cipher = "\x1f\xb8\x8f\xa3\xdd\x54\x00\xf2",
153 };
154
155 aead_test_vector_t aes_ccm11 = {
156 .alg = ENCR_AES_CCM_ICV8, .key_size = 24, .salt_size = 3,
157 .len = 32, .alen = 32,
158 .key = "\x58\x5d\xa0\x96\x65\x1a\x04\xd7\x96\xe5\xc5\x68\xaa\x95\x35\xe0"
159 "\x29\xa0\xba\x9e\x48\x78\xd1\xba\xee\x49\x83",
160 .iv = "\xe9\xa9\xff\xe9\x57\xba\xfd\x9e",
161 .adata = "\x44\xa6\x2c\x05\xe9\xe1\x43\xb1\x58\x7c\xf2\x5c\x6d\x39\x0a\x64"
162 "\xa4\xf0\x13\x05\xd1\x77\x99\x67\x11\xc4\xc6\xdb\x00\x56\x36\x61",
163 .plain = "\x85\x34\x66\x42\xc8\x92\x0f\x36\x58\xe0\x6b\x91\x3c\x98\x5c\xbb"
164 "\x0a\x85\xcc\x02\xad\x7a\x96\xe9\x65\x43\xa4\xc3\x0f\xdc\x55\x81",
165 .cipher = "\xfb\xe5\x5d\x34\xbe\xe5\xe8\xe7\x5a\xef\x2f\xbf\x1f\x7f\xd4\xb2"
166 "\x66\xca\x61\x1e\x96\x7a\x61\xb3\x1c\x16\x45\x52\xba\x04\x9c\x9f"
167 "\xb1\xd2\x40\xbc\x52\x7c\x6f\xb1",
168 };