1 /* gcrypt.h - GNU digital encryption library interface
2 * Copyright (C) 1998, 1999, 2000, 2001 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 General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (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 General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
31 * The version of this header should match the one of the library
32 * It should not be used by a program because gcry_check_version()
33 * should reurn the same version. The purpose of this macro is to
34 * let autoconf (using the AM_PATH_GCRYPT macro) check that this
35 * header matches the installed library.
36 * Note: Do not edit the next line as configure may fix the string here.
38 #define GCRYPT_VERSION "1.1.6"
41 #ifndef HAVE_BYTE_TYPEDEF
42 # undef byte /* maybe there is a macro with this name */
43 typedef unsigned char byte;
44 # define HAVE_BYTE_TYPEDEF
47 #ifdef _GCRYPT_IN_LIBGCRYPT
48 # ifndef GCRYPT_NO_MPI_MACROS
49 # define GCRYPT_NO_MPI_MACROS 1
54 typedef struct gcry_mpi *GCRY_MPI;
56 /*******************************************
58 * error handling etc. *
60 *******************************************/
62 /* FIXME: We should use the same values as they were used in GnuPG 1.0.
63 * gpg --status-fd may print some of these values */
65 GCRYERR_SUCCESS = 0, /* "no error" */
66 GCRYERR_GENERAL = 1, /* catch all the other errors code */
68 GCRYERR_INV_PK_ALGO = 4, /* invalid public key algorithm */
69 GCRYERR_INV_MD_ALGO = 5, /* invalid message digest algorithm */
70 GCRYERR_BAD_PUBLIC_KEY = 6, /* Bad public key */
71 GCRYERR_BAD_SECRET_KEY = 7, /* Bad secret key */
72 GCRYERR_BAD_SIGNATURE = 8, /* Bad signature */
74 GCRYERR_INV_CIPHER_ALGO = 12, /* invalid cipher algorithm */
76 GCRYERR_WRONG_PK_ALGO = 41, /* wrong public key algorithm */
77 GCRYERR_WEAK_KEY = 43, /* weak encryption key */
78 GCRYERR_INV_KEYLEN = 44, /* invalid length of a key*/
79 GCRYERR_INV_ARG = 45, /* invalid argument */
80 GCRYERR_SELFTEST = 50, /* selftest failed */
82 /* error codes not used in GnuPG 1.0 */
83 GCRYERR_INV_OP = 61, /* invalid operation code or ctl command */
84 GCRYERR_NO_MEM = 62, /* out of core */
85 GCRYERR_INTERNAL = 63, /* internal error */
86 GCRYERR_EOF = 64, /* (-1) is remapped to this value */
87 GCRYERR_INV_OBJ = 65, /* an object is not valid */
88 GCRYERR_TOO_SHORT = 66, /* provided buffer too short */
89 GCRYERR_TOO_LARGE = 67, /* object is too large */
90 GCRYERR_NO_OBJ = 68, /* Missing item in an object */
91 GCRYERR_NOT_IMPL = 69, /* Not implemented */
92 GCRYERR_CONFLICT = 70,
93 GCRYERR_INV_CIPHER_MODE = 71
96 const char *gcry_check_version( const char *req_version );
99 const char *gcry_strerror( int ec );
104 GCRYCTL_CFB_SYNC = 3,
105 GCRYCTL_RESET = 4, /* e.g. for MDs */
106 GCRYCTL_FINALIZE = 5,
107 GCRYCTL_GET_KEYLEN = 6,
108 GCRYCTL_GET_BLKLEN = 7,
109 GCRYCTL_TEST_ALGO = 8,
110 GCRYCTL_IS_SECURE = 9,
111 GCRYCTL_GET_ASNOID = 10,
112 GCRYCTL_ENABLE_ALGO = 11,
113 GCRYCTL_DISABLE_ALGO = 12,
114 GCRYCTL_DUMP_RANDOM_STATS = 13,
115 GCRYCTL_DUMP_SECMEM_STATS = 14,
116 GCRYCTL_GET_ALGO_NPKEY = 15,
117 GCRYCTL_GET_ALGO_NSKEY = 16,
118 GCRYCTL_GET_ALGO_NSIGN = 17,
119 GCRYCTL_GET_ALGO_NENCR = 18,
120 GCRYCTL_SET_VERBOSITY = 19,
121 GCRYCTL_SET_DEBUG_FLAGS = 20,
122 GCRYCTL_CLEAR_DEBUG_FLAGS = 21,
123 GCRYCTL_USE_SECURE_RNDPOOL= 22,
124 GCRYCTL_DUMP_MEMORY_STATS = 23,
125 GCRYCTL_INIT_SECMEM = 24,
126 GCRYCTL_TERM_SECMEM = 25,
127 GCRYCTL_DISABLE_SECMEM_WARN = 27,
128 GCRYCTL_SUSPEND_SECMEM_WARN = 28,
129 GCRYCTL_RESUME_SECMEM_WARN = 29,
130 GCRYCTL_DROP_PRIVS = 30,
131 GCRYCTL_ENABLE_M_GUARD = 31,
132 GCRYCTL_START_DUMP = 32,
133 GCRYCTL_STOP_DUMP = 33,
134 GCRYCTL_GET_ALGO_USAGE = 34,
135 GCRYCTL_IS_ALGO_ENABLED = 35
138 int gcry_control( enum gcry_ctl_cmds, ... );
140 enum gcry_random_level {
141 GCRY_WEAK_RANDOM = 0,
142 GCRY_STRONG_RANDOM = 1,
143 GCRY_VERY_STRONG_RANDOM = 2
148 typedef struct gcry_sexp *GCRY_SEXP;
150 enum gcry_sexp_format {
151 GCRYSEXP_FMT_DEFAULT = 0,
152 GCRYSEXP_FMT_CANON = 1,
153 GCRYSEXP_FMT_BASE64 = 2,
154 GCRYSEXP_FMT_ADVANCED = 3
157 void gcry_sexp_release( GCRY_SEXP sexp );
158 void gcry_sexp_dump( const GCRY_SEXP a );
159 GCRY_SEXP gcry_sexp_cons( const GCRY_SEXP a, const GCRY_SEXP b );
160 GCRY_SEXP gcry_sexp_alist( const GCRY_SEXP *array );
161 GCRY_SEXP gcry_sexp_vlist( const GCRY_SEXP a, ... );
162 GCRY_SEXP gcry_sexp_append( const GCRY_SEXP a, const GCRY_SEXP n );
163 GCRY_SEXP gcry_sexp_prepend( const GCRY_SEXP a, const GCRY_SEXP n );
164 int gcry_sexp_sscan( GCRY_SEXP *retsexp, size_t *erroff,
165 const char *buffer, size_t length );
166 int gcry_sexp_build( GCRY_SEXP *retsexp, size_t *erroff,
167 const char *format, ... );
168 size_t gcry_sexp_sprint( GCRY_SEXP sexp, int mode, char *buffer,
170 GCRY_SEXP gcry_sexp_find_token( GCRY_SEXP list,
171 const char *tok, size_t toklen );
172 int gcry_sexp_length( const GCRY_SEXP list );
173 GCRY_SEXP gcry_sexp_nth( const GCRY_SEXP list, int number );
174 GCRY_SEXP gcry_sexp_car( const GCRY_SEXP list );
175 GCRY_SEXP gcry_sexp_cdr( const GCRY_SEXP list );
176 GCRY_SEXP gcry_sexp_cadr( const GCRY_SEXP list );
177 const char *gcry_sexp_nth_data( const GCRY_SEXP list, int number,
179 GCRY_MPI gcry_sexp_nth_mpi( GCRY_SEXP list, int number, int mpifmt );
181 size_t gcry_sexp_canon_len (const unsigned char *buffer, size_t length,
182 size_t *erroff, int *errcode);
185 /*******************************************
187 * multi precision integer functions *
189 *******************************************/
191 enum gcry_mpi_format {
193 GCRYMPI_FMT_STD = 1, /* twos complement stored without length */
194 GCRYMPI_FMT_PGP = 2, /* As used by OpenPGP (only defined as unsigned)*/
195 GCRYMPI_FMT_SSH = 3, /* As used by SSH (same as 1 but with length)*/
196 GCRYMPI_FMT_HEX = 4, /* hex format */
197 GCRYMPI_FMT_USG = 5 /* like STD but this is an unsigned one */
202 GCRYMPI_FLAG_SECURE = 1,
203 GCRYMPI_FLAG_OPAQUE = 2
208 GCRY_MPI gcry_mpi_new( unsigned int nbits );
209 GCRY_MPI gcry_mpi_snew( unsigned int nbits );
210 void gcry_mpi_release( GCRY_MPI a );
211 GCRY_MPI gcry_mpi_copy( const GCRY_MPI a );
212 GCRY_MPI gcry_mpi_set( GCRY_MPI w, const GCRY_MPI u );
213 GCRY_MPI gcry_mpi_set_ui( GCRY_MPI w, unsigned long u );
214 int gcry_mpi_cmp( const GCRY_MPI u, const GCRY_MPI v );
215 int gcry_mpi_cmp_ui( const GCRY_MPI u, unsigned long v );
216 void gcry_mpi_randomize( GCRY_MPI w,
217 unsigned int nbits, enum gcry_random_level level);
218 int gcry_mpi_scan( GCRY_MPI *ret_mpi, enum gcry_mpi_format format,
219 const char *buffer, size_t *nbytes );
220 int gcry_mpi_print( enum gcry_mpi_format format,
221 char *buffer, size_t *nbytes, const GCRY_MPI a );
222 int gcry_mpi_aprint( enum gcry_mpi_format format,
223 void **buffer, size_t *nbytes, const GCRY_MPI a );
226 void gcry_mpi_add(GCRY_MPI w, GCRY_MPI u, GCRY_MPI v);
227 void gcry_mpi_add_ui(GCRY_MPI w, GCRY_MPI u, unsigned long v );
228 void gcry_mpi_addm(GCRY_MPI w, GCRY_MPI u, GCRY_MPI v, GCRY_MPI m);
229 void gcry_mpi_sub( GCRY_MPI w, GCRY_MPI u, GCRY_MPI v);
230 void gcry_mpi_sub_ui(GCRY_MPI w, GCRY_MPI u, unsigned long v );
231 void gcry_mpi_subm( GCRY_MPI w, GCRY_MPI u, GCRY_MPI v, GCRY_MPI m);
232 void gcry_mpi_mul_ui(GCRY_MPI w, GCRY_MPI u, unsigned long v );
233 void gcry_mpi_mul_2exp( GCRY_MPI w, GCRY_MPI u, unsigned long cnt);
234 void gcry_mpi_mul( GCRY_MPI w, GCRY_MPI u, GCRY_MPI v);
235 void gcry_mpi_mulm( GCRY_MPI w, GCRY_MPI u, GCRY_MPI v, GCRY_MPI m);
237 void gcry_mpi_powm( GCRY_MPI w,
238 const GCRY_MPI b, const GCRY_MPI e, const GCRY_MPI m );
239 int gcry_mpi_gcd( GCRY_MPI g, GCRY_MPI a, GCRY_MPI b );
241 unsigned int gcry_mpi_get_nbits( GCRY_MPI a );
243 /* Please note that keygrip is still experimental and should not be
244 used without contacting the author */
245 unsigned char *gcry_pk_get_keygrip (GCRY_SEXP key, unsigned char *array);
247 int gcry_mpi_test_bit( GCRY_MPI a, unsigned int n );
248 void gcry_mpi_set_bit( GCRY_MPI a, unsigned int n );
249 void gcry_mpi_clear_bit( GCRY_MPI a, unsigned int n );
250 void gcry_mpi_set_highbit( GCRY_MPI a, unsigned int n );
251 void gcry_mpi_clear_highbit( GCRY_MPI a, unsigned int n );
252 void gcry_mpi_rshift( GCRY_MPI x, GCRY_MPI a, unsigned int n );
254 GCRY_MPI gcry_mpi_set_opaque( GCRY_MPI a, void *p, unsigned int nbits );
255 void * gcry_mpi_get_opaque( GCRY_MPI a, unsigned int *nbits );
256 void gcry_mpi_set_flag( GCRY_MPI a, enum gcry_mpi_flag flag );
257 void gcry_mpi_clear_flag( GCRY_MPI a, enum gcry_mpi_flag flag );
258 int gcry_mpi_get_flag( GCRY_MPI a, enum gcry_mpi_flag flag );
261 #ifndef GCRYPT_NO_MPI_MACROS
262 #define mpi_new(n) gcry_mpi_new( (n) )
263 #define mpi_secure_new( n ) gcry_mpi_snew( (n) )
264 #define mpi_release( a ) do { gcry_mpi_release( (a) ); \
265 (a) = NULL; } while(0)
266 #define mpi_copy( a ) gcry_mpi_copy( (a) )
267 #define mpi_set( w, u) gcry_mpi_set( (w), (u) )
268 #define mpi_set_ui( w, u) gcry_mpi_set_ui( (w), (u) )
269 #define mpi_cmp( u, v ) gcry_mpi_cmp( (u), (v) )
270 #define mpi_cmp_ui( u, v ) gcry_mpi_cmp_ui( (u), (v) )
272 #define mpi_add_ui(w,u,v) gcry_mpi_add_ui((w),(u),(v))
273 #define mpi_add(w,u,v) gcry_mpi_add ((w),(u),(v))
274 #define mpi_addm(w,u,v,m) gcry_mpi_addm ((w),(u),(v),(m))
275 #define mpi_sub_ui(w,u,v) gcry_mpi_sub_ui ((w),(u),(v))
276 #define mpi_sub(w,u,v) gcry_mpi_sub ((w),(u),(v))
277 #define mpi_subm(w,u,v,m) gcry_mpi_subm ((w),(u),(v),(m))
278 #define mpi_mul_ui(w,u,v) gcry_mpi_mul_ui ((w),(u),(v))
279 #define mpi_mul_2exp(w,u,v) gcry_mpi_mul_2exp ((w),(u),(v))
280 #define mpi_mul(w,u,v) gcry_mpi_mul ((w),(u),(v))
281 #define mpi_mulm(w,u,v,m) gcry_mpi_mulm ((w),(u),(v),(m))
282 #define mpi_powm(w,b,e,m) gcry_mpi_powm( (w), (b), (e), (m) )
283 #define mpi_gcd(g,a,b) gcry_mpi_gcd( (g), (a), (b) )
285 #define mpi_get_nbits(a) gcry_mpi_get_nbits ((a))
286 #define mpi_test_bit(a,b) gcry_mpi_test_bit ((a),(b))
287 #define mpi_set_bit(a,b) gcry_mpi_set_bit ((a),(b))
288 #define mpi_set_highbit(a,b) gcry_mpi_set_highbit ((a),(b))
289 #define mpi_clear_bit(a,b) gcry_mpi_clear_bit ((a),(b))
290 #define mpi_clear_highbit(a,b) gcry_mpi_clear_highbit ((a),(b))
291 #define mpi_rshift(a,b,c) gcry_mpi_rshift ((a),(b),(c))
293 #define mpi_set_opaque(a,b,c) gcry_mpi_set_opaque( (a), (b), (c) )
294 #define mpi_get_opaque(a,b) gcry_mpi_get_opaque( (a), (b) )
295 #endif /* GCRYPT_NO_MPI_MACROS */
297 /********************************************
298 ******* symmetric cipher functions *******
299 ********************************************/
301 struct gcry_cipher_handle;
302 typedef struct gcry_cipher_handle *GCRY_CIPHER_HD;
304 enum gcry_cipher_algos {
305 GCRY_CIPHER_NONE = 0,
306 GCRY_CIPHER_IDEA = 1,
307 GCRY_CIPHER_3DES = 2,
308 GCRY_CIPHER_CAST5 = 3,
309 GCRY_CIPHER_BLOWFISH = 4,
310 GCRY_CIPHER_SAFER_SK128 = 5,
311 GCRY_CIPHER_DES_SK = 6,
312 GCRY_CIPHER_RIJNDAEL = 7,
313 GCRY_CIPHER_RIJNDAEL192 = 8,
314 GCRY_CIPHER_RIJNDAEL256 = 9,
315 GCRY_CIPHER_TWOFISH = 10,
316 /* other cipher numbers are above 300 for OpenPGP reasons. */
317 GCRY_CIPHER_ARCFOUR = 301
320 #define GCRY_CIPHER_AES GCRY_CIPHER_RIJNDAEL
321 #define GCRY_CIPHER_AES128 GCRY_CIPHER_RIJNDAEL
322 #define GCRY_CIPHER_AES192 GCRY_CIPHER_RIJNDAEL192
323 #define GCRY_CIPHER_AES256 GCRY_CIPHER_RIJNDAEL256
325 enum gcry_cipher_modes {
326 GCRY_CIPHER_MODE_NONE = 0,
327 GCRY_CIPHER_MODE_ECB = 1,
328 GCRY_CIPHER_MODE_CFB = 2,
329 GCRY_CIPHER_MODE_CBC = 3,
330 GCRY_CIPHER_MODE_STREAM = 4, /* native stream mode of some the algorithms */
331 GCRY_CIPHER_MODE_OFB = 5
334 enum gcry_cipher_flags {
335 GCRY_CIPHER_SECURE = 1, /* allocate in secure memory */
336 GCRY_CIPHER_ENABLE_SYNC = 2 /* enable CFB sync mode */
340 GCRY_CIPHER_HD gcry_cipher_open( int algo, int mode, unsigned flags);
341 void gcry_cipher_close( GCRY_CIPHER_HD h );
342 int gcry_cipher_ctl( GCRY_CIPHER_HD h, int cmd, void *buffer, size_t buflen);
343 int gcry_cipher_info( GCRY_CIPHER_HD h, int what, void *buffer, size_t *nbytes);
344 int gcry_cipher_algo_info( int algo, int what, void *buffer, size_t *nbytes);
345 const char *gcry_cipher_algo_name( int algo );
346 int gcry_cipher_map_name( const char* name );
347 int gcry_cipher_mode_from_oid (const char *string);
349 int gcry_cipher_encrypt( GCRY_CIPHER_HD h, byte *out, size_t outsize,
350 const byte *in, size_t inlen );
351 int gcry_cipher_decrypt( GCRY_CIPHER_HD h, byte *out, size_t outsize,
352 const byte *in, size_t inlen );
355 /* some handy macros */
356 /* We have to cast a way a const char* here - this catch-all ctl function
357 * was probably not the best choice */
358 #define gcry_cipher_setkey(h,k,l) gcry_cipher_ctl( (h), GCRYCTL_SET_KEY, \
360 #define gcry_cipher_setiv(h,k,l) gcry_cipher_ctl( (h), GCRYCTL_SET_IV, \
362 #define gcry_cipher_sync(h) gcry_cipher_ctl( (h), GCRYCTL_CFB_SYNC, \
365 #define gcry_cipher_get_algo_keylen(a) \
366 gcry_cipher_algo_info( (a), GCRYCTL_GET_KEYLEN, NULL, NULL )
367 #define gcry_cipher_get_algo_blklen(a) \
368 gcry_cipher_algo_info( (a), GCRYCTL_GET_BLKLEN, NULL, NULL )
369 #define gcry_cipher_test_algo(a) \
370 gcry_cipher_algo_info( (a), GCRYCTL_TEST_ALGO, NULL, NULL )
373 /*********************************************
374 ******* asymmetric cipher functions *******
375 *********************************************/
379 GCRY_PK_RSA_E = 2, /* use only for OpenPGP */
380 GCRY_PK_RSA_S = 3, /* use only for OpenPGP */
381 GCRY_PK_ELG_E = 16, /* use only for OpenPGP */
386 /* Flags describing usage capabilites/request of a PK algorithm */
387 #define GCRY_PK_USAGE_SIGN 1
388 #define GCRY_PK_USAGE_ENCR 2
390 int gcry_pk_encrypt( GCRY_SEXP *result, GCRY_SEXP data, GCRY_SEXP pkey );
391 int gcry_pk_decrypt( GCRY_SEXP *result, GCRY_SEXP data, GCRY_SEXP skey );
392 int gcry_pk_sign( GCRY_SEXP *result, GCRY_SEXP data, GCRY_SEXP skey );
393 int gcry_pk_verify( GCRY_SEXP sigval, GCRY_SEXP data, GCRY_SEXP pkey );
394 int gcry_pk_testkey( GCRY_SEXP key );
395 int gcry_pk_genkey( GCRY_SEXP *r_key, GCRY_SEXP s_parms );
397 int gcry_pk_ctl( int cmd, void *buffer, size_t buflen);
398 int gcry_pk_algo_info( int algo, int what, void *buffer, size_t *nbytes);
399 const char *gcry_pk_algo_name( int algo );
400 int gcry_pk_map_name( const char* name );
401 unsigned int gcry_pk_get_nbits( GCRY_SEXP key );
404 #define gcry_pk_test_algo(a) \
405 gcry_pk_algo_info( (a), GCRYCTL_TEST_ALGO, NULL, NULL )
407 /*********************************************
408 ******* cryptograhic hash functions *******
409 *********************************************/
420 GCRY_MD_FLAG_SECURE = 1,
421 GCRY_MD_FLAG_HMAC = 2
425 struct gcry_md_context;
426 struct gcry_md_handle {
427 struct gcry_md_context *ctx;
432 typedef struct gcry_md_handle *GCRY_MD_HD;
435 GCRY_MD_HD gcry_md_open( int algo, unsigned flags );
436 void gcry_md_close( GCRY_MD_HD hd );
437 int gcry_md_enable( GCRY_MD_HD hd, int algo );
438 GCRY_MD_HD gcry_md_copy( GCRY_MD_HD hd );
439 void gcry_md_reset( GCRY_MD_HD hd );
440 int gcry_md_ctl( GCRY_MD_HD hd, int cmd, byte *buffer, size_t buflen);
441 void gcry_md_write( GCRY_MD_HD hd, const byte *buffer, size_t length);
442 byte *gcry_md_read( GCRY_MD_HD hd, int algo );
443 void gcry_md_hash_buffer( int algo, char *digest,
444 const char *buffer, size_t length);
445 int gcry_md_get_algo( GCRY_MD_HD hd );
446 unsigned int gcry_md_get_algo_dlen( int algo );
447 /*??int gcry_md_get( GCRY_MD_HD hd, int algo, byte *buffer, int buflen );*/
448 int gcry_md_info( GCRY_MD_HD h, int what, void *buffer, size_t *nbytes);
449 int gcry_md_algo_info( int algo, int what, void *buffer, size_t *nbytes);
450 const char *gcry_md_algo_name( int algo );
451 int gcry_md_map_name( const char* name );
452 int gcry_md_setkey( GCRY_MD_HD hd, const char *key, size_t keylen );
454 #define gcry_md_putc(h,c) \
456 if( (h)->bufpos == (h)->bufsize ) \
457 gcry_md_write( (h), NULL, 0 ); \
458 (h)->buf[(h)->bufpos++] = (c) & 0xff; \
461 #define gcry_md_final(a) \
462 gcry_md_ctl( (a), GCRYCTL_FINALIZE, NULL, 0 )
464 #define gcry_md_is_secure(a) \
465 gcry_md_info( (a), GCRYCTL_IS_SECURE, NULL, NULL )
467 #define gcry_md_test_algo(a) \
468 gcry_md_algo_info( (a), GCRYCTL_TEST_ALGO, NULL, NULL )
470 #define gcry_md_start_debug(a,b) \
471 gcry_md_ctl( (a), GCRYCTL_START_DUMP, (b), 0 )
472 #define gcry_md_stop_debug(a,b) \
473 gcry_md_ctl( (a), GCRYCTL_STOP_DUMP, (b), 0 )
476 /*********************************************
477 ******* random generating functions *******
478 *********************************************/
479 void gcry_randomize( byte *buffer, size_t length,
480 enum gcry_random_level level );
481 void *gcry_random_bytes( size_t nbytes, enum gcry_random_level level );
482 void *gcry_random_bytes_secure( size_t nbytes, enum gcry_random_level level );
484 /*****************************************
485 ******* miscellaneous stuff **********
486 *****************************************/
488 enum gcry_log_levels {
489 GCRY_LOG_CONT = 0, /* continue the last log line */
499 /* Provide custom functions for special tasks of libgcrypt.
501 void gcry_set_allocation_handler( void *(*new_alloc_func)(size_t n),
502 void *(*new_alloc_secure_func)(size_t n),
503 int (*new_is_secure_func)(const void*),
504 void *(*new_realloc_func)(void *p, size_t n),
505 void (*new_free_func)(void*) );
506 void gcry_set_outofcore_handler( int (*h)( void*, size_t, unsigned int ),
508 void gcry_set_fatalerror_handler( void (*fnc)(void*,int, const char*),
510 void gcry_set_gettext_handler( const char *(*f)(const char*) );
511 void gcry_set_log_handler( void (*f)(void*,int, const char*, va_list ),
515 /* Access to the memory function of libgcrypt.
516 * Especially the gcry_free() should be used for memory
517 * allocated by gcry_ functions.
519 void *gcry_malloc( size_t n );
520 void *gcry_calloc( size_t n, size_t m );
521 void *gcry_malloc_secure( size_t n );
522 void *gcry_calloc_secure( size_t n, size_t m );
523 void *gcry_realloc( void *a, size_t n );
524 void *gcry_xmalloc( size_t n );
525 void *gcry_xcalloc( size_t n, size_t m );
526 void *gcry_xmalloc_secure( size_t n );
527 void *gcry_xcalloc_secure( size_t n, size_t m );
528 void *gcry_xrealloc( void *a, size_t n );
529 char *gcry_xstrdup( const char * a);
530 void gcry_free( void *a );
531 int gcry_is_secure( const void *a );
534 #ifndef GCRYPT_NO_MPI_MACROS
535 # ifndef DID_MPI_TYPEDEF
536 typedef struct gcry_mpi *MPI;
537 # define DID_MPI_TYPEDEF
539 #endif /* GCRYPT_NO_MPI_MACROS */
544 #endif /* _GCRYPT_H */