Coverage Report

Created: 2025-12-31 06:58

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl33/crypto/bn/rsaz_exp.h
Line
Count
Source
1
/*
2
 * Copyright 2013-2021 The OpenSSL Project Authors. All Rights Reserved.
3
 * Copyright (c) 2020, Intel Corporation. All Rights Reserved.
4
 *
5
 * Licensed under the Apache License 2.0 (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 Shay Gueron (1, 2), and Vlad Krasnov (1)
11
 * (1) Intel Corporation, Israel Development Center, Haifa, Israel
12
 * (2) University of Haifa, Israel
13
 */
14
15
#ifndef OSSL_CRYPTO_BN_RSAZ_EXP_H
16
#define OSSL_CRYPTO_BN_RSAZ_EXP_H
17
18
#undef RSAZ_ENABLED
19
#if defined(OPENSSL_BN_ASM_MONT) && (defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64))
20
#define RSAZ_ENABLED
21
22
#include <openssl/bn.h>
23
#include "internal/constant_time.h"
24
#include "bn_local.h"
25
26
void RSAZ_1024_mod_exp_avx2(BN_ULONG result[16],
27
    const BN_ULONG base_norm[16],
28
    const BN_ULONG exponent[16],
29
    const BN_ULONG m_norm[16], const BN_ULONG RR[16],
30
    BN_ULONG k0);
31
int rsaz_avx2_eligible(void);
32
33
void RSAZ_512_mod_exp(BN_ULONG result[8],
34
    const BN_ULONG base_norm[8], const BN_ULONG exponent[8],
35
    const BN_ULONG m_norm[8], BN_ULONG k0,
36
    const BN_ULONG RR[8]);
37
38
int ossl_rsaz_avx512ifma_eligible(void);
39
40
int ossl_rsaz_mod_exp_avx512_x2(BN_ULONG *res1,
41
    const BN_ULONG *base1,
42
    const BN_ULONG *exponent1,
43
    const BN_ULONG *m1,
44
    const BN_ULONG *RR1,
45
    BN_ULONG k0_1,
46
    BN_ULONG *res2,
47
    const BN_ULONG *base2,
48
    const BN_ULONG *exponent2,
49
    const BN_ULONG *m2,
50
    const BN_ULONG *RR2,
51
    BN_ULONG k0_2,
52
    int factor_size);
53
54
static ossl_inline void bn_select_words(BN_ULONG *r, BN_ULONG mask,
55
    const BN_ULONG *a,
56
    const BN_ULONG *b, size_t num)
57
981
{
58
981
    size_t i;
59
60
8.82k
    for (i = 0; i < num; i++) {
61
7.84k
        r[i] = constant_time_select_64(mask, a[i], b[i]);
62
7.84k
    }
63
981
}
Unexecuted instantiation: bn_exp.c:bn_select_words
rsaz_exp.c:bn_select_words
Line
Count
Source
57
981
{
58
981
    size_t i;
59
60
8.82k
    for (i = 0; i < num; i++) {
61
7.84k
        r[i] = constant_time_select_64(mask, a[i], b[i]);
62
7.84k
    }
63
981
}
Unexecuted instantiation: rsaz_exp_x2.c:bn_select_words
64
65
static ossl_inline BN_ULONG bn_reduce_once_in_place(BN_ULONG *r,
66
    BN_ULONG carry,
67
    const BN_ULONG *m,
68
    BN_ULONG *tmp, size_t num)
69
981
{
70
981
    carry -= bn_sub_words(tmp, r, m, num);
71
981
    bn_select_words(r, carry, r /* tmp < 0 */, tmp /* tmp >= 0 */, num);
72
981
    return carry;
73
981
}
Unexecuted instantiation: bn_exp.c:bn_reduce_once_in_place
rsaz_exp.c:bn_reduce_once_in_place
Line
Count
Source
69
981
{
70
981
    carry -= bn_sub_words(tmp, r, m, num);
71
981
    bn_select_words(r, carry, r /* tmp < 0 */, tmp /* tmp >= 0 */, num);
72
981
    return carry;
73
981
}
Unexecuted instantiation: rsaz_exp_x2.c:bn_reduce_once_in_place
74
75
#endif
76
77
#endif