mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-27 00:05:44 +01:00
Merge remote-tracking branch 'public/pr/1800' into mbedtls-2.7
This commit is contained in:
commit
1bb41e5d04
@ -109,7 +109,7 @@ int main( int argc, char *argv[] )
|
|||||||
{
|
{
|
||||||
usage:
|
usage:
|
||||||
mbedtls_printf( USAGE );
|
mbedtls_printf( USAGE );
|
||||||
goto exit;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
opt.mode = DFL_MODE;
|
opt.mode = DFL_MODE;
|
||||||
@ -159,13 +159,13 @@ int main( int argc, char *argv[] )
|
|||||||
if( ( f = fopen( opt.password_file, "rb" ) ) == NULL )
|
if( ( f = fopen( opt.password_file, "rb" ) ) == NULL )
|
||||||
{
|
{
|
||||||
mbedtls_printf( " failed\n ! fopen returned NULL\n" );
|
mbedtls_printf( " failed\n ! fopen returned NULL\n" );
|
||||||
goto exit;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if( fgets( buf, sizeof(buf), f ) == NULL )
|
if( fgets( buf, sizeof(buf), f ) == NULL )
|
||||||
{
|
{
|
||||||
fclose( f );
|
fclose( f );
|
||||||
mbedtls_printf( "Error: fgets() failed to retrieve password\n" );
|
mbedtls_printf( "Error: fgets() failed to retrieve password\n" );
|
||||||
goto exit;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
fclose( f );
|
fclose( f );
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ int main( int argc, char *argv[] )
|
|||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
{
|
{
|
||||||
mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile returned -0x%04x\n", -ret );
|
mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile returned -0x%04x\n", -ret );
|
||||||
goto exit;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
mbedtls_printf( " ok\n" );
|
mbedtls_printf( " ok\n" );
|
||||||
@ -204,17 +204,17 @@ int main( int argc, char *argv[] )
|
|||||||
( ret = mbedtls_rsa_export_crt( rsa, &DP, &DQ, &QP ) ) != 0 )
|
( ret = mbedtls_rsa_export_crt( rsa, &DP, &DQ, &QP ) ) != 0 )
|
||||||
{
|
{
|
||||||
mbedtls_printf( " failed\n ! could not export RSA parameters\n\n" );
|
mbedtls_printf( " failed\n ! could not export RSA parameters\n\n" );
|
||||||
goto exit;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
mbedtls_mpi_write_file( "N: ", &N, 16, NULL );
|
MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "N: ", &N, 16, NULL ) );
|
||||||
mbedtls_mpi_write_file( "E: ", &E, 16, NULL );
|
MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "E: ", &E, 16, NULL ) );
|
||||||
mbedtls_mpi_write_file( "D: ", &D, 16, NULL );
|
MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "D: ", &D, 16, NULL ) );
|
||||||
mbedtls_mpi_write_file( "P: ", &P, 16, NULL );
|
MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "P: ", &P, 16, NULL ) );
|
||||||
mbedtls_mpi_write_file( "Q: ", &Q, 16, NULL );
|
MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "Q: ", &Q, 16, NULL ) );
|
||||||
mbedtls_mpi_write_file( "DP: ", &DP, 16, NULL );
|
MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "DP: ", &DP, 16, NULL ) );
|
||||||
mbedtls_mpi_write_file( "DQ: ", &DQ, 16, NULL );
|
MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "DQ: ", &DQ, 16, NULL ) );
|
||||||
mbedtls_mpi_write_file( "QP: ", &QP, 16, NULL );
|
MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "QP: ", &QP, 16, NULL ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
@ -222,16 +222,16 @@ int main( int argc, char *argv[] )
|
|||||||
if( mbedtls_pk_get_type( &pk ) == MBEDTLS_PK_ECKEY )
|
if( mbedtls_pk_get_type( &pk ) == MBEDTLS_PK_ECKEY )
|
||||||
{
|
{
|
||||||
mbedtls_ecp_keypair *ecp = mbedtls_pk_ec( pk );
|
mbedtls_ecp_keypair *ecp = mbedtls_pk_ec( pk );
|
||||||
mbedtls_mpi_write_file( "Q(X): ", &ecp->Q.X, 16, NULL );
|
MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "Q(X): ", &ecp->Q.X, 16, NULL ) );
|
||||||
mbedtls_mpi_write_file( "Q(Y): ", &ecp->Q.Y, 16, NULL );
|
MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "Q(Y): ", &ecp->Q.Y, 16, NULL ) );
|
||||||
mbedtls_mpi_write_file( "Q(Z): ", &ecp->Q.Z, 16, NULL );
|
MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "Q(Z): ", &ecp->Q.Z, 16, NULL ) );
|
||||||
mbedtls_mpi_write_file( "D : ", &ecp->d , 16, NULL );
|
MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "D : ", &ecp->d , 16, NULL ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
mbedtls_printf("Do not know how to print key information for this type\n" );
|
mbedtls_printf("Do not know how to print key information for this type\n" );
|
||||||
goto exit;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( opt.mode == MODE_PUBLIC )
|
else if( opt.mode == MODE_PUBLIC )
|
||||||
@ -247,7 +247,7 @@ int main( int argc, char *argv[] )
|
|||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
{
|
{
|
||||||
mbedtls_printf( " failed\n ! mbedtls_pk_parse_public_keyfile returned -0x%04x\n", -ret );
|
mbedtls_printf( " failed\n ! mbedtls_pk_parse_public_keyfile returned -0x%04x\n", -ret );
|
||||||
goto exit;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
mbedtls_printf( " ok\n" );
|
mbedtls_printf( " ok\n" );
|
||||||
@ -262,10 +262,10 @@ int main( int argc, char *argv[] )
|
|||||||
NULL, &E ) ) != 0 )
|
NULL, &E ) ) != 0 )
|
||||||
{
|
{
|
||||||
mbedtls_printf( " failed\n ! could not export RSA parameters\n\n" );
|
mbedtls_printf( " failed\n ! could not export RSA parameters\n\n" );
|
||||||
goto exit;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
mbedtls_mpi_write_file( "N: ", &N, 16, NULL );
|
MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "N: ", &N, 16, NULL ) );
|
||||||
mbedtls_mpi_write_file( "E: ", &E, 16, NULL );
|
MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "E: ", &E, 16, NULL ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
@ -273,15 +273,15 @@ int main( int argc, char *argv[] )
|
|||||||
if( mbedtls_pk_get_type( &pk ) == MBEDTLS_PK_ECKEY )
|
if( mbedtls_pk_get_type( &pk ) == MBEDTLS_PK_ECKEY )
|
||||||
{
|
{
|
||||||
mbedtls_ecp_keypair *ecp = mbedtls_pk_ec( pk );
|
mbedtls_ecp_keypair *ecp = mbedtls_pk_ec( pk );
|
||||||
mbedtls_mpi_write_file( "Q(X): ", &ecp->Q.X, 16, NULL );
|
MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "Q(X): ", &ecp->Q.X, 16, NULL ) );
|
||||||
mbedtls_mpi_write_file( "Q(Y): ", &ecp->Q.Y, 16, NULL );
|
MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "Q(Y): ", &ecp->Q.Y, 16, NULL ) );
|
||||||
mbedtls_mpi_write_file( "Q(Z): ", &ecp->Q.Z, 16, NULL );
|
MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "Q(Z): ", &ecp->Q.Z, 16, NULL ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
mbedtls_printf("Do not know how to print key information for this type\n" );
|
mbedtls_printf("Do not know how to print key information for this type\n" );
|
||||||
goto exit;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -289,12 +289,12 @@ int main( int argc, char *argv[] )
|
|||||||
|
|
||||||
exit_code = MBEDTLS_EXIT_SUCCESS;
|
exit_code = MBEDTLS_EXIT_SUCCESS;
|
||||||
|
|
||||||
exit:
|
cleanup:
|
||||||
|
|
||||||
#if defined(MBEDTLS_ERROR_C)
|
#if defined(MBEDTLS_ERROR_C)
|
||||||
if( exit_code != MBEDTLS_EXIT_SUCCESS )
|
if( exit_code != MBEDTLS_EXIT_SUCCESS )
|
||||||
{
|
{
|
||||||
mbedtls_strerror( ret, buf, sizeof(buf) );
|
mbedtls_strerror( ret, buf, sizeof( buf ) );
|
||||||
mbedtls_printf( " ! Last error was: %s\n", buf );
|
mbedtls_printf( " ! Last error was: %s\n", buf );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user