Coverage Report

Created: 2025-11-16 06:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/gnutls/lib/pk.h
Line
Count
Source
1
/*
2
 * Copyright (C) 2000-2012 Free Software Foundation, Inc.
3
 *
4
 * Author: Nikos Mavrogiannopoulos
5
 *
6
 * This file is part of GnuTLS.
7
 *
8
 * The GnuTLS is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU Lesser General Public License
10
 * as published by the Free Software Foundation; either version 2.1 of
11
 * the License, or (at your option) any later version.
12
 *
13
 * This library is distributed in the hope that it will be useful, but
14
 * WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
 * Lesser General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Lesser General Public License
19
 * along with this program.  If not, see <https://www.gnu.org/licenses/>
20
 *
21
 */
22
23
#ifndef GNUTLS_LIB_PK_H
24
#define GNUTLS_LIB_PK_H
25
26
#include "crypto-backend.h"
27
28
extern int crypto_pk_prio;
29
30
#define _gnutls_pk_encrypt(algo, ciphertext, plaintext, params,            \
31
         encrypt_params)                                 \
32
0
  _gnutls_pk_backend()->encrypt(algo, ciphertext, plaintext, params, \
33
0
              encrypt_params)
34
#define _gnutls_pk_decrypt(algo, ciphertext, plaintext, params,            \
35
         encrypt_params)                                 \
36
0
  _gnutls_pk_backend()->decrypt(algo, ciphertext, plaintext, params, \
37
0
              encrypt_params)
38
#define _gnutls_pk_decrypt2(algo, ciphertext, plaintext, size, params,    \
39
          encrypt_params)                               \
40
0
  _gnutls_pk_backend()->decrypt2(algo, ciphertext, plaintext, size, \
41
0
               params, encrypt_params)
42
#define _gnutls_pk_sign(algo, sig, data, params, sign_params) \
43
0
  _gnutls_pk_backend()->sign(algo, sig, data, params, sign_params)
44
#define _gnutls_pk_verify(algo, data, sig, params, sign_params) \
45
0
  _gnutls_pk_backend()->verify(algo, data, sig, params, sign_params)
46
#define _gnutls_pk_verify_priv_params(algo, params) \
47
0
  _gnutls_pk_backend()->verify_priv_params(algo, params)
48
#define _gnutls_pk_verify_pub_params(algo, params) \
49
0
  _gnutls_pk_backend()->verify_pub_params(algo, params)
50
#define _gnutls_pk_derive(algo, out, pub, priv) \
51
0
  _gnutls_pk_backend()->derive(algo, out, pub, priv, NULL, 0)
52
#define _gnutls_pk_derive_nonce(algo, out, pub, priv, nonce) \
53
0
  _gnutls_pk_backend()->derive(algo, out, pub, priv, nonce, 0)
54
#define _gnutls_pk_derive_tls13(algo, out, pub, priv)            \
55
0
  _gnutls_pk_backend()->derive(algo, out, pub, priv, NULL, \
56
0
             PK_DERIVE_TLS13)
57
#define _gnutls_pk_encaps(algo, ciphertext, shared_secret, pub) \
58
0
  _gnutls_pk_backend()->encaps(algo, ciphertext, shared_secret, pub)
59
#define _gnutls_pk_decaps(algo, shared_secret, ciphertext, priv) \
60
0
  _gnutls_pk_backend()->decaps(algo, shared_secret, ciphertext, priv)
61
#define _gnutls_pk_generate_keys(algo, bits, params, temporal) \
62
0
  _gnutls_pk_backend()->generate_keys(algo, bits, params, temporal)
63
#define _gnutls_pk_generate_params(algo, bits, priv) \
64
0
  _gnutls_pk_backend()->generate_params(algo, bits, priv)
65
#define _gnutls_pk_hash_algorithm(pk, sig, params, hash) \
66
  _gnutls_pk_backend()->hash_algorithm(pk, sig, params, hash)
67
0
#define _gnutls_pk_curve_exists(curve) _gnutls_pk_backend()->curve_exists(curve)
68
0
#define _gnutls_pk_exists(algo) _gnutls_pk_backend()->pk_exists(algo)
69
#define _gnutls_pk_sign_exists(algo) _gnutls_pk_backend()->sign_exists(algo)
70
71
inline static int _gnutls_pk_fixup(gnutls_pk_algorithm_t algo,
72
           gnutls_direction_t direction,
73
           gnutls_pk_params_st *params)
74
0
{
75
0
  if (_gnutls_pk_backend()->pk_fixup_private_params)
76
0
    return _gnutls_pk_backend()->pk_fixup_private_params(
77
0
      algo, direction, params);
78
0
  return 0;
79
0
}
Unexecuted instantiation: cert-cred-x509.c:_gnutls_pk_fixup
Unexecuted instantiation: privkey.c:_gnutls_pk_fixup
Unexecuted instantiation: pubkey.c:_gnutls_pk_fixup
Unexecuted instantiation: crypto-backend.c:_gnutls_pk_fixup
Unexecuted instantiation: keys-dummy.c:_gnutls_pk_fixup
Unexecuted instantiation: crq.c:_gnutls_pk_fixup
Unexecuted instantiation: key_decode.c:_gnutls_pk_fixup
Unexecuted instantiation: key_encode.c:_gnutls_pk_fixup
Unexecuted instantiation: ocsp.c:_gnutls_pk_fixup
Unexecuted instantiation: pkcs7-crypt.c:_gnutls_pk_fixup
Unexecuted instantiation: privkey_pkcs8.c:_gnutls_pk_fixup
Unexecuted instantiation: sign.c:_gnutls_pk_fixup
Unexecuted instantiation: tls_features.c:_gnutls_pk_fixup
Unexecuted instantiation: verify.c:_gnutls_pk_fixup
Unexecuted instantiation: x509.c:_gnutls_pk_fixup
Unexecuted instantiation: x509_write.c:_gnutls_pk_fixup
Unexecuted instantiation: key_share.c:_gnutls_pk_fixup
Unexecuted instantiation: cert.c:_gnutls_pk_fixup
Unexecuted instantiation: dh_common.c:_gnutls_pk_fixup
Unexecuted instantiation: ecc.c:_gnutls_pk_fixup
Unexecuted instantiation: groups.c:_gnutls_pk_fixup
Unexecuted instantiation: publickey.c:_gnutls_pk_fixup
Unexecuted instantiation: pk.c:_gnutls_pk_fixup
Unexecuted instantiation: dh.c:_gnutls_pk_fixup
Unexecuted instantiation: tls-sig.c:_gnutls_pk_fixup
Unexecuted instantiation: ecdhe.c:_gnutls_pk_fixup
Unexecuted instantiation: rsa.c:_gnutls_pk_fixup
Unexecuted instantiation: rsa_psk.c:_gnutls_pk_fixup
Unexecuted instantiation: vko_gost.c:_gnutls_pk_fixup
Unexecuted instantiation: vko.c:_gnutls_pk_fixup
80
81
int _gnutls_pk_params_copy(gnutls_pk_params_st *dst,
82
         const gnutls_pk_params_st *src);
83
84
/* The internal PK interface */
85
int _gnutls_encode_ber_rs(gnutls_datum_t *sig_value, bigint_t r, bigint_t s);
86
int _gnutls_encode_ber_rs_raw(gnutls_datum_t *sig_value,
87
            const gnutls_datum_t *r, const gnutls_datum_t *s);
88
89
int _gnutls_decode_ber_rs(const gnutls_datum_t *sig_value, bigint_t *r,
90
        bigint_t *s);
91
92
int _gnutls_decode_ber_rs_raw(const gnutls_datum_t *sig_value,
93
            gnutls_datum_t *r, gnutls_datum_t *s);
94
95
int _gnutls_encode_gost_rs(gnutls_datum_t *sig_value, bigint_t r, bigint_t s,
96
         size_t intsize);
97
98
int _gnutls_decode_gost_rs(const gnutls_datum_t *sig_value, bigint_t *r,
99
         bigint_t *s);
100
101
gnutls_digest_algorithm_t _gnutls_gost_digest(gnutls_pk_algorithm_t pk);
102
gnutls_pk_algorithm_t _gnutls_digest_gost(gnutls_digest_algorithm_t digest);
103
gnutls_gost_paramset_t _gnutls_gost_paramset_default(gnutls_pk_algorithm_t pk);
104
105
int encode_ber_digest_info(const mac_entry_st *e, const gnutls_datum_t *digest,
106
         gnutls_datum_t *output);
107
108
#define decode_ber_digest_info gnutls_decode_ber_digest_info
109
110
int _gnutls_params_get_rsa_raw(const gnutls_pk_params_st *params,
111
             gnutls_datum_t *m, gnutls_datum_t *e,
112
             gnutls_datum_t *d, gnutls_datum_t *p,
113
             gnutls_datum_t *q, gnutls_datum_t *u,
114
             gnutls_datum_t *e1, gnutls_datum_t *e2,
115
             unsigned int flags);
116
117
int _gnutls_params_get_dsa_raw(const gnutls_pk_params_st *params,
118
             gnutls_datum_t *p, gnutls_datum_t *q,
119
             gnutls_datum_t *g, gnutls_datum_t *y,
120
             gnutls_datum_t *x, unsigned int flags);
121
122
int _gnutls_params_get_ecc_raw(const gnutls_pk_params_st *params,
123
             gnutls_ecc_curve_t *curve, gnutls_datum_t *x,
124
             gnutls_datum_t *y, gnutls_datum_t *k,
125
             unsigned int flags);
126
127
int _gnutls_params_get_gost_raw(const gnutls_pk_params_st *params,
128
        gnutls_ecc_curve_t *curve,
129
        gnutls_digest_algorithm_t *digest,
130
        gnutls_gost_paramset_t *paramset,
131
        gnutls_datum_t *x, gnutls_datum_t *y,
132
        gnutls_datum_t *k, unsigned int flags);
133
134
int pk_prepare_hash(gnutls_pk_algorithm_t pk, const mac_entry_st *hash,
135
        gnutls_datum_t *output);
136
int pk_hash_data(gnutls_pk_algorithm_t pk, const mac_entry_st *hash,
137
     gnutls_pk_params_st *params, const gnutls_datum_t *data,
138
     gnutls_datum_t *digest);
139
140
int _gnutls_find_rsa_pss_salt_size(unsigned bits, const mac_entry_st *me,
141
           unsigned salt_size);
142
143
#endif /* GNUTLS_LIB_PK_H */