Fix error code printing in cert_write

Error codes can consume up to two bytes, but only one was printed so far.
This commit is contained in:
Hanno Becker 2017-09-22 15:39:02 +01:00
parent 38eff43791
commit 7f3652ddf1

View file

@ -470,7 +470,7 @@ int main( int argc, char *argv[] )
{ {
mbedtls_strerror( ret, buf, 1024 ); mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! mbedtls_mpi_read_string " mbedtls_printf( " failed\n ! mbedtls_mpi_read_string "
"returned -0x%02x - %s\n\n", -ret, buf ); "returned -0x%04x - %s\n\n", -ret, buf );
goto exit; goto exit;
} }
@ -490,7 +490,7 @@ int main( int argc, char *argv[] )
{ {
mbedtls_strerror( ret, buf, 1024 ); mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse_file " mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse_file "
"returned -0x%02x - %s\n\n", -ret, buf ); "returned -0x%04x - %s\n\n", -ret, buf );
goto exit; goto exit;
} }
@ -500,7 +500,7 @@ int main( int argc, char *argv[] )
{ {
mbedtls_strerror( ret, buf, 1024 ); mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! mbedtls_x509_dn_gets " mbedtls_printf( " failed\n ! mbedtls_x509_dn_gets "
"returned -0x%02x - %s\n\n", -ret, buf ); "returned -0x%04x - %s\n\n", -ret, buf );
goto exit; goto exit;
} }
@ -524,7 +524,7 @@ int main( int argc, char *argv[] )
{ {
mbedtls_strerror( ret, buf, 1024 ); mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! mbedtls_x509_csr_parse_file " mbedtls_printf( " failed\n ! mbedtls_x509_csr_parse_file "
"returned -0x%02x - %s\n\n", -ret, buf ); "returned -0x%04x - %s\n\n", -ret, buf );
goto exit; goto exit;
} }
@ -534,7 +534,7 @@ int main( int argc, char *argv[] )
{ {
mbedtls_strerror( ret, buf, 1024 ); mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! mbedtls_x509_dn_gets " mbedtls_printf( " failed\n ! mbedtls_x509_dn_gets "
"returned -0x%02x - %s\n\n", -ret, buf ); "returned -0x%04x - %s\n\n", -ret, buf );
goto exit; goto exit;
} }
@ -559,7 +559,7 @@ int main( int argc, char *argv[] )
{ {
mbedtls_strerror( ret, buf, 1024 ); mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile " mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile "
"returned -0x%02x - %s\n\n", -ret, buf ); "returned -0x%04x - %s\n\n", -ret, buf );
goto exit; goto exit;
} }
@ -614,7 +614,7 @@ int main( int argc, char *argv[] )
{ {
mbedtls_strerror( ret, buf, 1024 ); mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_subject_name " mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_subject_name "
"returned -0x%02x - %s\n\n", -ret, buf ); "returned -0x%04x - %s\n\n", -ret, buf );
goto exit; goto exit;
} }
@ -622,7 +622,7 @@ int main( int argc, char *argv[] )
{ {
mbedtls_strerror( ret, buf, 1024 ); mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_issuer_name " mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_issuer_name "
"returned -0x%02x - %s\n\n", -ret, buf ); "returned -0x%04x - %s\n\n", -ret, buf );
goto exit; goto exit;
} }
@ -637,7 +637,7 @@ int main( int argc, char *argv[] )
{ {
mbedtls_strerror( ret, buf, 1024 ); mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_serial " mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_serial "
"returned -0x%02x - %s\n\n", -ret, buf ); "returned -0x%04x - %s\n\n", -ret, buf );
goto exit; goto exit;
} }
@ -646,7 +646,7 @@ int main( int argc, char *argv[] )
{ {
mbedtls_strerror( ret, buf, 1024 ); mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_validity " mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_validity "
"returned -0x%02x - %s\n\n", -ret, buf ); "returned -0x%04x - %s\n\n", -ret, buf );
goto exit; goto exit;
} }
@ -664,7 +664,7 @@ int main( int argc, char *argv[] )
{ {
mbedtls_strerror( ret, buf, 1024 ); mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! x509write_crt_set_basic_contraints " mbedtls_printf( " failed\n ! x509write_crt_set_basic_contraints "
"returned -0x%02x - %s\n\n", -ret, buf ); "returned -0x%04x - %s\n\n", -ret, buf );
goto exit; goto exit;
} }
@ -683,7 +683,7 @@ int main( int argc, char *argv[] )
{ {
mbedtls_strerror( ret, buf, 1024 ); mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_subject" mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_subject"
"_key_identifier returned -0x%02x - %s\n\n", "_key_identifier returned -0x%04x - %s\n\n",
-ret, buf ); -ret, buf );
goto exit; goto exit;
} }
@ -702,7 +702,7 @@ int main( int argc, char *argv[] )
{ {
mbedtls_strerror( ret, buf, 1024 ); mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_authority_" mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_authority_"
"key_identifier returned -0x%02x - %s\n\n", "key_identifier returned -0x%04x - %s\n\n",
-ret, buf ); -ret, buf );
goto exit; goto exit;
} }
@ -722,7 +722,7 @@ int main( int argc, char *argv[] )
{ {
mbedtls_strerror( ret, buf, 1024 ); mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_key_usage " mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_key_usage "
"returned -0x%02x - %s\n\n", -ret, buf ); "returned -0x%04x - %s\n\n", -ret, buf );
goto exit; goto exit;
} }
@ -740,7 +740,7 @@ int main( int argc, char *argv[] )
{ {
mbedtls_strerror( ret, buf, 1024 ); mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_ns_cert_type " mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_ns_cert_type "
"returned -0x%02x - %s\n\n", -ret, buf ); "returned -0x%04x - %s\n\n", -ret, buf );
goto exit; goto exit;
} }
@ -757,7 +757,7 @@ int main( int argc, char *argv[] )
mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 ) mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 )
{ {
mbedtls_strerror( ret, buf, 1024 ); mbedtls_strerror( ret, buf, 1024 );
mbedtls_printf( " failed\n ! write_certificate -0x%02x - %s\n\n", mbedtls_printf( " failed\n ! write_certificate -0x%04x - %s\n\n",
-ret, buf ); -ret, buf );
goto exit; goto exit;
} }