]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
EAP-pwd: Mark helper function arguments const when appropriate
authorJouni Malinen <j@w1.fi>
Sat, 28 Mar 2015 07:34:30 +0000 (09:34 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 28 Mar 2015 07:34:30 +0000 (09:34 +0200)
These variables are not modified during PWE or key computation.

Signed-off-by: Jouni Malinen <j@w1.fi>
src/eap_common/eap_pwd_common.c
src/eap_common/eap_pwd_common.h

index 631c363fb7c9f7e292fc9a5a84772413263e0ab7..4d27623f87bfdbbfced4b3916c188c7b8d9ff129 100644 (file)
@@ -86,9 +86,10 @@ static int eap_pwd_kdf(const u8 *key, size_t keylen, const u8 *label,
  * on the password and identities.
  */
 int compute_password_element(EAP_PWD_group *grp, u16 num,
-                            u8 *password, int password_len,
-                            u8 *id_server, int id_server_len,
-                            u8 *id_peer, int id_peer_len, u8 *token)
+                            const u8 *password, size_t password_len,
+                            const u8 *id_server, size_t id_server_len,
+                            const u8 *id_peer, size_t id_peer_len,
+                            const u8 *token)
 {
        BIGNUM *x_candidate = NULL, *rnd = NULL, *cofactor = NULL;
        struct crypto_hash *hash;
@@ -283,10 +284,10 @@ int compute_password_element(EAP_PWD_group *grp, u16 num,
 }
 
 
-int compute_keys(EAP_PWD_group *grp, BN_CTX *bnctx, BIGNUM *k,
-                BIGNUM *peer_scalar, BIGNUM *server_scalar,
-                u8 *confirm_peer, u8 *confirm_server,
-                u32 *ciphersuite, u8 *msk, u8 *emsk, u8 *session_id)
+int compute_keys(EAP_PWD_group *grp, BN_CTX *bnctx, const BIGNUM *k,
+                const BIGNUM *peer_scalar, const BIGNUM *server_scalar,
+                const u8 *confirm_peer, const u8 *confirm_server,
+                const u32 *ciphersuite, u8 *msk, u8 *emsk, u8 *session_id)
 {
        struct crypto_hash *hash;
        u8 mk[SHA256_MAC_LEN], *cruft;
@@ -306,7 +307,7 @@ int compute_keys(EAP_PWD_group *grp, BN_CTX *bnctx, BIGNUM *k,
                os_free(cruft);
                return -1;
        }
-       eap_pwd_h_update(hash, (u8 *) ciphersuite, sizeof(u32));
+       eap_pwd_h_update(hash, (const u8 *) ciphersuite, sizeof(u32));
        offset = BN_num_bytes(grp->order) - BN_num_bytes(peer_scalar);
        os_memset(cruft, 0, BN_num_bytes(grp->prime));
        BN_bn2bin(peer_scalar, cruft + offset);
index c54c4414f11f36425a3fd12753f4a526483963a2..a0d717edfe7a83c337d41dcc91b8625421eb4c53 100644 (file)
@@ -56,10 +56,15 @@ struct eap_pwd_id {
 } STRUCT_PACKED;
 
 /* common routines */
-int compute_password_element(EAP_PWD_group *, u16, u8 *, int, u8 *, int, u8 *,
-                            int, u8 *);
-int compute_keys(EAP_PWD_group *, BN_CTX *, BIGNUM *, BIGNUM *, BIGNUM *,
-                u8 *, u8 *, u32 *, u8 *, u8 *, u8 *);
+int compute_password_element(EAP_PWD_group *grp, u16 num,
+                            const u8 *password, size_t password_len,
+                            const u8 *id_server, size_t id_server_len,
+                            const u8 *id_peer, size_t id_peer_len,
+                            const u8 *token);
+int compute_keys(EAP_PWD_group *grp, BN_CTX *bnctx, const BIGNUM *k,
+                const BIGNUM *peer_scalar, const BIGNUM *server_scalar,
+                const u8 *confirm_peer, const u8 *confirm_server,
+                const u32 *ciphersuite, u8 *msk, u8 *emsk, u8 *session_id);
 struct crypto_hash * eap_pwd_h_init(void);
 void eap_pwd_h_update(struct crypto_hash *hash, const u8 *data, size_t len);
 void eap_pwd_h_final(struct crypto_hash *hash, u8 *digest);