blob: d09ea8b10b4fdbc5bd1455f13a42aeb992ee0142 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Quick & dirty crypto testing module.
3 *
4 * This will only exist until we have a better testing mechanism
5 * (e.g. a char device).
6 *
7 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
8 * Copyright (c) 2002 Jean-Francois Dive <jef@linuxbe.org>
Mikko Herranene3a4ea42007-11-26 22:12:07 +08009 * Copyright (c) 2007 Nokia Siemens Networks
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the Free
Herbert Xuef2736f2005-06-22 13:26:03 -070013 * Software Foundation; either version 2 of the License, or (at your option)
Linus Torvalds1da177e2005-04-16 15:20:36 -070014 * any later version.
15 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070016 */
17#ifndef _CRYPTO_TCRYPT_H
18#define _CRYPTO_TCRYPT_H
19
Herbert Xuda7f0332008-07-31 17:08:25 +080020struct cipher_speed_template {
21 const char *key;
22 unsigned int klen;
Mikko Herranene3a4ea42007-11-26 22:12:07 +080023};
24
Tim Chen53f52d72013-12-11 14:28:47 -080025struct aead_speed_template {
26 const char *key;
27 unsigned int klen;
28};
29
Herbert Xue9d41162006-08-19 21:38:49 +100030struct hash_speed {
Michal Ludvige8057922006-05-30 22:04:19 +100031 unsigned int blen; /* buffer length */
32 unsigned int plen; /* per-update length */
Huang Ying18bcc912010-03-10 18:30:32 +080033 unsigned int klen; /* key length */
Michal Ludvige8057922006-05-30 22:04:19 +100034};
35
Andrew Donofrioa28091a2006-12-10 12:10:20 +110036/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070037 * DES test vectors.
38 */
Herbert Xuda7f0332008-07-31 17:08:25 +080039#define DES3_SPEED_VECTORS 1
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
Herbert Xuda7f0332008-07-31 17:08:25 +080041static struct cipher_speed_template des3_speed_template[] = {
42 {
Sebastian Siewiorde224c32008-03-13 20:21:51 +080043 .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
44 "\x55\x55\x55\x55\x55\x55\x55\x55"
45 "\xfe\xdc\xba\x98\x76\x54\x32\x10",
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 .klen = 24,
Rik Snelf3d10442006-11-29 19:01:41 +110047 }
48};
49
Herbert Xuc907ee72006-08-21 22:04:03 +100050/*
Harald Welteebfd9bc2005-06-22 13:27:23 -070051 * Cipher speed tests
52 */
Sebastian Siewiord5dc3922008-03-11 21:27:11 +080053static u8 speed_template_8[] = {8, 0};
Gilad Ben-Yossef95ba5972018-09-20 14:18:38 +010054static u8 speed_template_16[] = {16, 0};
Sebastian Siewiord5dc3922008-03-11 21:27:11 +080055static u8 speed_template_24[] = {24, 0};
Johannes Goetzfrieda2c58262012-07-11 19:37:21 +020056static u8 speed_template_8_16[] = {8, 16, 0};
Sebastian Siewiord5dc3922008-03-11 21:27:11 +080057static u8 speed_template_8_32[] = {8, 32, 0};
58static u8 speed_template_16_32[] = {16, 32, 0};
59static u8 speed_template_16_24_32[] = {16, 24, 32, 0};
Jussi Kivilinna69d31502012-12-28 12:04:58 +020060static u8 speed_template_20_28_36[] = {20, 28, 36, 0};
Sebastian Siewiord5dc3922008-03-11 21:27:11 +080061static u8 speed_template_32_40_48[] = {32, 40, 48, 0};
Jussi Kivilinna87aae4b2011-10-18 13:32:39 +030062static u8 speed_template_32_48[] = {32, 48, 0};
Sebastian Siewiord5dc3922008-03-11 21:27:11 +080063static u8 speed_template_32_48_64[] = {32, 48, 64, 0};
Jussi Kivilinna5209c072011-10-18 13:33:22 +030064static u8 speed_template_32_64[] = {32, 64, 0};
Martin Willi2dce0632015-07-16 19:13:59 +020065static u8 speed_template_32[] = {32, 0};
Rik Snelf19f5112007-09-19 20:23:13 +080066
Michal Ludvige8057922006-05-30 22:04:19 +100067/*
Tim Chen53f52d72013-12-11 14:28:47 -080068 * AEAD speed tests
69 */
Herbert Xu4e4aab62015-06-17 14:04:21 +080070static u8 aead_speed_template_19[] = {19, 0};
Tim Chen53f52d72013-12-11 14:28:47 -080071static u8 aead_speed_template_20[] = {20, 0};
Martin Willi2dce0632015-07-16 19:13:59 +020072static u8 aead_speed_template_36[] = {36, 0};
Tim Chen53f52d72013-12-11 14:28:47 -080073
74/*
Michal Ludvige8057922006-05-30 22:04:19 +100075 * Digest speed tests
76 */
Herbert Xue9d41162006-08-19 21:38:49 +100077static struct hash_speed generic_hash_speed_template[] = {
Sebastian Siewiorde224c32008-03-13 20:21:51 +080078 { .blen = 16, .plen = 16, },
Michal Ludvige8057922006-05-30 22:04:19 +100079 { .blen = 64, .plen = 16, },
80 { .blen = 64, .plen = 64, },
81 { .blen = 256, .plen = 16, },
82 { .blen = 256, .plen = 64, },
83 { .blen = 256, .plen = 256, },
84 { .blen = 1024, .plen = 16, },
85 { .blen = 1024, .plen = 256, },
86 { .blen = 1024, .plen = 1024, },
87 { .blen = 2048, .plen = 16, },
88 { .blen = 2048, .plen = 256, },
89 { .blen = 2048, .plen = 1024, },
90 { .blen = 2048, .plen = 2048, },
91 { .blen = 4096, .plen = 16, },
92 { .blen = 4096, .plen = 256, },
93 { .blen = 4096, .plen = 1024, },
94 { .blen = 4096, .plen = 4096, },
95 { .blen = 8192, .plen = 16, },
96 { .blen = 8192, .plen = 256, },
97 { .blen = 8192, .plen = 1024, },
98 { .blen = 8192, .plen = 4096, },
99 { .blen = 8192, .plen = 8192, },
100
101 /* End marker */
102 { .blen = 0, .plen = 0, }
103};
104
Huang Ying18bcc912010-03-10 18:30:32 +0800105static struct hash_speed hash_speed_template_16[] = {
106 { .blen = 16, .plen = 16, .klen = 16, },
107 { .blen = 64, .plen = 16, .klen = 16, },
108 { .blen = 64, .plen = 64, .klen = 16, },
109 { .blen = 256, .plen = 16, .klen = 16, },
110 { .blen = 256, .plen = 64, .klen = 16, },
111 { .blen = 256, .plen = 256, .klen = 16, },
112 { .blen = 1024, .plen = 16, .klen = 16, },
113 { .blen = 1024, .plen = 256, .klen = 16, },
114 { .blen = 1024, .plen = 1024, .klen = 16, },
115 { .blen = 2048, .plen = 16, .klen = 16, },
116 { .blen = 2048, .plen = 256, .klen = 16, },
117 { .blen = 2048, .plen = 1024, .klen = 16, },
118 { .blen = 2048, .plen = 2048, .klen = 16, },
119 { .blen = 4096, .plen = 16, .klen = 16, },
120 { .blen = 4096, .plen = 256, .klen = 16, },
121 { .blen = 4096, .plen = 1024, .klen = 16, },
122 { .blen = 4096, .plen = 4096, .klen = 16, },
123 { .blen = 8192, .plen = 16, .klen = 16, },
124 { .blen = 8192, .plen = 256, .klen = 16, },
125 { .blen = 8192, .plen = 1024, .klen = 16, },
126 { .blen = 8192, .plen = 4096, .klen = 16, },
127 { .blen = 8192, .plen = 8192, .klen = 16, },
128
129 /* End marker */
130 { .blen = 0, .plen = 0, .klen = 0, }
131};
132
Martin Willi2dce0632015-07-16 19:13:59 +0200133static struct hash_speed poly1305_speed_template[] = {
134 { .blen = 96, .plen = 16, },
135 { .blen = 96, .plen = 32, },
136 { .blen = 96, .plen = 96, },
137 { .blen = 288, .plen = 16, },
138 { .blen = 288, .plen = 32, },
139 { .blen = 288, .plen = 288, },
140 { .blen = 1056, .plen = 32, },
141 { .blen = 1056, .plen = 1056, },
142 { .blen = 2080, .plen = 32, },
143 { .blen = 2080, .plen = 2080, },
144 { .blen = 4128, .plen = 4128, },
145 { .blen = 8224, .plen = 8224, },
146
147 /* End marker */
148 { .blen = 0, .plen = 0, }
149};
150
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151#endif /* _CRYPTO_TCRYPT_H */