The Great Renaming
A simple execution of tmp/invoke-rename.pl
diff --git a/programs/pkey/rsa_sign.c b/programs/pkey/rsa_sign.c
index 69c7374..0c441bd 100644
--- a/programs/pkey/rsa_sign.c
+++ b/programs/pkey/rsa_sign.c
@@ -20,22 +20,22 @@
* 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_RSA_C) && \
- defined(POLARSSL_SHA256_C) && defined(POLARSSL_FS_IO)
+#if defined(MBEDTLS_BIGNUM_C) && defined(MBEDTLS_RSA_C) && \
+ defined(MBEDTLS_SHA256_C) && defined(MBEDTLS_FS_IO)
#include "mbedtls/rsa.h"
#include "mbedtls/sha1.h"
@@ -43,12 +43,12 @@
#include <string.h>
#endif
-#if !defined(POLARSSL_BIGNUM_C) || !defined(POLARSSL_RSA_C) || \
- !defined(POLARSSL_SHA256_C) || !defined(POLARSSL_FS_IO)
+#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_RSA_C) || \
+ !defined(MBEDTLS_SHA256_C) || !defined(MBEDTLS_FS_IO)
int main( void )
{
- polarssl_printf("POLARSSL_BIGNUM_C and/or POLARSSL_RSA_C and/or "
- "POLARSSL_SHA256_C and/or POLARSSL_FS_IO not defined.\n");
+ mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_RSA_C and/or "
+ "MBEDTLS_SHA256_C and/or MBEDTLS_FS_IO not defined.\n");
return( 0 );
}
#else
@@ -57,58 +57,58 @@
FILE *f;
int ret;
size_t i;
- rsa_context rsa;
+ mbedtls_rsa_context rsa;
unsigned char hash[20];
- unsigned char buf[POLARSSL_MPI_MAX_SIZE];
+ unsigned char buf[MBEDTLS_MPI_MAX_SIZE];
ret = 1;
if( argc != 2 )
{
- polarssl_printf( "usage: rsa_sign <filename>\n" );
+ mbedtls_printf( "usage: rsa_sign <filename>\n" );
#if defined(_WIN32)
- polarssl_printf( "\n" );
+ mbedtls_printf( "\n" );
#endif
goto exit;
}
- polarssl_printf( "\n . Reading private key from rsa_priv.txt" );
+ mbedtls_printf( "\n . Reading private key from rsa_priv.txt" );
fflush( stdout );
if( ( f = fopen( "rsa_priv.txt", "rb" ) ) == NULL )
{
ret = 1;
- polarssl_printf( " failed\n ! Could not open rsa_priv.txt\n" \
+ mbedtls_printf( " failed\n ! Could not open rsa_priv.txt\n" \
" ! Please run rsa_genkey first\n\n" );
goto exit;
}
- rsa_init( &rsa, RSA_PKCS_V15, 0 );
+ mbedtls_rsa_init( &rsa, MBEDTLS_RSA_PKCS_V15, 0 );
- if( ( ret = mpi_read_file( &rsa.N , 16, f ) ) != 0 ||
- ( ret = mpi_read_file( &rsa.E , 16, f ) ) != 0 ||
- ( ret = mpi_read_file( &rsa.D , 16, f ) ) != 0 ||
- ( ret = mpi_read_file( &rsa.P , 16, f ) ) != 0 ||
- ( ret = mpi_read_file( &rsa.Q , 16, f ) ) != 0 ||
- ( ret = mpi_read_file( &rsa.DP, 16, f ) ) != 0 ||
- ( ret = mpi_read_file( &rsa.DQ, 16, f ) ) != 0 ||
- ( ret = mpi_read_file( &rsa.QP, 16, f ) ) != 0 )
+ if( ( ret = mbedtls_mpi_read_file( &rsa.N , 16, f ) ) != 0 ||
+ ( ret = mbedtls_mpi_read_file( &rsa.E , 16, f ) ) != 0 ||
+ ( ret = mbedtls_mpi_read_file( &rsa.D , 16, f ) ) != 0 ||
+ ( ret = mbedtls_mpi_read_file( &rsa.P , 16, f ) ) != 0 ||
+ ( ret = mbedtls_mpi_read_file( &rsa.Q , 16, f ) ) != 0 ||
+ ( ret = mbedtls_mpi_read_file( &rsa.DP, 16, f ) ) != 0 ||
+ ( ret = mbedtls_mpi_read_file( &rsa.DQ, 16, f ) ) != 0 ||
+ ( ret = mbedtls_mpi_read_file( &rsa.QP, 16, f ) ) != 0 )
{
- polarssl_printf( " failed\n ! mpi_read_file returned %d\n\n", ret );
+ mbedtls_printf( " failed\n ! mbedtls_mpi_read_file returned %d\n\n", ret );
goto exit;
}
- rsa.len = ( mpi_msb( &rsa.N ) + 7 ) >> 3;
+ rsa.len = ( mbedtls_mpi_msb( &rsa.N ) + 7 ) >> 3;
fclose( f );
- polarssl_printf( "\n . Checking the private key" );
+ mbedtls_printf( "\n . Checking the private key" );
fflush( stdout );
- if( ( ret = rsa_check_privkey( &rsa ) ) != 0 )
+ if( ( ret = mbedtls_rsa_check_privkey( &rsa ) ) != 0 )
{
- polarssl_printf( " failed\n ! rsa_check_privkey failed with -0x%0x\n", -ret );
+ mbedtls_printf( " failed\n ! mbedtls_rsa_check_privkey failed with -0x%0x\n", -ret );
goto exit;
}
@@ -116,19 +116,19 @@
* Compute the SHA-256 hash of the input file,
* then calculate the RSA signature of the hash.
*/
- polarssl_printf( "\n . Generating the RSA/SHA-256 signature" );
+ mbedtls_printf( "\n . Generating the RSA/SHA-256 signature" );
fflush( stdout );
- if( ( ret = sha1_file( argv[1], hash ) ) != 0 )
+ if( ( ret = mbedtls_sha1_file( argv[1], hash ) ) != 0 )
{
- polarssl_printf( " failed\n ! Could not open or read %s\n\n", argv[1] );
+ mbedtls_printf( " failed\n ! Could not open or read %s\n\n", argv[1] );
goto exit;
}
- if( ( ret = rsa_pkcs1_sign( &rsa, NULL, NULL, RSA_PRIVATE, POLARSSL_MD_SHA256,
+ if( ( ret = mbedtls_rsa_pkcs1_sign( &rsa, NULL, NULL, MBEDTLS_RSA_PRIVATE, MBEDTLS_MD_SHA256,
20, hash, buf ) ) != 0 )
{
- polarssl_printf( " failed\n ! rsa_pkcs1_sign returned -0x%0x\n\n", -ret );
+ mbedtls_printf( " failed\n ! mbedtls_rsa_pkcs1_sign returned -0x%0x\n\n", -ret );
goto exit;
}
@@ -140,26 +140,26 @@
if( ( f = fopen( argv[1], "wb+" ) ) == NULL )
{
ret = 1;
- polarssl_printf( " failed\n ! Could not create %s\n\n", argv[1] );
+ mbedtls_printf( " failed\n ! Could not create %s\n\n", argv[1] );
goto exit;
}
for( i = 0; i < rsa.len; 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", argv[1] );
+ mbedtls_printf( "\n . Done (created \"%s\")\n\n", argv[1] );
exit:
#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_RSA_C && POLARSSL_SHA256_C &&
- POLARSSL_FS_IO */
+#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_RSA_C && MBEDTLS_SHA256_C &&
+ MBEDTLS_FS_IO */