]> git.ipfire.org Git - thirdparty/strongswan.git/blame - src/libstrongswan/plugins/test_vectors/test_vectors/aes_cmac.c
Update copyright headers after acquisition by secunet
[thirdparty/strongswan.git] / src / libstrongswan / plugins / test_vectors / test_vectors / aes_cmac.c
CommitLineData
811e7490
TB
1/*
2 * Copyright (C) 2012 Tobias Brunner
19ef2aec
TB
3 *
4 * Copyright (C) secunet Security Networks AG
811e7490
TB
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the Licenseor (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 *
11 * This program is distributed in the hope that it will be usefulbut
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 */
16
17#include <crypto/crypto_tester.h>
18
19/**
20 * RFC 4493 Example #1: AES-CMAC with 0-byte input
21 */
22prf_test_vector_t aes_cmac_p1 = {
23 .alg = PRF_AES128_CMAC, .key_size = 16, .len = 0,
24 .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6\xab\xf7\x15\x88\x09\xcf\x4f\x3c",
25 .seed = "",
26 .out = "\xbb\x1d\x69\x29\xe9\x59\x37\x28\x7f\xa3\x7d\x12\x9b\x75\x67\x46"
27};
28
29/**
30 * RFC 4493 Example #2: AES-CMAC with 16-byte input
31 */
32prf_test_vector_t aes_cmac_p2 = {
33 .alg = PRF_AES128_CMAC, .key_size = 16, .len = 16,
34 .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6\xab\xf7\x15\x88\x09\xcf\x4f\x3c",
35 .seed = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a",
36 .out = "\x07\x0a\x16\xb4\x6b\x4d\x41\x44\xf7\x9b\xdd\x9d\xd0\x4a\x28\x7c"
37};
38
39/**
40 * RFC 4493 Example #3: AES-CMAC with 40-byte input
41 */
42prf_test_vector_t aes_cmac_p3 = {
43 .alg = PRF_AES128_CMAC, .key_size = 16, .len = 40,
44 .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6\xab\xf7\x15\x88\x09\xcf\x4f\x3c",
45 .seed = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
46 "\xae\x2d\x8a\x57\x1e\x03\xac\x9c\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
47 "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11",
48 .out = "\xdf\xa6\x67\x47\xde\x9a\xe6\x30\x30\xca\x32\x61\x14\x97\xc8\x27"
49};
50
51/**
52 * RFC 4493 Example #4: AES-CMAC with 64-byte input
53 */
54prf_test_vector_t aes_cmac_p4 = {
55 .alg = PRF_AES128_CMAC, .key_size = 16, .len = 64,
56 .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6\xab\xf7\x15\x88\x09\xcf\x4f\x3c",
57 .seed = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
58 "\xae\x2d\x8a\x57\x1e\x03\xac\x9c\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
59 "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
60 "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
61 .out = "\x51\xf0\xbe\xbf\x7e\x3b\x9d\x92\xfc\x49\x74\x17\x79\x36\x3c\xfe"
62};
63
64/**
65 * RFC 4615 Test Case #1: AES-CMAC with 20-byte input, 18-byte key
66 */
67prf_test_vector_t aes_cmac_p5 = {
68 .alg = PRF_AES128_CMAC, .key_size = 18, .len = 20,
69 .key = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
70 "\xed\xcb",
71 .seed = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
72 "\x10\x11\x12\x13",
73 .out = "\x84\xa3\x48\xa4\xa4\x5d\x23\x5b\xab\xff\xfc\x0d\x2b\x4d\xa0\x9a"
74};
75
76/**
77 * RFC 4615 Test Case #2: AES-CMAC with 20-byte input, 16-byte key
78 */
79prf_test_vector_t aes_cmac_p6 = {
80 .alg = PRF_AES128_CMAC, .key_size = 16, .len = 20,
81 .key = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
82 .seed = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
83 "\x10\x11\x12\x13",
84 .out = "\x98\x0a\xe8\x7b\x5f\x4c\x9c\x52\x14\xf5\xb6\xa8\x45\x5e\x4c\x2d"
85};
86
87/**
88 * RFC 4615 Test Case #3: AES-CMAC with 20-byte input, 10-byte key
89 */
90prf_test_vector_t aes_cmac_p7 = {
91 .alg = PRF_AES128_CMAC, .key_size = 10, .len = 20,
92 .key = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09",
93 .seed = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
94 "\x10\x11\x12\x13",
95 .out = "\x29\x0d\x9e\x11\x2e\xdb\x09\xee\x14\x1f\xcf\x64\xc0\xb7\x2f\x3d"
96};
97
98/**
99 * RFC 4494 Test Case #1: AES-CMAC-96 with 0-byte input
100 */
101signer_test_vector_t aes_cmac_s1 = {
102 .alg = AUTH_AES_CMAC_96, .len = 0,
103 .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6\xab\xf7\x15\x88\x09\xcf\x4f\x3c",
104 .data = "",
105 .mac = "\xbb\x1d\x69\x29\xe9\x59\x37\x28\x7f\xa3\x7d\x12"
106};
107
108
109/**
110 * RFC 4494 Test Case #2: AES-CMAC-96 with 16-byte input
111 */
112signer_test_vector_t aes_cmac_s2 = {
113 .alg = AUTH_AES_CMAC_96, .len = 16,
114 .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6\xab\xf7\x15\x88\x09\xcf\x4f\x3c",
115 .data = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a",
116 .mac = "\x07\x0a\x16\xb4\x6b\x4d\x41\x44\xf7\x9b\xdd\x9d"
117};
118
119/**
120 * RFC 4494 Test Case #3: AES-CMAC-96 with 40-byte input
121 */
122signer_test_vector_t aes_cmac_s3 = {
123 .alg = AUTH_AES_CMAC_96, .len = 40,
124 .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6\xab\xf7\x15\x88\x09\xcf\x4f\x3c",
125 .data = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
126 "\xae\x2d\x8a\x57\x1e\x03\xac\x9c\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
127 "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11",
128 .mac = "\xdf\xa6\x67\x47\xde\x9a\xe6\x30\x30\xca\x32\x61"
129};
130
131/**
132 * RFC 4494 Test Case #4: AES-CMAC-96 with 64-byte input
133 */
134signer_test_vector_t aes_cmac_s4 = {
135 .alg = AUTH_AES_CMAC_96, .len = 64,
136 .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6\xab\xf7\x15\x88\x09\xcf\x4f\x3c",
137 .data = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
138 "\xae\x2d\x8a\x57\x1e\x03\xac\x9c\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
139 "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
140 "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
141 .mac = "\x51\xf0\xbe\xbf\x7e\x3b\x9d\x92\xfc\x49\x74\x17"
142};