evpencod.txt 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. #
  2. # Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved.
  3. #
  4. # Licensed under the Apache License 2.0 (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. # Tests start with one of these keywords
  9. # Cipher Decrypt Derive Digest Encoding KDF MAC PBE
  10. # PrivPubKeyPair Sign Verify VerifyRecover
  11. # and continue until a blank line. Lines starting with a pound sign are ignored.
  12. Title = Base64 tests
  13. Encoding = canonical
  14. Input = ""
  15. Output = ""
  16. Encoding = canonical
  17. Input = "h"
  18. Output = "aA==\n"
  19. Encoding = canonical
  20. Input = "hello"
  21. Output = "aGVsbG8=\n"
  22. Encoding = canonical
  23. Input = "hello world!"
  24. Output = "aGVsbG8gd29ybGQh\n"
  25. Encoding = canonical
  26. Input = 00010203040506070809a0b0c0d0e0f000
  27. Output = "AAECAwQFBgcICaCwwNDg8AA=\n"
  28. # Missing padding
  29. Encoding = invalid
  30. Output = "aGVsbG8"
  31. Encoding = invalid
  32. Output = "aGVsbG8\n"
  33. # Tolerate missing newline
  34. Encoding = valid
  35. Input = "hello"
  36. Output = "aGVsbG8="
  37. # Don't tolerate extra trailing '='
  38. Encoding = invalid
  39. Input = "hello"
  40. Output = "aGVsbG8==\n"
  41. Encoding = invalid
  42. Output = "aGVsbG8===\n"
  43. # Don't tolerate data after '='
  44. Encoding = invalid
  45. Output = "aGV=sbG8=\n"
  46. # Newlines are ignored
  47. Encoding = valid
  48. Input = "hello"
  49. Output = "aGV\nsbG8=\n"
  50. Encoding = canonical
  51. Input = "hello"
  52. Output = 614756736247383d0a
  53. # Invalid characters
  54. Encoding = invalid
  55. Output = 614756736247383d0a00
  56. Encoding = invalid
  57. Output = 61475600736247383d0a
  58. Encoding = invalid
  59. Output = 61475601736247383d0a
  60. Encoding = invalid
  61. Output = 61475680736247383d0a
  62. Encoding = invalid
  63. Output = e14756736247383d0a
  64. Encoding = canonical
  65. Input = "OpenSSLOpenSSL\n"
  66. Output = "T3BlblNTTE9wZW5TU0wK\n"
  67. Encoding = valid
  68. Input = "OpenSSLOpenSSL\n"
  69. Output = "T3BlblNTTE9wZW5TU0wK"
  70. # Truncate 1-3 chars
  71. Encoding = invalid
  72. Output = "T3BlblNTTE9wZW5TU0w"
  73. Encoding = invalid
  74. Output = "T3BlblNTTE9wZW5TU0"
  75. Encoding = invalid
  76. Output = "T3BlblNTTE9wZW5TU"
  77. Encoding = invalid
  78. Output = "T3BlblNTTE9wZW5TU0wK===="
  79. Encoding = invalid
  80. Output = "T3BlblNTTE9wZW5TU0wK============================================\n"
  81. Encoding = invalid
  82. Output = "YQ==YQ==YQ==\n"
  83. Encoding = invalid
  84. Output = "A"
  85. Encoding = invalid
  86. Output = "A\n"
  87. Encoding = invalid
  88. Output = "A="
  89. Encoding = invalid
  90. Output = "A==\n"
  91. Encoding = invalid
  92. Output = "A===\n"
  93. Encoding = invalid
  94. Output = "A====\n"
  95. Encoding = valid
  96. Input = "OpenSSLOpenSSL\n"
  97. Output = "T3BlblNTTE9wZW5TU0wK\n\n"
  98. Encoding = valid
  99. Input = "OpenSSLOpenSSL\n"
  100. Output = "T3BlblNTTE\n9wZW5TU0wK"
  101. # CVE 2015-0292
  102. Encoding = invalid
  103. Output = "ZW5jb2RlIG1lCg==================================================================\n"
  104. Encoding = canonical
  105. Input = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  106. Output = "eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eA==\n"
  107. Encoding = valid
  108. Input = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  109. Output = "eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eA\n==\n"
  110. Encoding = valid
  111. Input = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  112. Output = "eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eA=\n=\n"
  113. Encoding = invalid
  114. Output = "eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eA====\n"
  115. # Multiline output without padding
  116. Encoding = canonical
  117. Input = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  118. Output = "eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4\neHh4eHh4eHh4eHh4\n"
  119. # Multiline output with padding
  120. Encoding = canonical
  121. Input = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  122. Output = "eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4\neHh4eHh4eHh4eHh4eHh4eA==\n"
  123. # Multiline output with line break in the middle of a b64 block is accepted
  124. Encoding = valid
  125. Input = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  126. Output = "eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh\n4eHh4eHh4eHh4eHh4eHh4eA==\n"
  127. # Long lines are accepted
  128. Encoding = valid
  129. Input = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  130. Output = "eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eA==\n"
  131. # Multiline input with data after '='.
  132. Encoding = invalid
  133. Output = "eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eA==\neHh4eHh4eHh4eHh4eHh4eHh4\n"
  134. Encoding = invalid
  135. Output = "eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4\neA==eHh4eHh4eHh4eHh4eHh4\n"
  136. # B64_EOF ('-') terminates input and trailing bytes are ignored
  137. Encoding = valid
  138. Input = "OpenSSLOpenSSL\n"
  139. Output = "T3BlblNTTE9wZW5TU0wK\n-abcd"
  140. Encoding = valid
  141. Input = "OpenSSLOpenSSL\n"
  142. Output = "T3BlblNTTE9wZW5TU0wK-abcd"