blob: 96c843a24607105e6011c0273d3818b37e87841e [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * Quick & dirty crypto testing module.
4 *
5 * This will only exist until we have a better testing mechanism
6 * (e.g. a char device).
7 *
8 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
9 * Copyright (c) 2002 Jean-Francois Dive <jef@linuxbe.org>
Mikko Herranene3a4ea42007-11-26 22:12:07 +080010 * Copyright (c) 2007 Nokia Siemens Networks
Linus Torvalds1da177e2005-04-16 15:20:36 -070011 */
12#ifndef _CRYPTO_TCRYPT_H
13#define _CRYPTO_TCRYPT_H
14
Herbert Xuda7f0332008-07-31 17:08:25 +080015struct cipher_speed_template {
16 const char *key;
17 unsigned int klen;
Mikko Herranene3a4ea42007-11-26 22:12:07 +080018};
19
Tim Chen53f52d72013-12-11 14:28:47 -080020struct aead_speed_template {
21 const char *key;
22 unsigned int klen;
23};
24
Herbert Xue9d41162006-08-19 21:38:49 +100025struct hash_speed {
Michal Ludvige8057922006-05-30 22:04:19 +100026 unsigned int blen; /* buffer length */
27 unsigned int plen; /* per-update length */
28};
29
Andrew Donofrioa28091a2006-12-10 12:10:20 +110030/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070031 * DES test vectors.
32 */
Herbert Xuda7f0332008-07-31 17:08:25 +080033#define DES3_SPEED_VECTORS 1
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Herbert Xuda7f0332008-07-31 17:08:25 +080035static struct cipher_speed_template des3_speed_template[] = {
36 {
Sebastian Siewiorde224c32008-03-13 20:21:51 +080037 .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
38 "\x55\x55\x55\x55\x55\x55\x55\x55"
39 "\xfe\xdc\xba\x98\x76\x54\x32\x10",
Linus Torvalds1da177e2005-04-16 15:20:36 -070040 .klen = 24,
Rik Snelf3d10442006-11-29 19:01:41 +110041 }
42};
43
Herbert Xuc907ee72006-08-21 22:04:03 +100044/*
Harald Welteebfd9bc2005-06-22 13:27:23 -070045 * Cipher speed tests
46 */
Sebastian Siewiord5dc3922008-03-11 21:27:11 +080047static u8 speed_template_8[] = {8, 0};
Gilad Ben-Yossef95ba5972018-09-20 14:18:38 +010048static u8 speed_template_16[] = {16, 0};
Sebastian Siewiord5dc3922008-03-11 21:27:11 +080049static u8 speed_template_24[] = {24, 0};
Johannes Goetzfrieda2c58262012-07-11 19:37:21 +020050static u8 speed_template_8_16[] = {8, 16, 0};
Sebastian Siewiord5dc3922008-03-11 21:27:11 +080051static u8 speed_template_8_32[] = {8, 32, 0};
52static u8 speed_template_16_32[] = {16, 32, 0};
53static u8 speed_template_16_24_32[] = {16, 24, 32, 0};
Jussi Kivilinna69d3150c2012-12-28 12:04:58 +020054static u8 speed_template_20_28_36[] = {20, 28, 36, 0};
Sebastian Siewiord5dc3922008-03-11 21:27:11 +080055static u8 speed_template_32_40_48[] = {32, 40, 48, 0};
Jussi Kivilinna87aae4b2011-10-18 13:32:39 +030056static u8 speed_template_32_48[] = {32, 48, 0};
Sebastian Siewiord5dc3922008-03-11 21:27:11 +080057static u8 speed_template_32_48_64[] = {32, 48, 64, 0};
Jussi Kivilinna5209c072011-10-18 13:33:22 +030058static u8 speed_template_32_64[] = {32, 64, 0};
Martin Willi2dce0632015-07-16 19:13:59 +020059static u8 speed_template_32[] = {32, 0};
Rik Snelf19f5112007-09-19 20:23:13 +080060
Michal Ludvige8057922006-05-30 22:04:19 +100061/*
Tim Chen53f52d72013-12-11 14:28:47 -080062 * AEAD speed tests
63 */
Herbert Xu4e4aab62015-06-17 14:04:21 +080064static u8 aead_speed_template_19[] = {19, 0};
Ard Biesheuvel425359a2022-12-14 18:19:56 +010065static u8 aead_speed_template_20_28_36[] = {20, 28, 36, 0};
Martin Willi2dce0632015-07-16 19:13:59 +020066static u8 aead_speed_template_36[] = {36, 0};
Tim Chen53f52d72013-12-11 14:28:47 -080067
68/*
Michal Ludvige8057922006-05-30 22:04:19 +100069 * Digest speed tests
70 */
Herbert Xue9d41162006-08-19 21:38:49 +100071static struct hash_speed generic_hash_speed_template[] = {
Sebastian Siewiorde224c32008-03-13 20:21:51 +080072 { .blen = 16, .plen = 16, },
Michal Ludvige8057922006-05-30 22:04:19 +100073 { .blen = 64, .plen = 16, },
74 { .blen = 64, .plen = 64, },
75 { .blen = 256, .plen = 16, },
76 { .blen = 256, .plen = 64, },
77 { .blen = 256, .plen = 256, },
78 { .blen = 1024, .plen = 16, },
79 { .blen = 1024, .plen = 256, },
80 { .blen = 1024, .plen = 1024, },
81 { .blen = 2048, .plen = 16, },
82 { .blen = 2048, .plen = 256, },
83 { .blen = 2048, .plen = 1024, },
84 { .blen = 2048, .plen = 2048, },
85 { .blen = 4096, .plen = 16, },
86 { .blen = 4096, .plen = 256, },
87 { .blen = 4096, .plen = 1024, },
88 { .blen = 4096, .plen = 4096, },
89 { .blen = 8192, .plen = 16, },
90 { .blen = 8192, .plen = 256, },
91 { .blen = 8192, .plen = 1024, },
92 { .blen = 8192, .plen = 4096, },
93 { .blen = 8192, .plen = 8192, },
94
95 /* End marker */
96 { .blen = 0, .plen = 0, }
97};
98
Martin Willi2dce0632015-07-16 19:13:59 +020099static struct hash_speed poly1305_speed_template[] = {
100 { .blen = 96, .plen = 16, },
101 { .blen = 96, .plen = 32, },
102 { .blen = 96, .plen = 96, },
103 { .blen = 288, .plen = 16, },
104 { .blen = 288, .plen = 32, },
105 { .blen = 288, .plen = 288, },
106 { .blen = 1056, .plen = 32, },
107 { .blen = 1056, .plen = 1056, },
108 { .blen = 2080, .plen = 32, },
109 { .blen = 2080, .plen = 2080, },
110 { .blen = 4128, .plen = 4128, },
111 { .blen = 8224, .plen = 8224, },
112
113 /* End marker */
114 { .blen = 0, .plen = 0, }
115};
116
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117#endif /* _CRYPTO_TCRYPT_H */