Home | History | Annotate | Download | only in hlr_auc_gw
      1 /*
      2  * 3GPP AKA - Milenage algorithm (3GPP TS 35.205, .206, .207, .208)
      3  * Copyright (c) 2006-2007 <j (at) 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 	os_memcpy(tmp2, sqn, 6);
     56 	os_memcpy(tmp2 + 6, amf, 2);
     57 	os_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 		os_memcpy(mac_a, tmp1, 8); /* f1 */
     76 	if (mac_s)
     77 		os_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 		os_memcpy(res, tmp3 + 8, 8); /* f2 */
    123 	if (ak)
    124 		os_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[8], 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 	os_memcpy(autn + 6, amf, 2);
    201 	os_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 	os_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 /**
    263  * milenage_generate - Generate AKA AUTN,IK,CK,RES
    264  * @opc: OPc = 128-bit operator variant algorithm configuration field (encr.)
    265  * @k: K = 128-bit subscriber key
    266  * @sqn: SQN = 48-bit sequence number
    267  * @_rand: RAND = 128-bit random challenge
    268  * @autn: AUTN = 128-bit authentication token
    269  * @ik: Buffer for IK = 128-bit integrity key (f4), or %NULL
    270  * @ck: Buffer for CK = 128-bit confidentiality key (f3), or %NULL
    271  * @res: Buffer for RES = 64-bit signed response (f2), or %NULL
    272  * @res_len: Variable that will be set to RES length
    273  * @auts: 112-bit buffer for AUTS
    274  * Returns: 0 on success, -1 on failure, or -2 on synchronization failure
    275  */
    276 int milenage_check(const u8 *opc, const u8 *k, const u8 *sqn, const u8 *_rand,
    277 		   const u8 *autn, u8 *ik, u8 *ck, u8 *res, size_t *res_len,
    278 		   u8 *auts)
    279 {
    280 	int i;
    281 	u8 mac_a[8], ak[6], rx_sqn[6];
    282 	const u8 *amf;
    283 
    284 	wpa_hexdump(MSG_DEBUG, "Milenage: AUTN", autn, 16);
    285 	wpa_hexdump(MSG_DEBUG, "Milenage: RAND", _rand, 16);
    286 
    287 	if (milenage_f2345(opc, k, _rand, res, ck, ik, ak, NULL))
    288 		return -1;
    289 
    290 	*res_len = 8;
    291 	wpa_hexdump_key(MSG_DEBUG, "Milenage: RES", res, *res_len);
    292 	wpa_hexdump_key(MSG_DEBUG, "Milenage: CK", ck, 16);
    293 	wpa_hexdump_key(MSG_DEBUG, "Milenage: IK", ik, 16);
    294 	wpa_hexdump_key(MSG_DEBUG, "Milenage: AK", ak, 6);
    295 
    296 	/* AUTN = (SQN ^ AK) || AMF || MAC */
    297 	for (i = 0; i < 6; i++)
    298 		rx_sqn[i] = autn[i] ^ ak[i];
    299 	wpa_hexdump(MSG_DEBUG, "Milenage: SQN", rx_sqn, 6);
    300 
    301 	if (os_memcmp(rx_sqn, sqn, 6) <= 0) {
    302 		u8 auts_amf[2] = { 0x00, 0x00 }; /* TS 33.102 v7.0.0, 6.3.3 */
    303 		if (milenage_f2345(opc, k, _rand, NULL, NULL, NULL, NULL, ak))
    304 			return -1;
    305 		wpa_hexdump_key(MSG_DEBUG, "Milenage: AK*", ak, 6);
    306 		for (i = 0; i < 6; i++)
    307 			auts[i] = sqn[i] ^ ak[i];
    308 		if (milenage_f1(opc, k, _rand, sqn, auts_amf, NULL, auts + 6))
    309 			return -1;
    310 		wpa_hexdump(MSG_DEBUG, "Milenage: AUTS", auts, 14);
    311 		return -2;
    312 	}
    313 
    314 	amf = autn + 6;
    315 	wpa_hexdump(MSG_DEBUG, "Milenage: AMF", amf, 2);
    316 	if (milenage_f1(opc, k, _rand, rx_sqn, amf, mac_a, NULL))
    317 		return -1;
    318 
    319 	wpa_hexdump(MSG_DEBUG, "Milenage: MAC_A", mac_a, 8);
    320 
    321 	if (os_memcmp(mac_a, autn + 8, 8) != 0) {
    322 		wpa_printf(MSG_DEBUG, "Milenage: MAC mismatch");
    323 		wpa_hexdump(MSG_DEBUG, "Milenage: Received MAC_A",
    324 			    autn + 8, 8);
    325 		return -1;
    326 	}
    327 
    328 	return 0;
    329 }
    330 
    331 
    332 #ifdef TEST_MAIN_MILENAGE
    333 
    334 extern int wpa_debug_level;
    335 
    336 
    337 /**
    338  * milenage_opc - Determine OPc from OP and K
    339  * @op: OP = 128-bit operator variant algorithm configuration field
    340  * @k: K = 128-bit subscriber key
    341  * @opc: Buffer for OPc = 128-bit value derived from OP and K
    342  */
    343 static void milenage_opc(const u8 *op, const u8 *k, u8 *opc)
    344 {
    345 	int i;
    346 	/* OP_C = OP XOR E_K(OP) */
    347 	aes_128_encrypt_block(k, op, opc);
    348 	for (i = 0; i < 16; i++)
    349 		opc[i] ^= op[i];
    350 }
    351 
    352 
    353 struct gsm_milenage_test_set {
    354 	u8 ki[16];
    355 	u8 rand[16];
    356 	u8 opc[16];
    357 	u8 sres1[4];
    358 	u8 sres2[4];
    359 	u8 kc[8];
    360 };
    361 
    362 static const struct gsm_milenage_test_set gsm_test_sets[] =
    363 {
    364 	{
    365 		/* 3GPP TS 55.205 v6.0.0 - Test Set 1 */
    366 		{ 0x46, 0x5b, 0x5c, 0xe8, 0xb1, 0x99, 0xb4, 0x9f,
    367 		  0xaa, 0x5f, 0x0a, 0x2e, 0xe2, 0x38, 0xa6, 0xbc },
    368 		{ 0x23, 0x55, 0x3c, 0xbe, 0x96, 0x37, 0xa8, 0x9d,
    369 		  0x21, 0x8a, 0xe6, 0x4d, 0xae, 0x47, 0xbf, 0x35 },
    370 		{ 0xcd, 0x63, 0xcb, 0x71, 0x95, 0x4a, 0x9f, 0x4e,
    371 		  0x48, 0xa5, 0x99, 0x4e, 0x37, 0xa0, 0x2b, 0xaf },
    372 		{ 0x46, 0xf8, 0x41, 0x6a },
    373 		{ 0xa5, 0x42, 0x11, 0xd5 },
    374 		{ 0xea, 0xe4, 0xbe, 0x82, 0x3a, 0xf9, 0xa0, 0x8b }
    375 	}, {
    376 		/* 3GPP TS 55.205 v6.0.0 - Test Set 2 */
    377 		{ 0xfe, 0xc8, 0x6b, 0xa6, 0xeb, 0x70, 0x7e, 0xd0,
    378 		  0x89, 0x05, 0x75, 0x7b, 0x1b, 0xb4, 0x4b, 0x8f },
    379 		{ 0x9f, 0x7c, 0x8d, 0x02, 0x1a, 0xcc, 0xf4, 0xdb,
    380 		  0x21, 0x3c, 0xcf, 0xf0, 0xc7, 0xf7, 0x1a, 0x6a },
    381 		{ 0x10, 0x06, 0x02, 0x0f, 0x0a, 0x47, 0x8b, 0xf6,
    382 		  0xb6, 0x99, 0xf1, 0x5c, 0x06, 0x2e, 0x42, 0xb3 },
    383 		{ 0x8c, 0x30, 0x8a, 0x5e },
    384 		{ 0x80, 0x11, 0xc4, 0x8c },
    385 		{ 0xaa, 0x01, 0x73, 0x9b, 0x8c, 0xaa, 0x97, 0x6d }
    386 	}, {
    387 		/* 3GPP TS 55.205 v6.0.0 - Test Set 3 */
    388 		{ 0x9e, 0x59, 0x44, 0xae, 0xa9, 0x4b, 0x81, 0x16,
    389 		  0x5c, 0x82, 0xfb, 0xf9, 0xf3, 0x2d, 0xb7, 0x51 },
    390 		{ 0xce, 0x83, 0xdb, 0xc5, 0x4a, 0xc0, 0x27, 0x4a,
    391 		  0x15, 0x7c, 0x17, 0xf8, 0x0d, 0x01, 0x7b, 0xd6 },
    392 		{ 0xa6, 0x4a, 0x50, 0x7a, 0xe1, 0xa2, 0xa9, 0x8b,
    393 		  0xb8, 0x8e, 0xb4, 0x21, 0x01, 0x35, 0xdc, 0x87 },
    394 		{ 0xcf, 0xbc, 0xe3, 0xfe },
    395 		{ 0xf3, 0x65, 0xcd, 0x68 },
    396 		{ 0x9a, 0x8e, 0xc9, 0x5f, 0x40, 0x8c, 0xc5, 0x07 }
    397 	}, {
    398 		/* 3GPP TS 55.205 v6.0.0 - Test Set 4 */
    399 		{ 0x4a, 0xb1, 0xde, 0xb0, 0x5c, 0xa6, 0xce, 0xb0,
    400 		  0x51, 0xfc, 0x98, 0xe7, 0x7d, 0x02, 0x6a, 0x84 },
    401 		{ 0x74, 0xb0, 0xcd, 0x60, 0x31, 0xa1, 0xc8, 0x33,
    402 		  0x9b, 0x2b, 0x6c, 0xe2, 0xb8, 0xc4, 0xa1, 0x86 },
    403 		{ 0xdc, 0xf0, 0x7c, 0xbd, 0x51, 0x85, 0x52, 0x90,
    404 		  0xb9, 0x2a, 0x07, 0xa9, 0x89, 0x1e, 0x52, 0x3e },
    405 		{ 0x96, 0x55, 0xe2, 0x65 },
    406 		{ 0x58, 0x60, 0xfc, 0x1b },
    407 		{ 0xcd, 0xc1, 0xdc, 0x08, 0x41, 0xb8, 0x1a, 0x22 }
    408 	}, {
    409 		/* 3GPP TS 55.205 v6.0.0 - Test Set 5 */
    410 		{ 0x6c, 0x38, 0xa1, 0x16, 0xac, 0x28, 0x0c, 0x45,
    411 		  0x4f, 0x59, 0x33, 0x2e, 0xe3, 0x5c, 0x8c, 0x4f },
    412 		{ 0xee, 0x64, 0x66, 0xbc, 0x96, 0x20, 0x2c, 0x5a,
    413 		  0x55, 0x7a, 0xbb, 0xef, 0xf8, 0xba, 0xbf, 0x63 },
    414 		{ 0x38, 0x03, 0xef, 0x53, 0x63, 0xb9, 0x47, 0xc6,
    415 		  0xaa, 0xa2, 0x25, 0xe5, 0x8f, 0xae, 0x39, 0x34 },
    416 		{ 0x13, 0x68, 0x8f, 0x17 },
    417 		{ 0x16, 0xc8, 0x23, 0x3f },
    418 		{ 0xdf, 0x75, 0xbc, 0x5e, 0xa8, 0x99, 0x87, 0x9f }
    419 	}, {
    420 		/* 3GPP TS 55.205 v6.0.0 - Test Set 6 */
    421 		{ 0x2d, 0x60, 0x9d, 0x4d, 0xb0, 0xac, 0x5b, 0xf0,
    422 		  0xd2, 0xc0, 0xde, 0x26, 0x70, 0x14, 0xde, 0x0d },
    423 		{ 0x19, 0x4a, 0xa7, 0x56, 0x01, 0x38, 0x96, 0xb7,
    424 		  0x4b, 0x4a, 0x2a, 0x3b, 0x0a, 0xf4, 0x53, 0x9e },
    425 		{ 0xc3, 0x5a, 0x0a, 0xb0, 0xbc, 0xbf, 0xc9, 0x25,
    426 		  0x2c, 0xaf, 0xf1, 0x5f, 0x24, 0xef, 0xbd, 0xe0 },
    427 		{ 0x55, 0x3d, 0x00, 0xb3 },
    428 		{ 0x8c, 0x25, 0xa1, 0x6c },
    429 		{ 0x84, 0xb4, 0x17, 0xae, 0x3a, 0xea, 0xb4, 0xf3 }
    430 	}, {
    431 		/* 3GPP TS 55.205 v6.0.0 - Test Set 7 */
    432 		{ 0xa5, 0x30, 0xa7, 0xfe, 0x42, 0x8f, 0xad, 0x10,
    433 		  0x82, 0xc4, 0x5e, 0xdd, 0xfc, 0xe1, 0x38, 0x84 },
    434 		{ 0x3a, 0x4c, 0x2b, 0x32, 0x45, 0xc5, 0x0e, 0xb5,
    435 		  0xc7, 0x1d, 0x08, 0x63, 0x93, 0x95, 0x76, 0x4d },
    436 		{ 0x27, 0x95, 0x3e, 0x49, 0xbc, 0x8a, 0xf6, 0xdc,
    437 		  0xc6, 0xe7, 0x30, 0xeb, 0x80, 0x28, 0x6b, 0xe3 },
    438 		{ 0x59, 0xf1, 0xa4, 0x4a },
    439 		{ 0xa6, 0x32, 0x41, 0xe1 },
    440 		{ 0x3b, 0x4e, 0x24, 0x4c, 0xdc, 0x60, 0xce, 0x03 }
    441 	}, {
    442 		/* 3GPP TS 55.205 v6.0.0 - Test Set 8 */
    443 		{ 0xd9, 0x15, 0x1c, 0xf0, 0x48, 0x96, 0xe2, 0x58,
    444 		  0x30, 0xbf, 0x2e, 0x08, 0x26, 0x7b, 0x83, 0x60 },
    445 		{ 0xf7, 0x61, 0xe5, 0xe9, 0x3d, 0x60, 0x3f, 0xeb,
    446 		  0x73, 0x0e, 0x27, 0x55, 0x6c, 0xb8, 0xa2, 0xca },
    447 		{ 0xc4, 0xc9, 0x3e, 0xff, 0xe8, 0xa0, 0x81, 0x38,
    448 		  0xc2, 0x03, 0xd4, 0xc2, 0x7c, 0xe4, 0xe3, 0xd9 },
    449 		{ 0x50, 0x58, 0x88, 0x61 },
    450 		{ 0x4a, 0x90, 0xb2, 0x17 },
    451 		{ 0x8d, 0x4e, 0xc0, 0x1d, 0xe5, 0x97, 0xac, 0xfe }
    452 	}, {
    453 		/* 3GPP TS 55.205 v6.0.0 - Test Set 9 */
    454 		{ 0xa0, 0xe2, 0x97, 0x1b, 0x68, 0x22, 0xe8, 0xd3,
    455 		  0x54, 0xa1, 0x8c, 0xc2, 0x35, 0x62, 0x4e, 0xcb },
    456 		{ 0x08, 0xef, 0xf8, 0x28, 0xb1, 0x3f, 0xdb, 0x56,
    457 		  0x27, 0x22, 0xc6, 0x5c, 0x7f, 0x30, 0xa9, 0xb2 },
    458 		{ 0x82, 0xa2, 0x6f, 0x22, 0xbb, 0xa9, 0xe9, 0x48,
    459 		  0x8f, 0x94, 0x9a, 0x10, 0xd9, 0x8e, 0x9c, 0xc4 },
    460 		{ 0xcd, 0xe6, 0xb0, 0x27 },
    461 		{ 0x4b, 0xc2, 0x21, 0x2d },
    462 		{ 0xd8, 0xde, 0xbc, 0x4f, 0xfb, 0xcd, 0x60, 0xaa }
    463 	}, {
    464 		/* 3GPP TS 55.205 v6.0.0 - Test Set 10 */
    465 		{ 0x0d, 0xa6, 0xf7, 0xba, 0x86, 0xd5, 0xea, 0xc8,
    466 		  0xa1, 0x9c, 0xf5, 0x63, 0xac, 0x58, 0x64, 0x2d },
    467 		{ 0x67, 0x9a, 0xc4, 0xdb, 0xac, 0xd7, 0xd2, 0x33,
    468 		  0xff, 0x9d, 0x68, 0x06, 0xf4, 0x14, 0x9c, 0xe3 },
    469 		{ 0x0d, 0xb1, 0x07, 0x1f, 0x87, 0x67, 0x56, 0x2c,
    470 		  0xa4, 0x3a, 0x0a, 0x64, 0xc4, 0x1e, 0x8d, 0x08 },
    471 		{ 0x02, 0xd1, 0x3a, 0xcd },
    472 		{ 0x6f, 0xc3, 0x0f, 0xee },
    473 		{ 0xf0, 0xea, 0xa5, 0x0a, 0x1e, 0xdc, 0xeb, 0xb7 }
    474 	}, {
    475 		/* 3GPP TS 55.205 v6.0.0 - Test Set 11 */
    476 		{ 0x77, 0xb4, 0x58, 0x43, 0xc8, 0x8e, 0x58, 0xc1,
    477 		  0x0d, 0x20, 0x26, 0x84, 0x51, 0x5e, 0xd4, 0x30 },
    478 		{ 0x4c, 0x47, 0xeb, 0x30, 0x76, 0xdc, 0x55, 0xfe,
    479 		  0x51, 0x06, 0xcb, 0x20, 0x34, 0xb8, 0xcd, 0x78 },
    480 		{ 0xd4, 0x83, 0xaf, 0xae, 0x56, 0x24, 0x09, 0xa3,
    481 		  0x26, 0xb5, 0xbb, 0x0b, 0x20, 0xc4, 0xd7, 0x62 },
    482 		{ 0x44, 0x38, 0x9d, 0x01 },
    483 		{ 0xae, 0xfa, 0x35, 0x7b },
    484 		{ 0x82, 0xdb, 0xab, 0x7f, 0x83, 0xf0, 0x63, 0xda }
    485 	}, {
    486 		/* 3GPP TS 55.205 v6.0.0 - Test Set 12 */
    487 		{ 0x72, 0x9b, 0x17, 0x72, 0x92, 0x70, 0xdd, 0x87,
    488 		  0xcc, 0xdf, 0x1b, 0xfe, 0x29, 0xb4, 0xe9, 0xbb },
    489 		{ 0x31, 0x1c, 0x4c, 0x92, 0x97, 0x44, 0xd6, 0x75,
    490 		  0xb7, 0x20, 0xf3, 0xb7, 0xe9, 0xb1, 0xcb, 0xd0 },
    491 		{ 0x22, 0x8c, 0x2f, 0x2f, 0x06, 0xac, 0x32, 0x68,
    492 		  0xa9, 0xe6, 0x16, 0xee, 0x16, 0xdb, 0x4b, 0xa1 },
    493 		{ 0x03, 0xe0, 0xfd, 0x84 },
    494 		{ 0x98, 0xdb, 0xbd, 0x09 },
    495 		{ 0x3c, 0x66, 0xcb, 0x98, 0xca, 0xb2, 0xd3, 0x3d }
    496 	}, {
    497 		/* 3GPP TS 55.205 v6.0.0 - Test Set 13 */
    498 		{ 0xd3, 0x2d, 0xd2, 0x3e, 0x89, 0xdc, 0x66, 0x23,
    499 		  0x54, 0xca, 0x12, 0xeb, 0x79, 0xdd, 0x32, 0xfa },
    500 		{ 0xcf, 0x7d, 0x0a, 0xb1, 0xd9, 0x43, 0x06, 0x95,
    501 		  0x0b, 0xf1, 0x20, 0x18, 0xfb, 0xd4, 0x68, 0x87 },
    502 		{ 0xd2, 0x2a, 0x4b, 0x41, 0x80, 0xa5, 0x32, 0x57,
    503 		  0x08, 0xa5, 0xff, 0x70, 0xd9, 0xf6, 0x7e, 0xc7 },
    504 		{ 0xbe, 0x73, 0xb3, 0xdc },
    505 		{ 0xaf, 0x4a, 0x41, 0x1e },
    506 		{ 0x96, 0x12, 0xb5, 0xd8, 0x8a, 0x41, 0x30, 0xbb }
    507 	}, {
    508 		/* 3GPP TS 55.205 v6.0.0 - Test Set 14 */
    509 		{ 0xaf, 0x7c, 0x65, 0xe1, 0x92, 0x72, 0x21, 0xde,
    510 		  0x59, 0x11, 0x87, 0xa2, 0xc5, 0x98, 0x7a, 0x53 },
    511 		{ 0x1f, 0x0f, 0x85, 0x78, 0x46, 0x4f, 0xd5, 0x9b,
    512 		  0x64, 0xbe, 0xd2, 0xd0, 0x94, 0x36, 0xb5, 0x7a },
    513 		{ 0xa4, 0xcf, 0x5c, 0x81, 0x55, 0xc0, 0x8a, 0x7e,
    514 		  0xff, 0x41, 0x8e, 0x54, 0x43, 0xb9, 0x8e, 0x55 },
    515 		{ 0x8f, 0xe0, 0x19, 0xc7 },
    516 		{ 0x7b, 0xff, 0xa5, 0xc2 },
    517 		{ 0x75, 0xa1, 0x50, 0xdf, 0x3c, 0x6a, 0xed, 0x08 }
    518 	}, {
    519 		/* 3GPP TS 55.205 v6.0.0 - Test Set 15 */
    520 		{ 0x5b, 0xd7, 0xec, 0xd3, 0xd3, 0x12, 0x7a, 0x41,
    521 		  0xd1, 0x25, 0x39, 0xbe, 0xd4, 0xe7, 0xcf, 0x71 },
    522 		{ 0x59, 0xb7, 0x5f, 0x14, 0x25, 0x1c, 0x75, 0x03,
    523 		  0x1d, 0x0b, 0xcb, 0xac, 0x1c, 0x2c, 0x04, 0xc7 },
    524 		{ 0x76, 0x08, 0x9d, 0x3c, 0x0f, 0xf3, 0xef, 0xdc,
    525 		  0x6e, 0x36, 0x72, 0x1d, 0x4f, 0xce, 0xb7, 0x47 },
    526 		{ 0x27, 0x20, 0x2b, 0x82 },
    527 		{ 0x7e, 0x3f, 0x44, 0xc7 },
    528 		{ 0xb7, 0xf9, 0x2e, 0x42, 0x6a, 0x36, 0xfe, 0xc5 }
    529 	}, {
    530 		/* 3GPP TS 55.205 v6.0.0 - Test Set 16 */
    531 		{ 0x6c, 0xd1, 0xc6, 0xce, 0xb1, 0xe0, 0x1e, 0x14,
    532 		  0xf1, 0xb8, 0x23, 0x16, 0xa9, 0x0b, 0x7f, 0x3d },
    533 		{ 0xf6, 0x9b, 0x78, 0xf3, 0x00, 0xa0, 0x56, 0x8b,
    534 		  0xce, 0x9f, 0x0c, 0xb9, 0x3c, 0x4b, 0xe4, 0xc9 },
    535 		{ 0xa2, 0x19, 0xdc, 0x37, 0xf1, 0xdc, 0x7d, 0x66,
    536 		  0x73, 0x8b, 0x58, 0x43, 0xc7, 0x99, 0xf2, 0x06 },
    537 		{ 0xdd, 0xd7, 0xef, 0xe6 },
    538 		{ 0x70, 0xf6, 0xbd, 0xb9 },
    539 		{ 0x88, 0xd9, 0xde, 0x10, 0xa2, 0x20, 0x04, 0xc5 }
    540 	}, {
    541 		/* 3GPP TS 55.205 v6.0.0 - Test Set 17 */
    542 		{ 0xb7, 0x3a, 0x90, 0xcb, 0xcf, 0x3a, 0xfb, 0x62,
    543 		  0x2d, 0xba, 0x83, 0xc5, 0x8a, 0x84, 0x15, 0xdf },
    544 		{ 0xb1, 0x20, 0xf1, 0xc1, 0xa0, 0x10, 0x2a, 0x2f,
    545 		  0x50, 0x7d, 0xd5, 0x43, 0xde, 0x68, 0x28, 0x1f },
    546 		{ 0xdf, 0x0c, 0x67, 0x86, 0x8f, 0xa2, 0x5f, 0x74,
    547 		  0x8b, 0x70, 0x44, 0xc6, 0xe7, 0xc2, 0x45, 0xb8 },
    548 		{ 0x67, 0xe4, 0xff, 0x3f },
    549 		{ 0x47, 0x9d, 0xd2, 0x5c },
    550 		{ 0xa8, 0x19, 0xe5, 0x77, 0xa8, 0xd6, 0x17, 0x5b }
    551 	}, {
    552 		/* 3GPP TS 55.205 v6.0.0 - Test Set 18 */
    553 		{ 0x51, 0x22, 0x25, 0x02, 0x14, 0xc3, 0x3e, 0x72,
    554 		  0x3a, 0x5d, 0xd5, 0x23, 0xfc, 0x14, 0x5f, 0xc0 },
    555 		{ 0x81, 0xe9, 0x2b, 0x6c, 0x0e, 0xe0, 0xe1, 0x2e,
    556 		  0xbc, 0xeb, 0xa8, 0xd9, 0x2a, 0x99, 0xdf, 0xa5 },
    557 		{ 0x98, 0x1d, 0x46, 0x4c, 0x7c, 0x52, 0xeb, 0x6e,
    558 		  0x50, 0x36, 0x23, 0x49, 0x84, 0xad, 0x0b, 0xcf },
    559 		{ 0x8a, 0x3b, 0x8d, 0x17 },
    560 		{ 0x28, 0xd7, 0xb0, 0xf2 },
    561 		{ 0x9a, 0x8d, 0x0e, 0x88, 0x3f, 0xf0, 0x88, 0x7a }
    562 	}, {
    563 		/* 3GPP TS 55.205 v6.0.0 - Test Set 19 */
    564 		{ 0x90, 0xdc, 0xa4, 0xed, 0xa4, 0x5b, 0x53, 0xcf,
    565 		  0x0f, 0x12, 0xd7, 0xc9, 0xc3, 0xbc, 0x6a, 0x89 },
    566 		{ 0x9f, 0xdd, 0xc7, 0x20, 0x92, 0xc6, 0xad, 0x03,
    567 		  0x6b, 0x6e, 0x46, 0x47, 0x89, 0x31, 0x5b, 0x78 },
    568 		{ 0xcb, 0x9c, 0xcc, 0xc4, 0xb9, 0x25, 0x8e, 0x6d,
    569 		  0xca, 0x47, 0x60, 0x37, 0x9f, 0xb8, 0x25, 0x81 },
    570 		{ 0xdf, 0x58, 0x52, 0x2f },
    571 		{ 0xa9, 0x51, 0x00, 0xe2 },
    572 		{ 0xed, 0x29, 0xb2, 0xf1, 0xc2, 0x7f, 0x9f, 0x34 }
    573 	}
    574 };
    575 
    576 #define NUM_GSM_TESTS (sizeof(gsm_test_sets) / sizeof(gsm_test_sets[0]))
    577 
    578 
    579 struct milenage_test_set {
    580 	u8 k[16];
    581 	u8 rand[16];
    582 	u8 sqn[6];
    583 	u8 amf[2];
    584 	u8 op[16];
    585 	u8 opc[16];
    586 	u8 f1[8];
    587 	u8 f1star[8];
    588 	u8 f2[8];
    589 	u8 f3[16];
    590 	u8 f4[16];
    591 	u8 f5[6];
    592 	u8 f5star[6];
    593 };
    594 
    595 static const struct milenage_test_set test_sets[] =
    596 {
    597 	{
    598 		/* 3GPP TS 35.208 v6.0.0 - 4.3.1 Test Set 1 */
    599 		{ 0x46, 0x5b, 0x5c, 0xe8, 0xb1, 0x99, 0xb4, 0x9f,
    600 		  0xaa, 0x5f, 0x0a, 0x2e, 0xe2, 0x38, 0xa6, 0xbc },
    601 		{ 0x23, 0x55, 0x3c, 0xbe, 0x96, 0x37, 0xa8, 0x9d,
    602 		  0x21, 0x8a, 0xe6, 0x4d, 0xae, 0x47, 0xbf, 0x35 },
    603 		{ 0xff, 0x9b, 0xb4, 0xd0, 0xb6, 0x07 },
    604 		{ 0xb9, 0xb9 },
    605 		{ 0xcd, 0xc2, 0x02, 0xd5, 0x12, 0x3e, 0x20, 0xf6,
    606 		  0x2b, 0x6d, 0x67, 0x6a, 0xc7, 0x2c, 0xb3, 0x18 },
    607 		{ 0xcd, 0x63, 0xcb, 0x71, 0x95, 0x4a, 0x9f, 0x4e,
    608 		  0x48, 0xa5, 0x99, 0x4e, 0x37, 0xa0, 0x2b, 0xaf },
    609 		{ 0x4a, 0x9f, 0xfa, 0xc3, 0x54, 0xdf, 0xaf, 0xb3 },
    610 		{ 0x01, 0xcf, 0xaf, 0x9e, 0xc4, 0xe8, 0x71, 0xe9 },
    611 		{ 0xa5, 0x42, 0x11, 0xd5, 0xe3, 0xba, 0x50, 0xbf },
    612 		{ 0xb4, 0x0b, 0xa9, 0xa3, 0xc5, 0x8b, 0x2a, 0x05,
    613 		  0xbb, 0xf0, 0xd9, 0x87, 0xb2, 0x1b, 0xf8, 0xcb },
    614 		{ 0xf7, 0x69, 0xbc, 0xd7, 0x51, 0x04, 0x46, 0x04,
    615 		  0x12, 0x76, 0x72, 0x71, 0x1c, 0x6d, 0x34, 0x41 },
    616 		{ 0xaa, 0x68, 0x9c, 0x64, 0x83, 0x70 },
    617 		{ 0x45, 0x1e, 0x8b, 0xec, 0xa4, 0x3b }
    618 	}, {
    619 		/* 3GPP TS 35.208 v6.0.0 - 4.3.2 Test Set 2 */
    620 		{ 0x46, 0x5b, 0x5c, 0xe8, 0xb1, 0x99, 0xb4, 0x9f,
    621 		  0xaa, 0x5f, 0x0a, 0x2e, 0xe2, 0x38, 0xa6, 0xbc },
    622 		{ 0x23, 0x55, 0x3c, 0xbe, 0x96, 0x37, 0xa8, 0x9d,
    623 		  0x21, 0x8a, 0xe6, 0x4d, 0xae, 0x47, 0xbf, 0x35 },
    624 		{ 0xff, 0x9b, 0xb4, 0xd0, 0xb6, 0x07 },
    625 		{ 0xb9, 0xb9 },
    626 		{ 0xcd, 0xc2, 0x02, 0xd5, 0x12, 0x3e, 0x20, 0xf6,
    627 		  0x2b, 0x6d, 0x67, 0x6a, 0xc7, 0x2c, 0xb3, 0x18 },
    628 		{ 0xcd, 0x63, 0xcb, 0x71, 0x95, 0x4a, 0x9f, 0x4e,
    629 		  0x48, 0xa5, 0x99, 0x4e, 0x37, 0xa0, 0x2b, 0xaf },
    630 		{ 0x4a, 0x9f, 0xfa, 0xc3, 0x54, 0xdf, 0xaf, 0xb3 },
    631 		{ 0x01, 0xcf, 0xaf, 0x9e, 0xc4, 0xe8, 0x71, 0xe9 },
    632 		{ 0xa5, 0x42, 0x11, 0xd5, 0xe3, 0xba, 0x50, 0xbf },
    633 		{ 0xb4, 0x0b, 0xa9, 0xa3, 0xc5, 0x8b, 0x2a, 0x05,
    634 		  0xbb, 0xf0, 0xd9, 0x87, 0xb2, 0x1b, 0xf8, 0xcb },
    635 		{ 0xf7, 0x69, 0xbc, 0xd7, 0x51, 0x04, 0x46, 0x04,
    636 		  0x12, 0x76, 0x72, 0x71, 0x1c, 0x6d, 0x34, 0x41 },
    637 		{ 0xaa, 0x68, 0x9c, 0x64, 0x83, 0x70 },
    638 		{ 0x45, 0x1e, 0x8b, 0xec, 0xa4, 0x3b }
    639 	}, {
    640 		/* 3GPP TS 35.208 v6.0.0 - 4.3.3 Test Set 3 */
    641 		{ 0xfe, 0xc8, 0x6b, 0xa6, 0xeb, 0x70, 0x7e, 0xd0,
    642 		  0x89, 0x05, 0x75, 0x7b, 0x1b, 0xb4, 0x4b, 0x8f },
    643 		{ 0x9f, 0x7c, 0x8d, 0x02, 0x1a, 0xcc, 0xf4, 0xdb,
    644 		  0x21, 0x3c, 0xcf, 0xf0, 0xc7, 0xf7, 0x1a, 0x6a },
    645 		{ 0x9d, 0x02, 0x77, 0x59, 0x5f, 0xfc },
    646 		{ 0x72, 0x5c },
    647 		{ 0xdb, 0xc5, 0x9a, 0xdc, 0xb6, 0xf9, 0xa0, 0xef,
    648 		  0x73, 0x54, 0x77, 0xb7, 0xfa, 0xdf, 0x83, 0x74 },
    649 		{ 0x10, 0x06, 0x02, 0x0f, 0x0a, 0x47, 0x8b, 0xf6,
    650 		  0xb6, 0x99, 0xf1, 0x5c, 0x06, 0x2e, 0x42, 0xb3 },
    651 		{ 0x9c, 0xab, 0xc3, 0xe9, 0x9b, 0xaf, 0x72, 0x81 },
    652 		{ 0x95, 0x81, 0x4b, 0xa2, 0xb3, 0x04, 0x43, 0x24 },
    653 		{ 0x80, 0x11, 0xc4, 0x8c, 0x0c, 0x21, 0x4e, 0xd2 },
    654 		{ 0x5d, 0xbd, 0xbb, 0x29, 0x54, 0xe8, 0xf3, 0xcd,
    655 		  0xe6, 0x65, 0xb0, 0x46, 0x17, 0x9a, 0x50, 0x98 },
    656 		{ 0x59, 0xa9, 0x2d, 0x3b, 0x47, 0x6a, 0x04, 0x43,
    657 		  0x48, 0x70, 0x55, 0xcf, 0x88, 0xb2, 0x30, 0x7b },
    658 		{ 0x33, 0x48, 0x4d, 0xc2, 0x13, 0x6b },
    659 		{ 0xde, 0xac, 0xdd, 0x84, 0x8c, 0xc6 }
    660 	}, {
    661 		/* 3GPP TS 35.208 v6.0.0 - 4.3.4 Test Set 4 */
    662 		{ 0x9e, 0x59, 0x44, 0xae, 0xa9, 0x4b, 0x81, 0x16,
    663 		  0x5c, 0x82, 0xfb, 0xf9, 0xf3, 0x2d, 0xb7, 0x51 },
    664 		{ 0xce, 0x83, 0xdb, 0xc5, 0x4a, 0xc0, 0x27, 0x4a,
    665 		  0x15, 0x7c, 0x17, 0xf8, 0x0d, 0x01, 0x7b, 0xd6 },
    666 		{ 0x0b, 0x60, 0x4a, 0x81, 0xec, 0xa8 },
    667 		{ 0x9e, 0x09 },
    668 		{ 0x22, 0x30, 0x14, 0xc5, 0x80, 0x66, 0x94, 0xc0,
    669 		  0x07, 0xca, 0x1e, 0xee, 0xf5, 0x7f, 0x00, 0x4f },
    670 		{ 0xa6, 0x4a, 0x50, 0x7a, 0xe1, 0xa2, 0xa9, 0x8b,
    671 		  0xb8, 0x8e, 0xb4, 0x21, 0x01, 0x35, 0xdc, 0x87 },
    672 		{ 0x74, 0xa5, 0x82, 0x20, 0xcb, 0xa8, 0x4c, 0x49 },
    673 		{ 0xac, 0x2c, 0xc7, 0x4a, 0x96, 0x87, 0x18, 0x37 },
    674 		{ 0xf3, 0x65, 0xcd, 0x68, 0x3c, 0xd9, 0x2e, 0x96 },
    675 		{ 0xe2, 0x03, 0xed, 0xb3, 0x97, 0x15, 0x74, 0xf5,
    676 		  0xa9, 0x4b, 0x0d, 0x61, 0xb8, 0x16, 0x34, 0x5d },
    677 		{ 0x0c, 0x45, 0x24, 0xad, 0xea, 0xc0, 0x41, 0xc4,
    678 		  0xdd, 0x83, 0x0d, 0x20, 0x85, 0x4f, 0xc4, 0x6b },
    679 		{ 0xf0, 0xb9, 0xc0, 0x8a, 0xd0, 0x2e },
    680 		{ 0x60, 0x85, 0xa8, 0x6c, 0x6f, 0x63 }
    681 	}, {
    682 		/* 3GPP TS 35.208 v6.0.0 - 4.3.5 Test Set 5 */
    683 		{ 0x4a, 0xb1, 0xde, 0xb0, 0x5c, 0xa6, 0xce, 0xb0,
    684 		  0x51, 0xfc, 0x98, 0xe7, 0x7d, 0x02, 0x6a, 0x84 },
    685 		{ 0x74, 0xb0, 0xcd, 0x60, 0x31, 0xa1, 0xc8, 0x33,
    686 		  0x9b, 0x2b, 0x6c, 0xe2, 0xb8, 0xc4, 0xa1, 0x86 },
    687 		{ 0xe8, 0x80, 0xa1, 0xb5, 0x80, 0xb6 },
    688 		{ 0x9f, 0x07 },
    689 		{ 0x2d, 0x16, 0xc5, 0xcd, 0x1f, 0xdf, 0x6b, 0x22,
    690 		  0x38, 0x35, 0x84, 0xe3, 0xbe, 0xf2, 0xa8, 0xd8 },
    691 		{ 0xdc, 0xf0, 0x7c, 0xbd, 0x51, 0x85, 0x52, 0x90,
    692 		  0xb9, 0x2a, 0x07, 0xa9, 0x89, 0x1e, 0x52, 0x3e },
    693 		{ 0x49, 0xe7, 0x85, 0xdd, 0x12, 0x62, 0x6e, 0xf2 },
    694 		{ 0x9e, 0x85, 0x79, 0x03, 0x36, 0xbb, 0x3f, 0xa2 },
    695 		{ 0x58, 0x60, 0xfc, 0x1b, 0xce, 0x35, 0x1e, 0x7e },
    696 		{ 0x76, 0x57, 0x76, 0x6b, 0x37, 0x3d, 0x1c, 0x21,
    697 		  0x38, 0xf3, 0x07, 0xe3, 0xde, 0x92, 0x42, 0xf9 },
    698 		{ 0x1c, 0x42, 0xe9, 0x60, 0xd8, 0x9b, 0x8f, 0xa9,
    699 		  0x9f, 0x27, 0x44, 0xe0, 0x70, 0x8c, 0xcb, 0x53 },
    700 		{ 0x31, 0xe1, 0x1a, 0x60, 0x91, 0x18 },
    701 		{ 0xfe, 0x25, 0x55, 0xe5, 0x4a, 0xa9 }
    702 	}, {
    703 		/* 3GPP TS 35.208 v6.0.0 - 4.3.6 Test Set 6 */
    704 		{ 0x6c, 0x38, 0xa1, 0x16, 0xac, 0x28, 0x0c, 0x45,
    705 		  0x4f, 0x59, 0x33, 0x2e, 0xe3, 0x5c, 0x8c, 0x4f },
    706 		{ 0xee, 0x64, 0x66, 0xbc, 0x96, 0x20, 0x2c, 0x5a,
    707 		  0x55, 0x7a, 0xbb, 0xef, 0xf8, 0xba, 0xbf, 0x63 },
    708 		{ 0x41, 0x4b, 0x98, 0x22, 0x21, 0x81 },
    709 		{ 0x44, 0x64 },
    710 		{ 0x1b, 0xa0, 0x0a, 0x1a, 0x7c, 0x67, 0x00, 0xac,
    711 		  0x8c, 0x3f, 0xf3, 0xe9, 0x6a, 0xd0, 0x87, 0x25 },
    712 		{ 0x38, 0x03, 0xef, 0x53, 0x63, 0xb9, 0x47, 0xc6,
    713 		  0xaa, 0xa2, 0x25, 0xe5, 0x8f, 0xae, 0x39, 0x34 },
    714 		{ 0x07, 0x8a, 0xdf, 0xb4, 0x88, 0x24, 0x1a, 0x57 },
    715 		{ 0x80, 0x24, 0x6b, 0x8d, 0x01, 0x86, 0xbc, 0xf1 },
    716 		{ 0x16, 0xc8, 0x23, 0x3f, 0x05, 0xa0, 0xac, 0x28 },
    717 		{ 0x3f, 0x8c, 0x75, 0x87, 0xfe, 0x8e, 0x4b, 0x23,
    718 		  0x3a, 0xf6, 0x76, 0xae, 0xde, 0x30, 0xba, 0x3b },
    719 		{ 0xa7, 0x46, 0x6c, 0xc1, 0xe6, 0xb2, 0xa1, 0x33,
    720 		  0x7d, 0x49, 0xd3, 0xb6, 0x6e, 0x95, 0xd7, 0xb4 },
    721 		{ 0x45, 0xb0, 0xf6, 0x9a, 0xb0, 0x6c },
    722 		{ 0x1f, 0x53, 0xcd, 0x2b, 0x11, 0x13 }
    723 	}, {
    724 		/* 3GPP TS 35.208 v6.0.0 - 4.3.7 Test Set 7 */
    725 		{ 0x2d, 0x60, 0x9d, 0x4d, 0xb0, 0xac, 0x5b, 0xf0,
    726 		  0xd2, 0xc0, 0xde, 0x26, 0x70, 0x14, 0xde, 0x0d },
    727 		{ 0x19, 0x4a, 0xa7, 0x56, 0x01, 0x38, 0x96, 0xb7,
    728 		  0x4b, 0x4a, 0x2a, 0x3b, 0x0a, 0xf4, 0x53, 0x9e },
    729 		{ 0x6b, 0xf6, 0x94, 0x38, 0xc2, 0xe4 },
    730 		{ 0x5f, 0x67 },
    731 		{ 0x46, 0x0a, 0x48, 0x38, 0x54, 0x27, 0xaa, 0x39,
    732 		  0x26, 0x4a, 0xac, 0x8e, 0xfc, 0x9e, 0x73, 0xe8 },
    733 		{ 0xc3, 0x5a, 0x0a, 0xb0, 0xbc, 0xbf, 0xc9, 0x25,
    734 		  0x2c, 0xaf, 0xf1, 0x5f, 0x24, 0xef, 0xbd, 0xe0 },
    735 		{ 0xbd, 0x07, 0xd3, 0x00, 0x3b, 0x9e, 0x5c, 0xc3 },
    736 		{ 0xbc, 0xb6, 0xc2, 0xfc, 0xad, 0x15, 0x22, 0x50 },
    737 		{ 0x8c, 0x25, 0xa1, 0x6c, 0xd9, 0x18, 0xa1, 0xdf },
    738 		{ 0x4c, 0xd0, 0x84, 0x60, 0x20, 0xf8, 0xfa, 0x07,
    739 		  0x31, 0xdd, 0x47, 0xcb, 0xdc, 0x6b, 0xe4, 0x11 },
    740 		{ 0x88, 0xab, 0x80, 0xa4, 0x15, 0xf1, 0x5c, 0x73,
    741 		  0x71, 0x12, 0x54, 0xa1, 0xd3, 0x88, 0xf6, 0x96 },
    742 		{ 0x7e, 0x64, 0x55, 0xf3, 0x4c, 0xf3 },
    743 		{ 0xdc, 0x6d, 0xd0, 0x1e, 0x8f, 0x15 }
    744 	}, {
    745 		/* 3GPP TS 35.208 v6.0.0 - 4.3.8 Test Set 8 */
    746 		{ 0xa5, 0x30, 0xa7, 0xfe, 0x42, 0x8f, 0xad, 0x10,
    747 		  0x82, 0xc4, 0x5e, 0xdd, 0xfc, 0xe1, 0x38, 0x84 },
    748 		{ 0x3a, 0x4c, 0x2b, 0x32, 0x45, 0xc5, 0x0e, 0xb5,
    749 		  0xc7, 0x1d, 0x08, 0x63, 0x93, 0x95, 0x76, 0x4d },
    750 		{ 0xf6, 0x3f, 0x5d, 0x76, 0x87, 0x84 },
    751 		{ 0xb9, 0x0e },
    752 		{ 0x51, 0x1c, 0x6c, 0x4e, 0x83, 0xe3, 0x8c, 0x89,
    753 		  0xb1, 0xc5, 0xd8, 0xdd, 0xe6, 0x24, 0x26, 0xfa },
    754 		{ 0x27, 0x95, 0x3e, 0x49, 0xbc, 0x8a, 0xf6, 0xdc,
    755 		  0xc6, 0xe7, 0x30, 0xeb, 0x80, 0x28, 0x6b, 0xe3 },
    756 		{ 0x53, 0x76, 0x1f, 0xbd, 0x67, 0x9b, 0x0b, 0xad },
    757 		{ 0x21, 0xad, 0xfd, 0x33, 0x4a, 0x10, 0xe7, 0xce },
    758 		{ 0xa6, 0x32, 0x41, 0xe1, 0xff, 0xc3, 0xe5, 0xab },
    759 		{ 0x10, 0xf0, 0x5b, 0xab, 0x75, 0xa9, 0x9a, 0x5f,
    760 		  0xbb, 0x98, 0xa9, 0xc2, 0x87, 0x67, 0x9c, 0x3b },
    761 		{ 0xf9, 0xec, 0x08, 0x65, 0xeb, 0x32, 0xf2, 0x23,
    762 		  0x69, 0xca, 0xde, 0x40, 0xc5, 0x9c, 0x3a, 0x44 },
    763 		{ 0x88, 0x19, 0x6c, 0x47, 0x98, 0x6f },
    764 		{ 0xc9, 0x87, 0xa3, 0xd2, 0x31, 0x15 }
    765 	}, {
    766 		/* 3GPP TS 35.208 v6.0.0 - 4.3.9 Test Set 9 */
    767 		{ 0xd9, 0x15, 0x1c, 0xf0, 0x48, 0x96, 0xe2, 0x58,
    768 		  0x30, 0xbf, 0x2e, 0x08, 0x26, 0x7b, 0x83, 0x60 },
    769 		{ 0xf7, 0x61, 0xe5, 0xe9, 0x3d, 0x60, 0x3f, 0xeb,
    770 		  0x73, 0x0e, 0x27, 0x55, 0x6c, 0xb8, 0xa2, 0xca },
    771 		{ 0x47, 0xee, 0x01, 0x99, 0x82, 0x0a },
    772 		{ 0x91, 0x13 },
    773 		{ 0x75, 0xfc, 0x22, 0x33, 0xa4, 0x42, 0x94, 0xee,
    774 		  0x8e, 0x6d, 0xe2, 0x5c, 0x43, 0x53, 0xd2, 0x6b },
    775 		{ 0xc4, 0xc9, 0x3e, 0xff, 0xe8, 0xa0, 0x81, 0x38,
    776 		  0xc2, 0x03, 0xd4, 0xc2, 0x7c, 0xe4, 0xe3, 0xd9 },
    777 		{ 0x66, 0xcc, 0x4b, 0xe4, 0x48, 0x62, 0xaf, 0x1f },
    778 		{ 0x7a, 0x4b, 0x8d, 0x7a, 0x87, 0x53, 0xf2, 0x46 },
    779 		{ 0x4a, 0x90, 0xb2, 0x17, 0x1a, 0xc8, 0x3a, 0x76 },
    780 		{ 0x71, 0x23, 0x6b, 0x71, 0x29, 0xf9, 0xb2, 0x2a,
    781 		  0xb7, 0x7e, 0xa7, 0xa5, 0x4c, 0x96, 0xda, 0x22 },
    782 		{ 0x90, 0x52, 0x7e, 0xba, 0xa5, 0x58, 0x89, 0x68,
    783 		  0xdb, 0x41, 0x72, 0x73, 0x25, 0xa0, 0x4d, 0x9e },
    784 		{ 0x82, 0xa0, 0xf5, 0x28, 0x7a, 0x71 },
    785 		{ 0x52, 0x7d, 0xbf, 0x41, 0xf3, 0x5f }
    786 	}, {
    787 		/* 3GPP TS 35.208 v6.0.0 - 4.3.10 Test Set 10 */
    788 		{ 0xa0, 0xe2, 0x97, 0x1b, 0x68, 0x22, 0xe8, 0xd3,
    789 		  0x54, 0xa1, 0x8c, 0xc2, 0x35, 0x62, 0x4e, 0xcb },
    790 		{ 0x08, 0xef, 0xf8, 0x28, 0xb1, 0x3f, 0xdb, 0x56,
    791 		  0x27, 0x22, 0xc6, 0x5c, 0x7f, 0x30, 0xa9, 0xb2 },
    792 		{ 0xdb, 0x5c, 0x06, 0x64, 0x81, 0xe0 },
    793 		{ 0x71, 0x6b },
    794 		{ 0x32, 0x37, 0x92, 0xfa, 0xca, 0x21, 0xfb, 0x4d,
    795 		  0x5d, 0x6f, 0x13, 0xc1, 0x45, 0xa9, 0xd2, 0xc1 },
    796 		{ 0x82, 0xa2, 0x6f, 0x22, 0xbb, 0xa9, 0xe9, 0x48,
    797 		  0x8f, 0x94, 0x9a, 0x10, 0xd9, 0x8e, 0x9c, 0xc4 },
    798 		{ 0x94, 0x85, 0xfe, 0x24, 0x62, 0x1c, 0xb9, 0xf6 },
    799 		{ 0xbc, 0xe3, 0x25, 0xce, 0x03, 0xe2, 0xe9, 0xb9 },
    800 		{ 0x4b, 0xc2, 0x21, 0x2d, 0x86, 0x24, 0x91, 0x0a },
    801 		{ 0x08, 0xce, 0xf6, 0xd0, 0x04, 0xec, 0x61, 0x47,
    802 		  0x1a, 0x3c, 0x3c, 0xda, 0x04, 0x81, 0x37, 0xfa },
    803 		{ 0xed, 0x03, 0x18, 0xca, 0x5d, 0xeb, 0x92, 0x06,
    804 		  0x27, 0x2f, 0x6e, 0x8f, 0xa6, 0x4b, 0xa4, 0x11 },
    805 		{ 0xa2, 0xf8, 0x58, 0xaa, 0x9e, 0x5d },
    806 		{ 0x74, 0xe7, 0x6f, 0xbb, 0xec, 0x38 }
    807 	}, {
    808 		/* 3GPP TS 35.208 v6.0.0 - 4.3.11 Test Set 11 */
    809 		{ 0x0d, 0xa6, 0xf7, 0xba, 0x86, 0xd5, 0xea, 0xc8,
    810 		  0xa1, 0x9c, 0xf5, 0x63, 0xac, 0x58, 0x64, 0x2d },
    811 		{ 0x67, 0x9a, 0xc4, 0xdb, 0xac, 0xd7, 0xd2, 0x33,
    812 		  0xff, 0x9d, 0x68, 0x06, 0xf4, 0x14, 0x9c, 0xe3 },
    813 		{ 0x6e, 0x23, 0x31, 0xd6, 0x92, 0xad },
    814 		{ 0x22, 0x4a },
    815 		{ 0x4b, 0x9a, 0x26, 0xfa, 0x45, 0x9e, 0x3a, 0xcb,
    816 		  0xff, 0x36, 0xf4, 0x01, 0x5d, 0xe3, 0xbd, 0xc1 },
    817 		{ 0x0d, 0xb1, 0x07, 0x1f, 0x87, 0x67, 0x56, 0x2c,
    818 		  0xa4, 0x3a, 0x0a, 0x64, 0xc4, 0x1e, 0x8d, 0x08 },
    819 		{ 0x28, 0x31, 0xd7, 0xae, 0x90, 0x88, 0xe4, 0x92 },
    820 		{ 0x9b, 0x2e, 0x16, 0x95, 0x11, 0x35, 0xd5, 0x23 },
    821 		{ 0x6f, 0xc3, 0x0f, 0xee, 0x6d, 0x12, 0x35, 0x23 },
    822 		{ 0x69, 0xb1, 0xca, 0xe7, 0xc7, 0x42, 0x9d, 0x97,
    823 		  0x5e, 0x24, 0x5c, 0xac, 0xb0, 0x5a, 0x51, 0x7c },
    824 		{ 0x74, 0xf2, 0x4e, 0x8c, 0x26, 0xdf, 0x58, 0xe1,
    825 		  0xb3, 0x8d, 0x7d, 0xcd, 0x4f, 0x1b, 0x7f, 0xbd },
    826 		{ 0x4c, 0x53, 0x9a, 0x26, 0xe1, 0xfa },
    827 		{ 0x07, 0x86, 0x1e, 0x12, 0x69, 0x28 }
    828 	}, {
    829 		/* 3GPP TS 35.208 v6.0.0 - 4.3.12 Test Set 12 */
    830 		{ 0x77, 0xb4, 0x58, 0x43, 0xc8, 0x8e, 0x58, 0xc1,
    831 		  0x0d, 0x20, 0x26, 0x84, 0x51, 0x5e, 0xd4, 0x30 },
    832 		{ 0x4c, 0x47, 0xeb, 0x30, 0x76, 0xdc, 0x55, 0xfe,
    833 		  0x51, 0x06, 0xcb, 0x20, 0x34, 0xb8, 0xcd, 0x78 },
    834 		{ 0xfe, 0x1a, 0x87, 0x31, 0x00, 0x5d },
    835 		{ 0xad, 0x25 },
    836 		{ 0xbf, 0x32, 0x86, 0xc7, 0xa5, 0x14, 0x09, 0xce,
    837 		  0x95, 0x72, 0x4d, 0x50, 0x3b, 0xfe, 0x6e, 0x70 },
    838 		{ 0xd4, 0x83, 0xaf, 0xae, 0x56, 0x24, 0x09, 0xa3,
    839 		  0x26, 0xb5, 0xbb, 0x0b, 0x20, 0xc4, 0xd7, 0x62 },
    840 		{ 0x08, 0x33, 0x2d, 0x7e, 0x9f, 0x48, 0x45, 0x70 },
    841 		{ 0xed, 0x41, 0xb7, 0x34, 0x48, 0x9d, 0x52, 0x07 },
    842 		{ 0xae, 0xfa, 0x35, 0x7b, 0xea, 0xc2, 0xa8, 0x7a },
    843 		{ 0x90, 0x8c, 0x43, 0xf0, 0x56, 0x9c, 0xb8, 0xf7,
    844 		  0x4b, 0xc9, 0x71, 0xe7, 0x06, 0xc3, 0x6c, 0x5f },
    845 		{ 0xc2, 0x51, 0xdf, 0x0d, 0x88, 0x8d, 0xd9, 0x32,
    846 		  0x9b, 0xcf, 0x46, 0x65, 0x5b, 0x22, 0x6e, 0x40 },
    847 		{ 0x30, 0xff, 0x25, 0xcd, 0xad, 0xf6 },
    848 		{ 0xe8, 0x4e, 0xd0, 0xd4, 0x67, 0x7e }
    849 	}, {
    850 		/* 3GPP TS 35.208 v6.0.0 - 4.3.13 Test Set 13 */
    851 		{ 0x72, 0x9b, 0x17, 0x72, 0x92, 0x70, 0xdd, 0x87,
    852 		  0xcc, 0xdf, 0x1b, 0xfe, 0x29, 0xb4, 0xe9, 0xbb },
    853 		{ 0x31, 0x1c, 0x4c, 0x92, 0x97, 0x44, 0xd6, 0x75,
    854 		  0xb7, 0x20, 0xf3, 0xb7, 0xe9, 0xb1, 0xcb, 0xd0 },
    855 		{ 0xc8, 0x5c, 0x4c, 0xf6, 0x59, 0x16 },
    856 		{ 0x5b, 0xb2 },
    857 		{ 0xd0, 0x4c, 0x9c, 0x35, 0xbd, 0x22, 0x62, 0xfa,
    858 		  0x81, 0x0d, 0x29, 0x24, 0xd0, 0x36, 0xfd, 0x13 },
    859 		{ 0x22, 0x8c, 0x2f, 0x2f, 0x06, 0xac, 0x32, 0x68,
    860 		  0xa9, 0xe6, 0x16, 0xee, 0x16, 0xdb, 0x4b, 0xa1 },
    861 		{ 0xff, 0x79, 0x4f, 0xe2, 0xf8, 0x27, 0xeb, 0xf8 },
    862 		{ 0x24, 0xfe, 0x4d, 0xc6, 0x1e, 0x87, 0x4b, 0x52 },
    863 		{ 0x98, 0xdb, 0xbd, 0x09, 0x9b, 0x3b, 0x40, 0x8d },
    864 		{ 0x44, 0xc0, 0xf2, 0x3c, 0x54, 0x93, 0xcf, 0xd2,
    865 		  0x41, 0xe4, 0x8f, 0x19, 0x7e, 0x1d, 0x10, 0x12 },
    866 		{ 0x0c, 0x9f, 0xb8, 0x16, 0x13, 0x88, 0x4c, 0x25,
    867 		  0x35, 0xdd, 0x0e, 0xab, 0xf3, 0xb4, 0x40, 0xd8 },
    868 		{ 0x53, 0x80, 0xd1, 0x58, 0xcf, 0xe3 },
    869 		{ 0x87, 0xac, 0x3b, 0x55, 0x9f, 0xb6 }
    870 	}, {
    871 		/* 3GPP TS 35.208 v6.0.0 - 4.3.14 Test Set 14 */
    872 		{ 0xd3, 0x2d, 0xd2, 0x3e, 0x89, 0xdc, 0x66, 0x23,
    873 		  0x54, 0xca, 0x12, 0xeb, 0x79, 0xdd, 0x32, 0xfa },
    874 		{ 0xcf, 0x7d, 0x0a, 0xb1, 0xd9, 0x43, 0x06, 0x95,
    875 		  0x0b, 0xf1, 0x20, 0x18, 0xfb, 0xd4, 0x68, 0x87 },
    876 		{ 0x48, 0x41, 0x07, 0xe5, 0x6a, 0x43 },
    877 		{ 0xb5, 0xe6 },
    878 		{ 0xfe, 0x75, 0x90, 0x5b, 0x9d, 0xa4, 0x7d, 0x35,
    879 		  0x62, 0x36, 0xd0, 0x31, 0x4e, 0x09, 0xc3, 0x2e },
    880 		{ 0xd2, 0x2a, 0x4b, 0x41, 0x80, 0xa5, 0x32, 0x57,
    881 		  0x08, 0xa5, 0xff, 0x70, 0xd9, 0xf6, 0x7e, 0xc7 },
    882 		{ 0xcf, 0x19, 0xd6, 0x2b, 0x6a, 0x80, 0x98, 0x66 },
    883 		{ 0x5d, 0x26, 0x95, 0x37, 0xe4, 0x5e, 0x2c, 0xe6 },
    884 		{ 0xaf, 0x4a, 0x41, 0x1e, 0x11, 0x39, 0xf2, 0xc2 },
    885 		{ 0x5a, 0xf8, 0x6b, 0x80, 0xed, 0xb7, 0x0d, 0xf5,
    886 		  0x29, 0x2c, 0xc1, 0x12, 0x1c, 0xba, 0xd5, 0x0c },
    887 		{ 0x7f, 0x4d, 0x6a, 0xe7, 0x44, 0x0e, 0x18, 0x78,
    888 		  0x9a, 0x8b, 0x75, 0xad, 0x3f, 0x42, 0xf0, 0x3a },
    889 		{ 0x21, 0x7a, 0xf4, 0x92, 0x72, 0xad },
    890 		{ 0x90, 0x0e, 0x10, 0x1c, 0x67, 0x7e }
    891 	}, {
    892 		/* 3GPP TS 35.208 v6.0.0 - 4.3.15 Test Set 15 */
    893 		{ 0xaf, 0x7c, 0x65, 0xe1, 0x92, 0x72, 0x21, 0xde,
    894 		  0x59, 0x11, 0x87, 0xa2, 0xc5, 0x98, 0x7a, 0x53 },
    895 		{ 0x1f, 0x0f, 0x85, 0x78, 0x46, 0x4f, 0xd5, 0x9b,
    896 		  0x64, 0xbe, 0xd2, 0xd0, 0x94, 0x36, 0xb5, 0x7a },
    897 		{ 0x3d, 0x62, 0x7b, 0x01, 0x41, 0x8d },
    898 		{ 0x84, 0xf6 },
    899 		{ 0x0c, 0x7a, 0xcb, 0x8d, 0x95, 0xb7, 0xd4, 0xa3,
    900 		  0x1c, 0x5a, 0xca, 0x6d, 0x26, 0x34, 0x5a, 0x88 },
    901 		{ 0xa4, 0xcf, 0x5c, 0x81, 0x55, 0xc0, 0x8a, 0x7e,
    902 		  0xff, 0x41, 0x8e, 0x54, 0x43, 0xb9, 0x8e, 0x55 },
    903 		{ 0xc3, 0x7c, 0xae, 0x78, 0x05, 0x64, 0x20, 0x32 },
    904 		{ 0x68, 0xcd, 0x09, 0xa4, 0x52, 0xd8, 0xdb, 0x7c },
    905 		{ 0x7b, 0xff, 0xa5, 0xc2, 0xf4, 0x1f, 0xbc, 0x05 },
    906 		{ 0x3f, 0x8c, 0x3f, 0x3c, 0xcf, 0x76, 0x25, 0xbf,
    907 		  0x77, 0xfc, 0x94, 0xbc, 0xfd, 0x22, 0xfd, 0x26 },
    908 		{ 0xab, 0xcb, 0xae, 0x8f, 0xd4, 0x61, 0x15, 0xe9,
    909 		  0x96, 0x1a, 0x55, 0xd0, 0xda, 0x5f, 0x20, 0x78 },
    910 		{ 0x83, 0x7f, 0xd7, 0xb7, 0x44, 0x19 },
    911 		{ 0x56, 0xe9, 0x7a, 0x60, 0x90, 0xb1 }
    912 	}, {
    913 		/* 3GPP TS 35.208 v6.0.0 - 4.3.16 Test Set 16 */
    914 		{ 0x5b, 0xd7, 0xec, 0xd3, 0xd3, 0x12, 0x7a, 0x41,
    915 		  0xd1, 0x25, 0x39, 0xbe, 0xd4, 0xe7, 0xcf, 0x71 },
    916 		{ 0x59, 0xb7, 0x5f, 0x14, 0x25, 0x1c, 0x75, 0x03,
    917 		  0x1d, 0x0b, 0xcb, 0xac, 0x1c, 0x2c, 0x04, 0xc7 },
    918 		{ 0xa2, 0x98, 0xae, 0x89, 0x29, 0xdc },
    919 		{ 0xd0, 0x56 },
    920 		{ 0xf9, 0x67, 0xf7, 0x60, 0x38, 0xb9, 0x20, 0xa9,
    921 		  0xcd, 0x25, 0xe1, 0x0c, 0x08, 0xb4, 0x99, 0x24 },
    922 		{ 0x76, 0x08, 0x9d, 0x3c, 0x0f, 0xf3, 0xef, 0xdc,
    923 		  0x6e, 0x36, 0x72, 0x1d, 0x4f, 0xce, 0xb7, 0x47 },
    924 		{ 0xc3, 0xf2, 0x5c, 0xd9, 0x43, 0x09, 0x10, 0x7e },
    925 		{ 0xb0, 0xc8, 0xba, 0x34, 0x36, 0x65, 0xaf, 0xcc },
    926 		{ 0x7e, 0x3f, 0x44, 0xc7, 0x59, 0x1f, 0x6f, 0x45 },
    927 		{ 0xd4, 0x2b, 0x2d, 0x61, 0x5e, 0x49, 0xa0, 0x3a,
    928 		  0xc2, 0x75, 0xa5, 0xae, 0xf9, 0x7a, 0xf8, 0x92 },
    929 		{ 0x0b, 0x3f, 0x8d, 0x02, 0x4f, 0xe6, 0xbf, 0xaf,
    930 		  0xaa, 0x98, 0x2b, 0x8f, 0x82, 0xe3, 0x19, 0xc2 },
    931 		{ 0x5b, 0xe1, 0x14, 0x95, 0x52, 0x5d },
    932 		{ 0x4d, 0x6a, 0x34, 0xa1, 0xe4, 0xeb }
    933 	}, {
    934 		/* 3GPP TS 35.208 v6.0.0 - 4.3.17 Test Set 17 */
    935 		{ 0x6c, 0xd1, 0xc6, 0xce, 0xb1, 0xe0, 0x1e, 0x14,
    936 		  0xf1, 0xb8, 0x23, 0x16, 0xa9, 0x0b, 0x7f, 0x3d },
    937 		{ 0xf6, 0x9b, 0x78, 0xf3, 0x00, 0xa0, 0x56, 0x8b,
    938 		  0xce, 0x9f, 0x0c, 0xb9, 0x3c, 0x4b, 0xe4, 0xc9 },
    939 		{ 0xb4, 0xfc, 0xe5, 0xfe, 0xb0, 0x59 },
    940 		{ 0xe4, 0xbb },
    941 		{ 0x07, 0x8b, 0xfc, 0xa9, 0x56, 0x46, 0x59, 0xec,
    942 		  0xd8, 0x85, 0x1e, 0x84, 0xe6, 0xc5, 0x9b, 0x48 },
    943 		{ 0xa2, 0x19, 0xdc, 0x37, 0xf1, 0xdc, 0x7d, 0x66,
    944 		  0x73, 0x8b, 0x58, 0x43, 0xc7, 0x99, 0xf2, 0x06 },
    945 		{ 0x69, 0xa9, 0x08, 0x69, 0xc2, 0x68, 0xcb, 0x7b },
    946 		{ 0x2e, 0x0f, 0xdc, 0xf9, 0xfd, 0x1c, 0xfa, 0x6a },
    947 		{ 0x70, 0xf6, 0xbd, 0xb9, 0xad, 0x21, 0x52, 0x5f },
    948 		{ 0x6e, 0xda, 0xf9, 0x9e, 0x5b, 0xd9, 0xf8, 0x5d,
    949 		  0x5f, 0x36, 0xd9, 0x1c, 0x12, 0x72, 0xfb, 0x4b },
    950 		{ 0xd6, 0x1c, 0x85, 0x3c, 0x28, 0x0d, 0xd9, 0xc4,
    951 		  0x6f, 0x29, 0x7b, 0xae, 0xc3, 0x86, 0xde, 0x17 },
    952 		{ 0x1c, 0x40, 0x8a, 0x85, 0x8b, 0x3e },
    953 		{ 0xaa, 0x4a, 0xe5, 0x2d, 0xaa, 0x30 }
    954 	}, {
    955 		/* 3GPP TS 35.208 v6.0.0 - 4.3.18 Test Set 18 */
    956 		{ 0xb7, 0x3a, 0x90, 0xcb, 0xcf, 0x3a, 0xfb, 0x62,
    957 		  0x2d, 0xba, 0x83, 0xc5, 0x8a, 0x84, 0x15, 0xdf },
    958 		{ 0xb1, 0x20, 0xf1, 0xc1, 0xa0, 0x10, 0x2a, 0x2f,
    959 		  0x50, 0x7d, 0xd5, 0x43, 0xde, 0x68, 0x28, 0x1f },
    960 		{ 0xf1, 0xe8, 0xa5, 0x23, 0xa3, 0x6d },
    961 		{ 0x47, 0x1b },
    962 		{ 0xb6, 0x72, 0x04, 0x7e, 0x00, 0x3b, 0xb9, 0x52,
    963 		  0xdc, 0xa6, 0xcb, 0x8a, 0xf0, 0xe5, 0xb7, 0x79 },
    964 		{ 0xdf, 0x0c, 0x67, 0x86, 0x8f, 0xa2, 0x5f, 0x74,
    965 		  0x8b, 0x70, 0x44, 0xc6, 0xe7, 0xc2, 0x45, 0xb8 },
    966 		{ 0xeb, 0xd7, 0x03, 0x41, 0xbc, 0xd4, 0x15, 0xb0 },
    967 		{ 0x12, 0x35, 0x9f, 0x5d, 0x82, 0x22, 0x0c, 0x14 },
    968 		{ 0x47, 0x9d, 0xd2, 0x5c, 0x20, 0x79, 0x2d, 0x63 },
    969 		{ 0x66, 0x19, 0x5d, 0xbe, 0xd0, 0x31, 0x32, 0x74,
    970 		  0xc5, 0xca, 0x77, 0x66, 0x61, 0x5f, 0xa2, 0x5e },
    971 		{ 0x66, 0xbe, 0xc7, 0x07, 0xeb, 0x2a, 0xfc, 0x47,
    972 		  0x6d, 0x74, 0x08, 0xa8, 0xf2, 0x92, 0x7b, 0x36 },
    973 		{ 0xae, 0xfd, 0xaa, 0x5d, 0xdd, 0x99 },
    974 		{ 0x12, 0xec, 0x2b, 0x87, 0xfb, 0xb1 }
    975 	}, {
    976 		/* 3GPP TS 35.208 v6.0.0 - 4.3.19 Test Set 19 */
    977 		{ 0x51, 0x22, 0x25, 0x02, 0x14, 0xc3, 0x3e, 0x72,
    978 		  0x3a, 0x5d, 0xd5, 0x23, 0xfc, 0x14, 0x5f, 0xc0 },
    979 		{ 0x81, 0xe9, 0x2b, 0x6c, 0x0e, 0xe0, 0xe1, 0x2e,
    980 		  0xbc, 0xeb, 0xa8, 0xd9, 0x2a, 0x99, 0xdf, 0xa5 },
    981 		{ 0x16, 0xf3, 0xb3, 0xf7, 0x0f, 0xc2 },
    982 		{ 0xc3, 0xab },
    983 		{ 0xc9, 0xe8, 0x76, 0x32, 0x86, 0xb5, 0xb9, 0xff,
    984 		  0xbd, 0xf5, 0x6e, 0x12, 0x97, 0xd0, 0x88, 0x7b },
    985 		{ 0x98, 0x1d, 0x46, 0x4c, 0x7c, 0x52, 0xeb, 0x6e,
    986 		  0x50, 0x36, 0x23, 0x49, 0x84, 0xad, 0x0b, 0xcf },
    987 		{ 0x2a, 0x5c, 0x23, 0xd1, 0x5e, 0xe3, 0x51, 0xd5 },
    988 		{ 0x62, 0xda, 0xe3, 0x85, 0x3f, 0x3a, 0xf9, 0xd2 },
    989 		{ 0x28, 0xd7, 0xb0, 0xf2, 0xa2, 0xec, 0x3d, 0xe5 },
    990 		{ 0x53, 0x49, 0xfb, 0xe0, 0x98, 0x64, 0x9f, 0x94,
    991 		  0x8f, 0x5d, 0x2e, 0x97, 0x3a, 0x81, 0xc0, 0x0f },
    992 		{ 0x97, 0x44, 0x87, 0x1a, 0xd3, 0x2b, 0xf9, 0xbb,
    993 		  0xd1, 0xdd, 0x5c, 0xe5, 0x4e, 0x3e, 0x2e, 0x5a },
    994 		{ 0xad, 0xa1, 0x5a, 0xeb, 0x7b, 0xb8 },
    995 		{ 0xd4, 0x61, 0xbc, 0x15, 0x47, 0x5d }
    996 	}, {
    997 		/* 3GPP TS 35.208 v6.0.0 - 4.3.20 Test Set 20 */
    998 		{ 0x90, 0xdc, 0xa4, 0xed, 0xa4, 0x5b, 0x53, 0xcf,
    999 		  0x0f, 0x12, 0xd7, 0xc9, 0xc3, 0xbc, 0x6a, 0x89 },
   1000 		{ 0x9f, 0xdd, 0xc7, 0x20, 0x92, 0xc6, 0xad, 0x03,
   1001 		  0x6b, 0x6e, 0x46, 0x47, 0x89, 0x31, 0x5b, 0x78 },
   1002 		{ 0x20, 0xf8, 0x13, 0xbd, 0x41, 0x41 },
   1003 		{ 0x61, 0xdf },
   1004 		{ 0x3f, 0xfc, 0xfe, 0x5b, 0x7b, 0x11, 0x11, 0x58,
   1005 		  0x99, 0x20, 0xd3, 0x52, 0x8e, 0x84, 0xe6, 0x55 },
   1006 		{ 0xcb, 0x9c, 0xcc, 0xc4, 0xb9, 0x25, 0x8e, 0x6d,
   1007 		  0xca, 0x47, 0x60, 0x37, 0x9f, 0xb8, 0x25, 0x81 },
   1008 		{ 0x09, 0xdb, 0x94, 0xea, 0xb4, 0xf8, 0x14, 0x9e },
   1009 		{ 0xa2, 0x94, 0x68, 0xaa, 0x97, 0x75, 0xb5, 0x27 },
   1010 		{ 0xa9, 0x51, 0x00, 0xe2, 0x76, 0x09, 0x52, 0xcd },
   1011 		{ 0xb5, 0xf2, 0xda, 0x03, 0x88, 0x3b, 0x69, 0xf9,
   1012 		  0x6b, 0xf5, 0x2e, 0x02, 0x9e, 0xd9, 0xac, 0x45 },
   1013 		{ 0xb4, 0x72, 0x13, 0x68, 0xbc, 0x16, 0xea, 0x67,
   1014 		  0x87, 0x5c, 0x55, 0x98, 0x68, 0x8b, 0xb0, 0xef },
   1015 		{ 0x83, 0xcf, 0xd5, 0x4d, 0xb9, 0x13 },
   1016 		{ 0x4f, 0x20, 0x39, 0x39, 0x2d, 0xdc }
   1017 	}
   1018 };
   1019 
   1020 #define NUM_TESTS (sizeof(test_sets) / sizeof(test_sets[0]))
   1021 
   1022 
   1023 int main(int argc, char *argv[])
   1024 {
   1025 	u8 buf[16], buf2[16], buf3[16], buf4[16], buf5[16], opc[16];
   1026 	u8 auts[14], sqn[6], _rand[16];
   1027 	int ret = 0, res, i;
   1028 	const struct milenage_test_set *t;
   1029 	size_t res_len;
   1030 
   1031 	wpa_debug_level = 0;
   1032 
   1033 	printf("Milenage test sets\n");
   1034 	for (i = 0; i < NUM_TESTS; i++) {
   1035 		t = &test_sets[i];
   1036 		printf("Test Set %d\n", i + 1);
   1037 
   1038 		milenage_opc(t->op, t->k, opc);
   1039 		if (memcmp(opc, t->opc, 16) != 0) {
   1040 			printf("- milenage_opc failed\n");
   1041 			ret++;
   1042 		}
   1043 
   1044 		if (milenage_f1(opc, t->k, t->rand, t->sqn, t->amf, buf, buf2)
   1045 		    ||  memcmp(buf, t->f1, 8) != 0) {
   1046 			printf("- milenage_f1 failed\n");
   1047 			ret++;
   1048 		}
   1049 		if (memcmp(buf2, t->f1star, 8) != 0) {
   1050 			printf("- milenage_f1* failed\n");
   1051 			ret++;
   1052 		}
   1053 
   1054 		if (milenage_f2345(opc, t->k, t->rand, buf, buf2, buf3, buf4,
   1055 				   buf5) ||
   1056 		    memcmp(buf, t->f2, 8) != 0) {
   1057 			printf("- milenage_f2 failed\n");
   1058 			ret++;
   1059 		}
   1060 		if (memcmp(buf2, t->f3, 16) != 0) {
   1061 			printf("- milenage_f3 failed\n");
   1062 			ret++;
   1063 		}
   1064 		if (memcmp(buf3, t->f4, 16) != 0) {
   1065 			printf("- milenage_f4 failed\n");
   1066 			ret++;
   1067 		}
   1068 		if (memcmp(buf4, t->f5, 6) != 0) {
   1069 			printf("- milenage_f5 failed\n");
   1070 			ret++;
   1071 		}
   1072 		if (memcmp(buf5, t->f5star, 6) != 0) {
   1073 			printf("- milenage_f5* failed\n");
   1074 			ret++;
   1075 		}
   1076 	}
   1077 
   1078 	printf("milenage_auts test:\n");
   1079 	os_memcpy(auts, "\x4f\x20\x39\x39\x2d\xdd", 6);
   1080 	os_memcpy(auts + 6, "\x4b\xb4\x31\x6e\xd4\xa1\x46\x88", 8);
   1081 	res = milenage_auts(t->opc, t->k, t->rand, auts, buf);
   1082 	printf("AUTS for test set %d: %d / SQN=%02x%02x%02x%02x%02x%02x\n",
   1083 	       i, res, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
   1084 	if (res)
   1085 		ret++;
   1086 
   1087 	os_memset(_rand, 0xaa, sizeof(_rand));
   1088 	os_memcpy(auts,
   1089 		  "\x43\x68\x1a\xd3\xda\xf0\x06\xbc\xde\x40\x5a\x20\x72\x67",
   1090 		  14);
   1091 	res = milenage_auts(t->opc, t->k, _rand, auts, buf);
   1092 	printf("AUTS from a test USIM: %d / SQN=%02x%02x%02x%02x%02x%02x\n",
   1093 	       res, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
   1094 	if (res)
   1095 		ret++;
   1096 
   1097 	printf("milenage_generate test:\n");
   1098 	os_memcpy(sqn, "\x00\x00\x00\x00\x40\x44", 6);
   1099 	os_memcpy(_rand, "\x12\x69\xb8\x23\x41\x39\x35\x66\xfb\x99\x41\xe9\x84"
   1100 		  "\x4f\xe6\x2f", 16);
   1101 	res_len = 8;
   1102 	milenage_generate(t->opc, t->amf, t->k, sqn, _rand, buf, buf2, buf3,
   1103 			  buf4, &res_len);
   1104 	wpa_hexdump(MSG_DEBUG, "SQN", sqn, 6);
   1105 	wpa_hexdump(MSG_DEBUG, "RAND", _rand, 16);
   1106 	wpa_hexdump(MSG_DEBUG, "AUTN", buf, 16);
   1107 	wpa_hexdump(MSG_DEBUG, "IK", buf2, 16);
   1108 	wpa_hexdump(MSG_DEBUG, "CK", buf3, 16);
   1109 	wpa_hexdump(MSG_DEBUG, "RES", buf4, res_len);
   1110 
   1111 	printf("GSM-Milenage test sets\n");
   1112 	for (i = 0; i < NUM_GSM_TESTS; i++) {
   1113 		const struct gsm_milenage_test_set *g;
   1114 		u8 sres[4], kc[8];
   1115 		g = &gsm_test_sets[i];
   1116 		printf("Test Set %d\n", i + 1);
   1117 		gsm_milenage(g->opc, g->ki, g->rand, sres, kc);
   1118 		if (memcmp(g->kc, kc, 8) != 0) {
   1119 			printf("- gsm_milenage Kc failed\n");
   1120 			ret++;
   1121 		}
   1122 #ifdef GSM_MILENAGE_ALT_SRES
   1123 		if (memcmp(g->sres2, sres, 4) != 0) {
   1124 			printf("- gsm_milenage SRES#2 failed\n");
   1125 			ret++;
   1126 		}
   1127 #else /* GSM_MILENAGE_ALT_SRES */
   1128 		if (memcmp(g->sres1, sres, 4) != 0) {
   1129 			printf("- gsm_milenage SRES#1 failed\n");
   1130 			ret++;
   1131 		}
   1132 #endif /* GSM_MILENAGE_ALT_SRES */
   1133 	}
   1134 
   1135 	if (ret)
   1136 		printf("Something failed\n");
   1137 	else
   1138 		printf("OK\n");
   1139 
   1140 	return ret;
   1141 }
   1142 #endif /* TEST_MAIN_MILENAGE */
   1143