OpenCoverage

ecp_oct.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/ec/ecp_oct.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2 * Copyright 2011-2018 The OpenSSL Project Authors. All Rights Reserved.-
3 * Copyright (c) 2002, Oracle and/or its affiliates. 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-
11#include <openssl/err.h>-
12#include <openssl/symhacks.h>-
13-
14#include "ec_lcl.h"-
15-
16int ec_GFp_simple_set_compressed_coordinates(const EC_GROUP *group,-
17 EC_POINT *point,-
18 const BIGNUM *x_, int y_bit,-
19 BN_CTX *ctx)-
20{-
21 BN_CTX *new_ctx = NULL;-
22 BIGNUM *tmp1, *tmp2, *x, *y;-
23 int ret = 0;-
24-
25 /* clear error queue */-
26 ERR_clear_error();-
27-
28 if (ctx == NULL) {
ctx == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 4526 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4526
29 ctx = new_ctx = BN_CTX_new();-
30 if (ctx == NULL)
ctx == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
31 return 0;
never executed: return 0;
0
32 }
never executed: end of block
0
33-
34 y_bit = (y_bit != 0);-
35-
36 BN_CTX_start(ctx);-
37 tmp1 = BN_CTX_get(ctx);-
38 tmp2 = BN_CTX_get(ctx);-
39 x = BN_CTX_get(ctx);-
40 y = BN_CTX_get(ctx);-
41 if (y == NULL)
y == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 4526 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4526
42 goto err;
never executed: goto err;
0
43-
44 /*--
45 * Recover y. We have a Weierstrass equation-
46 * y^2 = x^3 + a*x + b,-
47 * so y is one of the square roots of x^3 + a*x + b.-
48 */-
49-
50 /* tmp1 := x^3 */-
51 if (!BN_nnmod(x, x_, group->field, ctx))
!BN_nnmod(x, x...p->field, ctx)Description
TRUEnever evaluated
FALSEevaluated 4526 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4526
52 goto err;
never executed: goto err;
0
53 if (group->meth->field_decode == 0) {
group->meth->field_decode == 0Description
TRUEnever evaluated
FALSEevaluated 4526 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4526
54 /* field_{sqr,mul} work on standard representation */-
55 if (!group->meth->field_sqr(group, tmp2, x_, ctx))
!group->meth->...tmp2, x_, ctx)Description
TRUEnever evaluated
FALSEnever evaluated
0
56 goto err;
never executed: goto err;
0
57 if (!group->meth->field_mul(group, tmp1, tmp2, x_, ctx))
!group->meth->...tmp2, x_, ctx)Description
TRUEnever evaluated
FALSEnever evaluated
0
58 goto err;
never executed: goto err;
0
59 } else {
never executed: end of block
0
60 if (!BN_mod_sqr(tmp2, x_, group->field, ctx))
!BN_mod_sqr(tm...p->field, ctx)Description
TRUEnever evaluated
FALSEevaluated 4526 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4526
61 goto err;
never executed: goto err;
0
62 if (!BN_mod_mul(tmp1, tmp2, x_, group->field, ctx))
!BN_mod_mul(tm...p->field, ctx)Description
TRUEnever evaluated
FALSEevaluated 4526 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4526
63 goto err;
never executed: goto err;
0
64 }
executed 4526 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
4526
65-
66 /* tmp1 := tmp1 + a*x */-
67 if (group->a_is_minus3) {
group->a_is_minus3Description
TRUEevaluated 3739 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 787 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
787-3739
68 if (!BN_mod_lshift1_quick(tmp2, x, group->field))
!BN_mod_lshift... group->field)Description
TRUEnever evaluated
FALSEevaluated 3739 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3739
69 goto err;
never executed: goto err;
0
70 if (!BN_mod_add_quick(tmp2, tmp2, x, group->field))
!BN_mod_add_qu... group->field)Description
TRUEnever evaluated
FALSEevaluated 3739 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3739
71 goto err;
never executed: goto err;
0
72 if (!BN_mod_sub_quick(tmp1, tmp1, tmp2, group->field))
!BN_mod_sub_qu... group->field)Description
TRUEnever evaluated
FALSEevaluated 3739 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3739
73 goto err;
never executed: goto err;
0
74 } else {
executed 3739 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
3739
75 if (group->meth->field_decode) {
group->meth->field_decodeDescription
TRUEevaluated 787 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-787
76 if (!group->meth->field_decode(group, tmp2, group->a, ctx))
!group->meth->...group->a, ctx)Description
TRUEnever evaluated
FALSEevaluated 787 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-787
77 goto err;
never executed: goto err;
0
78 if (!BN_mod_mul(tmp2, tmp2, x, group->field, ctx))
!BN_mod_mul(tm...p->field, ctx)Description
TRUEnever evaluated
FALSEevaluated 787 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-787
79 goto err;
never executed: goto err;
0
80 } else {
executed 787 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
787
81 /* field_mul works on standard representation */-
82 if (!group->meth->field_mul(group, tmp2, group->a, x, ctx))
!group->meth->...up->a, x, ctx)Description
TRUEnever evaluated
FALSEnever evaluated
0
83 goto err;
never executed: goto err;
0
84 }
never executed: end of block
0
85-
86 if (!BN_mod_add_quick(tmp1, tmp1, tmp2, group->field))
!BN_mod_add_qu... group->field)Description
TRUEnever evaluated
FALSEevaluated 787 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-787
87 goto err;
never executed: goto err;
0
88 }
executed 787 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
787
89-
90 /* tmp1 := tmp1 + b */-
91 if (group->meth->field_decode) {
group->meth->field_decodeDescription
TRUEevaluated 4526 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-4526
92 if (!group->meth->field_decode(group, tmp2, group->b, ctx))
!group->meth->...group->b, ctx)Description
TRUEnever evaluated
FALSEevaluated 4526 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4526
93 goto err;
never executed: goto err;
0
94 if (!BN_mod_add_quick(tmp1, tmp1, tmp2, group->field))
!BN_mod_add_qu... group->field)Description
TRUEnever evaluated
FALSEevaluated 4526 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4526
95 goto err;
never executed: goto err;
0
96 } else {
executed 4526 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
4526
97 if (!BN_mod_add_quick(tmp1, tmp1, group->b, group->field))
!BN_mod_add_qu... group->field)Description
TRUEnever evaluated
FALSEnever evaluated
0
98 goto err;
never executed: goto err;
0
99 }
never executed: end of block
0
100-
101 if (!BN_mod_sqrt(y, tmp1, group->field, ctx)) {
!BN_mod_sqrt(y...p->field, ctx)Description
TRUEevaluated 1279 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3247 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1279-3247
102 unsigned long err = ERR_peek_last_error();-
103-
104 if (ERR_GET_LIB(err) == ERR_LIB_BN
(int)(((err) >...& 0x0FFL) == 3Description
TRUEevaluated 1279 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-1279
105 && ERR_GET_REASON(err) == BN_R_NOT_A_SQUARE) {
(int)( (err) & 0xFFFL) == 111Description
TRUEevaluated 1265 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 14 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
14-1265
106 ERR_clear_error();-
107 ECerr(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES,-
108 EC_R_INVALID_COMPRESSED_POINT);-
109 } else
executed 1265 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1265
110 ECerr(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES,
executed 14 times by 1 test: ERR_put_error(16,(169),(3),__FILE__,111) ;
Executed by:
  • libcrypto.so.1.1
14
111 ERR_R_BN_LIB);
executed 14 times by 1 test: ERR_put_error(16,(169),(3),__FILE__,111) ;
Executed by:
  • libcrypto.so.1.1
14
112 goto err;
executed 1279 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
1279
113 }-
114-
115 if (y_bit != BN_is_odd(y)) {
y_bit != BN_is_odd(y)Description
TRUEevaluated 1477 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1770 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1477-1770
116 if (BN_is_zero(y)) {
BN_is_zero(y)Description
TRUEnever evaluated
FALSEevaluated 1477 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1477
117 int kron;-
118-
119 kron = BN_kronecker(x, group->field, ctx);-
120 if (kron == -2)
kron == -2Description
TRUEnever evaluated
FALSEnever evaluated
0
121 goto err;
never executed: goto err;
0
122-
123 if (kron == 1)
kron == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
124 ECerr(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES,
never executed: ERR_put_error(16,(169),(109),__FILE__,125) ;
0
125 EC_R_INVALID_COMPRESSION_BIT);
never executed: ERR_put_error(16,(169),(109),__FILE__,125) ;
0
126 else-
127 /*-
128 * BN_mod_sqrt() should have caught this error (not a square)-
129 */-
130 ECerr(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES,
never executed: ERR_put_error(16,(169),(110),__FILE__,131) ;
0
131 EC_R_INVALID_COMPRESSED_POINT);
never executed: ERR_put_error(16,(169),(110),__FILE__,131) ;
0
132 goto err;
never executed: goto err;
0
133 }-
134 if (!BN_usub(y, group->field, y))
!BN_usub(y, group->field, y)Description
TRUEnever evaluated
FALSEevaluated 1477 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1477
135 goto err;
never executed: goto err;
0
136 }
executed 1477 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1477
137 if (y_bit != BN_is_odd(y)) {
y_bit != BN_is_odd(y)Description
TRUEnever evaluated
FALSEevaluated 3247 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3247
138 ECerr(EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES,-
139 ERR_R_INTERNAL_ERROR);-
140 goto err;
never executed: goto err;
0
141 }-
142-
143 if (!EC_POINT_set_affine_coordinates(group, point, x, y, ctx))
!EC_POINT_set_...nt, x, y, ctx)Description
TRUEnever evaluated
FALSEevaluated 3247 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3247
144 goto err;
never executed: goto err;
0
145-
146 ret = 1;-
147-
148 err:
code before this statement executed 3247 times by 1 test: err:
Executed by:
  • libcrypto.so.1.1
3247
149 BN_CTX_end(ctx);-
150 BN_CTX_free(new_ctx);-
151 return ret;
executed 4526 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
4526
152}-
153-
154size_t ec_GFp_simple_point2oct(const EC_GROUP *group, const EC_POINT *point,-
155 point_conversion_form_t form,-
156 unsigned char *buf, size_t len, BN_CTX *ctx)-
157{-
158 size_t ret;-
159 BN_CTX *new_ctx = NULL;-
160 int used_ctx = 0;-
161 BIGNUM *x, *y;-
162 size_t field_len, i, skip;-
163-
164 if ((form != POINT_CONVERSION_COMPRESSED)
(form != POINT...ON_COMPRESSED)Description
TRUEevaluated 41437 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 217 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
217-41437
165 && (form != POINT_CONVERSION_UNCOMPRESSED)
(form != POINT..._UNCOMPRESSED)Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 41425 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
12-41425
166 && (form != POINT_CONVERSION_HYBRID)) {
(form != POINT...ERSION_HYBRID)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 11 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1-11
167 ECerr(EC_F_EC_GFP_SIMPLE_POINT2OCT, EC_R_INVALID_FORM);-
168 goto err;
executed 1 time by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
1
169 }-
170-
171 if (EC_POINT_is_at_infinity(group, point)) {
EC_POINT_is_at...(group, point)Description
TRUEevaluated 28 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 41625 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
28-41625
172 /* encodes to a single 0 octet */-
173 if (buf != NULL) {
buf != ((void *)0)Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 14 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
14
174 if (len < 1) {
len < 1Description
TRUEnever evaluated
FALSEevaluated 14 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-14
175 ECerr(EC_F_EC_GFP_SIMPLE_POINT2OCT, EC_R_BUFFER_TOO_SMALL);-
176 return 0;
never executed: return 0;
0
177 }-
178 buf[0] = 0;-
179 }
executed 14 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
14
180 return 1;
executed 28 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
28
181 }-
182-
183 /* ret := required output buffer length */-
184 field_len = BN_num_bytes(group->field);-
185 ret =-
186 (form ==
(form == POINT...ON_COMPRESSED)Description
TRUEevaluated 217 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 41408 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
217-41408
187 POINT_CONVERSION_COMPRESSED) ? 1 + field_len : 1 + 2 * field_len;
(form == POINT...ON_COMPRESSED)Description
TRUEevaluated 217 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 41408 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
217-41408
188-
189 /* if 'buf' is NULL, just return required length */-
190 if (buf != NULL) {
buf != ((void *)0)Description
TRUEevaluated 14268 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 27357 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
14268-27357
191 if (len < ret) {
len < retDescription
TRUEnever evaluated
FALSEevaluated 14268 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-14268
192 ECerr(EC_F_EC_GFP_SIMPLE_POINT2OCT, EC_R_BUFFER_TOO_SMALL);-
193 goto err;
never executed: goto err;
0
194 }-
195-
196 if (ctx == NULL) {
ctx == ((void *)0)Description
TRUEevaluated 14220 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 48 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
48-14220
197 ctx = new_ctx = BN_CTX_new();-
198 if (ctx == NULL)
ctx == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 14220 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-14220
199 return 0;
never executed: return 0;
0
200 }
executed 14220 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
14220
201-
202 BN_CTX_start(ctx);-
203 used_ctx = 1;-
204 x = BN_CTX_get(ctx);-
205 y = BN_CTX_get(ctx);-
206 if (y == NULL)
y == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 14268 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-14268
207 goto err;
never executed: goto err;
0
208-
209 if (!EC_POINT_get_affine_coordinates(group, point, x, y, ctx))
!EC_POINT_get_...nt, x, y, ctx)Description
TRUEnever evaluated
FALSEevaluated 14268 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-14268
210 goto err;
never executed: goto err;
0
211-
212 if ((form == POINT_CONVERSION_COMPRESSED
form == POINT_...ION_COMPRESSEDDescription
TRUEevaluated 109 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 14159 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
109-14159
213 || form == POINT_CONVERSION_HYBRID) && BN_is_odd(y))
form == POINT_...VERSION_HYBRIDDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 14153 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
BN_is_odd(y)Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 103 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
6-14153
214 buf[0] = form + 1;
executed 12 times by 1 test: buf[0] = form + 1;
Executed by:
  • libcrypto.so.1.1
12
215 else-
216 buf[0] = form;
executed 14256 times by 1 test: buf[0] = form;
Executed by:
  • libcrypto.so.1.1
14256
217-
218 i = 1;-
219-
220 skip = field_len - BN_num_bytes(x);-
221 if (skip > field_len) {
skip > field_lenDescription
TRUEnever evaluated
FALSEevaluated 14268 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-14268
222 ECerr(EC_F_EC_GFP_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR);-
223 goto err;
never executed: goto err;
0
224 }-
225 while (skip > 0) {
skip > 0Description
TRUEevaluated 736 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 14268 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
736-14268
226 buf[i++] = 0;-
227 skip--;-
228 }
executed 736 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
736
229 skip = BN_bn2bin(x, buf + i);-
230 i += skip;-
231 if (i != 1 + field_len) {
i != 1 + field_lenDescription
TRUEnever evaluated
FALSEevaluated 14268 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-14268
232 ECerr(EC_F_EC_GFP_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR);-
233 goto err;
never executed: goto err;
0
234 }-
235-
236 if (form == POINT_CONVERSION_UNCOMPRESSED
form == POINT_...N_UNCOMPRESSEDDescription
TRUEevaluated 14153 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 115 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
115-14153
237 || form == POINT_CONVERSION_HYBRID) {
form == POINT_...VERSION_HYBRIDDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 109 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
6-109
238 skip = field_len - BN_num_bytes(y);-
239 if (skip > field_len) {
skip > field_lenDescription
TRUEnever evaluated
FALSEevaluated 14159 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-14159
240 ECerr(EC_F_EC_GFP_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR);-
241 goto err;
never executed: goto err;
0
242 }-
243 while (skip > 0) {
skip > 0Description
TRUEevaluated 339 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 14159 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
339-14159
244 buf[i++] = 0;-
245 skip--;-
246 }
executed 339 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
339
247 skip = BN_bn2bin(y, buf + i);-
248 i += skip;-
249 }
executed 14159 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
14159
250-
251 if (i != ret) {
i != retDescription
TRUEnever evaluated
FALSEevaluated 14268 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-14268
252 ECerr(EC_F_EC_GFP_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR);-
253 goto err;
never executed: goto err;
0
254 }-
255 }
executed 14268 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
14268
256-
257 if (used_ctx)
used_ctxDescription
TRUEevaluated 14268 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 27357 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
14268-27357
258 BN_CTX_end(ctx);
executed 14268 times by 1 test: BN_CTX_end(ctx);
Executed by:
  • libcrypto.so.1.1
14268
259 BN_CTX_free(new_ctx);-
260 return ret;
executed 41625 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
41625
261-
262 err:-
263 if (used_ctx)
used_ctxDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1
264 BN_CTX_end(ctx);
never executed: BN_CTX_end(ctx);
0
265 BN_CTX_free(new_ctx);-
266 return 0;
executed 1 time by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
1
267}-
268-
269int ec_GFp_simple_oct2point(const EC_GROUP *group, EC_POINT *point,-
270 const unsigned char *buf, size_t len, BN_CTX *ctx)-
271{-
272 point_conversion_form_t form;-
273 int y_bit;-
274 BN_CTX *new_ctx = NULL;-
275 BIGNUM *x, *y;-
276 size_t field_len, enc_len;-
277 int ret = 0;-
278-
279 if (len == 0) {
len == 0Description
TRUEevaluated 276 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 24879 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
276-24879
280 ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_BUFFER_TOO_SMALL);-
281 return 0;
executed 276 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
276
282 }-
283 form = buf[0];-
284 y_bit = form & 1;-
285 form = form & ~1U;-
286 if ((form != 0) && (form != POINT_CONVERSION_COMPRESSED)
(form != 0)Description
TRUEevaluated 24417 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 462 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(form != POINT...ON_COMPRESSED)Description
TRUEevaluated 19559 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4858 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
462-24417
287 && (form != POINT_CONVERSION_UNCOMPRESSED)
(form != POINT..._UNCOMPRESSED)Description
TRUEevaluated 551 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 19008 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
551-19008
288 && (form != POINT_CONVERSION_HYBRID)) {
(form != POINT...ERSION_HYBRID)Description
TRUEevaluated 250 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 301 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
250-301
289 ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING);-
290 return 0;
executed 250 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
250
291 }-
292 if ((form == 0 || form == POINT_CONVERSION_UNCOMPRESSED) && y_bit) {
form == 0Description
TRUEevaluated 462 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 24167 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
form == POINT_...N_UNCOMPRESSEDDescription
TRUEevaluated 19008 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 5159 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
y_bitDescription
TRUEevaluated 74 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 19396 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
74-24167
293 ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING);-
294 return 0;
executed 74 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
74
295 }-
296-
297 if (form == 0) {
form == 0Description
TRUEevaluated 393 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 24162 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
393-24162
298 if (len != 1) {
len != 1Description
TRUEevaluated 80 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 313 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
80-313
299 ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING);-
300 return 0;
executed 80 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
80
301 }-
302-
303 return EC_POINT_set_to_infinity(group, point);
executed 313 times by 1 test: return EC_POINT_set_to_infinity(group, point);
Executed by:
  • libcrypto.so.1.1
313
304 }-
305-
306 field_len = BN_num_bytes(group->field);-
307 enc_len =-
308 (form ==
(form == POINT...ON_COMPRESSED)Description
TRUEevaluated 4858 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 19304 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
4858-19304
309 POINT_CONVERSION_COMPRESSED) ? 1 + field_len : 1 + 2 * field_len;
(form == POINT...ON_COMPRESSED)Description
TRUEevaluated 4858 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 19304 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
4858-19304
310-
311 if (len != enc_len) {
len != enc_lenDescription
TRUEevaluated 360 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 23802 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
360-23802
312 ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING);-
313 return 0;
executed 360 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
360
314 }-
315-
316 if (ctx == NULL) {
ctx == ((void *)0)Description
TRUEevaluated 23799 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
3-23799
317 ctx = new_ctx = BN_CTX_new();-
318 if (ctx == NULL)
ctx == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 23799 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-23799
319 return 0;
never executed: return 0;
0
320 }
executed 23799 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
23799
321-
322 BN_CTX_start(ctx);-
323 x = BN_CTX_get(ctx);-
324 y = BN_CTX_get(ctx);-
325 if (y == NULL)
y == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 23802 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-23802
326 goto err;
never executed: goto err;
0
327-
328 if (!BN_bin2bn(buf + 1, field_len, x))
!BN_bin2bn(buf... field_len, x)Description
TRUEnever evaluated
FALSEevaluated 23802 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-23802
329 goto err;
never executed: goto err;
0
330 if (BN_ucmp(x, group->field) >= 0) {
BN_ucmp(x, group->field) >= 0Description
TRUEevaluated 91 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 23711 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
91-23711
331 ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING);-
332 goto err;
executed 91 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
91
333 }-
334-
335 if (form == POINT_CONVERSION_COMPRESSED) {
form == POINT_...ION_COMPRESSEDDescription
TRUEevaluated 4520 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 19191 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
4520-19191
336 if (!EC_POINT_set_compressed_coordinates(group, point, x, y_bit, ctx))
!EC_POINT_set_...x, y_bit, ctx)Description
TRUEevaluated 1279 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3241 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1279-3241
337 goto err;
executed 1279 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
1279
338 } else {
executed 3241 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
3241
339 if (!BN_bin2bn(buf + 1 + field_len, field_len, y))
!BN_bin2bn(buf... field_len, y)Description
TRUEnever evaluated
FALSEevaluated 19191 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-19191
340 goto err;
never executed: goto err;
0
341 if (BN_ucmp(y, group->field) >= 0) {
BN_ucmp(y, group->field) >= 0Description
TRUEevaluated 84 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 19107 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
84-19107
342 ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING);-
343 goto err;
executed 84 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
84
344 }-
345 if (form == POINT_CONVERSION_HYBRID) {
form == POINT_...VERSION_HYBRIDDescription
TRUEevaluated 173 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 18934 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
173-18934
346 if (y_bit != BN_is_odd(y)) {
y_bit != BN_is_odd(y)Description
TRUEevaluated 73 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 100 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
73-100
347 ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING);-
348 goto err;
executed 73 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
73
349 }-
350 }
executed 100 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
100
351-
352 /*-
353 * EC_POINT_set_affine_coordinates is responsible for checking that-
354 * the point is on the curve.-
355 */-
356 if (!EC_POINT_set_affine_coordinates(group, point, x, y, ctx))
!EC_POINT_set_...nt, x, y, ctx)Description
TRUEevaluated 479 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 18555 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
479-18555
357 goto err;
executed 479 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
479
358 }
executed 18555 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
18555
359-
360 ret = 1;-
361-
362 err:
code before this statement executed 21796 times by 1 test: err:
Executed by:
  • libcrypto.so.1.1
21796
363 BN_CTX_end(ctx);-
364 BN_CTX_free(new_ctx);-
365 return ret;
executed 23802 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
23802
366}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2