1 /* gcrypt-int.h - Internal version of gcrypt.h
2 * Copyright (C) 2013 g10 Code GmbH
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 #ifndef GCRY_GCRYPT_INT_H
21 #define GCRY_GCRYPT_INT_H
24 #error gcrypt.h already included
30 /* These error codes are used but not defined in the required
31 libgpg-error 1.11. Define them here. */
32 #if GPG_ERROR_VERSION_NUMBER < 0x010c00 /* 1.12 */
33 # define GPG_ERR_NO_CRYPT_CTX 191
34 # define GPG_ERR_WRONG_CRYPT_CTX 192
35 # define GPG_ERR_BAD_CRYPT_CTX 193
36 # define GPG_ERR_CRYPT_CTX_CONFLICT 194
37 # define GPG_ERR_BROKEN_PUBKEY 195
38 # define GPG_ERR_BROKEN_SECKEY 196
41 #if GPG_ERROR_VERSION_NUMBER < 0x010d00 /* 1.13 */
42 # define GPG_ERR_MAC_ALGO 197
46 /* Context used with elliptic curve functions. */
48 typedef struct mpi_ec_ctx_s *mpi_ec_t;
52 /* Underscore prefixed internal versions of the public functions.
53 They return gpg_err_code and not gpg_error_t. Some macros also
54 need an underscore prefixed internal version.
56 Note that the memory allocation functions and macros (xmalloc etc.)
57 are not defined here but in g10lib.h because this file here is
58 included by some test programs which define theie own xmalloc
61 gpg_err_code_t _gcry_cipher_open (gcry_cipher_hd_t *handle,
62 int algo, int mode, unsigned int flags);
63 void _gcry_cipher_close (gcry_cipher_hd_t h);
64 gpg_err_code_t _gcry_cipher_ctl (gcry_cipher_hd_t h, int cmd, void *buffer,
66 gpg_err_code_t _gcry_cipher_info (gcry_cipher_hd_t h, int what, void *buffer,
68 gpg_err_code_t _gcry_cipher_algo_info (int algo, int what, void *buffer,
70 const char *_gcry_cipher_algo_name (int algorithm) _GCRY_GCC_ATTR_PURE;
71 int _gcry_cipher_map_name (const char *name) _GCRY_GCC_ATTR_PURE;
72 int _gcry_cipher_mode_from_oid (const char *string) _GCRY_GCC_ATTR_PURE;
73 gpg_err_code_t _gcry_cipher_encrypt (gcry_cipher_hd_t h,
74 void *out, size_t outsize,
75 const void *in, size_t inlen);
76 gpg_err_code_t _gcry_cipher_decrypt (gcry_cipher_hd_t h,
77 void *out, size_t outsize,
78 const void *in, size_t inlen);
79 gcry_err_code_t _gcry_cipher_setkey (gcry_cipher_hd_t hd,
80 const void *key, size_t keylen);
81 gcry_err_code_t _gcry_cipher_setiv (gcry_cipher_hd_t hd,
82 const void *iv, size_t ivlen);
83 gpg_err_code_t _gcry_cipher_authenticate (gcry_cipher_hd_t hd, const void *abuf,
85 gpg_err_code_t _gcry_cipher_gettag (gcry_cipher_hd_t hd, void *outtag,
87 gpg_err_code_t _gcry_cipher_checktag (gcry_cipher_hd_t hd, const void *intag,
89 gpg_err_code_t _gcry_cipher_setctr (gcry_cipher_hd_t hd,
90 const void *ctr, size_t ctrlen);
91 size_t _gcry_cipher_get_algo_keylen (int algo);
92 size_t _gcry_cipher_get_algo_blklen (int algo);
94 #define _gcry_cipher_reset(h) _gcry_cipher_ctl ((h), GCRYCTL_RESET, NULL, 0)
99 gpg_err_code_t _gcry_pk_encrypt (gcry_sexp_t *result,
100 gcry_sexp_t data, gcry_sexp_t pkey);
101 gpg_err_code_t _gcry_pk_decrypt (gcry_sexp_t *result,
102 gcry_sexp_t data, gcry_sexp_t skey);
103 gpg_err_code_t _gcry_pk_sign (gcry_sexp_t *result,
104 gcry_sexp_t data, gcry_sexp_t skey);
105 gpg_err_code_t _gcry_pk_verify (gcry_sexp_t sigval,
106 gcry_sexp_t data, gcry_sexp_t pkey);
107 gpg_err_code_t _gcry_pk_testkey (gcry_sexp_t key);
108 gpg_err_code_t _gcry_pk_genkey (gcry_sexp_t *r_key, gcry_sexp_t s_parms);
109 gpg_err_code_t _gcry_pk_ctl (int cmd, void *buffer, size_t buflen);
110 gpg_err_code_t _gcry_pk_algo_info (int algo, int what,
111 void *buffer, size_t *nbytes);
112 const char *_gcry_pk_algo_name (int algorithm) _GCRY_GCC_ATTR_PURE;
113 int _gcry_pk_map_name (const char* name) _GCRY_GCC_ATTR_PURE;
114 unsigned int _gcry_pk_get_nbits (gcry_sexp_t key) _GCRY_GCC_ATTR_PURE;
115 unsigned char *_gcry_pk_get_keygrip (gcry_sexp_t key, unsigned char *array);
116 const char *_gcry_pk_get_curve (gcry_sexp_t key, int iterator,
117 unsigned int *r_nbits);
118 gcry_sexp_t _gcry_pk_get_param (int algo, const char *name);
119 gpg_err_code_t _gcry_pubkey_get_sexp (gcry_sexp_t *r_sexp,
120 int mode, gcry_ctx_t ctx);
123 gpg_err_code_t _gcry_md_open (gcry_md_hd_t *h, int algo, unsigned int flags);
124 void _gcry_md_close (gcry_md_hd_t hd);
125 gpg_err_code_t _gcry_md_enable (gcry_md_hd_t hd, int algo);
126 gpg_err_code_t _gcry_md_copy (gcry_md_hd_t *bhd, gcry_md_hd_t ahd);
127 void _gcry_md_reset (gcry_md_hd_t hd);
128 gpg_err_code_t _gcry_md_ctl (gcry_md_hd_t hd, int cmd,
129 void *buffer, size_t buflen);
130 void _gcry_md_write (gcry_md_hd_t hd, const void *buffer, size_t length);
131 unsigned char *_gcry_md_read (gcry_md_hd_t hd, int algo);
132 void _gcry_md_hash_buffer (int algo, void *digest,
133 const void *buffer, size_t length);
134 gpg_err_code_t _gcry_md_hash_buffers (int algo, unsigned int flags,
136 const gcry_buffer_t *iov, int iovcnt);
137 int _gcry_md_get_algo (gcry_md_hd_t hd);
138 unsigned int _gcry_md_get_algo_dlen (int algo);
139 int _gcry_md_is_enabled (gcry_md_hd_t a, int algo);
140 int _gcry_md_is_secure (gcry_md_hd_t a);
141 gpg_err_code_t _gcry_md_info (gcry_md_hd_t h, int what, void *buffer,
143 gpg_err_code_t _gcry_md_algo_info (int algo, int what, void *buffer,
145 const char *_gcry_md_algo_name (int algo) _GCRY_GCC_ATTR_PURE;
146 int _gcry_md_map_name (const char* name) _GCRY_GCC_ATTR_PURE;
147 gpg_err_code_t _gcry_md_setkey (gcry_md_hd_t hd,
148 const void *key, size_t keylen);
149 void _gcry_md_debug (gcry_md_hd_t hd, const char *suffix);
151 #define _gcry_md_test_algo(a) \
152 _gcry_md_algo_info ((a), GCRYCTL_TEST_ALGO, NULL, NULL)
154 #define _gcry_md_final(a) \
155 _gcry_md_ctl ((a), GCRYCTL_FINALIZE, NULL, 0)
157 #define _gcry_md_putc(h,c) \
159 gcry_md_hd_t h__ = (h); \
160 if( (h__)->bufpos == (h__)->bufsize ) \
161 _gcry_md_write( (h__), NULL, 0 ); \
162 (h__)->buf[(h__)->bufpos++] = (c) & 0xff; \
167 gpg_err_code_t _gcry_mac_open (gcry_mac_hd_t *handle, int algo,
168 unsigned int flags, gcry_ctx_t ctx);
169 void _gcry_mac_close (gcry_mac_hd_t h);
170 gpg_err_code_t _gcry_mac_ctl (gcry_mac_hd_t h, int cmd, void *buffer,
172 gpg_err_code_t _gcry_mac_algo_info (int algo, int what, void *buffer,
174 gpg_err_code_t _gcry_mac_setkey (gcry_mac_hd_t hd, const void *key,
176 gpg_err_code_t _gcry_mac_setiv (gcry_mac_hd_t hd, const void *iv,
178 gpg_err_code_t _gcry_mac_write (gcry_mac_hd_t hd, const void *buffer,
180 gpg_err_code_t _gcry_mac_read (gcry_mac_hd_t hd, void *buffer, size_t *buflen);
181 gpg_err_code_t _gcry_mac_verify (gcry_mac_hd_t hd, const void *buffer,
183 int _gcry_mac_get_algo (gcry_mac_hd_t hd);
184 unsigned int _gcry_mac_get_algo_maclen (int algo);
185 unsigned int _gcry_mac_get_algo_keylen (int algo);
186 const char *_gcry_mac_algo_name (int algorithm) _GCRY_GCC_ATTR_PURE;
187 int _gcry_mac_map_name (const char *name) _GCRY_GCC_ATTR_PURE;
189 #define _gcry_mac_reset(h) _gcry_mac_ctl ((h), GCRYCTL_RESET, NULL, 0)
192 gpg_err_code_t _gcry_kdf_derive (const void *passphrase, size_t passphraselen,
193 int algo, int subalgo,
194 const void *salt, size_t saltlen,
195 unsigned long iterations,
196 size_t keysize, void *keybuffer);
199 gpg_err_code_t _gcry_prime_generate (gcry_mpi_t *prime,
200 unsigned int prime_bits,
201 unsigned int factor_bits,
202 gcry_mpi_t **factors,
203 gcry_prime_check_func_t cb_func,
205 gcry_random_level_t random_level,
207 gpg_err_code_t _gcry_prime_group_generator (gcry_mpi_t *r_g,
211 void _gcry_prime_release_factors (gcry_mpi_t *factors);
212 gpg_err_code_t _gcry_prime_check (gcry_mpi_t x, unsigned int flags);
215 void _gcry_randomize (void *buffer, size_t length,
216 enum gcry_random_level level);
217 gpg_err_code_t _gcry_random_add_bytes (const void *buffer, size_t length,
219 void *_gcry_random_bytes (size_t nbytes, enum gcry_random_level level)
220 _GCRY_GCC_ATTR_MALLOC;
221 void *_gcry_random_bytes_secure (size_t nbytes, enum gcry_random_level level)
222 _GCRY_GCC_ATTR_MALLOC;
223 void _gcry_mpi_randomize (gcry_mpi_t w,
224 unsigned int nbits, enum gcry_random_level level);
225 void _gcry_create_nonce (void *buffer, size_t length);
228 void _gcry_ctx_release (gcry_ctx_t ctx);
231 const char *_gcry_check_version (const char *req_version);
233 void _gcry_set_allocation_handler (gcry_handler_alloc_t func_alloc,
234 gcry_handler_alloc_t func_alloc_secure,
235 gcry_handler_secure_check_t func_secure_check,
236 gcry_handler_realloc_t func_realloc,
237 gcry_handler_free_t func_free);
238 void _gcry_set_outofcore_handler (gcry_handler_no_mem_t h, void *opaque);
239 void _gcry_set_fatalerror_handler (gcry_handler_error_t fnc, void *opaque);
240 void _gcry_set_log_handler (gcry_handler_log_t f, void *opaque);
241 void _gcry_set_gettext_handler (const char *(*f)(const char*));
242 void _gcry_set_progress_handler (gcry_handler_progress_t cb, void *cb_data);
245 /* Return a pointer to a string containing a description of the error
246 code in the error value ERR. */
247 static inline const char *
248 _gcry_strerror (gcry_error_t err)
250 return gpg_strerror (err);
253 /* Return a pointer to a string containing a description of the error
254 source in the error value ERR. */
255 static inline const char *
256 _gcry_strsource (gcry_error_t err)
258 return gpg_strsource (err);
261 /* Retrieve the error code for the system error ERR. This returns
262 GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped (report
264 static inline gcry_err_code_t
265 _gcry_err_code_from_errno (int err)
267 return gpg_err_code_from_errno (err);
270 /* Retrieve the system error for the error code CODE. This returns 0
271 if CODE is not a system error code. */
273 _gcry_err_code_to_errno (gcry_err_code_t code)
275 return gpg_err_code_from_errno (code);
278 /* Return an error value with the error source SOURCE and the system
280 static inline gcry_err_code_t
281 _gcry_err_make_from_errno (gpg_err_source_t source, int err)
283 return gpg_err_make_from_errno (source, err);
287 /* Return an error value with the system error ERR. */
288 static inline gcry_err_code_t
289 _gcry_error_from_errno (int err)
291 return gpg_error (gpg_err_code_from_errno (err));
296 gpg_err_code_t _gcry_sexp_new (gcry_sexp_t *retsexp,
297 const void *buffer, size_t length,
299 gpg_err_code_t _gcry_sexp_create (gcry_sexp_t *retsexp,
300 void *buffer, size_t length,
301 int autodetect, void (*freefnc) (void *));
302 gpg_err_code_t _gcry_sexp_sscan (gcry_sexp_t *retsexp, size_t *erroff,
303 const char *buffer, size_t length);
304 gpg_err_code_t _gcry_sexp_build (gcry_sexp_t *retsexp, size_t *erroff,
305 const char *format, ...);
306 gpg_err_code_t _gcry_sexp_build_array (gcry_sexp_t *retsexp, size_t *erroff,
307 const char *format, void **arg_list);
308 void _gcry_sexp_release (gcry_sexp_t sexp);
309 size_t _gcry_sexp_canon_len (const unsigned char *buffer, size_t length,
310 size_t *erroff, gcry_err_code_t *errcode);
311 size_t _gcry_sexp_sprint (gcry_sexp_t sexp, int mode, void *buffer,
313 void _gcry_sexp_dump (const gcry_sexp_t a);
314 gcry_sexp_t _gcry_sexp_cons (const gcry_sexp_t a, const gcry_sexp_t b);
315 gcry_sexp_t _gcry_sexp_alist (const gcry_sexp_t *array);
316 gcry_sexp_t _gcry_sexp_vlist (const gcry_sexp_t a, ...);
317 gcry_sexp_t _gcry_sexp_append (const gcry_sexp_t a, const gcry_sexp_t n);
318 gcry_sexp_t _gcry_sexp_prepend (const gcry_sexp_t a, const gcry_sexp_t n);
319 gcry_sexp_t _gcry_sexp_find_token (gcry_sexp_t list,
320 const char *tok, size_t toklen);
321 int _gcry_sexp_length (const gcry_sexp_t list);
322 gcry_sexp_t _gcry_sexp_nth (const gcry_sexp_t list, int number);
323 gcry_sexp_t _gcry_sexp_car (const gcry_sexp_t list);
324 gcry_sexp_t _gcry_sexp_cdr (const gcry_sexp_t list);
325 gcry_sexp_t _gcry_sexp_cadr (const gcry_sexp_t list);
326 const char *_gcry_sexp_nth_data (const gcry_sexp_t list, int number,
328 void *_gcry_sexp_nth_buffer (const gcry_sexp_t list, int number,
330 char *_gcry_sexp_nth_string (gcry_sexp_t list, int number);
331 gcry_mpi_t _gcry_sexp_nth_mpi (gcry_sexp_t list, int number, int mpifmt);
332 gpg_err_code_t _gcry_sexp_extract_param (gcry_sexp_t sexp,
335 ...) _GCRY_GCC_ATTR_SENTINEL(0);
337 #define sexp_new(a, b, c, d) _gcry_sexp_new ((a), (b), (c), (d))
338 #define sexp_create(a, b, c, d, e) _gcry_sexp_create ((a), (b), (c), (d), (e))
339 #define sexp_sscan(a, b, c, d) _gcry_sexp_sscan ((a), (b), (c), (d))
340 #define sexp_build _gcry_sexp_build
341 #define sexp_build_array(a, b, c, d) _gcry_sexp_build_array ((a), (b), (c), (d))
342 #define sexp_release(a) _gcry_sexp_release ((a))
343 #define sexp_canon_len(a, b, c, d) _gcry_sexp_canon_len ((a), (b), (c), (d))
344 #define sexp_sprint(a, b, c, d) _gcry_sexp_sprint ((a), (b), (c), (d))
345 #define sexp_dump(a) _gcry_sexp_dump ((a))
346 #define sexp_cons(a, b) _gcry_sexp_cons ((a), (b))
347 #define sexp_alist(a) _gcry_sexp_alist ((a))
348 #define sexp_vlist _gcry_sexp_vlist
349 #define sexp_append(a, b) _gcry_sexp_append ((a), (b))
350 #define sexp_prepend(a, b) _gcry_sexp_prepend ((a), (b))
351 #define sexp_find_token(a, b, c) _gcry_sexp_find_token ((a), (b), (c))
352 #define sexp_length(a) _gcry_sexp_length ((a))
353 #define sexp_nth(a, b) _gcry_sexp_nth ((a), (b))
354 #define sexp_car(a) _gcry_sexp_car ((a))
355 #define sexp_cdr(a) _gcry_sexp_cdr ((a))
356 #define sexp_cadr(a) _gcry_sexp_cadr ((a))
357 #define sexp_nth_data(a, b, c) _gcry_sexp_nth_data ((a), (b), (c))
358 #define sexp_nth_buffer(a, b, c) _gcry_sexp_nth_buffer ((a), (b), (c))
359 #define sexp_nth_string(a, b) _gcry_sexp_nth_string ((a), (b))
360 #define sexp_nth_mpi(a, b, c) _gcry_sexp_nth_mpi ((a), (b), (c))
361 #define sexp_extract_param _gcry_sexp_extract_param
365 gcry_mpi_t _gcry_mpi_new (unsigned int nbits);
366 gcry_mpi_t _gcry_mpi_snew (unsigned int nbits);
367 void _gcry_mpi_release (gcry_mpi_t a);
368 gcry_mpi_t _gcry_mpi_copy (const gcry_mpi_t a);
369 void _gcry_mpi_snatch (gcry_mpi_t w, gcry_mpi_t u);
370 gcry_mpi_t _gcry_mpi_set (gcry_mpi_t w, const gcry_mpi_t u);
371 gcry_mpi_t _gcry_mpi_set_ui (gcry_mpi_t w, unsigned long u);
372 gcry_err_code_t _gcry_mpi_get_ui (gcry_mpi_t w, ulong *u);
373 void _gcry_mpi_swap (gcry_mpi_t a, gcry_mpi_t b);
374 int _gcry_mpi_is_neg (gcry_mpi_t a);
375 void _gcry_mpi_neg (gcry_mpi_t w, gcry_mpi_t u);
376 void _gcry_mpi_abs (gcry_mpi_t w);
377 int _gcry_mpi_cmp (const gcry_mpi_t u, const gcry_mpi_t v);
378 int _gcry_mpi_cmp_ui (const gcry_mpi_t u, unsigned long v);
379 gpg_err_code_t _gcry_mpi_scan (gcry_mpi_t *ret_mpi, enum gcry_mpi_format format,
380 const void *buffer, size_t buflen,
382 gpg_err_code_t _gcry_mpi_print (enum gcry_mpi_format format,
383 unsigned char *buffer, size_t buflen,
386 gpg_err_code_t _gcry_mpi_aprint (enum gcry_mpi_format format,
387 unsigned char **buffer, size_t *nwritten,
389 void _gcry_mpi_dump (const gcry_mpi_t a);
390 void _gcry_mpi_add (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v);
391 void _gcry_mpi_add_ui (gcry_mpi_t w, gcry_mpi_t u, unsigned long v);
392 void _gcry_mpi_addm (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m);
393 void _gcry_mpi_sub (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v);
394 void _gcry_mpi_sub_ui (gcry_mpi_t w, gcry_mpi_t u, unsigned long v );
395 void _gcry_mpi_subm (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m);
396 void _gcry_mpi_mul (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v);
397 void _gcry_mpi_mul_ui (gcry_mpi_t w, gcry_mpi_t u, unsigned long v );
398 void _gcry_mpi_mulm (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m);
399 void _gcry_mpi_mul_2exp (gcry_mpi_t w, gcry_mpi_t u, unsigned long cnt);
400 void _gcry_mpi_div (gcry_mpi_t q, gcry_mpi_t r,
401 gcry_mpi_t dividend, gcry_mpi_t divisor, int round);
402 void _gcry_mpi_mod (gcry_mpi_t r, gcry_mpi_t dividend, gcry_mpi_t divisor);
403 void _gcry_mpi_powm (gcry_mpi_t w,
404 const gcry_mpi_t b, const gcry_mpi_t e,
406 int _gcry_mpi_gcd (gcry_mpi_t g, gcry_mpi_t a, gcry_mpi_t b);
407 int _gcry_mpi_invm (gcry_mpi_t x, gcry_mpi_t a, gcry_mpi_t m);
408 gcry_mpi_point_t _gcry_mpi_point_new (unsigned int nbits);
409 void _gcry_mpi_point_release (gcry_mpi_point_t point);
410 void _gcry_mpi_point_get (gcry_mpi_t x, gcry_mpi_t y, gcry_mpi_t z,
411 gcry_mpi_point_t point);
412 void _gcry_mpi_point_snatch_get (gcry_mpi_t x, gcry_mpi_t y, gcry_mpi_t z,
413 gcry_mpi_point_t point);
414 gcry_mpi_point_t _gcry_mpi_point_set (gcry_mpi_point_t point,
415 gcry_mpi_t x, gcry_mpi_t y, gcry_mpi_t z);
416 gcry_mpi_point_t _gcry_mpi_point_snatch_set (gcry_mpi_point_t point,
417 gcry_mpi_t x, gcry_mpi_t y,
420 gcry_mpi_t _gcry_mpi_ec_get_mpi (const char *name, gcry_ctx_t ctx, int copy);
421 gcry_mpi_point_t _gcry_mpi_ec_get_point (const char *name,
422 gcry_ctx_t ctx, int copy);
423 int _gcry_mpi_ec_get_affine (gcry_mpi_t x, gcry_mpi_t y, gcry_mpi_point_t point,
425 void _gcry_mpi_ec_dup (gcry_mpi_point_t w, gcry_mpi_point_t u, gcry_ctx_t ctx);
426 void _gcry_mpi_ec_add (gcry_mpi_point_t w,
427 gcry_mpi_point_t u, gcry_mpi_point_t v, mpi_ec_t ctx);
428 void _gcry_mpi_ec_sub (gcry_mpi_point_t w,
429 gcry_mpi_point_t u, gcry_mpi_point_t v, mpi_ec_t ctx);
430 void _gcry_mpi_ec_mul (gcry_mpi_point_t w, gcry_mpi_t n, gcry_mpi_point_t u,
432 int _gcry_mpi_ec_curve_point (gcry_mpi_point_t w, mpi_ec_t ctx);
433 unsigned int _gcry_mpi_get_nbits (gcry_mpi_t a);
434 int _gcry_mpi_test_bit (gcry_mpi_t a, unsigned int n);
435 void _gcry_mpi_set_bit (gcry_mpi_t a, unsigned int n);
436 void _gcry_mpi_clear_bit (gcry_mpi_t a, unsigned int n);
437 void _gcry_mpi_set_highbit (gcry_mpi_t a, unsigned int n);
438 void _gcry_mpi_clear_highbit (gcry_mpi_t a, unsigned int n);
439 void _gcry_mpi_rshift (gcry_mpi_t x, gcry_mpi_t a, unsigned int n);
440 void _gcry_mpi_lshift (gcry_mpi_t x, gcry_mpi_t a, unsigned int n);
441 gcry_mpi_t _gcry_mpi_set_opaque (gcry_mpi_t a, void *p, unsigned int nbits);
442 gcry_mpi_t _gcry_mpi_set_opaque_copy (gcry_mpi_t a,
443 const void *p, unsigned int nbits);
444 void *_gcry_mpi_get_opaque (gcry_mpi_t a, unsigned int *nbits);
445 void _gcry_mpi_set_flag (gcry_mpi_t a, enum gcry_mpi_flag flag);
446 void _gcry_mpi_clear_flag (gcry_mpi_t a, enum gcry_mpi_flag flag);
447 int _gcry_mpi_get_flag (gcry_mpi_t a, enum gcry_mpi_flag flag);
450 /* Private function - do not use. */
451 /* gcry_mpi_t _gcry_mpi_get_const (int no); */
453 /* We need our internal versions of the macros. */
454 #ifndef GCRYPT_NO_MPI_MACROS
455 # error GCRYPT_NO_MPI_MACROS is not defined
458 #define mpi_new(n) _gcry_mpi_new ((n))
459 #define mpi_secure_new( n ) _gcry_mpi_snew ((n))
460 #define mpi_snew(n) _gcry_mpi_snew ((n))
462 #define mpi_release(a) \
465 _gcry_mpi_release ((a));\
470 #define mpi_snatch( w, u) _gcry_mpi_snatch( (w), (u) )
471 #define mpi_set( w, u) _gcry_mpi_set( (w), (u) )
472 #define mpi_set_ui( w, u) _gcry_mpi_set_ui( (w), (u) )
473 #define mpi_get_ui(a,b) _gcry_mpi_get_ui( (a), (b) )
474 #define mpi_swap(a,b) _gcry_mpi_swap ((a),(b))
475 #define mpi_abs( w ) _gcry_mpi_abs( (w) )
476 #define mpi_neg( w, u) _gcry_mpi_neg( (w), (u) )
477 #define mpi_cmp( u, v ) _gcry_mpi_cmp( (u), (v) )
478 #define mpi_cmp_ui( u, v ) _gcry_mpi_cmp_ui( (u), (v) )
479 #define mpi_is_neg( a ) _gcry_mpi_is_neg ((a))
481 #define mpi_add_ui(w,u,v) _gcry_mpi_add_ui((w),(u),(v))
482 #define mpi_add(w,u,v) _gcry_mpi_add ((w),(u),(v))
483 #define mpi_addm(w,u,v,m) _gcry_mpi_addm ((w),(u),(v),(m))
484 #define mpi_sub_ui(w,u,v) _gcry_mpi_sub_ui ((w),(u),(v))
485 #define mpi_sub(w,u,v) _gcry_mpi_sub ((w),(u),(v))
486 #define mpi_subm(w,u,v,m) _gcry_mpi_subm ((w),(u),(v),(m))
487 #define mpi_mul_ui(w,u,v) _gcry_mpi_mul_ui ((w),(u),(v))
488 #define mpi_mul_2exp(w,u,v) _gcry_mpi_mul_2exp ((w),(u),(v))
489 #define mpi_mul(w,u,v) _gcry_mpi_mul ((w),(u),(v))
490 #define mpi_mulm(w,u,v,m) _gcry_mpi_mulm ((w),(u),(v),(m))
491 #define mpi_powm(w,b,e,m) _gcry_mpi_powm ( (w), (b), (e), (m) )
492 #define mpi_tdiv(q,r,a,m) _gcry_mpi_div ( (q), (r), (a), (m), 0)
493 #define mpi_fdiv(q,r,a,m) _gcry_mpi_div ( (q), (r), (a), (m), -1)
494 #define mpi_mod(r,a,m) _gcry_mpi_mod ((r), (a), (m))
495 #define mpi_gcd(g,a,b) _gcry_mpi_gcd ( (g), (a), (b) )
496 #define mpi_invm(g,a,b) _gcry_mpi_invm ( (g), (a), (b) )
498 #define mpi_point_new(n) _gcry_mpi_point_new((n))
500 #define mpi_point_release(p) \
503 _gcry_mpi_point_release ((p)); \
508 #define mpi_point_get(x,y,z,p) _gcry_mpi_point_get((x),(y),(z),(p))
509 #define mpi_point_snatch_get(x,y,z,p) _gcry_mpi_point_snatch_get((x),(y), \
511 #define mpi_point_set(p,x,y,z) _gcry_mpi_point_set((p),(x),(y),(z))
512 #define mpi_point_snatch_set(p,x,y,z) _gcry_mpi_point_snatch_set((p),(x), \
515 #define mpi_get_nbits(a) _gcry_mpi_get_nbits ((a))
516 #define mpi_test_bit(a,b) _gcry_mpi_test_bit ((a),(b))
517 #define mpi_set_bit(a,b) _gcry_mpi_set_bit ((a),(b))
518 #define mpi_set_highbit(a,b) _gcry_mpi_set_highbit ((a),(b))
519 #define mpi_clear_bit(a,b) _gcry_mpi_clear_bit ((a),(b))
520 #define mpi_clear_highbit(a,b) _gcry_mpi_clear_highbit ((a),(b))
521 #define mpi_rshift(a,b,c) _gcry_mpi_rshift ((a),(b),(c))
522 #define mpi_lshift(a,b,c) _gcry_mpi_lshift ((a),(b),(c))
524 #define mpi_set_opaque(a,b,c) _gcry_mpi_set_opaque ((a), (b), (c))
525 #define mpi_get_opaque(a,b) _gcry_mpi_get_opaque ((a), (b))
526 #define mpi_set_flag(a,f) _gcry_mpi_set_flag ((a), (f))
527 #define mpi_set_flag(a,f) _gcry_mpi_set_flag ((a), (f))
528 #define mpi_clear_flag(a,f) _gcry_mpi_clear_flag ((a), (f))
529 #define mpi_get_flag(a,f) _gcry_mpi_get_flag ((a), (f))
532 #endif /*GCRY_GCRYPT_INT_H*/