summaryrefslogtreecommitdiffabout
path: root/pwmanager/libcrypt/crypt/gcrypt-module.h
Unidiff
Diffstat (limited to 'pwmanager/libcrypt/crypt/gcrypt-module.h') (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/libcrypt/crypt/gcrypt-module.h225
1 files changed, 225 insertions, 0 deletions
diff --git a/pwmanager/libcrypt/crypt/gcrypt-module.h b/pwmanager/libcrypt/crypt/gcrypt-module.h
new file mode 100644
index 0000000..1099c92
--- a/dev/null
+++ b/pwmanager/libcrypt/crypt/gcrypt-module.h
@@ -0,0 +1,225 @@
1/* gcrypt-module.h - GNU cryptographic library interface
2 * Copyright (C) 2003 Free Software Foundation, Inc.
3 *
4 * This file is part of Libgcrypt.
5 *
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.
10 *
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.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19 */
20
21/* This file contains the necessary declarations/definitions for
22 working with Libgcrypt modules. */
23
24#ifndef _GCRYPT_MODULE_H
25#define _GCRYPT_MODULE_H
26
27#ifdef __cplusplus
28extern "C" {
29#if 0 /* keep Emacsens's auto-indent happy */
30}
31#endif
32#endif
33
34/* This type represents a `module'. */
35typedef struct gcry_module *gcry_module_t;
36
37/* Check that the library fulfills the version requirement. */
38
39/* Type for the cipher_setkey function. */
40typedef gcry_err_code_t (*gcry_cipher_setkey_t) (void *c,
41 const unsigned char *key,
42 unsigned keylen);
43
44/* Type for the cipher_encrypt function. */
45typedef void (*gcry_cipher_encrypt_t) (void *c,
46 unsigned char *outbuf,
47 const unsigned char *inbuf);
48
49/* Type for the cipher_decrypt function. */
50typedef void (*gcry_cipher_decrypt_t) (void *c,
51 unsigned char *outbuf,
52 const unsigned char *inbuf);
53
54/* Type for the cipher_stencrypt function. */
55typedef void (*gcry_cipher_stencrypt_t) (void *c,
56 unsigned char *outbuf,
57 const unsigned char *inbuf,
58 unsigned int n);
59
60/* Type for the cipher_stdecrypt function. */
61typedef void (*gcry_cipher_stdecrypt_t) (void *c,
62 unsigned char *outbuf,
63 const unsigned char *inbuf,
64 unsigned int n);
65
66typedef struct gcry_cipher_oid_spec
67{
68 const char *oid;
69 int mode;
70} gcry_cipher_oid_spec_t;
71
72/* Module specification structure for ciphers. */
73typedef struct gcry_cipher_spec
74{
75 const char *name;
76 const char **aliases;
77 gcry_cipher_oid_spec_t *oids;
78 size_t blocksize;
79 size_t keylen;
80 size_t contextsize;
81 gcry_cipher_setkey_t setkey;
82 gcry_cipher_encrypt_t encrypt;
83 gcry_cipher_decrypt_t decrypt;
84 gcry_cipher_stencrypt_t stencrypt;
85 gcry_cipher_stdecrypt_t stdecrypt;
86} gcry_cipher_spec_t;
87
88/* Register a new cipher module whose specification can be found in
89 CIPHER. On success, a new algorithm ID is stored in ALGORITHM_ID
90 and a pointer representhing this module is stored in MODULE. */
91gcry_error_t gcry_cipher_register (gcry_cipher_spec_t *cipher,
92 unsigned int *algorithm_id,
93 gcry_module_t *module);
94
95/* Unregister the cipher identified by MODULE, which must have been
96 registered with gcry_cipher_register. */
97void gcry_cipher_unregister (gcry_module_t module);
98
99/* ********************** */
100
101/* Type for the pk_generate function. */
102typedef gcry_err_code_t (*gcry_pk_generate_t) (int algo,
103 unsigned int nbits,
104 unsigned long use_e,
105 gcry_mpi_t *skey,
106 gcry_mpi_t **retfactors);
107
108/* Type for the pk_check_secret_key function. */
109typedef gcry_err_code_t (*gcry_pk_check_secret_key_t) (int algo,
110 gcry_mpi_t *skey);
111
112/* Type for the pk_encrypt function. */
113typedef gcry_err_code_t (*gcry_pk_encrypt_t) (int algo,
114 gcry_mpi_t *resarr,
115 gcry_mpi_t data,
116 gcry_mpi_t *pkey,
117 int flags);
118
119/* Type for the pk_decrypt function. */
120typedef gcry_err_code_t (*gcry_pk_decrypt_t) (int algo,
121 gcry_mpi_t *result,
122 gcry_mpi_t *data,
123 gcry_mpi_t *skey,
124 int flags);
125
126/* Type for the pk_sign function. */
127typedef gcry_err_code_t (*gcry_pk_sign_t) (int algo,
128 gcry_mpi_t *resarr,
129 gcry_mpi_t data,
130 gcry_mpi_t *skey);
131
132/* Type for the pk_verify function. */
133typedef gcry_err_code_t (*gcry_pk_verify_t) (int algo,
134 gcry_mpi_t hash,
135 gcry_mpi_t *data,
136 gcry_mpi_t *pkey,
137 int (*cmp) (void *, gcry_mpi_t),
138 void *opaquev);
139
140/* Type for the pk_get_nbits function. */
141typedef unsigned (*gcry_pk_get_nbits_t) (int algo, gcry_mpi_t *pkey);
142
143/* Module specification structure for message digests. */
144typedef struct gcry_pk_spec
145{
146 const char *name;
147 char **aliases;
148 const char *elements_pkey;
149 const char *elements_skey;
150 const char *elements_enc;
151 const char *elements_sig;
152 const char *elements_grip;
153 int use;
154 gcry_pk_generate_t generate;
155 gcry_pk_check_secret_key_t check_secret_key;
156 gcry_pk_encrypt_t encrypt;
157 gcry_pk_decrypt_t decrypt;
158 gcry_pk_sign_t sign;
159 gcry_pk_verify_t verify;
160 gcry_pk_get_nbits_t get_nbits;
161} gcry_pk_spec_t;
162
163/* Register a new pubkey module whose specification can be found in
164 PUBKEY. On success, a new algorithm ID is stored in ALGORITHM_ID
165 and a pointer representhing this module is stored in MODULE. */
166gcry_error_t gcry_pk_register (gcry_pk_spec_t *pubkey,
167 unsigned int *algorithm_id,
168 gcry_module_t *module);
169
170/* Unregister the pubkey identified by ID, which must have been
171 registered with gcry_pk_register. */
172void gcry_pk_unregister (gcry_module_t module);
173
174/* ********************** */
175
176/* Type for the md_init function. */
177typedef void (*gcry_md_init_t) (void *c);
178
179/* Type for the md_write function. */
180typedef void (*gcry_md_write_t) (void *c, unsigned char *buf, size_t nbytes);
181
182/* Type for the md_final function. */
183typedef void (*gcry_md_final_t) (void *c);
184
185/* Type for the md_read function. */
186typedef unsigned char *(*gcry_md_read_t) (void *c);
187
188typedef struct gcry_md_oid_spec
189{
190 const char *oidstring;
191} gcry_md_oid_spec_t;
192
193/* Module specification structure for message digests. */
194typedef struct gcry_md_spec
195{
196 const char *name;
197 unsigned char *asnoid;
198 int asnlen;
199 gcry_md_oid_spec_t *oids;
200 int mdlen;
201 gcry_md_init_t init;
202 gcry_md_write_t write;
203 gcry_md_final_t final;
204 gcry_md_read_t read;
205 size_t contextsize; /* allocate this amount of context */
206} gcry_md_spec_t;
207
208/* Register a new digest module whose specification can be found in
209 DIGEST. On success, a new algorithm ID is stored in ALGORITHM_ID
210 and a pointer representhing this module is stored in MODULE. */
211gcry_error_t gcry_md_register (gcry_md_spec_t *digest,
212 unsigned int *algorithm_id,
213 gcry_module_t *module);
214
215/* Unregister the digest identified by ID, which must have been
216 registered with gcry_digest_register. */
217void gcry_md_unregister (gcry_module_t module);
218
219#if 0 /* keep Emacsens's auto-indent happy */
220{
221#endif
222#ifdef __cplusplus
223}
224#endif
225#endif