M7350v1_en_gpl

This commit is contained in:
T
2024-09-09 08:52:07 +00:00
commit f9cc65cfda
65988 changed files with 26357421 additions and 0 deletions

106
external/hostap/tests/Makefile vendored Normal file
View File

@ -0,0 +1,106 @@
TESTS=test-base64 test-md4 test-md5 test-milenage test-ms_funcs \
test-printf \
test-sha1 \
test-sha256 test-aes test-asn1 test-x509 test-x509v3 test-list test-rc4
all: $(TESTS)
ifndef CC
CC=gcc
endif
ifndef LDO
LDO=$(CC)
endif
ifndef CFLAGS
CFLAGS = -MMD -O2 -Wall -g
endif
CFLAGS += -I../src
CFLAGS += -I../src/utils
SLIBS = ../src/utils/libutils.a
DLIBS = ../src/crypto/libcrypto.a \
../src/tls/libtls.a
LIBS = $(SLIBS) $(DLIBS)
LLIBS = -Wl,--start-group $(DLIBS) -Wl,--end-group $(SLIBS)
../src/utils/libutils.a:
$(MAKE) -C ../src/utils
../src/crypto/libcrypto.a:
$(MAKE) -C ../src/crypto
../src/tls/libtls.a:
$(MAKE) -C ../src/tls
test-aes: test-aes.o $(LIBS)
$(LDO) $(LDFLAGS) -o $@ $^ $(LLIBS)
test-asn1: test-asn1.o $(LIBS)
$(LDO) $(LDFLAGS) -o $@ $^
test-base64: test-base64.o $(LIBS)
$(LDO) $(LDFLAGS) -o $@ $^
test-https: test-https.o $(LIBS)
$(LDO) $(LDFLAGS) -o $@ $< $(LLIBS)
test-list: test-list.o $(LIBS)
$(LDO) $(LDFLAGS) -o $@ $^
test-md4: test-md4.o $(LIBS)
$(LDO) $(LDFLAGS) -o $@ $^
test-md5: test-md5.o $(LIBS)
$(LDO) $(LDFLAGS) -o $@ $^
test-milenage: test-milenage.o $(LIBS)
$(LDO) $(LDFLAGS) -o $@ $^
test-ms_funcs: test-ms_funcs.o $(LIBS)
$(LDO) $(LDFLAGS) -o $@ $^
test-printf: test-printf.o $(LIBS)
$(LDO) $(LDFLAGS) -o $@ $^
test-rc4: test-rc4.o $(LIBS)
$(LDO) $(LDFLAGS) -o $@ $^
test-sha1: test-sha1.o $(LIBS)
$(LDO) $(LDFLAGS) -o $@ $^
test-sha256: test-sha256.o $(LIBS)
$(LDO) $(LDFLAGS) -o $@ $^
test-x509: test-x509.o $(LIBS)
$(LDO) $(LDFLAGS) -o $@ $< $(LLIBS)
test-x509v3: test-x509v3.o $(LIBS)
$(LDO) $(LDFLAGS) -o $@ $< $(LLIBS)
run-tests: $(TESTS)
./test-aes
./test-list
./test-md4
./test-md5
./test-milenage
./test-printf
./test-sha1
./test-sha256
@echo
@echo All tests completed successfully.
clean:
$(MAKE) -C ../src clean
rm -f $(TESTS) *~ *.o *.d
rm -f test-https
rm -f test_x509v3_nist.out.*
rm -f test_x509v3_nist2.out.*
-include $(OBJS:%.o=%.d)

582
external/hostap/tests/test-aes.c vendored Normal file
View File

@ -0,0 +1,582 @@
/*
* Test program for AES
* Copyright (c) 2003-2012, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
*/
#include "includes.h"
#include "common.h"
#include "crypto/crypto.h"
#include "crypto/aes_wrap.h"
#define BLOCK_SIZE 16
static void test_aes_perf(void)
{
#if 0 /* this did not seem to work with new compiler?! */
#ifdef __i386__
#define rdtscll(val) \
__asm__ __volatile__("rdtsc" : "=A" (val))
const int num_iters = 10;
int i;
unsigned int start, end;
u8 key[16], pt[16], ct[16];
void *ctx;
printf("keySetupEnc:");
for (i = 0; i < num_iters; i++) {
rdtscll(start);
ctx = aes_encrypt_init(key, 16);
rdtscll(end);
aes_encrypt_deinit(ctx);
printf(" %d", end - start);
}
printf("\n");
printf("Encrypt:");
ctx = aes_encrypt_init(key, 16);
for (i = 0; i < num_iters; i++) {
rdtscll(start);
aes_encrypt(ctx, pt, ct);
rdtscll(end);
printf(" %d", end - start);
}
aes_encrypt_deinit(ctx);
printf("\n");
#endif /* __i386__ */
#endif
}
static int test_eax(void)
{
u8 msg[] = { 0xF7, 0xFB };
u8 key[] = { 0x91, 0x94, 0x5D, 0x3F, 0x4D, 0xCB, 0xEE, 0x0B,
0xF4, 0x5E, 0xF5, 0x22, 0x55, 0xF0, 0x95, 0xA4 };
u8 nonce[] = { 0xBE, 0xCA, 0xF0, 0x43, 0xB0, 0xA2, 0x3D, 0x84,
0x31, 0x94, 0xBA, 0x97, 0x2C, 0x66, 0xDE, 0xBD };
u8 hdr[] = { 0xFA, 0x3B, 0xFD, 0x48, 0x06, 0xEB, 0x53, 0xFA };
u8 cipher[] = { 0x19, 0xDD, 0x5C, 0x4C, 0x93, 0x31, 0x04, 0x9D,
0x0B, 0xDA, 0xB0, 0x27, 0x74, 0x08, 0xF6, 0x79,
0x67, 0xE5 };
u8 data[sizeof(msg)], tag[BLOCK_SIZE];
memcpy(data, msg, sizeof(msg));
if (aes_128_eax_encrypt(key, nonce, sizeof(nonce), hdr, sizeof(hdr),
data, sizeof(data), tag)) {
printf("AES-128 EAX mode encryption failed\n");
return 1;
}
if (memcmp(data, cipher, sizeof(data)) != 0) {
printf("AES-128 EAX mode encryption returned invalid cipher "
"text\n");
return 1;
}
if (memcmp(tag, cipher + sizeof(data), BLOCK_SIZE) != 0) {
printf("AES-128 EAX mode encryption returned invalid tag\n");
return 1;
}
if (aes_128_eax_decrypt(key, nonce, sizeof(nonce), hdr, sizeof(hdr),
data, sizeof(data), tag)) {
printf("AES-128 EAX mode decryption failed\n");
return 1;
}
if (memcmp(data, msg, sizeof(data)) != 0) {
printf("AES-128 EAX mode decryption returned invalid plain "
"text\n");
return 1;
}
return 0;
}
static int test_cbc(void)
{
struct cbc_test_vector {
u8 key[16];
u8 iv[16];
u8 plain[32];
u8 cipher[32];
size_t len;
} vectors[] = {
{
{ 0x06, 0xa9, 0x21, 0x40, 0x36, 0xb8, 0xa1, 0x5b,
0x51, 0x2e, 0x03, 0xd5, 0x34, 0x12, 0x00, 0x06 },
{ 0x3d, 0xaf, 0xba, 0x42, 0x9d, 0x9e, 0xb4, 0x30,
0xb4, 0x22, 0xda, 0x80, 0x2c, 0x9f, 0xac, 0x41 },
"Single block msg",
{ 0xe3, 0x53, 0x77, 0x9c, 0x10, 0x79, 0xae, 0xb8,
0x27, 0x08, 0x94, 0x2d, 0xbe, 0x77, 0x18, 0x1a },
16
},
{
{ 0xc2, 0x86, 0x69, 0x6d, 0x88, 0x7c, 0x9a, 0xa0,
0x61, 0x1b, 0xbb, 0x3e, 0x20, 0x25, 0xa4, 0x5a },
{ 0x56, 0x2e, 0x17, 0x99, 0x6d, 0x09, 0x3d, 0x28,
0xdd, 0xb3, 0xba, 0x69, 0x5a, 0x2e, 0x6f, 0x58 },
{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
{ 0xd2, 0x96, 0xcd, 0x94, 0xc2, 0xcc, 0xcf, 0x8a,
0x3a, 0x86, 0x30, 0x28, 0xb5, 0xe1, 0xdc, 0x0a,
0x75, 0x86, 0x60, 0x2d, 0x25, 0x3c, 0xff, 0xf9,
0x1b, 0x82, 0x66, 0xbe, 0xa6, 0xd6, 0x1a, 0xb1 },
32
}
};
int ret = 0;
u8 *buf;
unsigned int i;
for (i = 0; i < sizeof(vectors) / sizeof(vectors[0]); i++) {
struct cbc_test_vector *tv = &vectors[i];
buf = malloc(tv->len);
if (buf == NULL) {
ret++;
break;
}
memcpy(buf, tv->plain, tv->len);
if (aes_128_cbc_encrypt(tv->key, tv->iv, buf, tv->len) ||
memcmp(buf, tv->cipher, tv->len) != 0) {
printf("AES-CBC encrypt %d failed\n", i);
ret++;
}
memcpy(buf, tv->cipher, tv->len);
if (aes_128_cbc_decrypt(tv->key, tv->iv, buf, tv->len) ||
memcmp(buf, tv->plain, tv->len) != 0) {
printf("AES-CBC decrypt %d failed\n", i);
ret++;
}
free(buf);
}
return ret;
}
/*
* GCM test vectors from
* http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/proposedmodes/gcm/gcm-spec.pdf
*/
struct gcm_test_vector {
char *k;
char *p;
char *aad;
char *iv;
char *c;
char *t;
};
static const struct gcm_test_vector gcm_tests[] = {
{
/* Test Case 1 */
"00000000000000000000000000000000",
"",
"",
"000000000000000000000000",
"",
"58e2fccefa7e3061367f1d57a4e7455a"
},
{
/* Test Case 2 */
"00000000000000000000000000000000",
"00000000000000000000000000000000",
"",
"000000000000000000000000",
"0388dace60b6a392f328c2b971b2fe78",
"ab6e47d42cec13bdf53a67b21257bddf"
},
{
/* Test Case 3 */
"feffe9928665731c6d6a8f9467308308",
"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255",
"",
"cafebabefacedbaddecaf888",
"42831ec2217774244b7221b784d0d49ce3aa212f2c02a4e035c17e2329aca12e21d514b25466931c7d8f6a5aac84aa051ba30b396a0aac973d58e091473f5985",
"4d5c2af327cd64a62cf35abd2ba6fab4"
},
{
/* Test Case 4 */
"feffe9928665731c6d6a8f9467308308",
"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39",
"feedfacedeadbeeffeedfacedeadbeefabaddad2",
"cafebabefacedbaddecaf888",
"42831ec2217774244b7221b784d0d49ce3aa212f2c02a4e035c17e2329aca12e21d514b25466931c7d8f6a5aac84aa051ba30b396a0aac973d58e091",
"5bc94fbc3221a5db94fae95ae7121a47"
},
{
/* Test Case 5 */
"feffe9928665731c6d6a8f9467308308",
"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39",
"feedfacedeadbeeffeedfacedeadbeefabaddad2",
"cafebabefacedbad",
"61353b4c2806934a777ff51fa22a4755699b2a714fcdc6f83766e5f97b6c742373806900e49f24b22b097544d4896b424989b5e1ebac0f07c23f4598",
"3612d2e79e3b0785561be14aaca2fccb"
},
{
/* Test Case 6 */
"feffe9928665731c6d6a8f9467308308",
"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39",
"feedfacedeadbeeffeedfacedeadbeefabaddad2",
"9313225df88406e555909c5aff5269aa6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b525416aedbf5a0de6a57a637b39b",
"8ce24998625615b603a033aca13fb894be9112a5c3a211a8ba262a3cca7e2ca701e4a9a4fba43c90ccdcb281d48c7c6fd62875d2aca417034c34aee5",
"619cc5aefffe0bfa462af43c1699d050"
},
{
/* Test Case 7 */
"000000000000000000000000000000000000000000000000",
"",
"",
"000000000000000000000000",
"",
"cd33b28ac773f74ba00ed1f312572435"
},
{
/* Test Case 8 */
"000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000",
"",
"000000000000000000000000",
"98e7247c07f0fe411c267e4384b0f600",
"2ff58d80033927ab8ef4d4587514f0fb"
},
{
/* Test Case 9 */
"feffe9928665731c6d6a8f9467308308feffe9928665731c",
"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255",
"",
"cafebabefacedbaddecaf888",
"3980ca0b3c00e841eb06fac4872a2757859e1ceaa6efd984628593b40ca1e19c7d773d00c144c525ac619d18c84a3f4718e2448b2fe324d9ccda2710acade256",
"9924a7c8587336bfb118024db8674a14"
},
{
/* Test Case 10 */
"feffe9928665731c6d6a8f9467308308feffe9928665731c",
"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39",
"feedfacedeadbeeffeedfacedeadbeefabaddad2",
"cafebabefacedbaddecaf888",
"3980ca0b3c00e841eb06fac4872a2757859e1ceaa6efd984628593b40ca1e19c7d773d00c144c525ac619d18c84a3f4718e2448b2fe324d9ccda2710",
"2519498e80f1478f37ba55bd6d27618c"
},
{
/* Test Case 11 */
"feffe9928665731c6d6a8f9467308308feffe9928665731c",
"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39",
"feedfacedeadbeeffeedfacedeadbeefabaddad2",
"cafebabefacedbad",
"0f10f599ae14a154ed24b36e25324db8c566632ef2bbb34f8347280fc4507057fddc29df9a471f75c66541d4d4dad1c9e93a19a58e8b473fa0f062f7",
"65dcc57fcf623a24094fcca40d3533f8"
},
{
/* Test Case 12 */
"feffe9928665731c6d6a8f9467308308feffe9928665731c",
"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39",
"feedfacedeadbeeffeedfacedeadbeefabaddad2",
"9313225df88406e555909c5aff5269aa6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b525416aedbf5a0de6a57a637b39b",
"d27e88681ce3243c4830165a8fdcf9ff1de9a1d8e6b447ef6ef7b79828666e4581e79012af34ddd9e2f037589b292db3e67c036745fa22e7e9b7373b",
"dcf566ff291c25bbb8568fc3d376a6d9"
},
{
/* Test Case 13 */
"0000000000000000000000000000000000000000000000000000000000000000",
"",
"",
"000000000000000000000000",
"",
"530f8afbc74536b9a963b4f1c4cb738b"
},
{
/* Test Case 14 */
"0000000000000000000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000",
"",
"000000000000000000000000",
"cea7403d4d606b6e074ec5d3baf39d18",
"d0d1c8a799996bf0265b98b5d48ab919"
},
{
/* Test Case 15 */
"feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308",
"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255",
"",
"cafebabefacedbaddecaf888",
"522dc1f099567d07f47f37a32a84427d643a8cdcbfe5c0c97598a2bd2555d1aa8cb08e48590dbb3da7b08b1056828838c5f61e6393ba7a0abcc9f662898015ad",
"b094dac5d93471bdec1a502270e3cc6c"
},
{
/* Test Case 16 */
"feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308",
"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39",
"feedfacedeadbeeffeedfacedeadbeefabaddad2",
"cafebabefacedbaddecaf888",
"522dc1f099567d07f47f37a32a84427d643a8cdcbfe5c0c97598a2bd2555d1aa8cb08e48590dbb3da7b08b1056828838c5f61e6393ba7a0abcc9f662",
"76fc6ece0f4e1768cddf8853bb2d551b"
},
{
/* Test Case 17 */
"feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308",
"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39",
"feedfacedeadbeeffeedfacedeadbeefabaddad2",
"cafebabefacedbad",
"c3762df1ca787d32ae47c13bf19844cbaf1ae14d0b976afac52ff7d79bba9de0feb582d33934a4f0954cc2363bc73f7862ac430e64abe499f47c9b1f",
"3a337dbf46a792c45e454913fe2ea8f2"
},
{
/* Test Case 18 */
"feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308",
"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39",
"feedfacedeadbeeffeedfacedeadbeefabaddad2",
"9313225df88406e555909c5aff5269aa6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b525416aedbf5a0de6a57a637b39b",
"5a8def2f0c9e53f1f75d7853659e2a20eeb2b22aafde6419a058ab4f6f746bf40fc0c3b780f244452da3ebf1c5d82cdea2418997200ef82e44ae7e3f",
"a44a8266ee1c8eb0c8b5d4cf5ae9f19a"
}
};
static int test_gcm(void)
{
int ret = 0;
int i;
u8 k[32], aad[32], iv[64], t[16], tag[16];
u8 p[64], c[64], tmp[64];
size_t k_len, p_len, aad_len, iv_len;
for (i = 0; i < sizeof(gcm_tests) / sizeof(gcm_tests[0]); i++) {
const struct gcm_test_vector *tc = &gcm_tests[i];
k_len = os_strlen(tc->k) / 2;
if (hexstr2bin(tc->k, k, k_len)) {
printf("Invalid GCM test vector %d (k)\n", i);
ret++;
continue;
}
p_len = os_strlen(tc->p) / 2;
if (hexstr2bin(tc->p, p, p_len)) {
printf("Invalid GCM test vector %d (p)\n", i);
ret++;
continue;
}
aad_len = os_strlen(tc->aad) / 2;
if (hexstr2bin(tc->aad, aad, aad_len)) {
printf("Invalid GCM test vector %d (aad)\n", i);
ret++;
continue;
}
iv_len = os_strlen(tc->iv) / 2;
if (hexstr2bin(tc->iv, iv, iv_len)) {
printf("Invalid GCM test vector %d (iv)\n", i);
ret++;
continue;
}
if (hexstr2bin(tc->c, c, p_len)) {
printf("Invalid GCM test vector %d (c)\n", i);
ret++;
continue;
}
if (hexstr2bin(tc->t, t, sizeof(t))) {
printf("Invalid GCM test vector %d (t)\n", i);
ret++;
continue;
}
if (aes_gcm_ae(k, k_len, iv, iv_len, p, p_len, aad, aad_len,
tmp, tag) < 0) {
printf("GCM-AE failed (test case %d)\n", i);
ret++;
continue;
}
if (os_memcmp(c, tmp, p_len) != 0) {
printf("GCM-AE mismatch (test case %d)\n", i);
ret++;
}
if (os_memcmp(tag, t, sizeof(tag)) != 0) {
printf("GCM-AE tag mismatch (test case %d)\n", i);
ret++;
}
if (p_len == 0) {
if (aes_gmac(k, k_len, iv, iv_len, aad, aad_len, tag) <
0) {
printf("GMAC failed (test case %d)\n", i);
ret++;
continue;
}
if (os_memcmp(tag, t, sizeof(tag)) != 0) {
printf("GMAC tag mismatch (test case %d)\n", i);
ret++;
}
}
if (aes_gcm_ad(k, k_len, iv, iv_len, c, p_len, aad, aad_len,
t, tmp) < 0) {
printf("GCM-AD failed (test case %d)\n", i);
ret++;
continue;
}
if (os_memcmp(p, tmp, p_len) != 0) {
printf("GCM-AD mismatch (test case %d)\n", i);
ret++;
}
}
return ret;
}
/* OMAC1 AES-128 test vectors from
* http://csrc.nist.gov/CryptoToolkit/modes/proposedmodes/omac/omac-ad.pdf
* which are same as the examples from NIST SP800-38B
* http://csrc.nist.gov/CryptoToolkit/modes/800-38_Series_Publications/SP800-38B.pdf
*/
struct omac1_test_vector {
u8 k[16];
u8 msg[64];
int msg_len;
u8 tag[16];
};
static struct omac1_test_vector test_vectors[] =
{
{
{ 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c },
{ },
0,
{ 0xbb, 0x1d, 0x69, 0x29, 0xe9, 0x59, 0x37, 0x28,
0x7f, 0xa3, 0x7d, 0x12, 0x9b, 0x75, 0x67, 0x46 }
},
{
{ 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c },
{ 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a},
16,
{ 0x07, 0x0a, 0x16, 0xb4, 0x6b, 0x4d, 0x41, 0x44,
0xf7, 0x9b, 0xdd, 0x9d, 0xd0, 0x4a, 0x28, 0x7c }
},
{
{ 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c },
{ 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11 },
40,
{ 0xdf, 0xa6, 0x67, 0x47, 0xde, 0x9a, 0xe6, 0x30,
0x30, 0xca, 0x32, 0x61, 0x14, 0x97, 0xc8, 0x27 }
},
{
{ 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c },
{ 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,
0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 },
64,
{ 0x51, 0xf0, 0xbe, 0xbf, 0x7e, 0x3b, 0x9d, 0x92,
0xfc, 0x49, 0x74, 0x17, 0x79, 0x36, 0x3c, 0xfe }
},
};
int main(int argc, char *argv[])
{
u8 kek[] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
};
u8 plain[] = {
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff
};
u8 crypt[] = {
0x1F, 0xA6, 0x8B, 0x0A, 0x81, 0x12, 0xB4, 0x47,
0xAE, 0xF3, 0x4B, 0xD8, 0xFB, 0x5A, 0x7B, 0x82,
0x9D, 0x3E, 0x86, 0x23, 0x71, 0xD2, 0xCF, 0xE5
};
u8 result[24];
int ret = 0;
unsigned int i;
struct omac1_test_vector *tv;
if (aes_wrap(kek, 2, plain, result)) {
printf("AES-WRAP-128-128 reported failure\n");
ret++;
}
if (memcmp(result, crypt, 24) != 0) {
printf("AES-WRAP-128-128 failed\n");
ret++;
}
if (aes_unwrap(kek, 2, crypt, result)) {
printf("AES-UNWRAP-128-128 reported failure\n");
ret++;
}
if (memcmp(result, plain, 16) != 0) {
printf("AES-UNWRAP-128-128 failed\n");
ret++;
for (i = 0; i < 16; i++)
printf(" %02x", result[i]);
printf("\n");
}
test_aes_perf();
for (i = 0; i < sizeof(test_vectors) / sizeof(test_vectors[0]); i++) {
tv = &test_vectors[i];
if (omac1_aes_128(tv->k, tv->msg, tv->msg_len, result) ||
memcmp(result, tv->tag, 16) != 0) {
printf("OMAC1-AES-128 test vector %d failed\n", i);
ret++;
}
if (tv->msg_len > 1) {
const u8 *addr[2];
size_t len[2];
addr[0] = tv->msg;
len[0] = 1;
addr[1] = tv->msg + 1;
len[1] = tv->msg_len - 1;
if (omac1_aes_128_vector(tv->k, 2, addr, len,
result) ||
memcmp(result, tv->tag, 16) != 0) {
printf("OMAC1-AES-128(vector) test vector %d "
"failed\n", i);
ret++;
}
}
}
ret += test_eax();
ret += test_cbc();
ret += test_gcm();
if (ret)
printf("FAILED!\n");
return ret;
}

197
external/hostap/tests/test-asn1.c vendored Normal file
View File

@ -0,0 +1,197 @@
/*
* Testing tool for ASN.1 routines
* Copyright (c) 2006-2009, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
*/
#include "includes.h"
#include "common.h"
#include "tls/asn1.h"
extern int wpa_debug_level;
static const char * asn1_class_str(int class)
{
switch (class) {
case ASN1_CLASS_UNIVERSAL:
return "Universal";
case ASN1_CLASS_APPLICATION:
return "Application";
case ASN1_CLASS_CONTEXT_SPECIFIC:
return "Context-specific";
case ASN1_CLASS_PRIVATE:
return "Private";
default:
return "?";
}
}
int asn1_parse(const u8 *buf, size_t len, int level)
{
const u8 *pos, *prev, *end;
char prefix[10], str[100];
int _level;
struct asn1_hdr hdr;
struct asn1_oid oid;
u8 tmp;
_level = level;
if ((size_t) _level > sizeof(prefix) - 1)
_level = sizeof(prefix) - 1;
memset(prefix, ' ', _level);
prefix[_level] = '\0';
pos = buf;
end = buf + len;
while (pos < end) {
if (asn1_get_next(pos, end - pos, &hdr) < 0)
return -1;
prev = pos;
pos = hdr.payload;
wpa_printf(MSG_MSGDUMP, "ASN.1:%s Class %d(%s) P/C %d(%s) "
"Tag %u Length %u",
prefix, hdr.class, asn1_class_str(hdr.class),
hdr.constructed,
hdr.constructed ? "Constructed" : "Primitive",
hdr.tag, hdr.length);
if (hdr.class == ASN1_CLASS_CONTEXT_SPECIFIC &&
hdr.constructed) {
if (asn1_parse(pos, hdr.length, level + 1) < 0)
return -1;
pos += hdr.length;
}
if (hdr.class != ASN1_CLASS_UNIVERSAL)
continue;
switch (hdr.tag) {
case ASN1_TAG_EOC:
if (hdr.length) {
wpa_printf(MSG_DEBUG, "ASN.1: Non-zero "
"end-of-contents length (%u)",
hdr.length);
return -1;
}
wpa_printf(MSG_MSGDUMP, "ASN.1:%s EOC", prefix);
break;
case ASN1_TAG_BOOLEAN:
if (hdr.length != 1) {
wpa_printf(MSG_DEBUG, "ASN.1: Unexpected "
"Boolean length (%u)", hdr.length);
return -1;
}
tmp = *pos++;
wpa_printf(MSG_MSGDUMP, "ASN.1:%s Boolean %s",
prefix, tmp ? "TRUE" : "FALSE");
break;
case ASN1_TAG_INTEGER:
wpa_hexdump(MSG_MSGDUMP, "ASN.1: INTEGER",
pos, hdr.length);
pos += hdr.length;
break;
case ASN1_TAG_BITSTRING:
wpa_hexdump(MSG_MSGDUMP, "ASN.1: BitString",
pos, hdr.length);
pos += hdr.length;
break;
case ASN1_TAG_OCTETSTRING:
wpa_hexdump(MSG_MSGDUMP, "ASN.1: OctetString",
pos, hdr.length);
pos += hdr.length;
break;
case ASN1_TAG_NULL:
if (hdr.length) {
wpa_printf(MSG_DEBUG, "ASN.1: Non-zero Null "
"length (%u)", hdr.length);
return -1;
}
wpa_printf(MSG_MSGDUMP, "ASN.1:%s Null", prefix);
break;
case ASN1_TAG_OID:
if (asn1_get_oid(prev, end - prev, &oid, &prev) < 0) {
wpa_printf(MSG_DEBUG, "ASN.1: Invalid OID");
return -1;
}
asn1_oid_to_str(&oid, str, sizeof(str));
wpa_printf(MSG_DEBUG, "ASN.1:%s OID %s", prefix, str);
pos += hdr.length;
break;
case ANS1_TAG_RELATIVE_OID:
wpa_hexdump(MSG_MSGDUMP, "ASN.1: Relative OID",
pos, hdr.length);
pos += hdr.length;
break;
case ASN1_TAG_SEQUENCE:
wpa_printf(MSG_MSGDUMP, "ASN.1:%s SEQUENCE", prefix);
if (asn1_parse(pos, hdr.length, level + 1) < 0)
return -1;
pos += hdr.length;
break;
case ASN1_TAG_SET:
wpa_printf(MSG_MSGDUMP, "ASN.1:%s SET", prefix);
if (asn1_parse(pos, hdr.length, level + 1) < 0)
return -1;
pos += hdr.length;
break;
case ASN1_TAG_PRINTABLESTRING:
wpa_hexdump_ascii(MSG_MSGDUMP,
"ASN.1: PrintableString",
pos, hdr.length);
pos += hdr.length;
break;
case ASN1_TAG_IA5STRING:
wpa_hexdump_ascii(MSG_MSGDUMP, "ASN.1: IA5String",
pos, hdr.length);
pos += hdr.length;
break;
case ASN1_TAG_UTCTIME:
wpa_hexdump_ascii(MSG_MSGDUMP, "ASN.1: UTCTIME",
pos, hdr.length);
pos += hdr.length;
break;
case ASN1_TAG_VISIBLESTRING:
wpa_hexdump_ascii(MSG_MSGDUMP, "ASN.1: VisibleString",
pos, hdr.length);
pos += hdr.length;
break;
default:
wpa_printf(MSG_DEBUG, "ASN.1: Unknown tag %d",
hdr.tag);
return -1;
}
}
return 0;
}
int main(int argc, char *argv[])
{
FILE *f;
u8 buf[3000];
size_t len;
wpa_debug_level = 0;
f = fopen(argv[1], "rb");
if (f == NULL)
return -1;
len = fread(buf, 1, sizeof(buf), f);
fclose(f);
if (asn1_parse(buf, len, 0) < 0)
printf("Failed to parse DER ASN.1\n");
printf("\n\n");
return 0;
}

42
external/hostap/tests/test-base64.c vendored Normal file
View File

@ -0,0 +1,42 @@
/*
* Base64 encoding/decoding (RFC1341) - test program
* Copyright (c) 2005, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
*/
#include "utils/includes.h"
#include "utils/os.h"
#include "utils/base64.h"
int main(int argc, char *argv[])
{
FILE *f;
size_t len, elen;
unsigned char *buf, *e;
if (argc != 4) {
printf("Usage: base64 <encode|decode> <in file> <out file>\n");
return -1;
}
buf = (unsigned char *) os_readfile(argv[2], &len);
if (buf == NULL)
return -1;
if (strcmp(argv[1], "encode") == 0)
e = base64_encode(buf, len, &elen);
else
e = base64_decode(buf, len, &elen);
if (e == NULL)
return -2;
f = fopen(argv[3], "w");
if (f == NULL)
return -3;
fwrite(e, 1, elen, f);
fclose(f);
free(e);
return 0;
}

228
external/hostap/tests/test-https.c vendored Normal file
View File

@ -0,0 +1,228 @@
/*
* Testing tool for TLSv1 client routines using HTTPS
* Copyright (c) 2011, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
*/
#include "includes.h"
#include <netdb.h>
#include "common.h"
#include "crypto/tls.h"
extern int wpa_debug_level;
extern int wpa_debug_show_keys;
static void https_tls_event_cb(void *ctx, enum tls_event ev,
union tls_event_data *data)
{
wpa_printf(MSG_DEBUG, "HTTPS: TLS event %d", ev);
}
static struct wpabuf * https_recv(int s)
{
struct wpabuf *in;
int len, ret;
fd_set rfds;
struct timeval tv;
in = wpabuf_alloc(20000);
if (in == NULL)
return NULL;
FD_ZERO(&rfds);
FD_SET(s, &rfds);
tv.tv_sec = 5;
tv.tv_usec = 0;
wpa_printf(MSG_DEBUG, "Waiting for more data");
ret = select(s + 1, &rfds, NULL, NULL, &tv);
if (ret < 0) {
wpa_printf(MSG_ERROR, "select: %s", strerror(errno));
wpabuf_free(in);
return NULL;
}
if (ret == 0) {
/* timeout */
wpa_printf(MSG_INFO, "Timeout on waiting for data");
wpabuf_free(in);
return NULL;
}
len = recv(s, wpabuf_put(in, 0), wpabuf_tailroom(in), 0);
if (len < 0) {
wpa_printf(MSG_ERROR, "recv: %s", strerror(errno));
wpabuf_free(in);
return NULL;
}
if (len == 0) {
wpa_printf(MSG_DEBUG, "No more data available");
wpabuf_free(in);
return NULL;
}
wpa_printf(MSG_DEBUG, "Received %d bytes", len);
wpabuf_put(in, len);
return in;
}
static int https_client(int s, const char *path)
{
struct tls_config conf;
void *tls;
struct tls_connection *conn;
struct wpabuf *in, *out, *appl;
int res = -1;
int need_more_data;
os_memset(&conf, 0, sizeof(conf));
conf.event_cb = https_tls_event_cb;
tls = tls_init(&conf);
if (tls == NULL)
return -1;
conn = tls_connection_init(tls);
if (conn == NULL) {
tls_deinit(tls);
return -1;
}
in = NULL;
for (;;) {
appl = NULL;
out = tls_connection_handshake2(tls, conn, in, &appl,
&need_more_data);
wpabuf_free(in);
in = NULL;
if (out == NULL) {
if (need_more_data)
goto read_more;
goto done;
}
if (tls_connection_get_failed(tls, conn)) {
wpa_printf(MSG_ERROR, "TLS handshake failed");
goto done;
}
if (tls_connection_established(tls, conn))
break;
wpa_printf(MSG_DEBUG, "Sending %d bytes",
(int) wpabuf_len(out));
if (send(s, wpabuf_head(out), wpabuf_len(out), 0) < 0) {
wpa_printf(MSG_ERROR, "send: %s", strerror(errno));
goto done;
}
wpabuf_free(out);
out = NULL;
read_more:
in = https_recv(s);
if (in == NULL)
goto done;
}
wpabuf_free(out);
out = NULL;
wpa_printf(MSG_INFO, "TLS connection established");
if (appl)
wpa_hexdump_buf(MSG_DEBUG, "Received application data", appl);
in = wpabuf_alloc(100 + os_strlen(path));
if (in == NULL)
goto done;
wpabuf_put_str(in, "GET ");
wpabuf_put_str(in, path);
wpabuf_put_str(in, " HTTP/1.0\r\n\r\n");
out = tls_connection_encrypt(tls, conn, in);
wpabuf_free(in);
in = NULL;
if (out == NULL)
goto done;
wpa_printf(MSG_INFO, "Sending HTTP request: %d bytes",
(int) wpabuf_len(out));
if (send(s, wpabuf_head(out), wpabuf_len(out), 0) < 0) {
wpa_printf(MSG_ERROR, "send: %s", strerror(errno));
goto done;
}
wpabuf_free(out);
out = NULL;
wpa_printf(MSG_INFO, "Reading HTTP response");
for (;;) {
int need_more_data;
in = https_recv(s);
if (in == NULL)
goto done;
out = tls_connection_decrypt2(tls, conn, in, &need_more_data);
if (need_more_data)
wpa_printf(MSG_DEBUG, "HTTP: Need more data");
wpabuf_free(in);
in = NULL;
if (out == NULL)
goto done;
wpa_hexdump_ascii(MSG_INFO, "Response", wpabuf_head(out),
wpabuf_len(out));
wpabuf_free(out);
out = NULL;
}
res = 0;
done:
wpabuf_free(out);
wpabuf_free(in);
wpabuf_free(appl);
tls_connection_deinit(tls, conn);
tls_deinit(tls);
return res;
}
int main(int argc, char *argv[])
{
struct addrinfo hints, *result, *rp;
int res, s;
wpa_debug_level = 0;
wpa_debug_show_keys = 1;
if (argc < 4) {
wpa_printf(MSG_INFO, "usage: test-https server port path");
return -1;
}
os_memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
res = getaddrinfo(argv[1], argv[2], &hints, &result);
if (res) {
wpa_printf(MSG_ERROR, "getaddrinfo: %s", gai_strerror(res));
return -1;
}
for (rp = result; rp; rp = rp->ai_next) {
s = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
if (s < 0)
continue;
if (connect(s, rp->ai_addr, rp->ai_addrlen) == 0)
break;
close(s);
}
freeaddrinfo(result);
if (rp == NULL) {
wpa_printf(MSG_ERROR, "Could not connect");
return -1;
}
https_client(s, argv[3]);
close(s);
return 0;
}

72
external/hostap/tests/test-list.c vendored Normal file
View File

@ -0,0 +1,72 @@
/*
* Doubly-linked list - test program
* Copyright (c) 2009, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
*/
#include "utils/includes.h"
#include "utils/os.h"
#include "utils/list.h"
struct test {
struct dl_list list;
int value;
};
static void dump_list(struct dl_list *head)
{
struct test *t;
printf("dump:");
dl_list_for_each(t, head, struct test, list)
printf(" %d", t->value);
printf(" (len=%d%s)\n", dl_list_len(head),
dl_list_empty(head) ? " empty" : "");
}
int main(int argc, char *argv[])
{
struct dl_list head;
struct test *t, *tmp;
int i;
dl_list_init(&head);
dump_list(&head);
for (i = 0; i < 5; i++) {
t = os_zalloc(sizeof(*t));
if (t == NULL)
return -1;
t->value = i;
dl_list_add(&head, &t->list);
dump_list(&head);
}
for (i = 10; i > 5; i--) {
t = os_zalloc(sizeof(*t));
if (t == NULL)
return -1;
t->value = i;
dl_list_add_tail(&head, &t->list);
dump_list(&head);
}
i = 0;
dl_list_for_each(t, &head, struct test, list)
if (++i == 5)
break;
printf("move: %d\n", t->value);
dl_list_del(&t->list);
dl_list_add(&head, &t->list);
dump_list(&head);
dl_list_for_each_safe(t, tmp, &head, struct test, list) {
printf("delete: %d\n", t->value);
dl_list_del(&t->list);
os_free(t);
dump_list(&head);
}
return 0;
}

93
external/hostap/tests/test-md4.c vendored Normal file
View File

@ -0,0 +1,93 @@
/*
* Test program for MD4 (test vectors from RFC 1320)
* Copyright (c) 2006-2009, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
*/
#include "includes.h"
#include "common.h"
#include "crypto/crypto.h"
int main(int argc, char *argv[])
{
struct {
char *data;
char *hash;
} tests[] = {
{
"",
"\x31\xd6\xcf\xe0\xd1\x6a\xe9\x31"
"\xb7\x3c\x59\xd7\xe0\xc0\x89\xc0"
},
{
"a",
"\xbd\xe5\x2c\xb3\x1d\xe3\x3e\x46"
"\x24\x5e\x05\xfb\xdb\xd6\xfb\x24"
},
{
"abc",
"\xa4\x48\x01\x7a\xaf\x21\xd8\x52"
"\x5f\xc1\x0a\xe8\x7a\xa6\x72\x9d"
},
{
"message digest",
"\xd9\x13\x0a\x81\x64\x54\x9f\xe8"
"\x18\x87\x48\x06\xe1\xc7\x01\x4b"
},
{
"abcdefghijklmnopqrstuvwxyz",
"\xd7\x9e\x1c\x30\x8a\xa5\xbb\xcd"
"\xee\xa8\xed\x63\xdf\x41\x2d\xa9"
},
{
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
"0123456789",
"\x04\x3f\x85\x82\xf2\x41\xdb\x35"
"\x1c\xe6\x27\xe1\x53\xe7\xf0\xe4"
},
{
"12345678901234567890123456789012345678901234567890"
"123456789012345678901234567890",
"\xe3\x3b\x4d\xdc\x9c\x38\xf2\x19"
"\x9c\x3e\x7b\x16\x4f\xcc\x05\x36"
}
};
unsigned int i;
u8 hash[16];
const u8 *addr[2];
size_t len[2];
int errors = 0;
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
printf("MD4 test case %d:", i);
addr[0] = (u8 *) tests[i].data;
len[0] = strlen(tests[i].data);
md4_vector(1, addr, len, hash);
if (memcmp(hash, tests[i].hash, 16) != 0) {
printf(" FAIL");
errors++;
} else
printf(" OK");
if (len[0]) {
addr[0] = (u8 *) tests[i].data;
len[0] = strlen(tests[i].data);
addr[1] = (u8 *) tests[i].data + 1;
len[1] = strlen(tests[i].data) - 1;
md4_vector(1, addr, len, hash);
if (memcmp(hash, tests[i].hash, 16) != 0) {
printf(" FAIL");
errors++;
} else
printf(" OK");
}
printf("\n");
}
return errors;
}

93
external/hostap/tests/test-md5.c vendored Normal file
View File

@ -0,0 +1,93 @@
/*
* Test program for MD5 (test vectors from RFC 1321)
* Copyright (c) 2006, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
*/
#include "includes.h"
#include "common.h"
#include "crypto/crypto.h"
int main(int argc, char *argv[])
{
struct {
char *data;
char *hash;
} tests[] = {
{
"",
"\xd4\x1d\x8c\xd9\x8f\x00\xb2\x04"
"\xe9\x80\x09\x98\xec\xf8\x42\x7e"
},
{
"a",
"\x0c\xc1\x75\xb9\xc0\xf1\xb6\xa8"
"\x31\xc3\x99\xe2\x69\x77\x26\x61"
},
{
"abc",
"\x90\x01\x50\x98\x3c\xd2\x4f\xb0"
"\xd6\x96\x3f\x7d\x28\xe1\x7f\x72"
},
{
"message digest",
"\xf9\x6b\x69\x7d\x7c\xb7\x93\x8d"
"\x52\x5a\x2f\x31\xaa\xf1\x61\xd0"
},
{
"abcdefghijklmnopqrstuvwxyz",
"\xc3\xfc\xd3\xd7\x61\x92\xe4\x00"
"\x7d\xfb\x49\x6c\xca\x67\xe1\x3b"
},
{
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
"0123456789",
"\xd1\x74\xab\x98\xd2\x77\xd9\xf5"
"\xa5\x61\x1c\x2c\x9f\x41\x9d\x9f"
},
{
"12345678901234567890123456789012345678901234567890"
"123456789012345678901234567890",
"\x57\xed\xf4\xa2\x2b\xe3\xc9\x55"
"\xac\x49\xda\x2e\x21\x07\xb6\x7a"
}
};
unsigned int i;
u8 hash[16];
const u8 *addr[2];
size_t len[2];
int errors = 0;
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
printf("MD5 test case %d:", i);
addr[0] = (u8 *) tests[i].data;
len[0] = strlen(tests[i].data);
md5_vector(1, addr, len, hash);
if (memcmp(hash, tests[i].hash, 16) != 0) {
printf(" FAIL");
errors++;
} else
printf(" OK");
if (len[0]) {
addr[0] = (u8 *) tests[i].data;
len[0] = strlen(tests[i].data);
addr[1] = (u8 *) tests[i].data + 1;
len[1] = strlen(tests[i].data) - 1;
md5_vector(1, addr, len, hash);
if (memcmp(hash, tests[i].hash, 16) != 0) {
printf(" FAIL");
errors++;
} else
printf(" OK");
}
printf("\n");
}
return errors;
}

817
external/hostap/tests/test-milenage.c vendored Normal file
View File

@ -0,0 +1,817 @@
#include "includes.h"
#include "common.h"
#include "crypto/aes_wrap.h"
#include "crypto/milenage.h"
extern int wpa_debug_level;
/**
* milenage_opc - Determine OPc from OP and K
* @op: OP = 128-bit operator variant algorithm configuration field
* @k: K = 128-bit subscriber key
* @opc: Buffer for OPc = 128-bit value derived from OP and K
*/
static int milenage_opc(const u8 *op, const u8 *k, u8 *opc)
{
int i;
/* OP_C = OP XOR E_K(OP) */
if (aes_128_encrypt_block(k, op, opc) < 0)
return -1;
for (i = 0; i < 16; i++)
opc[i] ^= op[i];
return 0;
}
struct gsm_milenage_test_set {
u8 ki[16];
u8 rand[16];
u8 opc[16];
u8 sres1[4];
u8 sres2[4];
u8 kc[8];
};
static const struct gsm_milenage_test_set gsm_test_sets[] =
{
{
/* 3GPP TS 55.205 v6.0.0 - Test Set 1 */
{ 0x46, 0x5b, 0x5c, 0xe8, 0xb1, 0x99, 0xb4, 0x9f,
0xaa, 0x5f, 0x0a, 0x2e, 0xe2, 0x38, 0xa6, 0xbc },
{ 0x23, 0x55, 0x3c, 0xbe, 0x96, 0x37, 0xa8, 0x9d,
0x21, 0x8a, 0xe6, 0x4d, 0xae, 0x47, 0xbf, 0x35 },
{ 0xcd, 0x63, 0xcb, 0x71, 0x95, 0x4a, 0x9f, 0x4e,
0x48, 0xa5, 0x99, 0x4e, 0x37, 0xa0, 0x2b, 0xaf },
{ 0x46, 0xf8, 0x41, 0x6a },
{ 0xa5, 0x42, 0x11, 0xd5 },
{ 0xea, 0xe4, 0xbe, 0x82, 0x3a, 0xf9, 0xa0, 0x8b }
}, {
/* 3GPP TS 55.205 v6.0.0 - Test Set 2 */
{ 0xfe, 0xc8, 0x6b, 0xa6, 0xeb, 0x70, 0x7e, 0xd0,
0x89, 0x05, 0x75, 0x7b, 0x1b, 0xb4, 0x4b, 0x8f },
{ 0x9f, 0x7c, 0x8d, 0x02, 0x1a, 0xcc, 0xf4, 0xdb,
0x21, 0x3c, 0xcf, 0xf0, 0xc7, 0xf7, 0x1a, 0x6a },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22 }
}, {
/* 3GPP TS 55.205 v6.0.0 - Test Set 5 */
{ 0x6c, 0x38, 0xa1, 0x16, 0xac, 0x28, 0x0c, 0x45,
0x4f, 0x59, 0x33, 0x2e, 0xe3, 0x5c, 0x8c, 0x4f },
{ 0xee, 0x64, 0x66, 0xbc, 0x96, 0x20, 0x2c, 0x5a,
0x55, 0x7a, 0xbb, 0xef, 0xf8, 0xba, 0xbf, 0x63 },
{ 0x38, 0x03, 0xef, 0x53, 0x63, 0xb9, 0x47, 0xc6,
0xaa, 0xa2, 0x25, 0xe5, 0x8f, 0xae, 0x39, 0x34 },
{ 0x13, 0x68, 0x8f, 0x17 },
{ 0x16, 0xc8, 0x23, 0x3f },
{ 0xdf, 0x75, 0xbc, 0x5e, 0xa8, 0x99, 0x87, 0x9f }
}, {
/* 3GPP TS 55.205 v6.0.0 - Test Set 6 */
{ 0x2d, 0x60, 0x9d, 0x4d, 0xb0, 0xac, 0x5b, 0xf0,
0xd2, 0xc0, 0xde, 0x26, 0x70, 0x14, 0xde, 0x0d },
{ 0x19, 0x4a, 0xa7, 0x56, 0x01, 0x38, 0x96, 0xb7,
0x4b, 0x4a, 0x2a, 0x3b, 0x0a, 0xf4, 0x53, 0x9e },
{ 0xc3, 0x5a, 0x0a, 0xb0, 0xbc, 0xbf, 0xc9, 0x25,
0x2c, 0xaf, 0xf1, 0x5f, 0x24, 0xef, 0xbd, 0xe0 },
{ 0x55, 0x3d, 0x00, 0xb3 },
{ 0x8c, 0x25, 0xa1, 0x6c },
{ 0x84, 0xb4, 0x17, 0xae, 0x3a, 0xea, 0xb4, 0xf3 }
}, {
/* 3GPP TS 55.205 v6.0.0 - Test Set 7 */
{ 0xa5, 0x30, 0xa7, 0xfe, 0x42, 0x8f, 0xad, 0x10,
0x82, 0xc4, 0x5e, 0xdd, 0xfc, 0xe1, 0x38, 0x84 },
{ 0x3a, 0x4c, 0x2b, 0x32, 0x45, 0xc5, 0x0e, 0xb5,
0xc7, 0x1d, 0x08, 0x63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, 0xfb, 0xcd, 0x60, 0xaa }
}, {
/* 3GPP TS 55.205 v6.0.0 - Test Set 10 */
{ 0x0d, 0xa6, 0xf7, 0xba, 0x86, 0xd5, 0xea, 0xc8,
0xa1, 0x9c, 0xf5, 0x63, 0xac, 0x58, 0x64, 0x2d },
{ 0x67, 0x9a, 0xc4, 0xdb, 0xac, 0xd7, 0xd2, 0x33,
0xff, 0x9d, 0x68, 0x06, 0xf4, 0x14, 0x9c, 0xe3 },
{ 0x0d, 0xb1, 0x07, 0x1f, 0x87, 0x67, 0x56, 0x2c,
0xa4, 0x3a, 0x0a, 0x64, 0xc4, 0x1e, 0x8d, 0x08 },
{ 0x02, 0xd1, 0x3a, 0xcd },
{ 0x6f, 0xc3, 0x0f, 0xee },
{ 0xf0, 0xea, 0xa5, 0x0a, 0x1e, 0xdc, 0xeb, 0xb7 }
}, {
/* 3GPP TS 55.205 v6.0.0 - Test Set 11 */
{ 0x77, 0xb4, 0x58, 0x43, 0xc8, 0x8e, 0x58, 0xc1,
0x0d, 0x20, 0x26, 0x84, 0x51, 0x5e, 0xd4, 0x30 },
{ 0x4c, 0x47, 0xeb, 0x30, 0x76, 0xdc, 0x55, 0xfe,
0x51, 0x06, 0xcb, 0x20, 0x34, 0xb8, 0xcd, 0x78 },
{ 0xd4, 0x83, 0xaf, 0xae, 0x56, 0x24, 0x09, 0xa3,
0x26, 0xb5, 0xbb, 0x0b, 0x20, 0xc4, 0xd7, 0x62 },
{ 0x44, 0x38, 0x9d, 0x01 },
{ 0xae, 0xfa, 0x35, 0x7b },
{ 0x82, 0xdb, 0xab, 0x7f, 0x83, 0xf0, 0x63, 0xda }
}, {
/* 3GPP TS 55.205 v6.0.0 - Test Set 12 */
{ 0x72, 0x9b, 0x17, 0x72, 0x92, 0x70, 0xdd, 0x87,
0xcc, 0xdf, 0x1b, 0xfe, 0x29, 0xb4, 0xe9, 0xbb },
{ 0x31, 0x1c, 0x4c, 0x92, 0x97, 0x44, 0xd6, 0x75,
0xb7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9, 0x51, 0x00, 0xe2 },
{ 0xed, 0x29, 0xb2, 0xf1, 0xc2, 0x7f, 0x9f, 0x34 }
}
};
#define NUM_GSM_TESTS (sizeof(gsm_test_sets) / sizeof(gsm_test_sets[0]))
struct milenage_test_set {
u8 k[16];
u8 rand[16];
u8 sqn[6];
u8 amf[2];
u8 op[16];
u8 opc[16];
u8 f1[8];
u8 f1star[8];
u8 f2[8];
u8 f3[16];
u8 f4[16];
u8 f5[6];
u8 f5star[6];
};
static const struct milenage_test_set test_sets[] =
{
{
/* 3GPP TS 35.208 v6.0.0 - 4.3.1 Test Set 1 */
{ 0x46, 0x5b, 0x5c, 0xe8, 0xb1, 0x99, 0xb4, 0x9f,
0xaa, 0x5f, 0x0a, 0x2e, 0xe2, 0x38, 0xa6, 0xbc },
{ 0x23, 0x55, 0x3c, 0xbe, 0x96, 0x37, 0xa8, 0x9d,
0x21, 0x8a, 0xe6, 0x4d, 0xae, 0x47, 0xbf, 0x35 },
{ 0xff, 0x9b, 0xb4, 0xd0, 0xb6, 0x07 },
{ 0xb9, 0xb9 },
{ 0xcd, 0xc2, 0x02, 0xd5, 0x12, 0x3e, 0x20, 0xf6,
0x2b, 0x6d, 0x67, 0x6a, 0xc7, 0x2c, 0xb3, 0x18 },
{ 0xcd, 0x63, 0xcb, 0x71, 0x95, 0x4a, 0x9f, 0x4e,
0x48, 0xa5, 0x99, 0x4e, 0x37, 0xa0, 0x2b, 0xaf },
{ 0x4a, 0x9f, 0xfa, 0xc3, 0x54, 0xdf, 0xaf, 0xb3 },
{ 0x01, 0xcf, 0xaf, 0x9e, 0xc4, 0xe8, 0x71, 0xe9 },
{ 0xa5, 0x42, 0x11, 0xd5, 0xe3, 0xba, 0x50, 0xbf },
{ 0xb4, 0x0b, 0xa9, 0xa3, 0xc5, 0x8b, 0x2a, 0x05,
0xbb, 0xf0, 0xd9, 0x87, 0xb2, 0x1b, 0xf8, 0xcb },
{ 0xf7, 0x69, 0xbc, 0xd7, 0x51, 0x04, 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 0xb5, 0xf2, 0xda, 0x03, 0x88, 0x3b, 0x69, 0xf9,
0x6b, 0xf5, 0x2e, 0x02, 0x9e, 0xd9, 0xac, 0x45 },
{ 0xb4, 0x72, 0x13, 0x68, 0xbc, 0x16, 0xea, 0x67,
0x87, 0x5c, 0x55, 0x98, 0x68, 0x8b, 0xb0, 0xef },
{ 0x83, 0xcf, 0xd5, 0x4d, 0xb9, 0x13 },
{ 0x4f, 0x20, 0x39, 0x39, 0x2d, 0xdc }
}
};
#define NUM_TESTS (sizeof(test_sets) / sizeof(test_sets[0]))
int main(int argc, char *argv[])
{
u8 buf[16], buf2[16], buf3[16], buf4[16], buf5[16], opc[16];
u8 auts[14], sqn[6], _rand[16];
int ret = 0, res, i;
const struct milenage_test_set *t;
size_t res_len;
wpa_debug_level = 0;
printf("Milenage test sets\n");
for (i = 0; i < NUM_TESTS; i++) {
t = &test_sets[i];
printf("Test Set %d\n", i + 1);
milenage_opc(t->op, t->k, opc);
if (memcmp(opc, t->opc, 16) != 0) {
printf("- milenage_opc failed\n");
ret++;
}
if (milenage_f1(opc, t->k, t->rand, t->sqn, t->amf, buf, buf2)
|| memcmp(buf, t->f1, 8) != 0) {
printf("- milenage_f1 failed\n");
ret++;
}
if (memcmp(buf2, t->f1star, 8) != 0) {
printf("- milenage_f1* failed\n");
ret++;
}
if (milenage_f2345(opc, t->k, t->rand, buf, buf2, buf3, buf4,
buf5) ||
memcmp(buf, t->f2, 8) != 0) {
printf("- milenage_f2 failed\n");
ret++;
}
if (memcmp(buf2, t->f3, 16) != 0) {
printf("- milenage_f3 failed\n");
ret++;
}
if (memcmp(buf3, t->f4, 16) != 0) {
printf("- milenage_f4 failed\n");
ret++;
}
if (memcmp(buf4, t->f5, 6) != 0) {
printf("- milenage_f5 failed\n");
ret++;
}
if (memcmp(buf5, t->f5star, 6) != 0) {
printf("- milenage_f5* failed\n");
ret++;
}
}
printf("milenage_auts test:\n");
os_memcpy(auts, "\x4f\x20\x39\x39\x2d\xdd", 6);
os_memcpy(auts + 6, "\x4b\xb4\x31\x6e\xd4\xa1\x46\x88", 8);
res = milenage_auts(t->opc, t->k, t->rand, auts, buf);
printf("AUTS for test set %d: %d / SQN=%02x%02x%02x%02x%02x%02x\n",
i, res, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
if (res)
ret++;
os_memset(_rand, 0xaa, sizeof(_rand));
os_memcpy(auts,
"\x43\x68\x1a\xd3\xda\xf0\x06\xbc\xde\x40\x5a\x20\x72\x67",
14);
res = milenage_auts(t->opc, t->k, _rand, auts, buf);
printf("AUTS from a test USIM: %d / SQN=%02x%02x%02x%02x%02x%02x\n",
res, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
if (res)
ret++;
printf("milenage_generate test:\n");
os_memcpy(sqn, "\x00\x00\x00\x00\x40\x44", 6);
os_memcpy(_rand, "\x12\x69\xb8\x23\x41\x39\x35\x66\xfb\x99\x41\xe9\x84"
"\x4f\xe6\x2f", 16);
res_len = 8;
milenage_generate(t->opc, t->amf, t->k, sqn, _rand, buf, buf2, buf3,
buf4, &res_len);
wpa_hexdump(MSG_DEBUG, "SQN", sqn, 6);
wpa_hexdump(MSG_DEBUG, "RAND", _rand, 16);
wpa_hexdump(MSG_DEBUG, "AUTN", buf, 16);
wpa_hexdump(MSG_DEBUG, "IK", buf2, 16);
wpa_hexdump(MSG_DEBUG, "CK", buf3, 16);
wpa_hexdump(MSG_DEBUG, "RES", buf4, res_len);
printf("GSM-Milenage test sets\n");
for (i = 0; i < NUM_GSM_TESTS; i++) {
const struct gsm_milenage_test_set *g;
u8 sres[4], kc[8];
g = &gsm_test_sets[i];
printf("Test Set %d\n", i + 1);
gsm_milenage(g->opc, g->ki, g->rand, sres, kc);
if (memcmp(g->kc, kc, 8) != 0) {
printf("- gsm_milenage Kc failed\n");
ret++;
}
#ifdef GSM_MILENAGE_ALT_SRES
if (memcmp(g->sres2, sres, 4) != 0) {
printf("- gsm_milenage SRES#2 failed\n");
ret++;
}
#else /* GSM_MILENAGE_ALT_SRES */
if (memcmp(g->sres1, sres, 4) != 0) {
printf("- gsm_milenage SRES#1 failed\n");
ret++;
}
#endif /* GSM_MILENAGE_ALT_SRES */
}
if (ret)
printf("Something failed\n");
else
printf("OK\n");
return ret;
}

114
external/hostap/tests/test-ms_funcs.c vendored Normal file
View File

@ -0,0 +1,114 @@
/*
* Test program for ms_funcs
* Copyright (c) 2003-2006, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
*/
#include "crypto/ms_funcs.c"
int main(int argc, char *argv[])
{
/* Test vector from RFC2759 example */
char *username = "User";
char *password = "clientPass";
u8 auth_challenge[] = {
0x5B, 0x5D, 0x7C, 0x7D, 0x7B, 0x3F, 0x2F, 0x3E,
0x3C, 0x2C, 0x60, 0x21, 0x32, 0x26, 0x26, 0x28
};
u8 peer_challenge[] = {
0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, 0x26, 0x2A,
0x28, 0x29, 0x5F, 0x2B, 0x3A, 0x33, 0x7C, 0x7E
};
u8 challenge[] = { 0xD0, 0x2E, 0x43, 0x86, 0xBC, 0xE9, 0x12, 0x26 };
u8 password_hash[] = {
0x44, 0xEB, 0xBA, 0x8D, 0x53, 0x12, 0xB8, 0xD6,
0x11, 0x47, 0x44, 0x11, 0xF5, 0x69, 0x89, 0xAE
};
u8 nt_response[] = {
0x82, 0x30, 0x9E, 0xCD, 0x8D, 0x70, 0x8B, 0x5E,
0xA0, 0x8F, 0xAA, 0x39, 0x81, 0xCD, 0x83, 0x54,
0x42, 0x33, 0x11, 0x4A, 0x3D, 0x85, 0xD6, 0xDF
};
u8 password_hash_hash[] = {
0x41, 0xC0, 0x0C, 0x58, 0x4B, 0xD2, 0xD9, 0x1C,
0x40, 0x17, 0xA2, 0xA1, 0x2F, 0xA5, 0x9F, 0x3F
};
u8 authenticator_response[] = {
0x40, 0x7A, 0x55, 0x89, 0x11, 0x5F, 0xD0, 0xD6,
0x20, 0x9F, 0x51, 0x0F, 0xE9, 0xC0, 0x45, 0x66,
0x93, 0x2C, 0xDA, 0x56
};
u8 master_key[] = {
0xFD, 0xEC, 0xE3, 0x71, 0x7A, 0x8C, 0x83, 0x8C,
0xB3, 0x88, 0xE5, 0x27, 0xAE, 0x3C, 0xDD, 0x31
};
u8 send_start_key[] = {
0x8B, 0x7C, 0xDC, 0x14, 0x9B, 0x99, 0x3A, 0x1B,
0xA1, 0x18, 0xCB, 0x15, 0x3F, 0x56, 0xDC, 0xCB
};
u8 buf[32];
int errors = 0;
printf("Testing ms_funcs.c\n");
if (challenge_hash(peer_challenge, auth_challenge,
(u8 *) username, strlen(username),
buf) ||
memcmp(challenge, buf, sizeof(challenge)) != 0) {
printf("challenge_hash failed\n");
errors++;
}
if (nt_password_hash((u8 *) password, strlen(password), buf) ||
memcmp(password_hash, buf, sizeof(password_hash)) != 0) {
printf("nt_password_hash failed\n");
errors++;
}
if (generate_nt_response(auth_challenge, peer_challenge,
(u8 *) username, strlen(username),
(u8 *) password, strlen(password),
buf) ||
memcmp(nt_response, buf, sizeof(nt_response)) != 0) {
printf("generate_nt_response failed\n");
errors++;
}
if (hash_nt_password_hash(password_hash, buf) ||
memcmp(password_hash_hash, buf, sizeof(password_hash_hash)) != 0) {
printf("hash_nt_password_hash failed\n");
errors++;
}
if (generate_authenticator_response((u8 *) password, strlen(password),
peer_challenge, auth_challenge,
(u8 *) username, strlen(username),
nt_response, buf) ||
memcmp(authenticator_response, buf, sizeof(authenticator_response))
!= 0) {
printf("generate_authenticator_response failed\n");
errors++;
}
if (get_master_key(password_hash_hash, nt_response, buf) ||
memcmp(master_key, buf, sizeof(master_key)) != 0) {
printf("get_master_key failed\n");
errors++;
}
if (get_asymetric_start_key(master_key, buf, sizeof(send_start_key),
1, 1) ||
memcmp(send_start_key, buf, sizeof(send_start_key)) != 0) {
printf("get_asymetric_start_key failed\n");
errors++;
}
if (errors)
printf("FAILED! %d errors\n", errors);
return errors;
}

83
external/hostap/tests/test-printf.c vendored Normal file
View File

@ -0,0 +1,83 @@
/*
* printf format routines - test program
* Copyright (c) 2012, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
*/
#include "utils/includes.h"
#include "utils/os.h"
#include "utils/common.h"
struct test_data {
u8 *data;
size_t len;
char *encoded;
};
static const struct test_data tests[] = {
{ (u8 *) "abcde", 5, "abcde" },
{ (u8 *) "a\0b\nc\ed\re\tf", 11, "a\\0b\\nc\\ed\\re\\tf" },
{ (u8 *) "\x00\x31\x00\x32\x00\x39", 6, "\\x001\\0002\\09" },
{ (u8 *) "\n\n\n", 3, "\n\12\x0a" },
{ (u8 *) "\303\245\303\244\303\266\303\205\303\204\303\226", 12,
"\\xc3\\xa5\xc3\\xa4\\xc3\\xb6\\xc3\\x85\\xc3\\x84\\xc3\\x96" },
{ (u8 *) "\303\245\303\244\303\266\303\205\303\204\303\226", 12,
"\\303\\245\\303\\244\\303\\266\\303\\205\\303\\204\\303\\226" },
{ (u8 *) "\xe5\xe4\xf6\xc5\xc4\xd6", 6,
"\\xe5\\xe4\\xf6\\xc5\\xc4\\xd6" },
{ NULL, 0, NULL }
};
static void print_hex(const u8 *data, size_t len)
{
size_t i;
for (i = 0; i < len; i++)
printf(" %02x", data[i]);
}
int main(int argc, char *argv[])
{
int i;
size_t binlen;
char buf[100];
u8 bin[100];
int errors = 0;
for (i = 0; tests[i].data; i++) {
const struct test_data *test = &tests[i];
printf("%d:", i);
print_hex(test->data, test->len);
printf_encode(buf, sizeof(buf), test->data, test->len);
printf(" -> \"%s\"\n", buf);
binlen = printf_decode(bin, sizeof(bin), buf);
if (binlen != test->len ||
os_memcmp(bin, test->data, binlen) != 0) {
printf("Error in decoding#1:");
print_hex(bin, binlen);
printf("\n");
errors++;
}
binlen = printf_decode(bin, sizeof(bin), test->encoded);
if (binlen != test->len ||
os_memcmp(bin, test->data, binlen) != 0) {
printf("Error in decoding#2:");
print_hex(bin, binlen);
printf("\n");
errors++;
}
}
if (errors) {
printf("%d test(s) failed\n", errors);
return -1;
}
return 0;
}

250
external/hostap/tests/test-rc4.c vendored Normal file
View File

@ -0,0 +1,250 @@
/*
* Test program for RC4
* Copyright (c) 2011, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
*/
#include "includes.h"
#include "common.h"
#include "crypto/crypto.h"
struct rc4_test_vector {
size_t key_len;
const u8 *key;
const u8 *stream0;
const u8 *stream240;
const u8 *stream496;
const u8 *stream752;
const u8 *stream1008;
const u8 *stream1520;
const u8 *stream2032;
const u8 *stream3056;
const u8 *stream4080;
};
/* RFC 6229 test vectors */
static const struct rc4_test_vector tests[] = {
{
5, (u8 *) "\x01\x02\x03\x04\x05",
(u8 *) "\xb2\x39\x63\x05\xf0\x3d\xc0\x27\xcc\xc3\x52\x4a\x0a\x11\x18\xa8\x69\x82\x94\x4f\x18\xfc\x82\xd5\x89\xc4\x03\xa4\x7a\x0d\x09\x19",
(u8 *) "\x28\xcb\x11\x32\xc9\x6c\xe2\x86\x42\x1d\xca\xad\xb8\xb6\x9e\xae\x1c\xfc\xf6\x2b\x03\xed\xdb\x64\x1d\x77\xdf\xcf\x7f\x8d\x8c\x93",
(u8 *) "\x42\xb7\xd0\xcd\xd9\x18\xa8\xa3\x3d\xd5\x17\x81\xc8\x1f\x40\x41\x64\x59\x84\x44\x32\xa7\xda\x92\x3c\xfb\x3e\xb4\x98\x06\x61\xf6",
(u8 *) "\xec\x10\x32\x7b\xde\x2b\xee\xfd\x18\xf9\x27\x76\x80\x45\x7e\x22\xeb\x62\x63\x8d\x4f\x0b\xa1\xfe\x9f\xca\x20\xe0\x5b\xf8\xff\x2b",
(u8 *) "\x45\x12\x90\x48\xe6\xa0\xed\x0b\x56\xb4\x90\x33\x8f\x07\x8d\xa5\x30\xab\xbc\xc7\xc2\x0b\x01\x60\x9f\x23\xee\x2d\x5f\x6b\xb7\xdf",
(u8 *) "\x32\x94\xf7\x44\xd8\xf9\x79\x05\x07\xe7\x0f\x62\xe5\xbb\xce\xea\xd8\x72\x9d\xb4\x18\x82\x25\x9b\xee\x4f\x82\x53\x25\xf5\xa1\x30",
(u8 *) "\x1e\xb1\x4a\x0c\x13\xb3\xbf\x47\xfa\x2a\x0b\xa9\x3a\xd4\x5b\x8b\xcc\x58\x2f\x8b\xa9\xf2\x65\xe2\xb1\xbe\x91\x12\xe9\x75\xd2\xd7",
(u8 *) "\xf2\xe3\x0f\x9b\xd1\x02\xec\xbf\x75\xaa\xad\xe9\xbc\x35\xc4\x3c\xec\x0e\x11\xc4\x79\xdc\x32\x9d\xc8\xda\x79\x68\xfe\x96\x56\x81",
(u8 *) "\x06\x83\x26\xa2\x11\x84\x16\xd2\x1f\x9d\x04\xb2\xcd\x1c\xa0\x50\xff\x25\xb5\x89\x95\x99\x67\x07\xe5\x1f\xbd\xf0\x8b\x34\xd8\x75"
},
{
7, (u8 *) "\x01\x02\x03\x04\x05\x06\x07",
(u8 *) "\x29\x3f\x02\xd4\x7f\x37\xc9\xb6\x33\xf2\xaf\x52\x85\xfe\xb4\x6b\xe6\x20\xf1\x39\x0d\x19\xbd\x84\xe2\xe0\xfd\x75\x20\x31\xaf\xc1",
(u8 *) "\x91\x4f\x02\x53\x1c\x92\x18\x81\x0d\xf6\x0f\x67\xe3\x38\x15\x4c\xd0\xfd\xb5\x83\x07\x3c\xe8\x5a\xb8\x39\x17\x74\x0e\xc0\x11\xd5",
(u8 *) "\x75\xf8\x14\x11\xe8\x71\xcf\xfa\x70\xb9\x0c\x74\xc5\x92\xe4\x54\x0b\xb8\x72\x02\x93\x8d\xad\x60\x9e\x87\xa5\xa1\xb0\x79\xe5\xe4",
(u8 *) "\xc2\x91\x12\x46\xb6\x12\xe7\xe7\xb9\x03\xdf\xed\xa1\xda\xd8\x66\x32\x82\x8f\x91\x50\x2b\x62\x91\x36\x8d\xe8\x08\x1d\xe3\x6f\xc2",
(u8 *) "\xf3\xb9\xa7\xe3\xb2\x97\xbf\x9a\xd8\x04\x51\x2f\x90\x63\xef\xf1\x8e\xcb\x67\xa9\xba\x1f\x55\xa5\xa0\x67\xe2\xb0\x26\xa3\x67\x6f",
(u8 *) "\xd2\xaa\x90\x2b\xd4\x2d\x0d\x7c\xfd\x34\x0c\xd4\x58\x10\x52\x9f\x78\xb2\x72\xc9\x6e\x42\xea\xb4\xc6\x0b\xd9\x14\xe3\x9d\x06\xe3",
(u8 *) "\xf4\x33\x2f\xd3\x1a\x07\x93\x96\xee\x3c\xee\x3f\x2a\x4f\xf0\x49\x05\x45\x97\x81\xd4\x1f\xda\x7f\x30\xc1\xbe\x7e\x12\x46\xc6\x23",
(u8 *) "\xad\xfd\x38\x68\xb8\xe5\x14\x85\xd5\xe6\x10\x01\x7e\x3d\xd6\x09\xad\x26\x58\x1c\x0c\x5b\xe4\x5f\x4c\xea\x01\xdb\x2f\x38\x05\xd5",
(u8 *) "\xf3\x17\x2c\xef\xfc\x3b\x3d\x99\x7c\x85\xcc\xd5\xaf\x1a\x95\x0c\xe7\x4b\x0b\x97\x31\x22\x7f\xd3\x7c\x0e\xc0\x8a\x47\xdd\xd8\xb8"
},
{
8, (u8 *) "\x01\x02\x03\x04\x05\x06\x07\x08",
(u8 *) "\x97\xab\x8a\x1b\xf0\xaf\xb9\x61\x32\xf2\xf6\x72\x58\xda\x15\xa8\x82\x63\xef\xdb\x45\xc4\xa1\x86\x84\xef\x87\xe6\xb1\x9e\x5b\x09",
(u8 *) "\x96\x36\xeb\xc9\x84\x19\x26\xf4\xf7\xd1\xf3\x62\xbd\xdf\x6e\x18\xd0\xa9\x90\xff\x2c\x05\xfe\xf5\xb9\x03\x73\xc9\xff\x4b\x87\x0a",
(u8 *) "\x73\x23\x9f\x1d\xb7\xf4\x1d\x80\xb6\x43\xc0\xc5\x25\x18\xec\x63\x16\x3b\x31\x99\x23\xa6\xbd\xb4\x52\x7c\x62\x61\x26\x70\x3c\x0f",
(u8 *) "\x49\xd6\xc8\xaf\x0f\x97\x14\x4a\x87\xdf\x21\xd9\x14\x72\xf9\x66\x44\x17\x3a\x10\x3b\x66\x16\xc5\xd5\xad\x1c\xee\x40\xc8\x63\xd0",
(u8 *) "\x27\x3c\x9c\x4b\x27\xf3\x22\xe4\xe7\x16\xef\x53\xa4\x7d\xe7\xa4\xc6\xd0\xe7\xb2\x26\x25\x9f\xa9\x02\x34\x90\xb2\x61\x67\xad\x1d",
(u8 *) "\x1f\xe8\x98\x67\x13\xf0\x7c\x3d\x9a\xe1\xc1\x63\xff\x8c\xf9\xd3\x83\x69\xe1\xa9\x65\x61\x0b\xe8\x87\xfb\xd0\xc7\x91\x62\xaa\xfb",
(u8 *) "\x0a\x01\x27\xab\xb4\x44\x84\xb9\xfb\xef\x5a\xbc\xae\x1b\x57\x9f\xc2\xcd\xad\xc6\x40\x2e\x8e\xe8\x66\xe1\xf3\x7b\xdb\x47\xe4\x2c",
(u8 *) "\x26\xb5\x1e\xa3\x7d\xf8\xe1\xd6\xf7\x6f\xc3\xb6\x6a\x74\x29\xb3\xbc\x76\x83\x20\x5d\x4f\x44\x3d\xc1\xf2\x9d\xda\x33\x15\xc8\x7b",
(u8 *) "\xd5\xfa\x5a\x34\x69\xd2\x9a\xaa\xf8\x3d\x23\x58\x9d\xb8\xc8\x5b\x3f\xb4\x6e\x2c\x8f\x0f\x06\x8e\xdc\xe8\xcd\xcd\x7d\xfc\x58\x62"
},
{
10, (u8 *) "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a",
(u8 *) "\xed\xe3\xb0\x46\x43\xe5\x86\xcc\x90\x7d\xc2\x18\x51\x70\x99\x02\x03\x51\x6b\xa7\x8f\x41\x3b\xeb\x22\x3a\xa5\xd4\xd2\xdf\x67\x11",
(u8 *) "\x3c\xfd\x6c\xb5\x8e\xe0\xfd\xde\x64\x01\x76\xad\x00\x00\x04\x4d\x48\x53\x2b\x21\xfb\x60\x79\xc9\x11\x4c\x0f\xfd\x9c\x04\xa1\xad",
(u8 *) "\x3e\x8c\xea\x98\x01\x71\x09\x97\x90\x84\xb1\xef\x92\xf9\x9d\x86\xe2\x0f\xb4\x9b\xdb\x33\x7e\xe4\x8b\x8d\x8d\xc0\xf4\xaf\xef\xfe",
(u8 *) "\x5c\x25\x21\xea\xcd\x79\x66\xf1\x5e\x05\x65\x44\xbe\xa0\xd3\x15\xe0\x67\xa7\x03\x19\x31\xa2\x46\xa6\xc3\x87\x5d\x2f\x67\x8a\xcb",
(u8 *) "\xa6\x4f\x70\xaf\x88\xae\x56\xb6\xf8\x75\x81\xc0\xe2\x3e\x6b\x08\xf4\x49\x03\x1d\xe3\x12\x81\x4e\xc6\xf3\x19\x29\x1f\x4a\x05\x16",
(u8 *) "\xbd\xae\x85\x92\x4b\x3c\xb1\xd0\xa2\xe3\x3a\x30\xc6\xd7\x95\x99\x8a\x0f\xed\xdb\xac\x86\x5a\x09\xbc\xd1\x27\xfb\x56\x2e\xd6\x0a",
(u8 *) "\xb5\x5a\x0a\x5b\x51\xa1\x2a\x8b\xe3\x48\x99\xc3\xe0\x47\x51\x1a\xd9\xa0\x9c\xea\x3c\xe7\x5f\xe3\x96\x98\x07\x03\x17\xa7\x13\x39",
(u8 *) "\x55\x22\x25\xed\x11\x77\xf4\x45\x84\xac\x8c\xfa\x6c\x4e\xb5\xfc\x7e\x82\xcb\xab\xfc\x95\x38\x1b\x08\x09\x98\x44\x21\x29\xc2\xf8",
(u8 *) "\x1f\x13\x5e\xd1\x4c\xe6\x0a\x91\x36\x9d\x23\x22\xbe\xf2\x5e\x3c\x08\xb6\xbe\x45\x12\x4a\x43\xe2\xeb\x77\x95\x3f\x84\xdc\x85\x53"
},
{
16, (u8 *) "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10",
(u8 *) "\x9a\xc7\xcc\x9a\x60\x9d\x1e\xf7\xb2\x93\x28\x99\xcd\xe4\x1b\x97\x52\x48\xc4\x95\x90\x14\x12\x6a\x6e\x8a\x84\xf1\x1d\x1a\x9e\x1c",
(u8 *) "\x06\x59\x02\xe4\xb6\x20\xf6\xcc\x36\xc8\x58\x9f\x66\x43\x2f\x2b\xd3\x9d\x56\x6b\xc6\xbc\xe3\x01\x07\x68\x15\x15\x49\xf3\x87\x3f",
(u8 *) "\xb6\xd1\xe6\xc4\xa5\xe4\x77\x1c\xad\x79\x53\x8d\xf2\x95\xfb\x11\xc6\x8c\x1d\x5c\x55\x9a\x97\x41\x23\xdf\x1d\xbc\x52\xa4\x3b\x89",
(u8 *) "\xc5\xec\xf8\x8d\xe8\x97\xfd\x57\xfe\xd3\x01\x70\x1b\x82\xa2\x59\xec\xcb\xe1\x3d\xe1\xfc\xc9\x1c\x11\xa0\xb2\x6c\x0b\xc8\xfa\x4d",
(u8 *) "\xe7\xa7\x25\x74\xf8\x78\x2a\xe2\x6a\xab\xcf\x9e\xbc\xd6\x60\x65\xbd\xf0\x32\x4e\x60\x83\xdc\xc6\xd3\xce\xdd\x3c\xa8\xc5\x3c\x16",
(u8 *) "\xb4\x01\x10\xc4\x19\x0b\x56\x22\xa9\x61\x16\xb0\x01\x7e\xd2\x97\xff\xa0\xb5\x14\x64\x7e\xc0\x4f\x63\x06\xb8\x92\xae\x66\x11\x81",
(u8 *) "\xd0\x3d\x1b\xc0\x3c\xd3\x3d\x70\xdf\xf9\xfa\x5d\x71\x96\x3e\xbd\x8a\x44\x12\x64\x11\xea\xa7\x8b\xd5\x1e\x8d\x87\xa8\x87\x9b\xf5",
(u8 *) "\xfa\xbe\xb7\x60\x28\xad\xe2\xd0\xe4\x87\x22\xe4\x6c\x46\x15\xa3\xc0\x5d\x88\xab\xd5\x03\x57\xf9\x35\xa6\x3c\x59\xee\x53\x76\x23",
(u8 *) "\xff\x38\x26\x5c\x16\x42\xc1\xab\xe8\xd3\xc2\xfe\x5e\x57\x2b\xf8\xa3\x6a\x4c\x30\x1a\xe8\xac\x13\x61\x0c\xcb\xc1\x22\x56\xca\xcc"
},
{
24, (u8 *) "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18",
(u8 *) "\x05\x95\xe5\x7f\xe5\xf0\xbb\x3c\x70\x6e\xda\xc8\xa4\xb2\xdb\x11\xdf\xde\x31\x34\x4a\x1a\xf7\x69\xc7\x4f\x07\x0a\xee\x9e\x23\x26",
(u8 *) "\xb0\x6b\x9b\x1e\x19\x5d\x13\xd8\xf4\xa7\x99\x5c\x45\x53\xac\x05\x6b\xd2\x37\x8e\xc3\x41\xc9\xa4\x2f\x37\xba\x79\xf8\x8a\x32\xff",
(u8 *) "\xe7\x0b\xce\x1d\xf7\x64\x5a\xdb\x5d\x2c\x41\x30\x21\x5c\x35\x22\x9a\x57\x30\xc7\xfc\xb4\xc9\xaf\x51\xff\xda\x89\xc7\xf1\xad\x22",
(u8 *) "\x04\x85\x05\x5f\xd4\xf6\xf0\xd9\x63\xef\x5a\xb9\xa5\x47\x69\x82\x59\x1f\xc6\x6b\xcd\xa1\x0e\x45\x2b\x03\xd4\x55\x1f\x6b\x62\xac",
(u8 *) "\x27\x53\xcc\x83\x98\x8a\xfa\x3e\x16\x88\xa1\xd3\xb4\x2c\x9a\x02\x93\x61\x0d\x52\x3d\x1d\x3f\x00\x62\xb3\xc2\xa3\xbb\xc7\xc7\xf0",
(u8 *) "\x96\xc2\x48\x61\x0a\xad\xed\xfe\xaf\x89\x78\xc0\x3d\xe8\x20\x5a\x0e\x31\x7b\x3d\x1c\x73\xb9\xe9\xa4\x68\x8f\x29\x6d\x13\x3a\x19",
(u8 *) "\xbd\xf0\xe6\xc3\xcc\xa5\xb5\xb9\xd5\x33\xb6\x9c\x56\xad\xa1\x20\x88\xa2\x18\xb6\xe2\xec\xe1\xe6\x24\x6d\x44\xc7\x59\xd1\x9b\x10",
(u8 *) "\x68\x66\x39\x7e\x95\xc1\x40\x53\x4f\x94\x26\x34\x21\x00\x6e\x40\x32\xcb\x0a\x1e\x95\x42\xc6\xb3\xb8\xb3\x98\xab\xc3\xb0\xf1\xd5",
(u8 *) "\x29\xa0\xb8\xae\xd5\x4a\x13\x23\x24\xc6\x2e\x42\x3f\x54\xb4\xc8\x3c\xb0\xf3\xb5\x02\x0a\x98\xb8\x2a\xf9\xfe\x15\x44\x84\xa1\x68"
},
{
32, (u8 *) "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20",
(u8 *) "\xea\xa6\xbd\x25\x88\x0b\xf9\x3d\x3f\x5d\x1e\x4c\xa2\x61\x1d\x91\xcf\xa4\x5c\x9f\x7e\x71\x4b\x54\xbd\xfa\x80\x02\x7c\xb1\x43\x80",
(u8 *) "\x11\x4a\xe3\x44\xde\xd7\x1b\x35\xf2\xe6\x0f\xeb\xad\x72\x7f\xd8\x02\xe1\xe7\x05\x6b\x0f\x62\x39\x00\x49\x64\x22\x94\x3e\x97\xb6",
(u8 *) "\x91\xcb\x93\xc7\x87\x96\x4e\x10\xd9\x52\x7d\x99\x9c\x6f\x93\x6b\x49\xb1\x8b\x42\xf8\xe8\x36\x7c\xbe\xb5\xef\x10\x4b\xa1\xc7\xcd",
(u8 *) "\x87\x08\x4b\x3b\xa7\x00\xba\xde\x95\x56\x10\x67\x27\x45\xb3\x74\xe7\xa7\xb9\xe9\xec\x54\x0d\x5f\xf4\x3b\xdb\x12\x79\x2d\x1b\x35",
(u8 *) "\xc7\x99\xb5\x96\x73\x8f\x6b\x01\x8c\x76\xc7\x4b\x17\x59\xbd\x90\x7f\xec\x5b\xfd\x9f\x9b\x89\xce\x65\x48\x30\x90\x92\xd7\xe9\x58",
(u8 *) "\x40\xf2\x50\xb2\x6d\x1f\x09\x6a\x4a\xfd\x4c\x34\x0a\x58\x88\x15\x3e\x34\x13\x5c\x79\xdb\x01\x02\x00\x76\x76\x51\xcf\x26\x30\x73",
(u8 *) "\xf6\x56\xab\xcc\xf8\x8d\xd8\x27\x02\x7b\x2c\xe9\x17\xd4\x64\xec\x18\xb6\x25\x03\xbf\xbc\x07\x7f\xba\xbb\x98\xf2\x0d\x98\xab\x34",
(u8 *) "\x8a\xed\x95\xee\x5b\x0d\xcb\xfb\xef\x4e\xb2\x1d\x3a\x3f\x52\xf9\x62\x5a\x1a\xb0\x0e\xe3\x9a\x53\x27\x34\x6b\xdd\xb0\x1a\x9c\x18",
(u8 *) "\xa1\x3a\x7c\x79\xc7\xe1\x19\xb5\xab\x02\x96\xab\x28\xc3\x00\xb9\xf3\xe4\xc0\xa2\xe0\x2d\x1d\x01\xf7\xf0\xa7\x46\x18\xaf\x2b\x48"
},
{
5, (u8 *) "\x83\x32\x22\x77\x2a",
(u8 *) "\x80\xad\x97\xbd\xc9\x73\xdf\x8a\x2e\x87\x9e\x92\xa4\x97\xef\xda\x20\xf0\x60\xc2\xf2\xe5\x12\x65\x01\xd3\xd4\xfe\xa1\x0d\x5f\xc0",
(u8 *) "\xfa\xa1\x48\xe9\x90\x46\x18\x1f\xec\x6b\x20\x85\xf3\xb2\x0e\xd9\xf0\xda\xf5\xba\xb3\xd5\x96\x83\x98\x57\x84\x6f\x73\xfb\xfe\x5a",
(u8 *) "\x1c\x7e\x2f\xc4\x63\x92\x32\xfe\x29\x75\x84\xb2\x96\x99\x6b\xc8\x3d\xb9\xb2\x49\x40\x6c\xc8\xed\xff\xac\x55\xcc\xd3\x22\xba\x12",
(u8 *) "\xe4\xf9\xf7\xe0\x06\x61\x54\xbb\xd1\x25\xb7\x45\x56\x9b\xc8\x97\x75\xd5\xef\x26\x2b\x44\xc4\x1a\x9c\xf6\x3a\xe1\x45\x68\xe1\xb9",
(u8 *) "\x6d\xa4\x53\xdb\xf8\x1e\x82\x33\x4a\x3d\x88\x66\xcb\x50\xa1\xe3\x78\x28\xd0\x74\x11\x9c\xab\x5c\x22\xb2\x94\xd7\xa9\xbf\xa0\xbb",
(u8 *) "\xad\xb8\x9c\xea\x9a\x15\xfb\xe6\x17\x29\x5b\xd0\x4b\x8c\xa0\x5c\x62\x51\xd8\x7f\xd4\xaa\xae\x9a\x7e\x4a\xd5\xc2\x17\xd3\xf3\x00",
(u8 *) "\xe7\x11\x9b\xd6\xdd\x9b\x22\xaf\xe8\xf8\x95\x85\x43\x28\x81\xe2\x78\x5b\x60\xfd\x7e\xc4\xe9\xfc\xb6\x54\x5f\x35\x0d\x66\x0f\xab",
(u8 *) "\xaf\xec\xc0\x37\xfd\xb7\xb0\x83\x8e\xb3\xd7\x0b\xcd\x26\x83\x82\xdb\xc1\xa7\xb4\x9d\x57\x35\x8c\xc9\xfa\x6d\x61\xd7\x3b\x7c\xf0",
(u8 *) "\x63\x49\xd1\x26\xa3\x7a\xfc\xba\x89\x79\x4f\x98\x04\x91\x4f\xdc\xbf\x42\xc3\x01\x8c\x2f\x7c\x66\xbf\xde\x52\x49\x75\x76\x81\x15"
},
{
7, (u8 *) "\x19\x10\x83\x32\x22\x77\x2a",
(u8 *) "\xbc\x92\x22\xdb\xd3\x27\x4d\x8f\xc6\x6d\x14\xcc\xbd\xa6\x69\x0b\x7a\xe6\x27\x41\x0c\x9a\x2b\xe6\x93\xdf\x5b\xb7\x48\x5a\x63\xe3",
(u8 *) "\x3f\x09\x31\xaa\x03\xde\xfb\x30\x0f\x06\x01\x03\x82\x6f\x2a\x64\xbe\xaa\x9e\xc8\xd5\x9b\xb6\x81\x29\xf3\x02\x7c\x96\x36\x11\x81",
(u8 *) "\x74\xe0\x4d\xb4\x6d\x28\x64\x8d\x7d\xee\x8a\x00\x64\xb0\x6c\xfe\x9b\x5e\x81\xc6\x2f\xe0\x23\xc5\x5b\xe4\x2f\x87\xbb\xf9\x32\xb8",
(u8 *) "\xce\x17\x8f\xc1\x82\x6e\xfe\xcb\xc1\x82\xf5\x79\x99\xa4\x61\x40\x8b\xdf\x55\xcd\x55\x06\x1c\x06\xdb\xa6\xbe\x11\xde\x4a\x57\x8a",
(u8 *) "\x62\x6f\x5f\x4d\xce\x65\x25\x01\xf3\x08\x7d\x39\xc9\x2c\xc3\x49\x42\xda\xac\x6a\x8f\x9a\xb9\xa7\xfd\x13\x7c\x60\x37\x82\x56\x82",
(u8 *) "\xcc\x03\xfd\xb7\x91\x92\xa2\x07\x31\x2f\x53\xf5\xd4\xdc\x33\xd9\xf7\x0f\x14\x12\x2a\x1c\x98\xa3\x15\x5d\x28\xb8\xa0\xa8\xa4\x1d",
(u8 *) "\x2a\x3a\x30\x7a\xb2\x70\x8a\x9c\x00\xfe\x0b\x42\xf9\xc2\xd6\xa1\x86\x26\x17\x62\x7d\x22\x61\xea\xb0\xb1\x24\x65\x97\xca\x0a\xe9",
(u8 *) "\x55\xf8\x77\xce\x4f\x2e\x1d\xdb\xbf\x8e\x13\xe2\xcd\xe0\xfd\xc8\x1b\x15\x56\xcb\x93\x5f\x17\x33\x37\x70\x5f\xbb\x5d\x50\x1f\xc1",
(u8 *) "\xec\xd0\xe9\x66\x02\xbe\x7f\x8d\x50\x92\x81\x6c\xcc\xf2\xc2\xe9\x02\x78\x81\xfa\xb4\x99\x3a\x1c\x26\x20\x24\xa9\x4f\xff\x3f\x61"
},
{
8, (u8 *) "\x64\x19\x10\x83\x32\x22\x77\x2a",
(u8 *) "\xbb\xf6\x09\xde\x94\x13\x17\x2d\x07\x66\x0c\xb6\x80\x71\x69\x26\x46\x10\x1a\x6d\xab\x43\x11\x5d\x6c\x52\x2b\x4f\xe9\x36\x04\xa9",
(u8 *) "\xcb\xe1\xff\xf2\x1c\x96\xf3\xee\xf6\x1e\x8f\xe0\x54\x2c\xbd\xf0\x34\x79\x38\xbf\xfa\x40\x09\xc5\x12\xcf\xb4\x03\x4b\x0d\xd1\xa7",
(u8 *) "\x78\x67\xa7\x86\xd0\x0a\x71\x47\x90\x4d\x76\xdd\xf1\xe5\x20\xe3\x8d\x3e\x9e\x1c\xae\xfc\xcc\xb3\xfb\xf8\xd1\x8f\x64\x12\x0b\x32",
(u8 *) "\x94\x23\x37\xf8\xfd\x76\xf0\xfa\xe8\xc5\x2d\x79\x54\x81\x06\x72\xb8\x54\x8c\x10\xf5\x16\x67\xf6\xe6\x0e\x18\x2f\xa1\x9b\x30\xf7",
(u8 *) "\x02\x11\xc7\xc6\x19\x0c\x9e\xfd\x12\x37\xc3\x4c\x8f\x2e\x06\xc4\xbd\xa6\x4f\x65\x27\x6d\x2a\xac\xb8\xf9\x02\x12\x20\x3a\x80\x8e",
(u8 *) "\xbd\x38\x20\xf7\x32\xff\xb5\x3e\xc1\x93\xe7\x9d\x33\xe2\x7c\x73\xd0\x16\x86\x16\x86\x19\x07\xd4\x82\xe3\x6c\xda\xc8\xcf\x57\x49",
(u8 *) "\x97\xb0\xf0\xf2\x24\xb2\xd2\x31\x71\x14\x80\x8f\xb0\x3a\xf7\xa0\xe5\x96\x16\xe4\x69\x78\x79\x39\xa0\x63\xce\xea\x9a\xf9\x56\xd1",
(u8 *) "\xc4\x7e\x0d\xc1\x66\x09\x19\xc1\x11\x01\x20\x8f\x9e\x69\xaa\x1f\x5a\xe4\xf1\x28\x96\xb8\x37\x9a\x2a\xad\x89\xb5\xb5\x53\xd6\xb0",
(u8 *) "\x6b\x6b\x09\x8d\x0c\x29\x3b\xc2\x99\x3d\x80\xbf\x05\x18\xb6\xd9\x81\x70\xcc\x3c\xcd\x92\xa6\x98\x62\x1b\x93\x9d\xd3\x8f\xe7\xb9"
},
{
10, (u8 *) "\x8b\x37\x64\x19\x10\x83\x32\x22\x77\x2a",
(u8 *) "\xab\x65\xc2\x6e\xdd\xb2\x87\x60\x0d\xb2\xfd\xa1\x0d\x1e\x60\x5c\xbb\x75\x90\x10\xc2\x96\x58\xf2\xc7\x2d\x93\xa2\xd1\x6d\x29\x30",
(u8 *) "\xb9\x01\xe8\x03\x6e\xd1\xc3\x83\xcd\x3c\x4c\x4d\xd0\xa6\xab\x05\x3d\x25\xce\x49\x22\x92\x4c\x55\xf0\x64\x94\x33\x53\xd7\x8a\x6c",
(u8 *) "\x12\xc1\xaa\x44\xbb\xf8\x7e\x75\xe6\x11\xf6\x9b\x2c\x38\xf4\x9b\x28\xf2\xb3\x43\x4b\x65\xc0\x98\x77\x47\x00\x44\xc6\xea\x17\x0d",
(u8 *) "\xbd\x9e\xf8\x22\xde\x52\x88\x19\x61\x34\xcf\x8a\xf7\x83\x93\x04\x67\x55\x9c\x23\xf0\x52\x15\x84\x70\xa2\x96\xf7\x25\x73\x5a\x32",
(u8 *) "\x8b\xab\x26\xfb\xc2\xc1\x2b\x0f\x13\xe2\xab\x18\x5e\xab\xf2\x41\x31\x18\x5a\x6d\x69\x6f\x0c\xfa\x9b\x42\x80\x8b\x38\xe1\x32\xa2",
(u8 *) "\x56\x4d\x3d\xae\x18\x3c\x52\x34\xc8\xaf\x1e\x51\x06\x1c\x44\xb5\x3c\x07\x78\xa7\xb5\xf7\x2d\x3c\x23\xa3\x13\x5c\x7d\x67\xb9\xf4",
(u8 *) "\xf3\x43\x69\x89\x0f\xcf\x16\xfb\x51\x7d\xca\xae\x44\x63\xb2\xdd\x02\xf3\x1c\x81\xe8\x20\x07\x31\xb8\x99\xb0\x28\xe7\x91\xbf\xa7",
(u8 *) "\x72\xda\x64\x62\x83\x22\x8c\x14\x30\x08\x53\x70\x17\x95\x61\x6f\x4e\x0a\x8c\x6f\x79\x34\xa7\x88\xe2\x26\x5e\x81\xd6\xd0\xc8\xf4",
(u8 *) "\x43\x8d\xd5\xea\xfe\xa0\x11\x1b\x6f\x36\xb4\xb9\x38\xda\x2a\x68\x5f\x6b\xfc\x73\x81\x58\x74\xd9\x71\x00\xf0\x86\x97\x93\x57\xd8"
},
{
16, (u8 *) "\xeb\xb4\x62\x27\xc6\xcc\x8b\x37\x64\x19\x10\x83\x32\x22\x77\x2a",
(u8 *) "\x72\x0c\x94\xb6\x3e\xdf\x44\xe1\x31\xd9\x50\xca\x21\x1a\x5a\x30\xc3\x66\xfd\xea\xcf\x9c\xa8\x04\x36\xbe\x7c\x35\x84\x24\xd2\x0b",
(u8 *) "\xb3\x39\x4a\x40\xaa\xbf\x75\xcb\xa4\x22\x82\xef\x25\xa0\x05\x9f\x48\x47\xd8\x1d\xa4\x94\x2d\xbc\x24\x9d\xef\xc4\x8c\x92\x2b\x9f",
(u8 *) "\x08\x12\x8c\x46\x9f\x27\x53\x42\xad\xda\x20\x2b\x2b\x58\xda\x95\x97\x0d\xac\xef\x40\xad\x98\x72\x3b\xac\x5d\x69\x55\xb8\x17\x61",
(u8 *) "\x3c\xb8\x99\x93\xb0\x7b\x0c\xed\x93\xde\x13\xd2\xa1\x10\x13\xac\xef\x2d\x67\x6f\x15\x45\xc2\xc1\x3d\xc6\x80\xa0\x2f\x4a\xdb\xfe",
(u8 *) "\xb6\x05\x95\x51\x4f\x24\xbc\x9f\xe5\x22\xa6\xca\xd7\x39\x36\x44\xb5\x15\xa8\xc5\x01\x17\x54\xf5\x90\x03\x05\x8b\xdb\x81\x51\x4e",
(u8 *) "\x3c\x70\x04\x7e\x8c\xbc\x03\x8e\x3b\x98\x20\xdb\x60\x1d\xa4\x95\x11\x75\xda\x6e\xe7\x56\xde\x46\xa5\x3e\x2b\x07\x56\x60\xb7\x70",
(u8 *) "\x00\xa5\x42\xbb\xa0\x21\x11\xcc\x2c\x65\xb3\x8e\xbd\xba\x58\x7e\x58\x65\xfd\xbb\x5b\x48\x06\x41\x04\xe8\x30\xb3\x80\xf2\xae\xde",
(u8 *) "\x34\xb2\x1a\xd2\xad\x44\xe9\x99\xdb\x2d\x7f\x08\x63\xf0\xd9\xb6\x84\xa9\x21\x8f\xc3\x6e\x8a\x5f\x2c\xcf\xbe\xae\x53\xa2\x7d\x25",
(u8 *) "\xa2\x22\x1a\x11\xb8\x33\xcc\xb4\x98\xa5\x95\x40\xf0\x54\x5f\x4a\x5b\xbe\xb4\x78\x7d\x59\xe5\x37\x3f\xdb\xea\x6c\x6f\x75\xc2\x9b"
},
{
24, (u8 *) "\xc1\x09\x16\x39\x08\xeb\xe5\x1d\xeb\xb4\x62\x27\xc6\xcc\x8b\x37\x64\x19\x10\x83\x32\x22\x77\x2a",
(u8 *) "\x54\xb6\x4e\x6b\x5a\x20\xb5\xe2\xec\x84\x59\x3d\xc7\x98\x9d\xa7\xc1\x35\xee\xe2\x37\xa8\x54\x65\xff\x97\xdc\x03\x92\x4f\x45\xce",
(u8 *) "\xcf\xcc\x92\x2f\xb4\xa1\x4a\xb4\x5d\x61\x75\xaa\xbb\xf2\xd2\x01\x83\x7b\x87\xe2\xa4\x46\xad\x0e\xf7\x98\xac\xd0\x2b\x94\x12\x4f",
(u8 *) "\x17\xa6\xdb\xd6\x64\x92\x6a\x06\x36\xb3\xf4\xc3\x7a\x4f\x46\x94\x4a\x5f\x9f\x26\xae\xee\xd4\xd4\xa2\x5f\x63\x2d\x30\x52\x33\xd9",
(u8 *) "\x80\xa3\xd0\x1e\xf0\x0c\x8e\x9a\x42\x09\xc1\x7f\x4e\xeb\x35\x8c\xd1\x5e\x7d\x5f\xfa\xaa\xbc\x02\x07\xbf\x20\x0a\x11\x77\x93\xa2",
(u8 *) "\x34\x96\x82\xbf\x58\x8e\xaa\x52\xd0\xaa\x15\x60\x34\x6a\xea\xfa\xf5\x85\x4c\xdb\x76\xc8\x89\xe3\xad\x63\x35\x4e\x5f\x72\x75\xe3",
(u8 *) "\x53\x2c\x7c\xec\xcb\x39\xdf\x32\x36\x31\x84\x05\xa4\xb1\x27\x9c\xba\xef\xe6\xd9\xce\xb6\x51\x84\x22\x60\xe0\xd1\xe0\x5e\x3b\x90",
(u8 *) "\xe8\x2d\x8c\x6d\xb5\x4e\x3c\x63\x3f\x58\x1c\x95\x2b\xa0\x42\x07\x4b\x16\xe5\x0a\xbd\x38\x1b\xd7\x09\x00\xa9\xcd\x9a\x62\xcb\x23",
(u8 *) "\x36\x82\xee\x33\xbd\x14\x8b\xd9\xf5\x86\x56\xcd\x8f\x30\xd9\xfb\x1e\x5a\x0b\x84\x75\x04\x5d\x9b\x20\xb2\x62\x86\x24\xed\xfd\x9e",
(u8 *) "\x63\xed\xd6\x84\xfb\x82\x62\x82\xfe\x52\x8f\x9c\x0e\x92\x37\xbc\xe4\xdd\x2e\x98\xd6\x96\x0f\xae\x0b\x43\x54\x54\x56\x74\x33\x91"
},
{
32, (u8 *) "\x1a\xda\x31\xd5\xcf\x68\x82\x21\xc1\x09\x16\x39\x08\xeb\xe5\x1d\xeb\xb4\x62\x27\xc6\xcc\x8b\x37\x64\x19\x10\x83\x32\x22\x77\x2a",
(u8 *) "\xdd\x5b\xcb\x00\x18\xe9\x22\xd4\x94\x75\x9d\x7c\x39\x5d\x02\xd3\xc8\x44\x6f\x8f\x77\xab\xf7\x37\x68\x53\x53\xeb\x89\xa1\xc9\xeb",
(u8 *) "\xaf\x3e\x30\xf9\xc0\x95\x04\x59\x38\x15\x15\x75\xc3\xfb\x90\x98\xf8\xcb\x62\x74\xdb\x99\xb8\x0b\x1d\x20\x12\xa9\x8e\xd4\x8f\x0e",
(u8 *) "\x25\xc3\x00\x5a\x1c\xb8\x5d\xe0\x76\x25\x98\x39\xab\x71\x98\xab\x9d\xcb\xc1\x83\xe8\xcb\x99\x4b\x72\x7b\x75\xbe\x31\x80\x76\x9c",
(u8 *) "\xa1\xd3\x07\x8d\xfa\x91\x69\x50\x3e\xd9\xd4\x49\x1d\xee\x4e\xb2\x85\x14\xa5\x49\x58\x58\x09\x6f\x59\x6e\x4b\xcd\x66\xb1\x06\x65",
(u8 *) "\x5f\x40\xd5\x9e\xc1\xb0\x3b\x33\x73\x8e\xfa\x60\xb2\x25\x5d\x31\x34\x77\xc7\xf7\x64\xa4\x1b\xac\xef\xf9\x0b\xf1\x4f\x92\xb7\xcc",
(u8 *) "\xac\x4e\x95\x36\x8d\x99\xb9\xeb\x78\xb8\xda\x8f\x81\xff\xa7\x95\x8c\x3c\x13\xf8\xc2\x38\x8b\xb7\x3f\x38\x57\x6e\x65\xb7\xc4\x46",
(u8 *) "\x13\xc4\xb9\xc1\xdf\xb6\x65\x79\xed\xdd\x8a\x28\x0b\x9f\x73\x16\xdd\xd2\x78\x20\x55\x01\x26\x69\x8e\xfa\xad\xc6\x4b\x64\xf6\x6e",
(u8 *) "\xf0\x8f\x2e\x66\xd2\x8e\xd1\x43\xf3\xa2\x37\xcf\x9d\xe7\x35\x59\x9e\xa3\x6c\x52\x55\x31\xb8\x80\xba\x12\x43\x34\xf5\x7b\x0b\x70",
(u8 *) "\xd5\xa3\x9e\x3d\xfc\xc5\x02\x80\xba\xc4\xa6\xb5\xaa\x0d\xca\x7d\x37\x0b\x1c\x1f\xe6\x55\x91\x6d\x97\xfd\x0d\x47\xca\x1d\x72\xb8"
}
};
#define NUM_TESTS (sizeof(tests) / sizeof(tests[0]))
static int run_test(unsigned int i, const u8 *key, size_t key_len,
const u8 *stream, int offset)
{
u8 res[32];
os_memset(res, 0, sizeof(res));
if (rc4_skip(key, key_len, offset, res, sizeof(res)) < 0 ||
os_memcmp(res, stream, 32) != 0) {
printf("RC4 test case %d (offset %d) - FAILED!\n",
i + 1, offset);
return 1;
}
return 0;
}
int main(int argc, char *argv[])
{
int ret = 0;
unsigned int i;
for (i = 0; i < NUM_TESTS; i++) {
const struct rc4_test_vector *test = &tests[i];
ret += run_test(i, test->key, test->key_len,
test->stream0, 0);
ret += run_test(i, test->key, test->key_len,
test->stream240, 240);
ret += run_test(i, test->key, test->key_len,
test->stream496, 496);
ret += run_test(i, test->key, test->key_len,
test->stream752, 752);
ret += run_test(i, test->key, test->key_len,
test->stream1008, 1008);
ret += run_test(i, test->key, test->key_len,
test->stream1520, 1520);
ret += run_test(i, test->key, test->key_len,
test->stream2032, 2032);
ret += run_test(i, test->key, test->key_len,
test->stream3056, 3056);
ret += run_test(i, test->key, test->key_len,
test->stream4080, 4080);
}
if (ret == 0)
printf("All RC4 test cases passed\n");
return ret;
}

442
external/hostap/tests/test-sha1.c vendored Normal file
View File

@ -0,0 +1,442 @@
/*
* Test program for SHA1 and MD5
* Copyright (c) 2003-2006, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
*/
#include "includes.h"
#include "common.h"
#include "crypto/crypto.h"
#include "crypto/md5.h"
#include "crypto/sha1.h"
static int test_eap_fast(void)
{
/* RFC 4851, Appendix B.1 */
const u8 pac_key[] = {
0x0B, 0x97, 0x39, 0x0F, 0x37, 0x51, 0x78, 0x09,
0x81, 0x1E, 0xFD, 0x9C, 0x6E, 0x65, 0x94, 0x2B,
0x63, 0x2C, 0xE9, 0x53, 0x89, 0x38, 0x08, 0xBA,
0x36, 0x0B, 0x03, 0x7C, 0xD1, 0x85, 0xE4, 0x14
};
const u8 seed[] = {
0x3F, 0xFB, 0x11, 0xC4, 0x6C, 0xBF, 0xA5, 0x7A,
0x54, 0x40, 0xDA, 0xE8, 0x22, 0xD3, 0x11, 0xD3,
0xF7, 0x6D, 0xE4, 0x1D, 0xD9, 0x33, 0xE5, 0x93,
0x70, 0x97, 0xEB, 0xA9, 0xB3, 0x66, 0xF4, 0x2A,
0x00, 0x00, 0x00, 0x02, 0x6A, 0x66, 0x43, 0x2A,
0x8D, 0x14, 0x43, 0x2C, 0xEC, 0x58, 0x2D, 0x2F,
0xC7, 0x9C, 0x33, 0x64, 0xBA, 0x04, 0xAD, 0x3A,
0x52, 0x54, 0xD6, 0xA5, 0x79, 0xAD, 0x1E, 0x00
};
const u8 master_secret[] = {
0x4A, 0x1A, 0x51, 0x2C, 0x01, 0x60, 0xBC, 0x02,
0x3C, 0xCF, 0xBC, 0x83, 0x3F, 0x03, 0xBC, 0x64,
0x88, 0xC1, 0x31, 0x2F, 0x0B, 0xA9, 0xA2, 0x77,
0x16, 0xA8, 0xD8, 0xE8, 0xBD, 0xC9, 0xD2, 0x29,
0x38, 0x4B, 0x7A, 0x85, 0xBE, 0x16, 0x4D, 0x27,
0x33, 0xD5, 0x24, 0x79, 0x87, 0xB1, 0xC5, 0xA2
};
const u8 key_block[] = {
0x59, 0x59, 0xBE, 0x8E, 0x41, 0x3A, 0x77, 0x74,
0x8B, 0xB2, 0xE5, 0xD3, 0x60, 0xAC, 0x4D, 0x35,
0xDF, 0xFB, 0xC8, 0x1E, 0x9C, 0x24, 0x9C, 0x8B,
0x0E, 0xC3, 0x1D, 0x72, 0xC8, 0x84, 0x9D, 0x57,
0x48, 0x51, 0x2E, 0x45, 0x97, 0x6C, 0x88, 0x70,
0xBE, 0x5F, 0x01, 0xD3, 0x64, 0xE7, 0x4C, 0xBB,
0x11, 0x24, 0xE3, 0x49, 0xE2, 0x3B, 0xCD, 0xEF,
0x7A, 0xB3, 0x05, 0x39, 0x5D, 0x64, 0x8A, 0x44,
0x11, 0xB6, 0x69, 0x88, 0x34, 0x2E, 0x8E, 0x29,
0xD6, 0x4B, 0x7D, 0x72, 0x17, 0x59, 0x28, 0x05,
0xAF, 0xF9, 0xB7, 0xFF, 0x66, 0x6D, 0xA1, 0x96,
0x8F, 0x0B, 0x5E, 0x06, 0x46, 0x7A, 0x44, 0x84,
0x64, 0xC1, 0xC8, 0x0C, 0x96, 0x44, 0x09, 0x98,
0xFF, 0x92, 0xA8, 0xB4, 0xC6, 0x42, 0x28, 0x71
};
const u8 sks[] = {
0xD6, 0x4B, 0x7D, 0x72, 0x17, 0x59, 0x28, 0x05,
0xAF, 0xF9, 0xB7, 0xFF, 0x66, 0x6D, 0xA1, 0x96,
0x8F, 0x0B, 0x5E, 0x06, 0x46, 0x7A, 0x44, 0x84,
0x64, 0xC1, 0xC8, 0x0C, 0x96, 0x44, 0x09, 0x98,
0xFF, 0x92, 0xA8, 0xB4, 0xC6, 0x42, 0x28, 0x71
};
const u8 isk[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
const u8 imck[] = {
0x16, 0x15, 0x3C, 0x3F, 0x21, 0x55, 0xEF, 0xD9,
0x7F, 0x34, 0xAE, 0xC8, 0x1A, 0x4E, 0x66, 0x80,
0x4C, 0xC3, 0x76, 0xF2, 0x8A, 0xA9, 0x6F, 0x96,
0xC2, 0x54, 0x5F, 0x8C, 0xAB, 0x65, 0x02, 0xE1,
0x18, 0x40, 0x7B, 0x56, 0xBE, 0xEA, 0xA7, 0xC5,
0x76, 0x5D, 0x8F, 0x0B, 0xC5, 0x07, 0xC6, 0xB9,
0x04, 0xD0, 0x69, 0x56, 0x72, 0x8B, 0x6B, 0xB8,
0x15, 0xEC, 0x57, 0x7B
};
const u8 msk[] = {
0x4D, 0x83, 0xA9, 0xBE, 0x6F, 0x8A, 0x74, 0xED,
0x6A, 0x02, 0x66, 0x0A, 0x63, 0x4D, 0x2C, 0x33,
0xC2, 0xDA, 0x60, 0x15, 0xC6, 0x37, 0x04, 0x51,
0x90, 0x38, 0x63, 0xDA, 0x54, 0x3E, 0x14, 0xB9,
0x27, 0x99, 0x18, 0x1E, 0x07, 0xBF, 0x0F, 0x5A,
0x5E, 0x3C, 0x32, 0x93, 0x80, 0x8C, 0x6C, 0x49,
0x67, 0xED, 0x24, 0xFE, 0x45, 0x40, 0xA0, 0x59,
0x5E, 0x37, 0xC2, 0xE9, 0xD0, 0x5D, 0x0A, 0xE3
};
const u8 emsk[] = {
0x3A, 0xD4, 0xAB, 0xDB, 0x76, 0xB2, 0x7F, 0x3B,
0xEA, 0x32, 0x2C, 0x2B, 0x74, 0xF4, 0x28, 0x55,
0xEF, 0x2D, 0xBA, 0x78, 0xC9, 0x57, 0x2F, 0x0D,
0x06, 0xCD, 0x51, 0x7C, 0x20, 0x93, 0x98, 0xA9,
0x76, 0xEA, 0x70, 0x21, 0xD7, 0x0E, 0x25, 0x54,
0x97, 0xED, 0xB2, 0x8A, 0xF6, 0xED, 0xFD, 0x0A,
0x2A, 0xE7, 0xA1, 0x58, 0x90, 0x10, 0x50, 0x44,
0xB3, 0x82, 0x85, 0xDB, 0x06, 0x14, 0xD2, 0xF9
};
/* RFC 4851, Appendix B.2 */
u8 tlv[] = {
0x80, 0x0C, 0x00, 0x38, 0x00, 0x01, 0x01, 0x00,
0xD8, 0x6A, 0x8C, 0x68, 0x3C, 0x32, 0x31, 0xA8,
0x56, 0x63, 0xB6, 0x40, 0x21, 0xFE, 0x21, 0x14,
0x4E, 0xE7, 0x54, 0x20, 0x79, 0x2D, 0x42, 0x62,
0xC9, 0xBF, 0x53, 0x7F, 0x54, 0xFD, 0xAC, 0x58,
0x43, 0x24, 0x6E, 0x30, 0x92, 0x17, 0x6D, 0xCF,
0xE6, 0xE0, 0x69, 0xEB, 0x33, 0x61, 0x6A, 0xCC,
0x05, 0xC5, 0x5B, 0xB7
};
const u8 compound_mac[] = {
0x43, 0x24, 0x6E, 0x30, 0x92, 0x17, 0x6D, 0xCF,
0xE6, 0xE0, 0x69, 0xEB, 0x33, 0x61, 0x6A, 0xCC,
0x05, 0xC5, 0x5B, 0xB7
};
u8 buf[512];
const u8 *simck, *cmk;
int errors = 0;
printf("EAP-FAST test cases\n");
printf("- T-PRF (SHA1) test case / master_secret\n");
sha1_t_prf(pac_key, sizeof(pac_key), "PAC to master secret label hash",
seed, sizeof(seed), buf, sizeof(master_secret));
if (memcmp(master_secret, buf, sizeof(master_secret)) != 0) {
printf("T-PRF test - FAILED!\n");
errors++;
}
printf("- PRF (TLS, SHA1/MD5) test case / key_block\n");
if (tls_prf_sha1_md5(master_secret, sizeof(master_secret),
"key expansion", seed, sizeof(seed),
buf, sizeof(key_block)) ||
memcmp(key_block, buf, sizeof(key_block)) != 0) {
printf("PRF test - FAILED!\n");
errors++;
}
printf("- T-PRF (SHA1) test case / IMCK\n");
sha1_t_prf(sks, sizeof(sks), "Inner Methods Compound Keys",
isk, sizeof(isk), buf, sizeof(imck));
if (memcmp(imck, buf, sizeof(imck)) != 0) {
printf("T-PRF test - FAILED!\n");
errors++;
}
simck = imck;
cmk = imck + 40;
printf("- T-PRF (SHA1) test case / MSK\n");
sha1_t_prf(simck, 40, "Session Key Generating Function",
(u8 *) "", 0, buf, sizeof(msk));
if (memcmp(msk, buf, sizeof(msk)) != 0) {
printf("T-PRF test - FAILED!\n");
errors++;
}
printf("- T-PRF (SHA1) test case / EMSK\n");
sha1_t_prf(simck, 40, "Extended Session Key Generating Function",
(u8 *) "", 0, buf, sizeof(msk));
if (memcmp(emsk, buf, sizeof(emsk)) != 0) {
printf("T-PRF test - FAILED!\n");
errors++;
}
printf("- Compound MAC test case\n");
memset(tlv + sizeof(tlv) - 20, 0, 20);
hmac_sha1(cmk, 20, tlv, sizeof(tlv), tlv + sizeof(tlv) - 20);
if (memcmp(tlv + sizeof(tlv) - 20, compound_mac, sizeof(compound_mac))
!= 0) {
printf("Compound MAC test - FAILED!\n");
errors++;
}
return errors;
}
static u8 key0[] =
{
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
0x0b, 0x0b, 0x0b, 0x0b
};
static u8 data0[] = "Hi There";
static u8 prf0[] =
{
0xbc, 0xd4, 0xc6, 0x50, 0xb3, 0x0b, 0x96, 0x84,
0x95, 0x18, 0x29, 0xe0, 0xd7, 0x5f, 0x9d, 0x54,
0xb8, 0x62, 0x17, 0x5e, 0xd9, 0xf0, 0x06, 0x06,
0xe1, 0x7d, 0x8d, 0xa3, 0x54, 0x02, 0xff, 0xee,
0x75, 0xdf, 0x78, 0xc3, 0xd3, 0x1e, 0x0f, 0x88,
0x9f, 0x01, 0x21, 0x20, 0xc0, 0x86, 0x2b, 0xeb,
0x67, 0x75, 0x3e, 0x74, 0x39, 0xae, 0x24, 0x2e,
0xdb, 0x83, 0x73, 0x69, 0x83, 0x56, 0xcf, 0x5a
};
static u8 key1[] = "Jefe";
static u8 data1[] = "what do ya want for nothing?";
static u8 prf1[] =
{
0x51, 0xf4, 0xde, 0x5b, 0x33, 0xf2, 0x49, 0xad,
0xf8, 0x1a, 0xeb, 0x71, 0x3a, 0x3c, 0x20, 0xf4,
0x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 0xa6,
0x8f, 0x1c, 0xbd, 0x9e, 0x2b, 0x6f, 0x76, 0x07
};
struct passphrase_test {
char *passphrase;
char *ssid;
char psk[32];
};
static struct passphrase_test passphrase_tests[] =
{
{
"password",
"IEEE",
{
0xf4, 0x2c, 0x6f, 0xc5, 0x2d, 0xf0, 0xeb, 0xef,
0x9e, 0xbb, 0x4b, 0x90, 0xb3, 0x8a, 0x5f, 0x90,
0x2e, 0x83, 0xfe, 0x1b, 0x13, 0x5a, 0x70, 0xe2,
0x3a, 0xed, 0x76, 0x2e, 0x97, 0x10, 0xa1, 0x2e
}
},
{
"ThisIsAPassword",
"ThisIsASSID",
{
0x0d, 0xc0, 0xd6, 0xeb, 0x90, 0x55, 0x5e, 0xd6,
0x41, 0x97, 0x56, 0xb9, 0xa1, 0x5e, 0xc3, 0xe3,
0x20, 0x9b, 0x63, 0xdf, 0x70, 0x7d, 0xd5, 0x08,
0xd1, 0x45, 0x81, 0xf8, 0x98, 0x27, 0x21, 0xaf
}
},
{
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ",
{
0xbe, 0xcb, 0x93, 0x86, 0x6b, 0xb8, 0xc3, 0x83,
0x2c, 0xb7, 0x77, 0xc2, 0xf5, 0x59, 0x80, 0x7c,
0x8c, 0x59, 0xaf, 0xcb, 0x6e, 0xae, 0x73, 0x48,
0x85, 0x00, 0x13, 0x00, 0xa9, 0x81, 0xcc, 0x62
}
},
};
#define NUM_PASSPHRASE_TESTS \
(sizeof(passphrase_tests) / sizeof(passphrase_tests[0]))
struct rfc6070_test {
char *p;
char *s;
int c;
char dk[32];
size_t dk_len;
};
static struct rfc6070_test rfc6070_tests[] =
{
{
"password",
"salt",
1,
{
0x0c, 0x60, 0xc8, 0x0f, 0x96, 0x1f, 0x0e, 0x71,
0xf3, 0xa9, 0xb5, 0x24, 0xaf, 0x60, 0x12, 0x06,
0x2f, 0xe0, 0x37, 0xa6
},
20
},
{
"password",
"salt",
2,
{
0xea, 0x6c, 0x01, 0x4d, 0xc7, 0x2d, 0x6f, 0x8c,
0xcd, 0x1e, 0xd9, 0x2a, 0xce, 0x1d, 0x41, 0xf0,
0xd8, 0xde, 0x89, 0x57
},
20
},
{
"password",
"salt",
4096,
{
0x4b, 0x00, 0x79, 0x01, 0xb7, 0x65, 0x48, 0x9a,
0xbe, 0xad, 0x49, 0xd9, 0x26, 0xf7, 0x21, 0xd0,
0x65, 0xa4, 0x29, 0xc1
},
20
},
#if 0 /* This takes quite long to derive.. */
{
"password",
"salt",
16777216,
{
0xee, 0xfe, 0x3d, 0x61, 0xcd, 0x4d, 0xa4, 0xe4,
0xe9, 0x94, 0x5b, 0x3d, 0x6b, 0xa2, 0x15, 0x8c,
0x26, 0x34, 0xe9, 0x84
},
20
},
#endif
{
"passwordPASSWORDpassword",
"saltSALTsaltSALTsaltSALTsaltSALTsalt",
4096,
{
0x3d, 0x2e, 0xec, 0x4f, 0xe4, 0x1c, 0x84, 0x9b,
0x80, 0xc8, 0xd8, 0x36, 0x62, 0xc0, 0xe4, 0x4a,
0x8b, 0x29, 0x1a, 0x96, 0x4c, 0xf2, 0xf0, 0x70,
0x38
},
25
},
#if 0 /* \0 not currently supported in passphrase parameters.. */
{
"pass\0word",
"sa\0lt",
4096,
{
0x56, 0xfa, 0x6a, 0xa7, 0x55, 0x48, 0x09, 0x9d,
0xcc, 0x37, 0xd7, 0xf0, 0x34, 0x25, 0xe0, 0xc3
},
16
},
#endif
};
#define NUM_RFC6070_TESTS \
(sizeof(rfc6070_tests) / sizeof(rfc6070_tests[0]))
int main(int argc, char *argv[])
{
u8 res[512];
int ret = 0;
unsigned int i;
printf("PRF-SHA1 test cases:\n");
sha1_prf(key0, sizeof(key0), "prefix", data0, sizeof(data0) - 1,
res, sizeof(prf0));
if (memcmp(res, prf0, sizeof(prf0)) == 0)
printf("Test case 0 - OK\n");
else {
printf("Test case 0 - FAILED!\n");
ret++;
}
sha1_prf(key1, sizeof(key1) - 1, "prefix", data1, sizeof(data1) - 1,
res, sizeof(prf1));
if (memcmp(res, prf1, sizeof(prf1)) == 0)
printf("Test case 1 - OK\n");
else {
printf("Test case 1 - FAILED!\n");
ret++;
}
sha1_prf(key2, sizeof(key2), "prefix", data2, sizeof(data2),
res, sizeof(prf2));
if (memcmp(res, prf2, sizeof(prf2)) == 0)
printf("Test case 2 - OK\n");
else {
printf("Test case 2 - FAILED!\n");
ret++;
}
ret += test_eap_fast();
printf("PBKDF2-SHA1 Passphrase test cases:\n");
for (i = 0; i < NUM_PASSPHRASE_TESTS; i++) {
u8 psk[32];
struct passphrase_test *test = &passphrase_tests[i];
pbkdf2_sha1(test->passphrase,
test->ssid, strlen(test->ssid),
4096, psk, 32);
if (memcmp(psk, test->psk, 32) == 0)
printf("Test case %d - OK\n", i);
else {
printf("Test case %d - FAILED!\n", i);
ret++;
}
}
printf("PBKDF2-SHA1 test cases (RFC 6070):\n");
for (i = 0; i < NUM_RFC6070_TESTS; i++) {
u8 dk[25];
struct rfc6070_test *test = &rfc6070_tests[i];
pbkdf2_sha1(test->p, test->s, strlen(test->s), test->c,
dk, test->dk_len);
if (memcmp(dk, test->dk, test->dk_len) == 0)
printf("Test case %d - OK\n", i);
else {
printf("Test case %d - FAILED!\n", i);
ret++;
}
}
return ret;
}

325
external/hostap/tests/test-sha256.c vendored Normal file
View File

@ -0,0 +1,325 @@
/*
* Test program for SHA256
* Copyright (c) 2006, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
*/
#include "includes.h"
#include "common.h"
#include "crypto/sha256.h"
#include "crypto/crypto.h"
struct {
char *data;
u8 hash[32];
} tests[] = {
{
"abc",
{
0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea,
0x41, 0x41, 0x40, 0xde, 0x5d, 0xae, 0x22, 0x23,
0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c,
0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad
}
},
{
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
{
0x24, 0x8d, 0x6a, 0x61, 0xd2, 0x06, 0x38, 0xb8,
0xe5, 0xc0, 0x26, 0x93, 0x0c, 0x3e, 0x60, 0x39,
0xa3, 0x3c, 0xe4, 0x59, 0x64, 0xff, 0x21, 0x67,
0xf6, 0xec, 0xed, 0xd4, 0x19, 0xdb, 0x06, 0xc1
}
}
};
struct hmac_test {
u8 key[80];
size_t key_len;
u8 data[128];
size_t data_len;
u8 hash[32];
} hmac_tests[] = {
/* draft-ietf-ipsec-ciph-sha-256-01.txt */
{
{
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20
},
32,
"abc", 3,
{
0xa2, 0x1b, 0x1f, 0x5d, 0x4c, 0xf4, 0xf7, 0x3a,
0x4d, 0xd9, 0x39, 0x75, 0x0f, 0x7a, 0x06, 0x6a,
0x7f, 0x98, 0xcc, 0x13, 0x1c, 0xb1, 0x6a, 0x66,
0x92, 0x75, 0x90, 0x21, 0xcf, 0xab, 0x81, 0x81
}
},
{
{
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20
},
32,
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
56,
{
0x10, 0x4f, 0xdc, 0x12, 0x57, 0x32, 0x8f, 0x08,
0x18, 0x4b, 0xa7, 0x31, 0x31, 0xc5, 0x3c, 0xae,
0xe6, 0x98, 0xe3, 0x61, 0x19, 0x42, 0x11, 0x49,
0xea, 0x8c, 0x71, 0x24, 0x56, 0x69, 0x7d, 0x30
}
},
{
{
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20
},
32,
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
112,
{
0x47, 0x03, 0x05, 0xfc, 0x7e, 0x40, 0xfe, 0x34,
0xd3, 0xee, 0xb3, 0xe7, 0x73, 0xd9, 0x5a, 0xab,
0x73, 0xac, 0xf0, 0xfd, 0x06, 0x04, 0x47, 0xa5,
0xeb, 0x45, 0x95, 0xbf, 0x33, 0xa9, 0xd1, 0xa3
}
},
{
{
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b
},
32,
"Hi There",
8,
{
0x19, 0x8a, 0x60, 0x7e, 0xb4, 0x4b, 0xfb, 0xc6,
0x99, 0x03, 0xa0, 0xf1, 0xcf, 0x2b, 0xbd, 0xc5,
0xba, 0x0a, 0xa3, 0xf3, 0xd9, 0xae, 0x3c, 0x1c,
0x7a, 0x3b, 0x16, 0x96, 0xa0, 0xb6, 0x8c, 0xf7
}
},
{
"Jefe",
4,
"what do ya want for nothing?",
28,
{
0x5b, 0xdc, 0xc1, 0x46, 0xbf, 0x60, 0x75, 0x4e,
0x6a, 0x04, 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aa, 0xaa
},
80,
"Test Using Larger Than Block-Size Key and Larger Than One "
"Block-Size Data",
73,
{
0x63, 0x55, 0xac, 0x22, 0xe8, 0x90, 0xd0, 0xa3,
0xc8, 0x48, 0x1a, 0x5c, 0xa4, 0x82, 0x5b, 0xc8,
0x84, 0xd3, 0xe7, 0xa1, 0xff, 0x98, 0xa2, 0xfc,
0x2a, 0xc7, 0xd8, 0xe0, 0x64, 0xc3, 0xb2, 0xe6
}
}
};
int main(int argc, char *argv[])
{
unsigned int i;
u8 hash[32];
const u8 *addr[2];
size_t len[2];
int errors = 0;
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
printf("SHA256 test case %d:", i + 1);
addr[0] = (u8 *) tests[i].data;
len[0] = strlen(tests[i].data);
sha256_vector(1, addr, len, hash);
if (memcmp(hash, tests[i].hash, 32) != 0) {
printf(" FAIL");
errors++;
} else
printf(" OK");
if (len[0]) {
addr[0] = (u8 *) tests[i].data;
len[0] = 1;
addr[1] = (u8 *) tests[i].data + 1;
len[1] = strlen(tests[i].data) - 1;
sha256_vector(2, addr, len, hash);
if (memcmp(hash, tests[i].hash, 32) != 0) {
printf(" FAIL");
errors++;
} else
printf(" OK");
}
printf("\n");
}
for (i = 0; i < sizeof(hmac_tests) / sizeof(hmac_tests[0]); i++) {
struct hmac_test *t = &hmac_tests[i];
printf("HMAC-SHA256 test case %d:", i + 1);
hmac_sha256(t->key, t->key_len, t->data, t->data_len, hash);
if (memcmp(hash, t->hash, 32) != 0) {
printf(" FAIL");
errors++;
} else
printf(" OK");
addr[0] = t->data;
len[0] = t->data_len;
hmac_sha256_vector(t->key, t->key_len, 1, addr, len, hash);
if (memcmp(hash, t->hash, 32) != 0) {
printf(" FAIL");
errors++;
} else
printf(" OK");
if (len[0]) {
addr[0] = t->data;
len[0] = 1;
addr[1] = t->data + 1;
len[1] = t->data_len - 1;
hmac_sha256_vector(t->key, t->key_len, 2, addr, len,
hash);
if (memcmp(hash, t->hash, 32) != 0) {
printf(" FAIL");
errors++;
} else
printf(" OK");
}
printf("\n");
}
printf("Test IEEE 802.11r KDF\n");
sha256_prf((u8 *) "abc", 3, "KDF test", (u8 *) "data", 4,
hash, sizeof(hash));
/* TODO: add proper test case for this */
return errors;
}

38
external/hostap/tests/test-x509.c vendored Normal file
View File

@ -0,0 +1,38 @@
/*
* Testing tool for X.509v3 routines
* Copyright (c) 2006-2009, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
*/
#include "includes.h"
#include "common.h"
#include "tls/x509v3.h"
extern int wpa_debug_level;
int main(int argc, char *argv[])
{
FILE *f;
u8 buf[3000];
size_t len;
struct x509_certificate *cert;
wpa_debug_level = 0;
f = fopen(argv[1], "rb");
if (f == NULL)
return -1;
len = fread(buf, 1, sizeof(buf), f);
fclose(f);
cert = x509_certificate_parse(buf, len);
if (cert == NULL)
printf("Failed to parse X.509 certificate\n");
x509_certificate_free(cert);
return 0;
}

63
external/hostap/tests/test-x509v3.c vendored Normal file
View File

@ -0,0 +1,63 @@
/*
* Testing tool for X.509v3 routines
* Copyright (c) 2006-2007, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
*/
#include "includes.h"
#include "common.h"
#include "tls/asn1.h"
#include "tls/x509v3.h"
extern int wpa_debug_level;
int main(int argc, char *argv[])
{
char *buf;
size_t len;
struct x509_certificate *certs = NULL, *last = NULL, *cert;
int i, reason;
wpa_debug_level = 0;
if (argc < 3 || strcmp(argv[1], "-v") != 0) {
printf("usage: test_x509v3 -v <cert1.der> <cert2.der> ..\n");
return -1;
}
for (i = 2; i < argc; i++) {
printf("Reading: %s\n", argv[i]);
buf = os_readfile(argv[i], &len);
if (buf == NULL) {
printf("Failed to read '%s'\n", argv[i]);
return -1;
}
cert = x509_certificate_parse((u8 *) buf, len);
if (cert == NULL) {
printf("Failed to parse X.509 certificate\n");
return -1;
}
free(buf);
if (certs == NULL)
certs = cert;
else
last->next = cert;
last = cert;
}
printf("\n\nValidating certificate chain\n");
if (x509_certificate_chain_validate(last, certs, &reason, 0) < 0) {
printf("\nCertificate chain validation failed: %d\n", reason);
return -1;
}
printf("\nCertificate chain is valid\n");
return 0;
}

144
external/hostap/tests/test_x509v3_nist.sh vendored Executable file
View File

@ -0,0 +1,144 @@
#!/bin/bash
# X.509 Path Validation Test Suite, Version 1.07
# http://csrc.nist.gov/pki/testing/x509paths_old.html
# http://csrc.nist.gov/pki/testing/x509tests.tgz
if [ -z "$1" ]; then
echo "usage: $0 <path to X509tests directory>"
exit 1
fi
TESTS=$1
if [ ! -d $TESTS ]; then
echo "Not a directory: $TESTS"
exit 1
fi
X509TEST="./test-x509v3 -v"
TMPOUT=test_x509v3_nist.out
# TODO: add support for validating CRLs
END="End Certificate "
ROOT="Trust Anchor "
ICA="Intermediate Certificate "
SUCCESS=""
FAILURE=""
function run_test
{
NUM=$1
RES=$2
shift 2
$X509TEST "$@" > $TMPOUT.$NUM
VALRES=$?
OK=0
if [ $RES -eq 0 ]; then
# expecting success
if [ $VALRES -eq 0 ]; then
OK=1
else
echo "test$NUM failed - expected validation success"
OK=0
fi
else
# expecting failure
if [ $VALRES -eq 0 ]; then
echo "test$NUM failed - expected validation failure"
OK=0
else
REASON=`grep "Certificate chain validation failed: " $TMPOUT.$NUM`
if [ $? -eq 0 ]; then
REASONNUM=`echo "$REASON" | colrm 1 37`
if [ $REASONNUM -eq $RES ]; then
OK=1
else
echo "test$NUM failed - expected validation result $RES; result was $REASONNUM"
OK=0
fi
else
echo "test$NUM failed - expected validation failure; other type of error detected"
OK=0
fi
fi
fi
if [ $OK -eq 1 ]; then
rm $TMPOUT.$NUM
SUCCESS="$SUCCESS $NUM"
else
FAILURE="$FAILURE $NUM"
fi
}
P=$TESTS/test
run_test 1 0 "${P}1/${END}CP.01.01.crt" "${P}1/${ROOT}CP.01.01.crt"
run_test 2 1 "${P}2/${END}CP.01.02.crt" "${P}2/${ICA}CP.01.02.crt" "${P}2/${ROOT}CP.01.01.crt"
run_test 3 1 "${P}3/${END}CP.01.03.crt" "${P}3/${ICA}CP.01.03.crt" "${P}3/${ROOT}CP.01.01.crt"
run_test 4 0 "${P}4/${END}CP.02.01.crt" "${P}4/${ICA}2 CP.02.01.crt" "${P}4/${ICA}1 CP.02.01.crt" "${P}4/${ROOT}CP.01.01.crt"
run_test 5 4 "${P}5/${END}CP.02.02.crt" "${P}5/${ICA}CP.02.02.crt" "${P}5/${ROOT}CP.01.01.crt"
run_test 6 4 "${P}6/${END}CP.02.03.crt" "${P}6/${ICA}CP.02.03.crt" "${P}6/${ROOT}CP.01.01.crt"
run_test 7 0 "${P}7/${END}CP.02.04.crt" "${P}7/${ICA}CP.02.04.crt" "${P}7/${ROOT}CP.01.01.crt"
run_test 8 4 "${P}8/${END}CP.02.05.crt" "${P}8/${ICA}CP.02.05.crt" "${P}8/${ROOT}CP.01.01.crt"
run_test 9 4 "${P}9/${END}CP.03.01.crt" "${P}9/${ICA}CP.03.01.crt" "${P}9/${ROOT}CP.01.01.crt"
run_test 10 4 "${P}10/${END}CP.03.02.crt" "${P}10/${ICA}CP.03.02.crt" "${P}10/${ROOT}CP.01.01.crt"
run_test 11 4 "${P}11/${END}CP.03.03.crt" "${P}11/${ICA}CP.03.03.crt" "${P}11/${ROOT}CP.01.01.crt"
run_test 12 0 "${P}12/${END}CP.03.04.crt" "${P}12/${ICA}CP.03.04.crt" "${P}12/${ROOT}CP.01.01.crt"
run_test 13 5 "${P}13/${END}CP.04.01.crt" "${P}13/${ICA}CP.04.01.crt" "${P}13/${ROOT}CP.01.01.crt"
run_test 14 5 "${P}14/${END}CP.04.02.crt" "${P}14/${ICA}CP.04.02.crt" "${P}14/${ROOT}CP.01.01.crt"
run_test 15 0 "${P}15/${END}CP.04.03.crt" "${P}15/${ICA}CP.04.03.crt" "${P}15/${ROOT}CP.01.01.crt"
run_test 16 0 "${P}16/${END}CP.04.04.crt" "${P}16/${ICA}CP.04.04.crt" "${P}16/${ROOT}CP.01.01.crt"
run_test 17 0 "${P}17/${END}CP.04.05.crt" "${P}17/${ICA}CP.04.05.crt" "${P}17/${ROOT}CP.01.01.crt"
run_test 18 0 "${P}18/${END}CP.04.06.crt" "${P}18/${ICA}CP.04.06.crt" "${P}18/${ROOT}CP.01.01.crt"
run_test 19 1 "${P}19/${END}CP.05.01.crt" "${P}19/${ICA}CP.05.01.crt" "${P}19/${ROOT}CP.01.01.crt"
run_test 20 3 "${P}20/${END}CP.06.01.crt" "${P}20/${ICA}CP.06.01.crt" "${P}20/${ROOT}CP.01.01.crt"
run_test 21 3 "${P}21/${END}CP.06.02.crt" "${P}21/${ICA}CP.06.02.crt" "${P}21/${ROOT}CP.01.01.crt"
run_test 22 1 "${P}22/${END}IC.01.01.crt" "${P}22/${ICA}IC.01.01.crt" "${P}22/${ROOT}CP.01.01.crt"
run_test 23 1 "${P}23/${END}IC.02.01.crt" "${P}23/${ICA}IC.02.01.crt" "${P}23/${ROOT}CP.01.01.crt"
run_test 24 0 "${P}24/${END}IC.02.02.crt" "${P}24/${ICA}IC.02.02.crt" "${P}24/${ROOT}CP.01.01.crt"
run_test 25 1 "${P}25/${END}IC.02.03.crt" "${P}25/${ICA}IC.02.03.crt" "${P}25/${ROOT}CP.01.01.crt"
run_test 26 0 "${P}26/${END}IC.02.04.crt" "${P}26/${ICA}IC.02.04.crt" "${P}26/${ROOT}CP.01.01.crt"
run_test 27 0 "${P}27/${END}IC.04.01.crt" "${P}27/${ICA}IC.04.01.crt" "${P}27/${ROOT}CP.01.01.crt"
run_test 28 1 "${P}28/${END}IC.05.01.crt" "${P}28/${ICA}IC.05.01.crt" "${P}28/${ROOT}CP.01.01.crt"
run_test 29 1 "${P}29/${END}IC.05.02.crt" "${P}29/${ICA}IC.05.02.crt" "${P}29/${ROOT}CP.01.01.crt"
run_test 30 0 "${P}30/${END}IC.05.03.crt" "${P}30/${ICA}IC.05.03.crt" "${P}30/${ROOT}CP.01.01.crt"
run_test 31 1 "${P}31/${END}IC.06.01.crt" "${P}31/${ICA}IC.06.01.crt" "${P}31/${ROOT}CP.01.01.crt"
run_test 32 1 "${P}32/${END}IC.06.02.crt" "${P}32/${ICA}IC.06.02.crt" "${P}32/${ROOT}CP.01.01.crt"
run_test 33 0 "${P}33/${END}IC.06.03.crt" "${P}33/${ICA}IC.06.03.crt" "${P}33/${ROOT}CP.01.01.crt"
run_test 34 0 "${P}34/${END}PP.01.01.crt" "${P}34/${ICA}PP.01.01.crt" "${P}34/${ROOT}CP.01.01.crt"
run_test 35 0 "${P}35/${END}PP.01.02.crt" "${P}35/${ICA}PP.01.02.crt" "${P}35/${ROOT}CP.01.01.crt"
run_test 36 0 "${P}36/${END}PP.01.03.crt" "${P}36/${ICA}2 PP.01.03.crt" "${P}36/${ICA}1 PP.01.03.crt" "${P}36/${ROOT}CP.01.01.crt"
run_test 37 0 "${P}37/${END}PP.01.04.crt" "${P}37/${ICA}2 PP.01.04.crt" "${P}37/${ICA}1 PP.01.04.crt" "${P}37/${ROOT}CP.01.01.crt"
run_test 38 0 "${P}38/${END}PP.01.05.crt" "${P}38/${ICA}2 PP.01.05.crt" "${P}38/${ICA}1 PP.01.05.crt" "${P}38/${ROOT}CP.01.01.crt"
run_test 39 0 "${P}39/${END}PP.01.06.crt" "${P}39/${ICA}3 PP.01.06.crt" "${P}39/${ICA}2 PP.01.06.crt" "${P}39/${ICA}1 PP.01.06.crt" "${P}39/${ROOT}CP.01.01.crt"
run_test 40 0 "${P}40/${END}PP.01.07.crt" "${P}40/${ICA}3 PP.01.07.crt" "${P}40/${ICA}2 PP.01.07.crt" "${P}40/${ICA}1 PP.01.07.crt" "${P}40/${ROOT}CP.01.01.crt"
run_test 41 0 "${P}41/${END}PP.01.08.crt" "${P}41/${ICA}3 PP.01.08.crt" "${P}41/${ICA}2 PP.01.08.crt" "${P}41/${ICA}1 PP.01.08.crt" "${P}41/${ROOT}CP.01.01.crt"
run_test 42 0 "${P}42/${END}PP.01.09.crt" "${P}42/${ICA}4 PP.01.09.crt" "${P}42/${ICA}3 PP.01.09.crt" "${P}42/${ICA}2 PP.01.09.crt" "${P}42/${ICA}1 PP.01.09.crt" "${P}42/${ROOT}CP.01.01.crt"
run_test 43 0 "${P}43/${END}PP.06.01.crt" "${P}43/${ICA}4 PP.06.01.crt" "${P}43/${ICA}3 PP.06.01.crt" "${P}43/${ICA}2 PP.06.01.crt" "${P}43/${ICA}1 PP.06.01.crt" "${P}43/${ROOT}CP.01.01.crt"
run_test 44 0 "${P}44/${END}PP.06.02.crt" "${P}44/${ICA}4 PP.06.02.crt" "${P}44/${ICA}3 PP.06.02.crt" "${P}44/${ICA}2 PP.06.02.crt" "${P}44/${ICA}1 PP.06.02.crt" "${P}44/${ROOT}CP.01.01.crt"
run_test 45 0 "${P}45/${END}PP.06.03.crt" "${P}45/${ICA}4 PP.06.03.crt" "${P}45/${ICA}3 PP.06.03.crt" "${P}45/${ICA}2 PP.06.03.crt" "${P}45/${ICA}1 PP.06.03.crt" "${P}45/${ROOT}CP.01.01.crt"
run_test 46 0 "${P}46/${END}PP.06.04.crt" "${P}46/${ICA}4 PP.06.04.crt" "${P}46/${ICA}3 PP.06.04.crt" "${P}46/${ICA}2 PP.06.04.crt" "${P}46/${ICA}1 PP.06.04.crt" "${P}46/${ROOT}CP.01.01.crt"
run_test 47 0 "${P}47/${END}PP.06.05.crt" "${P}47/${ICA}4 PP.06.05.crt" "${P}47/${ICA}3 PP.06.05.crt" "${P}47/${ICA}2 PP.06.05.crt" "${P}47/${ICA}1 PP.06.05.crt" "${P}47/${ROOT}CP.01.01.crt"
run_test 48 0 "${P}48/${END}PP.08.01.crt" "${P}48/${ICA}PP.08.01.crt" "${P}48/${ROOT}CP.01.01.crt"
run_test 49 0 "${P}49/${END}PP.08.02.crt" "${P}49/${ICA}PP.08.02.crt" "${P}49/${ROOT}CP.01.01.crt"
run_test 50 0 "${P}50/${END}PP.08.03.crt" "${P}50/${ICA}PP.08.03.crt" "${P}50/${ROOT}CP.01.01.crt"
run_test 51 0 "${P}51/${END}PP.08.04.crt" "${P}51/${ICA}PP.08.04.crt" "${P}51/${ROOT}CP.01.01.crt"
run_test 52 0 "${P}52/${END}PP.08.05.crt" "${P}52/${ICA}PP.08.05.crt" "${P}52/${ROOT}CP.01.01.crt"
run_test 53 0 "${P}53/${END}PP.08.06.crt" "${P}53/${ICA}PP.08.06.crt" "${P}53/${ROOT}CP.01.01.crt"
run_test 54 1 "${P}54/${END}PL.01.01.crt" "${P}54/${ICA}2 PL.01.01.crt" "${P}54/${ICA}1 PL.01.01.crt" "${P}54/${ROOT}CP.01.01.crt"
run_test 55 1 "${P}55/${END}PL.01.02.crt" "${P}55/${ICA}2 PL.01.02.crt" "${P}55/${ICA}1 PL.01.02.crt" "${P}55/${ROOT}CP.01.01.crt"
run_test 56 0 "${P}56/${END}PL.01.03.crt" "${P}56/${ICA}PL.01.03.crt" "${P}56/${ROOT}CP.01.01.crt"
run_test 57 0 "${P}57/${END}PL.01.04.crt" "${P}57/${ICA}PL.01.04.crt" "${P}57/${ROOT}CP.01.01.crt"
run_test 58 1 "${P}58/${END}PL.01.05.crt" "${P}58/${ICA}3 PL.01.05.crt" "${P}58/${ICA}2 PL.01.05.crt" "${P}58/${ICA}1 PL.01.05.crt" "${P}58/${ROOT}CP.01.01.crt"
run_test 59 1 "${P}59/${END}PL.01.06.crt" "${P}59/${ICA}3 PL.01.06.crt" "${P}59/${ICA}2 PL.01.06.crt" "${P}59/${ICA}1 PL.01.06.crt" "${P}59/${ROOT}CP.01.01.crt"
run_test 60 1 "${P}60/${END}PL.01.07.crt" "${P}60/${ICA}4 PL.01.07.crt" "${P}60/${ICA}3 PL.01.07.crt" "${P}60/${ICA}2 PL.01.07.crt" "${P}60/${ICA}1 PL.01.07.crt" "${P}60/${ROOT}CP.01.01.crt"
run_test 61 1 "${P}61/${END}PL.01.08.crt" "${P}61/${ICA}4 PL.01.08.crt" "${P}61/${ICA}3 PL.01.08.crt" "${P}61/${ICA}2 PL.01.08.crt" "${P}61/${ICA}1 PL.01.08.crt" "${P}61/${ROOT}CP.01.01.crt"
run_test 62 0 "${P}62/${END}PL.01.09.crt" "${P}62/${ICA}4 PL.01.09.crt" "${P}62/${ICA}3 PL.01.09.crt" "${P}62/${ICA}2 PL.01.09.crt" "${P}62/${ICA}1 PL.01.09.crt" "${P}62/${ROOT}CP.01.01.crt"
run_test 63 0 "${P}63/${END}PL.01.10.crt" "${P}63/${ICA}4 PL.01.10.crt" "${P}63/${ICA}3 PL.01.10.crt" "${P}63/${ICA}2 PL.01.10.crt" "${P}63/${ICA}1 PL.01.10.crt" "${P}63/${ROOT}CP.01.01.crt"
echo "Successful tests:$SUCCESS"
echo "Failed tests:$FAILURE"

165
external/hostap/tests/test_x509v3_nist2.sh vendored Executable file
View File

@ -0,0 +1,165 @@
#!/bin/bash
# Public Key Interoperability Test Suite (PKITS)
# http://csrc.nist.gov/pki/testing/x509paths.html
# http://csrc.nist.gov/groups/ST/crypto_apps_infra/documents/PKITS_data.zip
if [ -z "$1" ]; then
echo "usage: $0 <path to root test directory>"
exit 1
fi
TESTS=$1
if [ ! -d $TESTS ]; then
echo "Not a directory: $TESTS"
exit 1
fi
X509TEST="$PWD/test-x509v3 -v"
TMPOUT="$PWD/test_x509v3_nist2.out"
# TODO: add support for validating CRLs
SUCCESS=""
FAILURE=""
function run_test
{
NUM=$1
RES=$2
shift 2
$X509TEST "$@" TrustAnchorRootCertificate.crt > $TMPOUT.$NUM
VALRES=$?
OK=0
if [ $RES -eq 0 ]; then
# expecting success
if [ $VALRES -eq 0 ]; then
OK=1
else
echo "$NUM failed - expected validation success"
OK=0
fi
else
# expecting failure
if [ $VALRES -eq 0 ]; then
echo "$NUM failed - expected validation failure"
OK=0
else
REASON=`grep "Certificate chain validation failed: " $TMPOUT.$NUM`
if [ $? -eq 0 ]; then
REASONNUM=`echo "$REASON" | colrm 1 37`
if [ $REASONNUM -eq $RES ]; then
OK=1
else
echo "$NUM failed - expected validation result $RES; result was $REASONNUM"
OK=0
fi
else
echo "$NUM failed - expected validation failure; other type of error detected"
OK=0
fi
fi
fi
if [ $OK -eq 1 ]; then
rm $TMPOUT.$NUM
SUCCESS="$SUCCESS $NUM"
else
FAILURE="$FAILURE $NUM"
fi
}
pushd $TESTS/certs
run_test 4.1.1 0 ValidCertificatePathTest1EE.crt GoodCACert.crt
run_test 4.1.2 1 InvalidCASignatureTest2EE.crt BadSignedCACert.crt
run_test 4.1.3 1 InvalidEESignatureTest3EE.crt GoodCACert.crt
run_test 4.2.1 4 InvalidCAnotBeforeDateTest1EE.crt BadnotBeforeDateCACert.crt
run_test 4.2.2 4 InvalidEEnotBeforeDateTest2EE.crt GoodCACert.crt
run_test 4.2.3 0 Validpre2000UTCnotBeforeDateTest3EE.crt GoodCACert.crt
run_test 4.2.4 0 ValidGeneralizedTimenotBeforeDateTest4EE.crt GoodCACert.crt
run_test 4.2.5 4 InvalidCAnotAfterDateTest5EE.crt BadnotAfterDateCACert.crt
run_test 4.2.6 4 InvalidEEnotAfterDateTest6EE.crt GoodCACert.crt
run_test 4.2.7 4 Invalidpre2000UTCEEnotAfterDateTest7EE.crt GoodCACert.crt
run_test 4.2.8 0 ValidGeneralizedTimenotAfterDateTest8EE.crt GoodCACert.crt
run_test 4.3.1 5 InvalidNameChainingTest1EE.crt GoodCACert.crt
run_test 4.3.2 5 InvalidNameChainingOrderTest2EE.crt NameOrderingCACert.crt
run_test 4.3.3 0 ValidNameChainingWhitespaceTest3EE.crt GoodCACert.crt
run_test 4.3.4 0 ValidNameChainingWhitespaceTest4EE.crt GoodCACert.crt
run_test 4.3.5 0 ValidNameChainingCapitalizationTest5EE.crt GoodCACert.crt
run_test 4.3.6 0 ValidNameUIDsTest6EE.crt UIDCACert.crt
run_test 4.3.7 0 ValidRFC3280MandatoryAttributeTypesTest7EE.crt RFC3280MandatoryAttributeTypesCACert.crt
run_test 4.3.8 0 ValidRFC3280OptionalAttributeTypesTest8EE.crt RFC3280OptionalAttributeTypesCACert.crt
run_test 4.3.9 0 ValidUTF8StringEncodedNamesTest9EE.crt UTF8StringEncodedNamesCACert.crt
run_test 4.3.10 0 ValidRolloverfromPrintableStringtoUTF8StringTest10EE.crt RolloverfromPrintableStringtoUTF8StringCACert.crt
run_test 4.3.11 0 ValidUTF8StringCaseInsensitiveMatchTest11EE.crt UTF8StringCaseInsensitiveMatchCACert.crt
run_test 4.4.1 1 InvalidMissingCRLTest1EE.crt NoCRLCACert.crt
# skip rest of 4.4.x tests since CRLs are not yet supported
run_test 4.5.1 0 ValidBasicSelfIssuedOldWithNewTest1EE.crt BasicSelfIssuedNewKeyOldWithNewCACert.crt BasicSelfIssuedNewKeyCACert.crt
run_test 4.5.2 3 InvalidBasicSelfIssuedOldWithNewTest2EE.crt BasicSelfIssuedNewKeyOldWithNewCACert.crt BasicSelfIssuedNewKeyCACert.crt
run_test 4.5.3 0 ValidBasicSelfIssuedNewWithOldTest3EE.crt BasicSelfIssuedOldKeyNewWithOldCACert.crt BasicSelfIssuedOldKeyCACert.crt
run_test 4.5.4 0 ValidBasicSelfIssuedNewWithOldTest4EE.crt BasicSelfIssuedOldKeyNewWithOldCACert.crt BasicSelfIssuedOldKeyCACert.crt
run_test 4.5.5 3 InvalidBasicSelfIssuedNewWithOldTest5EE.crt BasicSelfIssuedOldKeyNewWithOldCACert.crt BasicSelfIssuedOldKeyCACert.crt
run_test 4.5.6 0 ValidBasicSelfIssuedCRLSigningKeyTest6EE.crt BasicSelfIssuedCRLSigningKeyCRLCert.crt BasicSelfIssuedCRLSigningKeyCACert.crt
run_test 4.5.7 3 InvalidBasicSelfIssuedCRLSigningKeyTest7EE.crt BasicSelfIssuedCRLSigningKeyCRLCert.crt BasicSelfIssuedCRLSigningKeyCACert.crt
run_test 4.5.8 1 InvalidBasicSelfIssuedCRLSigningKeyTest8EE.crt BasicSelfIssuedCRLSigningKeyCRLCert.crt BasicSelfIssuedCRLSigningKeyCACert.crt
run_test 4.6.1 1 InvalidMissingbasicConstraintsTest1EE.crt MissingbasicConstraintsCACert.crt
run_test 4.6.2 1 InvalidcAFalseTest2EE.crt basicConstraintsCriticalcAFalseCACert.crt
run_test 4.6.3 1 InvalidcAFalseTest3EE.crt basicConstraintsNotCriticalcAFalseCACert.crt
run_test 4.6.4 0 ValidbasicConstraintsNotCriticalTest4EE.crt basicConstraintsNotCriticalCACert.crt
run_test 4.6.5 1 InvalidpathLenConstraintTest5EE.crt pathLenConstraint0subCACert.crt pathLenConstraint0CACert.crt
run_test 4.6.6 1 InvalidpathLenConstraintTest6EE.crt pathLenConstraint0subCACert.crt pathLenConstraint0CACert.crt
run_test 4.6.7 0 ValidpathLenConstraintTest7EE.crt pathLenConstraint0CACert.crt
run_test 4.6.8 0 ValidpathLenConstraintTest8EE.crt pathLenConstraint0CACert.crt
run_test 4.6.9 1 InvalidpathLenConstraintTest9EE.crt pathLenConstraint6subsubCA00Cert.crt pathLenConstraint6subCA0Cert.crt pathLenConstraint6CACert.crt
run_test 4.6.10 1 InvalidpathLenConstraintTest10EE.crt pathLenConstraint6subsubCA00Cert.crt pathLenConstraint6subCA0Cert.crt pathLenConstraint6CACert.crt
run_test 4.6.11 1 InvalidpathLenConstraintTest11EE.crt pathLenConstraint6subsubsubCA11XCert.crt pathLenConstraint6subsubCA11Cert.crt pathLenConstraint6subCA1Cert.crt pathLenConstraint6CACert.crt
run_test 4.6.12 1 InvalidpathLenConstraintTest12EE.crt pathLenConstraint6subsubsubCA11XCert.crt pathLenConstraint6subsubCA11Cert.crt pathLenConstraint6subCA1Cert.crt pathLenConstraint6CACert.crt
run_test 4.6.13 0 ValidpathLenConstraintTest13EE.crt pathLenConstraint6subsubsubCA41XCert.crt pathLenConstraint6subsubCA41Cert.crt pathLenConstraint6subCA4Cert.crt pathLenConstraint6CACert.crt
run_test 4.6.14 0 ValidpathLenConstraintTest14EE.crt pathLenConstraint6subsubsubCA41XCert.crt pathLenConstraint6subsubCA41Cert.crt pathLenConstraint6subCA4Cert.crt pathLenConstraint6CACert.crt
run_test 4.6.15 0 ValidSelfIssuedpathLenConstraintTest15EE.crt pathLenConstraint0SelfIssuedCACert.crt pathLenConstraint0CACert.crt
run_test 4.6.16 1 InvalidSelfIssuedpathLenConstraintTest16EE.crt pathLenConstraint0subCA2Cert.crt pathLenConstraint0SelfIssuedCACert.crt pathLenConstraint0CACert.crt
run_test 4.6.17 0 ValidSelfIssuedpathLenConstraintTest17EE.crt pathLenConstraint1SelfIssuedsubCACert.crt pathLenConstraint1subCACert.crt pathLenConstraint1SelfIssuedCACert.crt pathLenConstraint1CACert.crt
run_test 4.7.1 1 InvalidkeyUsageCriticalkeyCertSignFalseTest1EE.crt keyUsageCriticalkeyCertSignFalseCACert.crt
run_test 4.7.2 1 InvalidkeyUsageNotCriticalkeyCertSignFalseTest2EE.crt keyUsageNotCriticalkeyCertSignFalseCACert.crt
run_test 4.7.3 0 ValidkeyUsageNotCriticalTest3EE.crt keyUsageNotCriticalCACert.crt
run_test 4.7.4 1 InvalidkeyUsageCriticalcRLSignFalseTest4EE.crt keyUsageCriticalcRLSignFalseCACert.crt
run_test 4.7.5 1 InvalidkeyUsageNotCriticalcRLSignFalseTest5EE.crt keyUsageNotCriticalcRLSignFalseCACert.crt
run_test 4.8.1 0 ValidCertificatePathTest1EE.crt GoodCACert.crt
run_test 4.8.2 0 AllCertificatesNoPoliciesTest2EE.crt NoPoliciesCACert.crt
run_test 4.8.3 0 DifferentPoliciesTest3EE.crt PoliciesP2subCACert.crt GoodCACert.crt
run_test 4.8.4 0 DifferentPoliciesTest4EE.crt GoodsubCACert.crt GoodCACert.crt
run_test 4.8.5 0 DifferentPoliciesTest5EE.crt PoliciesP2subCA2Cert.crt GoodCACert.crt
run_test 4.8.6 0 OverlappingPoliciesTest6EE.crt PoliciesP1234subsubCAP123P12Cert.crt PoliciesP1234subCAP123Cert.crt PoliciesP1234CACert.crt
run_test 4.8.7 0 DifferentPoliciesTest7EE.crt PoliciesP123subsubCAP12P1Cert.crt PoliciesP123subCAP12Cert.crt PoliciesP123CACert.crt
run_test 4.8.8 0 DifferentPoliciesTest8EE.crt PoliciesP12subsubCAP1P2Cert.crt PoliciesP12subCAP1Cert.crt PoliciesP12CACert.crt
run_test 4.8.9 0 DifferentPoliciesTest9EE.crt PoliciesP123subsubsubCAP12P2P1Cert.crt PoliciesP123subsubCAP12P2Cert.crt PoliciesP123subCAP12Cert.crt PoliciesP123CACert.crt
run_test 4.8.10 0 AllCertificatesSamePoliciesTest10EE.crt PoliciesP12CACert.crt
run_test 4.8.11 0 AllCertificatesanyPolicyTest11EE.crt anyPolicyCACert.crt
run_test 4.8.12 0 DifferentPoliciesTest12EE.crt PoliciesP3CACert.crt
run_test 4.8.13 0 AllCertificatesSamePoliciesTest13EE.crt PoliciesP123CACert.crt
run_test 4.8.14 0 AnyPolicyTest14EE.crt anyPolicyCACert.crt
run_test 4.8.15 0 UserNoticeQualifierTest15EE.crt
run_test 4.8.16 0 UserNoticeQualifierTest16EE.crt GoodCACert.crt
run_test 4.8.17 0 UserNoticeQualifierTest17EE.crt GoodCACert.crt
run_test 4.8.18 0 UserNoticeQualifierTest18EE.crt PoliciesP12CACert.crt
run_test 4.8.19 0 UserNoticeQualifierTest19EE.crt TrustAnchorRootCertificate.crt
run_test 4.8.20 0 CPSPointerQualifierTest20EE.crt GoodCACert.crt
if false; then
# DSA tests
run_test 4.1.4 0 ValidDSASignaturesTest4EE.crt DSACACert.crt
fi
popd
echo "Successful tests:$SUCCESS"
echo "Failed tests:$FAILURE"