| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#include "cryptoperf.h" |
| 21 |
#include <limits.h> |
| 22 |
#include <stdlib.h> |
| 23 |
#include <sys/user.h> |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
static int cp_skcipher_init_test(struct cp_test *test) |
| 30 |
{ |
| 31 |
unsigned char *scratchpad = NULL; |
| 32 |
struct cp_test_param *params = test->test_params; |
| 33 |
#define MAX_KEYLEN 64 |
| 34 |
unsigned char data[MAX_KEYLEN]; |
| 35 |
unsigned char *ivdata = NULL; |
| 36 |
unsigned int bs; |
| 37 |
int err; |
| 38 |
size_t pagesize = (size_t)sysconf(_SC_PAGESIZE); |
| 39 |
|
| 40 |
if (pagesize > ULONG_MAX) { |
| 41 |
printf(DRIVER_NAME": unable to determine the page size\n"); |
| 42 |
return -errno; |
| 43 |
} |
| 44 |
|
| 45 |
dbg("Initializing symmetric test %s\n", test->testname); |
| 46 |
if (!test->driver_name) { |
| 47 |
printf(DRIVER_NAME": missing test definition information for %s\n", |
| 48 |
test->testname); |
| 49 |
return -EFAULT; |
| 50 |
} |
| 51 |
|
| 52 |
if (kcapi_cipher_init(&test->u.skcipher.handle, test->driver_name, |
| 53 |
params->aio ? KCAPI_INIT_AIO : 0)) { |
| 54 |
printf(DRIVER_NAME": could not allocate skcipher handle for " |
| 55 |
"%s\n", test->driver_name); |
| 56 |
goto out; |
| 57 |
} |
| 58 |
|
| 59 |
if (test->u.skcipher.keysize > MAX_KEYLEN) { |
| 60 |
printf(DRIVER_NAME": key length for cipher %s too large\n", |
| 61 |
test->driver_name); |
| 62 |
goto out; |
| 63 |
} |
| 64 |
|
| 65 |
cp_read_random(data, test->u.skcipher.keysize); |
| 66 |
if (kcapi_cipher_setkey(test->u.skcipher.handle, data, |
| 67 |
test->u.skcipher.keysize)) { |
| 68 |
printf(DRIVER_NAME": key could not be set\n"); |
| 69 |
goto out; |
| 70 |
} |
| 71 |
|
| 72 |
bs = kcapi_cipher_blocksize(test->u.skcipher.handle); |
| 73 |
|
| 74 |
if (bs == 1) |
| 75 |
bs = 16; |
| 76 |
err = posix_memalign((void *)&ivdata, bs, bs); |
| 77 |
if (err) { |
| 78 |
printf(DRIVER_NAME": could not allocate ivdata for " |
| 79 |
"%s (error: %d)\n", test->driver_name, err); |
| 80 |
goto out; |
| 81 |
} |
| 82 |
cp_read_random(ivdata, kcapi_cipher_blocksize(test->u.skcipher.handle)); |
| 83 |
test->u.skcipher.iv = ivdata; |
| 84 |
|
| 85 |
err = posix_memalign((void *)&scratchpad, pagesize, |
| 86 |
kcapi_cipher_blocksize(test->u.skcipher.handle) * params->len * |
| 87 |
(params->aio ? params->aio : 1)); |
| 88 |
if (err) { |
| 89 |
printf(DRIVER_NAME": could not allocate scratchpad for " |
| 90 |
"%s (error %d)\n", test->driver_name, err); |
| 91 |
goto out; |
| 92 |
} |
| 93 |
|
| 94 |
cp_read_random(scratchpad, |
| 95 |
kcapi_cipher_blocksize(test->u.skcipher.handle) * |
| 96 |
params->len * |
| 97 |
(params->aio ? params->aio : 1)); |
| 98 |
|
| 99 |
test->u.skcipher.inputlen = |
| 100 |
params->len * kcapi_cipher_blocksize(test->u.skcipher.handle); |
| 101 |
test->u.skcipher.scratchpad = scratchpad; |
| 102 |
|
| 103 |
if (params->aio) { |
| 104 |
unsigned int i; |
| 105 |
|
| 106 |
err = posix_memalign((void *)&test->u.skcipher.iovec, bs, |
| 107 |
params->aio * sizeof(struct iovec)); |
| 108 |
if (err) { |
| 109 |
printf(DRIVER_NAME": could not allocate iovec buffer\n"); |
| 110 |
goto out; |
| 111 |
} |
| 112 |
|
| 113 |
for (i = 0; i < params->aio; i++) { |
| 114 |
test->u.skcipher.iovec[i].iov_base = scratchpad; |
| 115 |
test->u.skcipher.iovec[i].iov_len = test->u.skcipher.inputlen; |
| 116 |
scratchpad += test->u.skcipher.inputlen; |
| 117 |
} |
| 118 |
} |
| 119 |
|
| 120 |
return 0; |
| 121 |
|
| 122 |
out: |
| 123 |
kcapi_cipher_destroy(test->u.skcipher.handle); |
| 124 |
if (scratchpad) |
| 125 |
free(scratchpad); |
| 126 |
if (ivdata) |
| 127 |
free(ivdata); |
| 128 |
return -ENOMEM; |
| 129 |
} |
| 130 |
|
| 131 |
static void cp_skcipher_fini_test(struct cp_test *test) |
| 132 |
{ |
| 133 |
struct cp_test_param *params = test->test_params; |
| 134 |
|
| 135 |
dbg("Cleaning up asynchronous symmetric test %s\n", test->testname); |
| 136 |
free(test->u.skcipher.scratchpad); |
| 137 |
free(test->u.skcipher.iv); |
| 138 |
if (params->aio) |
| 139 |
free(test->u.skcipher.iovec); |
| 140 |
kcapi_cipher_destroy(test->u.skcipher.handle); |
| 141 |
} |
| 142 |
|
| 143 |
static size_t cp_skcipher_enc_test(struct cp_test *test) |
| 144 |
{ |
| 145 |
struct cp_test_param *params = test->test_params; |
| 146 |
|
| 147 |
if (params->aio) |
| 148 |
kcapi_cipher_encrypt_aio(test->u.skcipher.handle, |
| 149 |
test->u.skcipher.iovec, |
| 150 |
test->u.skcipher.iovec, |
| 151 |
params->aio, |
| 152 |
test->u.skcipher.iv, |
| 153 |
params->accesstype); |
| 154 |
else |
| 155 |
kcapi_cipher_encrypt(test->u.skcipher.handle, |
| 156 |
test->u.skcipher.scratchpad, |
| 157 |
test->u.skcipher.inputlen, |
| 158 |
test->u.skcipher.iv, |
| 159 |
test->u.skcipher.scratchpad, |
| 160 |
test->u.skcipher.inputlen, |
| 161 |
params->accesstype); |
| 162 |
return test->u.skcipher.inputlen; |
| 163 |
} |
| 164 |
|
| 165 |
static size_t cp_skcipher_dec_test(struct cp_test *test) |
| 166 |
{ |
| 167 |
struct cp_test_param *params = test->test_params; |
| 168 |
|
| 169 |
if (params->aio) |
| 170 |
kcapi_cipher_decrypt_aio(test->u.skcipher.handle, |
| 171 |
test->u.skcipher.iovec, |
| 172 |
test->u.skcipher.iovec, |
| 173 |
params->aio, |
| 174 |
test->u.skcipher.iv, |
| 175 |
params->accesstype); |
| 176 |
else |
| 177 |
kcapi_cipher_decrypt(test->u.skcipher.handle, |
| 178 |
test->u.skcipher.scratchpad, |
| 179 |
test->u.skcipher.inputlen, |
| 180 |
test->u.skcipher.iv, |
| 181 |
test->u.skcipher.scratchpad, |
| 182 |
test->u.skcipher.inputlen, |
| 183 |
params->accesstype); |
| 184 |
return test->u.skcipher.inputlen; |
| 185 |
} |
| 186 |
|
| 187 |
struct cp_skcipher_tests { |
| 188 |
char *testname; |
| 189 |
char *driver_name; |
| 190 |
unsigned int keysize; |
| 191 |
}; |
| 192 |
|
| 193 |
static const struct cp_skcipher_tests testcases[] = { |
| 194 |
|
| 195 |
{ "AES(G) CBC(G) 128", "cbc(aes-generic)", 16 }, |
| 196 |
{ "AES(G) CBC(G) 192", "cbc(aes-generic)", 24 }, |
| 197 |
{ "AES(G) CBC(G) 256", "cbc(aes-generic)", 32 }, |
| 198 |
{ "AES(AESNI) CBC(ASM) 128", "cbc-aes-aesni", 16 }, |
| 199 |
{ "AES(AESNI) CBC(ASM) 192", "cbc-aes-aesni", 24 }, |
| 200 |
{ "AES(AESNI) CBC(ASM) 256", "cbc-aes-aesni", 32 }, |
| 201 |
{ "AES(AESNI) CBC(G) 128", "cbc(aes-aesni)", 16 }, |
| 202 |
{ "AES(AESNI) CBC(G) 192", "cbc(aes-aesni)", 24 }, |
| 203 |
{ "AES(AESNI) CBC(G) 256", "cbc(aes-aesni)", 32 }, |
| 204 |
{ "AES(i586) CBC(G) 128", "cbc(aes-asm)", 16 }, |
| 205 |
{ "AES(i586) CBC(G) 192", "cbc(aes-asm)", 24 }, |
| 206 |
{ "AES(i586) CBC(G) 256", "cbc(aes-asm)", 32 }, |
| 207 |
|
| 208 |
{ "AES(CAAM) CBC(CAAM) 128", "cbc-aes-caam", 16 }, |
| 209 |
{ "AES(CAAM) CBC(CAAM) 192", "cbc-aes-caam", 24 }, |
| 210 |
{ "AES(CAAM) CBC(CAAM) 256", "cbc-aes-caam", 32 }, |
| 211 |
|
| 212 |
{ "AES(STM32) CBC(STM32) 128", "stm32-cbc-aes", 16 }, |
| 213 |
{ "AES(STM32) CBC(STM32) 192", "stm32-cbc-aes", 24 }, |
| 214 |
{ "AES(STM32) CBC(STM32) 256", "stm32-cbc-aes", 32 }, |
| 215 |
|
| 216 |
{ "AES(ARM64 CE) CBC(ARM64 CE) 128", "cbc-aes-ce", 16 }, |
| 217 |
{ "AES(ARM64 CE) CBC(ARM64 CE) 192", "cbc-aes-ce", 24 }, |
| 218 |
{ "AES(ARM64 CE) CBC(ARM64 CE) 256", "cbc-aes-ce", 32 }, |
| 219 |
|
| 220 |
{ "AES(MV-CESA) CBC(MV-CESA) 128", "mv-cbc-aes", 16 }, |
| 221 |
{ "AES(MV-CESA) CBC(MV-CESA) 192", "mv-cbc-aes", 24 }, |
| 222 |
{ "AES(MV-CESA) CBC(MV-CESA) 256", "mv-cbc-aes", 32 }, |
| 223 |
|
| 224 |
{ "AES(hisi) CBC 128", "hisi_sec_aes_cbc", 16 }, |
| 225 |
{ "AES(hisi) CBC 192", "hisi_sec_aes_cbc", 24 }, |
| 226 |
{ "AES(hisi) CBC 256", "hisi_sec_aes_cbc", 32 }, |
| 227 |
|
| 228 |
{ "AES(G) CTR(G) 128", "ctr(aes-generic)", 16 }, |
| 229 |
{ "AES(G) CTR(G) 192", "ctr(aes-generic)", 24 }, |
| 230 |
{ "AES(G) CTR(G) 256", "ctr(aes-generic)", 32 }, |
| 231 |
{ "AES(AESNI) CTR(ASM) 128", "ctr-aes-aesni", 16 }, |
| 232 |
{ "AES(AESNI) CTR(ASM) 192", "ctr-aes-aesni", 24 }, |
| 233 |
{ "AES(AESNI) CTR(ASM) 256", "ctr-aes-aesni", 32 }, |
| 234 |
{ "AES(AESNI) CTR(G) 128", "ctr(aes-aesni)", 16 }, |
| 235 |
{ "AES(AESNI) CTR(G) 192", "ctr(aes-aesni)", 24 }, |
| 236 |
{ "AES(AESNI) CTR(G) 256", "ctr(aes-aesni)", 32 }, |
| 237 |
{ "AES(i586) CTR(G) 128", "ctr(aes-asm)", 16 }, |
| 238 |
{ "AES(i586) CTR(G) 192", "ctr(aes-asm)", 24 }, |
| 239 |
{ "AES(i586) CTR(G) 256", "ctr(aes-asm)", 32 }, |
| 240 |
|
| 241 |
{ "AES(CAAM) CTR(CAAM) 128", "ctr-aes-caam", 16 }, |
| 242 |
{ "AES(CAAM) CTR(CAAM) 192", "ctr-aes-caam", 24 }, |
| 243 |
{ "AES(CAAM) CTR(CAAM) 256", "ctr-aes-caam", 32 }, |
| 244 |
|
| 245 |
{ "AES(STM32) CTR(STM32) 128", "stm32-ctr-aes", 16 }, |
| 246 |
{ "AES(STM32) CTR(STM32) 192", "stm32-ctr-aes", 24 }, |
| 247 |
{ "AES(STM32) CTR(STM32) 256", "stm32-ctr-aes", 32 }, |
| 248 |
|
| 249 |
{ "AES(ARM64 CE) CTR(ARM64 CE) 128", "ctr-aes-ce", 16 }, |
| 250 |
{ "AES(ARM64 CE) CTR(ARM64 CE) 192", "ctr-aes-ce", 24 }, |
| 251 |
{ "AES(ARM64 CE) CTR(ARM64 CE) 256", "ctr-aes-ce", 32 }, |
| 252 |
|
| 253 |
{ "AES(G) XTS(G) 128", "xts(aes-generic)", 32 }, |
| 254 |
{ "AES(G) XTS(G) 192", "xts(aes-generic)", 48 }, |
| 255 |
{ "AES(G) XTS(G) 256", "xts(aes-generic)", 64 }, |
| 256 |
{ "AES(AESNI) XTS(ASM) 128", "xts-aes-aesni", 32 }, |
| 257 |
{ "AES(AESNI) XTS(ASM) 192", "xts-aes-aesni", 48 }, |
| 258 |
{ "AES(AESNI) XTS(ASM) 256", "xts-aes-aesni", 64 }, |
| 259 |
{ "AES(AESNI) XTS(G) 128", "xts(aes-aesni)", 32 }, |
| 260 |
{ "AES(AESNI) XTS(G) 192", "xts(aes-aesni)", 48 }, |
| 261 |
{ "AES(AESNI) XTS(G) 256", "xts(aes-aesni)", 64 }, |
| 262 |
{ "AES(i586) XTS(G) 128", "xts(aes-asm)", 32 }, |
| 263 |
{ "AES(i586) XTS(G) 192", "xts(aes-asm)", 48 }, |
| 264 |
{ "AES(i586) XTS(G) 256", "xts(aes-asm)", 64 }, |
| 265 |
|
| 266 |
{ "AES(ARM64 CE) XTS(ARM64 CE) 128", "xts-aes-ce", 32 }, |
| 267 |
{ "AES(ARM64 CE) XTS(ARM64 CE) 192", "xts-aes-ce", 48 }, |
| 268 |
{ "AES(ARM64 CE) XTS(ARM64 CE) 256", "xts-aes-ce", 64 }, |
| 269 |
|
| 270 |
{ "AES(G) LRW(G) 128", "lrw(aes-generic)", 32 }, |
| 271 |
{ "AES(G) LRW(G) 192", "lrw(aes-generic)", 40 }, |
| 272 |
{ "AES(G) LRW(G) 256", "lrw(aes-generic)", 48 }, |
| 273 |
{ "AES(AESNI) LRW(ASM) 128", "lrw-aes-aesni", 32 }, |
| 274 |
{ "AES(AESNI) LRW(ASM) 192", "lrw-aes-aesni", 40 }, |
| 275 |
{ "AES(AESNI) LRW(ASM) 256", "lrw-aes-aesni", 48 }, |
| 276 |
{ "AES(AESNI) LRW(G) 128", "lrw(aes-aesni)", 32 }, |
| 277 |
{ "AES(AESNI) LRW(G) 192", "lrw(aes-aesni)", 40 }, |
| 278 |
{ "AES(AESNI) LRW(G) 256", "lrw(aes-aesni)", 48 }, |
| 279 |
{ "AES(i586) LRW(G) 128", "lrw(aes-asm)", 32 }, |
| 280 |
{ "AES(i586) LRW(G) 192", "lrw(aes-asm)", 40 }, |
| 281 |
{ "AES(i586) LRW(G) 256", "lrw(aes-asm)", 48 }, |
| 282 |
|
| 283 |
{ "AES(G) ECB(G) 128", "ecb(aes-generic)", 16 }, |
| 284 |
{ "AES(G) ECB(G) 192", "ecb(aes-generic)", 24 }, |
| 285 |
{ "AES(G) ECB(G) 256", "ecb(aes-generic)", 32 }, |
| 286 |
{ "AES(AESNI) ECB(ASM) 128", "ecb-aes-aesni", 16 }, |
| 287 |
{ "AES(AESNI) ECB(ASM) 192", "ecb-aes-aesni", 24 }, |
| 288 |
{ "AES(AESNI) ECB(ASM) 256", "ecb-aes-aesni", 32 }, |
| 289 |
{ "AES(AESNI) ECB(G) 128", "ecb(aes-aesni)", 16 }, |
| 290 |
{ "AES(AESNI) ECB(G) 192", "ecb(aes-aesni)", 24 }, |
| 291 |
{ "AES(AESNI) ECB(G) 256", "ecb(aes-aesni)", 32 }, |
| 292 |
{ "AES(i586) ECB(G) 128", "ecb(aes-asm)", 16 }, |
| 293 |
{ "AES(i586) ECB(G) 192", "ecb(aes-asm)", 24 }, |
| 294 |
{ "AES(i586) ECB(G) 256", "ecb(aes-asm)", 32 }, |
| 295 |
{ "AES(MV-CESA) ECB(MV-CESA) 128", "mv-ecb-aes", 16 }, |
| 296 |
{ "AES(MV-CESA) ECB(MV-CESA) 192", "mv-ecb-aes", 24 }, |
| 297 |
{ "AES(MV-CESA) ECB(MV-CESA) 256", "mv-ecb-aes", 32 }, |
| 298 |
|
| 299 |
{ "AES(CAAM) ECB(CAAM) 128", "ecb-aes-caam", 16 }, |
| 300 |
{ "AES(CAAM) ECB(CAAM) 192", "ecb-aes-caam", 24 }, |
| 301 |
{ "AES(CAAM) ECB(CAAM) 256", "ecb-aes-caam", 32 }, |
| 302 |
|
| 303 |
{ "AES(STM32) ECB(STM32) 128", "stm32-ecb-aes", 16 }, |
| 304 |
{ "AES(STM32) ECB(STM32) 192", "stm32-ecb-aes", 24 }, |
| 305 |
{ "AES(STM32) ECB(STM32) 256", "stm32-ecb-aes", 32 }, |
| 306 |
|
| 307 |
{ "AES(ARM64 CE) ECB(ARM64 CE) 128", "ecb-aes-ce", 16 }, |
| 308 |
{ "AES(ARM64 CE) ECB(ARM64 CE) 192", "ecb-aes-ce", 24 }, |
| 309 |
{ "AES(ARM64 CE) ECB(ARM64 CE) 256", "ecb-aes-ce", 32 }, |
| 310 |
|
| 311 |
{ "DES(MV-CESA) CBC(MV-CESA) 56", "mv-cbc-des", 8 }, |
| 312 |
{ "DES(MV-CESA) ECB(MV-CESA) 56", "mv-ecb-des", 8 }, |
| 313 |
|
| 314 |
{ "DES3(MV-CESA) CBC(MV-CESA) EDE 168", "mv-cbc-des3-ede", 24 }, |
| 315 |
{ "DES3(MV-CESA) ECB(MV-CESA) EDE 168", "mv-ecb-des3-ede", 24 }, |
| 316 |
|
| 317 |
{ "Serpent(AVX) XTS(AVX) 128", "xts-serpent-avx", 32 }, |
| 318 |
{ "Serpent(AVX) XTS(AVX) 192", "xts-serpent-avx", 48 }, |
| 319 |
{ "Serpent(AVX) XTS(AVX) 256", "xts-serpent-avx", 64 }, |
| 320 |
{ "Serpent(AVX2) XTS(AVX2) 128", "xts-serpent-avx2", 32 }, |
| 321 |
{ "Serpent(AVX2) XTS(AVX2) 192", "xts-serpent-avx2", 48 }, |
| 322 |
{ "Serpent(AVX2) XTS(AVX2) 256", "xts-serpent-avx2", 64 }, |
| 323 |
{ "Serpent(SSE2) XTS(SSE2) 128", "xts-serpent-sse2", 32 }, |
| 324 |
{ "Serpent(SSE2) XTS(SSE2) 192", "xts-serpent-sse2", 48 }, |
| 325 |
{ "Serpent(SSE2) XTS(SSE2) 256", "xts-serpent-sse2", 64 }, |
| 326 |
{ "Serpent(G) XTS(G) 128", "xts(serpent-generic)", 32 }, |
| 327 |
{ "Serpent(G) XTS(G) 192", "xts(serpent-generic)", 48 }, |
| 328 |
{ "Serpent(G) XTS(G) 256", "xts(serpent-generic)", 64 }, |
| 329 |
|
| 330 |
{ "Serpent(AVX) LRW(AVX) 128", "lrw-serpent-avx", 32 }, |
| 331 |
{ "Serpent(AVX) LRW(AVX) 192", "lrw-serpent-avx", 40 }, |
| 332 |
{ "Serpent(AVX) LRW(AVX) 256", "lrw-serpent-avx", 48 }, |
| 333 |
{ "Serpent(AVX2) LRW(AVX2) 128", "lrw-serpent-avx2", 32 }, |
| 334 |
{ "Serpent(AVX2) LRW(AVX2) 192", "lrw-serpent-avx2", 40 }, |
| 335 |
{ "Serpent(AVX2) LRW(AVX2) 256", "lrw-serpent-avx2", 48 }, |
| 336 |
{ "Serpent(SSE2) LRW(SSE2) 128", "lrw-serpent-sse2", 32 }, |
| 337 |
{ "Serpent(SSE2) LRW(SSE2) 192", "lrw-serpent-sse2", 40 }, |
| 338 |
{ "Serpent(SSE2) LRW(SSE2) 256", "lrw-serpent-sse2", 48 }, |
| 339 |
{ "Serpent(G) LRW(G) 128", "lrw(serpent-generic)", 32 }, |
| 340 |
{ "Serpent(G) LRW(G) 192", "lrw(serpent-generic)", 40 }, |
| 341 |
{ "Serpent(G) LRW(G) 256", "lrw(serpent-generic)", 48 }, |
| 342 |
|
| 343 |
{ "Serpent(AVX) CTR(AVX) 128", "ctr-serpent-avx", 16 }, |
| 344 |
{ "Serpent(AVX) CTR(AVX) 192", "ctr-serpent-avx", 24 }, |
| 345 |
{ "Serpent(AVX) CTR(AVX) 256", "ctr-serpent-avx", 32 }, |
| 346 |
{ "Serpent(AVX2) CTR(AVX2) 128", "ctr-serpent-avx2", 16 }, |
| 347 |
{ "Serpent(AVX2) CTR(AVX2) 192", "ctr-serpent-avx2", 24 }, |
| 348 |
{ "Serpent(AVX2) CTR(AVX2) 256", "ctr-serpent-avx2", 32 }, |
| 349 |
{ "Serpent(SSE2) CTR(SSE2) 128", "ctr-serpent-sse2", 16 }, |
| 350 |
{ "Serpent(SSE2) CTR(SSE2) 192", "ctr-serpent-sse2", 24 }, |
| 351 |
{ "Serpent(SSE2) CTR(SSE2) 256", "ctr-serpent-sse2", 32 }, |
| 352 |
{ "Serpent(G) CTR(G) 128", "ctr(serpent-generic)", 16 }, |
| 353 |
{ "Serpent(G) CTR(G) 192", "ctr(serpent-generic)", 24 }, |
| 354 |
{ "Serpent(G) CTR(G) 256", "ctr(serpent-generic)", 32 }, |
| 355 |
|
| 356 |
{ "Serpent(AVX) CBC(AVX) 128", "cbc-serpent-avx", 16 }, |
| 357 |
{ "Serpent(AVX) CBC(AVX) 192", "cbc-serpent-avx", 24 }, |
| 358 |
{ "Serpent(AVX) CBC(AVX) 256", "cbc-serpent-avx", 32 }, |
| 359 |
{ "Serpent(AVX2) CBC(AVX2) 128", "cbc-serpent-avx2", 16 }, |
| 360 |
{ "Serpent(AVX2) CBC(AVX2) 192", "cbc-serpent-avx2", 24 }, |
| 361 |
{ "Serpent(AVX2) CBC(AVX2) 256", "cbc-serpent-avx2", 32 }, |
| 362 |
{ "Serpent(SSE2) CBC(SSE2) 128", "cbc-serpent-sse2", 16 }, |
| 363 |
{ "Serpent(SSE2) CBC(SSE2) 192", "cbc-serpent-sse2", 24 }, |
| 364 |
{ "Serpent(SSE2) CBC(SSE2) 256", "cbc-serpent-sse2", 32 }, |
| 365 |
{ "Serpent(G) CBC(G) 128", "cbc(serpent-generic)", 16 }, |
| 366 |
{ "Serpent(G) CBC(G) 192", "cbc(serpent-generic)", 24 }, |
| 367 |
{ "Serpent(G) CBC(G) 256", "cbc(serpent-generic)", 32 }, |
| 368 |
|
| 369 |
{ "Serpent(AVX) ECB(AVX) 128", "ecb-serpent-avx", 16 }, |
| 370 |
{ "Serpent(AVX) ECB(AVX) 192", "ecb-serpent-avx", 24 }, |
| 371 |
{ "Serpent(AVX) ECB(AVX) 256", "ecb-serpent-avx", 32 }, |
| 372 |
{ "Serpent(AVX2) ECB(AVX2) 128", "ecb-serpent-avx2", 16 }, |
| 373 |
{ "Serpent(AVX2) ECB(AVX2) 192", "ecb-serpent-avx2", 24 }, |
| 374 |
{ "Serpent(AVX2) ECB(AVX2) 256", "ecb-serpent-avx2", 32 }, |
| 375 |
{ "Serpent(SSE2) ECB(SSE2) 128", "ecb-serpent-sse2", 16 }, |
| 376 |
{ "Serpent(SSE2) ECB(SSE2) 192", "ecb-serpent-sse2", 24 }, |
| 377 |
{ "Serpent(SSE2) ECB(SSE2) 256", "ecb-serpent-sse2", 32 }, |
| 378 |
{ "Serpent(G) ECB(G) 128", "ecb(serpent-generic)", 16 }, |
| 379 |
{ "Serpent(G) ECB(G) 192", "ecb(serpent-generic)", 24 }, |
| 380 |
{ "Serpent(G) ECB(G) 256", "ecb(serpent-generic)", 32 }, |
| 381 |
|
| 382 |
{ "Blowfish(G) ECB(G) 128", "ecb(blowfish-generic)", 16 }, |
| 383 |
{ "Blowfish(G) ECB(G) 192", "ecb(blowfish-generic)", 24 }, |
| 384 |
{ "Blowfish(G) ECB(G) 256", "ecb(blowfish-generic)", 32 }, |
| 385 |
{ "Blowfish(x86_64) ECB(G) 128", "ecb(blowfish-asm)", 16 }, |
| 386 |
{ "Blowfish(x86_64) ECB(G) 192", "ecb(blowfish-asm)", 24 }, |
| 387 |
{ "Blowfish(x86_64) ECB(G) 256", "ecb(blowfish-asm)", 32 }, |
| 388 |
{ "Blowfish(x86_64) ECB(x86_64) 128", "ecb-blowfish-asm", 16 }, |
| 389 |
{ "Blowfish(x86_64) ECB(x86_64) 192", "ecb-blowfish-asm", 24 }, |
| 390 |
{ "Blowfish(x86_64) ECB(x86_64) 256", "ecb-blowfish-asm", 32 }, |
| 391 |
|
| 392 |
{ "Blowfish(G) CBC(G) 128", "cbc(blowfish-generic)", 16 }, |
| 393 |
{ "Blowfish(G) CBC(G) 192", "cbc(blowfish-generic)", 24 }, |
| 394 |
{ "Blowfish(G) CBC(G) 256", "cbc(blowfish-generic)", 32 }, |
| 395 |
{ "Blowfish(x86_64) CBC(G) 128", "cbc(blowfish-asm)", 16 }, |
| 396 |
{ "Blowfish(x86_64) CBC(G) 192", "cbc(blowfish-asm)", 24 }, |
| 397 |
{ "Blowfish(x86_64) CBC(G) 256", "cbc(blowfish-asm)", 32 }, |
| 398 |
{ "Blowfish(x86_64) CBC(x86_64) 128", "cbc-blowfish-asm", 16 }, |
| 399 |
{ "Blowfish(x86_64) CBC(x86_64) 192", "cbc-blowfish-asm", 24 }, |
| 400 |
{ "Blowfish(x86_64) CBC(x86_64) 256", "cbc-blowfish-asm", 32 }, |
| 401 |
|
| 402 |
{ "Blowfish(G) CTR(G) 128", "ctr(blowfish-generic)", 16 }, |
| 403 |
{ "Blowfish(G) CTR(G) 192", "ctr(blowfish-generic)", 24 }, |
| 404 |
{ "Blowfish(G) CTR(G) 256", "ctr(blowfish-generic)", 32 }, |
| 405 |
{ "Blowfish(x86_64) CTR(G) 128", "ctr(blowfish-asm)", 16 }, |
| 406 |
{ "Blowfish(x86_64) CTR(G) 192", "ctr(blowfish-asm)", 24 }, |
| 407 |
{ "Blowfish(x86_64) CTR(G) 256", "ctr(blowfish-asm)", 32 }, |
| 408 |
{ "Blowfish(x86_64) CTR(x86_64) 128", "ctr-blowfish-asm", 16 }, |
| 409 |
{ "Blowfish(x86_64) CTR(x86_64) 192", "ctr-blowfish-asm", 24 }, |
| 410 |
{ "Blowfish(x86_64) CTR(x86_64) 256", "ctr-blowfish-asm", 32 }, |
| 411 |
|
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
{ "Twofish(G) ECB(G) 128", "ecb(twofish-generic)", 16 }, |
| 428 |
{ "Twofish(G) ECB(G) 192", "ecb(twofish-generic)", 24 }, |
| 429 |
{ "Twofish(G) ECB(G) 256", "ecb(twofish-generic)", 32 }, |
| 430 |
{ "Twofish(x86_64) ECB(G) 128", "ecb(twofish-asm)", 16 }, |
| 431 |
{ "Twofish(x86_64) ECB(G) 192", "ecb(twofish-asm)", 24 }, |
| 432 |
{ "Twofish(x86_64) ECB(G) 256", "ecb(twofish-asm)", 32 }, |
| 433 |
{ "Twofish(3way) ECB(3way) 128", "ecb-twofish-3way", 16 }, |
| 434 |
{ "Twofish(3way) ECB(3way) 192", "ecb-twofish-3way", 24 }, |
| 435 |
{ "Twofish(3way) ECB(3way) 256", "ecb-twofish-3way", 32 }, |
| 436 |
{ "Twofish(AVX) ECB(AVX) 128", "ecb-twofish-avx", 16 }, |
| 437 |
{ "Twofish(AVX) ECB(AVX) 192", "ecb-twofish-avx", 24 }, |
| 438 |
{ "Twofish(AVX) ECB(AVX) 256", "ecb-twofish-avx", 32 }, |
| 439 |
|
| 440 |
{ "Twofish(G) CBC(G) 128", "cbc(twofish-generic)", 16 }, |
| 441 |
{ "Twofish(G) CBC(G) 192", "cbc(twofish-generic)", 24 }, |
| 442 |
{ "Twofish(G) CBC(G) 256", "cbc(twofish-generic)", 32 }, |
| 443 |
{ "Twofish(x86_64) CBC(G) 128", "cbc(twofish-asm)", 16 }, |
| 444 |
{ "Twofish(x86_64) CBC(G) 192", "cbc(twofish-asm)", 24 }, |
| 445 |
{ "Twofish(x86_64) CBC(G) 256", "cbc(twofish-asm)", 32 }, |
| 446 |
{ "Twofish(3way) CBC(3way) 128", "cbc-twofish-3way", 16 }, |
| 447 |
{ "Twofish(3way) CBC(3way) 192", "cbc-twofish-3way", 24 }, |
| 448 |
{ "Twofish(3way) CBC(3way) 256", "cbc-twofish-3way", 32 }, |
| 449 |
{ "Twofish(AVX) CBC(AVX) 128", "cbc-twofish-avx", 16 }, |
| 450 |
{ "Twofish(AVX) CBC(AVX) 192", "cbc-twofish-avx", 24 }, |
| 451 |
{ "Twofish(AVX) CBC(AVX) 256", "cbc-twofish-avx", 32 }, |
| 452 |
|
| 453 |
{ "Twofish(G) CTR(G) 128", "ctr(twofish-generic)", 16 }, |
| 454 |
{ "Twofish(G) CTR(G) 192", "ctr(twofish-generic)", 24 }, |
| 455 |
{ "Twofish(G) CTR(G) 256", "ctr(twofish-generic)", 32 }, |
| 456 |
{ "Twofish(x86_64) CTR(G) 128", "ctr(twofish-asm)", 16 }, |
| 457 |
{ "Twofish(x86_64) CTR(G) 192", "ctr(twofish-asm)", 24 }, |
| 458 |
{ "Twofish(x86_64) CTR(G) 256", "ctr(twofish-asm)", 32 }, |
| 459 |
{ "Twofish(3way) CTR(3way) 128", "ctr-twofish-3way", 16 }, |
| 460 |
{ "Twofish(3way) CTR(3way) 192", "ctr-twofish-3way", 24 }, |
| 461 |
{ "Twofish(3way) CTR(3way) 256", "ctr-twofish-3way", 32 }, |
| 462 |
{ "Twofish(AVX) CTR(AVX) 128", "ctr-twofish-avx", 16 }, |
| 463 |
{ "Twofish(AVX) CTR(AVX) 192", "ctr-twofish-avx", 24 }, |
| 464 |
{ "Twofish(AVX) CTR(AVX) 256", "ctr-twofish-avx", 32 }, |
| 465 |
|
| 466 |
{ "Twofish(G) XTS(G) 128", "xts(twofish-generic)", 32 }, |
| 467 |
{ "Twofish(G) XTS(G) 192", "xts(twofish-generic)", 48 }, |
| 468 |
{ "Twofish(G) XTS(G) 256", "xts(twofish-generic)", 64 }, |
| 469 |
{ "Twofish(x86_64) XTS(G) 128", "xts(twofish-asm)", 32 }, |
| 470 |
{ "Twofish(x86_64) XTS(G) 192", "xts(twofish-asm)", 48 }, |
| 471 |
{ "Twofish(x86_64) XTS(G) 256", "xts(twofish-asm)", 64 }, |
| 472 |
{ "Twofish(3way) XTS(3way) 128", "xts-twofish-3way", 32 }, |
| 473 |
{ "Twofish(3way) XTS(3way) 192", "xts-twofish-3way", 48 }, |
| 474 |
{ "Twofish(3way) XTS(3way) 256", "xts-twofish-3way", 64 }, |
| 475 |
{ "Twofish(AVX) XTS(AVX) 128", "xts-twofish-avx", 32 }, |
| 476 |
{ "Twofish(AVX) XTS(AVX) 192", "xts-twofish-avx", 48 }, |
| 477 |
{ "Twofish(AVX) XTS(AVX) 256", "xts-twofish-avx", 64 }, |
| 478 |
|
| 479 |
{ "Twofish(G) LRW(G) 128", "lrw(twofish-generic)", 32 }, |
| 480 |
{ "Twofish(G) LRW(G) 192", "lrw(twofish-generic)", 40 }, |
| 481 |
{ "Twofish(G) LRW(G) 256", "lrw(twofish-generic)", 48 }, |
| 482 |
{ "Twofish(x86_64) LRW(G) 128", "lrw(twofish-asm)", 32 }, |
| 483 |
{ "Twofish(x86_64) LRW(G) 192", "lrw(twofish-asm)", 40 }, |
| 484 |
{ "Twofish(x86_64) LRW(G) 256", "lrw(twofish-asm)", 48 }, |
| 485 |
{ "Twofish(3way) LRW(3way) 128", "lrw-twofish-3way", 32 }, |
| 486 |
{ "Twofish(3way) LRW(3way) 192", "lrw-twofish-3way", 40 }, |
| 487 |
{ "Twofish(3way) LRW(3way) 256", "lrw-twofish-3way", 48 }, |
| 488 |
{ "Twofish(AVX) LRW(AVX) 128", "lrw-twofish-avx", 32 }, |
| 489 |
{ "Twofish(AVX) LRW(AVX) 192", "lrw-twofish-avx", 40 }, |
| 490 |
{ "Twofish(AVX) LRW(AVX) 256", "lrw-twofish-avx", 48 }, |
| 491 |
|
| 492 |
{ "Salsa20(G) 128", "salsa20-generic", 16 }, |
| 493 |
{ "Salsa20(G) 192", "salsa20-generic", 24 }, |
| 494 |
{ "Salsa20(G) 256", "salsa20-generic", 32 }, |
| 495 |
{ "Salsa20(x86) 128", "salsa20-asm", 16 }, |
| 496 |
{ "Salsa20(x86) 192", "salsa20-asm", 24 }, |
| 497 |
{ "Salsa20(x86) 256", "salsa20-asm", 32 }, |
| 498 |
|
| 499 |
{ "SM4(G) ECB(G)", "ecb(sm4-generic)", 16 }, |
| 500 |
{ "SM4(AVX) ECB(AVX)", "ecb-sm4-aesni-avx)", 16 }, |
| 501 |
{ "SM4(AVX2) ECB(AVX2)", "ecb-sm4-aesni-avx2)", 16 }, |
| 502 |
{ "SM4(G) CBC(G)", "cbc(sm4-generic)", 16 }, |
| 503 |
{ "SM4(AVX) CBC(AVX)", "cbc-sm4-aesni-avx)", 16 }, |
| 504 |
{ "SM4(AVX2) CBC(AVX2)", "cbc-sm4-aesni-avx2)", 16 }, |
| 505 |
{ "SM4(G) CFB(G)", "cfb(sm4-generic)", 16 }, |
| 506 |
{ "SM4(AVX) CFB(AVX)", "cfb-sm4-aesni-avx)", 16 }, |
| 507 |
{ "SM4(AVX2) CFB(AVX2)", "cfb-sm4-aesni-avx2)", 16 }, |
| 508 |
{ "SM4(G) CTR(G)", "ctr(sm4-generic)", 16 }, |
| 509 |
{ "SM4(AVX) CTR(AVX)", "ctr-sm4-aesni-avx)", 16 }, |
| 510 |
{ "SM4(AVX2) CTR(AVX2)", "ctr-sm4-aesni-avx2)", 16 }, |
| 511 |
}; |
| 512 |
|
| 513 |
static struct cp_test cp_skcipher_testdef[2 * (ARRAY_SIZE(testcases))]; |
| 514 |
|
| 515 |
void cp_skcipher_register(struct cp_test **skcipher_test, size_t *entries) |
| 516 |
{ |
| 517 |
size_t i, j; |
| 518 |
|
| 519 |
for (i = 0, j = 0; |
| 520 |
i < (ARRAY_SIZE(testcases)) && j < (2 * ARRAY_SIZE(testcases)); |
| 521 |
i++, j++) { |
| 522 |
int enc = 0; |
| 523 |
for (enc = 0; enc < 2; enc++) { |
| 524 |
j += (size_t)enc; |
| 525 |
cp_skcipher_testdef[j].enc = enc; |
| 526 |
cp_skcipher_testdef[j].testname = testcases[i].testname; |
| 527 |
cp_skcipher_testdef[j].driver_name = |
| 528 |
testcases[i].driver_name; |
| 529 |
cp_skcipher_testdef[j].type = "skcipher"; |
| 530 |
cp_skcipher_testdef[j].exectime = DFLT_EXECTIME; |
| 531 |
cp_skcipher_testdef[j].u.skcipher.keysize = |
| 532 |
testcases[i].keysize; |
| 533 |
cp_skcipher_testdef[j].init_test = cp_skcipher_init_test; |
| 534 |
cp_skcipher_testdef[j].fini_test = cp_skcipher_fini_test; |
| 535 |
if (enc) |
| 536 |
cp_skcipher_testdef[j].exec_test = cp_skcipher_enc_test; |
| 537 |
else |
| 538 |
cp_skcipher_testdef[j].exec_test = cp_skcipher_dec_test; |
| 539 |
} |
| 540 |
} |
| 541 |
*skcipher_test = &cp_skcipher_testdef[0]; |
| 542 |
*entries = j; |
| 543 |
} |