mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-28 19:21:08 +00:00
Replace some constant values with sizeof
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
This commit is contained in:
parent
e2b772d1b6
commit
2ee7bbd10a
@ -262,7 +262,7 @@ int main( int argc, char *argv[] )
|
|||||||
mbedtls_x509_csr_init( &csr );
|
mbedtls_x509_csr_init( &csr );
|
||||||
#endif
|
#endif
|
||||||
mbedtls_x509_crt_init( &issuer_crt );
|
mbedtls_x509_crt_init( &issuer_crt );
|
||||||
memset( buf, 0, 1024 );
|
memset( buf, 0, sizeof(buf) );
|
||||||
|
|
||||||
if( argc == 0 )
|
if( argc == 0 )
|
||||||
{
|
{
|
||||||
@ -532,7 +532,7 @@ int main( int argc, char *argv[] )
|
|||||||
(const unsigned char *) pers,
|
(const unsigned char *) pers,
|
||||||
strlen( pers ) ) ) != 0 )
|
strlen( pers ) ) ) != 0 )
|
||||||
{
|
{
|
||||||
mbedtls_strerror( ret, buf, 1024 );
|
mbedtls_strerror( ret, buf, sizeof(buf) );
|
||||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d - %s\n",
|
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d - %s\n",
|
||||||
ret, buf );
|
ret, buf );
|
||||||
goto exit;
|
goto exit;
|
||||||
@ -547,7 +547,7 @@ int main( int argc, char *argv[] )
|
|||||||
|
|
||||||
if( ( ret = mbedtls_mpi_read_string( &serial, 10, opt.serial ) ) != 0 )
|
if( ( ret = mbedtls_mpi_read_string( &serial, 10, opt.serial ) ) != 0 )
|
||||||
{
|
{
|
||||||
mbedtls_strerror( ret, buf, 1024 );
|
mbedtls_strerror( ret, buf, sizeof(buf) );
|
||||||
mbedtls_printf( " failed\n ! mbedtls_mpi_read_string "
|
mbedtls_printf( " failed\n ! mbedtls_mpi_read_string "
|
||||||
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
|
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
|
||||||
goto exit;
|
goto exit;
|
||||||
@ -567,7 +567,7 @@ int main( int argc, char *argv[] )
|
|||||||
|
|
||||||
if( ( ret = mbedtls_x509_crt_parse_file( &issuer_crt, opt.issuer_crt ) ) != 0 )
|
if( ( ret = mbedtls_x509_crt_parse_file( &issuer_crt, opt.issuer_crt ) ) != 0 )
|
||||||
{
|
{
|
||||||
mbedtls_strerror( ret, buf, 1024 );
|
mbedtls_strerror( ret, buf, sizeof(buf) );
|
||||||
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse_file "
|
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse_file "
|
||||||
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
|
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
|
||||||
goto exit;
|
goto exit;
|
||||||
@ -577,7 +577,7 @@ int main( int argc, char *argv[] )
|
|||||||
&issuer_crt.subject );
|
&issuer_crt.subject );
|
||||||
if( ret < 0 )
|
if( ret < 0 )
|
||||||
{
|
{
|
||||||
mbedtls_strerror( ret, buf, 1024 );
|
mbedtls_strerror( ret, buf, sizeof(buf) );
|
||||||
mbedtls_printf( " failed\n ! mbedtls_x509_dn_gets "
|
mbedtls_printf( " failed\n ! mbedtls_x509_dn_gets "
|
||||||
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
|
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
|
||||||
goto exit;
|
goto exit;
|
||||||
@ -601,7 +601,7 @@ int main( int argc, char *argv[] )
|
|||||||
|
|
||||||
if( ( ret = mbedtls_x509_csr_parse_file( &csr, opt.request_file ) ) != 0 )
|
if( ( ret = mbedtls_x509_csr_parse_file( &csr, opt.request_file ) ) != 0 )
|
||||||
{
|
{
|
||||||
mbedtls_strerror( ret, buf, 1024 );
|
mbedtls_strerror( ret, buf, sizeof(buf) );
|
||||||
mbedtls_printf( " failed\n ! mbedtls_x509_csr_parse_file "
|
mbedtls_printf( " failed\n ! mbedtls_x509_csr_parse_file "
|
||||||
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
|
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
|
||||||
goto exit;
|
goto exit;
|
||||||
@ -611,7 +611,7 @@ int main( int argc, char *argv[] )
|
|||||||
&csr.subject );
|
&csr.subject );
|
||||||
if( ret < 0 )
|
if( ret < 0 )
|
||||||
{
|
{
|
||||||
mbedtls_strerror( ret, buf, 1024 );
|
mbedtls_strerror( ret, buf, sizeof(buf) );
|
||||||
mbedtls_printf( " failed\n ! mbedtls_x509_dn_gets "
|
mbedtls_printf( " failed\n ! mbedtls_x509_dn_gets "
|
||||||
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
|
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
|
||||||
goto exit;
|
goto exit;
|
||||||
@ -636,7 +636,7 @@ int main( int argc, char *argv[] )
|
|||||||
opt.subject_pwd, mbedtls_ctr_drbg_random, &ctr_drbg );
|
opt.subject_pwd, mbedtls_ctr_drbg_random, &ctr_drbg );
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
{
|
{
|
||||||
mbedtls_strerror( ret, buf, 1024 );
|
mbedtls_strerror( ret, buf, sizeof(buf) );
|
||||||
mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile "
|
mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile "
|
||||||
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
|
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
|
||||||
goto exit;
|
goto exit;
|
||||||
@ -652,7 +652,7 @@ int main( int argc, char *argv[] )
|
|||||||
opt.issuer_pwd, mbedtls_ctr_drbg_random, &ctr_drbg );
|
opt.issuer_pwd, mbedtls_ctr_drbg_random, &ctr_drbg );
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
{
|
{
|
||||||
mbedtls_strerror( ret, buf, 1024 );
|
mbedtls_strerror( ret, buf, sizeof(buf) );
|
||||||
mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile "
|
mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile "
|
||||||
"returned -x%02x - %s\n\n", (unsigned int) -ret, buf );
|
"returned -x%02x - %s\n\n", (unsigned int) -ret, buf );
|
||||||
goto exit;
|
goto exit;
|
||||||
@ -687,7 +687,7 @@ int main( int argc, char *argv[] )
|
|||||||
*/
|
*/
|
||||||
if( ( ret = mbedtls_x509write_crt_set_subject_name( &crt, opt.subject_name ) ) != 0 )
|
if( ( ret = mbedtls_x509write_crt_set_subject_name( &crt, opt.subject_name ) ) != 0 )
|
||||||
{
|
{
|
||||||
mbedtls_strerror( ret, buf, 1024 );
|
mbedtls_strerror( ret, buf, sizeof(buf) );
|
||||||
mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_subject_name "
|
mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_subject_name "
|
||||||
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
|
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
|
||||||
goto exit;
|
goto exit;
|
||||||
@ -695,7 +695,7 @@ int main( int argc, char *argv[] )
|
|||||||
|
|
||||||
if( ( ret = mbedtls_x509write_crt_set_issuer_name( &crt, opt.issuer_name ) ) != 0 )
|
if( ( ret = mbedtls_x509write_crt_set_issuer_name( &crt, opt.issuer_name ) ) != 0 )
|
||||||
{
|
{
|
||||||
mbedtls_strerror( ret, buf, 1024 );
|
mbedtls_strerror( ret, buf, sizeof(buf) );
|
||||||
mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_issuer_name "
|
mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_issuer_name "
|
||||||
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
|
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
|
||||||
goto exit;
|
goto exit;
|
||||||
@ -710,7 +710,7 @@ int main( int argc, char *argv[] )
|
|||||||
ret = mbedtls_x509write_crt_set_serial( &crt, &serial );
|
ret = mbedtls_x509write_crt_set_serial( &crt, &serial );
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
{
|
{
|
||||||
mbedtls_strerror( ret, buf, 1024 );
|
mbedtls_strerror( ret, buf, sizeof(buf) );
|
||||||
mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_serial "
|
mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_serial "
|
||||||
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
|
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
|
||||||
goto exit;
|
goto exit;
|
||||||
@ -719,7 +719,7 @@ int main( int argc, char *argv[] )
|
|||||||
ret = mbedtls_x509write_crt_set_validity( &crt, opt.not_before, opt.not_after );
|
ret = mbedtls_x509write_crt_set_validity( &crt, opt.not_before, opt.not_after );
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
{
|
{
|
||||||
mbedtls_strerror( ret, buf, 1024 );
|
mbedtls_strerror( ret, buf, sizeof(buf) );
|
||||||
mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_validity "
|
mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_validity "
|
||||||
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
|
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
|
||||||
goto exit;
|
goto exit;
|
||||||
@ -737,7 +737,7 @@ int main( int argc, char *argv[] )
|
|||||||
opt.max_pathlen );
|
opt.max_pathlen );
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
{
|
{
|
||||||
mbedtls_strerror( ret, buf, 1024 );
|
mbedtls_strerror( ret, buf, sizeof(buf) );
|
||||||
mbedtls_printf( " failed\n ! x509write_crt_set_basic_contraints "
|
mbedtls_printf( " failed\n ! x509write_crt_set_basic_contraints "
|
||||||
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
|
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
|
||||||
goto exit;
|
goto exit;
|
||||||
@ -758,7 +758,7 @@ int main( int argc, char *argv[] )
|
|||||||
ret = mbedtls_x509write_crt_set_subject_key_identifier( &crt );
|
ret = mbedtls_x509write_crt_set_subject_key_identifier( &crt );
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
{
|
{
|
||||||
mbedtls_strerror( ret, buf, 1024 );
|
mbedtls_strerror( ret, buf, sizeof(buf) );
|
||||||
mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_subject"
|
mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_subject"
|
||||||
"_key_identifier returned -0x%04x - %s\n\n",
|
"_key_identifier returned -0x%04x - %s\n\n",
|
||||||
(unsigned int) -ret, buf );
|
(unsigned int) -ret, buf );
|
||||||
@ -777,7 +777,7 @@ int main( int argc, char *argv[] )
|
|||||||
ret = mbedtls_x509write_crt_set_authority_key_identifier( &crt );
|
ret = mbedtls_x509write_crt_set_authority_key_identifier( &crt );
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
{
|
{
|
||||||
mbedtls_strerror( ret, buf, 1024 );
|
mbedtls_strerror( ret, buf, sizeof(buf) );
|
||||||
mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_authority_"
|
mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_authority_"
|
||||||
"key_identifier returned -0x%04x - %s\n\n",
|
"key_identifier returned -0x%04x - %s\n\n",
|
||||||
(unsigned int) -ret, buf );
|
(unsigned int) -ret, buf );
|
||||||
@ -797,7 +797,7 @@ int main( int argc, char *argv[] )
|
|||||||
ret = mbedtls_x509write_crt_set_key_usage( &crt, opt.key_usage );
|
ret = mbedtls_x509write_crt_set_key_usage( &crt, opt.key_usage );
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
{
|
{
|
||||||
mbedtls_strerror( ret, buf, 1024 );
|
mbedtls_strerror( ret, buf, sizeof(buf) );
|
||||||
mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_key_usage "
|
mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_key_usage "
|
||||||
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
|
"returned -0x%04x - %s\n\n", (unsigned int) -ret, buf );
|
||||||
goto exit;
|
goto exit;
|
||||||
@ -814,7 +814,7 @@ int main( int argc, char *argv[] )
|
|||||||
ret = mbedtls_x509write_crt_set_ext_key_usage( &crt, opt.ext_key_usage );
|
ret = mbedtls_x509write_crt_set_ext_key_usage( &crt, opt.ext_key_usage );
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
{
|
{
|
||||||
mbedtls_strerror( ret, buf, 1024 );
|
mbedtls_strerror( ret, buf, sizeof(buf) );
|
||||||
mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_ext_key_usage returned -0x%02x - %s\n\n", (unsigned int) -ret, buf );
|
mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_ext_key_usage returned -0x%02x - %s\n\n", (unsigned int) -ret, buf );
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
@ -849,7 +849,7 @@ int main( int argc, char *argv[] )
|
|||||||
if( ( ret = write_certificate( &crt, opt.output_file,
|
if( ( ret = write_certificate( &crt, opt.output_file,
|
||||||
mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 )
|
mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 )
|
||||||
{
|
{
|
||||||
mbedtls_strerror( ret, buf, 1024 );
|
mbedtls_strerror( ret, buf, sizeof(buf) );
|
||||||
mbedtls_printf( " failed\n ! write_certificate -0x%04x - %s\n\n",
|
mbedtls_printf( " failed\n ! write_certificate -0x%04x - %s\n\n",
|
||||||
(unsigned int) -ret, buf );
|
(unsigned int) -ret, buf );
|
||||||
goto exit;
|
goto exit;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user