Fixed const correctness issues in programs and tests
diff --git a/programs/pkey/dh_client.c b/programs/pkey/dh_client.c
index db9283a..b3a2476 100644
--- a/programs/pkey/dh_client.c
+++ b/programs/pkey/dh_client.c
@@ -70,7 +70,7 @@
unsigned char *p, *end;
unsigned char buf[2048];
unsigned char hash[20];
- char *pers = "dh_client";
+ const char *pers = "dh_client";
entropy_context entropy;
ctr_drbg_context ctr_drbg;
@@ -92,7 +92,8 @@
entropy_init( &entropy );
if( ( ret = ctr_drbg_init( &ctr_drbg, entropy_func, &entropy,
- (unsigned char *) pers, strlen( pers ) ) ) != 0 )
+ (const unsigned char *) pers,
+ strlen( pers ) ) ) != 0 )
{
printf( " failed\n ! ctr_drbg_init returned %d\n", ret );
goto exit;
diff --git a/programs/pkey/dh_genprime.c b/programs/pkey/dh_genprime.c
index 94f1c62..5732f50 100644
--- a/programs/pkey/dh_genprime.c
+++ b/programs/pkey/dh_genprime.c
@@ -62,7 +62,7 @@
mpi G, P, Q;
entropy_context entropy;
ctr_drbg_context ctr_drbg;
- char *pers = "dh_genprime";
+ const char *pers = "dh_genprime";
FILE *fout;
((void) argc);
@@ -83,7 +83,8 @@
entropy_init( &entropy );
if( ( ret = ctr_drbg_init( &ctr_drbg, entropy_func, &entropy,
- (unsigned char *) pers, strlen( pers ) ) ) != 0 )
+ (const unsigned char *) pers,
+ strlen( pers ) ) ) != 0 )
{
printf( " failed\n ! ctr_drbg_init returned %d\n", ret );
goto exit;
diff --git a/programs/pkey/dh_server.c b/programs/pkey/dh_server.c
index 8babef2..9ea2a78 100644
--- a/programs/pkey/dh_server.c
+++ b/programs/pkey/dh_server.c
@@ -71,7 +71,7 @@
unsigned char buf[2048];
unsigned char hash[20];
unsigned char buf2[2];
- char *pers = "dh_server";
+ const char *pers = "dh_server";
entropy_context entropy;
ctr_drbg_context ctr_drbg;
@@ -93,7 +93,8 @@
entropy_init( &entropy );
if( ( ret = ctr_drbg_init( &ctr_drbg, entropy_func, &entropy,
- (unsigned char *) pers, strlen( pers ) ) ) != 0 )
+ (const unsigned char *) pers,
+ strlen( pers ) ) ) != 0 )
{
printf( " failed\n ! ctr_drbg_init returned %d\n", ret );
goto exit;
diff --git a/programs/pkey/key_app.c b/programs/pkey/key_app.c
index ebe94a7..fc0269e 100644
--- a/programs/pkey/key_app.c
+++ b/programs/pkey/key_app.c
@@ -53,9 +53,9 @@
struct options
{
int mode; /* the mode to run the application in */
- char *filename; /* filename of the key file */
- char *password; /* password for the private key */
- char *password_file; /* password_file for the private key */
+ const char *filename; /* filename of the key file */
+ const char *password; /* password for the private key */
+ const char *password_file; /* password_file for the private key */
int debug_level; /* level of debugging */
} opt;
diff --git a/programs/pkey/key_app_writer.c b/programs/pkey/key_app_writer.c
index ab05952..d8465ca 100644
--- a/programs/pkey/key_app_writer.c
+++ b/programs/pkey/key_app_writer.c
@@ -59,10 +59,10 @@
struct options
{
int mode; /* the mode to run the application in */
- char *filename; /* filename of the key file */
+ const char *filename; /* filename of the key file */
int debug_level; /* level of debugging */
int output_mode; /* the output mode to use */
- char *output_file; /* where to store the constructed key file */
+ const char *output_file; /* where to store the constructed key file */
} opt;
void my_debug( void *ctx, int level, const char *str )
@@ -74,7 +74,7 @@
}
}
-void write_public_key( rsa_context *rsa, char *output_file )
+void write_public_key( rsa_context *rsa, const char *output_file )
{
FILE *f;
unsigned char output_buf[16000];
@@ -111,7 +111,7 @@
fclose(f);
}
-void write_private_key( rsa_context *rsa, char *output_file )
+void write_private_key( rsa_context *rsa, const char *output_file )
{
FILE *f;
unsigned char output_buf[16000];
diff --git a/programs/pkey/rsa_encrypt.c b/programs/pkey/rsa_encrypt.c
index aa6ca0e..83dcef2 100644
--- a/programs/pkey/rsa_encrypt.c
+++ b/programs/pkey/rsa_encrypt.c
@@ -60,7 +60,7 @@
ctr_drbg_context ctr_drbg;
unsigned char input[1024];
unsigned char buf[512];
- char *pers = "rsa_encrypt";
+ const char *pers = "rsa_encrypt";
ret = 1;
@@ -80,7 +80,8 @@
entropy_init( &entropy );
if( ( ret = ctr_drbg_init( &ctr_drbg, entropy_func, &entropy,
- (unsigned char *) pers, strlen( pers ) ) ) != 0 )
+ (const unsigned char *) pers,
+ strlen( pers ) ) ) != 0 )
{
printf( " failed\n ! ctr_drbg_init returned %d\n", ret );
goto exit;
diff --git a/programs/pkey/rsa_genkey.c b/programs/pkey/rsa_genkey.c
index 424097e..68e33e5 100644
--- a/programs/pkey/rsa_genkey.c
+++ b/programs/pkey/rsa_genkey.c
@@ -62,7 +62,7 @@
ctr_drbg_context ctr_drbg;
FILE *fpub = NULL;
FILE *fpriv = NULL;
- char *pers = "rsa_genkey";
+ const char *pers = "rsa_genkey";
((void) argc);
((void) argv);
@@ -72,7 +72,8 @@
entropy_init( &entropy );
if( ( ret = ctr_drbg_init( &ctr_drbg, entropy_func, &entropy,
- (unsigned char *) pers, strlen( pers ) ) ) != 0 )
+ (const unsigned char *) pers,
+ strlen( pers ) ) ) != 0 )
{
printf( " failed\n ! ctr_drbg_init returned %d\n", ret );
goto exit;
diff --git a/programs/pkey/rsa_sign_pss.c b/programs/pkey/rsa_sign_pss.c
index ffc5de0..17e772a 100644
--- a/programs/pkey/rsa_sign_pss.c
+++ b/programs/pkey/rsa_sign_pss.c
@@ -69,7 +69,7 @@
unsigned char hash[20];
unsigned char buf[POLARSSL_MPI_MAX_SIZE];
char filename[512];
- char *pers = "rsa_sign_pss";
+ const char *pers = "rsa_sign_pss";
ret = 1;
@@ -89,7 +89,8 @@
entropy_init( &entropy );
if( ( ret = ctr_drbg_init( &ctr_drbg, entropy_func, &entropy,
- (unsigned char *) pers, strlen( pers ) ) ) != 0 )
+ (const unsigned char *) pers,
+ strlen( pers ) ) ) != 0 )
{
printf( " failed\n ! ctr_drbg_init returned %d\n", ret );
goto exit;