~ubuntu-branches/ubuntu/vivid/wpasupplicant/vivid

« back to all changes in this revision

Viewing changes to src/hlr_auc_gw/milenage.c

  • Committer: Bazaar Package Importer
  • Author(s): Kel Modderman
  • Date: 2008-03-12 20:03:04 UTC
  • mfrom: (1.1.10 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20080312200304-4331y9wj46pdd34z
Tags: 0.6.3-1
* New upstream release.
* Drop patches applied upstream:
  - debian/patches/30_wpa_gui_qt4_eventhistoryui_rework.patch
  - debian/patches/31_wpa_gui_qt4_eventhistory_always_scrollbar.patch
  - debian/patches/32_wpa_gui_qt4_eventhistory_scroll_with_events.patch
  - debian/patches/40_dbus_ssid_data.patch
* Tidy up the clean target of debian/rules. Now that the madwifi headers are
  handled differently we no longer need to do any cleanup.
* Fix formatting error in debian/ifupdown/wpa_action.8 to make lintian
  quieter.
* Add patch to fix formatting errors in manpages build from sgml source. Use
  <emphasis> tags to hightlight keywords instead of surrounding them in
  strong quotes.
  - debian/patches/41_manpage_format_fixes.patch
* wpasupplicant binary package no longer suggests pcscd, guessnet, iproute
  or wireless-tools, nor does it recommend dhcp3-client. These are not
  needed.
* Add debian/patches/10_silence_siocsiwauth_icotl_failure.patch to disable
  ioctl failure messages that occur under normal conditions.
* Cherry pick two upstream git commits concerning the dbus interface:
  - debian/patches/11_avoid_dbus_version_namespace.patch
  - debian/patches/12_fix_potential_use_after_free.patch
* Add debian/patches/42_manpage_explain_available_drivers.patch to explain
  that not all of the driver backends are available in the provided
  wpa_supplicant binary, and that the canonical list of supported driver
  backends can be retrieved from the wpa_supplicant -h (help) output.
  (Closes: #466910)
* Add debian/patches/20_wpa_gui_qt4_disable_link_prl.patch to remove
  link_prl CONFIG compile flag added by qmake-qt4 >= 4.3.4-2 to avoid excess
  linking.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * 3GPP AKA - Milenage algorithm (3GPP TS 35.205, .206, .207, .208)
 
3
 * Copyright (c) 2006-2007 <j@w1.fi>
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or modify
 
6
 * it under the terms of the GNU General Public License version 2 as
 
7
 * published by the Free Software Foundation.
 
8
 *
 
9
 * Alternatively, this software may be distributed under the terms of BSD
 
10
 * license.
 
11
 *
 
12
 * See README and COPYING for more details.
 
13
 *
 
14
 * This file implements an example authentication algorithm defined for 3GPP
 
15
 * AKA. This can be used to implement a simple HLR/AuC into hlr_auc_gw to allow
 
16
 * EAP-AKA to be tested properly with real USIM cards.
 
17
 *
 
18
 * This implementations assumes that the r1..r5 and c1..c5 constants defined in
 
19
 * TS 35.206 are used, i.e., r1=64, r2=0, r3=32, r4=64, r5=96, c1=00..00,
 
20
 * c2=00..01, c3=00..02, c4=00..04, c5=00..08. The block cipher is assumed to
 
21
 * be AES (Rijndael).
 
22
 */
 
23
 
 
24
#include "includes.h"
 
25
 
 
26
#include "common.h"
 
27
#include "milenage.h"
 
28
#include "aes_wrap.h"
 
29
 
 
30
 
 
31
/**
 
32
 * milenage_f1 - Milenage f1 and f1* algorithms
 
33
 * @opc: OPc = 128-bit value derived from OP and K
 
34
 * @k: K = 128-bit subscriber key
 
35
 * @_rand: RAND = 128-bit random challenge
 
36
 * @sqn: SQN = 48-bit sequence number
 
37
 * @amf: AMF = 16-bit authentication management field
 
38
 * @mac_a: Buffer for MAC-A = 64-bit network authentication code, or %NULL
 
39
 * @mac_s: Buffer for MAC-S = 64-bit resync authentication code, or %NULL
 
40
 * Returns: 0 on success, -1 on failure
 
41
 */
 
42
static int milenage_f1(const u8 *opc, const u8 *k, const u8 *_rand,
 
43
                       const u8 *sqn, const u8 *amf, u8 *mac_a, u8 *mac_s)
 
44
{
 
45
        u8 tmp1[16], tmp2[16], tmp3[16];
 
46
        int i;
 
47
 
 
48
        /* tmp1 = TEMP = E_K(RAND XOR OP_C) */
 
49
        for (i = 0; i < 16; i++)
 
50
                tmp1[i] = _rand[i] ^ opc[i];
 
51
        if (aes_128_encrypt_block(k, tmp1, tmp1))
 
52
                return -1;
 
53
 
 
54
        /* tmp2 = IN1 = SQN || AMF || SQN || AMF */
 
55
        memcpy(tmp2, sqn, 6);
 
56
        memcpy(tmp2 + 6, amf, 2);
 
57
        memcpy(tmp2 + 8, tmp2, 8);
 
58
 
 
59
        /* OUT1 = E_K(TEMP XOR rot(IN1 XOR OP_C, r1) XOR c1) XOR OP_C */
 
60
 
 
61
        /* rotate (tmp2 XOR OP_C) by r1 (= 0x40 = 8 bytes) */
 
62
        for (i = 0; i < 16; i++)
 
63
                tmp3[(i + 8) % 16] = tmp2[i] ^ opc[i];
 
64
        /* XOR with TEMP = E_K(RAND XOR OP_C) */
 
65
        for (i = 0; i < 16; i++)
 
66
                tmp3[i] ^= tmp1[i];
 
67
        /* XOR with c1 (= ..00, i.e., NOP) */
 
68
 
 
69
        /* f1 || f1* = E_K(tmp3) XOR OP_c */
 
70
        if (aes_128_encrypt_block(k, tmp3, tmp1))
 
71
                return -1;
 
72
        for (i = 0; i < 16; i++)
 
73
                tmp1[i] ^= opc[i];
 
74
        if (mac_a)
 
75
                memcpy(mac_a, tmp1, 8); /* f1 */
 
76
        if (mac_s)
 
77
                memcpy(mac_s, tmp1 + 8, 8); /* f1* */
 
78
        return 0;
 
79
}
 
80
 
 
81
 
 
82
/**
 
83
 * milenage_f2345 - Milenage f2, f3, f4, f5, f5* algorithms
 
84
 * @opc: OPc = 128-bit value derived from OP and K
 
85
 * @k: K = 128-bit subscriber key
 
86
 * @_rand: RAND = 128-bit random challenge
 
87
 * @res: Buffer for RES = 64-bit signed response (f2), or %NULL
 
88
 * @ck: Buffer for CK = 128-bit confidentiality key (f3), or %NULL
 
89
 * @ik: Buffer for IK = 128-bit integrity key (f4), or %NULL
 
90
 * @ak: Buffer for AK = 48-bit anonymity key (f5), or %NULL
 
91
 * @akstar: Buffer for AK = 48-bit anonymity key (f5*), or %NULL
 
92
 * Returns: 0 on success, -1 on failure
 
93
 */
 
94
static int milenage_f2345(const u8 *opc, const u8 *k, const u8 *_rand,
 
95
                          u8 *res, u8 *ck, u8 *ik, u8 *ak, u8 *akstar)
 
96
{
 
97
        u8 tmp1[16], tmp2[16], tmp3[16];
 
98
        int i;
 
99
 
 
100
        /* tmp2 = TEMP = E_K(RAND XOR OP_C) */
 
101
        for (i = 0; i < 16; i++)
 
102
                tmp1[i] = _rand[i] ^ opc[i];
 
103
        if (aes_128_encrypt_block(k, tmp1, tmp2))
 
104
                return -1;
 
105
 
 
106
        /* OUT2 = E_K(rot(TEMP XOR OP_C, r2) XOR c2) XOR OP_C */
 
107
        /* OUT3 = E_K(rot(TEMP XOR OP_C, r3) XOR c3) XOR OP_C */
 
108
        /* OUT4 = E_K(rot(TEMP XOR OP_C, r4) XOR c4) XOR OP_C */
 
109
        /* OUT5 = E_K(rot(TEMP XOR OP_C, r5) XOR c5) XOR OP_C */
 
110
 
 
111
        /* f2 and f5 */
 
112
        /* rotate by r2 (= 0, i.e., NOP) */
 
113
        for (i = 0; i < 16; i++)
 
114
                tmp1[i] = tmp2[i] ^ opc[i];
 
115
        tmp1[15] ^= 1; /* XOR c2 (= ..01) */
 
116
        /* f5 || f2 = E_K(tmp1) XOR OP_c */
 
117
        if (aes_128_encrypt_block(k, tmp1, tmp3))
 
118
                return -1;
 
119
        for (i = 0; i < 16; i++)
 
120
                tmp3[i] ^= opc[i];
 
121
        if (res)
 
122
                memcpy(res, tmp3 + 8, 8); /* f2 */
 
123
        if (ak)
 
124
                memcpy(ak, tmp3, 6); /* f5 */
 
125
 
 
126
        /* f3 */
 
127
        if (ck) {
 
128
                /* rotate by r3 = 0x20 = 4 bytes */
 
129
                for (i = 0; i < 16; i++)
 
130
                        tmp1[(i + 12) % 16] = tmp2[i] ^ opc[i];
 
131
                tmp1[15] ^= 2; /* XOR c3 (= ..02) */
 
132
                if (aes_128_encrypt_block(k, tmp1, ck))
 
133
                        return -1;
 
134
                for (i = 0; i < 16; i++)
 
135
                        ck[i] ^= opc[i];
 
136
        }
 
137
 
 
138
        /* f4 */
 
139
        if (ik) {
 
140
                /* rotate by r4 = 0x40 = 8 bytes */
 
141
                for (i = 0; i < 16; i++)
 
142
                        tmp1[(i + 8) % 16] = tmp2[i] ^ opc[i];
 
143
                tmp1[15] ^= 4; /* XOR c4 (= ..04) */
 
144
                if (aes_128_encrypt_block(k, tmp1, ik))
 
145
                        return -1;
 
146
                for (i = 0; i < 16; i++)
 
147
                        ik[i] ^= opc[i];
 
148
        }
 
149
 
 
150
        /* f5* */
 
151
        if (akstar) {
 
152
                /* rotate by r5 = 0x60 = 12 bytes */
 
153
                for (i = 0; i < 16; i++)
 
154
                        tmp1[(i + 4) % 16] = tmp2[i] ^ opc[i];
 
155
                tmp1[15] ^= 8; /* XOR c5 (= ..08) */
 
156
                if (aes_128_encrypt_block(k, tmp1, tmp1))
 
157
                        return -1;
 
158
                for (i = 0; i < 6; i++)
 
159
                        akstar[i] = tmp1[i] ^ opc[i];
 
160
        }
 
161
 
 
162
        return 0;
 
163
}
 
164
 
 
165
 
 
166
/**
 
167
 * milenage_generate - Generate AKA AUTN,IK,CK,RES
 
168
 * @opc: OPc = 128-bit operator variant algorithm configuration field (encr.)
 
169
 * @amf: AMF = 16-bit authentication management field
 
170
 * @k: K = 128-bit subscriber key
 
171
 * @sqn: SQN = 48-bit sequence number
 
172
 * @_rand: RAND = 128-bit random challenge
 
173
 * @autn: Buffer for AUTN = 128-bit authentication token
 
174
 * @ik: Buffer for IK = 128-bit integrity key (f4), or %NULL
 
175
 * @ck: Buffer for CK = 128-bit confidentiality key (f3), or %NULL
 
176
 * @res: Buffer for RES = 64-bit signed response (f2), or %NULL
 
177
 * @res_len: Max length for res; set to used length or 0 on failure
 
178
 */
 
179
void milenage_generate(const u8 *opc, const u8 *amf, const u8 *k,
 
180
                       const u8 *sqn, const u8 *_rand, u8 *autn, u8 *ik,
 
181
                       u8 *ck, u8 *res, size_t *res_len)
 
182
{
 
183
        int i;
 
184
        u8 mac_a[16], ak[6];
 
185
 
 
186
        if (*res_len < 8) {
 
187
                *res_len = 0;
 
188
                return;
 
189
        }
 
190
        if (milenage_f1(opc, k, _rand, sqn, amf, mac_a, NULL) ||
 
191
            milenage_f2345(opc, k, _rand, res, ck, ik, ak, NULL)) {
 
192
                *res_len = 0;
 
193
                return;
 
194
        }
 
195
        *res_len = 8;
 
196
 
 
197
        /* AUTN = (SQN ^ AK) || AMF || MAC */
 
198
        for (i = 0; i < 6; i++)
 
199
                autn[i] = sqn[i] ^ ak[i];
 
200
        memcpy(autn + 6, amf, 2);
 
201
        memcpy(autn + 8, mac_a, 8);
 
202
}
 
203
 
 
204
 
 
205
/**
 
206
 * milenage_auts - Milenage AUTS validation
 
207
 * @opc: OPc = 128-bit operator variant algorithm configuration field (encr.)
 
208
 * @k: K = 128-bit subscriber key
 
209
 * @_rand: RAND = 128-bit random challenge
 
210
 * @auts: AUTS = 112-bit authentication token from client
 
211
 * @sqn: Buffer for SQN = 48-bit sequence number
 
212
 * Returns: 0 = success (sqn filled), -1 on failure
 
213
 */
 
214
int milenage_auts(const u8 *opc, const u8 *k, const u8 *_rand, const u8 *auts,
 
215
                  u8 *sqn)
 
216
{
 
217
        u8 amf[2] = { 0x00, 0x00 }; /* TS 33.102 v7.0.0, 6.3.3 */
 
218
        u8 ak[6], mac_s[8];
 
219
        int i;
 
220
 
 
221
        if (milenage_f2345(opc, k, _rand, NULL, NULL, NULL, NULL, ak))
 
222
                return -1;
 
223
        for (i = 0; i < 6; i++)
 
224
                sqn[i] = auts[i] ^ ak[i];
 
225
        if (milenage_f1(opc, k, _rand, sqn, amf, NULL, mac_s) ||
 
226
            memcmp(mac_s, auts + 6, 8) != 0)
 
227
                return -1;
 
228
        return 0;
 
229
}
 
230
 
 
231
 
 
232
/**
 
233
 * gsm_milenage - Generate GSM-Milenage (3GPP TS 55.205) authentication triplet
 
234
 * @opc: OPc = 128-bit operator variant algorithm configuration field (encr.)
 
235
 * @k: K = 128-bit subscriber key
 
236
 * @_rand: RAND = 128-bit random challenge
 
237
 * @sres: Buffer for SRES = 32-bit SRES
 
238
 * @kc: Buffer for Kc = 64-bit Kc
 
239
 * Returns: 0 on success, -1 on failure
 
240
 */
 
241
int gsm_milenage(const u8 *opc, const u8 *k, const u8 *_rand, u8 *sres, u8 *kc)
 
242
{
 
243
        u8 res[8], ck[16], ik[16];
 
244
        int i;
 
245
 
 
246
        if (milenage_f2345(opc, k, _rand, res, ck, ik, NULL, NULL))
 
247
                return -1;
 
248
 
 
249
        for (i = 0; i < 8; i++)
 
250
                kc[i] = ck[i] ^ ck[i + 8] ^ ik[i] ^ ik[i + 8];
 
251
 
 
252
#ifdef GSM_MILENAGE_ALT_SRES
 
253
        memcpy(sres, res, 4);
 
254
#else /* GSM_MILENAGE_ALT_SRES */
 
255
        for (i = 0; i < 4; i++)
 
256
                sres[i] = res[i] ^ res[i + 4];
 
257
#endif /* GSM_MILENAGE_ALT_SRES */
 
258
        return 0;
 
259
}
 
260
 
 
261
 
 
262
#ifdef TEST_MAIN_MILENAGE
 
263
 
 
264
extern int wpa_debug_level;
 
265
 
 
266
 
 
267
/**
 
268
 * milenage_opc - Determine OPc from OP and K
 
269
 * @op: OP = 128-bit operator variant algorithm configuration field
 
270
 * @k: K = 128-bit subscriber key
 
271
 * @opc: Buffer for OPc = 128-bit value derived from OP and K
 
272
 */
 
273
static void milenage_opc(const u8 *op, const u8 *k, u8 *opc)
 
274
{
 
275
        int i;
 
276
        /* OP_C = OP XOR E_K(OP) */
 
277
        aes_128_encrypt_block(k, op, opc);
 
278
        for (i = 0; i < 16; i++)
 
279
                opc[i] ^= op[i];
 
280
}
 
281
 
 
282
 
 
283
struct gsm_milenage_test_set {
 
284
        u8 ki[16];
 
285
        u8 rand[16];
 
286
        u8 opc[16];
 
287
        u8 sres1[4];
 
288
        u8 sres2[4];
 
289
        u8 kc[8];
 
290
};
 
291
 
 
292
static const struct gsm_milenage_test_set gsm_test_sets[] =
 
293
{
 
294
        {
 
295
                /* 3GPP TS 55.205 v6.0.0 - Test Set 1 */
 
296
                { 0x46, 0x5b, 0x5c, 0xe8, 0xb1, 0x99, 0xb4, 0x9f,
 
297
                  0xaa, 0x5f, 0x0a, 0x2e, 0xe2, 0x38, 0xa6, 0xbc },
 
298
                { 0x23, 0x55, 0x3c, 0xbe, 0x96, 0x37, 0xa8, 0x9d,
 
299
                  0x21, 0x8a, 0xe6, 0x4d, 0xae, 0x47, 0xbf, 0x35 },
 
300
                { 0xcd, 0x63, 0xcb, 0x71, 0x95, 0x4a, 0x9f, 0x4e,
 
301
                  0x48, 0xa5, 0x99, 0x4e, 0x37, 0xa0, 0x2b, 0xaf },
 
302
                { 0x46, 0xf8, 0x41, 0x6a },
 
303
                { 0xa5, 0x42, 0x11, 0xd5 },
 
304
                { 0xea, 0xe4, 0xbe, 0x82, 0x3a, 0xf9, 0xa0, 0x8b }
 
305
        }, {
 
306
                /* 3GPP TS 55.205 v6.0.0 - Test Set 2 */
 
307
                { 0xfe, 0xc8, 0x6b, 0xa6, 0xeb, 0x70, 0x7e, 0xd0,
 
308
                  0x89, 0x05, 0x75, 0x7b, 0x1b, 0xb4, 0x4b, 0x8f },
 
309
                { 0x9f, 0x7c, 0x8d, 0x02, 0x1a, 0xcc, 0xf4, 0xdb,
 
310
                  0x21, 0x3c, 0xcf, 0xf0, 0xc7, 0xf7, 0x1a, 0x6a },
 
311
                { 0x10, 0x06, 0x02, 0x0f, 0x0a, 0x47, 0x8b, 0xf6,
 
312
                  0xb6, 0x99, 0xf1, 0x5c, 0x06, 0x2e, 0x42, 0xb3 },
 
313
                { 0x8c, 0x30, 0x8a, 0x5e },
 
314
                { 0x80, 0x11, 0xc4, 0x8c },
 
315
                { 0xaa, 0x01, 0x73, 0x9b, 0x8c, 0xaa, 0x97, 0x6d }
 
316
        }, {
 
317
                /* 3GPP TS 55.205 v6.0.0 - Test Set 3 */
 
318
                { 0x9e, 0x59, 0x44, 0xae, 0xa9, 0x4b, 0x81, 0x16,
 
319
                  0x5c, 0x82, 0xfb, 0xf9, 0xf3, 0x2d, 0xb7, 0x51 },
 
320
                { 0xce, 0x83, 0xdb, 0xc5, 0x4a, 0xc0, 0x27, 0x4a,
 
321
                  0x15, 0x7c, 0x17, 0xf8, 0x0d, 0x01, 0x7b, 0xd6 },
 
322
                { 0xa6, 0x4a, 0x50, 0x7a, 0xe1, 0xa2, 0xa9, 0x8b,
 
323
                  0xb8, 0x8e, 0xb4, 0x21, 0x01, 0x35, 0xdc, 0x87 },
 
324
                { 0xcf, 0xbc, 0xe3, 0xfe },
 
325
                { 0xf3, 0x65, 0xcd, 0x68 },
 
326
                { 0x9a, 0x8e, 0xc9, 0x5f, 0x40, 0x8c, 0xc5, 0x07 }
 
327
        }, {
 
328
                /* 3GPP TS 55.205 v6.0.0 - Test Set 4 */
 
329
                { 0x4a, 0xb1, 0xde, 0xb0, 0x5c, 0xa6, 0xce, 0xb0,
 
330
                  0x51, 0xfc, 0x98, 0xe7, 0x7d, 0x02, 0x6a, 0x84 },
 
331
                { 0x74, 0xb0, 0xcd, 0x60, 0x31, 0xa1, 0xc8, 0x33,
 
332
                  0x9b, 0x2b, 0x6c, 0xe2, 0xb8, 0xc4, 0xa1, 0x86 },
 
333
                { 0xdc, 0xf0, 0x7c, 0xbd, 0x51, 0x85, 0x52, 0x90,
 
334
                  0xb9, 0x2a, 0x07, 0xa9, 0x89, 0x1e, 0x52, 0x3e },
 
335
                { 0x96, 0x55, 0xe2, 0x65 },
 
336
                { 0x58, 0x60, 0xfc, 0x1b },
 
337
                { 0xcd, 0xc1, 0xdc, 0x08, 0x41, 0xb8, 0x1a, 0x22 }
 
338
        }, {
 
339
                /* 3GPP TS 55.205 v6.0.0 - Test Set 5 */
 
340
                { 0x6c, 0x38, 0xa1, 0x16, 0xac, 0x28, 0x0c, 0x45,
 
341
                  0x4f, 0x59, 0x33, 0x2e, 0xe3, 0x5c, 0x8c, 0x4f },
 
342
                { 0xee, 0x64, 0x66, 0xbc, 0x96, 0x20, 0x2c, 0x5a,
 
343
                  0x55, 0x7a, 0xbb, 0xef, 0xf8, 0xba, 0xbf, 0x63 },
 
344
                { 0x38, 0x03, 0xef, 0x53, 0x63, 0xb9, 0x47, 0xc6,
 
345
                  0xaa, 0xa2, 0x25, 0xe5, 0x8f, 0xae, 0x39, 0x34 },
 
346
                { 0x13, 0x68, 0x8f, 0x17 },
 
347
                { 0x16, 0xc8, 0x23, 0x3f },
 
348
                { 0xdf, 0x75, 0xbc, 0x5e, 0xa8, 0x99, 0x87, 0x9f }
 
349
        }, {
 
350
                /* 3GPP TS 55.205 v6.0.0 - Test Set 6 */
 
351
                { 0x2d, 0x60, 0x9d, 0x4d, 0xb0, 0xac, 0x5b, 0xf0,
 
352
                  0xd2, 0xc0, 0xde, 0x26, 0x70, 0x14, 0xde, 0x0d },
 
353
                { 0x19, 0x4a, 0xa7, 0x56, 0x01, 0x38, 0x96, 0xb7,
 
354
                  0x4b, 0x4a, 0x2a, 0x3b, 0x0a, 0xf4, 0x53, 0x9e },
 
355
                { 0xc3, 0x5a, 0x0a, 0xb0, 0xbc, 0xbf, 0xc9, 0x25,
 
356
                  0x2c, 0xaf, 0xf1, 0x5f, 0x24, 0xef, 0xbd, 0xe0 },
 
357
                { 0x55, 0x3d, 0x00, 0xb3 },
 
358
                { 0x8c, 0x25, 0xa1, 0x6c },
 
359
                { 0x84, 0xb4, 0x17, 0xae, 0x3a, 0xea, 0xb4, 0xf3 }
 
360
        }, {
 
361
                /* 3GPP TS 55.205 v6.0.0 - Test Set 7 */
 
362
                { 0xa5, 0x30, 0xa7, 0xfe, 0x42, 0x8f, 0xad, 0x10,
 
363
                  0x82, 0xc4, 0x5e, 0xdd, 0xfc, 0xe1, 0x38, 0x84 },
 
364
                { 0x3a, 0x4c, 0x2b, 0x32, 0x45, 0xc5, 0x0e, 0xb5,
 
365
                  0xc7, 0x1d, 0x08, 0x63, 0x93, 0x95, 0x76, 0x4d },
 
366
                { 0x27, 0x95, 0x3e, 0x49, 0xbc, 0x8a, 0xf6, 0xdc,
 
367
                  0xc6, 0xe7, 0x30, 0xeb, 0x80, 0x28, 0x6b, 0xe3 },
 
368
                { 0x59, 0xf1, 0xa4, 0x4a },
 
369
                { 0xa6, 0x32, 0x41, 0xe1 },
 
370
                { 0x3b, 0x4e, 0x24, 0x4c, 0xdc, 0x60, 0xce, 0x03 }
 
371
        }, {
 
372
                /* 3GPP TS 55.205 v6.0.0 - Test Set 8 */
 
373
                { 0xd9, 0x15, 0x1c, 0xf0, 0x48, 0x96, 0xe2, 0x58,
 
374
                  0x30, 0xbf, 0x2e, 0x08, 0x26, 0x7b, 0x83, 0x60 },
 
375
                { 0xf7, 0x61, 0xe5, 0xe9, 0x3d, 0x60, 0x3f, 0xeb,
 
376
                  0x73, 0x0e, 0x27, 0x55, 0x6c, 0xb8, 0xa2, 0xca },
 
377
                { 0xc4, 0xc9, 0x3e, 0xff, 0xe8, 0xa0, 0x81, 0x38,
 
378
                  0xc2, 0x03, 0xd4, 0xc2, 0x7c, 0xe4, 0xe3, 0xd9 },
 
379
                { 0x50, 0x58, 0x88, 0x61 },
 
380
                { 0x4a, 0x90, 0xb2, 0x17 },
 
381
                { 0x8d, 0x4e, 0xc0, 0x1d, 0xe5, 0x97, 0xac, 0xfe }
 
382
        }, {
 
383
                /* 3GPP TS 55.205 v6.0.0 - Test Set 9 */
 
384
                { 0xa0, 0xe2, 0x97, 0x1b, 0x68, 0x22, 0xe8, 0xd3,
 
385
                  0x54, 0xa1, 0x8c, 0xc2, 0x35, 0x62, 0x4e, 0xcb },
 
386
                { 0x08, 0xef, 0xf8, 0x28, 0xb1, 0x3f, 0xdb, 0x56,
 
387
                  0x27, 0x22, 0xc6, 0x5c, 0x7f, 0x30, 0xa9, 0xb2 },
 
388
                { 0x82, 0xa2, 0x6f, 0x22, 0xbb, 0xa9, 0xe9, 0x48,
 
389
                  0x8f, 0x94, 0x9a, 0x10, 0xd9, 0x8e, 0x9c, 0xc4 },
 
390
                { 0xcd, 0xe6, 0xb0, 0x27 },
 
391
                { 0x4b, 0xc2, 0x21, 0x2d },
 
392
                { 0xd8, 0xde, 0xbc, 0x4f, 0xfb, 0xcd, 0x60, 0xaa }
 
393
        }, {
 
394
                /* 3GPP TS 55.205 v6.0.0 - Test Set 10 */
 
395
                { 0x0d, 0xa6, 0xf7, 0xba, 0x86, 0xd5, 0xea, 0xc8,
 
396
                  0xa1, 0x9c, 0xf5, 0x63, 0xac, 0x58, 0x64, 0x2d },
 
397
                { 0x67, 0x9a, 0xc4, 0xdb, 0xac, 0xd7, 0xd2, 0x33,
 
398
                  0xff, 0x9d, 0x68, 0x06, 0xf4, 0x14, 0x9c, 0xe3 },
 
399
                { 0x0d, 0xb1, 0x07, 0x1f, 0x87, 0x67, 0x56, 0x2c,
 
400
                  0xa4, 0x3a, 0x0a, 0x64, 0xc4, 0x1e, 0x8d, 0x08 },
 
401
                { 0x02, 0xd1, 0x3a, 0xcd },
 
402
                { 0x6f, 0xc3, 0x0f, 0xee },
 
403
                { 0xf0, 0xea, 0xa5, 0x0a, 0x1e, 0xdc, 0xeb, 0xb7 }
 
404
        }, {
 
405
                /* 3GPP TS 55.205 v6.0.0 - Test Set 11 */
 
406
                { 0x77, 0xb4, 0x58, 0x43, 0xc8, 0x8e, 0x58, 0xc1,
 
407
                  0x0d, 0x20, 0x26, 0x84, 0x51, 0x5e, 0xd4, 0x30 },
 
408
                { 0x4c, 0x47, 0xeb, 0x30, 0x76, 0xdc, 0x55, 0xfe,
 
409
                  0x51, 0x06, 0xcb, 0x20, 0x34, 0xb8, 0xcd, 0x78 },
 
410
                { 0xd4, 0x83, 0xaf, 0xae, 0x56, 0x24, 0x09, 0xa3,
 
411
                  0x26, 0xb5, 0xbb, 0x0b, 0x20, 0xc4, 0xd7, 0x62 },
 
412
                { 0x44, 0x38, 0x9d, 0x01 },
 
413
                { 0xae, 0xfa, 0x35, 0x7b },
 
414
                { 0x82, 0xdb, 0xab, 0x7f, 0x83, 0xf0, 0x63, 0xda }
 
415
        }, {
 
416
                /* 3GPP TS 55.205 v6.0.0 - Test Set 12 */
 
417
                { 0x72, 0x9b, 0x17, 0x72, 0x92, 0x70, 0xdd, 0x87,
 
418
                  0xcc, 0xdf, 0x1b, 0xfe, 0x29, 0xb4, 0xe9, 0xbb },
 
419
                { 0x31, 0x1c, 0x4c, 0x92, 0x97, 0x44, 0xd6, 0x75,
 
420
                  0xb7, 0x20, 0xf3, 0xb7, 0xe9, 0xb1, 0xcb, 0xd0 },
 
421
                { 0x22, 0x8c, 0x2f, 0x2f, 0x06, 0xac, 0x32, 0x68,
 
422
                  0xa9, 0xe6, 0x16, 0xee, 0x16, 0xdb, 0x4b, 0xa1 },
 
423
                { 0x03, 0xe0, 0xfd, 0x84 },
 
424
                { 0x98, 0xdb, 0xbd, 0x09 },
 
425
                { 0x3c, 0x66, 0xcb, 0x98, 0xca, 0xb2, 0xd3, 0x3d }
 
426
        }, {
 
427
                /* 3GPP TS 55.205 v6.0.0 - Test Set 13 */
 
428
                { 0xd3, 0x2d, 0xd2, 0x3e, 0x89, 0xdc, 0x66, 0x23,
 
429
                  0x54, 0xca, 0x12, 0xeb, 0x79, 0xdd, 0x32, 0xfa },
 
430
                { 0xcf, 0x7d, 0x0a, 0xb1, 0xd9, 0x43, 0x06, 0x95,
 
431
                  0x0b, 0xf1, 0x20, 0x18, 0xfb, 0xd4, 0x68, 0x87 },
 
432
                { 0xd2, 0x2a, 0x4b, 0x41, 0x80, 0xa5, 0x32, 0x57,
 
433
                  0x08, 0xa5, 0xff, 0x70, 0xd9, 0xf6, 0x7e, 0xc7 },
 
434
                { 0xbe, 0x73, 0xb3, 0xdc },
 
435
                { 0xaf, 0x4a, 0x41, 0x1e },
 
436
                { 0x96, 0x12, 0xb5, 0xd8, 0x8a, 0x41, 0x30, 0xbb }
 
437
        }, {
 
438
                /* 3GPP TS 55.205 v6.0.0 - Test Set 14 */
 
439
                { 0xaf, 0x7c, 0x65, 0xe1, 0x92, 0x72, 0x21, 0xde,
 
440
                  0x59, 0x11, 0x87, 0xa2, 0xc5, 0x98, 0x7a, 0x53 },
 
441
                { 0x1f, 0x0f, 0x85, 0x78, 0x46, 0x4f, 0xd5, 0x9b,
 
442
                  0x64, 0xbe, 0xd2, 0xd0, 0x94, 0x36, 0xb5, 0x7a },
 
443
                { 0xa4, 0xcf, 0x5c, 0x81, 0x55, 0xc0, 0x8a, 0x7e,
 
444
                  0xff, 0x41, 0x8e, 0x54, 0x43, 0xb9, 0x8e, 0x55 },
 
445
                { 0x8f, 0xe0, 0x19, 0xc7 },
 
446
                { 0x7b, 0xff, 0xa5, 0xc2 },
 
447
                { 0x75, 0xa1, 0x50, 0xdf, 0x3c, 0x6a, 0xed, 0x08 }
 
448
        }, {
 
449
                /* 3GPP TS 55.205 v6.0.0 - Test Set 15 */
 
450
                { 0x5b, 0xd7, 0xec, 0xd3, 0xd3, 0x12, 0x7a, 0x41,
 
451
                  0xd1, 0x25, 0x39, 0xbe, 0xd4, 0xe7, 0xcf, 0x71 },
 
452
                { 0x59, 0xb7, 0x5f, 0x14, 0x25, 0x1c, 0x75, 0x03,
 
453
                  0x1d, 0x0b, 0xcb, 0xac, 0x1c, 0x2c, 0x04, 0xc7 },
 
454
                { 0x76, 0x08, 0x9d, 0x3c, 0x0f, 0xf3, 0xef, 0xdc,
 
455
                  0x6e, 0x36, 0x72, 0x1d, 0x4f, 0xce, 0xb7, 0x47 },
 
456
                { 0x27, 0x20, 0x2b, 0x82 },
 
457
                { 0x7e, 0x3f, 0x44, 0xc7 },
 
458
                { 0xb7, 0xf9, 0x2e, 0x42, 0x6a, 0x36, 0xfe, 0xc5 }
 
459
        }, {
 
460
                /* 3GPP TS 55.205 v6.0.0 - Test Set 16 */
 
461
                { 0x6c, 0xd1, 0xc6, 0xce, 0xb1, 0xe0, 0x1e, 0x14,
 
462
                  0xf1, 0xb8, 0x23, 0x16, 0xa9, 0x0b, 0x7f, 0x3d },
 
463
                { 0xf6, 0x9b, 0x78, 0xf3, 0x00, 0xa0, 0x56, 0x8b,
 
464
                  0xce, 0x9f, 0x0c, 0xb9, 0x3c, 0x4b, 0xe4, 0xc9 },
 
465
                { 0xa2, 0x19, 0xdc, 0x37, 0xf1, 0xdc, 0x7d, 0x66,
 
466
                  0x73, 0x8b, 0x58, 0x43, 0xc7, 0x99, 0xf2, 0x06 },
 
467
                { 0xdd, 0xd7, 0xef, 0xe6 },
 
468
                { 0x70, 0xf6, 0xbd, 0xb9 },
 
469
                { 0x88, 0xd9, 0xde, 0x10, 0xa2, 0x20, 0x04, 0xc5 }
 
470
        }, {
 
471
                /* 3GPP TS 55.205 v6.0.0 - Test Set 17 */
 
472
                { 0xb7, 0x3a, 0x90, 0xcb, 0xcf, 0x3a, 0xfb, 0x62,
 
473
                  0x2d, 0xba, 0x83, 0xc5, 0x8a, 0x84, 0x15, 0xdf },
 
474
                { 0xb1, 0x20, 0xf1, 0xc1, 0xa0, 0x10, 0x2a, 0x2f,
 
475
                  0x50, 0x7d, 0xd5, 0x43, 0xde, 0x68, 0x28, 0x1f },
 
476
                { 0xdf, 0x0c, 0x67, 0x86, 0x8f, 0xa2, 0x5f, 0x74,
 
477
                  0x8b, 0x70, 0x44, 0xc6, 0xe7, 0xc2, 0x45, 0xb8 },
 
478
                { 0x67, 0xe4, 0xff, 0x3f },
 
479
                { 0x47, 0x9d, 0xd2, 0x5c },
 
480
                { 0xa8, 0x19, 0xe5, 0x77, 0xa8, 0xd6, 0x17, 0x5b }
 
481
        }, {
 
482
                /* 3GPP TS 55.205 v6.0.0 - Test Set 18 */
 
483
                { 0x51, 0x22, 0x25, 0x02, 0x14, 0xc3, 0x3e, 0x72,
 
484
                  0x3a, 0x5d, 0xd5, 0x23, 0xfc, 0x14, 0x5f, 0xc0 },
 
485
                { 0x81, 0xe9, 0x2b, 0x6c, 0x0e, 0xe0, 0xe1, 0x2e,
 
486
                  0xbc, 0xeb, 0xa8, 0xd9, 0x2a, 0x99, 0xdf, 0xa5 },
 
487
                { 0x98, 0x1d, 0x46, 0x4c, 0x7c, 0x52, 0xeb, 0x6e,
 
488
                  0x50, 0x36, 0x23, 0x49, 0x84, 0xad, 0x0b, 0xcf },
 
489
                { 0x8a, 0x3b, 0x8d, 0x17 },
 
490
                { 0x28, 0xd7, 0xb0, 0xf2 },
 
491
                { 0x9a, 0x8d, 0x0e, 0x88, 0x3f, 0xf0, 0x88, 0x7a }
 
492
        }, {
 
493
                /* 3GPP TS 55.205 v6.0.0 - Test Set 19 */
 
494
                { 0x90, 0xdc, 0xa4, 0xed, 0xa4, 0x5b, 0x53, 0xcf,
 
495
                  0x0f, 0x12, 0xd7, 0xc9, 0xc3, 0xbc, 0x6a, 0x89 },
 
496
                { 0x9f, 0xdd, 0xc7, 0x20, 0x92, 0xc6, 0xad, 0x03,
 
497
                  0x6b, 0x6e, 0x46, 0x47, 0x89, 0x31, 0x5b, 0x78 },
 
498
                { 0xcb, 0x9c, 0xcc, 0xc4, 0xb9, 0x25, 0x8e, 0x6d,
 
499
                  0xca, 0x47, 0x60, 0x37, 0x9f, 0xb8, 0x25, 0x81 },
 
500
                { 0xdf, 0x58, 0x52, 0x2f },
 
501
                { 0xa9, 0x51, 0x00, 0xe2 },
 
502
                { 0xed, 0x29, 0xb2, 0xf1, 0xc2, 0x7f, 0x9f, 0x34 }
 
503
        }
 
504
};
 
505
 
 
506
#define NUM_GSM_TESTS (sizeof(gsm_test_sets) / sizeof(gsm_test_sets[0]))
 
507
 
 
508
 
 
509
struct milenage_test_set {
 
510
        u8 k[16];
 
511
        u8 rand[16];
 
512
        u8 sqn[6];
 
513
        u8 amf[2];
 
514
        u8 op[16];
 
515
        u8 opc[16];
 
516
        u8 f1[8];
 
517
        u8 f1star[8];
 
518
        u8 f2[8];
 
519
        u8 f3[16];
 
520
        u8 f4[16];
 
521
        u8 f5[6];
 
522
        u8 f5star[6];
 
523
};
 
524
 
 
525
static const struct milenage_test_set test_sets[] =
 
526
{
 
527
        {
 
528
                /* 3GPP TS 35.208 v6.0.0 - 4.3.1 Test Set 1 */
 
529
                { 0x46, 0x5b, 0x5c, 0xe8, 0xb1, 0x99, 0xb4, 0x9f,
 
530
                  0xaa, 0x5f, 0x0a, 0x2e, 0xe2, 0x38, 0xa6, 0xbc },
 
531
                { 0x23, 0x55, 0x3c, 0xbe, 0x96, 0x37, 0xa8, 0x9d,
 
532
                  0x21, 0x8a, 0xe6, 0x4d, 0xae, 0x47, 0xbf, 0x35 },
 
533
                { 0xff, 0x9b, 0xb4, 0xd0, 0xb6, 0x07 },
 
534
                { 0xb9, 0xb9 },
 
535
                { 0xcd, 0xc2, 0x02, 0xd5, 0x12, 0x3e, 0x20, 0xf6,
 
536
                  0x2b, 0x6d, 0x67, 0x6a, 0xc7, 0x2c, 0xb3, 0x18 },
 
537
                { 0xcd, 0x63, 0xcb, 0x71, 0x95, 0x4a, 0x9f, 0x4e,
 
538
                  0x48, 0xa5, 0x99, 0x4e, 0x37, 0xa0, 0x2b, 0xaf },
 
539
                { 0x4a, 0x9f, 0xfa, 0xc3, 0x54, 0xdf, 0xaf, 0xb3 },
 
540
                { 0x01, 0xcf, 0xaf, 0x9e, 0xc4, 0xe8, 0x71, 0xe9 },
 
541
                { 0xa5, 0x42, 0x11, 0xd5, 0xe3, 0xba, 0x50, 0xbf },
 
542
                { 0xb4, 0x0b, 0xa9, 0xa3, 0xc5, 0x8b, 0x2a, 0x05,
 
543
                  0xbb, 0xf0, 0xd9, 0x87, 0xb2, 0x1b, 0xf8, 0xcb },
 
544
                { 0xf7, 0x69, 0xbc, 0xd7, 0x51, 0x04, 0x46, 0x04,
 
545
                  0x12, 0x76, 0x72, 0x71, 0x1c, 0x6d, 0x34, 0x41 },
 
546
                { 0xaa, 0x68, 0x9c, 0x64, 0x83, 0x70 },
 
547
                { 0x45, 0x1e, 0x8b, 0xec, 0xa4, 0x3b }
 
548
        }, {
 
549
                /* 3GPP TS 35.208 v6.0.0 - 4.3.2 Test Set 2 */
 
550
                { 0x46, 0x5b, 0x5c, 0xe8, 0xb1, 0x99, 0xb4, 0x9f,
 
551
                  0xaa, 0x5f, 0x0a, 0x2e, 0xe2, 0x38, 0xa6, 0xbc },
 
552
                { 0x23, 0x55, 0x3c, 0xbe, 0x96, 0x37, 0xa8, 0x9d,
 
553
                  0x21, 0x8a, 0xe6, 0x4d, 0xae, 0x47, 0xbf, 0x35 },
 
554
                { 0xff, 0x9b, 0xb4, 0xd0, 0xb6, 0x07 },
 
555
                { 0xb9, 0xb9 },
 
556
                { 0xcd, 0xc2, 0x02, 0xd5, 0x12, 0x3e, 0x20, 0xf6,
 
557
                  0x2b, 0x6d, 0x67, 0x6a, 0xc7, 0x2c, 0xb3, 0x18 },
 
558
                { 0xcd, 0x63, 0xcb, 0x71, 0x95, 0x4a, 0x9f, 0x4e,
 
559
                  0x48, 0xa5, 0x99, 0x4e, 0x37, 0xa0, 0x2b, 0xaf },
 
560
                { 0x4a, 0x9f, 0xfa, 0xc3, 0x54, 0xdf, 0xaf, 0xb3 },
 
561
                { 0x01, 0xcf, 0xaf, 0x9e, 0xc4, 0xe8, 0x71, 0xe9 },
 
562
                { 0xa5, 0x42, 0x11, 0xd5, 0xe3, 0xba, 0x50, 0xbf },
 
563
                { 0xb4, 0x0b, 0xa9, 0xa3, 0xc5, 0x8b, 0x2a, 0x05,
 
564
                  0xbb, 0xf0, 0xd9, 0x87, 0xb2, 0x1b, 0xf8, 0xcb },
 
565
                { 0xf7, 0x69, 0xbc, 0xd7, 0x51, 0x04, 0x46, 0x04,
 
566
                  0x12, 0x76, 0x72, 0x71, 0x1c, 0x6d, 0x34, 0x41 },
 
567
                { 0xaa, 0x68, 0x9c, 0x64, 0x83, 0x70 },
 
568
                { 0x45, 0x1e, 0x8b, 0xec, 0xa4, 0x3b }
 
569
        }, {
 
570
                /* 3GPP TS 35.208 v6.0.0 - 4.3.3 Test Set 3 */
 
571
                { 0xfe, 0xc8, 0x6b, 0xa6, 0xeb, 0x70, 0x7e, 0xd0,
 
572
                  0x89, 0x05, 0x75, 0x7b, 0x1b, 0xb4, 0x4b, 0x8f },
 
573
                { 0x9f, 0x7c, 0x8d, 0x02, 0x1a, 0xcc, 0xf4, 0xdb,
 
574
                  0x21, 0x3c, 0xcf, 0xf0, 0xc7, 0xf7, 0x1a, 0x6a },
 
575
                { 0x9d, 0x02, 0x77, 0x59, 0x5f, 0xfc },
 
576
                { 0x72, 0x5c },
 
577
                { 0xdb, 0xc5, 0x9a, 0xdc, 0xb6, 0xf9, 0xa0, 0xef,
 
578
                  0x73, 0x54, 0x77, 0xb7, 0xfa, 0xdf, 0x83, 0x74 },
 
579
                { 0x10, 0x06, 0x02, 0x0f, 0x0a, 0x47, 0x8b, 0xf6,
 
580
                  0xb6, 0x99, 0xf1, 0x5c, 0x06, 0x2e, 0x42, 0xb3 },
 
581
                { 0x9c, 0xab, 0xc3, 0xe9, 0x9b, 0xaf, 0x72, 0x81 },
 
582
                { 0x95, 0x81, 0x4b, 0xa2, 0xb3, 0x04, 0x43, 0x24 },
 
583
                { 0x80, 0x11, 0xc4, 0x8c, 0x0c, 0x21, 0x4e, 0xd2 },
 
584
                { 0x5d, 0xbd, 0xbb, 0x29, 0x54, 0xe8, 0xf3, 0xcd,
 
585
                  0xe6, 0x65, 0xb0, 0x46, 0x17, 0x9a, 0x50, 0x98 },
 
586
                { 0x59, 0xa9, 0x2d, 0x3b, 0x47, 0x6a, 0x04, 0x43,
 
587
                  0x48, 0x70, 0x55, 0xcf, 0x88, 0xb2, 0x30, 0x7b },
 
588
                { 0x33, 0x48, 0x4d, 0xc2, 0x13, 0x6b },
 
589
                { 0xde, 0xac, 0xdd, 0x84, 0x8c, 0xc6 }
 
590
        }, {
 
591
                /* 3GPP TS 35.208 v6.0.0 - 4.3.4 Test Set 4 */
 
592
                { 0x9e, 0x59, 0x44, 0xae, 0xa9, 0x4b, 0x81, 0x16,
 
593
                  0x5c, 0x82, 0xfb, 0xf9, 0xf3, 0x2d, 0xb7, 0x51 },
 
594
                { 0xce, 0x83, 0xdb, 0xc5, 0x4a, 0xc0, 0x27, 0x4a,
 
595
                  0x15, 0x7c, 0x17, 0xf8, 0x0d, 0x01, 0x7b, 0xd6 },
 
596
                { 0x0b, 0x60, 0x4a, 0x81, 0xec, 0xa8 },
 
597
                { 0x9e, 0x09 },
 
598
                { 0x22, 0x30, 0x14, 0xc5, 0x80, 0x66, 0x94, 0xc0,
 
599
                  0x07, 0xca, 0x1e, 0xee, 0xf5, 0x7f, 0x00, 0x4f },
 
600
                { 0xa6, 0x4a, 0x50, 0x7a, 0xe1, 0xa2, 0xa9, 0x8b,
 
601
                  0xb8, 0x8e, 0xb4, 0x21, 0x01, 0x35, 0xdc, 0x87 },
 
602
                { 0x74, 0xa5, 0x82, 0x20, 0xcb, 0xa8, 0x4c, 0x49 },
 
603
                { 0xac, 0x2c, 0xc7, 0x4a, 0x96, 0x87, 0x18, 0x37 },
 
604
                { 0xf3, 0x65, 0xcd, 0x68, 0x3c, 0xd9, 0x2e, 0x96 },
 
605
                { 0xe2, 0x03, 0xed, 0xb3, 0x97, 0x15, 0x74, 0xf5,
 
606
                  0xa9, 0x4b, 0x0d, 0x61, 0xb8, 0x16, 0x34, 0x5d },
 
607
                { 0x0c, 0x45, 0x24, 0xad, 0xea, 0xc0, 0x41, 0xc4,
 
608
                  0xdd, 0x83, 0x0d, 0x20, 0x85, 0x4f, 0xc4, 0x6b },
 
609
                { 0xf0, 0xb9, 0xc0, 0x8a, 0xd0, 0x2e },
 
610
                { 0x60, 0x85, 0xa8, 0x6c, 0x6f, 0x63 }
 
611
        }, {
 
612
                /* 3GPP TS 35.208 v6.0.0 - 4.3.5 Test Set 5 */
 
613
                { 0x4a, 0xb1, 0xde, 0xb0, 0x5c, 0xa6, 0xce, 0xb0,
 
614
                  0x51, 0xfc, 0x98, 0xe7, 0x7d, 0x02, 0x6a, 0x84 },
 
615
                { 0x74, 0xb0, 0xcd, 0x60, 0x31, 0xa1, 0xc8, 0x33,
 
616
                  0x9b, 0x2b, 0x6c, 0xe2, 0xb8, 0xc4, 0xa1, 0x86 },
 
617
                { 0xe8, 0x80, 0xa1, 0xb5, 0x80, 0xb6 },
 
618
                { 0x9f, 0x07 },
 
619
                { 0x2d, 0x16, 0xc5, 0xcd, 0x1f, 0xdf, 0x6b, 0x22,
 
620
                  0x38, 0x35, 0x84, 0xe3, 0xbe, 0xf2, 0xa8, 0xd8 },
 
621
                { 0xdc, 0xf0, 0x7c, 0xbd, 0x51, 0x85, 0x52, 0x90,
 
622
                  0xb9, 0x2a, 0x07, 0xa9, 0x89, 0x1e, 0x52, 0x3e },
 
623
                { 0x49, 0xe7, 0x85, 0xdd, 0x12, 0x62, 0x6e, 0xf2 },
 
624
                { 0x9e, 0x85, 0x79, 0x03, 0x36, 0xbb, 0x3f, 0xa2 },
 
625
                { 0x58, 0x60, 0xfc, 0x1b, 0xce, 0x35, 0x1e, 0x7e },
 
626
                { 0x76, 0x57, 0x76, 0x6b, 0x37, 0x3d, 0x1c, 0x21,
 
627
                  0x38, 0xf3, 0x07, 0xe3, 0xde, 0x92, 0x42, 0xf9 },
 
628
                { 0x1c, 0x42, 0xe9, 0x60, 0xd8, 0x9b, 0x8f, 0xa9,
 
629
                  0x9f, 0x27, 0x44, 0xe0, 0x70, 0x8c, 0xcb, 0x53 },
 
630
                { 0x31, 0xe1, 0x1a, 0x60, 0x91, 0x18 },
 
631
                { 0xfe, 0x25, 0x55, 0xe5, 0x4a, 0xa9 }
 
632
        }, {
 
633
                /* 3GPP TS 35.208 v6.0.0 - 4.3.6 Test Set 6 */
 
634
                { 0x6c, 0x38, 0xa1, 0x16, 0xac, 0x28, 0x0c, 0x45,
 
635
                  0x4f, 0x59, 0x33, 0x2e, 0xe3, 0x5c, 0x8c, 0x4f },
 
636
                { 0xee, 0x64, 0x66, 0xbc, 0x96, 0x20, 0x2c, 0x5a,
 
637
                  0x55, 0x7a, 0xbb, 0xef, 0xf8, 0xba, 0xbf, 0x63 },
 
638
                { 0x41, 0x4b, 0x98, 0x22, 0x21, 0x81 },
 
639
                { 0x44, 0x64 },
 
640
                { 0x1b, 0xa0, 0x0a, 0x1a, 0x7c, 0x67, 0x00, 0xac,
 
641
                  0x8c, 0x3f, 0xf3, 0xe9, 0x6a, 0xd0, 0x87, 0x25 },
 
642
                { 0x38, 0x03, 0xef, 0x53, 0x63, 0xb9, 0x47, 0xc6,
 
643
                  0xaa, 0xa2, 0x25, 0xe5, 0x8f, 0xae, 0x39, 0x34 },
 
644
                { 0x07, 0x8a, 0xdf, 0xb4, 0x88, 0x24, 0x1a, 0x57 },
 
645
                { 0x80, 0x24, 0x6b, 0x8d, 0x01, 0x86, 0xbc, 0xf1 },
 
646
                { 0x16, 0xc8, 0x23, 0x3f, 0x05, 0xa0, 0xac, 0x28 },
 
647
                { 0x3f, 0x8c, 0x75, 0x87, 0xfe, 0x8e, 0x4b, 0x23,
 
648
                  0x3a, 0xf6, 0x76, 0xae, 0xde, 0x30, 0xba, 0x3b },
 
649
                { 0xa7, 0x46, 0x6c, 0xc1, 0xe6, 0xb2, 0xa1, 0x33,
 
650
                  0x7d, 0x49, 0xd3, 0xb6, 0x6e, 0x95, 0xd7, 0xb4 },
 
651
                { 0x45, 0xb0, 0xf6, 0x9a, 0xb0, 0x6c },
 
652
                { 0x1f, 0x53, 0xcd, 0x2b, 0x11, 0x13 }
 
653
        }, {
 
654
                /* 3GPP TS 35.208 v6.0.0 - 4.3.7 Test Set 7 */
 
655
                { 0x2d, 0x60, 0x9d, 0x4d, 0xb0, 0xac, 0x5b, 0xf0,
 
656
                  0xd2, 0xc0, 0xde, 0x26, 0x70, 0x14, 0xde, 0x0d },
 
657
                { 0x19, 0x4a, 0xa7, 0x56, 0x01, 0x38, 0x96, 0xb7,
 
658
                  0x4b, 0x4a, 0x2a, 0x3b, 0x0a, 0xf4, 0x53, 0x9e },
 
659
                { 0x6b, 0xf6, 0x94, 0x38, 0xc2, 0xe4 },
 
660
                { 0x5f, 0x67 },
 
661
                { 0x46, 0x0a, 0x48, 0x38, 0x54, 0x27, 0xaa, 0x39,
 
662
                  0x26, 0x4a, 0xac, 0x8e, 0xfc, 0x9e, 0x73, 0xe8 },
 
663
                { 0xc3, 0x5a, 0x0a, 0xb0, 0xbc, 0xbf, 0xc9, 0x25,
 
664
                  0x2c, 0xaf, 0xf1, 0x5f, 0x24, 0xef, 0xbd, 0xe0 },
 
665
                { 0xbd, 0x07, 0xd3, 0x00, 0x3b, 0x9e, 0x5c, 0xc3 },
 
666
                { 0xbc, 0xb6, 0xc2, 0xfc, 0xad, 0x15, 0x22, 0x50 },
 
667
                { 0x8c, 0x25, 0xa1, 0x6c, 0xd9, 0x18, 0xa1, 0xdf },
 
668
                { 0x4c, 0xd0, 0x84, 0x60, 0x20, 0xf8, 0xfa, 0x07,
 
669
                  0x31, 0xdd, 0x47, 0xcb, 0xdc, 0x6b, 0xe4, 0x11 },
 
670
                { 0x88, 0xab, 0x80, 0xa4, 0x15, 0xf1, 0x5c, 0x73,
 
671
                  0x71, 0x12, 0x54, 0xa1, 0xd3, 0x88, 0xf6, 0x96 },
 
672
                { 0x7e, 0x64, 0x55, 0xf3, 0x4c, 0xf3 },
 
673
                { 0xdc, 0x6d, 0xd0, 0x1e, 0x8f, 0x15 }
 
674
        }, {
 
675
                /* 3GPP TS 35.208 v6.0.0 - 4.3.8 Test Set 8 */
 
676
                { 0xa5, 0x30, 0xa7, 0xfe, 0x42, 0x8f, 0xad, 0x10,
 
677
                  0x82, 0xc4, 0x5e, 0xdd, 0xfc, 0xe1, 0x38, 0x84 },
 
678
                { 0x3a, 0x4c, 0x2b, 0x32, 0x45, 0xc5, 0x0e, 0xb5,
 
679
                  0xc7, 0x1d, 0x08, 0x63, 0x93, 0x95, 0x76, 0x4d },
 
680
                { 0xf6, 0x3f, 0x5d, 0x76, 0x87, 0x84 },
 
681
                { 0xb9, 0x0e },
 
682
                { 0x51, 0x1c, 0x6c, 0x4e, 0x83, 0xe3, 0x8c, 0x89,
 
683
                  0xb1, 0xc5, 0xd8, 0xdd, 0xe6, 0x24, 0x26, 0xfa },
 
684
                { 0x27, 0x95, 0x3e, 0x49, 0xbc, 0x8a, 0xf6, 0xdc,
 
685
                  0xc6, 0xe7, 0x30, 0xeb, 0x80, 0x28, 0x6b, 0xe3 },
 
686
                { 0x53, 0x76, 0x1f, 0xbd, 0x67, 0x9b, 0x0b, 0xad },
 
687
                { 0x21, 0xad, 0xfd, 0x33, 0x4a, 0x10, 0xe7, 0xce },
 
688
                { 0xa6, 0x32, 0x41, 0xe1, 0xff, 0xc3, 0xe5, 0xab },
 
689
                { 0x10, 0xf0, 0x5b, 0xab, 0x75, 0xa9, 0x9a, 0x5f,
 
690
                  0xbb, 0x98, 0xa9, 0xc2, 0x87, 0x67, 0x9c, 0x3b },
 
691
                { 0xf9, 0xec, 0x08, 0x65, 0xeb, 0x32, 0xf2, 0x23,
 
692
                  0x69, 0xca, 0xde, 0x40, 0xc5, 0x9c, 0x3a, 0x44 },
 
693
                { 0x88, 0x19, 0x6c, 0x47, 0x98, 0x6f },
 
694
                { 0xc9, 0x87, 0xa3, 0xd2, 0x31, 0x15 }
 
695
        }, {
 
696
                /* 3GPP TS 35.208 v6.0.0 - 4.3.9 Test Set 9 */
 
697
                { 0xd9, 0x15, 0x1c, 0xf0, 0x48, 0x96, 0xe2, 0x58,
 
698
                  0x30, 0xbf, 0x2e, 0x08, 0x26, 0x7b, 0x83, 0x60 },
 
699
                { 0xf7, 0x61, 0xe5, 0xe9, 0x3d, 0x60, 0x3f, 0xeb,
 
700
                  0x73, 0x0e, 0x27, 0x55, 0x6c, 0xb8, 0xa2, 0xca },
 
701
                { 0x47, 0xee, 0x01, 0x99, 0x82, 0x0a },
 
702
                { 0x91, 0x13 },
 
703
                { 0x75, 0xfc, 0x22, 0x33, 0xa4, 0x42, 0x94, 0xee,
 
704
                  0x8e, 0x6d, 0xe2, 0x5c, 0x43, 0x53, 0xd2, 0x6b },
 
705
                { 0xc4, 0xc9, 0x3e, 0xff, 0xe8, 0xa0, 0x81, 0x38,
 
706
                  0xc2, 0x03, 0xd4, 0xc2, 0x7c, 0xe4, 0xe3, 0xd9 },
 
707
                { 0x66, 0xcc, 0x4b, 0xe4, 0x48, 0x62, 0xaf, 0x1f },
 
708
                { 0x7a, 0x4b, 0x8d, 0x7a, 0x87, 0x53, 0xf2, 0x46 },
 
709
                { 0x4a, 0x90, 0xb2, 0x17, 0x1a, 0xc8, 0x3a, 0x76 },
 
710
                { 0x71, 0x23, 0x6b, 0x71, 0x29, 0xf9, 0xb2, 0x2a,
 
711
                  0xb7, 0x7e, 0xa7, 0xa5, 0x4c, 0x96, 0xda, 0x22 },
 
712
                { 0x90, 0x52, 0x7e, 0xba, 0xa5, 0x58, 0x89, 0x68,
 
713
                  0xdb, 0x41, 0x72, 0x73, 0x25, 0xa0, 0x4d, 0x9e },
 
714
                { 0x82, 0xa0, 0xf5, 0x28, 0x7a, 0x71 },
 
715
                { 0x52, 0x7d, 0xbf, 0x41, 0xf3, 0x5f }
 
716
        }, {
 
717
                /* 3GPP TS 35.208 v6.0.0 - 4.3.10 Test Set 10 */
 
718
                { 0xa0, 0xe2, 0x97, 0x1b, 0x68, 0x22, 0xe8, 0xd3,
 
719
                  0x54, 0xa1, 0x8c, 0xc2, 0x35, 0x62, 0x4e, 0xcb },
 
720
                { 0x08, 0xef, 0xf8, 0x28, 0xb1, 0x3f, 0xdb, 0x56,
 
721
                  0x27, 0x22, 0xc6, 0x5c, 0x7f, 0x30, 0xa9, 0xb2 },
 
722
                { 0xdb, 0x5c, 0x06, 0x64, 0x81, 0xe0 },
 
723
                { 0x71, 0x6b },
 
724
                { 0x32, 0x37, 0x92, 0xfa, 0xca, 0x21, 0xfb, 0x4d,
 
725
                  0x5d, 0x6f, 0x13, 0xc1, 0x45, 0xa9, 0xd2, 0xc1 },
 
726
                { 0x82, 0xa2, 0x6f, 0x22, 0xbb, 0xa9, 0xe9, 0x48,
 
727
                  0x8f, 0x94, 0x9a, 0x10, 0xd9, 0x8e, 0x9c, 0xc4 },
 
728
                { 0x94, 0x85, 0xfe, 0x24, 0x62, 0x1c, 0xb9, 0xf6 },
 
729
                { 0xbc, 0xe3, 0x25, 0xce, 0x03, 0xe2, 0xe9, 0xb9 },
 
730
                { 0x4b, 0xc2, 0x21, 0x2d, 0x86, 0x24, 0x91, 0x0a },
 
731
                { 0x08, 0xce, 0xf6, 0xd0, 0x04, 0xec, 0x61, 0x47,
 
732
                  0x1a, 0x3c, 0x3c, 0xda, 0x04, 0x81, 0x37, 0xfa },
 
733
                { 0xed, 0x03, 0x18, 0xca, 0x5d, 0xeb, 0x92, 0x06,
 
734
                  0x27, 0x2f, 0x6e, 0x8f, 0xa6, 0x4b, 0xa4, 0x11 },
 
735
                { 0xa2, 0xf8, 0x58, 0xaa, 0x9e, 0x5d },
 
736
                { 0x74, 0xe7, 0x6f, 0xbb, 0xec, 0x38 }
 
737
        }, {
 
738
                /* 3GPP TS 35.208 v6.0.0 - 4.3.11 Test Set 11 */
 
739
                { 0x0d, 0xa6, 0xf7, 0xba, 0x86, 0xd5, 0xea, 0xc8,
 
740
                  0xa1, 0x9c, 0xf5, 0x63, 0xac, 0x58, 0x64, 0x2d },
 
741
                { 0x67, 0x9a, 0xc4, 0xdb, 0xac, 0xd7, 0xd2, 0x33,
 
742
                  0xff, 0x9d, 0x68, 0x06, 0xf4, 0x14, 0x9c, 0xe3 },
 
743
                { 0x6e, 0x23, 0x31, 0xd6, 0x92, 0xad },
 
744
                { 0x22, 0x4a },
 
745
                { 0x4b, 0x9a, 0x26, 0xfa, 0x45, 0x9e, 0x3a, 0xcb,
 
746
                  0xff, 0x36, 0xf4, 0x01, 0x5d, 0xe3, 0xbd, 0xc1 },
 
747
                { 0x0d, 0xb1, 0x07, 0x1f, 0x87, 0x67, 0x56, 0x2c,
 
748
                  0xa4, 0x3a, 0x0a, 0x64, 0xc4, 0x1e, 0x8d, 0x08 },
 
749
                { 0x28, 0x31, 0xd7, 0xae, 0x90, 0x88, 0xe4, 0x92 },
 
750
                { 0x9b, 0x2e, 0x16, 0x95, 0x11, 0x35, 0xd5, 0x23 },
 
751
                { 0x6f, 0xc3, 0x0f, 0xee, 0x6d, 0x12, 0x35, 0x23 },
 
752
                { 0x69, 0xb1, 0xca, 0xe7, 0xc7, 0x42, 0x9d, 0x97,
 
753
                  0x5e, 0x24, 0x5c, 0xac, 0xb0, 0x5a, 0x51, 0x7c },
 
754
                { 0x74, 0xf2, 0x4e, 0x8c, 0x26, 0xdf, 0x58, 0xe1,
 
755
                  0xb3, 0x8d, 0x7d, 0xcd, 0x4f, 0x1b, 0x7f, 0xbd },
 
756
                { 0x4c, 0x53, 0x9a, 0x26, 0xe1, 0xfa },
 
757
                { 0x07, 0x86, 0x1e, 0x12, 0x69, 0x28 }
 
758
        }, {
 
759
                /* 3GPP TS 35.208 v6.0.0 - 4.3.12 Test Set 12 */
 
760
                { 0x77, 0xb4, 0x58, 0x43, 0xc8, 0x8e, 0x58, 0xc1,
 
761
                  0x0d, 0x20, 0x26, 0x84, 0x51, 0x5e, 0xd4, 0x30 },
 
762
                { 0x4c, 0x47, 0xeb, 0x30, 0x76, 0xdc, 0x55, 0xfe,
 
763
                  0x51, 0x06, 0xcb, 0x20, 0x34, 0xb8, 0xcd, 0x78 },
 
764
                { 0xfe, 0x1a, 0x87, 0x31, 0x00, 0x5d },
 
765
                { 0xad, 0x25 },
 
766
                { 0xbf, 0x32, 0x86, 0xc7, 0xa5, 0x14, 0x09, 0xce,
 
767
                  0x95, 0x72, 0x4d, 0x50, 0x3b, 0xfe, 0x6e, 0x70 },
 
768
                { 0xd4, 0x83, 0xaf, 0xae, 0x56, 0x24, 0x09, 0xa3,
 
769
                  0x26, 0xb5, 0xbb, 0x0b, 0x20, 0xc4, 0xd7, 0x62 },
 
770
                { 0x08, 0x33, 0x2d, 0x7e, 0x9f, 0x48, 0x45, 0x70 },
 
771
                { 0xed, 0x41, 0xb7, 0x34, 0x48, 0x9d, 0x52, 0x07 },
 
772
                { 0xae, 0xfa, 0x35, 0x7b, 0xea, 0xc2, 0xa8, 0x7a },
 
773
                { 0x90, 0x8c, 0x43, 0xf0, 0x56, 0x9c, 0xb8, 0xf7,
 
774
                  0x4b, 0xc9, 0x71, 0xe7, 0x06, 0xc3, 0x6c, 0x5f },
 
775
                { 0xc2, 0x51, 0xdf, 0x0d, 0x88, 0x8d, 0xd9, 0x32,
 
776
                  0x9b, 0xcf, 0x46, 0x65, 0x5b, 0x22, 0x6e, 0x40 },
 
777
                { 0x30, 0xff, 0x25, 0xcd, 0xad, 0xf6 },
 
778
                { 0xe8, 0x4e, 0xd0, 0xd4, 0x67, 0x7e }
 
779
        }, {
 
780
                /* 3GPP TS 35.208 v6.0.0 - 4.3.13 Test Set 13 */
 
781
                { 0x72, 0x9b, 0x17, 0x72, 0x92, 0x70, 0xdd, 0x87,
 
782
                  0xcc, 0xdf, 0x1b, 0xfe, 0x29, 0xb4, 0xe9, 0xbb },
 
783
                { 0x31, 0x1c, 0x4c, 0x92, 0x97, 0x44, 0xd6, 0x75,
 
784
                  0xb7, 0x20, 0xf3, 0xb7, 0xe9, 0xb1, 0xcb, 0xd0 },
 
785
                { 0xc8, 0x5c, 0x4c, 0xf6, 0x59, 0x16 },
 
786
                { 0x5b, 0xb2 },
 
787
                { 0xd0, 0x4c, 0x9c, 0x35, 0xbd, 0x22, 0x62, 0xfa,
 
788
                  0x81, 0x0d, 0x29, 0x24, 0xd0, 0x36, 0xfd, 0x13 },
 
789
                { 0x22, 0x8c, 0x2f, 0x2f, 0x06, 0xac, 0x32, 0x68,
 
790
                  0xa9, 0xe6, 0x16, 0xee, 0x16, 0xdb, 0x4b, 0xa1 },
 
791
                { 0xff, 0x79, 0x4f, 0xe2, 0xf8, 0x27, 0xeb, 0xf8 },
 
792
                { 0x24, 0xfe, 0x4d, 0xc6, 0x1e, 0x87, 0x4b, 0x52 },
 
793
                { 0x98, 0xdb, 0xbd, 0x09, 0x9b, 0x3b, 0x40, 0x8d },
 
794
                { 0x44, 0xc0, 0xf2, 0x3c, 0x54, 0x93, 0xcf, 0xd2,
 
795
                  0x41, 0xe4, 0x8f, 0x19, 0x7e, 0x1d, 0x10, 0x12 },
 
796
                { 0x0c, 0x9f, 0xb8, 0x16, 0x13, 0x88, 0x4c, 0x25,
 
797
                  0x35, 0xdd, 0x0e, 0xab, 0xf3, 0xb4, 0x40, 0xd8 },
 
798
                { 0x53, 0x80, 0xd1, 0x58, 0xcf, 0xe3 },
 
799
                { 0x87, 0xac, 0x3b, 0x55, 0x9f, 0xb6 }
 
800
        }, {
 
801
                /* 3GPP TS 35.208 v6.0.0 - 4.3.14 Test Set 14 */
 
802
                { 0xd3, 0x2d, 0xd2, 0x3e, 0x89, 0xdc, 0x66, 0x23,
 
803
                  0x54, 0xca, 0x12, 0xeb, 0x79, 0xdd, 0x32, 0xfa },
 
804
                { 0xcf, 0x7d, 0x0a, 0xb1, 0xd9, 0x43, 0x06, 0x95,
 
805
                  0x0b, 0xf1, 0x20, 0x18, 0xfb, 0xd4, 0x68, 0x87 },
 
806
                { 0x48, 0x41, 0x07, 0xe5, 0x6a, 0x43 },
 
807
                { 0xb5, 0xe6 },
 
808
                { 0xfe, 0x75, 0x90, 0x5b, 0x9d, 0xa4, 0x7d, 0x35,
 
809
                  0x62, 0x36, 0xd0, 0x31, 0x4e, 0x09, 0xc3, 0x2e },
 
810
                { 0xd2, 0x2a, 0x4b, 0x41, 0x80, 0xa5, 0x32, 0x57,
 
811
                  0x08, 0xa5, 0xff, 0x70, 0xd9, 0xf6, 0x7e, 0xc7 },
 
812
                { 0xcf, 0x19, 0xd6, 0x2b, 0x6a, 0x80, 0x98, 0x66 },
 
813
                { 0x5d, 0x26, 0x95, 0x37, 0xe4, 0x5e, 0x2c, 0xe6 },
 
814
                { 0xaf, 0x4a, 0x41, 0x1e, 0x11, 0x39, 0xf2, 0xc2 },
 
815
                { 0x5a, 0xf8, 0x6b, 0x80, 0xed, 0xb7, 0x0d, 0xf5,
 
816
                  0x29, 0x2c, 0xc1, 0x12, 0x1c, 0xba, 0xd5, 0x0c },
 
817
                { 0x7f, 0x4d, 0x6a, 0xe7, 0x44, 0x0e, 0x18, 0x78,
 
818
                  0x9a, 0x8b, 0x75, 0xad, 0x3f, 0x42, 0xf0, 0x3a },
 
819
                { 0x21, 0x7a, 0xf4, 0x92, 0x72, 0xad },
 
820
                { 0x90, 0x0e, 0x10, 0x1c, 0x67, 0x7e }
 
821
        }, {
 
822
                /* 3GPP TS 35.208 v6.0.0 - 4.3.15 Test Set 15 */
 
823
                { 0xaf, 0x7c, 0x65, 0xe1, 0x92, 0x72, 0x21, 0xde,
 
824
                  0x59, 0x11, 0x87, 0xa2, 0xc5, 0x98, 0x7a, 0x53 },
 
825
                { 0x1f, 0x0f, 0x85, 0x78, 0x46, 0x4f, 0xd5, 0x9b,
 
826
                  0x64, 0xbe, 0xd2, 0xd0, 0x94, 0x36, 0xb5, 0x7a },
 
827
                { 0x3d, 0x62, 0x7b, 0x01, 0x41, 0x8d },
 
828
                { 0x84, 0xf6 },
 
829
                { 0x0c, 0x7a, 0xcb, 0x8d, 0x95, 0xb7, 0xd4, 0xa3,
 
830
                  0x1c, 0x5a, 0xca, 0x6d, 0x26, 0x34, 0x5a, 0x88 },
 
831
                { 0xa4, 0xcf, 0x5c, 0x81, 0x55, 0xc0, 0x8a, 0x7e,
 
832
                  0xff, 0x41, 0x8e, 0x54, 0x43, 0xb9, 0x8e, 0x55 },
 
833
                { 0xc3, 0x7c, 0xae, 0x78, 0x05, 0x64, 0x20, 0x32 },
 
834
                { 0x68, 0xcd, 0x09, 0xa4, 0x52, 0xd8, 0xdb, 0x7c },
 
835
                { 0x7b, 0xff, 0xa5, 0xc2, 0xf4, 0x1f, 0xbc, 0x05 },
 
836
                { 0x3f, 0x8c, 0x3f, 0x3c, 0xcf, 0x76, 0x25, 0xbf,
 
837
                  0x77, 0xfc, 0x94, 0xbc, 0xfd, 0x22, 0xfd, 0x26 },
 
838
                { 0xab, 0xcb, 0xae, 0x8f, 0xd4, 0x61, 0x15, 0xe9,
 
839
                  0x96, 0x1a, 0x55, 0xd0, 0xda, 0x5f, 0x20, 0x78 },
 
840
                { 0x83, 0x7f, 0xd7, 0xb7, 0x44, 0x19 },
 
841
                { 0x56, 0xe9, 0x7a, 0x60, 0x90, 0xb1 }
 
842
        }, {
 
843
                /* 3GPP TS 35.208 v6.0.0 - 4.3.16 Test Set 16 */
 
844
                { 0x5b, 0xd7, 0xec, 0xd3, 0xd3, 0x12, 0x7a, 0x41,
 
845
                  0xd1, 0x25, 0x39, 0xbe, 0xd4, 0xe7, 0xcf, 0x71 },
 
846
                { 0x59, 0xb7, 0x5f, 0x14, 0x25, 0x1c, 0x75, 0x03,
 
847
                  0x1d, 0x0b, 0xcb, 0xac, 0x1c, 0x2c, 0x04, 0xc7 },
 
848
                { 0xa2, 0x98, 0xae, 0x89, 0x29, 0xdc },
 
849
                { 0xd0, 0x56 },
 
850
                { 0xf9, 0x67, 0xf7, 0x60, 0x38, 0xb9, 0x20, 0xa9,
 
851
                  0xcd, 0x25, 0xe1, 0x0c, 0x08, 0xb4, 0x99, 0x24 },
 
852
                { 0x76, 0x08, 0x9d, 0x3c, 0x0f, 0xf3, 0xef, 0xdc,
 
853
                  0x6e, 0x36, 0x72, 0x1d, 0x4f, 0xce, 0xb7, 0x47 },
 
854
                { 0xc3, 0xf2, 0x5c, 0xd9, 0x43, 0x09, 0x10, 0x7e },
 
855
                { 0xb0, 0xc8, 0xba, 0x34, 0x36, 0x65, 0xaf, 0xcc },
 
856
                { 0x7e, 0x3f, 0x44, 0xc7, 0x59, 0x1f, 0x6f, 0x45 },
 
857
                { 0xd4, 0x2b, 0x2d, 0x61, 0x5e, 0x49, 0xa0, 0x3a,
 
858
                  0xc2, 0x75, 0xa5, 0xae, 0xf9, 0x7a, 0xf8, 0x92 },
 
859
                { 0x0b, 0x3f, 0x8d, 0x02, 0x4f, 0xe6, 0xbf, 0xaf,
 
860
                  0xaa, 0x98, 0x2b, 0x8f, 0x82, 0xe3, 0x19, 0xc2 },
 
861
                { 0x5b, 0xe1, 0x14, 0x95, 0x52, 0x5d },
 
862
                { 0x4d, 0x6a, 0x34, 0xa1, 0xe4, 0xeb }
 
863
        }, {
 
864
                /* 3GPP TS 35.208 v6.0.0 - 4.3.17 Test Set 17 */
 
865
                { 0x6c, 0xd1, 0xc6, 0xce, 0xb1, 0xe0, 0x1e, 0x14,
 
866
                  0xf1, 0xb8, 0x23, 0x16, 0xa9, 0x0b, 0x7f, 0x3d },
 
867
                { 0xf6, 0x9b, 0x78, 0xf3, 0x00, 0xa0, 0x56, 0x8b,
 
868
                  0xce, 0x9f, 0x0c, 0xb9, 0x3c, 0x4b, 0xe4, 0xc9 },
 
869
                { 0xb4, 0xfc, 0xe5, 0xfe, 0xb0, 0x59 },
 
870
                { 0xe4, 0xbb },
 
871
                { 0x07, 0x8b, 0xfc, 0xa9, 0x56, 0x46, 0x59, 0xec,
 
872
                  0xd8, 0x85, 0x1e, 0x84, 0xe6, 0xc5, 0x9b, 0x48 },
 
873
                { 0xa2, 0x19, 0xdc, 0x37, 0xf1, 0xdc, 0x7d, 0x66,
 
874
                  0x73, 0x8b, 0x58, 0x43, 0xc7, 0x99, 0xf2, 0x06 },
 
875
                { 0x69, 0xa9, 0x08, 0x69, 0xc2, 0x68, 0xcb, 0x7b },
 
876
                { 0x2e, 0x0f, 0xdc, 0xf9, 0xfd, 0x1c, 0xfa, 0x6a },
 
877
                { 0x70, 0xf6, 0xbd, 0xb9, 0xad, 0x21, 0x52, 0x5f },
 
878
                { 0x6e, 0xda, 0xf9, 0x9e, 0x5b, 0xd9, 0xf8, 0x5d,
 
879
                  0x5f, 0x36, 0xd9, 0x1c, 0x12, 0x72, 0xfb, 0x4b },
 
880
                { 0xd6, 0x1c, 0x85, 0x3c, 0x28, 0x0d, 0xd9, 0xc4,
 
881
                  0x6f, 0x29, 0x7b, 0xae, 0xc3, 0x86, 0xde, 0x17 },
 
882
                { 0x1c, 0x40, 0x8a, 0x85, 0x8b, 0x3e },
 
883
                { 0xaa, 0x4a, 0xe5, 0x2d, 0xaa, 0x30 }
 
884
        }, {
 
885
                /* 3GPP TS 35.208 v6.0.0 - 4.3.18 Test Set 18 */
 
886
                { 0xb7, 0x3a, 0x90, 0xcb, 0xcf, 0x3a, 0xfb, 0x62,
 
887
                  0x2d, 0xba, 0x83, 0xc5, 0x8a, 0x84, 0x15, 0xdf },
 
888
                { 0xb1, 0x20, 0xf1, 0xc1, 0xa0, 0x10, 0x2a, 0x2f,
 
889
                  0x50, 0x7d, 0xd5, 0x43, 0xde, 0x68, 0x28, 0x1f },
 
890
                { 0xf1, 0xe8, 0xa5, 0x23, 0xa3, 0x6d },
 
891
                { 0x47, 0x1b },
 
892
                { 0xb6, 0x72, 0x04, 0x7e, 0x00, 0x3b, 0xb9, 0x52,
 
893
                  0xdc, 0xa6, 0xcb, 0x8a, 0xf0, 0xe5, 0xb7, 0x79 },
 
894
                { 0xdf, 0x0c, 0x67, 0x86, 0x8f, 0xa2, 0x5f, 0x74,
 
895
                  0x8b, 0x70, 0x44, 0xc6, 0xe7, 0xc2, 0x45, 0xb8 },
 
896
                { 0xeb, 0xd7, 0x03, 0x41, 0xbc, 0xd4, 0x15, 0xb0 },
 
897
                { 0x12, 0x35, 0x9f, 0x5d, 0x82, 0x22, 0x0c, 0x14 },
 
898
                { 0x47, 0x9d, 0xd2, 0x5c, 0x20, 0x79, 0x2d, 0x63 },
 
899
                { 0x66, 0x19, 0x5d, 0xbe, 0xd0, 0x31, 0x32, 0x74,
 
900
                  0xc5, 0xca, 0x77, 0x66, 0x61, 0x5f, 0xa2, 0x5e },
 
901
                { 0x66, 0xbe, 0xc7, 0x07, 0xeb, 0x2a, 0xfc, 0x47,
 
902
                  0x6d, 0x74, 0x08, 0xa8, 0xf2, 0x92, 0x7b, 0x36 },
 
903
                { 0xae, 0xfd, 0xaa, 0x5d, 0xdd, 0x99 },
 
904
                { 0x12, 0xec, 0x2b, 0x87, 0xfb, 0xb1 }
 
905
        }, {
 
906
                /* 3GPP TS 35.208 v6.0.0 - 4.3.19 Test Set 19 */
 
907
                { 0x51, 0x22, 0x25, 0x02, 0x14, 0xc3, 0x3e, 0x72,
 
908
                  0x3a, 0x5d, 0xd5, 0x23, 0xfc, 0x14, 0x5f, 0xc0 },
 
909
                { 0x81, 0xe9, 0x2b, 0x6c, 0x0e, 0xe0, 0xe1, 0x2e,
 
910
                  0xbc, 0xeb, 0xa8, 0xd9, 0x2a, 0x99, 0xdf, 0xa5 },
 
911
                { 0x16, 0xf3, 0xb3, 0xf7, 0x0f, 0xc2 },
 
912
                { 0xc3, 0xab },
 
913
                { 0xc9, 0xe8, 0x76, 0x32, 0x86, 0xb5, 0xb9, 0xff,
 
914
                  0xbd, 0xf5, 0x6e, 0x12, 0x97, 0xd0, 0x88, 0x7b },
 
915
                { 0x98, 0x1d, 0x46, 0x4c, 0x7c, 0x52, 0xeb, 0x6e,
 
916
                  0x50, 0x36, 0x23, 0x49, 0x84, 0xad, 0x0b, 0xcf },
 
917
                { 0x2a, 0x5c, 0x23, 0xd1, 0x5e, 0xe3, 0x51, 0xd5 },
 
918
                { 0x62, 0xda, 0xe3, 0x85, 0x3f, 0x3a, 0xf9, 0xd2 },
 
919
                { 0x28, 0xd7, 0xb0, 0xf2, 0xa2, 0xec, 0x3d, 0xe5 },
 
920
                { 0x53, 0x49, 0xfb, 0xe0, 0x98, 0x64, 0x9f, 0x94,
 
921
                  0x8f, 0x5d, 0x2e, 0x97, 0x3a, 0x81, 0xc0, 0x0f },
 
922
                { 0x97, 0x44, 0x87, 0x1a, 0xd3, 0x2b, 0xf9, 0xbb,
 
923
                  0xd1, 0xdd, 0x5c, 0xe5, 0x4e, 0x3e, 0x2e, 0x5a },
 
924
                { 0xad, 0xa1, 0x5a, 0xeb, 0x7b, 0xb8 },
 
925
                { 0xd4, 0x61, 0xbc, 0x15, 0x47, 0x5d }
 
926
        }, {
 
927
                /* 3GPP TS 35.208 v6.0.0 - 4.3.20 Test Set 20 */
 
928
                { 0x90, 0xdc, 0xa4, 0xed, 0xa4, 0x5b, 0x53, 0xcf,
 
929
                  0x0f, 0x12, 0xd7, 0xc9, 0xc3, 0xbc, 0x6a, 0x89 },
 
930
                { 0x9f, 0xdd, 0xc7, 0x20, 0x92, 0xc6, 0xad, 0x03,
 
931
                  0x6b, 0x6e, 0x46, 0x47, 0x89, 0x31, 0x5b, 0x78 },
 
932
                { 0x20, 0xf8, 0x13, 0xbd, 0x41, 0x41 },
 
933
                { 0x61, 0xdf },
 
934
                { 0x3f, 0xfc, 0xfe, 0x5b, 0x7b, 0x11, 0x11, 0x58,
 
935
                  0x99, 0x20, 0xd3, 0x52, 0x8e, 0x84, 0xe6, 0x55 },
 
936
                { 0xcb, 0x9c, 0xcc, 0xc4, 0xb9, 0x25, 0x8e, 0x6d,
 
937
                  0xca, 0x47, 0x60, 0x37, 0x9f, 0xb8, 0x25, 0x81 },
 
938
                { 0x09, 0xdb, 0x94, 0xea, 0xb4, 0xf8, 0x14, 0x9e },
 
939
                { 0xa2, 0x94, 0x68, 0xaa, 0x97, 0x75, 0xb5, 0x27 },
 
940
                { 0xa9, 0x51, 0x00, 0xe2, 0x76, 0x09, 0x52, 0xcd },
 
941
                { 0xb5, 0xf2, 0xda, 0x03, 0x88, 0x3b, 0x69, 0xf9,
 
942
                  0x6b, 0xf5, 0x2e, 0x02, 0x9e, 0xd9, 0xac, 0x45 },
 
943
                { 0xb4, 0x72, 0x13, 0x68, 0xbc, 0x16, 0xea, 0x67,
 
944
                  0x87, 0x5c, 0x55, 0x98, 0x68, 0x8b, 0xb0, 0xef },
 
945
                { 0x83, 0xcf, 0xd5, 0x4d, 0xb9, 0x13 },
 
946
                { 0x4f, 0x20, 0x39, 0x39, 0x2d, 0xdc }
 
947
        }
 
948
};
 
949
 
 
950
#define NUM_TESTS (sizeof(test_sets) / sizeof(test_sets[0]))
 
951
 
 
952
 
 
953
int main(int argc, char *argv[])
 
954
{
 
955
        u8 buf[16], buf2[16], buf3[16], buf4[16], buf5[16], opc[16];
 
956
        u8 auts[14], sqn[6], _rand[16];
 
957
        int ret = 0, res, i;
 
958
        const struct milenage_test_set *t;
 
959
        size_t res_len;
 
960
 
 
961
        wpa_debug_level = 0;
 
962
 
 
963
        printf("Milenage test sets\n");
 
964
        for (i = 0; i < NUM_TESTS; i++) {
 
965
                t = &test_sets[i];
 
966
                printf("Test Set %d\n", i + 1);
 
967
 
 
968
                milenage_opc(t->op, t->k, opc);
 
969
                if (memcmp(opc, t->opc, 16) != 0) {
 
970
                        printf("- milenage_opc failed\n");
 
971
                        ret++;
 
972
                }
 
973
 
 
974
                if (milenage_f1(opc, t->k, t->rand, t->sqn, t->amf, buf, buf2)
 
975
                    ||  memcmp(buf, t->f1, 8) != 0) {
 
976
                        printf("- milenage_f1 failed\n");
 
977
                        ret++;
 
978
                }
 
979
                if (memcmp(buf2, t->f1star, 8) != 0) {
 
980
                        printf("- milenage_f1* failed\n");
 
981
                        ret++;
 
982
                }
 
983
 
 
984
                if (milenage_f2345(opc, t->k, t->rand, buf, buf2, buf3, buf4,
 
985
                                   buf5) ||
 
986
                    memcmp(buf, t->f2, 8) != 0) {
 
987
                        printf("- milenage_f2 failed\n");
 
988
                        ret++;
 
989
                }
 
990
                if (memcmp(buf2, t->f3, 16) != 0) {
 
991
                        printf("- milenage_f3 failed\n");
 
992
                        ret++;
 
993
                }
 
994
                if (memcmp(buf3, t->f4, 16) != 0) {
 
995
                        printf("- milenage_f4 failed\n");
 
996
                        ret++;
 
997
                }
 
998
                if (memcmp(buf4, t->f5, 6) != 0) {
 
999
                        printf("- milenage_f5 failed\n");
 
1000
                        ret++;
 
1001
                }
 
1002
                if (memcmp(buf5, t->f5star, 6) != 0) {
 
1003
                        printf("- milenage_f5* failed\n");
 
1004
                        ret++;
 
1005
                }
 
1006
        }
 
1007
 
 
1008
        printf("milenage_auts test:\n");
 
1009
        memcpy(auts, "\x4f\x20\x39\x39\x2d\xdd", 6);
 
1010
        memcpy(auts + 6, "\x4b\xb4\x31\x6e\xd4\xa1\x46\x88", 8);
 
1011
        res = milenage_auts(t->opc, t->k, t->rand, auts, buf);
 
1012
        printf("AUTS for test set %d: %d / SQN=%02x%02x%02x%02x%02x%02x\n",
 
1013
               i, res, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
 
1014
        if (res)
 
1015
                ret++;
 
1016
 
 
1017
        memset(_rand, 0xaa, sizeof(_rand));
 
1018
        memcpy(auts,
 
1019
               "\x43\x68\x1a\xd3\xda\xf0\x06\xbc\xde\x40\x5a\x20\x72\x67", 14);
 
1020
        res = milenage_auts(t->opc, t->k, _rand, auts, buf);
 
1021
        printf("AUTS from a test USIM: %d / SQN=%02x%02x%02x%02x%02x%02x\n",
 
1022
               res, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
 
1023
        if (res)
 
1024
                ret++;
 
1025
 
 
1026
        printf("milenage_generate test:\n");
 
1027
        memcpy(sqn, "\x00\x00\x00\x00\x40\x44", 6);
 
1028
        memcpy(_rand, "\x12\x69\xb8\x23\x41\x39\x35\x66\xfb\x99\x41\xe9\x84"
 
1029
               "\x4f\xe6\x2f", 16);
 
1030
        res_len = 8;
 
1031
        milenage_generate(t->opc, t->amf, t->k, sqn, _rand, buf, buf2, buf3,
 
1032
                          buf4, &res_len);
 
1033
        wpa_hexdump(MSG_DEBUG, "SQN", sqn, 6);
 
1034
        wpa_hexdump(MSG_DEBUG, "RAND", _rand, 16);
 
1035
        wpa_hexdump(MSG_DEBUG, "AUTN", buf, 16);
 
1036
        wpa_hexdump(MSG_DEBUG, "IK", buf2, 16);
 
1037
        wpa_hexdump(MSG_DEBUG, "CK", buf3, 16);
 
1038
        wpa_hexdump(MSG_DEBUG, "RES", buf4, res_len);
 
1039
 
 
1040
        printf("GSM-Milenage test sets\n");
 
1041
        for (i = 0; i < NUM_GSM_TESTS; i++) {
 
1042
                const struct gsm_milenage_test_set *g;
 
1043
                u8 sres[4], kc[8];
 
1044
                g = &gsm_test_sets[i];
 
1045
                printf("Test Set %d\n", i + 1);
 
1046
                gsm_milenage(g->opc, g->ki, g->rand, sres, kc);
 
1047
                if (memcmp(g->kc, kc, 8) != 0) {
 
1048
                        printf("- gsm_milenage Kc failed\n");
 
1049
                        ret++;
 
1050
                }
 
1051
#ifdef GSM_MILENAGE_ALT_SRES
 
1052
                if (memcmp(g->sres2, sres, 4) != 0) {
 
1053
                        printf("- gsm_milenage SRES#2 failed\n");
 
1054
                        ret++;
 
1055
                }
 
1056
#else /* GSM_MILENAGE_ALT_SRES */
 
1057
                if (memcmp(g->sres1, sres, 4) != 0) {
 
1058
                        printf("- gsm_milenage SRES#1 failed\n");
 
1059
                        ret++;
 
1060
                }
 
1061
#endif /* GSM_MILENAGE_ALT_SRES */
 
1062
        }
 
1063
 
 
1064
        if (ret)
 
1065
                printf("Something failed\n");
 
1066
        else
 
1067
                printf("OK\n");
 
1068
 
 
1069
        return ret;
 
1070
}
 
1071
#endif /* TEST_MAIN_MILENAGE */