OpenCoverage

srp_lib.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/srp/srp_lib.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2 * Copyright 2004-2018 The OpenSSL Project Authors. All Rights Reserved.-
3 * Copyright (c) 2004, EdelKey Project. All Rights Reserved.-
4 *-
5 * Licensed under the OpenSSL license (the "License"). You may not use-
6 * this file except in compliance with the License. You can obtain a copy-
7 * in the file LICENSE in the source distribution or at-
8 * https://www.openssl.org/source/license.html-
9 *-
10 * Originally written by Christophe Renou and Peter Sylvester,-
11 * for the EdelKey project.-
12 */-
13-
14#ifndef OPENSSL_NO_SRP-
15# include "internal/cryptlib.h"-
16# include <openssl/sha.h>-
17# include <openssl/srp.h>-
18# include <openssl/evp.h>-
19# include "internal/bn_srp.h"-
20-
21/* calculate = SHA1(PAD(x) || PAD(y)) */-
22-
23static BIGNUM *srp_Calc_xy(const BIGNUM *x, const BIGNUM *y, const BIGNUM *N)-
24{-
25 unsigned char digest[SHA_DIGEST_LENGTH];-
26 unsigned char *tmp = NULL;-
27 int numN = BN_num_bytes(N);-
28 BIGNUM *res = NULL;-
29 if (x != N && BN_ucmp(x, N) >= 0)
x != NDescription
TRUEevaluated 23 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 26 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
BN_ucmp(x, N) >= 0Description
TRUEnever evaluated
FALSEevaluated 23 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-26
30 return NULL;
never executed: return ((void *)0) ;
0
31 if (y != N && BN_ucmp(y, N) >= 0)
y != NDescription
TRUEevaluated 49 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
BN_ucmp(y, N) >= 0Description
TRUEnever evaluated
FALSEevaluated 49 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-49
32 return NULL;
never executed: return ((void *)0) ;
0
33 if ((tmp = OPENSSL_malloc(numN * 2)) == NULL)
(tmp = CRYPTO_...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 49 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-49
34 goto err;
never executed: goto err;
0
35 if (BN_bn2binpad(x, tmp, numN) < 0
BN_bn2binpad(x, tmp, numN) < 0Description
TRUEnever evaluated
FALSEevaluated 49 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-49
36 || BN_bn2binpad(y, tmp + numN, numN) < 0
BN_bn2binpad(y...umN, numN) < 0Description
TRUEnever evaluated
FALSEevaluated 49 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-49
37 || !EVP_Digest(tmp, numN * 2, digest, NULL, EVP_sha1(), NULL))
!EVP_Digest(tm... ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 49 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-49
38 goto err;
never executed: goto err;
0
39 res = BN_bin2bn(digest, sizeof(digest), NULL);-
40 err:
code before this statement executed 49 times by 1 test: err:
Executed by:
  • libcrypto.so.1.1
49
41 OPENSSL_free(tmp);-
42 return res;
executed 49 times by 1 test: return res;
Executed by:
  • libcrypto.so.1.1
49
43}-
44-
45static BIGNUM *srp_Calc_k(const BIGNUM *N, const BIGNUM *g)-
46{-
47 /* k = SHA1(N | PAD(g)) -- tls-srp draft 8 */-
48 return srp_Calc_xy(N, g, N);
executed 26 times by 1 test: return srp_Calc_xy(N, g, N);
Executed by:
  • libcrypto.so.1.1
26
49}-
50-
51BIGNUM *SRP_Calc_u(const BIGNUM *A, const BIGNUM *B, const BIGNUM *N)-
52{-
53 /* k = SHA1(PAD(A) || PAD(B) ) -- tls-srp draft 8 */-
54 return srp_Calc_xy(A, B, N);
executed 23 times by 1 test: return srp_Calc_xy(A, B, N);
Executed by:
  • libcrypto.so.1.1
23
55}-
56-
57BIGNUM *SRP_Calc_server_key(const BIGNUM *A, const BIGNUM *v, const BIGNUM *u,-
58 const BIGNUM *b, const BIGNUM *N)-
59{-
60 BIGNUM *tmp = NULL, *S = NULL;-
61 BN_CTX *bn_ctx;-
62-
63 if (u == NULL || A == NULL || v == NULL || b == NULL || N == NULL)
u == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
A == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
v == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
b == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
N == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-13
64 return NULL;
never executed: return ((void *)0) ;
0
65-
66 if ((bn_ctx = BN_CTX_new()) == NULL || (tmp = BN_new()) == NULL)
(bn_ctx = BN_C...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(tmp = BN_new(...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-13
67 goto err;
never executed: goto err;
0
68-
69 /* S = (A*v**u) ** b */-
70-
71 if (!BN_mod_exp(tmp, v, u, N, bn_ctx))
!BN_mod_exp(tm... u, N, bn_ctx)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-13
72 goto err;
never executed: goto err;
0
73 if (!BN_mod_mul(tmp, A, tmp, N, bn_ctx))
!BN_mod_mul(tm...mp, N, bn_ctx)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-13
74 goto err;
never executed: goto err;
0
75-
76 S = BN_new();-
77 if (S != NULL && !BN_mod_exp(S, tmp, b, N, bn_ctx)) {
S != ((void *)0)Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
!BN_mod_exp(S,... b, N, bn_ctx)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-13
78 BN_free(S);-
79 S = NULL;-
80 }
never executed: end of block
0
81 err:
code before this statement executed 13 times by 1 test: err:
Executed by:
  • libcrypto.so.1.1
13
82 BN_CTX_free(bn_ctx);-
83 BN_clear_free(tmp);-
84 return S;
executed 13 times by 1 test: return S;
Executed by:
  • libcrypto.so.1.1
13
85}-
86-
87BIGNUM *SRP_Calc_B(const BIGNUM *b, const BIGNUM *N, const BIGNUM *g,-
88 const BIGNUM *v)-
89{-
90 BIGNUM *kv = NULL, *gb = NULL;-
91 BIGNUM *B = NULL, *k = NULL;-
92 BN_CTX *bn_ctx;-
93-
94 if (b == NULL || N == NULL || g == NULL || v == NULL ||
b == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
N == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
g == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
v == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-13
95 (bn_ctx = BN_CTX_new()) == NULL)
(bn_ctx = BN_C...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-13
96 return NULL;
never executed: return ((void *)0) ;
0
97-
98 if ((kv = BN_new()) == NULL ||
(kv = BN_new()) == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-13
99 (gb = BN_new()) == NULL || (B = BN_new()) == NULL)
(gb = BN_new()) == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(B = BN_new()) == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-13
100 goto err;
never executed: goto err;
0
101-
102 /* B = g**b + k*v */-
103-
104 if (!BN_mod_exp(gb, g, b, N, bn_ctx)
!BN_mod_exp(gb... b, N, bn_ctx)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-13
105 || (k = srp_Calc_k(N, g)) == NULL
(k = srp_Calc_...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-13
106 || !BN_mod_mul(kv, v, k, N, bn_ctx)
!BN_mod_mul(kv... k, N, bn_ctx)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-13
107 || !BN_mod_add(B, gb, kv, N, bn_ctx)) {
!BN_mod_add(B,...kv, N, bn_ctx)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-13
108 BN_free(B);-
109 B = NULL;-
110 }
never executed: end of block
0
111 err:
code before this statement executed 13 times by 1 test: err:
Executed by:
  • libcrypto.so.1.1
13
112 BN_CTX_free(bn_ctx);-
113 BN_clear_free(kv);-
114 BN_clear_free(gb);-
115 BN_free(k);-
116 return B;
executed 13 times by 1 test: return B;
Executed by:
  • libcrypto.so.1.1
13
117}-
118-
119BIGNUM *SRP_Calc_x(const BIGNUM *s, const char *user, const char *pass)-
120{-
121 unsigned char dig[SHA_DIGEST_LENGTH];-
122 EVP_MD_CTX *ctxt;-
123 unsigned char *cs = NULL;-
124 BIGNUM *res = NULL;-
125-
126 if ((s == NULL) || (user == NULL) || (pass == NULL))
(s == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(user == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(pass == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-24
127 return NULL;
never executed: return ((void *)0) ;
0
128-
129 ctxt = EVP_MD_CTX_new();-
130 if (ctxt == NULL)
ctxt == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-24
131 return NULL;
never executed: return ((void *)0) ;
0
132 if ((cs = OPENSSL_malloc(BN_num_bytes(s))) == NULL)
(cs = CRYPTO_m...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-24
133 goto err;
never executed: goto err;
0
134-
135 if (!EVP_DigestInit_ex(ctxt, EVP_sha1(), NULL)
!EVP_DigestIni... ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-24
136 || !EVP_DigestUpdate(ctxt, user, strlen(user))
!EVP_DigestUpd... strlen(user))Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-24
137 || !EVP_DigestUpdate(ctxt, ":", 1)
!EVP_DigestUpd...(ctxt, ":", 1)Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-24
138 || !EVP_DigestUpdate(ctxt, pass, strlen(pass))
!EVP_DigestUpd... strlen(pass))Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-24
139 || !EVP_DigestFinal_ex(ctxt, dig, NULL)
!EVP_DigestFin... ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-24
140 || !EVP_DigestInit_ex(ctxt, EVP_sha1(), NULL))
!EVP_DigestIni... ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-24
141 goto err;
never executed: goto err;
0
142 BN_bn2bin(s, cs);-
143 if (!EVP_DigestUpdate(ctxt, cs, BN_num_bytes(s)))
!EVP_DigestUpd...bits(s)+7)/8))Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-24
144 goto err;
never executed: goto err;
0
145-
146 if (!EVP_DigestUpdate(ctxt, dig, sizeof(dig))
!EVP_DigestUpd..., sizeof(dig))Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-24
147 || !EVP_DigestFinal_ex(ctxt, dig, NULL))
!EVP_DigestFin... ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-24
148 goto err;
never executed: goto err;
0
149-
150 res = BN_bin2bn(dig, sizeof(dig), NULL);-
151-
152 err:
code before this statement executed 24 times by 1 test: err:
Executed by:
  • libcrypto.so.1.1
24
153 OPENSSL_free(cs);-
154 EVP_MD_CTX_free(ctxt);-
155 return res;
executed 24 times by 1 test: return res;
Executed by:
  • libcrypto.so.1.1
24
156}-
157-
158BIGNUM *SRP_Calc_A(const BIGNUM *a, const BIGNUM *N, const BIGNUM *g)-
159{-
160 BN_CTX *bn_ctx;-
161 BIGNUM *A = NULL;-
162-
163 if (a == NULL || N == NULL || g == NULL || (bn_ctx = BN_CTX_new()) == NULL)
a == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
N == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
g == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(bn_ctx = BN_C...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-13
164 return NULL;
never executed: return ((void *)0) ;
0
165-
166 if ((A = BN_new()) != NULL && !BN_mod_exp(A, g, a, N, bn_ctx)) {
(A = BN_new()) != ((void *)0)Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
!BN_mod_exp(A,... a, N, bn_ctx)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-13
167 BN_free(A);-
168 A = NULL;-
169 }
never executed: end of block
0
170 BN_CTX_free(bn_ctx);-
171 return A;
executed 13 times by 1 test: return A;
Executed by:
  • libcrypto.so.1.1
13
172}-
173-
174BIGNUM *SRP_Calc_client_key(const BIGNUM *N, const BIGNUM *B, const BIGNUM *g,-
175 const BIGNUM *x, const BIGNUM *a, const BIGNUM *u)-
176{-
177 BIGNUM *tmp = NULL, *tmp2 = NULL, *tmp3 = NULL, *k = NULL, *K = NULL;-
178 BN_CTX *bn_ctx;-
179-
180 if (u == NULL || B == NULL || N == NULL || g == NULL || x == NULL
u == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
B == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
N == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
g == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
x == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-13
181 || a == NULL || (bn_ctx = BN_CTX_new()) == NULL)
a == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(bn_ctx = BN_C...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-13
182 return NULL;
never executed: return ((void *)0) ;
0
183-
184 if ((tmp = BN_new()) == NULL ||
(tmp = BN_new(...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-13
185 (tmp2 = BN_new()) == NULL ||
(tmp2 = BN_new...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-13
186 (tmp3 = BN_new()) == NULL)
(tmp3 = BN_new...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-13
187 goto err;
never executed: goto err;
0
188-
189 if (!BN_mod_exp(tmp, g, x, N, bn_ctx))
!BN_mod_exp(tm... x, N, bn_ctx)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-13
190 goto err;
never executed: goto err;
0
191 if ((k = srp_Calc_k(N, g)) == NULL)
(k = srp_Calc_...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-13
192 goto err;
never executed: goto err;
0
193 if (!BN_mod_mul(tmp2, tmp, k, N, bn_ctx))
!BN_mod_mul(tm... k, N, bn_ctx)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-13
194 goto err;
never executed: goto err;
0
195 if (!BN_mod_sub(tmp, B, tmp2, N, bn_ctx))
!BN_mod_sub(tm...p2, N, bn_ctx)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-13
196 goto err;
never executed: goto err;
0
197 if (!BN_mul(tmp3, u, x, bn_ctx))
!BN_mul(tmp3, u, x, bn_ctx)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-13
198 goto err;
never executed: goto err;
0
199 if (!BN_add(tmp2, a, tmp3))
!BN_add(tmp2, a, tmp3)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-13
200 goto err;
never executed: goto err;
0
201 K = BN_new();-
202 if (K != NULL && !BN_mod_exp(K, tmp, tmp2, N, bn_ctx)) {
K != ((void *)0)Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
!BN_mod_exp(K,...p2, N, bn_ctx)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-13
203 BN_free(K);-
204 K = NULL;-
205 }
never executed: end of block
0
206-
207 err:
code before this statement executed 13 times by 1 test: err:
Executed by:
  • libcrypto.so.1.1
13
208 BN_CTX_free(bn_ctx);-
209 BN_clear_free(tmp);-
210 BN_clear_free(tmp2);-
211 BN_clear_free(tmp3);-
212 BN_free(k);-
213 return K;
executed 13 times by 1 test: return K;
Executed by:
  • libcrypto.so.1.1
13
214}-
215-
216int SRP_Verify_B_mod_N(const BIGNUM *B, const BIGNUM *N)-
217{-
218 BIGNUM *r;-
219 BN_CTX *bn_ctx;-
220 int ret = 0;-
221-
222 if (B == NULL || N == NULL || (bn_ctx = BN_CTX_new()) == NULL)
B == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 26 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
N == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 26 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(bn_ctx = BN_C...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 26 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-26
223 return 0;
never executed: return 0;
0
224-
225 if ((r = BN_new()) == NULL)
(r = BN_new()) == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 26 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-26
226 goto err;
never executed: goto err;
0
227 /* Checks if B % N == 0 */-
228 if (!BN_nnmod(r, B, N, bn_ctx))
!BN_nnmod(r, B, N, bn_ctx)Description
TRUEnever evaluated
FALSEevaluated 26 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-26
229 goto err;
never executed: goto err;
0
230 ret = !BN_is_zero(r);-
231 err:
code before this statement executed 26 times by 1 test: err:
Executed by:
  • libcrypto.so.1.1
26
232 BN_CTX_free(bn_ctx);-
233 BN_free(r);-
234 return ret;
executed 26 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
26
235}-
236-
237int SRP_Verify_A_mod_N(const BIGNUM *A, const BIGNUM *N)-
238{-
239 /* Checks if A % N == 0 */-
240 return SRP_Verify_B_mod_N(A, N);
executed 13 times by 1 test: return SRP_Verify_B_mod_N(A, N);
Executed by:
  • libcrypto.so.1.1
13
241}-
242-
243static SRP_gN knowngN[] = {-
244 {"8192", &bn_generator_19, &bn_group_8192},-
245 {"6144", &bn_generator_5, &bn_group_6144},-
246 {"4096", &bn_generator_5, &bn_group_4096},-
247 {"3072", &bn_generator_5, &bn_group_3072},-
248 {"2048", &bn_generator_2, &bn_group_2048},-
249 {"1536", &bn_generator_2, &bn_group_1536},-
250 {"1024", &bn_generator_2, &bn_group_1024},-
251};-
252-
253# define KNOWN_GN_NUMBER sizeof(knowngN) / sizeof(SRP_gN)-
254-
255/*-
256 * Check if G and N are known parameters. The values have been generated-
257 * from the ietf-tls-srp draft version 8-
258 */-
259char *SRP_check_known_gN_param(const BIGNUM *g, const BIGNUM *N)-
260{-
261 size_t i;-
262 if ((g == NULL) || (N == NULL))
(g == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(N == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-10
263 return 0;
never executed: return 0;
0
264-
265 for (i = 0; i < KNOWN_GN_NUMBER; i++) {
i < sizeof(kno...sizeof(SRP_gN)Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-26
266 if (BN_cmp(knowngN[i].g, g) == 0 && BN_cmp(knowngN[i].N, N) == 0)
BN_cmp(knowngN[i].g, g) == 0Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 16 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
BN_cmp(knowngN[i].N, N) == 0Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-16
267 return knowngN[i].id;
executed 10 times by 1 test: return knowngN[i].id;
Executed by:
  • libcrypto.so.1.1
10
268 }
executed 16 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
16
269 return NULL;
never executed: return ((void *)0) ;
0
270}-
271-
272SRP_gN *SRP_get_default_gN(const char *id)-
273{-
274 size_t i;-
275-
276 if (id == NULL)
id == ((void *)0)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 11 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
4-11
277 return knowngN;
executed 4 times by 1 test: return knowngN;
Executed by:
  • libcrypto.so.1.1
4
278 for (i = 0; i < KNOWN_GN_NUMBER; i++) {
i < sizeof(kno...sizeof(SRP_gN)Description
TRUEevaluated 45 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-45
279 if (strcmp(knowngN[i].id, id) == 0)
never executed: __result = (((const unsigned char *) (const char *) ( knowngN[i].id ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( id ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
__extension__ ... )))); }) == 0Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 34 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-34
280 return knowngN + i;
executed 11 times by 1 test: return knowngN + i;
Executed by:
  • libcrypto.so.1.1
11
281 }
executed 34 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
34
282 return NULL;
never executed: return ((void *)0) ;
0
283}-
284#endif-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2