Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 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 Herranen | e3a4ea4 | 2007-11-26 22:12:07 +0800 | [diff] [blame] | 10 | * Copyright (c) 2007 Nokia Siemens Networks |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | */ |
| 12 | #ifndef _CRYPTO_TCRYPT_H |
| 13 | #define _CRYPTO_TCRYPT_H |
| 14 | |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 15 | struct cipher_speed_template { |
| 16 | const char *key; |
| 17 | unsigned int klen; |
Mikko Herranen | e3a4ea4 | 2007-11-26 22:12:07 +0800 | [diff] [blame] | 18 | }; |
| 19 | |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 20 | struct aead_speed_template { |
| 21 | const char *key; |
| 22 | unsigned int klen; |
| 23 | }; |
| 24 | |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 25 | struct hash_speed { |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 26 | unsigned int blen; /* buffer length */ |
| 27 | unsigned int plen; /* per-update length */ |
Huang Ying | 18bcc91 | 2010-03-10 18:30:32 +0800 | [diff] [blame] | 28 | unsigned int klen; /* key length */ |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 29 | }; |
| 30 | |
Andrew Donofrio | a28091a | 2006-12-10 12:10:20 +1100 | [diff] [blame] | 31 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | * DES test vectors. |
| 33 | */ |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 34 | #define DES3_SPEED_VECTORS 1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | |
Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 36 | static struct cipher_speed_template des3_speed_template[] = { |
| 37 | { |
Sebastian Siewior | de224c3 | 2008-03-13 20:21:51 +0800 | [diff] [blame] | 38 | .key = "\x01\x23\x45\x67\x89\xab\xcd\xef" |
| 39 | "\x55\x55\x55\x55\x55\x55\x55\x55" |
| 40 | "\xfe\xdc\xba\x98\x76\x54\x32\x10", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | .klen = 24, |
Rik Snel | f3d1044 | 2006-11-29 19:01:41 +1100 | [diff] [blame] | 42 | } |
| 43 | }; |
| 44 | |
Herbert Xu | c907ee7 | 2006-08-21 22:04:03 +1000 | [diff] [blame] | 45 | /* |
Harald Welte | ebfd9bc | 2005-06-22 13:27:23 -0700 | [diff] [blame] | 46 | * Cipher speed tests |
| 47 | */ |
Sebastian Siewior | d5dc392 | 2008-03-11 21:27:11 +0800 | [diff] [blame] | 48 | static u8 speed_template_8[] = {8, 0}; |
Gilad Ben-Yossef | 95ba597 | 2018-09-20 14:18:38 +0100 | [diff] [blame] | 49 | static u8 speed_template_16[] = {16, 0}; |
Sebastian Siewior | d5dc392 | 2008-03-11 21:27:11 +0800 | [diff] [blame] | 50 | static u8 speed_template_24[] = {24, 0}; |
Johannes Goetzfried | a2c5826 | 2012-07-11 19:37:21 +0200 | [diff] [blame] | 51 | static u8 speed_template_8_16[] = {8, 16, 0}; |
Sebastian Siewior | d5dc392 | 2008-03-11 21:27:11 +0800 | [diff] [blame] | 52 | static u8 speed_template_8_32[] = {8, 32, 0}; |
| 53 | static u8 speed_template_16_32[] = {16, 32, 0}; |
| 54 | static u8 speed_template_16_24_32[] = {16, 24, 32, 0}; |
Jussi Kivilinna | 69d3150 | 2012-12-28 12:04:58 +0200 | [diff] [blame] | 55 | static u8 speed_template_20_28_36[] = {20, 28, 36, 0}; |
Sebastian Siewior | d5dc392 | 2008-03-11 21:27:11 +0800 | [diff] [blame] | 56 | static u8 speed_template_32_40_48[] = {32, 40, 48, 0}; |
Jussi Kivilinna | 87aae4b | 2011-10-18 13:32:39 +0300 | [diff] [blame] | 57 | static u8 speed_template_32_48[] = {32, 48, 0}; |
Sebastian Siewior | d5dc392 | 2008-03-11 21:27:11 +0800 | [diff] [blame] | 58 | static u8 speed_template_32_48_64[] = {32, 48, 64, 0}; |
Jussi Kivilinna | 5209c07 | 2011-10-18 13:33:22 +0300 | [diff] [blame] | 59 | static u8 speed_template_32_64[] = {32, 64, 0}; |
Martin Willi | 2dce063 | 2015-07-16 19:13:59 +0200 | [diff] [blame] | 60 | static u8 speed_template_32[] = {32, 0}; |
Rik Snel | f19f511 | 2007-09-19 20:23:13 +0800 | [diff] [blame] | 61 | |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 62 | /* |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 63 | * AEAD speed tests |
| 64 | */ |
Herbert Xu | 4e4aab6 | 2015-06-17 14:04:21 +0800 | [diff] [blame] | 65 | static u8 aead_speed_template_19[] = {19, 0}; |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 66 | static u8 aead_speed_template_20[] = {20, 0}; |
Martin Willi | 2dce063 | 2015-07-16 19:13:59 +0200 | [diff] [blame] | 67 | static u8 aead_speed_template_36[] = {36, 0}; |
Tim Chen | 53f52d7 | 2013-12-11 14:28:47 -0800 | [diff] [blame] | 68 | |
| 69 | /* |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 70 | * Digest speed tests |
| 71 | */ |
Herbert Xu | e9d4116 | 2006-08-19 21:38:49 +1000 | [diff] [blame] | 72 | static struct hash_speed generic_hash_speed_template[] = { |
Sebastian Siewior | de224c3 | 2008-03-13 20:21:51 +0800 | [diff] [blame] | 73 | { .blen = 16, .plen = 16, }, |
Michal Ludvig | e805792 | 2006-05-30 22:04:19 +1000 | [diff] [blame] | 74 | { .blen = 64, .plen = 16, }, |
| 75 | { .blen = 64, .plen = 64, }, |
| 76 | { .blen = 256, .plen = 16, }, |
| 77 | { .blen = 256, .plen = 64, }, |
| 78 | { .blen = 256, .plen = 256, }, |
| 79 | { .blen = 1024, .plen = 16, }, |
| 80 | { .blen = 1024, .plen = 256, }, |
| 81 | { .blen = 1024, .plen = 1024, }, |
| 82 | { .blen = 2048, .plen = 16, }, |
| 83 | { .blen = 2048, .plen = 256, }, |
| 84 | { .blen = 2048, .plen = 1024, }, |
| 85 | { .blen = 2048, .plen = 2048, }, |
| 86 | { .blen = 4096, .plen = 16, }, |
| 87 | { .blen = 4096, .plen = 256, }, |
| 88 | { .blen = 4096, .plen = 1024, }, |
| 89 | { .blen = 4096, .plen = 4096, }, |
| 90 | { .blen = 8192, .plen = 16, }, |
| 91 | { .blen = 8192, .plen = 256, }, |
| 92 | { .blen = 8192, .plen = 1024, }, |
| 93 | { .blen = 8192, .plen = 4096, }, |
| 94 | { .blen = 8192, .plen = 8192, }, |
| 95 | |
| 96 | /* End marker */ |
| 97 | { .blen = 0, .plen = 0, } |
| 98 | }; |
| 99 | |
Huang Ying | 18bcc91 | 2010-03-10 18:30:32 +0800 | [diff] [blame] | 100 | static struct hash_speed hash_speed_template_16[] = { |
| 101 | { .blen = 16, .plen = 16, .klen = 16, }, |
| 102 | { .blen = 64, .plen = 16, .klen = 16, }, |
| 103 | { .blen = 64, .plen = 64, .klen = 16, }, |
| 104 | { .blen = 256, .plen = 16, .klen = 16, }, |
| 105 | { .blen = 256, .plen = 64, .klen = 16, }, |
| 106 | { .blen = 256, .plen = 256, .klen = 16, }, |
| 107 | { .blen = 1024, .plen = 16, .klen = 16, }, |
| 108 | { .blen = 1024, .plen = 256, .klen = 16, }, |
| 109 | { .blen = 1024, .plen = 1024, .klen = 16, }, |
| 110 | { .blen = 2048, .plen = 16, .klen = 16, }, |
| 111 | { .blen = 2048, .plen = 256, .klen = 16, }, |
| 112 | { .blen = 2048, .plen = 1024, .klen = 16, }, |
| 113 | { .blen = 2048, .plen = 2048, .klen = 16, }, |
| 114 | { .blen = 4096, .plen = 16, .klen = 16, }, |
| 115 | { .blen = 4096, .plen = 256, .klen = 16, }, |
| 116 | { .blen = 4096, .plen = 1024, .klen = 16, }, |
| 117 | { .blen = 4096, .plen = 4096, .klen = 16, }, |
| 118 | { .blen = 8192, .plen = 16, .klen = 16, }, |
| 119 | { .blen = 8192, .plen = 256, .klen = 16, }, |
| 120 | { .blen = 8192, .plen = 1024, .klen = 16, }, |
| 121 | { .blen = 8192, .plen = 4096, .klen = 16, }, |
| 122 | { .blen = 8192, .plen = 8192, .klen = 16, }, |
| 123 | |
| 124 | /* End marker */ |
| 125 | { .blen = 0, .plen = 0, .klen = 0, } |
| 126 | }; |
| 127 | |
Martin Willi | 2dce063 | 2015-07-16 19:13:59 +0200 | [diff] [blame] | 128 | static struct hash_speed poly1305_speed_template[] = { |
| 129 | { .blen = 96, .plen = 16, }, |
| 130 | { .blen = 96, .plen = 32, }, |
| 131 | { .blen = 96, .plen = 96, }, |
| 132 | { .blen = 288, .plen = 16, }, |
| 133 | { .blen = 288, .plen = 32, }, |
| 134 | { .blen = 288, .plen = 288, }, |
| 135 | { .blen = 1056, .plen = 32, }, |
| 136 | { .blen = 1056, .plen = 1056, }, |
| 137 | { .blen = 2080, .plen = 32, }, |
| 138 | { .blen = 2080, .plen = 2080, }, |
| 139 | { .blen = 4128, .plen = 4128, }, |
| 140 | { .blen = 8224, .plen = 8224, }, |
| 141 | |
| 142 | /* End marker */ |
| 143 | { .blen = 0, .plen = 0, } |
| 144 | }; |
| 145 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | #endif /* _CRYPTO_TCRYPT_H */ |