Coverage Report

Created: 2024-07-27 06:35

/src/openssl/crypto/ec/ecdsa_ossl.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2002-2023 The OpenSSL Project Authors. All Rights Reserved.
3
 *
4
 * Licensed under the Apache License 2.0 (the "License").  You may not use
5
 * this file except in compliance with the License.  You can obtain a copy
6
 * in the file LICENSE in the source distribution or at
7
 * https://www.openssl.org/source/license.html
8
 */
9
10
/*
11
 * ECDSA low level APIs are deprecated for public use, but still ok for
12
 * internal use.
13
 */
14
#include "internal/deprecated.h"
15
16
#include <string.h>
17
#include <openssl/err.h>
18
#include <openssl/obj_mac.h>
19
#include <openssl/rand.h>
20
#include "crypto/bn.h"
21
#include "ec_local.h"
22
#include "internal/deterministic_nonce.h"
23
24
0
#define MIN_ECDSA_SIGN_ORDERBITS 64
25
/*
26
 * It is highly unlikely that a retry will happen,
27
 * Multiple retries would indicate that something is wrong
28
 * with the group parameters (which would normally only happen
29
 * with a bad custom group).
30
 */
31
0
#define MAX_ECDSA_SIGN_RETRIES 8
32
33
static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in,
34
                            BIGNUM **kinvp, BIGNUM **rp,
35
                            const unsigned char *dgst, int dlen,
36
                            unsigned int nonce_type, const char *digestname,
37
                            OSSL_LIB_CTX *libctx, const char *propq);
38
39
int ossl_ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp,
40
                          BIGNUM **rp)
41
0
{
42
0
    if (eckey->group->meth->ecdsa_sign_setup == NULL) {
43
0
        ERR_raise(ERR_LIB_EC, EC_R_CURVE_DOES_NOT_SUPPORT_ECDSA);
44
0
        return 0;
45
0
    }
46
47
0
    return eckey->group->meth->ecdsa_sign_setup(eckey, ctx_in, kinvp, rp);
48
0
}
49
50
ECDSA_SIG *ossl_ecdsa_sign_sig(const unsigned char *dgst, int dgst_len,
51
                               const BIGNUM *in_kinv, const BIGNUM *in_r,
52
                               EC_KEY *eckey)
53
0
{
54
0
    if (eckey->group->meth->ecdsa_sign_sig == NULL) {
55
0
        ERR_raise(ERR_LIB_EC, EC_R_CURVE_DOES_NOT_SUPPORT_ECDSA);
56
0
        return NULL;
57
0
    }
58
59
0
    return eckey->group->meth->ecdsa_sign_sig(dgst, dgst_len,
60
0
                                              in_kinv, in_r, eckey);
61
0
}
62
63
int ossl_ecdsa_verify_sig(const unsigned char *dgst, int dgst_len,
64
                          const ECDSA_SIG *sig, EC_KEY *eckey)
65
0
{
66
0
    if (eckey->group->meth->ecdsa_verify_sig == NULL) {
67
0
        ERR_raise(ERR_LIB_EC, EC_R_CURVE_DOES_NOT_SUPPORT_ECDSA);
68
0
        return 0;
69
0
    }
70
71
0
    return eckey->group->meth->ecdsa_verify_sig(dgst, dgst_len, sig, eckey);
72
0
}
73
74
int ossl_ecdsa_sign(int type, const unsigned char *dgst, int dlen,
75
                    unsigned char *sig, unsigned int *siglen,
76
                    const BIGNUM *kinv, const BIGNUM *r, EC_KEY *eckey)
77
0
{
78
0
    ECDSA_SIG *s;
79
80
0
    if (sig == NULL && (kinv == NULL || r == NULL)) {
81
0
        *siglen = ECDSA_size(eckey);
82
0
        return 1;
83
0
    }
84
85
0
    s = ECDSA_do_sign_ex(dgst, dlen, kinv, r, eckey);
86
0
    if (s == NULL) {
87
0
        *siglen = 0;
88
0
        return 0;
89
0
    }
90
0
    *siglen = i2d_ECDSA_SIG(s, sig != NULL ? &sig : NULL);
91
0
    ECDSA_SIG_free(s);
92
0
    return 1;
93
0
}
94
95
int ossl_ecdsa_deterministic_sign(const unsigned char *dgst, int dlen,
96
                                  unsigned char *sig, unsigned int *siglen,
97
                                  EC_KEY *eckey, unsigned int nonce_type,
98
                                  const char *digestname,
99
                                  OSSL_LIB_CTX *libctx, const char *propq)
100
0
{
101
0
    ECDSA_SIG *s;
102
0
    BIGNUM *kinv = NULL, *r = NULL;
103
0
    int ret = 0;
104
105
0
    if (sig == NULL) {
106
0
        ERR_raise(ERR_LIB_EC, ERR_R_PASSED_NULL_PARAMETER);
107
0
        return 0;
108
0
    }
109
110
0
    *siglen = 0;
111
0
    if (!ecdsa_sign_setup(eckey, NULL, &kinv, &r, dgst, dlen,
112
0
                          nonce_type, digestname, libctx, propq))
113
0
        return 0;
114
115
0
    s = ECDSA_do_sign_ex(dgst, dlen, kinv, r, eckey);
116
0
    if (s == NULL)
117
0
        goto end;
118
119
0
    *siglen = i2d_ECDSA_SIG(s, &sig);
120
0
    ECDSA_SIG_free(s);
121
0
    ret = 1;
122
0
end:
123
0
    BN_clear_free(kinv);
124
0
    BN_clear_free(r);
125
0
    return ret;
126
0
}
127
128
static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in,
129
                            BIGNUM **kinvp, BIGNUM **rp,
130
                            const unsigned char *dgst, int dlen,
131
                            unsigned int nonce_type, const char *digestname,
132
                            OSSL_LIB_CTX *libctx, const char *propq)
133
0
{
134
0
    BN_CTX *ctx = NULL;
135
0
    BIGNUM *k = NULL, *r = NULL, *X = NULL;
136
0
    const BIGNUM *order;
137
0
    EC_POINT *tmp_point = NULL;
138
0
    const EC_GROUP *group;
139
0
    int ret = 0;
140
0
    int order_bits;
141
0
    const BIGNUM *priv_key;
142
143
0
    if (eckey == NULL || (group = EC_KEY_get0_group(eckey)) == NULL) {
144
0
        ERR_raise(ERR_LIB_EC, ERR_R_PASSED_NULL_PARAMETER);
145
0
        return 0;
146
0
    }
147
0
    if ((priv_key = EC_KEY_get0_private_key(eckey)) == NULL) {
148
0
        ERR_raise(ERR_LIB_EC, EC_R_MISSING_PRIVATE_KEY);
149
0
        return 0;
150
0
    }
151
152
0
    if (!EC_KEY_can_sign(eckey)) {
153
0
        ERR_raise(ERR_LIB_EC, EC_R_CURVE_DOES_NOT_SUPPORT_SIGNING);
154
0
        return 0;
155
0
    }
156
157
0
    if ((ctx = ctx_in) == NULL) {
158
0
        if ((ctx = BN_CTX_new_ex(eckey->libctx)) == NULL) {
159
0
            ERR_raise(ERR_LIB_EC, ERR_R_BN_LIB);
160
0
            return 0;
161
0
        }
162
0
    }
163
164
0
    k = BN_secure_new();        /* this value is later returned in *kinvp */
165
0
    r = BN_new();               /* this value is later returned in *rp */
166
0
    X = BN_new();
167
0
    if (k == NULL || r == NULL || X == NULL) {
168
0
        ERR_raise(ERR_LIB_EC, ERR_R_BN_LIB);
169
0
        goto err;
170
0
    }
171
0
    if ((tmp_point = EC_POINT_new(group)) == NULL) {
172
0
        ERR_raise(ERR_LIB_EC, ERR_R_EC_LIB);
173
0
        goto err;
174
0
    }
175
176
0
    if ((order = EC_GROUP_get0_order(group)) == NULL) {
177
0
        ERR_raise(ERR_LIB_EC, ERR_R_EC_LIB);
178
0
        goto err;
179
0
    }
180
181
    /* Preallocate space */
182
0
    order_bits = BN_num_bits(order);
183
    /* Check the number of bits here so that an infinite loop is not possible */
184
0
    if (order_bits < MIN_ECDSA_SIGN_ORDERBITS
185
0
        || !BN_set_bit(k, order_bits)
186
0
        || !BN_set_bit(r, order_bits)
187
0
        || !BN_set_bit(X, order_bits))
188
0
        goto err;
189
190
0
    do {
191
        /* get random or deterministic value of k */
192
0
        do {
193
0
            int res = 0;
194
195
0
            if (dgst != NULL) {
196
0
                if (nonce_type == 1) {
197
0
#ifndef FIPS_MODULE
198
0
                    res = ossl_gen_deterministic_nonce_rfc6979(k, order,
199
0
                                                               priv_key,
200
0
                                                               dgst, dlen,
201
0
                                                               digestname,
202
0
                                                               libctx, propq);
203
0
#endif
204
0
                } else {
205
0
                    res = ossl_bn_gen_dsa_nonce_fixed_top(k, order, priv_key,
206
0
                                                          dgst, dlen, ctx);
207
0
                }
208
0
            } else {
209
0
                res = ossl_bn_priv_rand_range_fixed_top(k, order, 0, ctx);
210
0
            }
211
0
            if (!res) {
212
0
                ERR_raise(ERR_LIB_EC, EC_R_RANDOM_NUMBER_GENERATION_FAILED);
213
0
                goto err;
214
0
            }
215
0
        } while (ossl_bn_is_word_fixed_top(k, 0));
216
217
        /* compute r the x-coordinate of generator * k */
218
0
        if (!EC_POINT_mul(group, tmp_point, k, NULL, NULL, ctx)) {
219
0
            ERR_raise(ERR_LIB_EC, ERR_R_EC_LIB);
220
0
            goto err;
221
0
        }
222
223
0
        if (!EC_POINT_get_affine_coordinates(group, tmp_point, X, NULL, ctx)) {
224
0
            ERR_raise(ERR_LIB_EC, ERR_R_EC_LIB);
225
0
            goto err;
226
0
        }
227
228
0
        if (!BN_nnmod(r, X, order, ctx)) {
229
0
            ERR_raise(ERR_LIB_EC, ERR_R_BN_LIB);
230
0
            goto err;
231
0
        }
232
0
    } while (BN_is_zero(r));
233
234
    /* compute the inverse of k */
235
0
    if (!ossl_ec_group_do_inverse_ord(group, k, k, ctx)) {
236
0
        ERR_raise(ERR_LIB_EC, ERR_R_BN_LIB);
237
0
        goto err;
238
0
    }
239
240
    /* clear old values if necessary */
241
0
    BN_clear_free(*rp);
242
0
    BN_clear_free(*kinvp);
243
    /* save the pre-computed values  */
244
0
    *rp = r;
245
0
    *kinvp = k;
246
0
    ret = 1;
247
0
 err:
248
0
    if (!ret) {
249
0
        BN_clear_free(k);
250
0
        BN_clear_free(r);
251
0
    }
252
0
    if (ctx != ctx_in)
253
0
        BN_CTX_free(ctx);
254
0
    EC_POINT_free(tmp_point);
255
0
    BN_clear_free(X);
256
0
    return ret;
257
0
}
258
259
int ossl_ecdsa_simple_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp,
260
                                 BIGNUM **rp)
261
0
{
262
0
    return ecdsa_sign_setup(eckey, ctx_in, kinvp, rp, NULL, 0,
263
0
                            0, NULL, NULL, NULL);
264
0
}
265
266
ECDSA_SIG *ossl_ecdsa_simple_sign_sig(const unsigned char *dgst, int dgst_len,
267
                                      const BIGNUM *in_kinv, const BIGNUM *in_r,
268
                                      EC_KEY *eckey)
269
0
{
270
0
    int ok = 0, i;
271
0
    int retries = 0;
272
0
    BIGNUM *kinv = NULL, *s, *m = NULL;
273
0
    const BIGNUM *order, *ckinv;
274
0
    BN_CTX *ctx = NULL;
275
0
    const EC_GROUP *group;
276
0
    ECDSA_SIG *ret;
277
0
    const BIGNUM *priv_key;
278
279
0
    group = EC_KEY_get0_group(eckey);
280
0
    priv_key = EC_KEY_get0_private_key(eckey);
281
282
0
    if (group == NULL) {
283
0
        ERR_raise(ERR_LIB_EC, ERR_R_PASSED_NULL_PARAMETER);
284
0
        return NULL;
285
0
    }
286
0
    if (priv_key == NULL) {
287
0
        ERR_raise(ERR_LIB_EC, EC_R_MISSING_PRIVATE_KEY);
288
0
        return NULL;
289
0
    }
290
291
0
    if (!EC_KEY_can_sign(eckey)) {
292
0
        ERR_raise(ERR_LIB_EC, EC_R_CURVE_DOES_NOT_SUPPORT_SIGNING);
293
0
        return NULL;
294
0
    }
295
296
0
    ret = ECDSA_SIG_new();
297
0
    if (ret == NULL) {
298
0
        ERR_raise(ERR_LIB_EC, ERR_R_ECDSA_LIB);
299
0
        return NULL;
300
0
    }
301
0
    ret->r = BN_new();
302
0
    ret->s = BN_new();
303
0
    if (ret->r == NULL || ret->s == NULL) {
304
0
        ERR_raise(ERR_LIB_EC, ERR_R_BN_LIB);
305
0
        goto err;
306
0
    }
307
0
    s = ret->s;
308
309
0
    if ((ctx = BN_CTX_new_ex(eckey->libctx)) == NULL
310
0
        || (m = BN_new()) == NULL) {
311
0
        ERR_raise(ERR_LIB_EC, ERR_R_BN_LIB);
312
0
        goto err;
313
0
    }
314
315
0
    if ((order = EC_GROUP_get0_order(group)) == NULL) {
316
0
        ERR_raise(ERR_LIB_EC, ERR_R_EC_LIB);
317
0
        goto err;
318
0
    }
319
320
0
    i = BN_num_bits(order);
321
    /*
322
     * Need to truncate digest if it is too long: first truncate whole bytes.
323
     */
324
0
    if (8 * dgst_len > i)
325
0
        dgst_len = (i + 7) / 8;
326
0
    if (!BN_bin2bn(dgst, dgst_len, m)) {
327
0
        ERR_raise(ERR_LIB_EC, ERR_R_BN_LIB);
328
0
        goto err;
329
0
    }
330
    /* If still too long, truncate remaining bits with a shift */
331
0
    if ((8 * dgst_len > i) && !BN_rshift(m, m, 8 - (i & 0x7))) {
332
0
        ERR_raise(ERR_LIB_EC, ERR_R_BN_LIB);
333
0
        goto err;
334
0
    }
335
0
    do {
336
0
        if (in_kinv == NULL || in_r == NULL) {
337
0
            if (!ecdsa_sign_setup(eckey, ctx, &kinv, &ret->r, dgst, dgst_len,
338
0
                                  0, NULL, NULL, NULL)) {
339
0
                ERR_raise(ERR_LIB_EC, ERR_R_ECDSA_LIB);
340
0
                goto err;
341
0
            }
342
0
            ckinv = kinv;
343
0
        } else {
344
0
            ckinv = in_kinv;
345
0
            if (BN_copy(ret->r, in_r) == NULL) {
346
0
                ERR_raise(ERR_LIB_EC, ERR_R_BN_LIB);
347
0
                goto err;
348
0
            }
349
0
        }
350
351
        /*
352
         * With only one multiplicant being in Montgomery domain
353
         * multiplication yields real result without post-conversion.
354
         * Also note that all operations but last are performed with
355
         * zero-padded vectors. Last operation, BN_mod_mul_montgomery
356
         * below, returns user-visible value with removed zero padding.
357
         */
358
0
        if (!bn_to_mont_fixed_top(s, ret->r, group->mont_data, ctx)
359
0
            || !bn_mul_mont_fixed_top(s, s, priv_key, group->mont_data, ctx)) {
360
0
            ERR_raise(ERR_LIB_EC, ERR_R_BN_LIB);
361
0
            goto err;
362
0
        }
363
0
        if (!bn_mod_add_fixed_top(s, s, m, order)) {
364
0
            ERR_raise(ERR_LIB_EC, ERR_R_BN_LIB);
365
0
            goto err;
366
0
        }
367
        /*
368
         * |s| can still be larger than modulus, because |m| can be. In
369
         * such case we count on Montgomery reduction to tie it up.
370
         */
371
0
        if (!bn_to_mont_fixed_top(s, s, group->mont_data, ctx)
372
0
            || !BN_mod_mul_montgomery(s, s, ckinv, group->mont_data, ctx)) {
373
0
            ERR_raise(ERR_LIB_EC, ERR_R_BN_LIB);
374
0
            goto err;
375
0
        }
376
377
0
        if (BN_is_zero(s)) {
378
            /*
379
             * if kinv and r have been supplied by the caller, don't
380
             * generate new kinv and r values
381
             */
382
0
            if (in_kinv != NULL && in_r != NULL) {
383
0
                ERR_raise(ERR_LIB_EC, EC_R_NEED_NEW_SETUP_VALUES);
384
0
                goto err;
385
0
            }
386
            /* Avoid infinite loops cause by invalid group parameters */
387
0
            if (retries++ > MAX_ECDSA_SIGN_RETRIES) {
388
0
                ERR_raise(ERR_LIB_EC, EC_R_TOO_MANY_RETRIES);
389
0
                goto err;
390
0
            }
391
0
        } else {
392
            /* s != 0 => we have a valid signature */
393
0
            break;
394
0
        }
395
0
    } while (1);
396
397
0
    ok = 1;
398
0
 err:
399
0
    if (!ok) {
400
0
        ECDSA_SIG_free(ret);
401
0
        ret = NULL;
402
0
    }
403
0
    BN_CTX_free(ctx);
404
0
    BN_clear_free(m);
405
0
    BN_clear_free(kinv);
406
0
    return ret;
407
0
}
408
409
/*-
410
 * returns
411
 *      1: correct signature
412
 *      0: incorrect signature
413
 *     -1: error
414
 */
415
int ossl_ecdsa_verify(int type, const unsigned char *dgst, int dgst_len,
416
                      const unsigned char *sigbuf, int sig_len, EC_KEY *eckey)
417
0
{
418
0
    ECDSA_SIG *s;
419
0
    const unsigned char *p = sigbuf;
420
0
    unsigned char *der = NULL;
421
0
    int derlen = -1;
422
0
    int ret = -1;
423
424
0
    s = ECDSA_SIG_new();
425
0
    if (s == NULL)
426
0
        return ret;
427
0
    if (d2i_ECDSA_SIG(&s, &p, sig_len) == NULL)
428
0
        goto err;
429
    /* Ensure signature uses DER and doesn't have trailing garbage */
430
0
    derlen = i2d_ECDSA_SIG(s, &der);
431
0
    if (derlen != sig_len || memcmp(sigbuf, der, derlen) != 0)
432
0
        goto err;
433
0
    ret = ECDSA_do_verify(dgst, dgst_len, s, eckey);
434
0
 err:
435
0
    OPENSSL_free(der);
436
0
    ECDSA_SIG_free(s);
437
0
    return ret;
438
0
}
439
440
int ossl_ecdsa_simple_verify_sig(const unsigned char *dgst, int dgst_len,
441
                                 const ECDSA_SIG *sig, EC_KEY *eckey)
442
0
{
443
0
    int ret = -1, i;
444
0
    BN_CTX *ctx;
445
0
    const BIGNUM *order;
446
0
    BIGNUM *u1, *u2, *m, *X;
447
0
    EC_POINT *point = NULL;
448
0
    const EC_GROUP *group;
449
0
    const EC_POINT *pub_key;
450
451
    /* check input values */
452
0
    if (eckey == NULL || (group = EC_KEY_get0_group(eckey)) == NULL ||
453
0
        (pub_key = EC_KEY_get0_public_key(eckey)) == NULL || sig == NULL) {
454
0
        ERR_raise(ERR_LIB_EC, EC_R_MISSING_PARAMETERS);
455
0
        return -1;
456
0
    }
457
458
0
    if (!EC_KEY_can_sign(eckey)) {
459
0
        ERR_raise(ERR_LIB_EC, EC_R_CURVE_DOES_NOT_SUPPORT_SIGNING);
460
0
        return -1;
461
0
    }
462
463
0
    ctx = BN_CTX_new_ex(eckey->libctx);
464
0
    if (ctx == NULL) {
465
0
        ERR_raise(ERR_LIB_EC, ERR_R_BN_LIB);
466
0
        return -1;
467
0
    }
468
0
    BN_CTX_start(ctx);
469
0
    u1 = BN_CTX_get(ctx);
470
0
    u2 = BN_CTX_get(ctx);
471
0
    m = BN_CTX_get(ctx);
472
0
    X = BN_CTX_get(ctx);
473
0
    if (X == NULL) {
474
0
        ERR_raise(ERR_LIB_EC, ERR_R_BN_LIB);
475
0
        goto err;
476
0
    }
477
478
0
    order = EC_GROUP_get0_order(group);
479
0
    if (order == NULL) {
480
0
        ERR_raise(ERR_LIB_EC, ERR_R_EC_LIB);
481
0
        goto err;
482
0
    }
483
484
0
    if (BN_is_zero(sig->r) || BN_is_negative(sig->r) ||
485
0
        BN_ucmp(sig->r, order) >= 0 || BN_is_zero(sig->s) ||
486
0
        BN_is_negative(sig->s) || BN_ucmp(sig->s, order) >= 0) {
487
0
        ERR_raise(ERR_LIB_EC, EC_R_BAD_SIGNATURE);
488
0
        ret = 0;                /* signature is invalid */
489
0
        goto err;
490
0
    }
491
    /* calculate tmp1 = inv(S) mod order */
492
0
    if (!ossl_ec_group_do_inverse_ord(group, u2, sig->s, ctx)) {
493
0
        ERR_raise(ERR_LIB_EC, ERR_R_BN_LIB);
494
0
        goto err;
495
0
    }
496
    /* digest -> m */
497
0
    i = BN_num_bits(order);
498
    /*
499
     * Need to truncate digest if it is too long: first truncate whole bytes.
500
     */
501
0
    if (8 * dgst_len > i)
502
0
        dgst_len = (i + 7) / 8;
503
0
    if (!BN_bin2bn(dgst, dgst_len, m)) {
504
0
        ERR_raise(ERR_LIB_EC, ERR_R_BN_LIB);
505
0
        goto err;
506
0
    }
507
    /* If still too long truncate remaining bits with a shift */
508
0
    if ((8 * dgst_len > i) && !BN_rshift(m, m, 8 - (i & 0x7))) {
509
0
        ERR_raise(ERR_LIB_EC, ERR_R_BN_LIB);
510
0
        goto err;
511
0
    }
512
    /* u1 = m * tmp mod order */
513
0
    if (!BN_mod_mul(u1, m, u2, order, ctx)) {
514
0
        ERR_raise(ERR_LIB_EC, ERR_R_BN_LIB);
515
0
        goto err;
516
0
    }
517
    /* u2 = r * w mod q */
518
0
    if (!BN_mod_mul(u2, sig->r, u2, order, ctx)) {
519
0
        ERR_raise(ERR_LIB_EC, ERR_R_BN_LIB);
520
0
        goto err;
521
0
    }
522
523
0
    if ((point = EC_POINT_new(group)) == NULL) {
524
0
        ERR_raise(ERR_LIB_EC, ERR_R_EC_LIB);
525
0
        goto err;
526
0
    }
527
0
    if (!EC_POINT_mul(group, point, u1, pub_key, u2, ctx)) {
528
0
        ERR_raise(ERR_LIB_EC, ERR_R_EC_LIB);
529
0
        goto err;
530
0
    }
531
532
0
    if (!EC_POINT_get_affine_coordinates(group, point, X, NULL, ctx)) {
533
0
        ERR_raise(ERR_LIB_EC, ERR_R_EC_LIB);
534
0
        goto err;
535
0
    }
536
537
0
    if (!BN_nnmod(u1, X, order, ctx)) {
538
0
        ERR_raise(ERR_LIB_EC, ERR_R_BN_LIB);
539
0
        goto err;
540
0
    }
541
    /*  if the signature is correct u1 is equal to sig->r */
542
0
    ret = (BN_ucmp(u1, sig->r) == 0);
543
0
 err:
544
0
    BN_CTX_end(ctx);
545
0
    BN_CTX_free(ctx);
546
0
    EC_POINT_free(point);
547
0
    return ret;
548
0
}