Fixed const correctness issues in programs and tests
diff --git a/programs/test/o_p_test.c b/programs/test/o_p_test.c
index 187372a..3531d54 100644
--- a/programs/test/o_p_test.c
+++ b/programs/test/o_p_test.c
@@ -63,11 +63,12 @@
unsigned char o_priv_encrypted[512];
unsigned char p_priv_decrypted[512];
unsigned char o_priv_decrypted[512];
- char *pers = "o_p_test_example";
+ const char *pers = "o_p_test_example";
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/test/ssl_cert_test.c b/programs/test/ssl_cert_test.c
index 57ea32c..83a2a01 100644
--- a/programs/test/ssl_cert_test.c
+++ b/programs/test/ssl_cert_test.c
@@ -41,7 +41,7 @@
#define MAX_CLIENT_CERTS 8
-char *client_certificates[MAX_CLIENT_CERTS] =
+const char *client_certificates[MAX_CLIENT_CERTS] =
{
"client1.crt",
"client2.crt",
@@ -53,7 +53,7 @@
"cert_sha512.crt"
};
-char *client_private_keys[MAX_CLIENT_CERTS] =
+const char *client_private_keys[MAX_CLIENT_CERTS] =
{
"client1.key",
"client2.key",
diff --git a/programs/test/ssl_test.c b/programs/test/ssl_test.c
index 802fda0..f011a2c 100644
--- a/programs/test/ssl_test.c
+++ b/programs/test/ssl_test.c
@@ -68,8 +68,8 @@
/*
* server-specific data
*/
-char *dhm_G = "4";
-char *dhm_P =
+const char *dhm_G = "4";
+const char *dhm_P =
"E4004C1F94182000103D883A448B3F802CE4B44A83301270002C20D0321CFD00" \
"11CCEF784C26A400F43DFB901BCA7538F2C6B176001CF5A0FD16D2C48B1D0C1C" \
"F6AC8E1DA6BCC3B4E1F96B0564965300FFA1D0B601EB2800F489AA512C4B248C" \
@@ -84,7 +84,7 @@
{
int opmode; /* operation mode (client or server) */
int iomode; /* I/O mode (blocking or non-blocking) */
- char *server_name; /* hostname of the server (client only) */
+ const char *server_name; /* hostname of the server (client only) */
int server_port; /* port on which the ssl service runs */
int command; /* what to do: read or write operation */
int buffer_size; /* size of the send/receive buffer */
@@ -161,7 +161,7 @@
unsigned char *read_buf = NULL;
unsigned char *write_buf = NULL;
- char *pers = "ssl_test";
+ const char *pers = "ssl_test";
struct hr_time t;
entropy_context entropy;
@@ -174,7 +174,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( " ! ctr_drbg_init returned %d\n", ret );
goto exit;
@@ -212,7 +213,7 @@
printf("POLARSSL_CERTS_C not defined.\n");
goto exit;
#else
- ret = x509parse_crt( &srvcert, (unsigned char *) test_srv_crt,
+ ret = x509parse_crt( &srvcert, (const unsigned char *) test_srv_crt,
strlen( test_srv_crt ) );
if( ret != 0 )
{
@@ -220,7 +221,7 @@
goto exit;
}
- ret = x509parse_crt( &srvcert, (unsigned char *) test_ca_crt,
+ ret = x509parse_crt( &srvcert, (const unsigned char *) test_ca_crt,
strlen( test_ca_crt ) );
if( ret != 0 )
{
@@ -228,7 +229,7 @@
goto exit;
}
- ret = x509parse_key( &rsa, (unsigned char *) test_srv_key,
+ ret = x509parse_key( &rsa, (const unsigned char *) test_srv_key,
strlen( test_srv_key ), NULL, 0 );
if( ret != 0 )
{