Coverage Report

Created: 2025-07-23 07:18

/src/gnutls/lib/pk.h
Line
Count
Source (jump to first uncovered line)
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
0
  _gnutls_pk_backend()->encrypt(algo, ciphertext, plaintext, params)
32
#define _gnutls_pk_decrypt(algo, ciphertext, plaintext, params) \
33
0
  _gnutls_pk_backend()->decrypt(algo, ciphertext, plaintext, params)
34
#define _gnutls_pk_decrypt2(algo, ciphertext, plaintext, size, params)    \
35
0
  _gnutls_pk_backend()->decrypt2(algo, ciphertext, plaintext, size, \
36
0
               params)
37
#define _gnutls_pk_sign(algo, sig, data, params, sign_params) \
38
0
  _gnutls_pk_backend()->sign(algo, sig, data, params, sign_params)
39
#define _gnutls_pk_verify(algo, data, sig, params, sign_params) \
40
0
  _gnutls_pk_backend()->verify(algo, data, sig, params, sign_params)
41
#define _gnutls_pk_verify_priv_params(algo, params) \
42
0
  _gnutls_pk_backend()->verify_priv_params(algo, params)
43
#define _gnutls_pk_verify_pub_params(algo, params) \
44
0
  _gnutls_pk_backend()->verify_pub_params(algo, params)
45
#define _gnutls_pk_derive(algo, out, pub, priv) \
46
0
  _gnutls_pk_backend()->derive(algo, out, pub, priv, NULL, 0)
47
#define _gnutls_pk_derive_nonce(algo, out, pub, priv, nonce) \
48
0
  _gnutls_pk_backend()->derive(algo, out, pub, priv, nonce, 0)
49
#define _gnutls_pk_derive_tls13(algo, out, pub, priv)            \
50
0
  _gnutls_pk_backend()->derive(algo, out, pub, priv, NULL, \
51
0
             PK_DERIVE_TLS13)
52
#define _gnutls_pk_encaps(algo, ciphertext, shared_secret, pub) \
53
0
  _gnutls_pk_backend()->encaps(algo, ciphertext, shared_secret, pub)
54
#define _gnutls_pk_decaps(algo, shared_secret, ciphertext, priv) \
55
0
  _gnutls_pk_backend()->decaps(algo, shared_secret, ciphertext, priv)
56
#define _gnutls_pk_generate_keys(algo, bits, params, temporal) \
57
0
  _gnutls_pk_backend()->generate_keys(algo, bits, params, temporal)
58
#define _gnutls_pk_generate_params(algo, bits, priv) \
59
0
  _gnutls_pk_backend()->generate_params(algo, bits, priv)
60
#define _gnutls_pk_hash_algorithm(pk, sig, params, hash) \
61
  _gnutls_pk_backend()->hash_algorithm(pk, sig, params, hash)
62
0
#define _gnutls_pk_curve_exists(curve) _gnutls_pk_backend()->curve_exists(curve)
63
0
#define _gnutls_pk_exists(algo) _gnutls_pk_backend()->pk_exists(algo)
64
#define _gnutls_pk_sign_exists(algo) _gnutls_pk_backend()->sign_exists(algo)
65
66
inline static int _gnutls_pk_fixup(gnutls_pk_algorithm_t algo,
67
           gnutls_direction_t direction,
68
           gnutls_pk_params_st *params)
69
0
{
70
0
  if (_gnutls_pk_backend()->pk_fixup_private_params)
71
0
    return _gnutls_pk_backend()->pk_fixup_private_params(
72
0
      algo, direction, params);
73
0
  return 0;
74
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
75
76
int _gnutls_pk_params_copy(gnutls_pk_params_st *dst,
77
         const gnutls_pk_params_st *src);
78
79
/* The internal PK interface */
80
int _gnutls_encode_ber_rs(gnutls_datum_t *sig_value, bigint_t r, bigint_t s);
81
int _gnutls_encode_ber_rs_raw(gnutls_datum_t *sig_value,
82
            const gnutls_datum_t *r, const gnutls_datum_t *s);
83
84
int _gnutls_decode_ber_rs(const gnutls_datum_t *sig_value, bigint_t *r,
85
        bigint_t *s);
86
87
int _gnutls_decode_ber_rs_raw(const gnutls_datum_t *sig_value,
88
            gnutls_datum_t *r, gnutls_datum_t *s);
89
90
int _gnutls_encode_gost_rs(gnutls_datum_t *sig_value, bigint_t r, bigint_t s,
91
         size_t intsize);
92
93
int _gnutls_decode_gost_rs(const gnutls_datum_t *sig_value, bigint_t *r,
94
         bigint_t *s);
95
96
gnutls_digest_algorithm_t _gnutls_gost_digest(gnutls_pk_algorithm_t pk);
97
gnutls_pk_algorithm_t _gnutls_digest_gost(gnutls_digest_algorithm_t digest);
98
gnutls_gost_paramset_t _gnutls_gost_paramset_default(gnutls_pk_algorithm_t pk);
99
100
int encode_ber_digest_info(const mac_entry_st *e, const gnutls_datum_t *digest,
101
         gnutls_datum_t *output);
102
103
#define decode_ber_digest_info gnutls_decode_ber_digest_info
104
105
int _gnutls_params_get_rsa_raw(const gnutls_pk_params_st *params,
106
             gnutls_datum_t *m, gnutls_datum_t *e,
107
             gnutls_datum_t *d, gnutls_datum_t *p,
108
             gnutls_datum_t *q, gnutls_datum_t *u,
109
             gnutls_datum_t *e1, gnutls_datum_t *e2,
110
             unsigned int flags);
111
112
int _gnutls_params_get_dsa_raw(const gnutls_pk_params_st *params,
113
             gnutls_datum_t *p, gnutls_datum_t *q,
114
             gnutls_datum_t *g, gnutls_datum_t *y,
115
             gnutls_datum_t *x, unsigned int flags);
116
117
int _gnutls_params_get_ecc_raw(const gnutls_pk_params_st *params,
118
             gnutls_ecc_curve_t *curve, gnutls_datum_t *x,
119
             gnutls_datum_t *y, gnutls_datum_t *k,
120
             unsigned int flags);
121
122
int _gnutls_params_get_gost_raw(const gnutls_pk_params_st *params,
123
        gnutls_ecc_curve_t *curve,
124
        gnutls_digest_algorithm_t *digest,
125
        gnutls_gost_paramset_t *paramset,
126
        gnutls_datum_t *x, gnutls_datum_t *y,
127
        gnutls_datum_t *k, unsigned int flags);
128
129
int pk_prepare_hash(gnutls_pk_algorithm_t pk, const mac_entry_st *hash,
130
        gnutls_datum_t *output);
131
int pk_hash_data(gnutls_pk_algorithm_t pk, const mac_entry_st *hash,
132
     gnutls_pk_params_st *params, const gnutls_datum_t *data,
133
     gnutls_datum_t *digest);
134
135
int _gnutls_find_rsa_pss_salt_size(unsigned bits, const mac_entry_st *me,
136
           unsigned salt_size);
137
138
#endif /* GNUTLS_LIB_PK_H */