From 79e72018540e6b0890b18d293a2af38a87192501 Mon Sep 17 00:00:00 2001 From: Dirk Ziegelmeier Date: Tue, 8 Sep 2015 21:33:00 +0200 Subject: [PATCH] PPP: fix constness in PPP related files (GCC -Wcast-qual) Signed-off-by: Dirk Ziegelmeier --- src/include/netif/ppp/chap-new.h | 2 +- src/include/netif/ppp/fsm.h | 2 +- src/include/netif/ppp/polarssl/des.h | 2 +- src/include/netif/ppp/polarssl/md4.h | 2 +- src/include/netif/ppp/polarssl/md5.h | 2 +- src/include/netif/ppp/polarssl/sha1.h | 2 +- src/netif/ppp/chap-md5.c | 6 +- src/netif/ppp/chap_ms.c | 100 +++++++++++++------------- src/netif/ppp/fsm.c | 6 +- src/netif/ppp/mppe.c | 4 +- src/netif/ppp/polarssl/des.c | 2 +- src/netif/ppp/polarssl/md4.c | 10 +-- src/netif/ppp/polarssl/md5.c | 10 +-- src/netif/ppp/polarssl/sha1.c | 10 +-- src/netif/ppp/utils.c | 6 +- 15 files changed, 83 insertions(+), 83 deletions(-) diff --git a/src/include/netif/ppp/chap-new.h b/src/include/netif/ppp/chap-new.h index 9e4b864f..9b7c0487 100644 --- a/src/include/netif/ppp/chap-new.h +++ b/src/include/netif/ppp/chap-new.h @@ -140,7 +140,7 @@ struct chap_digest_type { #endif /* PPP_SERVER */ void (*make_response)(ppp_pcb *pcb, unsigned char *response, int id, const char *our_name, const unsigned char *challenge, const char *secret, int secret_len, - const unsigned char *priv); + unsigned char *priv); int (*check_success)(ppp_pcb *pcb, unsigned char *pkt, int len, unsigned char *priv); void (*handle_failure)(ppp_pcb *pcb, unsigned char *pkt, int len); }; diff --git a/src/include/netif/ppp/fsm.h b/src/include/netif/ppp/fsm.h index fda2d6e1..fc0a4b10 100644 --- a/src/include/netif/ppp/fsm.h +++ b/src/include/netif/ppp/fsm.h @@ -168,7 +168,7 @@ void fsm_open(fsm *f); void fsm_close(fsm *f, const char *reason); void fsm_input(fsm *f, u_char *inpacket, int l); void fsm_protreject(fsm *f); -void fsm_sdata(fsm *f, u_char code, u_char id, u_char *data, int datalen); +void fsm_sdata(fsm *f, u_char code, u_char id, const u_char *data, int datalen); #endif /* FSM_H */ diff --git a/src/include/netif/ppp/polarssl/des.h b/src/include/netif/ppp/polarssl/des.h index 86417cd4..d0858bd8 100644 --- a/src/include/netif/ppp/polarssl/des.h +++ b/src/include/netif/ppp/polarssl/des.h @@ -80,7 +80,7 @@ void des_setkey_dec( des_context *ctx, unsigned char key[8] ); * \param output 64-bit output block */ void des_crypt_ecb( des_context *ctx, - unsigned char input[8], + const unsigned char input[8], unsigned char output[8] ); #ifdef __cplusplus diff --git a/src/include/netif/ppp/polarssl/md4.h b/src/include/netif/ppp/polarssl/md4.h index 46ebf5cb..a382f85a 100644 --- a/src/include/netif/ppp/polarssl/md4.h +++ b/src/include/netif/ppp/polarssl/md4.h @@ -68,7 +68,7 @@ void md4_starts( md4_context *ctx ); * \param input buffer holding the data * \param ilen length of the input data */ -void md4_update( md4_context *ctx, unsigned char *input, int ilen ); +void md4_update( md4_context *ctx, const unsigned char *input, int ilen ); /** * \brief MD4 final digest diff --git a/src/include/netif/ppp/polarssl/md5.h b/src/include/netif/ppp/polarssl/md5.h index 3587b4c0..a299d98c 100644 --- a/src/include/netif/ppp/polarssl/md5.h +++ b/src/include/netif/ppp/polarssl/md5.h @@ -68,7 +68,7 @@ void md5_starts( md5_context *ctx ); * \param input buffer holding the data * \param ilen length of the input data */ -void md5_update( md5_context *ctx, unsigned char *input, int ilen ); +void md5_update( md5_context *ctx, const unsigned char *input, int ilen ); /** * \brief MD5 final digest diff --git a/src/include/netif/ppp/polarssl/sha1.h b/src/include/netif/ppp/polarssl/sha1.h index 9d331633..56d947c2 100644 --- a/src/include/netif/ppp/polarssl/sha1.h +++ b/src/include/netif/ppp/polarssl/sha1.h @@ -68,7 +68,7 @@ void sha1_starts( sha1_context *ctx ); * \param input buffer holding the data * \param ilen length of the input data */ -void sha1_update( sha1_context *ctx, unsigned char *input, int ilen ); +void sha1_update( sha1_context *ctx, const unsigned char *input, int ilen ); /** * \brief SHA-1 final digest diff --git a/src/netif/ppp/chap-md5.c b/src/netif/ppp/chap-md5.c index 842a449b..4a2bb055 100644 --- a/src/netif/ppp/chap-md5.c +++ b/src/netif/ppp/chap-md5.c @@ -97,7 +97,7 @@ static int chap_md5_verify_response(ppp_pcb *pcb, int id, const char *name, static void chap_md5_make_response(ppp_pcb *pcb, unsigned char *response, int id, const char *our_name, const unsigned char *challenge, const char *secret, int secret_len, - const unsigned char *private_) { + unsigned char *private_) { md5_context ctx; unsigned char idbyte = id; int challenge_len = *challenge++; @@ -107,8 +107,8 @@ static void chap_md5_make_response(ppp_pcb *pcb, unsigned char *response, int id md5_starts(&ctx); md5_update(&ctx, &idbyte, 1); - md5_update(&ctx, (u_char *)secret, secret_len); - md5_update(&ctx, (unsigned char *)challenge, challenge_len); + md5_update(&ctx, (const u_char *)secret, secret_len); + md5_update(&ctx, challenge, challenge_len); md5_finish(&ctx, &response[1]); response[0] = MD5_HASH_SIZE; } diff --git a/src/netif/ppp/chap_ms.c b/src/netif/ppp/chap_ms.c index 0ac8382a..d35db5ec 100644 --- a/src/netif/ppp/chap_ms.c +++ b/src/netif/ppp/chap_ms.c @@ -168,32 +168,32 @@ extern void set_mppe_enc_types(int, int); #define MS_CHAP2_AUTHENTICATEE 0 #define MS_CHAP2_AUTHENTICATOR 1 -static void ascii2unicode (char[], int, u_char[]); +static void ascii2unicode (const char[], int, u_char[]); static void NTPasswordHash (u_char *, int, u_char[MD4_SIGNATURE_SIZE]); -static void ChallengeResponse (u_char *, u_char *, u_char[24]); -static void ChallengeHash (u_char[16], u_char *, char *, u_char[8]); -static void ChapMS_NT (u_char *, char *, int, u_char[24]); -static void ChapMS2_NT (u_char *, u_char[16], char *, char *, int, +static void ChallengeResponse (const u_char *, const u_char *, u_char[24]); +static void ChallengeHash (const u_char[16], const u_char *, const char *, u_char[8]); +static void ChapMS_NT (const u_char *, const char *, int, u_char[24]); +static void ChapMS2_NT (const u_char *, const u_char[16], const char *, const char *, int, u_char[24]); static void GenerateAuthenticatorResponsePlain - (char*, int, u_char[24], u_char[16], u_char *, - char *, u_char[41]); + (const char*, int, u_char[24], const u_char[16], const u_char *, + const char *, u_char[41]); #ifdef MSLANMAN static void ChapMS_LANMan (u_char *, char *, int, u_char *); #endif -static void GenerateAuthenticatorResponse(u_char PasswordHashHash[MD4_SIGNATURE_SIZE], - u_char NTResponse[24], u_char PeerChallenge[16], - u_char *rchallenge, char *username, +static void GenerateAuthenticatorResponse(const u_char PasswordHashHash[MD4_SIGNATURE_SIZE], + u_char NTResponse[24], const u_char PeerChallenge[16], + const u_char *rchallenge, const char *username, u_char authResponse[MS_AUTH_RESPONSE_LENGTH+1]); #if MPPE_SUPPORT -static void Set_Start_Key (ppp_pcb *pcb, u_char *, char *, int); -static void SetMasterKeys (ppp_pcb *pcb, char *, int, u_char[24], int); +static void Set_Start_Key (ppp_pcb *pcb, const u_char *, const char *, int); +static void SetMasterKeys (ppp_pcb *pcb, const char *, int, u_char[24], int); #endif /* MPPE_SUPPORT */ -static void ChapMS (ppp_pcb *pcb, u_char *, char *, int, u_char *); -static void ChapMS2 (ppp_pcb *pcb, u_char *, u_char *, char *, char *, int, +static void ChapMS (ppp_pcb *pcb, const u_char *, const char *, int, u_char *); +static void ChapMS2 (ppp_pcb *pcb, const u_char *, const u_char *, const char *, const char *, int, u_char *, u_char[MS_AUTH_RESPONSE_LENGTH+1], int); #ifdef MSLANMAN @@ -391,28 +391,28 @@ static int chapms2_verify_response(ppp_pcb *pcb, int id, const char *name, static void chapms_make_response(ppp_pcb *pcb, unsigned char *response, int id, const char *our_name, const unsigned char *challenge, const char *secret, int secret_len, - const unsigned char *private_) { + unsigned char *private_) { LWIP_UNUSED_ARG(id); LWIP_UNUSED_ARG(our_name); LWIP_UNUSED_ARG(private_); challenge++; /* skip length, should be 8 */ *response++ = MS_CHAP_RESPONSE_LEN; - ChapMS(pcb, (u_char*)challenge, (char*)secret, secret_len, response); + ChapMS(pcb, challenge, secret, secret_len, response); } static void chapms2_make_response(ppp_pcb *pcb, unsigned char *response, int id, const char *our_name, const unsigned char *challenge, const char *secret, int secret_len, - const unsigned char *private_) { + unsigned char *private_) { LWIP_UNUSED_ARG(id); challenge++; /* skip length, should be 16 */ *response++ = MS_CHAP2_RESPONSE_LEN; - ChapMS2(pcb, (u_char*)challenge, + ChapMS2(pcb, challenge, #ifdef DEBUGMPPEKEY mschap2_peer_challenge, #else NULL, #endif - (char*)our_name, (char*)secret, secret_len, response, (u_char*)private_, + our_name, secret, secret_len, response, private_, MS_CHAP2_AUTHENTICATEE); } @@ -511,8 +511,8 @@ print_msg: ppp_error("MS-CHAP authentication failed: %v", p); } -static void ChallengeResponse(u_char *challenge, - u_char PasswordHash[MD4_SIGNATURE_SIZE], +static void ChallengeResponse(const u_char *challenge, + const u_char PasswordHash[MD4_SIGNATURE_SIZE], u_char response[24]) { u_char ZPasswordHash[21]; des_context des; @@ -543,11 +543,11 @@ static void ChallengeResponse(u_char *challenge, #endif } -static void ChallengeHash(u_char PeerChallenge[16], u_char *rchallenge, - char *username, u_char Challenge[8]) { +static void ChallengeHash(const u_char PeerChallenge[16], const u_char *rchallenge, + const char *username, u_char Challenge[8]) { sha1_context sha1Context; u_char sha1Hash[SHA1_SIGNATURE_SIZE]; - char *user; + const char *user; /* remove domain from "domain\username" */ if ((user = strrchr(username, '\\')) != NULL) @@ -558,7 +558,7 @@ static void ChallengeHash(u_char PeerChallenge[16], u_char *rchallenge, sha1_starts(&sha1Context); sha1_update(&sha1Context, PeerChallenge, 16); sha1_update(&sha1Context, rchallenge, 16); - sha1_update(&sha1Context, (unsigned char *)user, strlen(user)); + sha1_update(&sha1Context, (const unsigned char*)user, strlen(user)); sha1_finish(&sha1Context, sha1Hash); MEMCPY(Challenge, sha1Hash, 8); @@ -571,7 +571,7 @@ static void ChallengeHash(u_char PeerChallenge[16], u_char *rchallenge, * is assumed by all M$ CHAP RFCs. (Unicode byte ordering * is machine-dependent.) */ -static void ascii2unicode(char ascii[], int ascii_len, u_char unicode[]) { +static void ascii2unicode(const char ascii[], int ascii_len, u_char unicode[]) { int i; BZERO(unicode, ascii_len * 2); @@ -587,7 +587,7 @@ static void NTPasswordHash(u_char *secret, int secret_len, u_char hash[MD4_SIGNA md4_finish(&md4Context, hash); } -static void ChapMS_NT(u_char *rchallenge, char *secret, int secret_len, +static void ChapMS_NT(const u_char *rchallenge, const char *secret, int secret_len, u_char NTResponse[24]) { u_char unicodePassword[MAX_NT_PASSWORD * 2]; u_char PasswordHash[MD4_SIGNATURE_SIZE]; @@ -599,8 +599,8 @@ static void ChapMS_NT(u_char *rchallenge, char *secret, int secret_len, ChallengeResponse(rchallenge, PasswordHash, NTResponse); } -static void ChapMS2_NT(u_char *rchallenge, u_char PeerChallenge[16], char *username, - char *secret, int secret_len, u_char NTResponse[24]) { +static void ChapMS2_NT(const u_char *rchallenge, const u_char PeerChallenge[16], const char *username, + const char *secret, int secret_len, u_char NTResponse[24]) { u_char unicodePassword[MAX_NT_PASSWORD * 2]; u_char PasswordHash[MD4_SIGNATURE_SIZE]; u_char Challenge[8]; @@ -643,9 +643,9 @@ static void ChapMS_LANMan(u_char *rchallenge, char *secret, int secret_len, #endif -static void GenerateAuthenticatorResponse(u_char PasswordHashHash[MD4_SIGNATURE_SIZE], - u_char NTResponse[24], u_char PeerChallenge[16], - u_char *rchallenge, char *username, +static void GenerateAuthenticatorResponse(const u_char PasswordHashHash[MD4_SIGNATURE_SIZE], + u_char NTResponse[24], const u_char PeerChallenge[16], + const u_char *rchallenge, const char *username, u_char authResponse[MS_AUTH_RESPONSE_LENGTH+1]) { /* * "Magic" constants used in response generation, from RFC 2759. @@ -670,7 +670,7 @@ static void GenerateAuthenticatorResponse(u_char PasswordHashHash[MD4_SIGNATURE_ sha1_starts(&sha1Context); sha1_update(&sha1Context, PasswordHashHash, MD4_SIGNATURE_SIZE); sha1_update(&sha1Context, NTResponse, 24); - sha1_update(&sha1Context, (unsigned char *)Magic1, sizeof(Magic1)); + sha1_update(&sha1Context, Magic1, sizeof(Magic1)); sha1_finish(&sha1Context, Digest); ChallengeHash(PeerChallenge, rchallenge, username, Challenge); @@ -678,7 +678,7 @@ static void GenerateAuthenticatorResponse(u_char PasswordHashHash[MD4_SIGNATURE_ sha1_starts(&sha1Context); sha1_update(&sha1Context, Digest, sizeof(Digest)); sha1_update(&sha1Context, Challenge, sizeof(Challenge)); - sha1_update(&sha1Context, (unsigned char *)Magic2, sizeof(Magic2)); + sha1_update(&sha1Context, Magic2, sizeof(Magic2)); sha1_finish(&sha1Context, Digest); /* Convert to ASCII hex string. */ @@ -687,10 +687,10 @@ static void GenerateAuthenticatorResponse(u_char PasswordHashHash[MD4_SIGNATURE_ } -static void GenerateAuthenticatorResponsePlain - (char *secret, int secret_len, - u_char NTResponse[24], u_char PeerChallenge[16], - u_char *rchallenge, char *username, +static void GenerateAuthenticatorResponsePlain( + const char *secret, int secret_len, + u_char NTResponse[24], const u_char PeerChallenge[16], + const u_char *rchallenge, const char *username, u_char authResponse[MS_AUTH_RESPONSE_LENGTH+1]) { u_char unicodePassword[MAX_NT_PASSWORD * 2]; u_char PasswordHash[MD4_SIGNATURE_SIZE]; @@ -711,7 +711,7 @@ static void GenerateAuthenticatorResponsePlain /* * Set mppe_xxxx_key from MS-CHAP credentials. (see RFC 3079) */ -static void Set_Start_Key(ppp_pcb *pcb, u_char *rchallenge, char *secret, int secret_len) { +static void Set_Start_Key(ppp_pcb *pcb, const u_char *rchallenge, const char *secret, int secret_len) { u_char unicodePassword[MAX_NT_PASSWORD * 2]; u_char PasswordHash[MD4_SIGNATURE_SIZE]; u_char PasswordHashHash[MD4_SIGNATURE_SIZE]; @@ -739,7 +739,7 @@ static void Set_Start_Key(ppp_pcb *pcb, u_char *rchallenge, char *secret, int se /* * Set mppe_xxxx_key from MS-CHAPv2 credentials. (see RFC 3079) */ -static void SetMasterKeys(ppp_pcb *pcb, char *secret, int secret_len, u_char NTResponse[24], int IsServer) { +static void SetMasterKeys(ppp_pcb *pcb, const char *secret, int secret_len, u_char NTResponse[24], int IsServer) { u_char unicodePassword[MAX_NT_PASSWORD * 2]; u_char PasswordHash[MD4_SIGNATURE_SIZE]; u_char PasswordHashHash[MD4_SIGNATURE_SIZE]; @@ -786,7 +786,7 @@ static void SetMasterKeys(ppp_pcb *pcb, char *secret, int secret_len, u_char NTR sha1_starts(&sha1Context); sha1_update(&sha1Context, PasswordHashHash, MD4_SIGNATURE_SIZE); sha1_update(&sha1Context, NTResponse, 24); - sha1_update(&sha1Context, (unsigned char *)Magic1, sizeof(Magic1)); + sha1_update(&sha1Context, Magic1, sizeof(Magic1)); sha1_finish(&sha1Context, MasterKey); /* @@ -798,9 +798,9 @@ static void SetMasterKeys(ppp_pcb *pcb, char *secret, int secret_len, u_char NTR s = Magic2; sha1_starts(&sha1Context); sha1_update(&sha1Context, MasterKey, 16); - sha1_update(&sha1Context, (unsigned char *)mppe_sha1_pad1, SHA1_PAD_SIZE); - sha1_update(&sha1Context, (unsigned char *)s, 84); - sha1_update(&sha1Context, (unsigned char *)mppe_sha1_pad2, SHA1_PAD_SIZE); + sha1_update(&sha1Context, mppe_sha1_pad1, SHA1_PAD_SIZE); + sha1_update(&sha1Context, s, 84); + sha1_update(&sha1Context, mppe_sha1_pad2, SHA1_PAD_SIZE); sha1_finish(&sha1Context, Digest); mppe_set_key(pcb, &pcb->mppe_comp, Digest); @@ -814,9 +814,9 @@ static void SetMasterKeys(ppp_pcb *pcb, char *secret, int secret_len, u_char NTR s = Magic3; sha1_starts(&sha1Context); sha1_update(&sha1Context, MasterKey, 16); - sha1_update(&sha1Context, (unsigned char *)mppe_sha1_pad1, SHA1_PAD_SIZE); - sha1_update(&sha1Context, (unsigned char *)s, 84); - sha1_update(&sha1Context, (unsigned char *)mppe_sha1_pad2, SHA1_PAD_SIZE); + sha1_update(&sha1Context, mppe_sha1_pad1, SHA1_PAD_SIZE); + sha1_update(&sha1Context, s, 84); + sha1_update(&sha1Context, mppe_sha1_pad2, SHA1_PAD_SIZE); sha1_finish(&sha1Context, Digest); mppe_set_key(pcb, &pcb->mppe_decomp, Digest); @@ -827,7 +827,7 @@ static void SetMasterKeys(ppp_pcb *pcb, char *secret, int secret_len, u_char NTR #endif /* MPPE_SUPPORT */ -static void ChapMS(ppp_pcb *pcb, u_char *rchallenge, char *secret, int secret_len, +static void ChapMS(ppp_pcb *pcb, const u_char *rchallenge, const char *secret, int secret_len, unsigned char *response) { #if !MPPE_SUPPORT LWIP_UNUSED_ARG(pcb); @@ -862,8 +862,8 @@ static void ChapMS(ppp_pcb *pcb, u_char *rchallenge, char *secret, int secret_le * The PeerChallenge field of response is then used for calculation of the * Authenticator Response. */ -static void ChapMS2(ppp_pcb *pcb, u_char *rchallenge, u_char *PeerChallenge, - char *user, char *secret, int secret_len, unsigned char *response, +static void ChapMS2(ppp_pcb *pcb, const u_char *rchallenge, const u_char *PeerChallenge, + const char *user, const char *secret, int secret_len, unsigned char *response, u_char authResponse[], int authenticator) { /* ARGSUSED */ LWIP_UNUSED_ARG(authenticator); diff --git a/src/netif/ppp/fsm.c b/src/netif/ppp/fsm.c index 3e63e2fd..9237d3d6 100644 --- a/src/netif/ppp/fsm.c +++ b/src/netif/ppp/fsm.c @@ -208,7 +208,7 @@ static void terminate_layer(fsm *f, int nextstate) { /* Init restart counter and send Terminate-Request */ f->retransmits = pcb->settings.fsm_max_term_transmits; fsm_sdata(f, TERMREQ, f->reqid = ++f->id, - (u_char *) f->term_reason, f->term_reason_len); + (const u_char *) f->term_reason, f->term_reason_len); if (f->retransmits == 0) { /* @@ -280,7 +280,7 @@ static void fsm_timeout(void *arg) { } else { /* Send Terminate-Request */ fsm_sdata(f, TERMREQ, f->reqid = ++f->id, - (u_char *) f->term_reason, f->term_reason_len); + (const u_char *) f->term_reason, f->term_reason_len); TIMEOUT(fsm_timeout, f, pcb->settings.fsm_timeout_time); --f->retransmits; } @@ -767,7 +767,7 @@ static void fsm_sconfreq(fsm *f, int retransmit) { * * Used for all packets sent to our peer by this module. */ -void fsm_sdata(fsm *f, u_char code, u_char id, u_char *data, int datalen) { +void fsm_sdata(fsm *f, u_char code, u_char id, const u_char *data, int datalen) { ppp_pcb *pcb = f->pcb; struct pbuf *p; u_char *outp; diff --git a/src/netif/ppp/mppe.c b/src/netif/ppp/mppe.c index 24e886c1..67ca8e4f 100644 --- a/src/netif/ppp/mppe.c +++ b/src/netif/ppp/mppe.c @@ -80,9 +80,9 @@ static void mppe_rekey(ppp_mppe_state * state, int initial_key) */ sha1_starts(&sha1); sha1_update(&sha1, state->master_key, state->keylen); - sha1_update(&sha1, (unsigned char *)mppe_sha1_pad1, SHA1_PAD_SIZE); + sha1_update(&sha1, mppe_sha1_pad1, SHA1_PAD_SIZE); sha1_update(&sha1, state->session_key, state->keylen); - sha1_update(&sha1, (unsigned char *)mppe_sha1_pad2, SHA1_PAD_SIZE); + sha1_update(&sha1, mppe_sha1_pad2, SHA1_PAD_SIZE); sha1_finish(&sha1, sha1_digest); MEMCPY(state->session_key, sha1_digest, state->keylen); diff --git a/src/netif/ppp/polarssl/des.c b/src/netif/ppp/polarssl/des.c index 38f3a746..0d6af849 100644 --- a/src/netif/ppp/polarssl/des.c +++ b/src/netif/ppp/polarssl/des.c @@ -394,7 +394,7 @@ void des_setkey_dec( des_context *ctx, unsigned char key[8] ) * DES-ECB block encryption/decryption */ void des_crypt_ecb( des_context *ctx, - unsigned char input[8], + const unsigned char input[8], unsigned char output[8] ) { int i; diff --git a/src/netif/ppp/polarssl/md4.c b/src/netif/ppp/polarssl/md4.c index 64d77665..b134cba9 100644 --- a/src/netif/ppp/polarssl/md4.c +++ b/src/netif/ppp/polarssl/md4.c @@ -83,7 +83,7 @@ void md4_starts( md4_context *ctx ) ctx->state[3] = 0x10325476; } -static void md4_process( md4_context *ctx, unsigned char data[64] ) +static void md4_process( md4_context *ctx, const unsigned char data[64] ) { unsigned long X[16], A, B, C, D; @@ -189,7 +189,7 @@ static void md4_process( md4_context *ctx, unsigned char data[64] ) /* * MD4 process buffer */ -void md4_update( md4_context *ctx, unsigned char *input, int ilen ) +void md4_update( md4_context *ctx, const unsigned char *input, int ilen ) { int fill; unsigned long left; @@ -209,7 +209,7 @@ void md4_update( md4_context *ctx, unsigned char *input, int ilen ) if( left && ilen >= fill ) { MEMCPY( (void *) (ctx->buffer + left), - (void *) input, fill ); + input, fill ); md4_process( ctx, ctx->buffer ); input += fill; ilen -= fill; @@ -226,7 +226,7 @@ void md4_update( md4_context *ctx, unsigned char *input, int ilen ) if( ilen > 0 ) { MEMCPY( (void *) (ctx->buffer + left), - (void *) input, ilen ); + input, ilen ); } } @@ -257,7 +257,7 @@ void md4_finish( md4_context *ctx, unsigned char output[16] ) last = ctx->total[0] & 0x3F; padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last ); - md4_update( ctx, (unsigned char *) md4_padding, padn ); + md4_update( ctx, md4_padding, padn ); md4_update( ctx, msglen, 8 ); PUT_ULONG_LE( ctx->state[0], output, 0 ); diff --git a/src/netif/ppp/polarssl/md5.c b/src/netif/ppp/polarssl/md5.c index 9d0dae0a..ba103c4c 100644 --- a/src/netif/ppp/polarssl/md5.c +++ b/src/netif/ppp/polarssl/md5.c @@ -82,7 +82,7 @@ void md5_starts( md5_context *ctx ) ctx->state[3] = 0x10325476; } -static void md5_process( md5_context *ctx, unsigned char data[64] ) +static void md5_process( md5_context *ctx, const unsigned char data[64] ) { unsigned long X[16], A, B, C, D; @@ -208,7 +208,7 @@ static void md5_process( md5_context *ctx, unsigned char data[64] ) /* * MD5 process buffer */ -void md5_update( md5_context *ctx, unsigned char *input, int ilen ) +void md5_update( md5_context *ctx, const unsigned char *input, int ilen ) { int fill; unsigned long left; @@ -228,7 +228,7 @@ void md5_update( md5_context *ctx, unsigned char *input, int ilen ) if( left && ilen >= fill ) { MEMCPY( (void *) (ctx->buffer + left), - (void *) input, fill ); + input, fill ); md5_process( ctx, ctx->buffer ); input += fill; ilen -= fill; @@ -245,7 +245,7 @@ void md5_update( md5_context *ctx, unsigned char *input, int ilen ) if( ilen > 0 ) { MEMCPY( (void *) (ctx->buffer + left), - (void *) input, ilen ); + input, ilen ); } } @@ -276,7 +276,7 @@ void md5_finish( md5_context *ctx, unsigned char output[16] ) last = ctx->total[0] & 0x3F; padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last ); - md5_update( ctx, (unsigned char *) md5_padding, padn ); + md5_update( ctx, md5_padding, padn ); md5_update( ctx, msglen, 8 ); PUT_ULONG_LE( ctx->state[0], output, 0 ); diff --git a/src/netif/ppp/polarssl/sha1.c b/src/netif/ppp/polarssl/sha1.c index 89d4991a..313b7564 100644 --- a/src/netif/ppp/polarssl/sha1.c +++ b/src/netif/ppp/polarssl/sha1.c @@ -83,7 +83,7 @@ void sha1_starts( sha1_context *ctx ) ctx->state[4] = 0xC3D2E1F0; } -static void sha1_process( sha1_context *ctx, unsigned char data[64] ) +static void sha1_process( sha1_context *ctx, const unsigned char data[64] ) { unsigned long temp, W[16], A, B, C, D, E; @@ -242,7 +242,7 @@ static void sha1_process( sha1_context *ctx, unsigned char data[64] ) /* * SHA-1 process buffer */ -void sha1_update( sha1_context *ctx, unsigned char *input, int ilen ) +void sha1_update( sha1_context *ctx, const unsigned char *input, int ilen ) { int fill; unsigned long left; @@ -262,7 +262,7 @@ void sha1_update( sha1_context *ctx, unsigned char *input, int ilen ) if( left && ilen >= fill ) { MEMCPY( (void *) (ctx->buffer + left), - (void *) input, fill ); + input, fill ); sha1_process( ctx, ctx->buffer ); input += fill; ilen -= fill; @@ -279,7 +279,7 @@ void sha1_update( sha1_context *ctx, unsigned char *input, int ilen ) if( ilen > 0 ) { MEMCPY( (void *) (ctx->buffer + left), - (void *) input, ilen ); + input, ilen ); } } @@ -310,7 +310,7 @@ void sha1_finish( sha1_context *ctx, unsigned char output[20] ) last = ctx->total[0] & 0x3F; padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last ); - sha1_update( ctx, (unsigned char *) sha1_padding, padn ); + sha1_update( ctx, sha1_padding, padn ); sha1_update( ctx, msglen, 8 ); PUT_ULONG_BE( ctx->state[0], output, 0 ); diff --git a/src/netif/ppp/utils.c b/src/netif/ppp/utils.c index afa6fd4a..4c14e36d 100644 --- a/src/netif/ppp/utils.c +++ b/src/netif/ppp/utils.c @@ -141,7 +141,7 @@ int ppp_vslprintf(char *buf, int buflen, const char *fmt, va_list args) { unsigned long val = 0; const char *f; char *str, *buf0; - unsigned char *p; + const unsigned char *p; char num[32]; #if 0 /* need port */ time_t t; @@ -285,11 +285,11 @@ int ppp_vslprintf(char *buf, int buflen, const char *fmt, va_list args) { quoted = c == 'q'; p = va_arg(args, unsigned char *); if (p == NULL) - p = (unsigned char *)""; + p = (const unsigned char *)""; if (fillch == '0' && prec >= 0) { n = prec; } else { - n = strlen((char *)p); + n = strlen((const char *)p); if (prec >= 0 && n > prec) n = prec; }