mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2026-02-18 16:33:01 +00:00
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
This commit is contained in:
@@ -70,7 +70,7 @@ int main( int argc, char *argv[] )
|
||||
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 @@ int main( int argc, char *argv[] )
|
||||
|
||||
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;
|
||||
|
||||
@@ -62,7 +62,7 @@ int main( int argc, char *argv[] )
|
||||
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 @@ int main( int argc, char *argv[] )
|
||||
|
||||
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;
|
||||
|
||||
@@ -71,7 +71,7 @@ int main( int argc, char *argv[] )
|
||||
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 @@ int main( int argc, char *argv[] )
|
||||
|
||||
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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -72,10 +72,10 @@ int main( int argc, char *argv[] )
|
||||
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 )
|
||||
@@ -87,7 +87,7 @@ void my_debug( void *ctx, int level, const char *str )
|
||||
}
|
||||
}
|
||||
|
||||
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];
|
||||
@@ -124,7 +124,7 @@ void write_public_key( rsa_context *rsa, char *output_file )
|
||||
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];
|
||||
|
||||
@@ -60,7 +60,7 @@ int main( int argc, char *argv[] )
|
||||
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 @@ int main( int argc, char *argv[] )
|
||||
|
||||
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;
|
||||
|
||||
@@ -62,7 +62,7 @@ int main( int argc, char *argv[] )
|
||||
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 @@ int main( int argc, char *argv[] )
|
||||
|
||||
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;
|
||||
|
||||
@@ -69,7 +69,7 @@ int main( int argc, char *argv[] )
|
||||
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 @@ int main( int argc, char *argv[] )
|
||||
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user