removed gnutls_pubkey_get_verify_algorithm() and unnecessary internal APIs
[gnutls:gnutls.git] / lib / gnutls_pk.h
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 <http://www.gnu.org/licenses/>
20  *
21  */
22
23 #ifndef GNUTLS_PK_H
24 #define GNUTLS_PK_H
25
26 extern int crypto_pk_prio;
27 extern gnutls_crypto_pk_st _gnutls_pk_ops;
28
29 #define _gnutls_pk_encrypt( algo, ciphertext, plaintext, params) _gnutls_pk_ops.encrypt( algo, ciphertext, plaintext, params)
30 #define _gnutls_pk_decrypt( algo, ciphertext, plaintext, params) _gnutls_pk_ops.decrypt( algo, ciphertext, plaintext, params)
31 #define _gnutls_pk_sign( algo, sig, data, params) _gnutls_pk_ops.sign( algo, sig, data, params)
32 #define _gnutls_pk_verify( algo, data, sig, params) _gnutls_pk_ops.verify( algo, data, sig, params)
33 #define _gnutls_pk_verify_priv_params( algo, params) _gnutls_pk_ops.verify_priv_params( algo, params)
34 #define _gnutls_pk_verify_pub_params( algo, params) _gnutls_pk_ops.verify_pub_params( algo, params)
35 #define _gnutls_pk_derive( algo, out, pub, priv) _gnutls_pk_ops.derive( algo, out, pub, priv)
36 #define _gnutls_pk_generate_keys( algo, bits, priv) _gnutls_pk_ops.generate_keys( algo, bits, priv)
37 #define _gnutls_pk_generate_params( algo, bits, priv) _gnutls_pk_ops.generate_params( algo, bits, priv)
38 #define _gnutls_pk_hash_algorithm( pk, sig, params, hash) _gnutls_pk_ops.hash_algorithm(pk, sig, params, hash)
39 #define _gnutls_pk_curve_exists( curve) _gnutls_pk_ops.curve_exists(curve)
40
41 inline static int
42 _gnutls_pk_fixup(gnutls_pk_algorithm_t algo, gnutls_direction_t direction,
43                  gnutls_pk_params_st * params)
44 {
45         if (_gnutls_pk_ops.pk_fixup_private_params)
46                 return _gnutls_pk_ops.pk_fixup_private_params(algo,
47                                                               direction,
48                                                               params);
49         return 0;
50 }
51
52 int _gnutls_pk_params_copy(gnutls_pk_params_st * dst,
53                            const gnutls_pk_params_st * src);
54
55 /* The internal PK interface */
56 int
57 _gnutls_encode_ber_rs(gnutls_datum_t * sig_value, bigint_t r, bigint_t s);
58 int
59 _gnutls_encode_ber_rs_raw(gnutls_datum_t * sig_value,
60                           const gnutls_datum_t * r,
61                           const gnutls_datum_t * s);
62
63 int
64 _gnutls_decode_ber_rs(const gnutls_datum_t * sig_value, bigint_t * r,
65                       bigint_t * s);
66
67 int
68 encode_ber_digest_info(const mac_entry_st * e,
69                        const gnutls_datum_t * digest,
70                        gnutls_datum_t * output);
71
72 int
73 decode_ber_digest_info(const gnutls_datum_t * info,
74                        gnutls_digest_algorithm_t * hash,
75                        uint8_t * digest, unsigned int *digest_size);
76
77 int
78 _gnutls_params_get_rsa_raw(const gnutls_pk_params_st* params,
79                                     gnutls_datum_t * m, gnutls_datum_t * e,
80                                     gnutls_datum_t * d, gnutls_datum_t * p,
81                                     gnutls_datum_t * q, gnutls_datum_t * u,
82                                     gnutls_datum_t * e1,
83                                     gnutls_datum_t * e2);
84
85 int
86 _gnutls_params_get_dsa_raw(const gnutls_pk_params_st* params,
87                              gnutls_datum_t * p, gnutls_datum_t * q,
88                              gnutls_datum_t * g, gnutls_datum_t * y,
89                              gnutls_datum_t * x);
90
91 int _gnutls_params_get_ecc_raw(const gnutls_pk_params_st* params,
92                                        gnutls_ecc_curve_t * curve,
93                                        gnutls_datum_t * x,
94                                        gnutls_datum_t * y,
95                                        gnutls_datum_t * k);
96
97 #endif                          /* GNUTLS_PK_H */