OpenCoverage

ec2_oct.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/ec/ec2_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-
13#include "ec_lcl.h"-
14-
15#ifndef OPENSSL_NO_EC2M-
16-
17/*--
18 * Calculates and sets the affine coordinates of an EC_POINT from the given-
19 * compressed coordinates. Uses algorithm 2.3.4 of SEC 1.-
20 * Note that the simple implementation only uses affine coordinates.-
21 *-
22 * The method is from the following publication:-
23 *-
24 * Harper, Menezes, Vanstone:-
25 * "Public-Key Cryptosystems with Very Small Key Lengths",-
26 * EUROCRYPT '92, Springer-Verlag LNCS 658,-
27 * published February 1993-
28 *-
29 * US Patents 6,141,420 and 6,618,483 (Vanstone, Mullin, Agnew) describe-
30 * the same method, but claim no priority date earlier than July 29, 1994-
31 * (and additionally fail to cite the EUROCRYPT '92 publication as prior art).-
32 */-
33int ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *group,-
34 EC_POINT *point,-
35 const BIGNUM *x_, int y_bit,-
36 BN_CTX *ctx)-
37{-
38 BN_CTX *new_ctx = NULL;-
39 BIGNUM *tmp, *x, *y, *z;-
40 int ret = 0, z0;-
41-
42 /* clear error queue */-
43 ERR_clear_error();-
44-
45 if (ctx == NULL) {
ctx == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 6045 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-6045
46 ctx = new_ctx = BN_CTX_new();-
47 if (ctx == NULL)
ctx == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
48 return 0;
never executed: return 0;
0
49 }
never executed: end of block
0
50-
51 y_bit = (y_bit != 0) ? 1 : 0;
(y_bit != 0)Description
TRUEevaluated 5754 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 291 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
291-5754
52-
53 BN_CTX_start(ctx);-
54 tmp = BN_CTX_get(ctx);-
55 x = BN_CTX_get(ctx);-
56 y = BN_CTX_get(ctx);-
57 z = BN_CTX_get(ctx);-
58 if (z == NULL)
z == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 6045 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-6045
59 goto err;
never executed: goto err;
0
60-
61 if (!BN_GF2m_mod_arr(x, x_, group->poly))
!BN_GF2m_mod_a..., group->poly)Description
TRUEnever evaluated
FALSEevaluated 6045 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-6045
62 goto err;
never executed: goto err;
0
63 if (BN_is_zero(x)) {
BN_is_zero(x)Description
TRUEevaluated 1111 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4934 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1111-4934
64 if (!BN_GF2m_mod_sqrt_arr(y, group->b, group->poly, ctx))
!BN_GF2m_mod_s...up->poly, ctx)Description
TRUEnever evaluated
FALSEevaluated 1111 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1111
65 goto err;
never executed: goto err;
0
66 } else {
executed 1111 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1111
67 if (!group->meth->field_sqr(group, tmp, x, ctx))
!group->meth->..., tmp, x, ctx)Description
TRUEnever evaluated
FALSEevaluated 4934 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4934
68 goto err;
never executed: goto err;
0
69 if (!group->meth->field_div(group, tmp, group->b, tmp, ctx))
!group->meth->...->b, tmp, ctx)Description
TRUEnever evaluated
FALSEevaluated 4934 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4934
70 goto err;
never executed: goto err;
0
71 if (!BN_GF2m_add(tmp, group->a, tmp))
!BN_GF2m_add(t...group->a, tmp)Description
TRUEnever evaluated
FALSEevaluated 4934 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4934
72 goto err;
never executed: goto err;
0
73 if (!BN_GF2m_add(tmp, x, tmp))
!BN_GF2m_add(tmp, x, tmp)Description
TRUEnever evaluated
FALSEevaluated 4934 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4934
74 goto err;
never executed: goto err;
0
75 if (!BN_GF2m_mod_solve_quad_arr(z, tmp, group->poly, ctx)) {
!BN_GF2m_mod_s...up->poly, ctx)Description
TRUEevaluated 2314 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2620 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2314-2620
76 unsigned long err = ERR_peek_last_error();-
77-
78 if (ERR_GET_LIB(err) == ERR_LIB_BN
(int)(((err) >...& 0x0FFL) == 3Description
TRUEevaluated 2314 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-2314
79 && ERR_GET_REASON(err) == BN_R_NO_SOLUTION) {
(int)( (err) & 0xFFFL) == 116Description
TRUEevaluated 1483 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 831 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
831-1483
80 ERR_clear_error();-
81 ECerr(EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES,-
82 EC_R_INVALID_COMPRESSED_POINT);-
83 } else
executed 1483 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1483
84 ECerr(EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES,
executed 831 times by 1 test: ERR_put_error(16,(164),(3),__FILE__,85) ;
Executed by:
  • libcrypto.so.1.1
831
85 ERR_R_BN_LIB);
executed 831 times by 1 test: ERR_put_error(16,(164),(3),__FILE__,85) ;
Executed by:
  • libcrypto.so.1.1
831
86 goto err;
executed 2314 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
2314
87 }-
88 z0 = (BN_is_odd(z)) ? 1 : 0;
(BN_is_odd(z))Description
TRUEevaluated 109 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2511 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
109-2511
89 if (!group->meth->field_mul(group, y, x, z, ctx))
!group->meth->... y, x, z, ctx)Description
TRUEnever evaluated
FALSEevaluated 2620 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2620
90 goto err;
never executed: goto err;
0
91 if (z0 != y_bit) {
z0 != y_bitDescription
TRUEevaluated 2402 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 218 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
218-2402
92 if (!BN_GF2m_add(y, y, x))
!BN_GF2m_add(y, y, x)Description
TRUEnever evaluated
FALSEevaluated 2402 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2402
93 goto err;
never executed: goto err;
0
94 }
executed 2402 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
2402
95 }
executed 2620 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
2620
96-
97 if (!EC_POINT_set_affine_coordinates(group, point, x, y, ctx))
!EC_POINT_set_...nt, x, y, ctx)Description
TRUEnever evaluated
FALSEevaluated 3731 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3731
98 goto err;
never executed: goto err;
0
99-
100 ret = 1;-
101-
102 err:
code before this statement executed 3731 times by 1 test: err:
Executed by:
  • libcrypto.so.1.1
3731
103 BN_CTX_end(ctx);-
104 BN_CTX_free(new_ctx);-
105 return ret;
executed 6045 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
6045
106}-
107-
108/*-
109 * Converts an EC_POINT to an octet string. If buf is NULL, the encoded-
110 * length will be returned. If the length len of buf is smaller than required-
111 * an error will be returned.-
112 */-
113size_t ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point,-
114 point_conversion_form_t form,-
115 unsigned char *buf, size_t len, BN_CTX *ctx)-
116{-
117 size_t ret;-
118 BN_CTX *new_ctx = NULL;-
119 int used_ctx = 0;-
120 BIGNUM *x, *y, *yxi;-
121 size_t field_len, i, skip;-
122-
123 if ((form != POINT_CONVERSION_COMPRESSED)
(form != POINT...ON_COMPRESSED)Description
TRUEevaluated 169 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 32 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
32-169
124 && (form != POINT_CONVERSION_UNCOMPRESSED)
(form != POINT..._UNCOMPRESSED)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 166 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
3-166
125 && (form != POINT_CONVERSION_HYBRID)) {
(form != POINT...ERSION_HYBRID)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1-2
126 ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, EC_R_INVALID_FORM);-
127 goto err;
executed 1 time by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
1
128 }-
129-
130 if (EC_POINT_is_at_infinity(group, point)) {
EC_POINT_is_at...(group, point)Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 186 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
14-186
131 /* encodes to a single 0 octet */-
132 if (buf != NULL) {
buf != ((void *)0)Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 7 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
7
133 if (len < 1) {
len < 1Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-7
134 ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, EC_R_BUFFER_TOO_SMALL);-
135 return 0;
never executed: return 0;
0
136 }-
137 buf[0] = 0;-
138 }
executed 7 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
7
139 return 1;
executed 14 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
14
140 }-
141-
142 /* ret := required output buffer length */-
143 field_len = (EC_GROUP_get_degree(group) + 7) / 8;-
144 ret =-
145 (form ==
(form == POINT...ON_COMPRESSED)Description
TRUEevaluated 32 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 154 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
32-154
146 POINT_CONVERSION_COMPRESSED) ? 1 + field_len : 1 + 2 * field_len;
(form == POINT...ON_COMPRESSED)Description
TRUEevaluated 32 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 154 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
32-154
147-
148 /* if 'buf' is NULL, just return required length */-
149 if (buf != NULL) {
buf != ((void *)0)Description
TRUEevaluated 93 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 93 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
93
150 if (len < ret) {
len < retDescription
TRUEnever evaluated
FALSEevaluated 93 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-93
151 ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, EC_R_BUFFER_TOO_SMALL);-
152 goto err;
never executed: goto err;
0
153 }-
154-
155 if (ctx == NULL) {
ctx == ((void *)0)Description
TRUEevaluated 92 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
1-92
156 ctx = new_ctx = BN_CTX_new();-
157 if (ctx == NULL)
ctx == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 92 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-92
158 return 0;
never executed: return 0;
0
159 }
executed 92 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
92
160-
161 BN_CTX_start(ctx);-
162 used_ctx = 1;-
163 x = BN_CTX_get(ctx);-
164 y = BN_CTX_get(ctx);-
165 yxi = BN_CTX_get(ctx);-
166 if (yxi == NULL)
yxi == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 93 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-93
167 goto err;
never executed: goto err;
0
168-
169 if (!EC_POINT_get_affine_coordinates(group, point, x, y, ctx))
!EC_POINT_get_...nt, x, y, ctx)Description
TRUEnever evaluated
FALSEevaluated 93 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-93
170 goto err;
never executed: goto err;
0
171-
172 buf[0] = form;-
173 if ((form != POINT_CONVERSION_UNCOMPRESSED) && !BN_is_zero(x)) {
(form != POINT..._UNCOMPRESSED)Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 76 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!BN_is_zero(x)Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
1-76
174 if (!group->meth->field_div(group, yxi, y, x, ctx))
!group->meth->...xi, y, x, ctx)Description
TRUEnever evaluated
FALSEevaluated 16 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-16
175 goto err;
never executed: goto err;
0
176 if (BN_is_odd(yxi))
BN_is_odd(yxi)Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 9 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
7-9
177 buf[0]++;
executed 7 times by 1 test: buf[0]++;
Executed by:
  • libcrypto.so.1.1
7
178 }
executed 16 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
16
179-
180 i = 1;-
181-
182 skip = field_len - BN_num_bytes(x);-
183 if (skip > field_len) {
skip > field_lenDescription
TRUEnever evaluated
FALSEevaluated 93 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-93
184 ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR);-
185 goto err;
never executed: goto err;
0
186 }-
187 while (skip > 0) {
skip > 0Description
TRUEevaluated 246 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 93 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
93-246
188 buf[i++] = 0;-
189 skip--;-
190 }
executed 246 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
246
191 skip = BN_bn2bin(x, buf + i);-
192 i += skip;-
193 if (i != 1 + field_len) {
i != 1 + field_lenDescription
TRUEnever evaluated
FALSEevaluated 93 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-93
194 ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR);-
195 goto err;
never executed: goto err;
0
196 }-
197-
198 if (form == POINT_CONVERSION_UNCOMPRESSED
form == POINT_...N_UNCOMPRESSEDDescription
TRUEevaluated 76 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 17 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
17-76
199 || form == POINT_CONVERSION_HYBRID) {
form == POINT_...VERSION_HYBRIDDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 16 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1-16
200 skip = field_len - BN_num_bytes(y);-
201 if (skip > field_len) {
skip > field_lenDescription
TRUEnever evaluated
FALSEevaluated 77 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-77
202 ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR);-
203 goto err;
never executed: goto err;
0
204 }-
205 while (skip > 0) {
skip > 0Description
TRUEevaluated 94 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 77 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
77-94
206 buf[i++] = 0;-
207 skip--;-
208 }
executed 94 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
94
209 skip = BN_bn2bin(y, buf + i);-
210 i += skip;-
211 }
executed 77 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
77
212-
213 if (i != ret) {
i != retDescription
TRUEnever evaluated
FALSEevaluated 93 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-93
214 ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR);-
215 goto err;
never executed: goto err;
0
216 }-
217 }
executed 93 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
93
218-
219 if (used_ctx)
used_ctxDescription
TRUEevaluated 93 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 93 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
93
220 BN_CTX_end(ctx);
executed 93 times by 1 test: BN_CTX_end(ctx);
Executed by:
  • libcrypto.so.1.1
93
221 BN_CTX_free(new_ctx);-
222 return ret;
executed 186 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
186
223-
224 err:-
225 if (used_ctx)
used_ctxDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1
226 BN_CTX_end(ctx);
never executed: BN_CTX_end(ctx);
0
227 BN_CTX_free(new_ctx);-
228 return 0;
executed 1 time by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
1
229}-
230-
231/*-
232 * Converts an octet string representation to an EC_POINT. Note that the-
233 * simple implementation only uses affine coordinates.-
234 */-
235int ec_GF2m_simple_oct2point(const EC_GROUP *group, EC_POINT *point,-
236 const unsigned char *buf, size_t len,-
237 BN_CTX *ctx)-
238{-
239 point_conversion_form_t form;-
240 int y_bit;-
241 BN_CTX *new_ctx = NULL;-
242 BIGNUM *x, *y, *yxi;-
243 size_t field_len, enc_len;-
244 int ret = 0;-
245-
246 if (len == 0) {
len == 0Description
TRUEevaluated 80 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 9189 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
80-9189
247 ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_BUFFER_TOO_SMALL);-
248 return 0;
executed 80 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
80
249 }-
250 form = buf[0];-
251 y_bit = form & 1;-
252 form = form & ~1U;-
253 if ((form != 0) && (form != POINT_CONVERSION_COMPRESSED)
(form != 0)Description
TRUEevaluated 8841 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 348 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(form != POINT...ON_COMPRESSED)Description
TRUEevaluated 2484 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 6357 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
348-8841
254 && (form != POINT_CONVERSION_UNCOMPRESSED)
(form != POINT..._UNCOMPRESSED)Description
TRUEevaluated 1213 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1271 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1213-1271
255 && (form != POINT_CONVERSION_HYBRID)) {
(form != POINT...ERSION_HYBRID)Description
TRUEevaluated 572 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 641 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
572-641
256 ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING);-
257 return 0;
executed 572 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
572
258 }-
259 if ((form == 0 || form == POINT_CONVERSION_UNCOMPRESSED) && y_bit) {
form == 0Description
TRUEevaluated 348 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 8269 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
form == POINT_...N_UNCOMPRESSEDDescription
TRUEevaluated 1271 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 6998 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
y_bitDescription
TRUEevaluated 75 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1544 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
75-8269
260 ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING);-
261 return 0;
executed 75 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
75
262 }-
263-
264 if (form == 0) {
form == 0Description
TRUEevaluated 274 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 8268 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
274-8268
265 if (len != 1) {
len != 1Description
TRUEevaluated 77 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 197 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
77-197
266 ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING);-
267 return 0;
executed 77 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
77
268 }-
269-
270 return EC_POINT_set_to_infinity(group, point);
executed 197 times by 1 test: return EC_POINT_set_to_infinity(group, point);
Executed by:
  • libcrypto.so.1.1
197
271 }-
272-
273 field_len = (EC_GROUP_get_degree(group) + 7) / 8;-
274 enc_len =-
275 (form ==
(form == POINT...ON_COMPRESSED)Description
TRUEevaluated 6357 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1911 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1911-6357
276 POINT_CONVERSION_COMPRESSED) ? 1 + field_len : 1 + 2 * field_len;
(form == POINT...ON_COMPRESSED)Description
TRUEevaluated 6357 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1911 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1911-6357
277-
278 if (len != enc_len) {
len != enc_lenDescription
TRUEevaluated 258 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 8010 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
258-8010
279 ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING);-
280 return 0;
executed 258 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
258
281 }-
282-
283 if (ctx == NULL) {
ctx == ((void *)0)Description
TRUEevaluated 8009 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
1-8009
284 ctx = new_ctx = BN_CTX_new();-
285 if (ctx == NULL)
ctx == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 8009 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-8009
286 return 0;
never executed: return 0;
0
287 }
executed 8009 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
8009
288-
289 BN_CTX_start(ctx);-
290 x = BN_CTX_get(ctx);-
291 y = BN_CTX_get(ctx);-
292 yxi = BN_CTX_get(ctx);-
293 if (yxi == NULL)
yxi == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 8010 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-8010
294 goto err;
never executed: goto err;
0
295-
296 if (!BN_bin2bn(buf + 1, field_len, x))
!BN_bin2bn(buf... field_len, x)Description
TRUEnever evaluated
FALSEevaluated 8010 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-8010
297 goto err;
never executed: goto err;
0
298 if (BN_ucmp(x, group->field) >= 0) {
BN_ucmp(x, group->field) >= 0Description
TRUEevaluated 92 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 7918 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
92-7918
299 ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING);-
300 goto err;
executed 92 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
92
301 }-
302-
303 if (form == POINT_CONVERSION_COMPRESSED) {
form == POINT_...ION_COMPRESSEDDescription
TRUEevaluated 6045 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1873 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1873-6045
304 if (!EC_POINT_set_compressed_coordinates(group, point, x, y_bit, ctx))
!EC_POINT_set_...x, y_bit, ctx)Description
TRUEevaluated 2314 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3731 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2314-3731
305 goto err;
executed 2314 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
2314
306 } else {
executed 3731 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
3731
307 if (!BN_bin2bn(buf + 1 + field_len, field_len, y))
!BN_bin2bn(buf... field_len, y)Description
TRUEnever evaluated
FALSEevaluated 1873 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1873
308 goto err;
never executed: goto err;
0
309 if (BN_ucmp(y, group->field) >= 0) {
BN_ucmp(y, group->field) >= 0Description
TRUEevaluated 73 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1800 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
73-1800
310 ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING);-
311 goto err;
executed 73 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
73
312 }-
313 if (form == POINT_CONVERSION_HYBRID) {
form == POINT_...VERSION_HYBRIDDescription
TRUEevaluated 566 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1234 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
566-1234
314 if (!group->meth->field_div(group, yxi, y, x, ctx))
!group->meth->...xi, y, x, ctx)Description
TRUEevaluated 77 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 489 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
77-489
315 goto err;
executed 77 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
77
316 if (y_bit != BN_is_odd(yxi)) {
y_bit != BN_is_odd(yxi)Description
TRUEevaluated 98 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 391 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
98-391
317 ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING);-
318 goto err;
executed 98 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
98
319 }-
320 }
executed 391 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
391
321-
322 /*-
323 * EC_POINT_set_affine_coordinates is responsible for checking that-
324 * the point is on the curve.-
325 */-
326 if (!EC_POINT_set_affine_coordinates(group, point, x, y, ctx))
!EC_POINT_set_...nt, x, y, ctx)Description
TRUEevaluated 516 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1109 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
516-1109
327 goto err;
executed 516 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
516
328 }
executed 1109 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1109
329-
330 ret = 1;-
331-
332 err:
code before this statement executed 4840 times by 1 test: err:
Executed by:
  • libcrypto.so.1.1
4840
333 BN_CTX_end(ctx);-
334 BN_CTX_free(new_ctx);-
335 return ret;
executed 8010 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
8010
336}-
337#endif-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2