mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2025-12-24 08:16:33 +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,23 +20,23 @@
|
|||
* 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_fprintf fprintf
|
||||
#define polarssl_printf printf
|
||||
#define mbedtls_fprintf fprintf
|
||||
#define mbedtls_printf printf
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_BIGNUM_C) && defined(POLARSSL_PK_PARSE_C) && \
|
||||
defined(POLARSSL_ENTROPY_C) && defined(POLARSSL_FS_IO) && \
|
||||
defined(POLARSSL_CTR_DRBG_C)
|
||||
#if defined(MBEDTLS_BIGNUM_C) && defined(MBEDTLS_PK_PARSE_C) && \
|
||||
defined(MBEDTLS_ENTROPY_C) && defined(MBEDTLS_FS_IO) && \
|
||||
defined(MBEDTLS_CTR_DRBG_C)
|
||||
#include "mbedtls/error.h"
|
||||
#include "mbedtls/pk.h"
|
||||
#include "mbedtls/entropy.h"
|
||||
|
|
@ -46,14 +46,14 @@
|
|||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#if !defined(POLARSSL_BIGNUM_C) || !defined(POLARSSL_PK_PARSE_C) || \
|
||||
!defined(POLARSSL_ENTROPY_C) || !defined(POLARSSL_FS_IO) || \
|
||||
!defined(POLARSSL_CTR_DRBG_C)
|
||||
#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_PK_PARSE_C) || \
|
||||
!defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_FS_IO) || \
|
||||
!defined(MBEDTLS_CTR_DRBG_C)
|
||||
int main( void )
|
||||
{
|
||||
polarssl_printf("POLARSSL_BIGNUM_C and/or POLARSSL_PK_PARSE_C and/or "
|
||||
"POLARSSL_ENTROPY_C and/or POLARSSL_FS_IO and/or "
|
||||
"POLARSSL_CTR_DRBG_C not defined.\n");
|
||||
mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_PK_PARSE_C and/or "
|
||||
"MBEDTLS_ENTROPY_C and/or MBEDTLS_FS_IO and/or "
|
||||
"MBEDTLS_CTR_DRBG_C not defined.\n");
|
||||
return( 0 );
|
||||
}
|
||||
#else
|
||||
|
|
@ -62,52 +62,52 @@ int main( int argc, char *argv[] )
|
|||
FILE *f;
|
||||
int ret;
|
||||
size_t i, olen = 0;
|
||||
pk_context pk;
|
||||
entropy_context entropy;
|
||||
ctr_drbg_context ctr_drbg;
|
||||
mbedtls_pk_context pk;
|
||||
mbedtls_entropy_context entropy;
|
||||
mbedtls_ctr_drbg_context ctr_drbg;
|
||||
unsigned char input[1024];
|
||||
unsigned char buf[512];
|
||||
const char *pers = "pk_encrypt";
|
||||
const char *pers = "mbedtls_pk_encrypt";
|
||||
|
||||
ret = 1;
|
||||
|
||||
if( argc != 3 )
|
||||
{
|
||||
polarssl_printf( "usage: pk_encrypt <key_file> <string of max 100 characters>\n" );
|
||||
mbedtls_printf( "usage: mbedtls_pk_encrypt <key_file> <string of max 100 characters>\n" );
|
||||
|
||||
#if defined(_WIN32)
|
||||
polarssl_printf( "\n" );
|
||||
mbedtls_printf( "\n" );
|
||||
#endif
|
||||
|
||||
goto exit;
|
||||
}
|
||||
|
||||
polarssl_printf( "\n . Seeding the random number generator..." );
|
||||
mbedtls_printf( "\n . Seeding the random number generator..." );
|
||||
fflush( stdout );
|
||||
|
||||
entropy_init( &entropy );
|
||||
if( ( ret = ctr_drbg_init( &ctr_drbg, entropy_func, &entropy,
|
||||
mbedtls_entropy_init( &entropy );
|
||||
if( ( ret = mbedtls_ctr_drbg_init( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
(const unsigned char *) pers,
|
||||
strlen( pers ) ) ) != 0 )
|
||||
{
|
||||
polarssl_printf( " failed\n ! ctr_drbg_init returned -0x%04x\n", -ret );
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_init returned -0x%04x\n", -ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
polarssl_printf( "\n . Reading public key from '%s'", argv[1] );
|
||||
mbedtls_printf( "\n . Reading public key from '%s'", argv[1] );
|
||||
fflush( stdout );
|
||||
|
||||
pk_init( &pk );
|
||||
mbedtls_pk_init( &pk );
|
||||
|
||||
if( ( ret = pk_parse_public_keyfile( &pk, argv[1] ) ) != 0 )
|
||||
if( ( ret = mbedtls_pk_parse_public_keyfile( &pk, argv[1] ) ) != 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;
|
||||
}
|
||||
|
||||
if( strlen( argv[2] ) > 100 )
|
||||
{
|
||||
polarssl_printf( " Input data larger than 100 characters.\n\n" );
|
||||
mbedtls_printf( " Input data larger than 100 characters.\n\n" );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
|
@ -116,14 +116,14 @@ int main( int argc, char *argv[] )
|
|||
/*
|
||||
* Calculate the RSA encryption of the hash.
|
||||
*/
|
||||
polarssl_printf( "\n . Generating the encrypted value" );
|
||||
mbedtls_printf( "\n . Generating the encrypted value" );
|
||||
fflush( stdout );
|
||||
|
||||
if( ( ret = pk_encrypt( &pk, input, strlen( argv[2] ),
|
||||
if( ( ret = mbedtls_pk_encrypt( &pk, input, strlen( argv[2] ),
|
||||
buf, &olen, sizeof(buf),
|
||||
ctr_drbg_random, &ctr_drbg ) ) != 0 )
|
||||
mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 )
|
||||
{
|
||||
polarssl_printf( " failed\n ! pk_encrypt returned -0x%04x\n", -ret );
|
||||
mbedtls_printf( " failed\n ! mbedtls_pk_encrypt returned -0x%04x\n", -ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
|
@ -133,33 +133,33 @@ int main( int argc, char *argv[] )
|
|||
if( ( f = fopen( "result-enc.txt", "wb+" ) ) == NULL )
|
||||
{
|
||||
ret = 1;
|
||||
polarssl_printf( " failed\n ! Could not create %s\n\n", "result-enc.txt" );
|
||||
mbedtls_printf( " failed\n ! Could not create %s\n\n", "result-enc.txt" );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
for( i = 0; i < olen; i++ )
|
||||
polarssl_fprintf( f, "%02X%s", buf[i],
|
||||
mbedtls_fprintf( f, "%02X%s", buf[i],
|
||||
( i + 1 ) % 16 == 0 ? "\r\n" : " " );
|
||||
|
||||
fclose( f );
|
||||
|
||||
polarssl_printf( "\n . Done (created \"%s\")\n\n", "result-enc.txt" );
|
||||
mbedtls_printf( "\n . Done (created \"%s\")\n\n", "result-enc.txt" );
|
||||
|
||||
exit:
|
||||
ctr_drbg_free( &ctr_drbg );
|
||||
entropy_free( &entropy );
|
||||
mbedtls_ctr_drbg_free( &ctr_drbg );
|
||||
mbedtls_entropy_free( &entropy );
|
||||
|
||||
#if defined(POLARSSL_ERROR_C)
|
||||
polarssl_strerror( ret, (char *) buf, sizeof(buf) );
|
||||
polarssl_printf( " ! Last error was: %s\n", buf );
|
||||
#if defined(MBEDTLS_ERROR_C)
|
||||
mbedtls_strerror( ret, (char *) buf, sizeof(buf) );
|
||||
mbedtls_printf( " ! Last error was: %s\n", buf );
|
||||
#endif
|
||||
|
||||
#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_ENTROPY_C &&
|
||||
POLARSSL_FS_IO && POLARSSL_CTR_DRBG_C */
|
||||
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_PK_PARSE_C && MBEDTLS_ENTROPY_C &&
|
||||
MBEDTLS_FS_IO && MBEDTLS_CTR_DRBG_C */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue