summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2023-04-25 15:19:28 +0000
committertb <>2023-04-25 15:19:28 +0000
commit90831910ceae91e1ec4fd12de38835f8ec56dc98 (patch)
tree38ec62f32c14e1d3bf22d8711aca50b5e08051c2 /src
parent67b4618ddc6e874f67fbfe29878a62e5935bd317 (diff)
downloadopenbsd-90831910ceae91e1ec4fd12de38835f8ec56dc98.tar.gz
openbsd-90831910ceae91e1ec4fd12de38835f8ec56dc98.tar.bz2
openbsd-90831910ceae91e1ec4fd12de38835f8ec56dc98.zip
Remove CTS test
Diffstat (limited to 'src')
-rw-r--r--src/regress/lib/libcrypto/cts128/Makefile9
-rw-r--r--src/regress/lib/libcrypto/cts128/cts128test.c170
2 files changed, 0 insertions, 179 deletions
diff --git a/src/regress/lib/libcrypto/cts128/Makefile b/src/regress/lib/libcrypto/cts128/Makefile
deleted file mode 100644
index 801d1d7182..0000000000
--- a/src/regress/lib/libcrypto/cts128/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
1# $OpenBSD: Makefile,v 1.3 2014/07/08 15:53:52 jsing Exp $
2
3PROG= cts128test
4LDADD= -lcrypto
5DPADD= ${LIBCRYPTO}
6WARNINGS= Yes
7CFLAGS+= -DLIBRESSL_INTERNAL -Werror
8
9.include <bsd.regress.mk>
diff --git a/src/regress/lib/libcrypto/cts128/cts128test.c b/src/regress/lib/libcrypto/cts128/cts128test.c
deleted file mode 100644
index ca60808718..0000000000
--- a/src/regress/lib/libcrypto/cts128/cts128test.c
+++ /dev/null
@@ -1,170 +0,0 @@
1/* $OpenBSD: cts128test.c,v 1.3 2018/07/17 17:06:49 tb Exp $ */
2/* ====================================================================
3 * Copyright (c) 2008 The OpenSSL Project. All rights reserved.
4 *
5 * Rights for redistribution and usage in source and binary
6 * forms are granted according to the OpenSSL license.
7 */
8
9#include <stdio.h>
10#include <stdlib.h>
11#include <string.h>
12
13#include <openssl/aes.h>
14#include <openssl/modes.h>
15
16void test_vector(const unsigned char *vector,size_t len);
17void test_nistvector(const unsigned char *vector,size_t len);
18
19/* test vectors from RFC 3962 */
20static const unsigned char test_key[16] = "chicken teriyaki";
21static const unsigned char test_input[64] =
22 "I would like the" " General Gau's C"
23 "hicken, please, " "and wonton soup.";
24static const unsigned char test_iv[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
25
26static const unsigned char vector_17[17] =
27{0xc6,0x35,0x35,0x68,0xf2,0xbf,0x8c,0xb4, 0xd8,0xa5,0x80,0x36,0x2d,0xa7,0xff,0x7f,
28 0x97};
29static const unsigned char vector_31[31] =
30{0xfc,0x00,0x78,0x3e,0x0e,0xfd,0xb2,0xc1, 0xd4,0x45,0xd4,0xc8,0xef,0xf7,0xed,0x22,
31 0x97,0x68,0x72,0x68,0xd6,0xec,0xcc,0xc0, 0xc0,0x7b,0x25,0xe2,0x5e,0xcf,0xe5};
32static const unsigned char vector_32[32] =
33{0x39,0x31,0x25,0x23,0xa7,0x86,0x62,0xd5, 0xbe,0x7f,0xcb,0xcc,0x98,0xeb,0xf5,0xa8,
34 0x97,0x68,0x72,0x68,0xd6,0xec,0xcc,0xc0, 0xc0,0x7b,0x25,0xe2,0x5e,0xcf,0xe5,0x84};
35static const unsigned char vector_47[47] =
36{0x97,0x68,0x72,0x68,0xd6,0xec,0xcc,0xc0, 0xc0,0x7b,0x25,0xe2,0x5e,0xcf,0xe5,0x84,
37 0xb3,0xff,0xfd,0x94,0x0c,0x16,0xa1,0x8c, 0x1b,0x55,0x49,0xd2,0xf8,0x38,0x02,0x9e,
38 0x39,0x31,0x25,0x23,0xa7,0x86,0x62,0xd5, 0xbe,0x7f,0xcb,0xcc,0x98,0xeb,0xf5};
39static const unsigned char vector_48[48] =
40{0x97,0x68,0x72,0x68,0xd6,0xec,0xcc,0xc0, 0xc0,0x7b,0x25,0xe2,0x5e,0xcf,0xe5,0x84,
41 0x9d,0xad,0x8b,0xbb,0x96,0xc4,0xcd,0xc0, 0x3b,0xc1,0x03,0xe1,0xa1,0x94,0xbb,0xd8,
42 0x39,0x31,0x25,0x23,0xa7,0x86,0x62,0xd5, 0xbe,0x7f,0xcb,0xcc,0x98,0xeb,0xf5,0xa8};
43static const unsigned char vector_64[64] =
44{0x97,0x68,0x72,0x68,0xd6,0xec,0xcc,0xc0, 0xc0,0x7b,0x25,0xe2,0x5e,0xcf,0xe5,0x84,
45 0x39,0x31,0x25,0x23,0xa7,0x86,0x62,0xd5, 0xbe,0x7f,0xcb,0xcc,0x98,0xeb,0xf5,0xa8,
46 0x48,0x07,0xef,0xe8,0x36,0xee,0x89,0xa5, 0x26,0x73,0x0d,0xbc,0x2f,0x7b,0xc8,0x40,
47 0x9d,0xad,0x8b,0xbb,0x96,0xc4,0xcd,0xc0, 0x3b,0xc1,0x03,0xe1,0xa1,0x94,0xbb,0xd8};
48
49static AES_KEY encks, decks;
50
51void
52test_vector(const unsigned char *vector,size_t len)
53{
54 unsigned char iv[sizeof(test_iv)];
55 unsigned char cleartext[64],ciphertext[64];
56 size_t tail;
57
58 printf("vector_%zu\n",len);
59 fflush(stdout);
60
61 if ((tail=len%16) == 0) tail = 16;
62 tail += 16;
63
64 /* test block-based encryption */
65 memcpy(iv,test_iv,sizeof(test_iv));
66 CRYPTO_cts128_encrypt_block(test_input,ciphertext,len,&encks,iv,(block128_f)AES_encrypt);
67 if (memcmp(ciphertext,vector,len))
68 fprintf(stderr,"output_%zu mismatch\n",len), exit(1);
69 if (memcmp(iv,vector+len-tail,sizeof(iv)))
70 fprintf(stderr,"iv_%zu mismatch\n",len), exit(1);
71
72 /* test block-based decryption */
73 memcpy(iv,test_iv,sizeof(test_iv));
74 CRYPTO_cts128_decrypt_block(ciphertext,cleartext,len,&decks,iv,(block128_f)AES_decrypt);
75 if (memcmp(cleartext,test_input,len))
76 fprintf(stderr,"input_%zu mismatch\n",len), exit(2);
77 if (memcmp(iv,vector+len-tail,sizeof(iv)))
78 fprintf(stderr,"iv_%zu mismatch\n",len), exit(2);
79
80 /* test streamed encryption */
81 memcpy(iv,test_iv,sizeof(test_iv));
82 CRYPTO_cts128_encrypt(test_input,ciphertext,len,&encks,iv,(cbc128_f)AES_cbc_encrypt);
83 if (memcmp(ciphertext,vector,len))
84 fprintf(stderr,"output_%zu mismatch\n",len), exit(3);
85 if (memcmp(iv,vector+len-tail,sizeof(iv)))
86 fprintf(stderr,"iv_%zu mismatch\n",len), exit(3);
87
88 /* test streamed decryption */
89 memcpy(iv,test_iv,sizeof(test_iv));
90 CRYPTO_cts128_decrypt(ciphertext,cleartext,len,&decks,iv,(cbc128_f)AES_cbc_encrypt);
91 if (memcmp(cleartext,test_input,len))
92 fprintf(stderr,"input_%zu mismatch\n",len), exit(4);
93 if (memcmp(iv,vector+len-tail,sizeof(iv)))
94 fprintf(stderr,"iv_%zu mismatch\n",len), exit(4);
95}
96
97void
98test_nistvector(const unsigned char *vector,size_t len)
99{
100 unsigned char iv[sizeof(test_iv)];
101 unsigned char cleartext[64],ciphertext[64],nistvector[64];
102 size_t tail;
103
104 printf("nistvector_%zu\n",len); fflush(stdout);
105
106 if ((tail=len%16) == 0) tail = 16;
107
108 len -= 16 + tail;
109 memcpy(nistvector,vector,len);
110 /* flip two last blocks */
111 memcpy(nistvector+len,vector+len+16,tail);
112 memcpy(nistvector+len+tail,vector+len,16);
113 len += 16 + tail;
114 tail = 16;
115
116 /* test block-based encryption */
117 memcpy(iv,test_iv,sizeof(test_iv));
118 CRYPTO_nistcts128_encrypt_block(test_input,ciphertext,len,&encks,iv,(block128_f)AES_encrypt);
119 if (memcmp(ciphertext,nistvector,len))
120 fprintf(stderr,"output_%zu mismatch\n",len), exit(1);
121 if (memcmp(iv,nistvector+len-tail,sizeof(iv)))
122 fprintf(stderr,"iv_%zu mismatch\n",len), exit(1);
123
124 /* test block-based decryption */
125 memcpy(iv,test_iv,sizeof(test_iv));
126 CRYPTO_nistcts128_decrypt_block(ciphertext,cleartext,len,&decks,iv,(block128_f)AES_decrypt);
127 if (memcmp(cleartext,test_input,len))
128 fprintf(stderr,"input_%zu mismatch\n",len), exit(2);
129 if (memcmp(iv,nistvector+len-tail,sizeof(iv)))
130 fprintf(stderr,"iv_%zu mismatch\n",len), exit(2);
131
132 /* test streamed encryption */
133 memcpy(iv,test_iv,sizeof(test_iv));
134 CRYPTO_nistcts128_encrypt(test_input,ciphertext,len,&encks,iv,(cbc128_f)AES_cbc_encrypt);
135 if (memcmp(ciphertext,nistvector,len))
136 fprintf(stderr,"output_%zu mismatch\n",len), exit(3);
137 if (memcmp(iv,nistvector+len-tail,sizeof(iv)))
138 fprintf(stderr,"iv_%zu mismatch\n",len), exit(3);
139
140 /* test streamed decryption */
141 memcpy(iv,test_iv,sizeof(test_iv));
142 CRYPTO_nistcts128_decrypt(ciphertext,cleartext,len,&decks,iv,(cbc128_f)AES_cbc_encrypt);
143 if (memcmp(cleartext,test_input,len))
144 fprintf(stderr,"input_%zu mismatch\n",len), exit(4);
145 if (memcmp(iv,nistvector+len-tail,sizeof(iv)))
146 fprintf(stderr,"iv_%zu mismatch\n",len), exit(4);
147}
148
149int
150main(int argc, char *argv[])
151{
152 AES_set_encrypt_key(test_key,128,&encks);
153 AES_set_decrypt_key(test_key,128,&decks);
154
155 test_vector(vector_17,sizeof(vector_17));
156 test_vector(vector_31,sizeof(vector_31));
157 test_vector(vector_32,sizeof(vector_32));
158 test_vector(vector_47,sizeof(vector_47));
159 test_vector(vector_48,sizeof(vector_48));
160 test_vector(vector_64,sizeof(vector_64));
161
162 test_nistvector(vector_17,sizeof(vector_17));
163 test_nistvector(vector_31,sizeof(vector_31));
164 test_nistvector(vector_32,sizeof(vector_32));
165 test_nistvector(vector_47,sizeof(vector_47));
166 test_nistvector(vector_48,sizeof(vector_48));
167 test_nistvector(vector_64,sizeof(vector_64));
168
169 return 0;
170}