aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/srp/srp_lib.c
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2016-06-15 15:17:50 +0100
committerMatt Caswell <matt@openssl.org>2016-06-18 15:34:03 +0100
commit98370c2dd7dc32cecd7bb7d940383846fa435f25 (patch)
treec5f83ad8c892b93534e3079c925acba0a0103142 /crypto/srp/srp_lib.c
parent7fb4b92c01bdef71543650ef7da6bfcec69f9cde (diff)
downloadopenssl-98370c2dd7dc32cecd7bb7d940383846fa435f25.tar.gz
constify SRP
Add const qualifiers to lots of SRP stuff. This started out as an effort to silence some "type-punning" warnings on OpenBSD...but the fix was to have proper const correctness in SRP. RT4378 Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'crypto/srp/srp_lib.c')
-rw-r--r--crypto/srp/srp_lib.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/crypto/srp/srp_lib.c b/crypto/srp/srp_lib.c
index 766a0a23be..06671749a6 100644
--- a/crypto/srp/srp_lib.c
+++ b/crypto/srp/srp_lib.c
@@ -14,7 +14,7 @@
# include <openssl/evp.h>
# include "internal/bn_srp.h"
-static BIGNUM *srp_Calc_k(BIGNUM *N, BIGNUM *g)
+static BIGNUM *srp_Calc_k(const BIGNUM *N, const BIGNUM *g)
{
/* k = SHA1(N | PAD(g)) -- tls-srp draft 8 */
@@ -52,7 +52,7 @@ static BIGNUM *srp_Calc_k(BIGNUM *N, BIGNUM *g)
return res;
}
-BIGNUM *SRP_Calc_u(BIGNUM *A, BIGNUM *B, BIGNUM *N)
+BIGNUM *SRP_Calc_u(const BIGNUM *A, const BIGNUM *B, const BIGNUM *N)
{
/* k = SHA1(PAD(A) || PAD(B) ) -- tls-srp draft 8 */
@@ -95,8 +95,8 @@ BIGNUM *SRP_Calc_u(BIGNUM *A, BIGNUM *B, BIGNUM *N)
return u;
}
-BIGNUM *SRP_Calc_server_key(BIGNUM *A, BIGNUM *v, BIGNUM *u, BIGNUM *b,
- BIGNUM *N)
+BIGNUM *SRP_Calc_server_key(const BIGNUM *A, const BIGNUM *v, const BIGNUM *u,
+ const BIGNUM *b, const BIGNUM *N)
{
BIGNUM *tmp = NULL, *S = NULL;
BN_CTX *bn_ctx;
@@ -125,7 +125,8 @@ BIGNUM *SRP_Calc_server_key(BIGNUM *A, BIGNUM *v, BIGNUM *u, BIGNUM *b,
return S;
}
-BIGNUM *SRP_Calc_B(BIGNUM *b, BIGNUM *N, BIGNUM *g, BIGNUM *v)
+BIGNUM *SRP_Calc_B(const BIGNUM *b, const BIGNUM *N, const BIGNUM *g,
+ const BIGNUM *v)
{
BIGNUM *kv = NULL, *gb = NULL;
BIGNUM *B = NULL, *k = NULL;
@@ -156,7 +157,7 @@ BIGNUM *SRP_Calc_B(BIGNUM *b, BIGNUM *N, BIGNUM *g, BIGNUM *v)
return B;
}
-BIGNUM *SRP_Calc_x(BIGNUM *s, const char *user, const char *pass)
+BIGNUM *SRP_Calc_x(const BIGNUM *s, const char *user, const char *pass)
{
unsigned char dig[SHA_DIGEST_LENGTH];
EVP_MD_CTX *ctxt;
@@ -191,7 +192,7 @@ BIGNUM *SRP_Calc_x(BIGNUM *s, const char *user, const char *pass)
return res;
}
-BIGNUM *SRP_Calc_A(BIGNUM *a, BIGNUM *N, BIGNUM *g)
+BIGNUM *SRP_Calc_A(const BIGNUM *a, const BIGNUM *N, const BIGNUM *g)
{
BN_CTX *bn_ctx;
BIGNUM *A = NULL;
@@ -207,8 +208,8 @@ BIGNUM *SRP_Calc_A(BIGNUM *a, BIGNUM *N, BIGNUM *g)
return A;
}
-BIGNUM *SRP_Calc_client_key(BIGNUM *N, BIGNUM *B, BIGNUM *g, BIGNUM *x,
- BIGNUM *a, BIGNUM *u)
+BIGNUM *SRP_Calc_client_key(const BIGNUM *N, const BIGNUM *B, const BIGNUM *g,
+ const BIGNUM *x, const BIGNUM *a, const BIGNUM *u)
{
BIGNUM *tmp = NULL, *tmp2 = NULL, *tmp3 = NULL, *k = NULL, *K = NULL;
BN_CTX *bn_ctx;
@@ -249,7 +250,7 @@ BIGNUM *SRP_Calc_client_key(BIGNUM *N, BIGNUM *B, BIGNUM *g, BIGNUM *x,
return K;
}
-int SRP_Verify_B_mod_N(BIGNUM *B, BIGNUM *N)
+int SRP_Verify_B_mod_N(const BIGNUM *B, const BIGNUM *N)
{
BIGNUM *r;
BN_CTX *bn_ctx;
@@ -270,20 +271,20 @@ int SRP_Verify_B_mod_N(BIGNUM *B, BIGNUM *N)
return ret;
}
-int SRP_Verify_A_mod_N(BIGNUM *A, BIGNUM *N)
+int SRP_Verify_A_mod_N(const BIGNUM *A, const BIGNUM *N)
{
/* Checks if A % N == 0 */
return SRP_Verify_B_mod_N(A, N);
}
static SRP_gN knowngN[] = {
- {"8192", (BIGNUM *)&bn_generator_19, (BIGNUM *)&bn_group_8192},
- {"6144", (BIGNUM *)&bn_generator_5, (BIGNUM *)&bn_group_6144},
- {"4096", (BIGNUM *)&bn_generator_5, (BIGNUM *)&bn_group_4096},
- {"3072", (BIGNUM *)&bn_generator_5, (BIGNUM *)&bn_group_3072},
- {"2048", (BIGNUM *)&bn_generator_2, (BIGNUM *)&bn_group_2048},
- {"1536", (BIGNUM *)&bn_generator_2, (BIGNUM *)&bn_group_1536},
- {"1024", (BIGNUM *)&bn_generator_2, (BIGNUM *)&bn_group_1024},
+ {"8192", &bn_generator_19, &bn_group_8192},
+ {"6144", &bn_generator_5, &bn_group_6144},
+ {"4096", &bn_generator_5, &bn_group_4096},
+ {"3072", &bn_generator_5, &bn_group_3072},
+ {"2048", &bn_generator_2, &bn_group_2048},
+ {"1536", &bn_generator_2, &bn_group_1536},
+ {"1024", &bn_generator_2, &bn_group_1024},
};
# define KNOWN_GN_NUMBER sizeof(knowngN) / sizeof(SRP_gN)
@@ -292,7 +293,7 @@ static SRP_gN knowngN[] = {
* Check if G and N are known parameters. The values have been generated
* from the ietf-tls-srp draft version 8
*/
-char *SRP_check_known_gN_param(BIGNUM *g, BIGNUM *N)
+char *SRP_check_known_gN_param(const BIGNUM *g, const BIGNUM *N)
{
size_t i;
if ((g == NULL) || (N == NULL))