Coverage Report

Created: 2025-04-22 06:18

/src/openssl/crypto/bn/bn_depr.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2002-2021 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
 * Support for deprecated functions goes here - static linkage will only
12
 * slurp this code if applications are using them directly.
13
 */
14
15
#include <openssl/opensslconf.h>
16
17
#include <stdio.h>
18
#include <time.h>
19
#include "internal/cryptlib.h"
20
#include "bn_local.h"
21
22
BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe,
23
                          const BIGNUM *add, const BIGNUM *rem,
24
                          void (*callback) (int, int, void *), void *cb_arg)
25
0
{
26
0
    BN_GENCB cb;
27
0
    BIGNUM *rnd = NULL;
28
29
0
    BN_GENCB_set_old(&cb, callback, cb_arg);
30
31
0
    if (ret == NULL) {
32
0
        if ((rnd = BN_new()) == NULL)
33
0
            goto err;
34
0
    } else
35
0
        rnd = ret;
36
0
    if (!BN_generate_prime_ex(rnd, bits, safe, add, rem, &cb))
37
0
        goto err;
38
39
    /* we have a prime :-) */
40
0
    return rnd;
41
0
 err:
42
0
    BN_free(rnd);
43
0
    return NULL;
44
0
}
45
46
int BN_is_prime(const BIGNUM *a, int checks,
47
                void (*callback) (int, int, void *), BN_CTX *ctx_passed,
48
                void *cb_arg)
49
0
{
50
0
    BN_GENCB cb;
51
0
    BN_GENCB_set_old(&cb, callback, cb_arg);
52
0
    return ossl_bn_check_prime(a, checks, ctx_passed, 0, &cb);
53
0
}
54
55
int BN_is_prime_fasttest(const BIGNUM *a, int checks,
56
                         void (*callback) (int, int, void *),
57
                         BN_CTX *ctx_passed, void *cb_arg,
58
                         int do_trial_division)
59
0
{
60
0
    BN_GENCB cb;
61
0
    BN_GENCB_set_old(&cb, callback, cb_arg);
62
0
    return ossl_bn_check_prime(a, checks, ctx_passed, do_trial_division, &cb);
63
0
}