mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 11:15:43 +01:00
modify library/x509*.c to use polarssl_snprintf
This commit is contained in:
parent
a18b11f285
commit
fac657fd52
@ -53,9 +53,10 @@
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#define polarssl_printf printf
|
||||
#define polarssl_malloc malloc
|
||||
#define polarssl_free free
|
||||
#define polarssl_malloc malloc
|
||||
#define polarssl_printf printf
|
||||
#define polarssl_snprintf snprintf
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
|
||||
@ -734,16 +735,16 @@ int x509_dn_gets( char *buf, size_t size, const x509_name *dn )
|
||||
|
||||
if( name != dn )
|
||||
{
|
||||
ret = snprintf( p, n, merge ? " + " : ", " );
|
||||
ret = polarssl_snprintf( p, n, merge ? " + " : ", " );
|
||||
SAFE_SNPRINTF();
|
||||
}
|
||||
|
||||
ret = oid_get_attr_short_name( &name->oid, &short_name );
|
||||
|
||||
if( ret == 0 )
|
||||
ret = snprintf( p, n, "%s=", short_name );
|
||||
ret = polarssl_snprintf( p, n, "%s=", short_name );
|
||||
else
|
||||
ret = snprintf( p, n, "\?\?=" );
|
||||
ret = polarssl_snprintf( p, n, "\?\?=" );
|
||||
SAFE_SNPRINTF();
|
||||
|
||||
for( i = 0; i < name->val.len; i++ )
|
||||
@ -757,7 +758,7 @@ int x509_dn_gets( char *buf, size_t size, const x509_name *dn )
|
||||
else s[i] = c;
|
||||
}
|
||||
s[i] = '\0';
|
||||
ret = snprintf( p, n, "%s", s );
|
||||
ret = polarssl_snprintf( p, n, "%s", s );
|
||||
SAFE_SNPRINTF();
|
||||
|
||||
merge = name->next_merged;
|
||||
@ -788,14 +789,14 @@ int x509_serial_gets( char *buf, size_t size, const x509_buf *serial )
|
||||
if( i == 0 && nr > 1 && serial->p[i] == 0x0 )
|
||||
continue;
|
||||
|
||||
ret = snprintf( p, n, "%02X%s",
|
||||
ret = polarssl_snprintf( p, n, "%02X%s",
|
||||
serial->p[i], ( i < nr - 1 ) ? ":" : "" );
|
||||
SAFE_SNPRINTF();
|
||||
}
|
||||
|
||||
if( nr != serial->len )
|
||||
{
|
||||
ret = snprintf( p, n, "...." );
|
||||
ret = polarssl_snprintf( p, n, "...." );
|
||||
SAFE_SNPRINTF();
|
||||
}
|
||||
|
||||
@ -816,9 +817,9 @@ int x509_sig_alg_gets( char *buf, size_t size, const x509_buf *sig_oid,
|
||||
|
||||
ret = oid_get_sig_alg_desc( sig_oid, &desc );
|
||||
if( ret != 0 )
|
||||
ret = snprintf( p, n, "???" );
|
||||
ret = polarssl_snprintf( p, n, "???" );
|
||||
else
|
||||
ret = snprintf( p, n, "%s", desc );
|
||||
ret = polarssl_snprintf( p, n, "%s", desc );
|
||||
SAFE_SNPRINTF();
|
||||
|
||||
#if defined(POLARSSL_X509_RSASSA_PSS_SUPPORT)
|
||||
@ -832,7 +833,7 @@ int x509_sig_alg_gets( char *buf, size_t size, const x509_buf *sig_oid,
|
||||
md_info = md_info_from_type( md_alg );
|
||||
mgf_md_info = md_info_from_type( pss_opts->mgf1_hash_id );
|
||||
|
||||
ret = snprintf( p, n, " (%s, MGF1-%s, 0x%02X)",
|
||||
ret = polarssl_snprintf( p, n, " (%s, MGF1-%s, 0x%02X)",
|
||||
md_info ? md_info->name : "???",
|
||||
mgf_md_info ? mgf_md_info->name : "???",
|
||||
pss_opts->expected_salt_len );
|
||||
@ -859,7 +860,7 @@ int x509_key_size_helper( char *buf, size_t size, const char *name )
|
||||
if( strlen( name ) + sizeof( " key size" ) > size )
|
||||
return( POLARSSL_ERR_DEBUG_BUF_TOO_SMALL );
|
||||
|
||||
ret = snprintf( p, n, "%s key size", name );
|
||||
ret = polarssl_snprintf( p, n, "%s key size", name );
|
||||
SAFE_SNPRINTF();
|
||||
|
||||
return( 0 );
|
||||
|
@ -51,8 +51,9 @@
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#define polarssl_malloc malloc
|
||||
#define polarssl_free free
|
||||
#define polarssl_malloc malloc
|
||||
#define polarssl_snprintf snprintf
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
|
||||
@ -630,23 +631,23 @@ int x509_crl_info( char *buf, size_t size, const char *prefix,
|
||||
p = buf;
|
||||
n = size;
|
||||
|
||||
ret = snprintf( p, n, "%sCRL version : %d",
|
||||
ret = polarssl_snprintf( p, n, "%sCRL version : %d",
|
||||
prefix, crl->version );
|
||||
SAFE_SNPRINTF();
|
||||
|
||||
ret = snprintf( p, n, "\n%sissuer name : ", prefix );
|
||||
ret = polarssl_snprintf( p, n, "\n%sissuer name : ", prefix );
|
||||
SAFE_SNPRINTF();
|
||||
ret = x509_dn_gets( p, n, &crl->issuer );
|
||||
SAFE_SNPRINTF();
|
||||
|
||||
ret = snprintf( p, n, "\n%sthis update : " \
|
||||
ret = polarssl_snprintf( p, n, "\n%sthis update : " \
|
||||
"%04d-%02d-%02d %02d:%02d:%02d", prefix,
|
||||
crl->this_update.year, crl->this_update.mon,
|
||||
crl->this_update.day, crl->this_update.hour,
|
||||
crl->this_update.min, crl->this_update.sec );
|
||||
SAFE_SNPRINTF();
|
||||
|
||||
ret = snprintf( p, n, "\n%snext update : " \
|
||||
ret = polarssl_snprintf( p, n, "\n%snext update : " \
|
||||
"%04d-%02d-%02d %02d:%02d:%02d", prefix,
|
||||
crl->next_update.year, crl->next_update.mon,
|
||||
crl->next_update.day, crl->next_update.hour,
|
||||
@ -655,20 +656,20 @@ int x509_crl_info( char *buf, size_t size, const char *prefix,
|
||||
|
||||
entry = &crl->entry;
|
||||
|
||||
ret = snprintf( p, n, "\n%sRevoked certificates:",
|
||||
ret = polarssl_snprintf( p, n, "\n%sRevoked certificates:",
|
||||
prefix );
|
||||
SAFE_SNPRINTF();
|
||||
|
||||
while( entry != NULL && entry->raw.len != 0 )
|
||||
{
|
||||
ret = snprintf( p, n, "\n%sserial number: ",
|
||||
ret = polarssl_snprintf( p, n, "\n%sserial number: ",
|
||||
prefix );
|
||||
SAFE_SNPRINTF();
|
||||
|
||||
ret = x509_serial_gets( p, n, &entry->serial );
|
||||
SAFE_SNPRINTF();
|
||||
|
||||
ret = snprintf( p, n, " revocation date: " \
|
||||
ret = polarssl_snprintf( p, n, " revocation date: " \
|
||||
"%04d-%02d-%02d %02d:%02d:%02d",
|
||||
entry->revocation_date.year, entry->revocation_date.mon,
|
||||
entry->revocation_date.day, entry->revocation_date.hour,
|
||||
@ -678,14 +679,14 @@ int x509_crl_info( char *buf, size_t size, const char *prefix,
|
||||
entry = entry->next;
|
||||
}
|
||||
|
||||
ret = snprintf( p, n, "\n%ssigned using : ", prefix );
|
||||
ret = polarssl_snprintf( p, n, "\n%ssigned using : ", prefix );
|
||||
SAFE_SNPRINTF();
|
||||
|
||||
ret = x509_sig_alg_gets( p, n, &crl->sig_oid1, crl->sig_pk, crl->sig_md,
|
||||
crl->sig_opts );
|
||||
SAFE_SNPRINTF();
|
||||
|
||||
ret = snprintf( p, n, "\n" );
|
||||
ret = polarssl_snprintf( p, n, "\n" );
|
||||
SAFE_SNPRINTF();
|
||||
|
||||
return( (int) ( size - n ) );
|
||||
|
@ -52,8 +52,9 @@
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#define polarssl_malloc malloc
|
||||
#define polarssl_free free
|
||||
#define polarssl_malloc malloc
|
||||
#define polarssl_snprintf snprintf
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_THREADING_C)
|
||||
@ -1040,7 +1041,7 @@ int x509_crt_parse_path( x509_crt *chain, const char *path )
|
||||
|
||||
while( ( entry = readdir( dir ) ) != NULL )
|
||||
{
|
||||
snprintf( entry_name, sizeof entry_name, "%s/%s", path, entry->d_name );
|
||||
polarssl_snprintf( entry_name, sizeof entry_name, "%s/%s", path, entry->d_name );
|
||||
|
||||
if( stat( entry_name, &sb ) == -1 )
|
||||
{
|
||||
@ -1166,7 +1167,7 @@ static int x509_info_subject_alt_name( char **buf, size_t *size,
|
||||
|
||||
#define PRINT_ITEM(i) \
|
||||
{ \
|
||||
ret = snprintf( p, n, "%s" i, sep ); \
|
||||
ret = polarssl_snprintf( p, n, "%s" i, sep ); \
|
||||
SAFE_SNPRINTF(); \
|
||||
sep = ", "; \
|
||||
}
|
||||
@ -1239,7 +1240,7 @@ static int x509_info_ext_key_usage( char **buf, size_t *size,
|
||||
if( oid_get_extended_key_usage( &cur->buf, &desc ) != 0 )
|
||||
desc = "???";
|
||||
|
||||
ret = snprintf( p, n, "%s%s", sep, desc );
|
||||
ret = polarssl_snprintf( p, n, "%s%s", sep, desc );
|
||||
SAFE_SNPRINTF();
|
||||
|
||||
sep = ", ";
|
||||
@ -1269,41 +1270,41 @@ int x509_crt_info( char *buf, size_t size, const char *prefix,
|
||||
p = buf;
|
||||
n = size;
|
||||
|
||||
ret = snprintf( p, n, "%scert. version : %d\n",
|
||||
ret = polarssl_snprintf( p, n, "%scert. version : %d\n",
|
||||
prefix, crt->version );
|
||||
SAFE_SNPRINTF();
|
||||
ret = snprintf( p, n, "%sserial number : ",
|
||||
ret = polarssl_snprintf( p, n, "%sserial number : ",
|
||||
prefix );
|
||||
SAFE_SNPRINTF();
|
||||
|
||||
ret = x509_serial_gets( p, n, &crt->serial );
|
||||
SAFE_SNPRINTF();
|
||||
|
||||
ret = snprintf( p, n, "\n%sissuer name : ", prefix );
|
||||
ret = polarssl_snprintf( p, n, "\n%sissuer name : ", prefix );
|
||||
SAFE_SNPRINTF();
|
||||
ret = x509_dn_gets( p, n, &crt->issuer );
|
||||
SAFE_SNPRINTF();
|
||||
|
||||
ret = snprintf( p, n, "\n%ssubject name : ", prefix );
|
||||
ret = polarssl_snprintf( p, n, "\n%ssubject name : ", prefix );
|
||||
SAFE_SNPRINTF();
|
||||
ret = x509_dn_gets( p, n, &crt->subject );
|
||||
SAFE_SNPRINTF();
|
||||
|
||||
ret = snprintf( p, n, "\n%sissued on : " \
|
||||
ret = polarssl_snprintf( p, n, "\n%sissued on : " \
|
||||
"%04d-%02d-%02d %02d:%02d:%02d", prefix,
|
||||
crt->valid_from.year, crt->valid_from.mon,
|
||||
crt->valid_from.day, crt->valid_from.hour,
|
||||
crt->valid_from.min, crt->valid_from.sec );
|
||||
SAFE_SNPRINTF();
|
||||
|
||||
ret = snprintf( p, n, "\n%sexpires on : " \
|
||||
ret = polarssl_snprintf( p, n, "\n%sexpires on : " \
|
||||
"%04d-%02d-%02d %02d:%02d:%02d", prefix,
|
||||
crt->valid_to.year, crt->valid_to.mon,
|
||||
crt->valid_to.day, crt->valid_to.hour,
|
||||
crt->valid_to.min, crt->valid_to.sec );
|
||||
SAFE_SNPRINTF();
|
||||
|
||||
ret = snprintf( p, n, "\n%ssigned using : ", prefix );
|
||||
ret = polarssl_snprintf( p, n, "\n%ssigned using : ", prefix );
|
||||
SAFE_SNPRINTF();
|
||||
|
||||
ret = x509_sig_alg_gets( p, n, &crt->sig_oid1, crt->sig_pk,
|
||||
@ -1317,7 +1318,7 @@ int x509_crt_info( char *buf, size_t size, const char *prefix,
|
||||
return( ret );
|
||||
}
|
||||
|
||||
ret = snprintf( p, n, "\n%s%-" BC "s: %d bits", prefix, key_size_str,
|
||||
ret = polarssl_snprintf( p, n, "\n%s%-" BC "s: %d bits", prefix, key_size_str,
|
||||
(int) pk_get_size( &crt->pk ) );
|
||||
SAFE_SNPRINTF();
|
||||
|
||||
@ -1327,20 +1328,20 @@ int x509_crt_info( char *buf, size_t size, const char *prefix,
|
||||
|
||||
if( crt->ext_types & EXT_BASIC_CONSTRAINTS )
|
||||
{
|
||||
ret = snprintf( p, n, "\n%sbasic constraints : CA=%s", prefix,
|
||||
ret = polarssl_snprintf( p, n, "\n%sbasic constraints : CA=%s", prefix,
|
||||
crt->ca_istrue ? "true" : "false" );
|
||||
SAFE_SNPRINTF();
|
||||
|
||||
if( crt->max_pathlen > 0 )
|
||||
{
|
||||
ret = snprintf( p, n, ", max_pathlen=%d", crt->max_pathlen - 1 );
|
||||
ret = polarssl_snprintf( p, n, ", max_pathlen=%d", crt->max_pathlen - 1 );
|
||||
SAFE_SNPRINTF();
|
||||
}
|
||||
}
|
||||
|
||||
if( crt->ext_types & EXT_SUBJECT_ALT_NAME )
|
||||
{
|
||||
ret = snprintf( p, n, "\n%ssubject alt name : ", prefix );
|
||||
ret = polarssl_snprintf( p, n, "\n%ssubject alt name : ", prefix );
|
||||
SAFE_SNPRINTF();
|
||||
|
||||
if( ( ret = x509_info_subject_alt_name( &p, &n,
|
||||
@ -1350,7 +1351,7 @@ int x509_crt_info( char *buf, size_t size, const char *prefix,
|
||||
|
||||
if( crt->ext_types & EXT_NS_CERT_TYPE )
|
||||
{
|
||||
ret = snprintf( p, n, "\n%scert. type : ", prefix );
|
||||
ret = polarssl_snprintf( p, n, "\n%scert. type : ", prefix );
|
||||
SAFE_SNPRINTF();
|
||||
|
||||
if( ( ret = x509_info_cert_type( &p, &n, crt->ns_cert_type ) ) != 0 )
|
||||
@ -1359,7 +1360,7 @@ int x509_crt_info( char *buf, size_t size, const char *prefix,
|
||||
|
||||
if( crt->ext_types & EXT_KEY_USAGE )
|
||||
{
|
||||
ret = snprintf( p, n, "\n%skey usage : ", prefix );
|
||||
ret = polarssl_snprintf( p, n, "\n%skey usage : ", prefix );
|
||||
SAFE_SNPRINTF();
|
||||
|
||||
if( ( ret = x509_info_key_usage( &p, &n, crt->key_usage ) ) != 0 )
|
||||
@ -1368,7 +1369,7 @@ int x509_crt_info( char *buf, size_t size, const char *prefix,
|
||||
|
||||
if( crt->ext_types & EXT_EXTENDED_KEY_USAGE )
|
||||
{
|
||||
ret = snprintf( p, n, "\n%sext key usage : ", prefix );
|
||||
ret = polarssl_snprintf( p, n, "\n%sext key usage : ", prefix );
|
||||
SAFE_SNPRINTF();
|
||||
|
||||
if( ( ret = x509_info_ext_key_usage( &p, &n,
|
||||
@ -1376,7 +1377,7 @@ int x509_crt_info( char *buf, size_t size, const char *prefix,
|
||||
return( ret );
|
||||
}
|
||||
|
||||
ret = snprintf( p, n, "\n" );
|
||||
ret = polarssl_snprintf( p, n, "\n" );
|
||||
SAFE_SNPRINTF();
|
||||
|
||||
return( (int) ( size - n ) );
|
||||
|
@ -51,8 +51,9 @@
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#define polarssl_malloc malloc
|
||||
#define polarssl_free free
|
||||
#define polarssl_malloc malloc
|
||||
#define polarssl_snprintf snprintf
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_FS_IO) || defined(EFIX64) || defined(EFI32)
|
||||
@ -388,16 +389,16 @@ int x509_csr_info( char *buf, size_t size, const char *prefix,
|
||||
p = buf;
|
||||
n = size;
|
||||
|
||||
ret = snprintf( p, n, "%sCSR version : %d",
|
||||
ret = polarssl_snprintf( p, n, "%sCSR version : %d",
|
||||
prefix, csr->version );
|
||||
SAFE_SNPRINTF();
|
||||
|
||||
ret = snprintf( p, n, "\n%ssubject name : ", prefix );
|
||||
ret = polarssl_snprintf( p, n, "\n%ssubject name : ", prefix );
|
||||
SAFE_SNPRINTF();
|
||||
ret = x509_dn_gets( p, n, &csr->subject );
|
||||
SAFE_SNPRINTF();
|
||||
|
||||
ret = snprintf( p, n, "\n%ssigned using : ", prefix );
|
||||
ret = polarssl_snprintf( p, n, "\n%ssigned using : ", prefix );
|
||||
SAFE_SNPRINTF();
|
||||
|
||||
ret = x509_sig_alg_gets( p, n, &csr->sig_oid, csr->sig_pk, csr->sig_md,
|
||||
@ -410,7 +411,7 @@ int x509_csr_info( char *buf, size_t size, const char *prefix,
|
||||
return( ret );
|
||||
}
|
||||
|
||||
ret = snprintf( p, n, "\n%s%-" BC "s: %d bits\n", prefix, key_size_str,
|
||||
ret = polarssl_snprintf( p, n, "\n%s%-" BC "s: %d bits\n", prefix, key_size_str,
|
||||
(int) pk_get_size( &csr->pk ) );
|
||||
SAFE_SNPRINTF();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user