1
/* cipher-proto.h - Internal declarations
2
* Copyright (C) 2008, 2011 Free Software Foundation, Inc.
4
* This file is part of Libgcrypt.
6
* Libgcrypt is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU Lesser general Public License as
8
* published by the Free Software Foundation; either version 2.1 of
9
* the License, or (at your option) any later version.
11
* Libgcrypt is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU Lesser General Public License for more details.
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with this program; if not, see <http://www.gnu.org/licenses/>.
20
/* This file has been factored out from cipher.h so that it can be
21
used standalone in visibility.c . */
23
#ifndef G10_CIPHER_PROTO_H
24
#define G10_CIPHER_PROTO_H
26
/* Definition of a function used to report selftest failures.
27
DOMAIN is a string describing the function block:
28
"cipher", "digest", "pubkey or "random",
29
ALGO is the algorithm under test,
30
WHAT is a string describing what has been tested,
31
DESC is a string describing the error. */
32
typedef void (*selftest_report_func_t)(const char *domain,
37
/* Definition of the selftest functions. */
38
typedef gpg_err_code_t (*selftest_func_t)
39
(int algo, int extended, selftest_report_func_t report);
42
/* An extended type of the generate function. */
43
typedef gcry_err_code_t (*pk_ext_generate_t)
49
gcry_mpi_t **retfactors,
50
gcry_sexp_t *extrainfo);
52
/* The type used to compute the keygrip. */
53
typedef gpg_err_code_t (*pk_comp_keygrip_t)
54
(gcry_md_hd_t md, gcry_sexp_t keyparm);
56
/* The type used to query ECC curve parameters. */
57
typedef gcry_err_code_t (*pk_get_param_t)
58
(const char *name, gcry_mpi_t *pkey);
60
/* The type used to query an ECC curve name. */
61
typedef const char *(*pk_get_curve_t)(gcry_mpi_t *pkey, int iterator,
62
unsigned int *r_nbits);
64
/* The type used to query ECC curve parameters by name. */
65
typedef gcry_sexp_t (*pk_get_curve_param_t)(const char *name);
67
/* The type used to convey additional information to a cipher. */
68
typedef gpg_err_code_t (*cipher_set_extra_info_t)
69
(void *c, int what, const void *buffer, size_t buflen);
72
/* Extra module specification structures. These are used for internal
73
modules which provide more functions than available through the
74
public algorithm register APIs. */
75
typedef struct cipher_extra_spec
77
selftest_func_t selftest;
78
cipher_set_extra_info_t set_extra_info;
79
} cipher_extra_spec_t;
81
typedef struct md_extra_spec
83
selftest_func_t selftest;
86
typedef struct pk_extra_spec
88
selftest_func_t selftest;
89
pk_ext_generate_t ext_generate;
90
pk_comp_keygrip_t comp_keygrip;
91
pk_get_param_t get_param;
92
pk_get_curve_t get_curve;
93
pk_get_curve_param_t get_curve_param;
98
/* The private register functions. */
99
gcry_error_t _gcry_cipher_register (gcry_cipher_spec_t *cipher,
100
cipher_extra_spec_t *extraspec,
102
gcry_module_t *module);
103
gcry_error_t _gcry_md_register (gcry_md_spec_t *cipher,
104
md_extra_spec_t *extraspec,
105
unsigned int *algorithm_id,
106
gcry_module_t *module);
107
gcry_error_t _gcry_pk_register (gcry_pk_spec_t *cipher,
108
pk_extra_spec_t *extraspec,
109
unsigned int *algorithm_id,
110
gcry_module_t *module);
112
/* The selftest functions. */
113
gcry_error_t _gcry_cipher_selftest (int algo, int extended,
114
selftest_report_func_t report);
115
gcry_error_t _gcry_md_selftest (int algo, int extended,
116
selftest_report_func_t report);
117
gcry_error_t _gcry_pk_selftest (int algo, int extended,
118
selftest_report_func_t report);
119
gcry_error_t _gcry_hmac_selftest (int algo, int extended,
120
selftest_report_func_t report);
122
gcry_error_t _gcry_random_selftest (selftest_report_func_t report);
124
#endif /*G10_CIPHER_PROTO_H*/