mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2026-01-05 22:19:11 +01:00
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
|
|
@ -20,21 +20,21 @@
|
|||
* 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_PLATFORM_C)
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
#include "mbedtls/platform.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define polarssl_printf printf
|
||||
#define mbedtls_printf printf
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_BIGNUM_C) && \
|
||||
defined(POLARSSL_PK_PARSE_C) && defined(POLARSSL_FS_IO)
|
||||
#if defined(MBEDTLS_BIGNUM_C) && \
|
||||
defined(MBEDTLS_PK_PARSE_C) && defined(MBEDTLS_FS_IO)
|
||||
#include "mbedtls/error.h"
|
||||
#include "mbedtls/rsa.h"
|
||||
#include "mbedtls/x509.h"
|
||||
|
|
@ -62,12 +62,12 @@
|
|||
"\n"
|
||||
|
||||
|
||||
#if !defined(POLARSSL_BIGNUM_C) || \
|
||||
!defined(POLARSSL_PK_PARSE_C) || !defined(POLARSSL_FS_IO)
|
||||
#if !defined(MBEDTLS_BIGNUM_C) || \
|
||||
!defined(MBEDTLS_PK_PARSE_C) || !defined(MBEDTLS_FS_IO)
|
||||
int main( void )
|
||||
{
|
||||
polarssl_printf("POLARSSL_BIGNUM_C and/or "
|
||||
"POLARSSL_PK_PARSE_C and/or POLARSSL_FS_IO not defined.\n");
|
||||
mbedtls_printf("MBEDTLS_BIGNUM_C and/or "
|
||||
"MBEDTLS_PK_PARSE_C and/or MBEDTLS_FS_IO not defined.\n");
|
||||
return( 0 );
|
||||
}
|
||||
#else
|
||||
|
|
@ -85,7 +85,7 @@ struct options
|
|||
int main( int argc, char *argv[] )
|
||||
{
|
||||
int ret = 0;
|
||||
pk_context pk;
|
||||
mbedtls_pk_context pk;
|
||||
char buf[1024];
|
||||
int i;
|
||||
char *p, *q;
|
||||
|
|
@ -93,13 +93,13 @@ int main( int argc, char *argv[] )
|
|||
/*
|
||||
* Set to sane values
|
||||
*/
|
||||
pk_init( &pk );
|
||||
mbedtls_pk_init( &pk );
|
||||
memset( buf, 0, sizeof(buf) );
|
||||
|
||||
if( argc == 0 )
|
||||
{
|
||||
usage:
|
||||
polarssl_printf( USAGE );
|
||||
mbedtls_printf( USAGE );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
|
@ -138,7 +138,7 @@ int main( int argc, char *argv[] )
|
|||
{
|
||||
if( strlen( opt.password ) && strlen( opt.password_file ) )
|
||||
{
|
||||
polarssl_printf( "Error: cannot have both password and password_file\n" );
|
||||
mbedtls_printf( "Error: cannot have both password and password_file\n" );
|
||||
goto usage;
|
||||
}
|
||||
|
||||
|
|
@ -146,16 +146,16 @@ int main( int argc, char *argv[] )
|
|||
{
|
||||
FILE *f;
|
||||
|
||||
polarssl_printf( "\n . Loading the password file ..." );
|
||||
mbedtls_printf( "\n . Loading the password file ..." );
|
||||
if( ( f = fopen( opt.password_file, "rb" ) ) == NULL )
|
||||
{
|
||||
polarssl_printf( " failed\n ! fopen returned NULL\n" );
|
||||
mbedtls_printf( " failed\n ! fopen returned NULL\n" );
|
||||
goto exit;
|
||||
}
|
||||
if( fgets( buf, sizeof(buf), f ) == NULL )
|
||||
{
|
||||
fclose( f );
|
||||
polarssl_printf( "Error: fgets() failed to retrieve password\n" );
|
||||
mbedtls_printf( "Error: fgets() failed to retrieve password\n" );
|
||||
goto exit;
|
||||
}
|
||||
fclose( f );
|
||||
|
|
@ -169,51 +169,51 @@ int main( int argc, char *argv[] )
|
|||
/*
|
||||
* 1.1. Load the key
|
||||
*/
|
||||
polarssl_printf( "\n . Loading the private key ..." );
|
||||
mbedtls_printf( "\n . Loading the private key ..." );
|
||||
fflush( stdout );
|
||||
|
||||
ret = pk_parse_keyfile( &pk, opt.filename, opt.password );
|
||||
ret = mbedtls_pk_parse_keyfile( &pk, opt.filename, opt.password );
|
||||
|
||||
if( ret != 0 )
|
||||
{
|
||||
polarssl_printf( " failed\n ! pk_parse_keyfile returned -0x%04x\n", -ret );
|
||||
mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile returned -0x%04x\n", -ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
polarssl_printf( " ok\n" );
|
||||
mbedtls_printf( " ok\n" );
|
||||
|
||||
/*
|
||||
* 1.2 Print the key
|
||||
*/
|
||||
polarssl_printf( " . Key information ...\n" );
|
||||
#if defined(POLARSSL_RSA_C)
|
||||
if( pk_get_type( &pk ) == POLARSSL_PK_RSA )
|
||||
mbedtls_printf( " . Key information ...\n" );
|
||||
#if defined(MBEDTLS_RSA_C)
|
||||
if( mbedtls_pk_get_type( &pk ) == MBEDTLS_PK_RSA )
|
||||
{
|
||||
rsa_context *rsa = pk_rsa( pk );
|
||||
mpi_write_file( "N: ", &rsa->N, 16, NULL );
|
||||
mpi_write_file( "E: ", &rsa->E, 16, NULL );
|
||||
mpi_write_file( "D: ", &rsa->D, 16, NULL );
|
||||
mpi_write_file( "P: ", &rsa->P, 16, NULL );
|
||||
mpi_write_file( "Q: ", &rsa->Q, 16, NULL );
|
||||
mpi_write_file( "DP: ", &rsa->DP, 16, NULL );
|
||||
mpi_write_file( "DQ: ", &rsa->DQ, 16, NULL );
|
||||
mpi_write_file( "QP: ", &rsa->QP, 16, NULL );
|
||||
mbedtls_rsa_context *rsa = mbedtls_pk_rsa( pk );
|
||||
mbedtls_mpi_write_file( "N: ", &rsa->N, 16, NULL );
|
||||
mbedtls_mpi_write_file( "E: ", &rsa->E, 16, NULL );
|
||||
mbedtls_mpi_write_file( "D: ", &rsa->D, 16, NULL );
|
||||
mbedtls_mpi_write_file( "P: ", &rsa->P, 16, NULL );
|
||||
mbedtls_mpi_write_file( "Q: ", &rsa->Q, 16, NULL );
|
||||
mbedtls_mpi_write_file( "DP: ", &rsa->DP, 16, NULL );
|
||||
mbedtls_mpi_write_file( "DQ: ", &rsa->DQ, 16, NULL );
|
||||
mbedtls_mpi_write_file( "QP: ", &rsa->QP, 16, NULL );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#if defined(POLARSSL_ECP_C)
|
||||
if( pk_get_type( &pk ) == POLARSSL_PK_ECKEY )
|
||||
#if defined(MBEDTLS_ECP_C)
|
||||
if( mbedtls_pk_get_type( &pk ) == MBEDTLS_PK_ECKEY )
|
||||
{
|
||||
ecp_keypair *ecp = pk_ec( pk );
|
||||
mpi_write_file( "Q(X): ", &ecp->Q.X, 16, NULL );
|
||||
mpi_write_file( "Q(Y): ", &ecp->Q.Y, 16, NULL );
|
||||
mpi_write_file( "Q(Z): ", &ecp->Q.Z, 16, NULL );
|
||||
mpi_write_file( "D : ", &ecp->d , 16, NULL );
|
||||
mbedtls_ecp_keypair *ecp = mbedtls_pk_ec( pk );
|
||||
mbedtls_mpi_write_file( "Q(X): ", &ecp->Q.X, 16, NULL );
|
||||
mbedtls_mpi_write_file( "Q(Y): ", &ecp->Q.Y, 16, NULL );
|
||||
mbedtls_mpi_write_file( "Q(Z): ", &ecp->Q.Z, 16, NULL );
|
||||
mbedtls_mpi_write_file( "D : ", &ecp->d , 16, NULL );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
polarssl_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;
|
||||
}
|
||||
}
|
||||
|
|
@ -222,41 +222,41 @@ int main( int argc, char *argv[] )
|
|||
/*
|
||||
* 1.1. Load the key
|
||||
*/
|
||||
polarssl_printf( "\n . Loading the public key ..." );
|
||||
mbedtls_printf( "\n . Loading the public key ..." );
|
||||
fflush( stdout );
|
||||
|
||||
ret = pk_parse_public_keyfile( &pk, opt.filename );
|
||||
ret = mbedtls_pk_parse_public_keyfile( &pk, opt.filename );
|
||||
|
||||
if( ret != 0 )
|
||||
{
|
||||
polarssl_printf( " failed\n ! 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;
|
||||
}
|
||||
|
||||
polarssl_printf( " ok\n" );
|
||||
mbedtls_printf( " ok\n" );
|
||||
|
||||
polarssl_printf( " . Key information ...\n" );
|
||||
#if defined(POLARSSL_RSA_C)
|
||||
if( pk_get_type( &pk ) == POLARSSL_PK_RSA )
|
||||
mbedtls_printf( " . Key information ...\n" );
|
||||
#if defined(MBEDTLS_RSA_C)
|
||||
if( mbedtls_pk_get_type( &pk ) == MBEDTLS_PK_RSA )
|
||||
{
|
||||
rsa_context *rsa = pk_rsa( pk );
|
||||
mpi_write_file( "N: ", &rsa->N, 16, NULL );
|
||||
mpi_write_file( "E: ", &rsa->E, 16, NULL );
|
||||
mbedtls_rsa_context *rsa = mbedtls_pk_rsa( pk );
|
||||
mbedtls_mpi_write_file( "N: ", &rsa->N, 16, NULL );
|
||||
mbedtls_mpi_write_file( "E: ", &rsa->E, 16, NULL );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#if defined(POLARSSL_ECP_C)
|
||||
if( pk_get_type( &pk ) == POLARSSL_PK_ECKEY )
|
||||
#if defined(MBEDTLS_ECP_C)
|
||||
if( mbedtls_pk_get_type( &pk ) == MBEDTLS_PK_ECKEY )
|
||||
{
|
||||
ecp_keypair *ecp = pk_ec( pk );
|
||||
mpi_write_file( "Q(X): ", &ecp->Q.X, 16, NULL );
|
||||
mpi_write_file( "Q(Y): ", &ecp->Q.Y, 16, NULL );
|
||||
mpi_write_file( "Q(Z): ", &ecp->Q.Z, 16, NULL );
|
||||
mbedtls_ecp_keypair *ecp = mbedtls_pk_ec( pk );
|
||||
mbedtls_mpi_write_file( "Q(X): ", &ecp->Q.X, 16, NULL );
|
||||
mbedtls_mpi_write_file( "Q(Y): ", &ecp->Q.Y, 16, NULL );
|
||||
mbedtls_mpi_write_file( "Q(Z): ", &ecp->Q.Z, 16, NULL );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
polarssl_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;
|
||||
}
|
||||
}
|
||||
|
|
@ -265,18 +265,18 @@ int main( int argc, char *argv[] )
|
|||
|
||||
exit:
|
||||
|
||||
#if defined(POLARSSL_ERROR_C)
|
||||
polarssl_strerror( ret, buf, sizeof(buf) );
|
||||
polarssl_printf( " ! Last error was: %s\n", buf );
|
||||
#if defined(MBEDTLS_ERROR_C)
|
||||
mbedtls_strerror( ret, buf, sizeof(buf) );
|
||||
mbedtls_printf( " ! Last error was: %s\n", buf );
|
||||
#endif
|
||||
|
||||
pk_free( &pk );
|
||||
mbedtls_pk_free( &pk );
|
||||
|
||||
#if defined(_WIN32)
|
||||
polarssl_printf( " + Press Enter to exit this program.\n" );
|
||||
mbedtls_printf( " + Press Enter to exit this program.\n" );
|
||||
fflush( stdout ); getchar();
|
||||
#endif
|
||||
|
||||
return( ret );
|
||||
}
|
||||
#endif /* POLARSSL_BIGNUM_C && POLARSSL_PK_PARSE_C && POLARSSL_FS_IO */
|
||||
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_PK_PARSE_C && MBEDTLS_FS_IO */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue