• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
15Title = Base64 tests
16
17Encoding = canonical
18Input = ""
19Output = ""
20
21Encoding = canonical
22Input = "h"
23Output = "aA==\n"
24
25Encoding = canonical
26Input = "hello"
27Output = "aGVsbG8=\n"
28
29Encoding = canonical
30Input = "hello world!"
31Output = "aGVsbG8gd29ybGQh\n"
32
33Encoding = canonical
34Input = 00010203040506070809a0b0c0d0e0f000
35Output = "AAECAwQFBgcICaCwwNDg8AA=\n"
36
37# Missing padding
38Encoding = invalid
39Output = "aGVsbG8"
40
41Encoding = invalid
42Output = "aGVsbG8\n"
43
44# Tolerate missing newline
45Encoding = valid
46Input = "hello"
47Output = "aGVsbG8="
48
49# Don't tolerate extra trailing '='
50Encoding = invalid
51Input = "hello"
52Output = "aGVsbG8==\n"
53
54Encoding = invalid
55Output = "aGVsbG8===\n"
56
57# Don't tolerate data after '='
58Encoding = invalid
59Output = "aGV=sbG8=\n"
60
61# Newlines are ignored
62Encoding = valid
63Input = "hello"
64Output = "aGV\nsbG8=\n"
65
66Encoding = canonical
67Input = "hello"
68Output = 614756736247383d0a
69
70# Invalid characters
71Encoding = invalid
72Output = 614756736247383d0a00
73
74Encoding = invalid
75Output = 61475600736247383d0a
76
77Encoding = invalid
78Output = 61475601736247383d0a
79
80Encoding = invalid
81Output = 61475680736247383d0a
82
83Encoding = invalid
84Output = e14756736247383d0a
85
86Encoding = canonical
87Input = "OpenSSLOpenSSL\n"
88Output = "T3BlblNTTE9wZW5TU0wK\n"
89
90Encoding = valid
91Input = "OpenSSLOpenSSL\n"
92Output = "T3BlblNTTE9wZW5TU0wK"
93
94# Truncate 1-3 chars
95Encoding = invalid
96Output = "T3BlblNTTE9wZW5TU0w"
97
98Encoding = invalid
99Output = "T3BlblNTTE9wZW5TU0"
100
101Encoding = invalid
102Output = "T3BlblNTTE9wZW5TU"
103
104Encoding = invalid
105Output = "T3BlblNTTE9wZW5TU0wK===="
106
107Encoding = invalid
108Output = "T3BlblNTTE9wZW5TU0wK============================================\n"
109
110Encoding = invalid
111Output = "YQ==YQ==YQ==\n"
112
113Encoding = invalid
114Output = "A"
115
116Encoding = invalid
117Output = "A\n"
118
119Encoding = invalid
120Output = "A="
121
122Encoding = invalid
123Output = "A==\n"
124
125Encoding = invalid
126Output = "A===\n"
127
128Encoding = invalid
129Output = "A====\n"
130
131Encoding = valid
132Input = "OpenSSLOpenSSL\n"
133Output = "T3BlblNTTE9wZW5TU0wK\n\n"
134
135Encoding = valid
136Input = "OpenSSLOpenSSL\n"
137Output = "T3BlblNTTE\n9wZW5TU0wK"
138
139# CVE 2015-0292
140Encoding = invalid
141Output = "ZW5jb2RlIG1lCg==================================================================\n"
142
143Encoding = canonical
144Input = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
145Output = "eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eA==\n"
146
147Encoding = valid
148Input = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
149Output = "eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eA\n==\n"
150
151Encoding = valid
152Input = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
153Output = "eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eA=\n=\n"
154
155Encoding = invalid
156Output = "eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eA====\n"
157
158# Multiline output without padding
159Encoding = canonical
160Input = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
161Output = "eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4\neHh4eHh4eHh4eHh4\n"
162
163# Multiline output with padding
164Encoding = canonical
165Input = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
166Output = "eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4\neHh4eHh4eHh4eHh4eHh4eA==\n"
167
168# Multiline output with line break in the middle of a b64 block is accepted
169Encoding = valid
170Input = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
171Output = "eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh\n4eHh4eHh4eHh4eHh4eHh4eA==\n"
172
173# Long lines are accepted
174Encoding = valid
175Input = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
176Output = "eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eA==\n"
177
178# Multiline input with data after '='.
179Encoding = invalid
180Output = "eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eA==\neHh4eHh4eHh4eHh4eHh4eHh4\n"
181
182Encoding = invalid
183Output = "eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4\neA==eHh4eHh4eHh4eHh4eHh4\n"
184
185# B64_EOF ('-') terminates input and trailing bytes are ignored
186Encoding = valid
187Input = "OpenSSLOpenSSL\n"
188Output = "T3BlblNTTE9wZW5TU0wK\n-abcd"
189
190Encoding = valid
191Input = "OpenSSLOpenSSL\n"
192Output = "T3BlblNTTE9wZW5TU0wK-abcd"
193
194
195