The Great Renaming
A simple execution of tmp/invoke-rename.pl
This commit is contained in:
parent
b5904d25ef
commit
2cf5a7c98e
291 changed files with 36012 additions and 36012 deletions
156
library/debug.c
156
library/debug.c
|
@ -20,13 +20,13 @@
|
|||
* 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_DEBUG_C)
|
||||
#if defined(MBEDTLS_DEBUG_C)
|
||||
|
||||
#include "mbedtls/debug.h"
|
||||
|
||||
|
@ -44,26 +44,26 @@
|
|||
#endif
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
#include "mbedtls/platform.h"
|
||||
#else
|
||||
#define polarssl_snprintf snprintf
|
||||
#define mbedtls_snprintf snprintf
|
||||
#endif
|
||||
|
||||
static int debug_log_mode = POLARSSL_DEBUG_DFL_MODE;
|
||||
static int debug_log_mode = MBEDTLS_DEBUG_DFL_MODE;
|
||||
static int debug_threshold = 0;
|
||||
|
||||
void debug_set_log_mode( int log_mode )
|
||||
void mbedtls_debug_set_log_mode( int log_mode )
|
||||
{
|
||||
debug_log_mode = log_mode;
|
||||
}
|
||||
|
||||
void debug_set_threshold( int threshold )
|
||||
void mbedtls_debug_set_threshold( int threshold )
|
||||
{
|
||||
debug_threshold = threshold;
|
||||
}
|
||||
|
||||
char *debug_fmt( const char *format, ... )
|
||||
char *mbedtls_debug_fmt( const char *format, ... )
|
||||
{
|
||||
va_list argp;
|
||||
static char str[512];
|
||||
|
@ -77,7 +77,7 @@ char *debug_fmt( const char *format, ... )
|
|||
return( str );
|
||||
}
|
||||
|
||||
void debug_print_msg( const ssl_context *ssl, int level,
|
||||
void mbedtls_debug_print_msg( const mbedtls_ssl_context *ssl, int level,
|
||||
const char *file, int line, const char *text )
|
||||
{
|
||||
char str[512];
|
||||
|
@ -86,18 +86,18 @@ void debug_print_msg( const ssl_context *ssl, int level,
|
|||
if( ssl->f_dbg == NULL || level > debug_threshold )
|
||||
return;
|
||||
|
||||
if( debug_log_mode == POLARSSL_DEBUG_LOG_RAW )
|
||||
if( debug_log_mode == MBEDTLS_DEBUG_LOG_RAW )
|
||||
{
|
||||
ssl->f_dbg( ssl->p_dbg, level, text );
|
||||
return;
|
||||
}
|
||||
|
||||
polarssl_snprintf( str, maxlen, "%s(%04d): %s\n", file, line, text );
|
||||
mbedtls_snprintf( str, maxlen, "%s(%04d): %s\n", file, line, text );
|
||||
str[maxlen] = '\0';
|
||||
ssl->f_dbg( ssl->p_dbg, level, str );
|
||||
}
|
||||
|
||||
void debug_print_ret( const ssl_context *ssl, int level,
|
||||
void mbedtls_debug_print_ret( const mbedtls_ssl_context *ssl, int level,
|
||||
const char *file, int line,
|
||||
const char *text, int ret )
|
||||
{
|
||||
|
@ -108,17 +108,17 @@ void debug_print_ret( const ssl_context *ssl, int level,
|
|||
if( ssl->f_dbg == NULL || level > debug_threshold )
|
||||
return;
|
||||
|
||||
if( debug_log_mode == POLARSSL_DEBUG_LOG_FULL )
|
||||
idx = polarssl_snprintf( str, maxlen, "%s(%04d): ", file, line );
|
||||
if( debug_log_mode == MBEDTLS_DEBUG_LOG_FULL )
|
||||
idx = mbedtls_snprintf( str, maxlen, "%s(%04d): ", file, line );
|
||||
|
||||
polarssl_snprintf( str + idx, maxlen - idx, "%s() returned %d (-0x%04x)\n",
|
||||
mbedtls_snprintf( str + idx, maxlen - idx, "%s() returned %d (-0x%04x)\n",
|
||||
text, ret, -ret );
|
||||
|
||||
str[maxlen] = '\0';
|
||||
ssl->f_dbg( ssl->p_dbg, level, str );
|
||||
}
|
||||
|
||||
void debug_print_buf( const ssl_context *ssl, int level,
|
||||
void mbedtls_debug_print_buf( const mbedtls_ssl_context *ssl, int level,
|
||||
const char *file, int line, const char *text,
|
||||
const unsigned char *buf, size_t len )
|
||||
{
|
||||
|
@ -129,10 +129,10 @@ void debug_print_buf( const ssl_context *ssl, int level,
|
|||
if( ssl->f_dbg == NULL || level > debug_threshold )
|
||||
return;
|
||||
|
||||
if( debug_log_mode == POLARSSL_DEBUG_LOG_FULL )
|
||||
idx = polarssl_snprintf( str, maxlen, "%s(%04d): ", file, line );
|
||||
if( debug_log_mode == MBEDTLS_DEBUG_LOG_FULL )
|
||||
idx = mbedtls_snprintf( str, maxlen, "%s(%04d): ", file, line );
|
||||
|
||||
polarssl_snprintf( str + idx, maxlen - idx, "dumping '%s' (%u bytes)\n",
|
||||
mbedtls_snprintf( str + idx, maxlen - idx, "dumping '%s' (%u bytes)\n",
|
||||
text, (unsigned int) len );
|
||||
|
||||
str[maxlen] = '\0';
|
||||
|
@ -149,22 +149,22 @@ void debug_print_buf( const ssl_context *ssl, int level,
|
|||
{
|
||||
if( i > 0 )
|
||||
{
|
||||
polarssl_snprintf( str + idx, maxlen - idx, " %s\n", txt );
|
||||
mbedtls_snprintf( str + idx, maxlen - idx, " %s\n", txt );
|
||||
ssl->f_dbg( ssl->p_dbg, level, str );
|
||||
|
||||
idx = 0;
|
||||
memset( txt, 0, sizeof( txt ) );
|
||||
}
|
||||
|
||||
if( debug_log_mode == POLARSSL_DEBUG_LOG_FULL )
|
||||
idx = polarssl_snprintf( str, maxlen, "%s(%04d): ", file, line );
|
||||
if( debug_log_mode == MBEDTLS_DEBUG_LOG_FULL )
|
||||
idx = mbedtls_snprintf( str, maxlen, "%s(%04d): ", file, line );
|
||||
|
||||
idx += polarssl_snprintf( str + idx, maxlen - idx, "%04x: ",
|
||||
idx += mbedtls_snprintf( str + idx, maxlen - idx, "%04x: ",
|
||||
(unsigned int) i );
|
||||
|
||||
}
|
||||
|
||||
idx += polarssl_snprintf( str + idx, maxlen - idx, " %02x",
|
||||
idx += mbedtls_snprintf( str + idx, maxlen - idx, " %02x",
|
||||
(unsigned int) buf[i] );
|
||||
txt[i % 16] = ( buf[i] > 31 && buf[i] < 127 ) ? buf[i] : '.' ;
|
||||
}
|
||||
|
@ -172,17 +172,17 @@ void debug_print_buf( const ssl_context *ssl, int level,
|
|||
if( len > 0 )
|
||||
{
|
||||
for( /* i = i */; i % 16 != 0; i++ )
|
||||
idx += polarssl_snprintf( str + idx, maxlen - idx, " " );
|
||||
idx += mbedtls_snprintf( str + idx, maxlen - idx, " " );
|
||||
|
||||
polarssl_snprintf( str + idx, maxlen - idx, " %s\n", txt );
|
||||
mbedtls_snprintf( str + idx, maxlen - idx, " %s\n", txt );
|
||||
ssl->f_dbg( ssl->p_dbg, level, str );
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(POLARSSL_ECP_C)
|
||||
void debug_print_ecp( const ssl_context *ssl, int level,
|
||||
#if defined(MBEDTLS_ECP_C)
|
||||
void mbedtls_debug_print_ecp( const mbedtls_ssl_context *ssl, int level,
|
||||
const char *file, int line,
|
||||
const char *text, const ecp_point *X )
|
||||
const char *text, const mbedtls_ecp_point *X )
|
||||
{
|
||||
char str[512];
|
||||
int maxlen = sizeof( str ) - 1;
|
||||
|
@ -190,20 +190,20 @@ void debug_print_ecp( const ssl_context *ssl, int level,
|
|||
if( ssl->f_dbg == NULL || level > debug_threshold )
|
||||
return;
|
||||
|
||||
polarssl_snprintf( str, maxlen, "%s(X)", text );
|
||||
mbedtls_snprintf( str, maxlen, "%s(X)", text );
|
||||
str[maxlen] = '\0';
|
||||
debug_print_mpi( ssl, level, file, line, str, &X->X );
|
||||
mbedtls_debug_print_mpi( ssl, level, file, line, str, &X->X );
|
||||
|
||||
polarssl_snprintf( str, maxlen, "%s(Y)", text );
|
||||
mbedtls_snprintf( str, maxlen, "%s(Y)", text );
|
||||
str[maxlen] = '\0';
|
||||
debug_print_mpi( ssl, level, file, line, str, &X->Y );
|
||||
mbedtls_debug_print_mpi( ssl, level, file, line, str, &X->Y );
|
||||
}
|
||||
#endif /* POLARSSL_ECP_C */
|
||||
#endif /* MBEDTLS_ECP_C */
|
||||
|
||||
#if defined(POLARSSL_BIGNUM_C)
|
||||
void debug_print_mpi( const ssl_context *ssl, int level,
|
||||
#if defined(MBEDTLS_BIGNUM_C)
|
||||
void mbedtls_debug_print_mpi( const mbedtls_ssl_context *ssl, int level,
|
||||
const char *file, int line,
|
||||
const char *text, const mpi *X )
|
||||
const char *text, const mbedtls_mpi *X )
|
||||
{
|
||||
char str[512];
|
||||
int j, k, maxlen = sizeof( str ) - 1, zeros = 1;
|
||||
|
@ -216,15 +216,15 @@ void debug_print_mpi( const ssl_context *ssl, int level,
|
|||
if( X->p[n] != 0 )
|
||||
break;
|
||||
|
||||
for( j = ( sizeof(t_uint) << 3 ) - 1; j >= 0; j-- )
|
||||
for( j = ( sizeof(mbedtls_mpi_uint) << 3 ) - 1; j >= 0; j-- )
|
||||
if( ( ( X->p[n] >> j ) & 1 ) != 0 )
|
||||
break;
|
||||
|
||||
if( debug_log_mode == POLARSSL_DEBUG_LOG_FULL )
|
||||
idx = polarssl_snprintf( str, maxlen, "%s(%04d): ", file, line );
|
||||
if( debug_log_mode == MBEDTLS_DEBUG_LOG_FULL )
|
||||
idx = mbedtls_snprintf( str, maxlen, "%s(%04d): ", file, line );
|
||||
|
||||
polarssl_snprintf( str + idx, maxlen - idx, "value of '%s' (%d bits) is:\n",
|
||||
text, (int) ( ( n * ( sizeof(t_uint) << 3 ) ) + j + 1 ) );
|
||||
mbedtls_snprintf( str + idx, maxlen - idx, "value of '%s' (%d bits) is:\n",
|
||||
text, (int) ( ( n * ( sizeof(mbedtls_mpi_uint) << 3 ) ) + j + 1 ) );
|
||||
|
||||
str[maxlen] = '\0';
|
||||
ssl->f_dbg( ssl->p_dbg, level, str );
|
||||
|
@ -235,7 +235,7 @@ void debug_print_mpi( const ssl_context *ssl, int level,
|
|||
if( zeros && X->p[i - 1] == 0 )
|
||||
continue;
|
||||
|
||||
for( k = sizeof( t_uint ) - 1; k >= 0; k-- )
|
||||
for( k = sizeof( mbedtls_mpi_uint ) - 1; k >= 0; k-- )
|
||||
{
|
||||
if( zeros && ( ( X->p[i - 1] >> ( k << 3 ) ) & 0xFF ) == 0 )
|
||||
continue;
|
||||
|
@ -246,16 +246,16 @@ void debug_print_mpi( const ssl_context *ssl, int level,
|
|||
{
|
||||
if( j > 0 )
|
||||
{
|
||||
polarssl_snprintf( str + idx, maxlen - idx, "\n" );
|
||||
mbedtls_snprintf( str + idx, maxlen - idx, "\n" );
|
||||
ssl->f_dbg( ssl->p_dbg, level, str );
|
||||
idx = 0;
|
||||
}
|
||||
|
||||
if( debug_log_mode == POLARSSL_DEBUG_LOG_FULL )
|
||||
idx = polarssl_snprintf( str, maxlen, "%s(%04d): ", file, line );
|
||||
if( debug_log_mode == MBEDTLS_DEBUG_LOG_FULL )
|
||||
idx = mbedtls_snprintf( str, maxlen, "%s(%04d): ", file, line );
|
||||
}
|
||||
|
||||
idx += polarssl_snprintf( str + idx, maxlen - idx, " %02x", (unsigned int)
|
||||
idx += mbedtls_snprintf( str + idx, maxlen - idx, " %02x", (unsigned int)
|
||||
( X->p[i - 1] >> ( k << 3 ) ) & 0xFF );
|
||||
|
||||
j++;
|
||||
|
@ -265,59 +265,59 @@ void debug_print_mpi( const ssl_context *ssl, int level,
|
|||
|
||||
if( zeros == 1 )
|
||||
{
|
||||
if( debug_log_mode == POLARSSL_DEBUG_LOG_FULL )
|
||||
if( debug_log_mode == MBEDTLS_DEBUG_LOG_FULL )
|
||||
{
|
||||
idx = polarssl_snprintf( str, maxlen, "%s(%04d): ", file, line );
|
||||
idx = mbedtls_snprintf( str, maxlen, "%s(%04d): ", file, line );
|
||||
|
||||
}
|
||||
idx += polarssl_snprintf( str + idx, maxlen - idx, " 00" );
|
||||
idx += mbedtls_snprintf( str + idx, maxlen - idx, " 00" );
|
||||
}
|
||||
|
||||
polarssl_snprintf( str + idx, maxlen - idx, "\n" );
|
||||
mbedtls_snprintf( str + idx, maxlen - idx, "\n" );
|
||||
ssl->f_dbg( ssl->p_dbg, level, str );
|
||||
}
|
||||
#endif /* POLARSSL_BIGNUM_C */
|
||||
#endif /* MBEDTLS_BIGNUM_C */
|
||||
|
||||
#if defined(POLARSSL_X509_CRT_PARSE_C)
|
||||
static void debug_print_pk( const ssl_context *ssl, int level,
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
static void debug_print_pk( const mbedtls_ssl_context *ssl, int level,
|
||||
const char *file, int line,
|
||||
const char *text, const pk_context *pk )
|
||||
const char *text, const mbedtls_pk_context *pk )
|
||||
{
|
||||
size_t i;
|
||||
pk_debug_item items[POLARSSL_PK_DEBUG_MAX_ITEMS];
|
||||
mbedtls_pk_debug_item items[MBEDTLS_PK_DEBUG_MAX_ITEMS];
|
||||
char name[16];
|
||||
|
||||
memset( items, 0, sizeof( items ) );
|
||||
|
||||
if( pk_debug( pk, items ) != 0 )
|
||||
if( mbedtls_pk_debug( pk, items ) != 0 )
|
||||
{
|
||||
debug_print_msg( ssl, level, file, line, "invalid PK context" );
|
||||
mbedtls_debug_print_msg( ssl, level, file, line, "invalid PK context" );
|
||||
return;
|
||||
}
|
||||
|
||||
for( i = 0; i < POLARSSL_PK_DEBUG_MAX_ITEMS; i++ )
|
||||
for( i = 0; i < MBEDTLS_PK_DEBUG_MAX_ITEMS; i++ )
|
||||
{
|
||||
if( items[i].type == POLARSSL_PK_DEBUG_NONE )
|
||||
if( items[i].type == MBEDTLS_PK_DEBUG_NONE )
|
||||
return;
|
||||
|
||||
polarssl_snprintf( name, sizeof( name ), "%s%s", text, items[i].name );
|
||||
mbedtls_snprintf( name, sizeof( name ), "%s%s", text, items[i].name );
|
||||
name[sizeof( name ) - 1] = '\0';
|
||||
|
||||
if( items[i].type == POLARSSL_PK_DEBUG_MPI )
|
||||
debug_print_mpi( ssl, level, file, line, name, items[i].value );
|
||||
if( items[i].type == MBEDTLS_PK_DEBUG_MPI )
|
||||
mbedtls_debug_print_mpi( ssl, level, file, line, name, items[i].value );
|
||||
else
|
||||
#if defined(POLARSSL_ECP_C)
|
||||
if( items[i].type == POLARSSL_PK_DEBUG_ECP )
|
||||
debug_print_ecp( ssl, level, file, line, name, items[i].value );
|
||||
#if defined(MBEDTLS_ECP_C)
|
||||
if( items[i].type == MBEDTLS_PK_DEBUG_ECP )
|
||||
mbedtls_debug_print_ecp( ssl, level, file, line, name, items[i].value );
|
||||
else
|
||||
#endif
|
||||
debug_print_msg( ssl, level, file, line, "should not happen" );
|
||||
mbedtls_debug_print_msg( ssl, level, file, line, "should not happen" );
|
||||
}
|
||||
}
|
||||
|
||||
void debug_print_crt( const ssl_context *ssl, int level,
|
||||
void mbedtls_debug_print_crt( const mbedtls_ssl_context *ssl, int level,
|
||||
const char *file, int line,
|
||||
const char *text, const x509_crt *crt )
|
||||
const char *text, const mbedtls_x509_crt *crt )
|
||||
{
|
||||
char str[1024], prefix[64];
|
||||
int i = 0, maxlen = sizeof( prefix ) - 1, idx = 0;
|
||||
|
@ -325,9 +325,9 @@ void debug_print_crt( const ssl_context *ssl, int level,
|
|||
if( ssl->f_dbg == NULL || crt == NULL || level > debug_threshold )
|
||||
return;
|
||||
|
||||
if( debug_log_mode == POLARSSL_DEBUG_LOG_FULL )
|
||||
if( debug_log_mode == MBEDTLS_DEBUG_LOG_FULL )
|
||||
{
|
||||
polarssl_snprintf( prefix, maxlen, "%s(%04d): ", file, line );
|
||||
mbedtls_snprintf( prefix, maxlen, "%s(%04d): ", file, line );
|
||||
prefix[maxlen] = '\0';
|
||||
}
|
||||
else
|
||||
|
@ -338,12 +338,12 @@ void debug_print_crt( const ssl_context *ssl, int level,
|
|||
while( crt != NULL )
|
||||
{
|
||||
char buf[1024];
|
||||
x509_crt_info( buf, sizeof( buf ) - 1, prefix, crt );
|
||||
mbedtls_x509_crt_info( buf, sizeof( buf ) - 1, prefix, crt );
|
||||
|
||||
if( debug_log_mode == POLARSSL_DEBUG_LOG_FULL )
|
||||
idx = polarssl_snprintf( str, maxlen, "%s(%04d): ", file, line );
|
||||
if( debug_log_mode == MBEDTLS_DEBUG_LOG_FULL )
|
||||
idx = mbedtls_snprintf( str, maxlen, "%s(%04d): ", file, line );
|
||||
|
||||
polarssl_snprintf( str + idx, maxlen - idx, "%s #%d:\n%s",
|
||||
mbedtls_snprintf( str + idx, maxlen - idx, "%s #%d:\n%s",
|
||||
text, ++i, buf );
|
||||
|
||||
str[maxlen] = '\0';
|
||||
|
@ -354,6 +354,6 @@ void debug_print_crt( const ssl_context *ssl, int level,
|
|||
crt = crt->next;
|
||||
}
|
||||
}
|
||||
#endif /* POLARSSL_X509_CRT_PARSE_C */
|
||||
#endif /* MBEDTLS_X509_CRT_PARSE_C */
|
||||
|
||||
#endif /* POLARSSL_DEBUG_C */
|
||||
#endif /* MBEDTLS_DEBUG_C */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue