Pinned to some recent date

Committer:
Simon Cooksey
Date:
Thu Nov 17 16:43:53 2016 +0000
Revision:
0:fb7af294d5d9
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Simon Cooksey 0:fb7af294d5d9 1 /*
Simon Cooksey 0:fb7af294d5d9 2 * RFC 1521 base64 encoding/decoding
Simon Cooksey 0:fb7af294d5d9 3 *
Simon Cooksey 0:fb7af294d5d9 4 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
Simon Cooksey 0:fb7af294d5d9 5 * SPDX-License-Identifier: Apache-2.0
Simon Cooksey 0:fb7af294d5d9 6 *
Simon Cooksey 0:fb7af294d5d9 7 * Licensed under the Apache License, Version 2.0 (the "License"); you may
Simon Cooksey 0:fb7af294d5d9 8 * not use this file except in compliance with the License.
Simon Cooksey 0:fb7af294d5d9 9 * You may obtain a copy of the License at
Simon Cooksey 0:fb7af294d5d9 10 *
Simon Cooksey 0:fb7af294d5d9 11 * http://www.apache.org/licenses/LICENSE-2.0
Simon Cooksey 0:fb7af294d5d9 12 *
Simon Cooksey 0:fb7af294d5d9 13 * Unless required by applicable law or agreed to in writing, software
Simon Cooksey 0:fb7af294d5d9 14 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
Simon Cooksey 0:fb7af294d5d9 15 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Simon Cooksey 0:fb7af294d5d9 16 * See the License for the specific language governing permissions and
Simon Cooksey 0:fb7af294d5d9 17 * limitations under the License.
Simon Cooksey 0:fb7af294d5d9 18 *
Simon Cooksey 0:fb7af294d5d9 19 * This file is part of mbed TLS (https://tls.mbed.org)
Simon Cooksey 0:fb7af294d5d9 20 */
Simon Cooksey 0:fb7af294d5d9 21
Simon Cooksey 0:fb7af294d5d9 22 #if !defined(MBEDTLS_CONFIG_FILE)
Simon Cooksey 0:fb7af294d5d9 23 #include "mbedtls/config.h"
Simon Cooksey 0:fb7af294d5d9 24 #else
Simon Cooksey 0:fb7af294d5d9 25 #include MBEDTLS_CONFIG_FILE
Simon Cooksey 0:fb7af294d5d9 26 #endif
Simon Cooksey 0:fb7af294d5d9 27
Simon Cooksey 0:fb7af294d5d9 28 #if defined(MBEDTLS_BASE64_C)
Simon Cooksey 0:fb7af294d5d9 29
Simon Cooksey 0:fb7af294d5d9 30 #include "mbedtls/base64.h"
Simon Cooksey 0:fb7af294d5d9 31
Simon Cooksey 0:fb7af294d5d9 32 #include <stdint.h>
Simon Cooksey 0:fb7af294d5d9 33
Simon Cooksey 0:fb7af294d5d9 34 #if defined(MBEDTLS_SELF_TEST)
Simon Cooksey 0:fb7af294d5d9 35 #include <string.h>
Simon Cooksey 0:fb7af294d5d9 36 #if defined(MBEDTLS_PLATFORM_C)
Simon Cooksey 0:fb7af294d5d9 37 #include "mbedtls/platform.h"
Simon Cooksey 0:fb7af294d5d9 38 #else
Simon Cooksey 0:fb7af294d5d9 39 #include <stdio.h>
Simon Cooksey 0:fb7af294d5d9 40 #define mbedtls_printf printf
Simon Cooksey 0:fb7af294d5d9 41 #endif /* MBEDTLS_PLATFORM_C */
Simon Cooksey 0:fb7af294d5d9 42 #endif /* MBEDTLS_SELF_TEST */
Simon Cooksey 0:fb7af294d5d9 43
Simon Cooksey 0:fb7af294d5d9 44 static const unsigned char base64_enc_map[64] =
Simon Cooksey 0:fb7af294d5d9 45 {
Simon Cooksey 0:fb7af294d5d9 46 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
Simon Cooksey 0:fb7af294d5d9 47 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
Simon Cooksey 0:fb7af294d5d9 48 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
Simon Cooksey 0:fb7af294d5d9 49 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
Simon Cooksey 0:fb7af294d5d9 50 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
Simon Cooksey 0:fb7af294d5d9 51 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7',
Simon Cooksey 0:fb7af294d5d9 52 '8', '9', '+', '/'
Simon Cooksey 0:fb7af294d5d9 53 };
Simon Cooksey 0:fb7af294d5d9 54
Simon Cooksey 0:fb7af294d5d9 55 static const unsigned char base64_dec_map[128] =
Simon Cooksey 0:fb7af294d5d9 56 {
Simon Cooksey 0:fb7af294d5d9 57 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
Simon Cooksey 0:fb7af294d5d9 58 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
Simon Cooksey 0:fb7af294d5d9 59 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
Simon Cooksey 0:fb7af294d5d9 60 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
Simon Cooksey 0:fb7af294d5d9 61 127, 127, 127, 62, 127, 127, 127, 63, 52, 53,
Simon Cooksey 0:fb7af294d5d9 62 54, 55, 56, 57, 58, 59, 60, 61, 127, 127,
Simon Cooksey 0:fb7af294d5d9 63 127, 64, 127, 127, 127, 0, 1, 2, 3, 4,
Simon Cooksey 0:fb7af294d5d9 64 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
Simon Cooksey 0:fb7af294d5d9 65 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
Simon Cooksey 0:fb7af294d5d9 66 25, 127, 127, 127, 127, 127, 127, 26, 27, 28,
Simon Cooksey 0:fb7af294d5d9 67 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
Simon Cooksey 0:fb7af294d5d9 68 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
Simon Cooksey 0:fb7af294d5d9 69 49, 50, 51, 127, 127, 127, 127, 127
Simon Cooksey 0:fb7af294d5d9 70 };
Simon Cooksey 0:fb7af294d5d9 71
Simon Cooksey 0:fb7af294d5d9 72 #define BASE64_SIZE_T_MAX ( (size_t) -1 ) /* SIZE_T_MAX is not standard */
Simon Cooksey 0:fb7af294d5d9 73
Simon Cooksey 0:fb7af294d5d9 74 /*
Simon Cooksey 0:fb7af294d5d9 75 * Encode a buffer into base64 format
Simon Cooksey 0:fb7af294d5d9 76 */
Simon Cooksey 0:fb7af294d5d9 77 int mbedtls_base64_encode( unsigned char *dst, size_t dlen, size_t *olen,
Simon Cooksey 0:fb7af294d5d9 78 const unsigned char *src, size_t slen )
Simon Cooksey 0:fb7af294d5d9 79 {
Simon Cooksey 0:fb7af294d5d9 80 size_t i, n;
Simon Cooksey 0:fb7af294d5d9 81 int C1, C2, C3;
Simon Cooksey 0:fb7af294d5d9 82 unsigned char *p;
Simon Cooksey 0:fb7af294d5d9 83
Simon Cooksey 0:fb7af294d5d9 84 if( slen == 0 )
Simon Cooksey 0:fb7af294d5d9 85 {
Simon Cooksey 0:fb7af294d5d9 86 *olen = 0;
Simon Cooksey 0:fb7af294d5d9 87 return( 0 );
Simon Cooksey 0:fb7af294d5d9 88 }
Simon Cooksey 0:fb7af294d5d9 89
Simon Cooksey 0:fb7af294d5d9 90 n = slen / 3 + ( slen % 3 != 0 );
Simon Cooksey 0:fb7af294d5d9 91
Simon Cooksey 0:fb7af294d5d9 92 if( n > ( BASE64_SIZE_T_MAX - 1 ) / 4 )
Simon Cooksey 0:fb7af294d5d9 93 {
Simon Cooksey 0:fb7af294d5d9 94 *olen = BASE64_SIZE_T_MAX;
Simon Cooksey 0:fb7af294d5d9 95 return( MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL );
Simon Cooksey 0:fb7af294d5d9 96 }
Simon Cooksey 0:fb7af294d5d9 97
Simon Cooksey 0:fb7af294d5d9 98 n *= 4;
Simon Cooksey 0:fb7af294d5d9 99
Simon Cooksey 0:fb7af294d5d9 100 if( ( dlen < n + 1 ) || ( NULL == dst ) )
Simon Cooksey 0:fb7af294d5d9 101 {
Simon Cooksey 0:fb7af294d5d9 102 *olen = n + 1;
Simon Cooksey 0:fb7af294d5d9 103 return( MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL );
Simon Cooksey 0:fb7af294d5d9 104 }
Simon Cooksey 0:fb7af294d5d9 105
Simon Cooksey 0:fb7af294d5d9 106 n = ( slen / 3 ) * 3;
Simon Cooksey 0:fb7af294d5d9 107
Simon Cooksey 0:fb7af294d5d9 108 for( i = 0, p = dst; i < n; i += 3 )
Simon Cooksey 0:fb7af294d5d9 109 {
Simon Cooksey 0:fb7af294d5d9 110 C1 = *src++;
Simon Cooksey 0:fb7af294d5d9 111 C2 = *src++;
Simon Cooksey 0:fb7af294d5d9 112 C3 = *src++;
Simon Cooksey 0:fb7af294d5d9 113
Simon Cooksey 0:fb7af294d5d9 114 *p++ = base64_enc_map[(C1 >> 2) & 0x3F];
Simon Cooksey 0:fb7af294d5d9 115 *p++ = base64_enc_map[(((C1 & 3) << 4) + (C2 >> 4)) & 0x3F];
Simon Cooksey 0:fb7af294d5d9 116 *p++ = base64_enc_map[(((C2 & 15) << 2) + (C3 >> 6)) & 0x3F];
Simon Cooksey 0:fb7af294d5d9 117 *p++ = base64_enc_map[C3 & 0x3F];
Simon Cooksey 0:fb7af294d5d9 118 }
Simon Cooksey 0:fb7af294d5d9 119
Simon Cooksey 0:fb7af294d5d9 120 if( i < slen )
Simon Cooksey 0:fb7af294d5d9 121 {
Simon Cooksey 0:fb7af294d5d9 122 C1 = *src++;
Simon Cooksey 0:fb7af294d5d9 123 C2 = ( ( i + 1 ) < slen ) ? *src++ : 0;
Simon Cooksey 0:fb7af294d5d9 124
Simon Cooksey 0:fb7af294d5d9 125 *p++ = base64_enc_map[(C1 >> 2) & 0x3F];
Simon Cooksey 0:fb7af294d5d9 126 *p++ = base64_enc_map[(((C1 & 3) << 4) + (C2 >> 4)) & 0x3F];
Simon Cooksey 0:fb7af294d5d9 127
Simon Cooksey 0:fb7af294d5d9 128 if( ( i + 1 ) < slen )
Simon Cooksey 0:fb7af294d5d9 129 *p++ = base64_enc_map[((C2 & 15) << 2) & 0x3F];
Simon Cooksey 0:fb7af294d5d9 130 else *p++ = '=';
Simon Cooksey 0:fb7af294d5d9 131
Simon Cooksey 0:fb7af294d5d9 132 *p++ = '=';
Simon Cooksey 0:fb7af294d5d9 133 }
Simon Cooksey 0:fb7af294d5d9 134
Simon Cooksey 0:fb7af294d5d9 135 *olen = p - dst;
Simon Cooksey 0:fb7af294d5d9 136 *p = 0;
Simon Cooksey 0:fb7af294d5d9 137
Simon Cooksey 0:fb7af294d5d9 138 return( 0 );
Simon Cooksey 0:fb7af294d5d9 139 }
Simon Cooksey 0:fb7af294d5d9 140
Simon Cooksey 0:fb7af294d5d9 141 /*
Simon Cooksey 0:fb7af294d5d9 142 * Decode a base64-formatted buffer
Simon Cooksey 0:fb7af294d5d9 143 */
Simon Cooksey 0:fb7af294d5d9 144 int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen,
Simon Cooksey 0:fb7af294d5d9 145 const unsigned char *src, size_t slen )
Simon Cooksey 0:fb7af294d5d9 146 {
Simon Cooksey 0:fb7af294d5d9 147 size_t i, n;
Simon Cooksey 0:fb7af294d5d9 148 uint32_t j, x;
Simon Cooksey 0:fb7af294d5d9 149 unsigned char *p;
Simon Cooksey 0:fb7af294d5d9 150
Simon Cooksey 0:fb7af294d5d9 151 /* First pass: check for validity and get output length */
Simon Cooksey 0:fb7af294d5d9 152 for( i = n = j = 0; i < slen; i++ )
Simon Cooksey 0:fb7af294d5d9 153 {
Simon Cooksey 0:fb7af294d5d9 154 /* Skip spaces before checking for EOL */
Simon Cooksey 0:fb7af294d5d9 155 x = 0;
Simon Cooksey 0:fb7af294d5d9 156 while( i < slen && src[i] == ' ' )
Simon Cooksey 0:fb7af294d5d9 157 {
Simon Cooksey 0:fb7af294d5d9 158 ++i;
Simon Cooksey 0:fb7af294d5d9 159 ++x;
Simon Cooksey 0:fb7af294d5d9 160 }
Simon Cooksey 0:fb7af294d5d9 161
Simon Cooksey 0:fb7af294d5d9 162 /* Spaces at end of buffer are OK */
Simon Cooksey 0:fb7af294d5d9 163 if( i == slen )
Simon Cooksey 0:fb7af294d5d9 164 break;
Simon Cooksey 0:fb7af294d5d9 165
Simon Cooksey 0:fb7af294d5d9 166 if( ( slen - i ) >= 2 &&
Simon Cooksey 0:fb7af294d5d9 167 src[i] == '\r' && src[i + 1] == '\n' )
Simon Cooksey 0:fb7af294d5d9 168 continue;
Simon Cooksey 0:fb7af294d5d9 169
Simon Cooksey 0:fb7af294d5d9 170 if( src[i] == '\n' )
Simon Cooksey 0:fb7af294d5d9 171 continue;
Simon Cooksey 0:fb7af294d5d9 172
Simon Cooksey 0:fb7af294d5d9 173 /* Space inside a line is an error */
Simon Cooksey 0:fb7af294d5d9 174 if( x != 0 )
Simon Cooksey 0:fb7af294d5d9 175 return( MBEDTLS_ERR_BASE64_INVALID_CHARACTER );
Simon Cooksey 0:fb7af294d5d9 176
Simon Cooksey 0:fb7af294d5d9 177 if( src[i] == '=' && ++j > 2 )
Simon Cooksey 0:fb7af294d5d9 178 return( MBEDTLS_ERR_BASE64_INVALID_CHARACTER );
Simon Cooksey 0:fb7af294d5d9 179
Simon Cooksey 0:fb7af294d5d9 180 if( src[i] > 127 || base64_dec_map[src[i]] == 127 )
Simon Cooksey 0:fb7af294d5d9 181 return( MBEDTLS_ERR_BASE64_INVALID_CHARACTER );
Simon Cooksey 0:fb7af294d5d9 182
Simon Cooksey 0:fb7af294d5d9 183 if( base64_dec_map[src[i]] < 64 && j != 0 )
Simon Cooksey 0:fb7af294d5d9 184 return( MBEDTLS_ERR_BASE64_INVALID_CHARACTER );
Simon Cooksey 0:fb7af294d5d9 185
Simon Cooksey 0:fb7af294d5d9 186 n++;
Simon Cooksey 0:fb7af294d5d9 187 }
Simon Cooksey 0:fb7af294d5d9 188
Simon Cooksey 0:fb7af294d5d9 189 if( n == 0 )
Simon Cooksey 0:fb7af294d5d9 190 {
Simon Cooksey 0:fb7af294d5d9 191 *olen = 0;
Simon Cooksey 0:fb7af294d5d9 192 return( 0 );
Simon Cooksey 0:fb7af294d5d9 193 }
Simon Cooksey 0:fb7af294d5d9 194
Simon Cooksey 0:fb7af294d5d9 195 n = ( ( n * 6 ) + 7 ) >> 3;
Simon Cooksey 0:fb7af294d5d9 196 n -= j;
Simon Cooksey 0:fb7af294d5d9 197
Simon Cooksey 0:fb7af294d5d9 198 if( dst == NULL || dlen < n )
Simon Cooksey 0:fb7af294d5d9 199 {
Simon Cooksey 0:fb7af294d5d9 200 *olen = n;
Simon Cooksey 0:fb7af294d5d9 201 return( MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL );
Simon Cooksey 0:fb7af294d5d9 202 }
Simon Cooksey 0:fb7af294d5d9 203
Simon Cooksey 0:fb7af294d5d9 204 for( j = 3, n = x = 0, p = dst; i > 0; i--, src++ )
Simon Cooksey 0:fb7af294d5d9 205 {
Simon Cooksey 0:fb7af294d5d9 206 if( *src == '\r' || *src == '\n' || *src == ' ' )
Simon Cooksey 0:fb7af294d5d9 207 continue;
Simon Cooksey 0:fb7af294d5d9 208
Simon Cooksey 0:fb7af294d5d9 209 j -= ( base64_dec_map[*src] == 64 );
Simon Cooksey 0:fb7af294d5d9 210 x = ( x << 6 ) | ( base64_dec_map[*src] & 0x3F );
Simon Cooksey 0:fb7af294d5d9 211
Simon Cooksey 0:fb7af294d5d9 212 if( ++n == 4 )
Simon Cooksey 0:fb7af294d5d9 213 {
Simon Cooksey 0:fb7af294d5d9 214 n = 0;
Simon Cooksey 0:fb7af294d5d9 215 if( j > 0 ) *p++ = (unsigned char)( x >> 16 );
Simon Cooksey 0:fb7af294d5d9 216 if( j > 1 ) *p++ = (unsigned char)( x >> 8 );
Simon Cooksey 0:fb7af294d5d9 217 if( j > 2 ) *p++ = (unsigned char)( x );
Simon Cooksey 0:fb7af294d5d9 218 }
Simon Cooksey 0:fb7af294d5d9 219 }
Simon Cooksey 0:fb7af294d5d9 220
Simon Cooksey 0:fb7af294d5d9 221 *olen = p - dst;
Simon Cooksey 0:fb7af294d5d9 222
Simon Cooksey 0:fb7af294d5d9 223 return( 0 );
Simon Cooksey 0:fb7af294d5d9 224 }
Simon Cooksey 0:fb7af294d5d9 225
Simon Cooksey 0:fb7af294d5d9 226 #if defined(MBEDTLS_SELF_TEST)
Simon Cooksey 0:fb7af294d5d9 227
Simon Cooksey 0:fb7af294d5d9 228 static const unsigned char base64_test_dec[64] =
Simon Cooksey 0:fb7af294d5d9 229 {
Simon Cooksey 0:fb7af294d5d9 230 0x24, 0x48, 0x6E, 0x56, 0x87, 0x62, 0x5A, 0xBD,
Simon Cooksey 0:fb7af294d5d9 231 0xBF, 0x17, 0xD9, 0xA2, 0xC4, 0x17, 0x1A, 0x01,
Simon Cooksey 0:fb7af294d5d9 232 0x94, 0xED, 0x8F, 0x1E, 0x11, 0xB3, 0xD7, 0x09,
Simon Cooksey 0:fb7af294d5d9 233 0x0C, 0xB6, 0xE9, 0x10, 0x6F, 0x22, 0xEE, 0x13,
Simon Cooksey 0:fb7af294d5d9 234 0xCA, 0xB3, 0x07, 0x05, 0x76, 0xC9, 0xFA, 0x31,
Simon Cooksey 0:fb7af294d5d9 235 0x6C, 0x08, 0x34, 0xFF, 0x8D, 0xC2, 0x6C, 0x38,
Simon Cooksey 0:fb7af294d5d9 236 0x00, 0x43, 0xE9, 0x54, 0x97, 0xAF, 0x50, 0x4B,
Simon Cooksey 0:fb7af294d5d9 237 0xD1, 0x41, 0xBA, 0x95, 0x31, 0x5A, 0x0B, 0x97
Simon Cooksey 0:fb7af294d5d9 238 };
Simon Cooksey 0:fb7af294d5d9 239
Simon Cooksey 0:fb7af294d5d9 240 static const unsigned char base64_test_enc[] =
Simon Cooksey 0:fb7af294d5d9 241 "JEhuVodiWr2/F9mixBcaAZTtjx4Rs9cJDLbpEG8i7hPK"
Simon Cooksey 0:fb7af294d5d9 242 "swcFdsn6MWwINP+Nwmw4AEPpVJevUEvRQbqVMVoLlw==";
Simon Cooksey 0:fb7af294d5d9 243
Simon Cooksey 0:fb7af294d5d9 244 /*
Simon Cooksey 0:fb7af294d5d9 245 * Checkup routine
Simon Cooksey 0:fb7af294d5d9 246 */
Simon Cooksey 0:fb7af294d5d9 247 int mbedtls_base64_self_test( int verbose )
Simon Cooksey 0:fb7af294d5d9 248 {
Simon Cooksey 0:fb7af294d5d9 249 size_t len;
Simon Cooksey 0:fb7af294d5d9 250 const unsigned char *src;
Simon Cooksey 0:fb7af294d5d9 251 unsigned char buffer[128];
Simon Cooksey 0:fb7af294d5d9 252
Simon Cooksey 0:fb7af294d5d9 253 if( verbose != 0 )
Simon Cooksey 0:fb7af294d5d9 254 mbedtls_printf( " Base64 encoding test: " );
Simon Cooksey 0:fb7af294d5d9 255
Simon Cooksey 0:fb7af294d5d9 256 src = base64_test_dec;
Simon Cooksey 0:fb7af294d5d9 257
Simon Cooksey 0:fb7af294d5d9 258 if( mbedtls_base64_encode( buffer, sizeof( buffer ), &len, src, 64 ) != 0 ||
Simon Cooksey 0:fb7af294d5d9 259 memcmp( base64_test_enc, buffer, 88 ) != 0 )
Simon Cooksey 0:fb7af294d5d9 260 {
Simon Cooksey 0:fb7af294d5d9 261 if( verbose != 0 )
Simon Cooksey 0:fb7af294d5d9 262 mbedtls_printf( "failed\n" );
Simon Cooksey 0:fb7af294d5d9 263
Simon Cooksey 0:fb7af294d5d9 264 return( 1 );
Simon Cooksey 0:fb7af294d5d9 265 }
Simon Cooksey 0:fb7af294d5d9 266
Simon Cooksey 0:fb7af294d5d9 267 if( verbose != 0 )
Simon Cooksey 0:fb7af294d5d9 268 mbedtls_printf( "passed\n Base64 decoding test: " );
Simon Cooksey 0:fb7af294d5d9 269
Simon Cooksey 0:fb7af294d5d9 270 src = base64_test_enc;
Simon Cooksey 0:fb7af294d5d9 271
Simon Cooksey 0:fb7af294d5d9 272 if( mbedtls_base64_decode( buffer, sizeof( buffer ), &len, src, 88 ) != 0 ||
Simon Cooksey 0:fb7af294d5d9 273 memcmp( base64_test_dec, buffer, 64 ) != 0 )
Simon Cooksey 0:fb7af294d5d9 274 {
Simon Cooksey 0:fb7af294d5d9 275 if( verbose != 0 )
Simon Cooksey 0:fb7af294d5d9 276 mbedtls_printf( "failed\n" );
Simon Cooksey 0:fb7af294d5d9 277
Simon Cooksey 0:fb7af294d5d9 278 return( 1 );
Simon Cooksey 0:fb7af294d5d9 279 }
Simon Cooksey 0:fb7af294d5d9 280
Simon Cooksey 0:fb7af294d5d9 281 if( verbose != 0 )
Simon Cooksey 0:fb7af294d5d9 282 mbedtls_printf( "passed\n\n" );
Simon Cooksey 0:fb7af294d5d9 283
Simon Cooksey 0:fb7af294d5d9 284 return( 0 );
Simon Cooksey 0:fb7af294d5d9 285 }
Simon Cooksey 0:fb7af294d5d9 286
Simon Cooksey 0:fb7af294d5d9 287 #endif /* MBEDTLS_SELF_TEST */
Simon Cooksey 0:fb7af294d5d9 288
Simon Cooksey 0:fb7af294d5d9 289 #endif /* MBEDTLS_BASE64_C */