OpenCoverage

srp_vfy.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/srp/srp_vfy.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 "internal/evp_int.h"-
17# include <openssl/sha.h>-
18# include <openssl/srp.h>-
19# include <openssl/evp.h>-
20# include <openssl/buffer.h>-
21# include <openssl/rand.h>-
22# include <openssl/txt_db.h>-
23# include <openssl/err.h>-
24-
25# define SRP_RANDOM_SALT_LEN 20-
26# define MAX_LEN 2500-
27-
28/*-
29 * Note that SRP uses its own variant of base 64 encoding. A different base64-
30 * alphabet is used and no padding '=' characters are added. Instead we pad to-
31 * the front with 0 bytes and subsequently strip off leading encoded padding.-
32 * This variant is used for compatibility with other SRP implementations --
33 * notably libsrp, but also others. It is also required for backwards-
34 * compatibility in order to load verifier files from other OpenSSL versions.-
35 */-
36-
37/*-
38 * Convert a base64 string into raw byte array representation.-
39 * Returns the length of the decoded data, or -1 on error.-
40 */-
41static int t_fromb64(unsigned char *a, size_t alen, const char *src)-
42{-
43 EVP_ENCODE_CTX *ctx;-
44 int outl = 0, outl2 = 0;-
45 size_t size, padsize;-
46 const unsigned char *pad = (const unsigned char *)"00";-
47-
48 while (*src == ' ' || *src == '\t' || *src == '\n')
*src == ' 'Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
*src == '\t'Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
*src == '\n'Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-8
49 ++src;
never executed: ++src;
0
50 size = strlen(src);-
51 padsize = 4 - (size & 3);-
52 padsize &= 3;-
53-
54 /* Four bytes in src become three bytes output. */-
55 if (size > INT_MAX || ((size + padsize) / 4) * 3 > alen)
size > 0x7fffffffDescription
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
((size + padsi... 4) * 3 > alenDescription
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-8
56 return -1;
never executed: return -1;
0
57-
58 ctx = EVP_ENCODE_CTX_new();-
59 if (ctx == NULL)
ctx == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-8
60 return -1;
never executed: return -1;
0
61-
62 /*-
63 * This should never occur because 1 byte of data always requires 2 bytes of-
64 * encoding, i.e.-
65 * 0 bytes unencoded = 0 bytes encoded-
66 * 1 byte unencoded = 2 bytes encoded-
67 * 2 bytes unencoded = 3 bytes encoded-
68 * 3 bytes unencoded = 4 bytes encoded-
69 * 4 bytes unencoded = 6 bytes encoded-
70 * etc-
71 */-
72 if (padsize == 3) {
padsize == 3Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-8
73 outl = -1;-
74 goto err;
never executed: goto err;
0
75 }-
76-
77 /* Valid padsize values are now 0, 1 or 2 */-
78-
79 EVP_DecodeInit(ctx);-
80 evp_encode_ctx_set_flags(ctx, EVP_ENCODE_CTX_USE_SRP_ALPHABET);-
81-
82 /* Add any encoded padding that is required */-
83 if (padsize != 0
padsize != 0Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-8
84 && EVP_DecodeUpdate(ctx, a, &outl, pad, padsize) < 0) {
EVP_DecodeUpda..., padsize) < 0Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-8
85 outl = -1;-
86 goto err;
never executed: goto err;
0
87 }-
88 if (EVP_DecodeUpdate(ctx, a, &outl2, (const unsigned char *)src, size) < 0) {
EVP_DecodeUpda...src, size) < 0Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-8
89 outl = -1;-
90 goto err;
never executed: goto err;
0
91 }-
92 outl += outl2;-
93 EVP_DecodeFinal(ctx, a + outl, &outl2);-
94 outl += outl2;-
95-
96 /* Strip off the leading padding */-
97 if (padsize != 0) {
padsize != 0Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-8
98 if ((int)padsize >= outl) {
(int)padsize >= outlDescription
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-8
99 outl = -1;-
100 goto err;
never executed: goto err;
0
101 }-
102-
103 /*-
104 * If we added 1 byte of padding prior to encoding then we have 2 bytes-
105 * of "real" data which gets spread across 4 encoded bytes like this:-
106 * (6 bits pad)(2 bits pad | 4 bits data)(6 bits data)(6 bits data)-
107 * So 1 byte of pre-encoding padding results in 1 full byte of encoded-
108 * padding.-
109 * If we added 2 bytes of padding prior to encoding this gets encoded-
110 * as:-
111 * (6 bits pad)(6 bits pad)(4 bits pad | 2 bits data)(6 bits data)-
112 * So 2 bytes of pre-encoding padding results in 2 full bytes of encoded-
113 * padding, i.e. we have to strip the same number of bytes of padding-
114 * from the encoded data as we added to the pre-encoded data.-
115 */-
116 memmove(a, a + padsize, outl - padsize);-
117 outl -= padsize;-
118 }
executed 8 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
8
119-
120 err:
code before this statement executed 8 times by 1 test: err:
Executed by:
  • libcrypto.so.1.1
8
121 EVP_ENCODE_CTX_free(ctx);-
122-
123 return outl;
executed 8 times by 1 test: return outl;
Executed by:
  • libcrypto.so.1.1
8
124}-
125-
126/*-
127 * Convert a raw byte string into a null-terminated base64 ASCII string.-
128 * Returns 1 on success or 0 on error.-
129 */-
130static int t_tob64(char *dst, const unsigned char *src, int size)-
131{-
132 EVP_ENCODE_CTX *ctx = EVP_ENCODE_CTX_new();-
133 int outl = 0, outl2 = 0;-
134 unsigned char pad[2] = {0, 0};-
135 size_t leadz = 0;-
136-
137 if (ctx == NULL)
ctx == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4
138 return 0;
never executed: return 0;
0
139-
140 EVP_EncodeInit(ctx);-
141 evp_encode_ctx_set_flags(ctx, EVP_ENCODE_CTX_NO_NEWLINES-
142 | EVP_ENCODE_CTX_USE_SRP_ALPHABET);-
143-
144 /*-
145 * We pad at the front with zero bytes until the length is a multiple of 3-
146 * so that EVP_EncodeUpdate/EVP_EncodeFinal does not add any of its own "="-
147 * padding-
148 */-
149 leadz = 3 - (size % 3);-
150 if (leadz != 3
leadz != 3Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-4
151 && !EVP_EncodeUpdate(ctx, (unsigned char *)dst, &outl, pad,
!EVP_EncodeUpd...l, pad, leadz)Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4
152 leadz)) {
!EVP_EncodeUpd...l, pad, leadz)Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4
153 EVP_ENCODE_CTX_free(ctx);-
154 return 0;
never executed: return 0;
0
155 }-
156-
157 if (!EVP_EncodeUpdate(ctx, (unsigned char *)dst + outl, &outl2, src,
!EVP_EncodeUpd...l2, src, size)Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4
158 size)) {
!EVP_EncodeUpd...l2, src, size)Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4
159 EVP_ENCODE_CTX_free(ctx);-
160 return 0;
never executed: return 0;
0
161 }-
162 outl += outl2;-
163 EVP_EncodeFinal(ctx, (unsigned char *)dst + outl, &outl2);-
164 outl += outl2;-
165-
166 /* Strip the encoded padding at the front */-
167 if (leadz != 3) {
leadz != 3Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-4
168 memmove(dst, dst + leadz, outl - leadz);-
169 dst[outl - leadz] = '\0';-
170 }
executed 4 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
4
171-
172 EVP_ENCODE_CTX_free(ctx);-
173 return 1;
executed 4 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
4
174}-
175-
176void SRP_user_pwd_free(SRP_user_pwd *user_pwd)-
177{-
178 if (user_pwd == NULL)
user_pwd == ((void *)0)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 12 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
6-12
179 return;
executed 6 times by 1 test: return;
Executed by:
  • libcrypto.so.1.1
6
180 BN_free(user_pwd->s);-
181 BN_clear_free(user_pwd->v);-
182 OPENSSL_free(user_pwd->id);-
183 OPENSSL_free(user_pwd->info);-
184 OPENSSL_free(user_pwd);-
185}
executed 12 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
12
186-
187static SRP_user_pwd *SRP_user_pwd_new(void)-
188{-
189 SRP_user_pwd *ret;-
190 -
191 if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL) {
(ret = CRYPTO_...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-10
192 /* SRPerr(SRP_F_SRP_USER_PWD_NEW, ERR_R_MALLOC_FAILURE); */ /*ckerr_ignore*/-
193 return NULL;
never executed: return ((void *)0) ;
0
194 }-
195 ret->N = NULL;-
196 ret->g = NULL;-
197 ret->s = NULL;-
198 ret->v = NULL;-
199 ret->id = NULL;-
200 ret->info = NULL;-
201 return ret;
executed 10 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
10
202}-
203-
204static void SRP_user_pwd_set_gN(SRP_user_pwd *vinfo, const BIGNUM *g,-
205 const BIGNUM *N)-
206{-
207 vinfo->N = N;-
208 vinfo->g = g;-
209}
executed 10 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
10
210-
211static int SRP_user_pwd_set_ids(SRP_user_pwd *vinfo, const char *id,-
212 const char *info)-
213{-
214 if (id != NULL && NULL == (vinfo->id = OPENSSL_strdup(id)))
id != ((void *)0)Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
((void *)0) ==..._FILE__, 214))Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-10
215 return 0;
never executed: return 0;
0
216 return (info == NULL || NULL != (vinfo->info = OPENSSL_strdup(info)));
executed 10 times by 1 test: return (info == ((void *)0) || ((void *)0) != (vinfo->info = CRYPTO_strdup(info, __FILE__, 216)));
Executed by:
  • libcrypto.so.1.1
info == ((void *)0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 8 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
((void *)0) !=..._FILE__, 216))Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-10
217}-
218-
219static int SRP_user_pwd_set_sv(SRP_user_pwd *vinfo, const char *s,-
220 const char *v)-
221{-
222 unsigned char tmp[MAX_LEN];-
223 int len;-
224-
225 vinfo->v = NULL;-
226 vinfo->s = NULL;-
227-
228 len = t_fromb64(tmp, sizeof(tmp), v);-
229 if (len < 0)
len < 0Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4
230 return 0;
never executed: return 0;
0
231 if (NULL == (vinfo->v = BN_bin2bn(tmp, len, NULL)))
((void *)0) ==...((void *)0) ))Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4
232 return 0;
never executed: return 0;
0
233 len = t_fromb64(tmp, sizeof(tmp), s);-
234 if (len < 0)
len < 0Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4
235 goto err;
never executed: goto err;
0
236 vinfo->s = BN_bin2bn(tmp, len, NULL);-
237 if (vinfo->s == NULL)
vinfo->s == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4
238 goto err;
never executed: goto err;
0
239 return 1;
executed 4 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
4
240 err:-
241 BN_free(vinfo->v);-
242 vinfo->v = NULL;-
243 return 0;
never executed: return 0;
0
244}-
245-
246static int SRP_user_pwd_set_sv_BN(SRP_user_pwd *vinfo, BIGNUM *s, BIGNUM *v)-
247{-
248 vinfo->v = v;-
249 vinfo->s = s;-
250 return (vinfo->s != NULL && vinfo->v != NULL);
executed 6 times by 1 test: return (vinfo->s != ((void *)0) && vinfo->v != ((void *)0) );
Executed by:
  • libcrypto.so.1.1
vinfo->s != ((void *)0)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
vinfo->v != ((void *)0)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-6
251}-
252-
253static SRP_user_pwd *srp_user_pwd_dup(SRP_user_pwd *src)-
254{-
255 SRP_user_pwd *ret;-
256-
257 if (src == NULL)
src == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-6
258 return NULL;
never executed: return ((void *)0) ;
0
259 if ((ret = SRP_user_pwd_new()) == NULL)
(ret = SRP_use...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-6
260 return NULL;
never executed: return ((void *)0) ;
0
261-
262 SRP_user_pwd_set_gN(ret, src->g, src->N);-
263 if (!SRP_user_pwd_set_ids(ret, src->id, src->info)
!SRP_user_pwd_...id, src->info)Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-6
264 || !SRP_user_pwd_set_sv_BN(ret, BN_dup(src->s), BN_dup(src->v))) {
!SRP_user_pwd_...N_dup(src->v))Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-6
265 SRP_user_pwd_free(ret);-
266 return NULL;
never executed: return ((void *)0) ;
0
267 }-
268 return ret;
executed 6 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
6
269}-
270-
271SRP_VBASE *SRP_VBASE_new(char *seed_key)-
272{-
273 SRP_VBASE *vb = OPENSSL_malloc(sizeof(*vb));-
274-
275 if (vb == NULL)
vb == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-6
276 return NULL;
never executed: return ((void *)0) ;
0
277 if ((vb->users_pwd = sk_SRP_user_pwd_new_null()) == NULL
(vb->users_pwd...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-6
278 || (vb->gN_cache = sk_SRP_gN_cache_new_null()) == NULL) {
(vb->gN_cache ...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-6
279 OPENSSL_free(vb);-
280 return NULL;
never executed: return ((void *)0) ;
0
281 }-
282 vb->default_g = NULL;-
283 vb->default_N = NULL;-
284 vb->seed_key = NULL;-
285 if ((seed_key != NULL) && (vb->seed_key = OPENSSL_strdup(seed_key)) == NULL) {
(seed_key != ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(vb->seed_key ...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0-6
286 sk_SRP_user_pwd_free(vb->users_pwd);-
287 sk_SRP_gN_cache_free(vb->gN_cache);-
288 OPENSSL_free(vb);-
289 return NULL;
never executed: return ((void *)0) ;
0
290 }-
291 return vb;
executed 6 times by 1 test: return vb;
Executed by:
  • libcrypto.so.1.1
6
292}-
293-
294void SRP_VBASE_free(SRP_VBASE *vb)-
295{-
296 if (!vb)
!vbDescription
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-6
297 return;
never executed: return;
0
298 sk_SRP_user_pwd_pop_free(vb->users_pwd, SRP_user_pwd_free);-
299 sk_SRP_gN_cache_free(vb->gN_cache);-
300 OPENSSL_free(vb->seed_key);-
301 OPENSSL_free(vb);-
302}
executed 6 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
6
303-
304static SRP_gN_cache *SRP_gN_new_init(const char *ch)-
305{-
306 unsigned char tmp[MAX_LEN];-
307 int len;-
308 SRP_gN_cache *newgN = OPENSSL_malloc(sizeof(*newgN));-
309-
310 if (newgN == NULL)
newgN == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
311 return NULL;
never executed: return ((void *)0) ;
0
312-
313 len = t_fromb64(tmp, sizeof(tmp), ch);-
314 if (len < 0)
len < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
315 goto err;
never executed: goto err;
0
316-
317 if ((newgN->b64_bn = OPENSSL_strdup(ch)) == NULL)
(newgN->b64_bn...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
318 goto err;
never executed: goto err;
0
319-
320 if ((newgN->bn = BN_bin2bn(tmp, len, NULL)))
(newgN->bn = B...((void *)0) ))Description
TRUEnever evaluated
FALSEnever evaluated
0
321 return newgN;
never executed: return newgN;
0
322-
323 OPENSSL_free(newgN->b64_bn);-
324 err:
code before this statement never executed: err:
0
325 OPENSSL_free(newgN);-
326 return NULL;
never executed: return ((void *)0) ;
0
327}-
328-
329static void SRP_gN_free(SRP_gN_cache *gN_cache)-
330{-
331 if (gN_cache == NULL)
gN_cache == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
332 return;
never executed: return;
0
333 OPENSSL_free(gN_cache->b64_bn);-
334 BN_free(gN_cache->bn);-
335 OPENSSL_free(gN_cache);-
336}
never executed: end of block
0
337-
338static SRP_gN *SRP_get_gN_by_id(const char *id, STACK_OF(SRP_gN) *gN_tab)-
339{-
340 int i;-
341-
342 SRP_gN *gN;-
343 if (gN_tab != NULL)
gN_tab != ((void *)0)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2-4
344 for (i = 0; i < sk_SRP_gN_num(gN_tab); i++) {
i < sk_SRP_gN_num(gN_tab)Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4
345 gN = sk_SRP_gN_value(gN_tab, i);-
346 if (gN && (id == NULL || strcmp(gN->id, id) == 0))
never executed: __result = (((const unsigned char *) (const char *) ( gN->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
gNDescription
TRUEnever evaluated
FALSEnever evaluated
id == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
__extension__ ... )))); }) == 0Description
TRUEnever evaluated
FALSEnever evaluated
__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
347 return gN;
never executed: return gN;
0
348 }
never executed: end of block
0
349-
350 return SRP_get_default_gN(id);
executed 6 times by 1 test: return SRP_get_default_gN(id);
Executed by:
  • libcrypto.so.1.1
6
351}-
352-
353static BIGNUM *SRP_gN_place_bn(STACK_OF(SRP_gN_cache) *gN_cache, char *ch)-
354{-
355 int i;-
356 if (gN_cache == NULL)
gN_cache == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
357 return NULL;
never executed: return ((void *)0) ;
0
358-
359 /* search if we have already one... */-
360 for (i = 0; i < sk_SRP_gN_cache_num(gN_cache); i++) {
i < sk_SRP_gN_..._num(gN_cache)Description
TRUEnever evaluated
FALSEnever evaluated
0
361 SRP_gN_cache *cache = sk_SRP_gN_cache_value(gN_cache, i);-
362 if (strcmp(cache->b64_bn, ch) == 0)
never executed: __result = (((const unsigned char *) (const char *) ( cache->b64_bn ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( ch ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
__extension__ ... )))); }) == 0Description
TRUEnever evaluated
FALSEnever evaluated
__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
363 return cache->bn;
never executed: return cache->bn;
0
364 }
never executed: end of block
0
365 { /* it is the first time that we find it */-
366 SRP_gN_cache *newgN = SRP_gN_new_init(ch);-
367 if (newgN) {
newgNDescription
TRUEnever evaluated
FALSEnever evaluated
0
368 if (sk_SRP_gN_cache_insert(gN_cache, newgN, 0) > 0)
sk_SRP_gN_cach... newgN, 0) > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
369 return newgN->bn;
never executed: return newgN->bn;
0
370 SRP_gN_free(newgN);-
371 }
never executed: end of block
0
372 }-
373 return NULL;
never executed: return ((void *)0) ;
0
374}-
375-
376/*-
377 * this function parses verifier file. Format is:-
378 * string(index):base64(N):base64(g):0-
379 * string(username):base64(v):base64(salt):int(index)-
380 */-
381-
382int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file)-
383{-
384 int error_code;-
385 STACK_OF(SRP_gN) *SRP_gN_tab = sk_SRP_gN_new_null();-
386 char *last_index = NULL;-
387 int i;-
388 char **pp;-
389-
390 SRP_gN *gN = NULL;-
391 SRP_user_pwd *user_pwd = NULL;-
392-
393 TXT_DB *tmpdb = NULL;-
394 BIO *in = BIO_new(BIO_s_file());-
395-
396 error_code = SRP_ERR_OPEN_FILE;-
397-
398 if (in == NULL || BIO_read_filename(in, verifier_file) <= 0)
in == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(int)BIO_ctrl(...er_file)) <= 0Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4
399 goto err;
never executed: goto err;
0
400-
401 error_code = SRP_ERR_VBASE_INCOMPLETE_FILE;-
402-
403 if ((tmpdb = TXT_DB_read(in, DB_NUMBER)) == NULL)
(tmpdb = TXT_D...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4
404 goto err;
never executed: goto err;
0
405-
406 error_code = SRP_ERR_MEMORY;-
407-
408 if (vb->seed_key) {
vb->seed_keyDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4
409 last_index = SRP_get_default_gN(NULL)->id;-
410 }
never executed: end of block
0
411 for (i = 0; i < sk_OPENSSL_PSTRING_num(tmpdb->data); i++) {
i < sk_OPENSSL...m(tmpdb->data)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
4
412 pp = sk_OPENSSL_PSTRING_value(tmpdb->data, i);-
413 if (pp[DB_srptype][0] == DB_SRP_INDEX) {
pp[0][0] == 'I'Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4
414 /*-
415 * we add this couple in the internal Stack-
416 */-
417-
418 if ((gN = OPENSSL_malloc(sizeof(*gN))) == NULL)
(gN = CRYPTO_m...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
419 goto err;
never executed: goto err;
0
420-
421 if ((gN->id = OPENSSL_strdup(pp[DB_srpid])) == NULL
(gN->id = CRYP...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
422 || (gN->N = SRP_gN_place_bn(vb->gN_cache, pp[DB_srpverifier]))
(gN->N = SRP_g...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
423 == NULL
(gN->N = SRP_g...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
424 || (gN->g = SRP_gN_place_bn(vb->gN_cache, pp[DB_srpsalt]))
(gN->g = SRP_g...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
425 == NULL
(gN->g = SRP_g...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
426 || sk_SRP_gN_insert(SRP_gN_tab, gN, 0) == 0)
sk_SRP_gN_inse...b, gN, 0) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
427 goto err;
never executed: goto err;
0
428-
429 gN = NULL;-
430-
431 if (vb->seed_key != NULL) {
vb->seed_key != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
432 last_index = pp[DB_srpid];-
433 }
never executed: end of block
0
434 } else if (pp[DB_srptype][0] == DB_SRP_VALID) {
never executed: end of block
pp[0][0] == 'V'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-4
435 /* it is a user .... */-
436 const SRP_gN *lgN;-
437-
438 if ((lgN = SRP_get_gN_by_id(pp[DB_srpgN], SRP_gN_tab)) != NULL) {
(lgN = SRP_get...!= ((void *)0)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-4
439 error_code = SRP_ERR_MEMORY;-
440 if ((user_pwd = SRP_user_pwd_new()) == NULL)
(user_pwd = SR...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4
441 goto err;
never executed: goto err;
0
442-
443 SRP_user_pwd_set_gN(user_pwd, lgN->g, lgN->N);-
444 if (!SRP_user_pwd_set_ids
!SRP_user_pwd_... pp[3], pp[5])Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4
445 (user_pwd, pp[DB_srpid], pp[DB_srpinfo]))
!SRP_user_pwd_... pp[3], pp[5])Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4
446 goto err;
never executed: goto err;
0
447-
448 error_code = SRP_ERR_VBASE_BN_LIB;-
449 if (!SRP_user_pwd_set_sv
!SRP_user_pwd_... pp[2], pp[1])Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4
450 (user_pwd, pp[DB_srpsalt], pp[DB_srpverifier]))
!SRP_user_pwd_... pp[2], pp[1])Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4
451 goto err;
never executed: goto err;
0
452-
453 if (sk_SRP_user_pwd_insert(vb->users_pwd, user_pwd, 0) == 0)
sk_SRP_user_pw...r_pwd, 0) == 0Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4
454 goto err;
never executed: goto err;
0
455 user_pwd = NULL; /* abandon responsibility */-
456 }
executed 4 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
4
457 }
executed 4 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
4
458 }
executed 4 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
4
459-
460 if (last_index != NULL) {
last_index != ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4
461 /* this means that we want to simulate a default user */-
462-
463 if (((gN = SRP_get_gN_by_id(last_index, SRP_gN_tab)) == NULL)) {
((gN = SRP_get... ((void *)0) )Description
TRUEnever evaluated
FALSEnever evaluated
0
464 error_code = SRP_ERR_VBASE_BN_LIB;-
465 goto err;
never executed: goto err;
0
466 }-
467 vb->default_g = gN->g;-
468 vb->default_N = gN->N;-
469 gN = NULL;-
470 }
never executed: end of block
0
471 error_code = SRP_NO_ERROR;-
472-
473 err:
code before this statement executed 4 times by 1 test: err:
Executed by:
  • libcrypto.so.1.1
4
474 /*-
475 * there may be still some leaks to fix, if this fails, the application-
476 * terminates most likely-
477 */-
478-
479 if (gN != NULL) {
gN != ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4
480 OPENSSL_free(gN->id);-
481 OPENSSL_free(gN);-
482 }
never executed: end of block
0
483-
484 SRP_user_pwd_free(user_pwd);-
485-
486 TXT_DB_free(tmpdb);-
487 BIO_free_all(in);-
488-
489 sk_SRP_gN_free(SRP_gN_tab);-
490-
491 return error_code;
executed 4 times by 1 test: return error_code;
Executed by:
  • libcrypto.so.1.1
4
492-
493}-
494-
495static SRP_user_pwd *find_user(SRP_VBASE *vb, char *username)-
496{-
497 int i;-
498 SRP_user_pwd *user;-
499-
500 if (vb == NULL)
vb == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-6
501 return NULL;
never executed: return ((void *)0) ;
0
502-
503 for (i = 0; i < sk_SRP_user_pwd_num(vb->users_pwd); i++) {
i < sk_SRP_use...vb->users_pwd)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-6
504 user = sk_SRP_user_pwd_value(vb->users_pwd, i);-
505 if (strcmp(user->id, username) == 0)
never executed: __result = (((const unsigned char *) (const char *) ( user->id ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( username ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
__extension__ ... )))); }) == 0Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
__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-6
506 return user;
executed 6 times by 1 test: return user;
Executed by:
  • libcrypto.so.1.1
6
507 }
never executed: end of block
0
508-
509 return NULL;
never executed: return ((void *)0) ;
0
510}-
511-
512# if OPENSSL_API_COMPAT < 0x10100000L-
513/*-
514 * DEPRECATED: use SRP_VBASE_get1_by_user instead.-
515 * This method ignores the configured seed and fails for an unknown user.-
516 * Ownership of the returned pointer is not released to the caller.-
517 * In other words, caller must not free the result.-
518 */-
519SRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username)-
520{-
521 return find_user(vb, username);
never executed: return find_user(vb, username);
0
522}-
523# endif-
524-
525/*-
526 * Ownership of the returned pointer is released to the caller.-
527 * In other words, caller must free the result once done.-
528 */-
529SRP_user_pwd *SRP_VBASE_get1_by_user(SRP_VBASE *vb, char *username)-
530{-
531 SRP_user_pwd *user;-
532 unsigned char digv[SHA_DIGEST_LENGTH];-
533 unsigned char digs[SHA_DIGEST_LENGTH];-
534 EVP_MD_CTX *ctxt = NULL;-
535-
536 if (vb == NULL)
vb == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-6
537 return NULL;
never executed: return ((void *)0) ;
0
538-
539 if ((user = find_user(vb, username)) != NULL)
(user = find_u...!= ((void *)0)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-6
540 return srp_user_pwd_dup(user);
executed 6 times by 1 test: return srp_user_pwd_dup(user);
Executed by:
  • libcrypto.so.1.1
6
541-
542 if ((vb->seed_key == NULL) ||
(vb->seed_key == ((void *)0) )Description
TRUEnever evaluated
FALSEnever evaluated
0
543 (vb->default_g == NULL) || (vb->default_N == NULL))
(vb->default_g... ((void *)0) )Description
TRUEnever evaluated
FALSEnever evaluated
(vb->default_N... ((void *)0) )Description
TRUEnever evaluated
FALSEnever evaluated
0
544 return NULL;
never executed: return ((void *)0) ;
0
545-
546/* if the user is unknown we set parameters as well if we have a seed_key */-
547-
548 if ((user = SRP_user_pwd_new()) == NULL)
(user = SRP_us...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
549 return NULL;
never executed: return ((void *)0) ;
0
550-
551 SRP_user_pwd_set_gN(user, vb->default_g, vb->default_N);-
552-
553 if (!SRP_user_pwd_set_ids(user, username, NULL))
!SRP_user_pwd_... ((void *)0) )Description
TRUEnever evaluated
FALSEnever evaluated
0
554 goto err;
never executed: goto err;
0
555-
556 if (RAND_priv_bytes(digv, SHA_DIGEST_LENGTH) <= 0)
RAND_priv_bytes(digv, 20) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
557 goto err;
never executed: goto err;
0
558 ctxt = EVP_MD_CTX_new();-
559 if (ctxt == NULL
ctxt == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
560 || !EVP_DigestInit_ex(ctxt, EVP_sha1(), NULL)
!EVP_DigestIni... ((void *)0) )Description
TRUEnever evaluated
FALSEnever evaluated
0
561 || !EVP_DigestUpdate(ctxt, vb->seed_key, strlen(vb->seed_key))
!EVP_DigestUpd...vb->seed_key))Description
TRUEnever evaluated
FALSEnever evaluated
0
562 || !EVP_DigestUpdate(ctxt, username, strlen(username))
!EVP_DigestUpd...len(username))Description
TRUEnever evaluated
FALSEnever evaluated
0
563 || !EVP_DigestFinal_ex(ctxt, digs, NULL))
!EVP_DigestFin... ((void *)0) )Description
TRUEnever evaluated
FALSEnever evaluated
0
564 goto err;
never executed: goto err;
0
565 EVP_MD_CTX_free(ctxt);-
566 ctxt = NULL;-
567 if (SRP_user_pwd_set_sv_BN(user,
SRP_user_pwd_s...((void *)0) ))Description
TRUEnever evaluated
FALSEnever evaluated
0
568 BN_bin2bn(digs, SHA_DIGEST_LENGTH, NULL),
SRP_user_pwd_s...((void *)0) ))Description
TRUEnever evaluated
FALSEnever evaluated
0
569 BN_bin2bn(digv, SHA_DIGEST_LENGTH, NULL)))
SRP_user_pwd_s...((void *)0) ))Description
TRUEnever evaluated
FALSEnever evaluated
0
570 return user;
never executed: return user;
0
571-
572 err:
code before this statement never executed: err:
0
573 EVP_MD_CTX_free(ctxt);-
574 SRP_user_pwd_free(user);-
575 return NULL;
never executed: return ((void *)0) ;
0
576}-
577-
578/*-
579 * create a verifier (*salt,*verifier,g and N are in base64)-
580 */-
581char *SRP_create_verifier(const char *user, const char *pass, char **salt,-
582 char **verifier, const char *N, const char *g)-
583{-
584 int len;-
585 char *result = NULL, *vf = NULL;-
586 const BIGNUM *N_bn = NULL, *g_bn = NULL;-
587 BIGNUM *N_bn_alloc = NULL, *g_bn_alloc = NULL, *s = NULL, *v = NULL;-
588 unsigned char tmp[MAX_LEN];-
589 unsigned char tmp2[MAX_LEN];-
590 char *defgNid = NULL;-
591 int vfsize = 0;-
592-
593 if ((user == NULL) ||
(user == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2
594 (pass == NULL) || (salt == NULL) || (verifier == NULL))
(pass == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(salt == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(verifier == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2
595 goto err;
never executed: goto err;
0
596-
597 if (N) {
NDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2
598 if ((len = t_fromb64(tmp, sizeof(tmp), N)) <= 0)
(len = t_fromb...tmp), N)) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
599 goto err;
never executed: goto err;
0
600 N_bn_alloc = BN_bin2bn(tmp, len, NULL);-
601 N_bn = N_bn_alloc;-
602 if ((len = t_fromb64(tmp, sizeof(tmp) ,g)) <= 0)
(len = t_fromb...tmp) ,g)) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
603 goto err;
never executed: goto err;
0
604 g_bn_alloc = BN_bin2bn(tmp, len, NULL);-
605 g_bn = g_bn_alloc;-
606 defgNid = "*";-
607 } else {
never executed: end of block
0
608 SRP_gN *gN = SRP_get_gN_by_id(g, NULL);-
609 if (gN == NULL)
gN == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2
610 goto err;
never executed: goto err;
0
611 N_bn = gN->N;-
612 g_bn = gN->g;-
613 defgNid = gN->id;-
614 }
executed 2 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
2
615-
616 if (*salt == NULL) {
*salt == ((void *)0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-2
617 if (RAND_bytes(tmp2, SRP_RANDOM_SALT_LEN) <= 0)
RAND_bytes(tmp2, 20) <= 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2
618 goto err;
never executed: goto err;
0
619-
620 s = BN_bin2bn(tmp2, SRP_RANDOM_SALT_LEN, NULL);-
621 } else {
executed 2 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
2
622 if ((len = t_fromb64(tmp2, sizeof(tmp2), *salt)) <= 0)
(len = t_fromb..., *salt)) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
623 goto err;
never executed: goto err;
0
624 s = BN_bin2bn(tmp2, len, NULL);-
625 }
never executed: end of block
0
626-
627 if (!SRP_create_verifier_BN(user, pass, &s, &v, N_bn, g_bn))
!SRP_create_ve...v, N_bn, g_bn)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2
628 goto err;
never executed: goto err;
0
629-
630 BN_bn2bin(v, tmp);-
631 vfsize = BN_num_bytes(v) * 2;-
632 if (((vf = OPENSSL_malloc(vfsize)) == NULL))
((vf = CRYPTO_... ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2
633 goto err;
never executed: goto err;
0
634 t_tob64(vf, tmp, BN_num_bytes(v));-
635-
636 if (*salt == NULL) {
*salt == ((void *)0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-2
637 char *tmp_salt;-
638-
639 if ((tmp_salt = OPENSSL_malloc(SRP_RANDOM_SALT_LEN * 2)) == NULL) {
(tmp_salt = CR...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2
640 goto err;
never executed: goto err;
0
641 }-
642 t_tob64(tmp_salt, tmp2, SRP_RANDOM_SALT_LEN);-
643 *salt = tmp_salt;-
644 }
executed 2 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
2
645-
646 *verifier = vf;-
647 vf = NULL;-
648 result = defgNid;-
649-
650 err:
code before this statement executed 2 times by 1 test: err:
Executed by:
  • libcrypto.so.1.1
2
651 BN_free(N_bn_alloc);-
652 BN_free(g_bn_alloc);-
653 OPENSSL_clear_free(vf, vfsize);-
654 BN_clear_free(s);-
655 BN_clear_free(v);-
656 return result;
executed 2 times by 1 test: return result;
Executed by:
  • libcrypto.so.1.1
2
657}-
658-
659/*-
660 * create a verifier (*salt,*verifier,g and N are BIGNUMs). If *salt != NULL-
661 * then the provided salt will be used. On successful exit *verifier will point-
662 * to a newly allocated BIGNUM containing the verifier and (if a salt was not-
663 * provided) *salt will be populated with a newly allocated BIGNUM containing a-
664 * random salt.-
665 * The caller is responsible for freeing the allocated *salt and *verifier-
666 * BIGNUMS.-
667 */-
668int SRP_create_verifier_BN(const char *user, const char *pass, BIGNUM **salt,-
669 BIGNUM **verifier, const BIGNUM *N,-
670 const BIGNUM *g)-
671{-
672 int result = 0;-
673 BIGNUM *x = NULL;-
674 BN_CTX *bn_ctx = BN_CTX_new();-
675 unsigned char tmp2[MAX_LEN];-
676 BIGNUM *salttmp = NULL;-
677-
678 if ((user == NULL) ||
(user == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 11 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-11
679 (pass == NULL) ||
(pass == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 11 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-11
680 (salt == NULL) ||
(salt == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 11 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-11
681 (verifier == NULL) || (N == NULL) || (g == NULL) || (bn_ctx == NULL))
(verifier == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 11 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(N == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 11 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(g == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 11 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(bn_ctx == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 11 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-11
682 goto err;
never executed: goto err;
0
683-
684 if (*salt == NULL) {
*salt == ((void *)0)Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
3-8
685 if (RAND_bytes(tmp2, SRP_RANDOM_SALT_LEN) <= 0)
RAND_bytes(tmp2, 20) <= 0Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-8
686 goto err;
never executed: goto err;
0
687-
688 salttmp = BN_bin2bn(tmp2, SRP_RANDOM_SALT_LEN, NULL);-
689 } else {
executed 8 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
8
690 salttmp = *salt;-
691 }
executed 3 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
3
692-
693 x = SRP_Calc_x(salttmp, user, pass);-
694-
695 *verifier = BN_new();-
696 if (*verifier == NULL)
*verifier == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 11 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-11
697 goto err;
never executed: goto err;
0
698-
699 if (!BN_mod_exp(*verifier, g, x, N, bn_ctx)) {
!BN_mod_exp(*v... x, N, bn_ctx)Description
TRUEnever evaluated
FALSEevaluated 11 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-11
700 BN_clear_free(*verifier);-
701 goto err;
never executed: goto err;
0
702 }-
703-
704 result = 1;-
705 *salt = salttmp;-
706-
707 err:
code before this statement executed 11 times by 1 test: err:
Executed by:
  • libcrypto.so.1.1
11
708 if (salt != NULL && *salt != salttmp)
salt != ((void *)0)Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
*salt != salttmpDescription
TRUEnever evaluated
FALSEevaluated 11 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-11
709 BN_clear_free(salttmp);
never executed: BN_clear_free(salttmp);
0
710 BN_clear_free(x);-
711 BN_CTX_free(bn_ctx);-
712 return result;
executed 11 times by 1 test: return result;
Executed by:
  • libcrypto.so.1.1
11
713}-
714-
715#endif-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2