mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-12-24 17:41:01 +03:00
The Great Renaming
A simple execution of tmp/invoke-rename.pl
This commit is contained in:
@@ -20,22 +20,22 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#if !defined(POLARSSL_CONFIG_FILE)
|
||||
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||
#include "mbedtls/config.h"
|
||||
#else
|
||||
#include POLARSSL_CONFIG_FILE
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
#include "mbedtls/platform.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define polarssl_free free
|
||||
#define polarssl_malloc malloc
|
||||
#define polarssl_printf printf
|
||||
#define mbedtls_free free
|
||||
#define mbedtls_malloc malloc
|
||||
#define mbedtls_printf printf
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_BASE64_C) && defined(POLARSSL_FS_IO)
|
||||
#if defined(MBEDTLS_BASE64_C) && defined(MBEDTLS_FS_IO)
|
||||
#include "mbedtls/error.h"
|
||||
#include "mbedtls/base64.h"
|
||||
|
||||
@@ -54,10 +54,10 @@
|
||||
" output_file=%%s default: file.der\n" \
|
||||
"\n"
|
||||
|
||||
#if !defined(POLARSSL_BASE64_C) || !defined(POLARSSL_FS_IO)
|
||||
#if !defined(MBEDTLS_BASE64_C) || !defined(MBEDTLS_FS_IO)
|
||||
int main( void )
|
||||
{
|
||||
polarssl_printf("POLARSSL_BASE64_C and/or POLARSSL_FS_IO not defined.\n");
|
||||
mbedtls_printf("MBEDTLS_BASE64_C and/or MBEDTLS_FS_IO not defined.\n");
|
||||
return( 0 );
|
||||
}
|
||||
#else
|
||||
@@ -96,14 +96,14 @@ int convert_pem_to_der( const unsigned char *input, size_t ilen,
|
||||
if( s2 <= s1 || s2 > end )
|
||||
return( -1 );
|
||||
|
||||
ret = base64_decode( NULL, &len, (const unsigned char *) s1, s2 - s1 );
|
||||
if( ret == POLARSSL_ERR_BASE64_INVALID_CHARACTER )
|
||||
ret = mbedtls_base64_decode( NULL, &len, (const unsigned char *) s1, s2 - s1 );
|
||||
if( ret == MBEDTLS_ERR_BASE64_INVALID_CHARACTER )
|
||||
return( ret );
|
||||
|
||||
if( len > *olen )
|
||||
return( -1 );
|
||||
|
||||
if( ( ret = base64_decode( output, &len, (const unsigned char *) s1,
|
||||
if( ( ret = mbedtls_base64_decode( output, &len, (const unsigned char *) s1,
|
||||
s2 - s1 ) ) != 0 )
|
||||
{
|
||||
return( ret );
|
||||
@@ -136,7 +136,7 @@ static int load_file( const char *path, unsigned char **buf, size_t *n )
|
||||
*n = (size_t) size;
|
||||
|
||||
if( *n + 1 == 0 ||
|
||||
( *buf = polarssl_malloc( *n + 1 ) ) == NULL )
|
||||
( *buf = mbedtls_malloc( *n + 1 ) ) == NULL )
|
||||
{
|
||||
fclose( f );
|
||||
return( -1 );
|
||||
@@ -196,7 +196,7 @@ int main( int argc, char *argv[] )
|
||||
if( argc == 0 )
|
||||
{
|
||||
usage:
|
||||
polarssl_printf( USAGE );
|
||||
mbedtls_printf( USAGE );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
@@ -222,66 +222,66 @@ int main( int argc, char *argv[] )
|
||||
/*
|
||||
* 1.1. Load the PEM file
|
||||
*/
|
||||
polarssl_printf( "\n . Loading the PEM file ..." );
|
||||
mbedtls_printf( "\n . Loading the PEM file ..." );
|
||||
fflush( stdout );
|
||||
|
||||
ret = load_file( opt.filename, &pem_buffer, &pem_size );
|
||||
|
||||
if( ret != 0 )
|
||||
{
|
||||
#ifdef POLARSSL_ERROR_C
|
||||
polarssl_strerror( ret, buf, 1024 );
|
||||
#ifdef MBEDTLS_ERROR_C
|
||||
mbedtls_strerror( ret, buf, 1024 );
|
||||
#endif
|
||||
polarssl_printf( " failed\n ! load_file returned %d - %s\n\n", ret, buf );
|
||||
mbedtls_printf( " failed\n ! load_file returned %d - %s\n\n", ret, buf );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
polarssl_printf( " ok\n" );
|
||||
mbedtls_printf( " ok\n" );
|
||||
|
||||
/*
|
||||
* 1.2. Convert from PEM to DER
|
||||
*/
|
||||
polarssl_printf( " . Converting from PEM to DER ..." );
|
||||
mbedtls_printf( " . Converting from PEM to DER ..." );
|
||||
fflush( stdout );
|
||||
|
||||
if( ( ret = convert_pem_to_der( pem_buffer, pem_size, der_buffer, &der_size ) ) != 0 )
|
||||
{
|
||||
#ifdef POLARSSL_ERROR_C
|
||||
polarssl_strerror( ret, buf, 1024 );
|
||||
#ifdef MBEDTLS_ERROR_C
|
||||
mbedtls_strerror( ret, buf, 1024 );
|
||||
#endif
|
||||
polarssl_printf( " failed\n ! convert_pem_to_der %d - %s\n\n", ret, buf );
|
||||
mbedtls_printf( " failed\n ! convert_pem_to_der %d - %s\n\n", ret, buf );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
polarssl_printf( " ok\n" );
|
||||
mbedtls_printf( " ok\n" );
|
||||
|
||||
/*
|
||||
* 1.3. Write the DER file
|
||||
*/
|
||||
polarssl_printf( " . Writing the DER file ..." );
|
||||
mbedtls_printf( " . Writing the DER file ..." );
|
||||
fflush( stdout );
|
||||
|
||||
ret = write_file( opt.output_file, der_buffer, der_size );
|
||||
|
||||
if( ret != 0 )
|
||||
{
|
||||
#ifdef POLARSSL_ERROR_C
|
||||
polarssl_strerror( ret, buf, 1024 );
|
||||
#ifdef MBEDTLS_ERROR_C
|
||||
mbedtls_strerror( ret, buf, 1024 );
|
||||
#endif
|
||||
polarssl_printf( " failed\n ! write_file returned %d - %s\n\n", ret, buf );
|
||||
mbedtls_printf( " failed\n ! write_file returned %d - %s\n\n", ret, buf );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
polarssl_printf( " ok\n" );
|
||||
mbedtls_printf( " ok\n" );
|
||||
|
||||
exit:
|
||||
free( pem_buffer );
|
||||
|
||||
#if defined(_WIN32)
|
||||
polarssl_printf( " + Press Enter to exit this program.\n" );
|
||||
mbedtls_printf( " + Press Enter to exit this program.\n" );
|
||||
fflush( stdout ); getchar();
|
||||
#endif
|
||||
|
||||
return( ret );
|
||||
}
|
||||
#endif /* POLARSSL_BASE64_C && POLARSSL_FS_IO */
|
||||
#endif /* MBEDTLS_BASE64_C && MBEDTLS_FS_IO */
|
||||
|
||||
@@ -20,20 +20,20 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#if !defined(POLARSSL_CONFIG_FILE)
|
||||
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||
#include "mbedtls/config.h"
|
||||
#else
|
||||
#include POLARSSL_CONFIG_FILE
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
#include "mbedtls/platform.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define polarssl_printf printf
|
||||
#define mbedtls_printf printf
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_ERROR_C) || defined(POLARSSL_ERROR_STRERROR_DUMMY)
|
||||
#if defined(MBEDTLS_ERROR_C) || defined(MBEDTLS_ERROR_STRERROR_DUMMY)
|
||||
#include "mbedtls/error.h"
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -45,10 +45,10 @@
|
||||
"\n usage: strerror <errorcode>\n" \
|
||||
"\n where <errorcode> can be a decimal or hexadecimal (starts with 0x or -0x)\n"
|
||||
|
||||
#if !defined(POLARSSL_ERROR_C) && !defined(POLARSSL_ERROR_STRERROR_DUMMY)
|
||||
#if !defined(MBEDTLS_ERROR_C) && !defined(MBEDTLS_ERROR_STRERROR_DUMMY)
|
||||
int main( void )
|
||||
{
|
||||
polarssl_printf("POLARSSL_ERROR_C and/or POLARSSL_ERROR_STRERROR_DUMMY not defined.\n");
|
||||
mbedtls_printf("MBEDTLS_ERROR_C and/or MBEDTLS_ERROR_STRERROR_DUMMY not defined.\n");
|
||||
return( 0 );
|
||||
}
|
||||
#else
|
||||
@@ -59,7 +59,7 @@ int main( int argc, char *argv[] )
|
||||
|
||||
if( argc != 2 )
|
||||
{
|
||||
polarssl_printf( USAGE );
|
||||
mbedtls_printf( USAGE );
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ int main( int argc, char *argv[] )
|
||||
val = strtol( argv[1], &end, 16 );
|
||||
if( *end != '\0' )
|
||||
{
|
||||
polarssl_printf( USAGE );
|
||||
mbedtls_printf( USAGE );
|
||||
return( 0 );
|
||||
}
|
||||
}
|
||||
@@ -79,15 +79,15 @@ int main( int argc, char *argv[] )
|
||||
if( val != 0 )
|
||||
{
|
||||
char error_buf[200];
|
||||
polarssl_strerror( val, error_buf, 200 );
|
||||
polarssl_printf("Last error was: -0x%04x - %s\n\n", (int) -val, error_buf );
|
||||
mbedtls_strerror( val, error_buf, 200 );
|
||||
mbedtls_printf("Last error was: -0x%04x - %s\n\n", (int) -val, error_buf );
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
polarssl_printf( " + Press Enter to exit this program.\n" );
|
||||
mbedtls_printf( " + Press Enter to exit this program.\n" );
|
||||
fflush( stdout ); getchar();
|
||||
#endif
|
||||
|
||||
return( val );
|
||||
}
|
||||
#endif /* POLARSSL_ERROR_C */
|
||||
#endif /* MBEDTLS_ERROR_C */
|
||||
|
||||
Reference in New Issue
Block a user