b75372d390ec1a5c2d9b44470d9bb237dab42a41
[openssl.git] / test / evpencod.txt
1 #
2 # Copyright 2001-2017 The OpenSSL Project Authors. All Rights Reserved.
3 #
4 # Licensed under the OpenSSL license (the "License").  You may not use
5 # this file except in compliance with the License.  You can obtain a copy
6 # in the file LICENSE in the source distribution or at
7 # https://www.openssl.org/source/license.html
8
9 # Tests start with one of these keywords
10 #       Cipher Decrypt Derive Digest Encoding KDF MAC PBE
11 #       PrivPubKeyPair Sign Verify VerifyRecover
12 # and continue until a blank line.  Lines starting with a pound sign,
13 # like this prolog, are ignored.
14
15 Title = Base64 tests
16
17 Encoding = canonical
18 Input = ""
19 Output = ""
20
21 Encoding = canonical
22 Input = "h"
23 Output = "aA==\n"
24
25 Encoding = canonical
26 Input = "hello"
27 Output = "aGVsbG8=\n"
28
29 Encoding = canonical
30 Input = "hello world!"
31 Output = "aGVsbG8gd29ybGQh\n"
32
33 Encoding = canonical
34 Input = 00010203040506070809a0b0c0d0e0f000
35 Output = "AAECAwQFBgcICaCwwNDg8AA=\n"
36
37 # Missing padding
38 Encoding = invalid
39 Output = "aGVsbG8"
40
41 Encoding = invalid
42 Output = "aGVsbG8\n"
43
44 # Tolerate missing newline
45 Encoding = valid
46 Input = "hello"
47 Output = "aGVsbG8="
48
49 # Don't tolerate extra trailing '='
50 Encoding = invalid
51 Input = "hello"
52 Output = "aGVsbG8==\n"
53
54 Encoding = invalid
55 Output = "aGVsbG8===\n"
56
57 # Don't tolerate data after '='
58 Encoding = invalid
59 Output = "aGV=sbG8=\n"
60
61 # Newlines are ignored
62 Encoding = valid
63 Input = "hello"
64 Output = "aGV\nsbG8=\n"
65
66 Encoding = canonical
67 Input = "hello"
68 Output = 614756736247383d0a
69
70 # Invalid characters
71 Encoding = invalid
72 Output = 614756736247383d0a00
73
74 Encoding = invalid
75 Output = 61475600736247383d0a
76
77 Encoding = invalid
78 Output = 61475601736247383d0a
79
80 Encoding = invalid
81 Output = 61475680736247383d0a
82
83 Encoding = invalid
84 Output = e14756736247383d0a
85
86 Encoding = canonical
87 Input = "OpenSSLOpenSSL\n"
88 Output = "T3BlblNTTE9wZW5TU0wK\n"
89
90 Encoding = valid
91 Input = "OpenSSLOpenSSL\n"
92 Output = "T3BlblNTTE9wZW5TU0wK"
93
94 # Truncate 1-3 chars
95 Encoding = invalid
96 Output = "T3BlblNTTE9wZW5TU0w"
97
98 Encoding = invalid
99 Output = "T3BlblNTTE9wZW5TU0"
100
101 Encoding = invalid
102 Output = "T3BlblNTTE9wZW5TU"
103
104 Encoding = invalid
105 Output = "T3BlblNTTE9wZW5TU0wK===="
106
107 Encoding = invalid
108 Output = "T3BlblNTTE9wZW5TU0wK============================================\n"
109
110 Encoding = invalid
111 Output = "YQ==YQ==YQ==\n"
112
113 Encoding = invalid
114 Output = "A"
115
116 Encoding = invalid
117 Output = "A\n"
118
119 Encoding = invalid
120 Output = "A="
121
122 Encoding = invalid
123 Output = "A==\n"
124
125 Encoding = invalid
126 Output = "A===\n"
127
128 Encoding = invalid
129 Output = "A====\n"
130
131 Encoding = valid
132 Input = "OpenSSLOpenSSL\n"
133 Output = "T3BlblNTTE9wZW5TU0wK\n\n"
134
135 Encoding = valid
136 Input = "OpenSSLOpenSSL\n"
137 Output = "T3BlblNTTE\n9wZW5TU0wK"
138
139 # CVE 2015-0292
140 Encoding = invalid
141 Output = "ZW5jb2RlIG1lCg==================================================================\n"
142
143 Encoding = canonical
144 Input = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
145 Output = "eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eA==\n"
146
147 Encoding = valid
148 Input = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
149 Output = "eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eA\n==\n"
150
151 Encoding = valid
152 Input = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
153 Output = "eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eA=\n=\n"
154
155 Encoding = invalid
156 Output = "eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eA====\n"
157
158 # Multiline output without padding
159 Encoding = canonical
160 Input = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
161 Output = "eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4\neHh4eHh4eHh4eHh4\n"
162
163 # Multiline output with padding
164 Encoding = canonical
165 Input = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
166 Output = "eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4\neHh4eHh4eHh4eHh4eHh4eA==\n"
167
168 # Multiline output with line break in the middle of a b64 block is accepted
169 Encoding = valid
170 Input = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
171 Output = "eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh\n4eHh4eHh4eHh4eHh4eHh4eA==\n"
172
173 # Long lines are accepted
174 Encoding = valid
175 Input = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
176 Output = "eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eA==\n"
177
178 # Multiline input with data after '='.
179 Encoding = invalid
180 Output = "eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eA==\neHh4eHh4eHh4eHh4eHh4eHh4\n"
181
182 Encoding = invalid
183 Output = "eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4\neA==eHh4eHh4eHh4eHh4eHh4\n"
184
185 # B64_EOF ('-') terminates input and trailing bytes are ignored
186 Encoding = valid
187 Input = "OpenSSLOpenSSL\n"
188 Output = "T3BlblNTTE9wZW5TU0wK\n-abcd"
189
190 Encoding = valid
191 Input = "OpenSSLOpenSSL\n"
192 Output = "T3BlblNTTE9wZW5TU0wK-abcd"
193
194