From 548bf316319a8522c0a3dfe9478ec8aaea8ed8d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Sat, 18 Mar 2017 17:12:16 +0100 Subject: [PATCH] Implement DES (single-key ECB only for now). --- include/cryb/Makefile.am | 1 + include/cryb/des.h | 64 ++ lib/cipher/Makefile.am | 1 + lib/cipher/cryb_des.c | 409 +++++++ t/.gitignore | 1 + t/Makefile.am | 3 +- t/t_des.c | 2172 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 2650 insertions(+), 1 deletion(-) create mode 100644 include/cryb/des.h create mode 100644 lib/cipher/cryb_des.c create mode 100644 t/t_des.c diff --git a/include/cryb/Makefile.am b/include/cryb/Makefile.am index 78fd5f9..49872e8 100644 --- a/include/cryb/Makefile.am +++ b/include/cryb/Makefile.am @@ -6,6 +6,7 @@ if CRYB_CIPHER cryb_HEADERS += \ aes.h \ chacha.h \ + des.h \ rc4.h \ salsa.h \ \ diff --git a/include/cryb/des.h b/include/cryb/des.h new file mode 100644 index 0000000..b159866 --- /dev/null +++ b/include/cryb/des.h @@ -0,0 +1,64 @@ +/*- + * Copyright (c) 2015-2016 Dag-Erling Smørgrav + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef CRYB_DES_H_INCLUDED +#define CRYB_DES_H_INCLUDED + +#ifndef CRYB_TO +#include +#endif + +#include + +CRYB_BEGIN + +#define DES_BLOCK_LEN 8 + +#define des_cipher cryb_des_cipher +#define des_ctx cryb_des_ctx +#define des_init cryb_des_init +#define des_keystream cryb_des_keystream +#define des_encrypt cryb_des_encrypt +#define des_decrypt cryb_des_decrypt +#define des_finish cryb_des_finish + +extern cipher_algorithm des_cipher; + +typedef struct { + uint32_t sk[32]; +} des_ctx; + +void des_init(des_ctx *, cipher_mode mode, const uint8_t *, size_t); +size_t des_encrypt(des_ctx *, const void *, uint8_t *, size_t); +size_t des_decrypt(des_ctx *, const uint8_t *, void *, size_t); +void des_finish(des_ctx *); + +CRYB_END + +#endif diff --git a/lib/cipher/Makefile.am b/lib/cipher/Makefile.am index 647f273..890d6b4 100644 --- a/lib/cipher/Makefile.am +++ b/lib/cipher/Makefile.am @@ -5,6 +5,7 @@ lib_LTLIBRARIES = libcryb-cipher.la libcryb_cipher_la_SOURCES = \ cryb_aes.c \ cryb_chacha.c \ + cryb_des.c \ cryb_rc4.c \ cryb_salsa.c \ \ diff --git a/lib/cipher/cryb_des.c b/lib/cipher/cryb_des.c new file mode 100644 index 0000000..d639d81 --- /dev/null +++ b/lib/cipher/cryb_des.c @@ -0,0 +1,409 @@ +/*- + * Copyright (c) 2006-2007 Christophe Devine + * Copyright (c) 2017 Dag-Erling Smørgrav + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "cryb/impl.h" + +#include +#include + +#include +#include +#include + +#include + +/* + * Expanded DES S-boxes + */ +static const uint32_t sb1[64] = { + 0x01010400, 0x00000000, 0x00010000, 0x01010404, + 0x01010004, 0x00010404, 0x00000004, 0x00010000, + 0x00000400, 0x01010400, 0x01010404, 0x00000400, + 0x01000404, 0x01010004, 0x01000000, 0x00000004, + 0x00000404, 0x01000400, 0x01000400, 0x00010400, + 0x00010400, 0x01010000, 0x01010000, 0x01000404, + 0x00010004, 0x01000004, 0x01000004, 0x00010004, + 0x00000000, 0x00000404, 0x00010404, 0x01000000, + 0x00010000, 0x01010404, 0x00000004, 0x01010000, + 0x01010400, 0x01000000, 0x01000000, 0x00000400, + 0x01010004, 0x00010000, 0x00010400, 0x01000004, + 0x00000400, 0x00000004, 0x01000404, 0x00010404, + 0x01010404, 0x00010004, 0x01010000, 0x01000404, + 0x01000004, 0x00000404, 0x00010404, 0x01010400, + 0x00000404, 0x01000400, 0x01000400, 0x00000000, + 0x00010004, 0x00010400, 0x00000000, 0x01010004 +}; + +static const uint32_t sb2[64] = { + 0x80108020, 0x80008000, 0x00008000, 0x00108020, + 0x00100000, 0x00000020, 0x80100020, 0x80008020, + 0x80000020, 0x80108020, 0x80108000, 0x80000000, + 0x80008000, 0x00100000, 0x00000020, 0x80100020, + 0x00108000, 0x00100020, 0x80008020, 0x00000000, + 0x80000000, 0x00008000, 0x00108020, 0x80100000, + 0x00100020, 0x80000020, 0x00000000, 0x00108000, + 0x00008020, 0x80108000, 0x80100000, 0x00008020, + 0x00000000, 0x00108020, 0x80100020, 0x00100000, + 0x80008020, 0x80100000, 0x80108000, 0x00008000, + 0x80100000, 0x80008000, 0x00000020, 0x80108020, + 0x00108020, 0x00000020, 0x00008000, 0x80000000, + 0x00008020, 0x80108000, 0x00100000, 0x80000020, + 0x00100020, 0x80008020, 0x80000020, 0x00100020, + 0x00108000, 0x00000000, 0x80008000, 0x00008020, + 0x80000000, 0x80100020, 0x80108020, 0x00108000 +}; + +static const uint32_t sb3[64] = { + 0x00000208, 0x08020200, 0x00000000, 0x08020008, + 0x08000200, 0x00000000, 0x00020208, 0x08000200, + 0x00020008, 0x08000008, 0x08000008, 0x00020000, + 0x08020208, 0x00020008, 0x08020000, 0x00000208, + 0x08000000, 0x00000008, 0x08020200, 0x00000200, + 0x00020200, 0x08020000, 0x08020008, 0x00020208, + 0x08000208, 0x00020200, 0x00020000, 0x08000208, + 0x00000008, 0x08020208, 0x00000200, 0x08000000, + 0x08020200, 0x08000000, 0x00020008, 0x00000208, + 0x00020000, 0x08020200, 0x08000200, 0x00000000, + 0x00000200, 0x00020008, 0x08020208, 0x08000200, + 0x08000008, 0x00000200, 0x00000000, 0x08020008, + 0x08000208, 0x00020000, 0x08000000, 0x08020208, + 0x00000008, 0x00020208, 0x00020200, 0x08000008, + 0x08020000, 0x08000208, 0x00000208, 0x08020000, + 0x00020208, 0x00000008, 0x08020008, 0x00020200 +}; + +static const uint32_t sb4[64] = { + 0x00802001, 0x00002081, 0x00002081, 0x00000080, + 0x00802080, 0x00800081, 0x00800001, 0x00002001, + 0x00000000, 0x00802000, 0x00802000, 0x00802081, + 0x00000081, 0x00000000, 0x00800080, 0x00800001, + 0x00000001, 0x00002000, 0x00800000, 0x00802001, + 0x00000080, 0x00800000, 0x00002001, 0x00002080, + 0x00800081, 0x00000001, 0x00002080, 0x00800080, + 0x00002000, 0x00802080, 0x00802081, 0x00000081, + 0x00800080, 0x00800001, 0x00802000, 0x00802081, + 0x00000081, 0x00000000, 0x00000000, 0x00802000, + 0x00002080, 0x00800080, 0x00800081, 0x00000001, + 0x00802001, 0x00002081, 0x00002081, 0x00000080, + 0x00802081, 0x00000081, 0x00000001, 0x00002000, + 0x00800001, 0x00002001, 0x00802080, 0x00800081, + 0x00002001, 0x00002080, 0x00800000, 0x00802001, + 0x00000080, 0x00800000, 0x00002000, 0x00802080 +}; + +static const uint32_t sb5[64] = { + 0x00000100, 0x02080100, 0x02080000, 0x42000100, + 0x00080000, 0x00000100, 0x40000000, 0x02080000, + 0x40080100, 0x00080000, 0x02000100, 0x40080100, + 0x42000100, 0x42080000, 0x00080100, 0x40000000, + 0x02000000, 0x40080000, 0x40080000, 0x00000000, + 0x40000100, 0x42080100, 0x42080100, 0x02000100, + 0x42080000, 0x40000100, 0x00000000, 0x42000000, + 0x02080100, 0x02000000, 0x42000000, 0x00080100, + 0x00080000, 0x42000100, 0x00000100, 0x02000000, + 0x40000000, 0x02080000, 0x42000100, 0x40080100, + 0x02000100, 0x40000000, 0x42080000, 0x02080100, + 0x40080100, 0x00000100, 0x02000000, 0x42080000, + 0x42080100, 0x00080100, 0x42000000, 0x42080100, + 0x02080000, 0x00000000, 0x40080000, 0x42000000, + 0x00080100, 0x02000100, 0x40000100, 0x00080000, + 0x00000000, 0x40080000, 0x02080100, 0x40000100 +}; + +static const uint32_t sb6[64] = { + 0x20000010, 0x20400000, 0x00004000, 0x20404010, + 0x20400000, 0x00000010, 0x20404010, 0x00400000, + 0x20004000, 0x00404010, 0x00400000, 0x20000010, + 0x00400010, 0x20004000, 0x20000000, 0x00004010, + 0x00000000, 0x00400010, 0x20004010, 0x00004000, + 0x00404000, 0x20004010, 0x00000010, 0x20400010, + 0x20400010, 0x00000000, 0x00404010, 0x20404000, + 0x00004010, 0x00404000, 0x20404000, 0x20000000, + 0x20004000, 0x00000010, 0x20400010, 0x00404000, + 0x20404010, 0x00400000, 0x00004010, 0x20000010, + 0x00400000, 0x20004000, 0x20000000, 0x00004010, + 0x20000010, 0x20404010, 0x00404000, 0x20400000, + 0x00404010, 0x20404000, 0x00000000, 0x20400010, + 0x00000010, 0x00004000, 0x20400000, 0x00404010, + 0x00004000, 0x00400010, 0x20004010, 0x00000000, + 0x20404000, 0x20000000, 0x00400010, 0x20004010 +}; + +static const uint32_t sb7[64] = { + 0x00200000, 0x04200002, 0x04000802, 0x00000000, + 0x00000800, 0x04000802, 0x00200802, 0x04200800, + 0x04200802, 0x00200000, 0x00000000, 0x04000002, + 0x00000002, 0x04000000, 0x04200002, 0x00000802, + 0x04000800, 0x00200802, 0x00200002, 0x04000800, + 0x04000002, 0x04200000, 0x04200800, 0x00200002, + 0x04200000, 0x00000800, 0x00000802, 0x04200802, + 0x00200800, 0x00000002, 0x04000000, 0x00200800, + 0x04000000, 0x00200800, 0x00200000, 0x04000802, + 0x04000802, 0x04200002, 0x04200002, 0x00000002, + 0x00200002, 0x04000000, 0x04000800, 0x00200000, + 0x04200800, 0x00000802, 0x00200802, 0x04200800, + 0x00000802, 0x04000002, 0x04200802, 0x04200000, + 0x00200800, 0x00000000, 0x00000002, 0x04200802, + 0x00000000, 0x00200802, 0x04200000, 0x00000800, + 0x04000002, 0x04000800, 0x00000800, 0x00200002 +}; + +static const uint32_t sb8[64] = { + 0x10001040, 0x00001000, 0x00040000, 0x10041040, + 0x10000000, 0x10001040, 0x00000040, 0x10000000, + 0x00040040, 0x10040000, 0x10041040, 0x00041000, + 0x10041000, 0x00041040, 0x00001000, 0x00000040, + 0x10040000, 0x10000040, 0x10001000, 0x00001040, + 0x00041000, 0x00040040, 0x10040040, 0x10041000, + 0x00001040, 0x00000000, 0x00000000, 0x10040040, + 0x10000040, 0x10001000, 0x00041040, 0x00040000, + 0x00041040, 0x00040000, 0x10041000, 0x00001000, + 0x00000040, 0x10040040, 0x00001000, 0x00041040, + 0x10001000, 0x00000040, 0x10000040, 0x10040000, + 0x10040040, 0x10000000, 0x00040000, 0x10001040, + 0x00000000, 0x10041040, 0x00040040, 0x10000040, + 0x10040000, 0x10001000, 0x10001040, 0x00000000, + 0x10041040, 0x00041000, 0x00041000, 0x00001040, + 0x00001040, 0x00040040, 0x10000000, 0x10041000 +}; + +/* + * PC1: left and right halves bit-swap + */ +static const uint32_t lhs[16] = { + 0x00000000, 0x00000001, 0x00000100, 0x00000101, + 0x00010000, 0x00010001, 0x00010100, 0x00010101, + 0x01000000, 0x01000001, 0x01000100, 0x01000101, + 0x01010000, 0x01010001, 0x01010100, 0x01010101 +}; + +static const uint32_t rhs[16] = { + 0x00000000, 0x01000000, 0x00010000, 0x01010000, + 0x00000100, 0x01000100, 0x00010100, 0x01010100, + 0x00000001, 0x01000001, 0x00010001, 0x01010001, + 0x00000101, 0x01000101, 0x00010101, 0x01010101, +}; + +/* + * Initial Permutation macro + */ +#define DES_IP(x,y) \ + do { \ + t = (x >> 4 ^ y) & 0x0f0f0f0f; y ^= t; x ^= t << 4; \ + t = (x >> 16 ^ y) & 0x0000ffff; y ^= t; x ^= t << 16; \ + t = (y >> 2 ^ x) & 0x33333333; x ^= t; y ^= t << 2; \ + t = (y >> 8 ^ x) & 0x00ff00ff; x ^= t; y ^= t << 8; \ + y = rol32(y, 1) & 0xffffffff; \ + t = (x ^ y) & 0xaaaaaaaa; y ^= t; x ^= t; \ + x = rol32(x, 1) & 0xffffffff; \ + } while (0) + +/* + * Final Permutation macro + */ +#define DES_FP(x,y) \ + do { \ + x = ror32(x, 1) & 0xffffffff; \ + t = (x ^ y) & 0xaaaaaaaa; x ^= t; y ^= t; \ + y = ror32(y, 1) & 0xffffffff; \ + t = (y >> 8 ^ x) & 0x00ff00ff; x ^= t; y ^= t << 8; \ + t = (y >> 2 ^ x) & 0x33333333; x ^= t; y ^= t << 2; \ + t = (x >> 16 ^ y) & 0x0000ffff; y ^= t; x ^= t << 16; \ + t = (x >> 4 ^ y) & 0x0f0f0f0f; y ^= t; x ^= t << 4; \ + } while (0) + +/* + * DES round macro + */ +#define DES_ROUND(x,y) \ + do { \ + t = *sk++ ^ x; \ + y ^= \ + sb8[t & 0x3f] ^ \ + sb6[t >> 8 & 0x3f] ^ \ + sb4[t >> 16 & 0x3f] ^ \ + sb2[t >> 24 & 0x3f]; \ + t = *sk++ ^ ror32(x, 4); \ + y ^= \ + sb7[t & 0x3f] ^ \ + sb5[t >> 8 & 0x3f] ^ \ + sb3[t >> 16 & 0x3f] ^ \ + sb1[t >> 24 & 0x3f]; \ + } while (0) + +#define SWAP(a, b) \ + do { \ + (a) ^= (b); (b) ^= (a); (a) ^= (b); \ + } while (0) + +static void +des_setkey(uint32_t sk[32], const uint8_t key[8]) +{ + uint32_t x, y, t; + unsigned int i; + + x = be32dec(key + 0); + y = be32dec(key + 4); + + /* permuted choice 1 */ + t = (y >> 4 ^ x) & 0x0f0f0f0f; x ^= t; y ^= t << 4; + t = (y ^ x) & 0x10101010; x ^= t; y ^= t ; + x = lhs[x & 0xf] << 3 | lhs[x >> 8 & 0xf] << 2 | + lhs[x >> 16 & 0xf] << 1 | lhs[x >> 24 & 0xf] | + lhs[x >> 5 & 0xf] << 7 | lhs[x >> 13 & 0xf] << 6 | + lhs[x >> 21 & 0xf] << 5 | lhs[x >> 29 & 0xf] << 4; + y = rhs[y >> 1 & 0xf] << 3 | rhs[y >> 9 & 0xf] << 2 | + rhs[y >> 17 & 0xf] << 1 | rhs[y >> 25 & 0xf] | + rhs[y >> 4 & 0xf] << 7 | rhs[y >> 12 & 0xf] << 6 | + rhs[y >> 20 & 0xf] << 5 | rhs[y >> 28 & 0xf] << 4; + x &= 0x0FFFFFFF; + y &= 0x0FFFFFFF; + + /* calculate subkeys */ + for (i = 0; i < 16; i++) { + if (i < 2 || i == 8 || i == 15) { + x = (x << 1 | x >> 27) & 0x0FFFFFFF; + y = (y << 1 | y >> 27) & 0x0FFFFFFF; + } else { + x = (x << 2 | x >> 26) & 0x0FFFFFFF; + y = (y << 2 | y >> 26) & 0x0FFFFFFF; + } + *sk++ = + (x << 4 & 0x24000000) | (x << 28 & 0x10000000) | + (x << 14 & 0x08000000) | (x << 18 & 0x02080000) | + (x << 6 & 0x01000000) | (x << 9 & 0x00200000) | + (x >> 1 & 0x00100000) | (x << 10 & 0x00040000) | + (x << 2 & 0x00020000) | (x >> 10 & 0x00010000) | + (y >> 13 & 0x00002000) | (y >> 4 & 0x00001000) | + (y << 6 & 0x00000800) | (y >> 1 & 0x00000400) | + (y >> 14 & 0x00000200) | (y & 0x00000100) | + (y >> 5 & 0x00000020) | (y >> 10 & 0x00000010) | + (y >> 3 & 0x00000008) | (y >> 18 & 0x00000004) | + (y >> 26 & 0x00000002) | (y >> 24 & 0x00000001); + *sk++ = + (x << 15 & 0x20000000) | (x << 17 & 0x10000000) | + (x << 10 & 0x08000000) | (x << 22 & 0x04000000) | + (x >> 2 & 0x02000000) | (x << 1 & 0x01000000) | + (x << 16 & 0x00200000) | (x << 11 & 0x00100000) | + (x << 3 & 0x00080000) | (x >> 6 & 0x00040000) | + (x << 15 & 0x00020000) | (x >> 4 & 0x00010000) | + (y >> 2 & 0x00002000) | (y << 8 & 0x00001000) | + (y >> 14 & 0x00000808) | (y >> 9 & 0x00000400) | + (y & 0x00000200) | (y << 7 & 0x00000100) | + (y >> 7 & 0x00000020) | (y >> 3 & 0x00000011) | + (y << 2 & 0x00000004) | (y >> 21 & 0x00000002); + } +} + +/* + * DES-ECB block encryption / decryption + */ +static void +des_crypt_ecb(des_ctx *ctx, const uint8_t input[8], uint8_t output[8]) +{ + uint32_t x, y, t, *sk; + unsigned int i; + + sk = ctx->sk; + + x = be32dec(input + 0); + y = be32dec(input + 4); + DES_IP(x, y); + for (i = 0; i < 8; ++i) { + DES_ROUND(y, x); + DES_ROUND(x, y); + } + DES_FP(y, x); + be32enc(output + 0, y); + be32enc(output + 4, x); +} + +void +des_init(des_ctx *ctx, cipher_mode mode, const uint8_t *key, size_t keylen) +{ + unsigned int i; + + (void)keylen; + des_setkey(ctx->sk, key); + if (mode == CIPHER_MODE_DECRYPT) { + for (i = 0; i < 16; i += 2) { + SWAP(ctx->sk[i ], ctx->sk[30 - i]); + SWAP(ctx->sk[i + 1], ctx->sk[31 - i]); + } + } +} + +size_t +des_encrypt(des_ctx *ctx, const void *vpt, uint8_t *ct, size_t len) +{ + const uint8_t *pt = vpt; + unsigned int i; + + len -= len % DES_BLOCK_LEN; + for (i = 0; i < len; i += DES_BLOCK_LEN) { + des_crypt_ecb(ctx, pt, ct); + pt += DES_BLOCK_LEN; + ct += DES_BLOCK_LEN; + } + return (len); +} + +size_t +des_decrypt(des_ctx *ctx, const uint8_t *ct, void *vpt, size_t len) +{ + uint8_t *pt = vpt; + unsigned int i; + + len -= len % DES_BLOCK_LEN; + for (i = 0; i < len; i += DES_BLOCK_LEN) { + des_crypt_ecb(ctx, ct, pt); + ct += DES_BLOCK_LEN; + pt += DES_BLOCK_LEN; + } + return (len); +} + +void +des_finish(des_ctx *ctx) +{ + + memset_s(ctx, 0, sizeof *ctx, sizeof *ctx); +} + +cipher_algorithm des_cipher = { + .name = "des", + .contextlen = sizeof(des_ctx), + .blocklen = DES_BLOCK_LEN, + .keylen = DES_BLOCK_LEN, + .init = (cipher_init_func)des_init, + .encrypt = (cipher_encrypt_func)des_encrypt, + .decrypt = (cipher_decrypt_func)des_decrypt, + .finish = (cipher_finish_func)des_finish, +}; diff --git a/t/.gitignore b/t/.gitignore index cca1d6c..0ff0cc4 100644 --- a/t/.gitignore +++ b/t/.gitignore @@ -6,6 +6,7 @@ /t_core /t_ctype /t_cxx +/t_des /t_digest /t_enc /t_endian diff --git a/t/Makefile.am b/t/Makefile.am index c800ca5..aa17a21 100644 --- a/t/Makefile.am +++ b/t/Makefile.am @@ -79,9 +79,10 @@ endif CRYB_RAND if CRYB_CIPHER TESTS += t_cipher t_cipher_LDADD = $(libt) $(libcipher) -TESTS += t_aes t_chacha t_rc4 t_salsa +TESTS += t_aes t_chacha t_des t_rc4 t_salsa t_aes_LDADD = $(libt) $(libcipher) t_chacha_LDADD = $(libt) $(libcipher) +t_des_LDADD = $(libt) $(libcipher) t_rc4_LDADD = $(libt) $(libcipher) t_salsa_LDADD = $(libt) $(libcipher) endif CRYB_CIPHER diff --git a/t/t_des.c b/t/t_des.c new file mode 100644 index 0000000..9007bb5 --- /dev/null +++ b/t/t_des.c @@ -0,0 +1,2172 @@ +/*- + * Copyright (c) 2017 Dag-Erling Smørgrav + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "cryb/impl.h" + +#include + +#include +#include + +#include + +#include + +struct t_case { + const char *desc; + const uint8_t key[8]; + const uint8_t ptext[DES_BLOCK_LEN]; + const uint8_t ctext[DES_BLOCK_LEN]; +}; + +/*************************************************************************** + * Test cases + */ + +static struct t_case t_cases[] = { + { + .desc = "NIST SP 800-20 A.1 0", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x95, 0xf8, 0xa5, 0xe5, 0xdd, 0x31, 0xd9, 0x00, + }, + }, + { + .desc = "NIST SP 800-20 A.1 1", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xdd, 0x7f, 0x12, 0x1c, 0xa5, 0x01, 0x56, 0x19, + }, + }, + { + .desc = "NIST SP 800-20 A.1 2", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x2e, 0x86, 0x53, 0x10, 0x4f, 0x38, 0x34, 0xea, + }, + }, + { + .desc = "NIST SP 800-20 A.1 3", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x4b, 0xd3, 0x88, 0xff, 0x6c, 0xd8, 0x1d, 0x4f, + }, + }, + { + .desc = "NIST SP 800-20 A.1 4", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x20, 0xb9, 0xe7, 0x67, 0xb2, 0xfb, 0x14, 0x56, + }, + }, + { + .desc = "NIST SP 800-20 A.1 5", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x55, 0x57, 0x93, 0x80, 0xd7, 0x71, 0x38, 0xef, + }, + }, + { + .desc = "NIST SP 800-20 A.1 6", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x6c, 0xc5, 0xde, 0xfa, 0xaf, 0x04, 0x51, 0x2f, + }, + }, + { + .desc = "NIST SP 800-20 A.1 7", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x0d, 0x9f, 0x27, 0x9b, 0xa5, 0xd8, 0x72, 0x60, + }, + }, + { + .desc = "NIST SP 800-20 A.1 8", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xd9, 0x03, 0x1b, 0x02, 0x71, 0xbd, 0x5a, 0x0a, + }, + }, + { + .desc = "NIST SP 800-20 A.1 9", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x42, 0x42, 0x50, 0xb3, 0x7c, 0x3d, 0xd9, 0x51, + }, + }, + { + .desc = "NIST SP 800-20 A.1 10", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xb8, 0x06, 0x1b, 0x7e, 0xcd, 0x9a, 0x21, 0xe5, + }, + }, + { + .desc = "NIST SP 800-20 A.1 11", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xf1, 0x5d, 0x0f, 0x28, 0x6b, 0x65, 0xbd, 0x28, + }, + }, + { + .desc = "NIST SP 800-20 A.1 12", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xad, 0xd0, 0xcc, 0x8d, 0x6e, 0x5d, 0xeb, 0xa1, + }, + }, + { + .desc = "NIST SP 800-20 A.1 13", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xe6, 0xd5, 0xf8, 0x27, 0x52, 0xad, 0x63, 0xd1, + }, + }, + { + .desc = "NIST SP 800-20 A.1 14", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xec, 0xbf, 0xe3, 0xbd, 0x3f, 0x59, 0x1a, 0x5e, + }, + }, + { + .desc = "NIST SP 800-20 A.1 15", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xf3, 0x56, 0x83, 0x43, 0x79, 0xd1, 0x65, 0xcd, + }, + }, + { + .desc = "NIST SP 800-20 A.1 16", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x2b, 0x9f, 0x98, 0x2f, 0x20, 0x03, 0x7f, 0xa9, + }, + }, + { + .desc = "NIST SP 800-20 A.1 17", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x88, 0x9d, 0xe0, 0x68, 0xa1, 0x6f, 0x0b, 0xe6, + }, + }, + { + .desc = "NIST SP 800-20 A.1 18", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xe1, 0x9e, 0x27, 0x5d, 0x84, 0x6a, 0x12, 0x98, + }, + }, + { + .desc = "NIST SP 800-20 A.1 19", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x32, 0x9a, 0x8e, 0xd5, 0x23, 0xd7, 0x1a, 0xec, + }, + }, + { + .desc = "NIST SP 800-20 A.1 20", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xe7, 0xfc, 0xe2, 0x25, 0x57, 0xd2, 0x3c, 0x97, + }, + }, + { + .desc = "NIST SP 800-20 A.1 21", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x12, 0xa9, 0xf5, 0x81, 0x7f, 0xf2, 0xd6, 0x5d, + }, + }, + { + .desc = "NIST SP 800-20 A.1 22", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xa4, 0x84, 0xc3, 0xad, 0x38, 0xdc, 0x9c, 0x19, + }, + }, + { + .desc = "NIST SP 800-20 A.1 23", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xfb, 0xe0, 0x0a, 0x8a, 0x1e, 0xf8, 0xad, 0x72, + }, + }, + { + .desc = "NIST SP 800-20 A.1 24", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x75, 0x0d, 0x07, 0x94, 0x07, 0x52, 0x13, 0x63, + }, + }, + { + .desc = "NIST SP 800-20 A.1 25", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x64, 0xfe, 0xed, 0x9c, 0x72, 0x4c, 0x2f, 0xaf, + }, + }, + { + .desc = "NIST SP 800-20 A.1 26", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xf0, 0x2b, 0x26, 0x3b, 0x32, 0x8e, 0x2b, 0x60, + }, + }, + { + .desc = "NIST SP 800-20 A.1 27", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x9d, 0x64, 0x55, 0x5a, 0x9a, 0x10, 0xb8, 0x52, + }, + }, + { + .desc = "NIST SP 800-20 A.1 28", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xd1, 0x06, 0xff, 0x0b, 0xed, 0x52, 0x55, 0xd7, + }, + }, + { + .desc = "NIST SP 800-20 A.1 29", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xe1, 0x65, 0x2c, 0x6b, 0x13, 0x8c, 0x64, 0xa5, + }, + }, + { + .desc = "NIST SP 800-20 A.1 30", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xe4, 0x28, 0x58, 0x11, 0x86, 0xec, 0x8f, 0x46, + }, + }, + { + .desc = "NIST SP 800-20 A.1 31", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xae, 0xb5, 0xf5, 0xed, 0xe2, 0x2d, 0x1a, 0x36, + }, + }, + { + .desc = "NIST SP 800-20 A.1 32", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xe9, 0x43, 0xd7, 0x56, 0x8a, 0xec, 0x0c, 0x5c, + }, + }, + { + .desc = "NIST SP 800-20 A.1 33", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xdf, 0x98, 0xc8, 0x27, 0x6f, 0x54, 0xb0, 0x4b, + }, + }, + { + .desc = "NIST SP 800-20 A.1 34", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xb1, 0x60, 0xe4, 0x68, 0x0f, 0x6c, 0x69, 0x6f, + }, + }, + { + .desc = "NIST SP 800-20 A.1 35", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xfa, 0x07, 0x52, 0xb0, 0x7d, 0x9c, 0x4a, 0xb8, + }, + }, + { + .desc = "NIST SP 800-20 A.1 36", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xca, 0x3a, 0x2b, 0x03, 0x6d, 0xbc, 0x85, 0x02, + }, + }, + { + .desc = "NIST SP 800-20 A.1 37", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x5e, 0x09, 0x05, 0x51, 0x7b, 0xb5, 0x9b, 0xcf, + }, + }, + { + .desc = "NIST SP 800-20 A.1 38", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x81, 0x4e, 0xeb, 0x3b, 0x91, 0xd9, 0x07, 0x26, + }, + }, + { + .desc = "NIST SP 800-20 A.1 39", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x4d, 0x49, 0xdb, 0x15, 0x32, 0x91, 0x9c, 0x9f, + }, + }, + { + .desc = "NIST SP 800-20 A.1 40", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + }, + .ctext = { + 0x25, 0xeb, 0x5f, 0xc3, 0xf8, 0xcf, 0x06, 0x21, + }, + }, + { + .desc = "NIST SP 800-20 A.1 41", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, + }, + .ctext = { + 0xab, 0x6a, 0x20, 0xc0, 0x62, 0x0d, 0x1c, 0x6f, + }, + }, + { + .desc = "NIST SP 800-20 A.1 42", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, + }, + .ctext = { + 0x79, 0xe9, 0x0d, 0xbc, 0x98, 0xf9, 0x2c, 0xca, + }, + }, + { + .desc = "NIST SP 800-20 A.1 43", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, + }, + .ctext = { + 0x86, 0x6e, 0xce, 0xdd, 0x80, 0x72, 0xbb, 0x0e, + }, + }, + { + .desc = "NIST SP 800-20 A.1 44", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, + }, + .ctext = { + 0x8b, 0x54, 0x53, 0x6f, 0x2f, 0x3e, 0x64, 0xa8, + }, + }, + { + .desc = "NIST SP 800-20 A.1 45", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, + }, + .ctext = { + 0xea, 0x51, 0xd3, 0x97, 0x55, 0x95, 0xb8, 0x6b, + }, + }, + { + .desc = "NIST SP 800-20 A.1 46", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, + }, + .ctext = { + 0xca, 0xff, 0xc6, 0xac, 0x45, 0x42, 0xde, 0x31, + }, + }, + { + .desc = "NIST SP 800-20 A.1 47", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + }, + .ctext = { + 0x8d, 0xd4, 0x5a, 0x2d, 0xdf, 0x90, 0x79, 0x6c, + }, + }, + { + .desc = "NIST SP 800-20 A.1 48", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, + }, + .ctext = { + 0x10, 0x29, 0xd5, 0x5e, 0x88, 0x0e, 0xc2, 0xd0, + }, + }, + { + .desc = "NIST SP 800-20 A.1 49", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, + }, + .ctext = { + 0x5d, 0x86, 0xcb, 0x23, 0x63, 0x9d, 0xbe, 0xa9, + }, + }, + { + .desc = "NIST SP 800-20 A.1 50", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, + }, + .ctext = { + 0x1d, 0x1c, 0xa8, 0x53, 0xae, 0x7c, 0x0c, 0x5f, + }, + }, + { + .desc = "NIST SP 800-20 A.1 51", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, + }, + .ctext = { + 0xce, 0x33, 0x23, 0x29, 0x24, 0x8f, 0x32, 0x28, + }, + }, + { + .desc = "NIST SP 800-20 A.1 52", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, + }, + .ctext = { + 0x84, 0x05, 0xd1, 0xab, 0xe2, 0x4f, 0xb9, 0x42, + }, + }, + { + .desc = "NIST SP 800-20 A.1 53", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, + }, + .ctext = { + 0xe6, 0x43, 0xd7, 0x80, 0x90, 0xca, 0x42, 0x07, + }, + }, + { + .desc = "NIST SP 800-20 A.1 54", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, + }, + .ctext = { + 0x48, 0x22, 0x1b, 0x99, 0x37, 0x74, 0x8a, 0x23, + }, + }, + { + .desc = "NIST SP 800-20 A.1 55", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + }, + .ctext = { + 0xdd, 0x7c, 0x0b, 0xbd, 0x61, 0xfa, 0xfd, 0x54, + }, + }, + { + .desc = "NIST SP 800-20 A.1 56", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, + }, + .ctext = { + 0x2f, 0xbc, 0x29, 0x1a, 0x57, 0x0d, 0xb5, 0xc4, + }, + }, + { + .desc = "NIST SP 800-20 A.1 57", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, + }, + .ctext = { + 0xe0, 0x7c, 0x30, 0xd7, 0xe4, 0xe2, 0x6e, 0x12, + }, + }, + { + .desc = "NIST SP 800-20 A.1 58", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, + }, + .ctext = { + 0x09, 0x53, 0xe2, 0x25, 0x8e, 0x8e, 0x90, 0xa1, + }, + }, + { + .desc = "NIST SP 800-20 A.1 59", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, + }, + .ctext = { + 0x5b, 0x71, 0x1b, 0xc4, 0xce, 0xeb, 0xf2, 0xee, + }, + }, + { + .desc = "NIST SP 800-20 A.1 60", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, + }, + .ctext = { + 0xcc, 0x08, 0x3f, 0x1e, 0x6d, 0x9e, 0x85, 0xf6, + }, + }, + { + .desc = "NIST SP 800-20 A.1 61", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, + }, + .ctext = { + 0xd2, 0xfd, 0x88, 0x67, 0xd5, 0x0d, 0x2d, 0xfe, + }, + }, + { + .desc = "NIST SP 800-20 A.1 62", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + }, + .ctext = { + 0x06, 0xe7, 0xea, 0x22, 0xce, 0x92, 0x70, 0x8f, + }, + }, + { + .desc = "NIST SP 800-20 A.1 63", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + }, + .ctext = { + 0x16, 0x6b, 0x40, 0xb4, 0x4a, 0xba, 0x4b, 0xd6, + }, + }, + { + .desc = "NIST SP 800-20 A.2 0", + .key = { + 0x80, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x95, 0xa8, 0xd7, 0x28, 0x13, 0xda, 0xa9, 0x4d, + }, + }, + { + .desc = "NIST SP 800-20 A.2 1", + .key = { + 0x40, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x0e, 0xec, 0x14, 0x87, 0xdd, 0x8c, 0x26, 0xd5, + }, + }, + { + .desc = "NIST SP 800-20 A.2 2", + .key = { + 0x20, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x7a, 0xd1, 0x6f, 0xfb, 0x79, 0xc4, 0x59, 0x26, + }, + }, + { + .desc = "NIST SP 800-20 A.2 3", + .key = { + 0x10, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xd3, 0x74, 0x62, 0x94, 0xca, 0x6a, 0x6c, 0xf3, + }, + }, + { + .desc = "NIST SP 800-20 A.2 4", + .key = { + 0x08, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x80, 0x9f, 0x5f, 0x87, 0x3c, 0x1f, 0xd7, 0x61, + }, + }, + { + .desc = "NIST SP 800-20 A.2 5", + .key = { + 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xc0, 0x2f, 0xaf, 0xfe, 0xc9, 0x89, 0xd1, 0xfc, + }, + }, + { + .desc = "NIST SP 800-20 A.2 6", + .key = { + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x46, 0x15, 0xaa, 0x1d, 0x33, 0xe7, 0x2f, 0x10, + }, + }, + { + .desc = "NIST SP 800-20 A.2 7", + .key = { + 0x01, 0x80, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x20, 0x55, 0x12, 0x33, 0x50, 0xc0, 0x08, 0x58, + }, + }, + { + .desc = "NIST SP 800-20 A.2 8", + .key = { + 0x01, 0x40, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xdf, 0x3b, 0x99, 0xd6, 0x57, 0x73, 0x97, 0xc8, + }, + }, + { + .desc = "NIST SP 800-20 A.2 9", + .key = { + 0x01, 0x20, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x31, 0xfe, 0x17, 0x36, 0x9b, 0x52, 0x88, 0xc9, + }, + }, + { + .desc = "NIST SP 800-20 A.2 10", + .key = { + 0x01, 0x10, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xdf, 0xdd, 0x3c, 0xc6, 0x4d, 0xae, 0x16, 0x42, + }, + }, + { + .desc = "NIST SP 800-20 A.2 11", + .key = { + 0x01, 0x08, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x17, 0x8c, 0x83, 0xce, 0x2b, 0x39, 0x9d, 0x94, + }, + }, + { + .desc = "NIST SP 800-20 A.2 12", + .key = { + 0x01, 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x50, 0xf6, 0x36, 0x32, 0x4a, 0x9b, 0x7f, 0x80, + }, + }, + { + .desc = "NIST SP 800-20 A.2 13", + .key = { + 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xa8, 0x46, 0x8e, 0xe3, 0xbc, 0x18, 0xf0, 0x6d, + }, + }, + { + .desc = "NIST SP 800-20 A.2 14", + .key = { + 0x01, 0x01, 0x80, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xa2, 0xdc, 0x9e, 0x92, 0xfd, 0x3c, 0xde, 0x92, + }, + }, + { + .desc = "NIST SP 800-20 A.2 15", + .key = { + 0x01, 0x01, 0x40, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xca, 0xc0, 0x9f, 0x79, 0x7d, 0x03, 0x12, 0x87, + }, + }, + { + .desc = "NIST SP 800-20 A.2 16", + .key = { + 0x01, 0x01, 0x20, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x90, 0xba, 0x68, 0x0b, 0x22, 0xae, 0xb5, 0x25, + }, + }, + { + .desc = "NIST SP 800-20 A.2 17", + .key = { + 0x01, 0x01, 0x10, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xce, 0x7a, 0x24, 0xf3, 0x50, 0xe2, 0x80, 0xb6, + }, + }, + { + .desc = "NIST SP 800-20 A.2 18", + .key = { + 0x01, 0x01, 0x08, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x88, 0x2b, 0xff, 0x0a, 0xa0, 0x1a, 0x0b, 0x87, + }, + }, + { + .desc = "NIST SP 800-20 A.2 19", + .key = { + 0x01, 0x01, 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x25, 0x61, 0x02, 0x88, 0x92, 0x45, 0x11, 0xc2, + }, + }, + { + .desc = "NIST SP 800-20 A.2 20", + .key = { + 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xc7, 0x15, 0x16, 0xc2, 0x9c, 0x75, 0xd1, 0x70, + }, + }, + { + .desc = "NIST SP 800-20 A.2 21", + .key = { + 0x01, 0x01, 0x01, 0x80, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x51, 0x99, 0xc2, 0x9a, 0x52, 0xc9, 0xf0, 0x59, + }, + }, + { + .desc = "NIST SP 800-20 A.2 22", + .key = { + 0x01, 0x01, 0x01, 0x40, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xc2, 0x2f, 0x0a, 0x29, 0x4a, 0x71, 0xf2, 0x9f, + }, + }, + { + .desc = "NIST SP 800-20 A.2 23", + .key = { + 0x01, 0x01, 0x01, 0x20, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xee, 0x37, 0x14, 0x83, 0x71, 0x4c, 0x02, 0xea, + }, + }, + { + .desc = "NIST SP 800-20 A.2 24", + .key = { + 0x01, 0x01, 0x01, 0x10, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xa8, 0x1f, 0xbd, 0x44, 0x8f, 0x9e, 0x52, 0x2f, + }, + }, + { + .desc = "NIST SP 800-20 A.2 25", + .key = { + 0x01, 0x01, 0x01, 0x08, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x4f, 0x64, 0x4c, 0x92, 0xe1, 0x92, 0xdf, 0xed, + }, + }, + { + .desc = "NIST SP 800-20 A.2 26", + .key = { + 0x01, 0x01, 0x01, 0x04, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x1a, 0xfa, 0x9a, 0x66, 0xa6, 0xdf, 0x92, 0xae, + }, + }, + { + .desc = "NIST SP 800-20 A.2 27", + .key = { + 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xb3, 0xc1, 0xcc, 0x71, 0x5c, 0xb8, 0x79, 0xd8, + }, + }, + { + .desc = "NIST SP 800-20 A.2 28", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x80, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x19, 0xd0, 0x32, 0xe6, 0x4a, 0xb0, 0xbd, 0x8b, + }, + }, + { + .desc = "NIST SP 800-20 A.2 29", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x40, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x3c, 0xfa, 0xa7, 0xa7, 0xdc, 0x87, 0x20, 0xdc, + }, + }, + { + .desc = "NIST SP 800-20 A.2 30", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x20, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xb7, 0x26, 0x5f, 0x7f, 0x44, 0x7a, 0xc6, 0xf3, + }, + }, + { + .desc = "NIST SP 800-20 A.2 31", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x10, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x9d, 0xb7, 0x3b, 0x3c, 0x0d, 0x16, 0x3f, 0x54, + }, + }, + { + .desc = "NIST SP 800-20 A.2 32", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x08, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x81, 0x81, 0xb6, 0x5b, 0xab, 0xf4, 0xa9, 0x75, + }, + }, + { + .desc = "NIST SP 800-20 A.2 33", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x04, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x93, 0xc9, 0xb6, 0x40, 0x42, 0xea, 0xa2, 0x40, + }, + }, + { + .desc = "NIST SP 800-20 A.2 34", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x55, 0x70, 0x53, 0x08, 0x29, 0x70, 0x55, 0x92, + }, + }, + { + .desc = "NIST SP 800-20 A.2 35", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x80, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x86, 0x38, 0x80, 0x9e, 0x87, 0x87, 0x87, 0xa0, + }, + }, + { + .desc = "NIST SP 800-20 A.2 36", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x40, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x41, 0xb9, 0xa7, 0x9a, 0xf7, 0x9a, 0xc2, 0x08, + }, + }, + { + .desc = "NIST SP 800-20 A.2 37", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x20, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x7a, 0x9b, 0xe4, 0x2f, 0x20, 0x09, 0xa8, 0x92, + }, + }, + { + .desc = "NIST SP 800-20 A.2 38", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x10, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x29, 0x03, 0x8d, 0x56, 0xba, 0x6d, 0x27, 0x45, + }, + }, + { + .desc = "NIST SP 800-20 A.2 39", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x08, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x54, 0x95, 0xc6, 0xab, 0xf1, 0xe5, 0xdf, 0x51, + }, + }, + { + .desc = "NIST SP 800-20 A.2 40", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x04, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xae, 0x13, 0xdb, 0xd5, 0x61, 0x48, 0x89, 0x33, + }, + }, + { + .desc = "NIST SP 800-20 A.2 41", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x02, 0x4d, 0x1f, 0xfa, 0x89, 0x04, 0xe3, 0x89, + }, + }, + { + .desc = "NIST SP 800-20 A.2 42", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x80, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xd1, 0x39, 0x97, 0x12, 0xf9, 0x9b, 0xf0, 0x2e, + }, + }, + { + .desc = "NIST SP 800-20 A.2 43", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x40, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x14, 0xc1, 0xd7, 0xc1, 0xcf, 0xfe, 0xc7, 0x9e, + }, + }, + { + .desc = "NIST SP 800-20 A.2 44", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x20, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x1d, 0xe5, 0x27, 0x9d, 0xae, 0x3b, 0xed, 0x6f, + }, + }, + { + .desc = "NIST SP 800-20 A.2 45", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x10, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xe9, 0x41, 0xa3, 0x3f, 0x85, 0x50, 0x13, 0x03, + }, + }, + { + .desc = "NIST SP 800-20 A.2 46", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xda, 0x99, 0xdb, 0xbc, 0x9a, 0x03, 0xf3, 0x79, + }, + }, + { + .desc = "NIST SP 800-20 A.2 47", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x04, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xb7, 0xfc, 0x92, 0xf9, 0x1d, 0x8e, 0x92, 0xe9, + }, + }, + { + .desc = "NIST SP 800-20 A.2 48", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xae, 0x8e, 0x5c, 0xaa, 0x3c, 0xa0, 0x4e, 0x85, + }, + }, + { + .desc = "NIST SP 800-20 A.2 49", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x80, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x9c, 0xc6, 0x2d, 0xf4, 0x3b, 0x6e, 0xed, 0x74, + }, + }, + { + .desc = "NIST SP 800-20 A.2 50", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x40, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xd8, 0x63, 0xdb, 0xb5, 0xc5, 0x9a, 0x91, 0xa0, + }, + }, + { + .desc = "NIST SP 800-20 A.2 51", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x20, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xa1, 0xab, 0x21, 0x90, 0x54, 0x5b, 0x91, 0xd7, + }, + }, + { + .desc = "NIST SP 800-20 A.2 52", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x10, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x08, 0x75, 0x04, 0x1e, 0x64, 0xc5, 0x70, 0xf7, + }, + }, + { + .desc = "NIST SP 800-20 A.2 53", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x08, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x5a, 0x59, 0x45, 0x28, 0xbe, 0xbe, 0xf1, 0xcc, + }, + }, + { + .desc = "NIST SP 800-20 A.2 54", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x04, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xfc, 0xdb, 0x32, 0x91, 0xde, 0x21, 0xf0, 0xc0, + }, + }, + { + .desc = "NIST SP 800-20 A.2 55", + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x86, 0x9e, 0xfd, 0x7f, 0x9f, 0x26, 0x5a, 0x09, + }, + }, + { + .desc = "NIST SP 800-20 A.3 0", + .key = { + 0x10, 0x46, 0x91, 0x34, 0x89, 0x98, 0x01, 0x31, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x88, 0xd5, 0x5e, 0x54, 0xf5, 0x4c, 0x97, 0xb4, + }, + }, + { + .desc = "NIST SP 800-20 A.3 1", + .key = { + 0x10, 0x07, 0x10, 0x34, 0x89, 0x98, 0x80, 0x20, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x0c, 0x0c, 0xc0, 0x0c, 0x83, 0xea, 0x48, 0xfd, + }, + }, + { + .desc = "NIST SP 800-20 A.3 2", + .key = { + 0x10, 0x07, 0x10, 0x34, 0xc8, 0x98, 0x01, 0x20, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x83, 0xbc, 0x8e, 0xf3, 0xa6, 0x57, 0x01, 0x83, + }, + }, + { + .desc = "NIST SP 800-20 A.3 3", + .key = { + 0x10, 0x46, 0x10, 0x34, 0x89, 0x98, 0x80, 0x20, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xdf, 0x72, 0x5d, 0xca, 0xd9, 0x4e, 0xa2, 0xe9, + }, + }, + { + .desc = "NIST SP 800-20 A.3 4", + .key = { + 0x10, 0x86, 0x91, 0x15, 0x19, 0x19, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xe6, 0x52, 0xb5, 0x3b, 0x55, 0x0b, 0xe8, 0xb0, + }, + }, + { + .desc = "NIST SP 800-20 A.3 5", + .key = { + 0x10, 0x86, 0x91, 0x15, 0x19, 0x58, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xaf, 0x52, 0x71, 0x20, 0xc4, 0x85, 0xcb, 0xb0, + }, + }, + { + .desc = "NIST SP 800-20 A.3 6", + .key = { + 0x51, 0x07, 0xb0, 0x15, 0x19, 0x58, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x0f, 0x04, 0xce, 0x39, 0x3d, 0xb9, 0x26, 0xd5, + }, + }, + { + .desc = "NIST SP 800-20 A.3 7", + .key = { + 0x10, 0x07, 0xb0, 0x15, 0x19, 0x19, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xc9, 0xf0, 0x0f, 0xfc, 0x74, 0x07, 0x90, 0x67, + }, + }, + { + .desc = "NIST SP 800-20 A.3 8", + .key = { + 0x31, 0x07, 0x91, 0x54, 0x98, 0x08, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x7c, 0xfd, 0x82, 0xa5, 0x93, 0x25, 0x2b, 0x4e, + }, + }, + { + .desc = "NIST SP 800-20 A.3 9", + .key = { + 0x31, 0x07, 0x91, 0x94, 0x98, 0x08, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xcb, 0x49, 0xa2, 0xf9, 0xe9, 0x13, 0x63, 0xe3, + }, + }, + { + .desc = "NIST SP 800-20 A.3 10", + .key = { + 0x10, 0x07, 0x91, 0x15, 0xb9, 0x08, 0x01, 0x40, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x00, 0xb5, 0x88, 0xbe, 0x70, 0xd2, 0x3f, 0x56, + }, + }, + { + .desc = "NIST SP 800-20 A.3 11", + .key = { + 0x31, 0x07, 0x91, 0x15, 0x98, 0x08, 0x01, 0x40, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x40, 0x6a, 0x9a, 0x6a, 0xb4, 0x33, 0x99, 0xae, + }, + }, + { + .desc = "NIST SP 800-20 A.3 12", + .key = { + 0x10, 0x07, 0xd0, 0x15, 0x89, 0x98, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x6c, 0xb7, 0x73, 0x61, 0x1d, 0xca, 0x9a, 0xda, + }, + }, + { + .desc = "NIST SP 800-20 A.3 13", + .key = { + 0x91, 0x07, 0x91, 0x15, 0x89, 0x98, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x67, 0xfd, 0x21, 0xc1, 0x7d, 0xbb, 0x5d, 0x70, + }, + }, + { + .desc = "NIST SP 800-20 A.3 14", + .key = { + 0x91, 0x07, 0xd0, 0x15, 0x89, 0x19, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x95, 0x92, 0xcb, 0x41, 0x10, 0x43, 0x07, 0x87, + }, + }, + { + .desc = "NIST SP 800-20 A.3 15", + .key = { + 0x10, 0x07, 0xd0, 0x15, 0x98, 0x98, 0x01, 0x20, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xa6, 0xb7, 0xff, 0x68, 0xa3, 0x18, 0xdd, 0xd3, + }, + }, + { + .desc = "NIST SP 800-20 A.3 16", + .key = { + 0x10, 0x07, 0x94, 0x04, 0x98, 0x19, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x4d, 0x10, 0x21, 0x96, 0xc9, 0x14, 0xca, 0x16, + }, + }, + { + .desc = "NIST SP 800-20 A.3 17", + .key = { + 0x01, 0x07, 0x91, 0x04, 0x91, 0x19, 0x04, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x2d, 0xfa, 0x9f, 0x45, 0x73, 0x59, 0x49, 0x65, + }, + }, + { + .desc = "NIST SP 800-20 A.3 18", + .key = { + 0x01, 0x07, 0x91, 0x04, 0x91, 0x19, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xb4, 0x66, 0x04, 0x81, 0x6c, 0x0e, 0x07, 0x74, + }, + }, + { + .desc = "NIST SP 800-20 A.3 19", + .key = { + 0x01, 0x07, 0x94, 0x04, 0x91, 0x19, 0x04, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x6e, 0x7e, 0x62, 0x21, 0xa4, 0xf3, 0x4e, 0x87, + }, + }, + { + .desc = "NIST SP 800-20 A.3 20", + .key = { + 0x19, 0x07, 0x92, 0x10, 0x98, 0x1a, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xaa, 0x85, 0xe7, 0x46, 0x43, 0x23, 0x31, 0x99, + }, + }, + { + .desc = "NIST SP 800-20 A.3 21", + .key = { + 0x10, 0x07, 0x91, 0x19, 0x98, 0x19, 0x08, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x2e, 0x5a, 0x19, 0xdb, 0x4d, 0x19, 0x62, 0xd6, + }, + }, + { + .desc = "NIST SP 800-20 A.3 22", + .key = { + 0x10, 0x07, 0x91, 0x19, 0x98, 0x1a, 0x08, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x23, 0xa8, 0x66, 0xa8, 0x09, 0xd3, 0x08, 0x94, + }, + }, + { + .desc = "NIST SP 800-20 A.3 23", + .key = { + 0x10, 0x07, 0x92, 0x10, 0x98, 0x19, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xd8, 0x12, 0xd9, 0x61, 0xf0, 0x17, 0xd3, 0x20, + }, + }, + { + .desc = "NIST SP 800-20 A.3 24", + .key = { + 0x10, 0x07, 0x91, 0x15, 0x98, 0x19, 0x01, 0x0b, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x05, 0x56, 0x05, 0x81, 0x6e, 0x58, 0x60, 0x8f, + }, + }, + { + .desc = "NIST SP 800-20 A.3 25", + .key = { + 0x10, 0x04, 0x80, 0x15, 0x98, 0x19, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xab, 0xd8, 0x8e, 0x8b, 0x1b, 0x77, 0x16, 0xf1, + }, + }, + { + .desc = "NIST SP 800-20 A.3 26", + .key = { + 0x10, 0x04, 0x80, 0x15, 0x98, 0x19, 0x01, 0x02, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x53, 0x7a, 0xc9, 0x5b, 0xe6, 0x9d, 0xa1, 0xe1, + }, + }, + { + .desc = "NIST SP 800-20 A.3 27", + .key = { + 0x10, 0x04, 0x80, 0x15, 0x98, 0x19, 0x01, 0x08, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xae, 0xd0, 0xf6, 0xae, 0x3c, 0x25, 0xcd, 0xd8, + }, + }, + { + .desc = "NIST SP 800-20 A.3 28", + .key = { + 0x10, 0x02, 0x91, 0x15, 0x98, 0x10, 0x01, 0x04, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xb3, 0xe3, 0x5a, 0x5e, 0xe5, 0x3e, 0x7b, 0x8d, + }, + }, + { + .desc = "NIST SP 800-20 A.3 29", + .key = { + 0x10, 0x02, 0x91, 0x15, 0x98, 0x19, 0x01, 0x04, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x61, 0xc7, 0x9c, 0x71, 0x92, 0x1a, 0x2e, 0xf8, + }, + }, + { + .desc = "NIST SP 800-20 A.3 30", + .key = { + 0x10, 0x02, 0x91, 0x15, 0x98, 0x10, 0x02, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0xe2, 0xf5, 0x72, 0x8f, 0x09, 0x95, 0x01, 0x3c, + }, + }, + { + .desc = "NIST SP 800-20 A.3 31", + .key = { + 0x10, 0x02, 0x91, 0x16, 0x98, 0x10, 0x01, 0x01, + }, + .ptext = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .ctext = { + 0x1a, 0xea, 0xc3, 0x9a, 0x61, 0xf0, 0xa4, 0x64, + }, + }, + { + .desc = "NIST SP 800-20 A.4 0", + .key = { + 0x7c, 0xa1, 0x10, 0x45, 0x4a, 0x1a, 0x6e, 0x57, + }, + .ptext = { + 0x01, 0xa1, 0xd6, 0xd0, 0x39, 0x77, 0x67, 0x42, + }, + .ctext = { + 0x69, 0x0f, 0x5b, 0x0d, 0x9a, 0x26, 0x93, 0x9b, + }, + }, + { + .desc = "NIST SP 800-20 A.4 1", + .key = { + 0x01, 0x31, 0xd9, 0x61, 0x9d, 0xc1, 0x37, 0x6e, + }, + .ptext = { + 0x5c, 0xd5, 0x4c, 0xa8, 0x3d, 0xef, 0x57, 0xda, + }, + .ctext = { + 0x7a, 0x38, 0x9d, 0x10, 0x35, 0x4b, 0xd2, 0x71, + }, + }, + { + .desc = "NIST SP 800-20 A.4 2", + .key = { + 0x07, 0xa1, 0x13, 0x3e, 0x4a, 0x0b, 0x26, 0x86, + }, + .ptext = { + 0x02, 0x48, 0xd4, 0x38, 0x06, 0xf6, 0x71, 0x72, + }, + .ctext = { + 0x86, 0x8e, 0xbb, 0x51, 0xca, 0xb4, 0x59, 0x9a, + }, + }, + { + .desc = "NIST SP 800-20 A.4 3", + .key = { + 0x38, 0x49, 0x67, 0x4c, 0x26, 0x02, 0x31, 0x9e, + }, + .ptext = { + 0x51, 0x45, 0x4b, 0x58, 0x2d, 0xdf, 0x44, 0x0a, + }, + .ctext = { + 0x71, 0x78, 0x87, 0x6e, 0x01, 0xf1, 0x9b, 0x2a, + }, + }, + { + .desc = "NIST SP 800-20 A.4 4", + .key = { + 0x04, 0xb9, 0x15, 0xba, 0x43, 0xfe, 0xb5, 0xb6, + }, + .ptext = { + 0x42, 0xfd, 0x44, 0x30, 0x59, 0x57, 0x7f, 0xa2, + }, + .ctext = { + 0xaf, 0x37, 0xfb, 0x42, 0x1f, 0x8c, 0x40, 0x95, + }, + }, + { + .desc = "NIST SP 800-20 A.4 5", + .key = { + 0x01, 0x13, 0xb9, 0x70, 0xfd, 0x34, 0xf2, 0xce, + }, + .ptext = { + 0x05, 0x9b, 0x5e, 0x08, 0x51, 0xcf, 0x14, 0x3a, + }, + .ctext = { + 0x86, 0xa5, 0x60, 0xf1, 0x0e, 0xc6, 0xd8, 0x5b, + }, + }, + { + .desc = "NIST SP 800-20 A.4 6", + .key = { + 0x01, 0x70, 0xf1, 0x75, 0x46, 0x8f, 0xb5, 0xe6, + }, + .ptext = { + 0x07, 0x56, 0xd8, 0xe0, 0x77, 0x47, 0x61, 0xd2, + }, + .ctext = { + 0x0c, 0xd3, 0xda, 0x02, 0x00, 0x21, 0xdc, 0x09, + }, + }, + { + .desc = "NIST SP 800-20 A.4 7", + .key = { + 0x43, 0x29, 0x7f, 0xad, 0x38, 0xe3, 0x73, 0xfe, + }, + .ptext = { + 0x76, 0x25, 0x14, 0xb8, 0x29, 0xbf, 0x48, 0x6a, + }, + .ctext = { + 0xea, 0x67, 0x6b, 0x2c, 0xb7, 0xdb, 0x2b, 0x7a, + }, + }, + { + .desc = "NIST SP 800-20 A.4 8", + .key = { + 0x07, 0xa7, 0x13, 0x70, 0x45, 0xda, 0x2a, 0x16, + }, + .ptext = { + 0x3b, 0xdd, 0x11, 0x90, 0x49, 0x37, 0x28, 0x02, + }, + .ctext = { + 0xdf, 0xd6, 0x4a, 0x81, 0x5c, 0xaf, 0x1a, 0x0f, + }, + }, + { + .desc = "NIST SP 800-20 A.4 9", + .key = { + 0x04, 0x68, 0x91, 0x04, 0xc2, 0xfd, 0x3b, 0x2f, + }, + .ptext = { + 0x26, 0x95, 0x5f, 0x68, 0x35, 0xaf, 0x60, 0x9a, + }, + .ctext = { + 0x5c, 0x51, 0x3c, 0x9c, 0x48, 0x86, 0xc0, 0x88, + }, + }, + { + .desc = "NIST SP 800-20 A.4 10", + .key = { + 0x37, 0xd0, 0x6b, 0xb5, 0x16, 0xcb, 0x75, 0x46, + }, + .ptext = { + 0x16, 0x4d, 0x5e, 0x40, 0x4f, 0x27, 0x52, 0x32, + }, + .ctext = { + 0x0a, 0x2a, 0xee, 0xae, 0x3f, 0xf4, 0xab, 0x77, + }, + }, + { + .desc = "NIST SP 800-20 A.4 11", + .key = { + 0x1f, 0x08, 0x26, 0x0d, 0x1a, 0xc2, 0x46, 0x5e, + }, + .ptext = { + 0x6b, 0x05, 0x6e, 0x18, 0x75, 0x9f, 0x5c, 0xca, + }, + .ctext = { + 0xef, 0x1b, 0xf0, 0x3e, 0x5d, 0xfa, 0x57, 0x5a, + }, + }, + { + .desc = "NIST SP 800-20 A.4 12", + .key = { + 0x58, 0x40, 0x23, 0x64, 0x1a, 0xba, 0x61, 0x76, + }, + .ptext = { + 0x00, 0x4b, 0xd6, 0xef, 0x09, 0x17, 0x60, 0x62, + }, + .ctext = { + 0x88, 0xbf, 0x0d, 0xb6, 0xd7, 0x0d, 0xee, 0x56, + }, + }, + { + .desc = "NIST SP 800-20 A.4 13", + .key = { + 0x02, 0x58, 0x16, 0x16, 0x46, 0x29, 0xb0, 0x07, + }, + .ptext = { + 0x48, 0x0d, 0x39, 0x00, 0x6e, 0xe7, 0x62, 0xf2, + }, + .ctext = { + 0xa1, 0xf9, 0x91, 0x55, 0x41, 0x02, 0x0b, 0x56, + }, + }, + { + .desc = "NIST SP 800-20 A.4 14", + .key = { + 0x49, 0x79, 0x3e, 0xbc, 0x79, 0xb3, 0x25, 0x8f, + }, + .ptext = { + 0x43, 0x75, 0x40, 0xc8, 0x69, 0x8f, 0x3c, 0xfa, + }, + .ctext = { + 0x6f, 0xbf, 0x1c, 0xaf, 0xcf, 0xfd, 0x05, 0x56, + }, + }, + { + .desc = "NIST SP 800-20 A.4 15", + .key = { + 0x4f, 0xb0, 0x5e, 0x15, 0x15, 0xab, 0x73, 0xa7, + }, + .ptext = { + 0x07, 0x2d, 0x43, 0xa0, 0x77, 0x07, 0x52, 0x92, + }, + .ctext = { + 0x2f, 0x22, 0xe4, 0x9b, 0xab, 0x7c, 0xa1, 0xac, + }, + }, + { + .desc = "NIST SP 800-20 A.4 16", + .key = { + 0x49, 0xe9, 0x5d, 0x6d, 0x4c, 0xa2, 0x29, 0xbf, + }, + .ptext = { + 0x02, 0xfe, 0x55, 0x77, 0x81, 0x17, 0xf1, 0x2a, + }, + .ctext = { + 0x5a, 0x6b, 0x61, 0x2c, 0xc2, 0x6c, 0xce, 0x4a, + }, + }, + { + .desc = "NIST SP 800-20 A.4 17", + .key = { + 0x01, 0x83, 0x10, 0xdc, 0x40, 0x9b, 0x26, 0xd6, + }, + .ptext = { + 0x1d, 0x9d, 0x5c, 0x50, 0x18, 0xf7, 0x28, 0xc2, + }, + .ctext = { + 0x5f, 0x4c, 0x03, 0x8e, 0xd1, 0x2b, 0x2e, 0x41, + }, + }, + { + .desc = "NIST SP 800-20 A.4 18", + .key = { + 0x1c, 0x58, 0x7f, 0x1c, 0x13, 0x92, 0x4f, 0xef, + }, + .ptext = { + 0x30, 0x55, 0x32, 0x28, 0x6d, 0x6f, 0x29, 0x5a, + }, + .ctext = { + 0x63, 0xfa, 0xc0, 0xd0, 0x34, 0xd9, 0xf7, 0x93, + }, + }, +}; + +/*************************************************************************** + * Test functions + */ + +static int +t_des_enc(char **desc, void *arg) +{ + struct t_case *t = arg; + uint8_t out[DES_BLOCK_LEN]; + des_ctx ctx; + size_t len; + int ret; + + (void)asprintf(desc, "%s (encrypt)", t->desc); + des_init(&ctx, CIPHER_MODE_ENCRYPT, t->key, sizeof t->key); + len = des_encrypt(&ctx, t->ptext, out, DES_BLOCK_LEN); + des_finish(&ctx); + ret = t_compare_sz(DES_BLOCK_LEN, len) & + t_compare_mem(t->ctext, out, DES_BLOCK_LEN); + return (ret); +} + +static int +t_des_dec(char **desc, void *arg) +{ + struct t_case *t = arg; + uint8_t out[DES_BLOCK_LEN]; + des_ctx ctx; + size_t len; + int ret; + + (void)asprintf(desc, "%s (decrypt)", t->desc); + des_init(&ctx, CIPHER_MODE_DECRYPT, t->key, sizeof t->key); + len = des_decrypt(&ctx, t->ctext, out, DES_BLOCK_LEN); + des_finish(&ctx); + ret = t_compare_sz(DES_BLOCK_LEN, len) & + t_compare_mem(t->ptext, out, DES_BLOCK_LEN); + return (ret); +} + + +/*************************************************************************** + * Boilerplate + */ + +static int +t_prepare(int argc, char *argv[]) +{ + unsigned int i, n; + + (void)argc; + (void)argv; + n = sizeof t_cases / sizeof t_cases[0]; + for (i = 0; i < n; ++i) { + t_add_test(t_des_enc, &t_cases[i], "%s", t_cases[i].desc); + t_add_test(t_des_dec, &t_cases[i], "%s", t_cases[i].desc); + } + return (0); +} + +int +main(int argc, char *argv[]) +{ + + t_main(t_prepare, NULL, argc, argv); +}