summaryrefslogtreecommitdiff
path: root/src/cipher-proto.h
blob: 4ca76b55641e716459ba304ddc48a0e384c8933f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* cipher-proto.h - Internal declarations
 *	Copyright (C) 2008 Free Software Foundation, Inc.
 *
 * This file is part of Libgcrypt.
 *
 * Libgcrypt is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser general Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * Libgcrypt is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program; if not, see <http://www.gnu.org/licenses/>.
 */

/* This file has been factored out from cipher.h so that it can be
   used standalone in visibility.c . */

#ifndef G10_CIPHER_PROTO_H
#define G10_CIPHER_PROTO_H

/* Definition of a function used to report selftest failures. 
   DOMAIN is a string describing the function block:
          "cipher", "digest", "pubkey or "random",
   ALGO   is the algorithm under test,
   WHAT   is a string describing what has been tested,
   DESC   is a string describing the error. */
typedef void (*selftest_report_func_t)(const char *domain,
                                       int algo, 
                                       const char *what,
                                       const char *errdesc);

/* Definition of the selftest functions.  */
typedef gpg_err_code_t (*selftest_func_t)
     (int algo, selftest_report_func_t report);


/* An extended type of the generate function.  */
typedef gcry_err_code_t (*pk_ext_generate_t)
     (int algo,
      unsigned int nbits,
      unsigned long use_e,
      unsigned int keygen_flags, 
      gcry_mpi_t *skey,
      gcry_mpi_t **retfactors);


/* Extra module specification structures.  These are used for internal
   modules which provide more functions than available through the
   public algorithm register APIs.  */
typedef struct cipher_extra_spec
{
  selftest_func_t selftest;
} cipher_extra_spec_t;

typedef struct md_extra_spec
{
  selftest_func_t selftest;
} md_extra_spec_t;

typedef struct pk_extra_spec
{
  selftest_func_t selftest;
  pk_ext_generate_t ext_generate;
} pk_extra_spec_t;



/* The private register functions. */
gcry_error_t _gcry_cipher_register (gcry_cipher_spec_t *cipher,
                                    cipher_extra_spec_t *extraspec,
                                    int *algorithm_id,
                                    gcry_module_t *module);
gcry_error_t _gcry_md_register (gcry_md_spec_t *cipher,
                                md_extra_spec_t *extraspec,
                                unsigned int *algorithm_id,
                                gcry_module_t *module);
gcry_error_t _gcry_pk_register (gcry_pk_spec_t *cipher,
                                pk_extra_spec_t *extraspec,
                                unsigned int *algorithm_id,
                                gcry_module_t *module);

/* The selftest functions.  */
gcry_error_t _gcry_cipher_selftest (int algo, selftest_report_func_t report);
gcry_error_t _gcry_md_selftest (int algo, selftest_report_func_t report);
gcry_error_t _gcry_pk_selftest (int algo, selftest_report_func_t report);
gcry_error_t _gcry_hmac_selftest (int algo, selftest_report_func_t report);

gcry_error_t _gcry_random_selftest (selftest_report_func_t report);

#endif /*G10_CIPHER_PROTO_H*/