Fixed const correctness issues in programs and tests
(cherry picked from commit e0225e4d7f18f4565224f4997af537533d06a80d)
Conflicts:
programs/ssl/ssl_client2.c
programs/ssl/ssl_server2.c
programs/test/ssl_test.c
programs/x509/cert_app.c
diff --git a/programs/test/o_p_test.c b/programs/test/o_p_test.c
index eb02350..9726282 100644
--- a/programs/test/o_p_test.c
+++ b/programs/test/o_p_test.c
@@ -75,11 +75,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 5d829e5..34fd9c2 100644
--- a/programs/test/ssl_test.c
+++ b/programs/test/ssl_test.c
@@ -74,7 +74,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 */
@@ -153,7 +153,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;
@@ -166,7 +166,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;
@@ -204,7 +205,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 )
{
@@ -212,7 +213,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 )
{
@@ -220,7 +221,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 )
{