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