1 /* visibility.c - Wrapper for all public functions.
2 * Copyright (C) 2007, 2008, 2011 Free Software Foundation, Inc.
3 * Copyright (C) 2013 g10 Code GmbH
5 * This file is part of Libgcrypt.
7 * Libgcrypt is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
12 * Libgcrypt is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this program; if not, see <http://www.gnu.org/licenses/>.
24 #define _GCRY_INCLUDED_BY_VISIBILITY_C
26 #include "cipher-proto.h"
31 gcry_strerror (gcry_error_t err)
33 return _gcry_strerror (err);
37 gcry_strsource (gcry_error_t err)
39 return _gcry_strsource (err);
43 gcry_err_code_from_errno (int err)
45 return _gcry_err_code_from_errno (err);
49 gcry_err_code_to_errno (gcry_err_code_t code)
51 return _gcry_err_code_to_errno (code);
55 gcry_err_make_from_errno (gcry_err_source_t source, int err)
57 return _gcry_err_make_from_errno (source, err);
61 gcry_error_from_errno (int err)
63 return _gcry_error_from_errno (err);
67 gcry_check_version (const char *req_version)
69 return _gcry_check_version (req_version);
73 gcry_control (enum gcry_ctl_cmds cmd, ...)
78 va_start (arg_ptr, cmd);
79 err = _gcry_vcontrol (cmd, arg_ptr);
85 gcry_sexp_new (gcry_sexp_t *retsexp,
86 const void *buffer, size_t length,
89 return _gcry_sexp_new (retsexp, buffer, length, autodetect);
93 gcry_sexp_create (gcry_sexp_t *retsexp,
94 void *buffer, size_t length,
95 int autodetect, void (*freefnc) (void *))
97 return _gcry_sexp_create (retsexp, buffer, length,
102 gcry_sexp_sscan (gcry_sexp_t *retsexp, size_t *erroff,
103 const char *buffer, size_t length)
105 return _gcry_sexp_sscan (retsexp, erroff, buffer, length);
109 gcry_sexp_build (gcry_sexp_t *retsexp, size_t *erroff,
110 const char *format, ...)
115 va_start (arg_ptr, format);
116 err = _gcry_sexp_vbuild (retsexp, erroff, format, arg_ptr);
122 gcry_sexp_build_array (gcry_sexp_t *retsexp, size_t *erroff,
123 const char *format, void **arg_list)
125 return _gcry_sexp_build_array (retsexp, erroff, format, arg_list);
129 gcry_sexp_release (gcry_sexp_t sexp)
131 _gcry_sexp_release (sexp);
135 gcry_sexp_canon_len (const unsigned char *buffer, size_t length,
136 size_t *erroff, gcry_error_t *errcode)
138 return _gcry_sexp_canon_len (buffer, length, erroff, errcode);
142 gcry_sexp_sprint (gcry_sexp_t sexp, int mode, void *buffer, size_t maxlength)
144 return _gcry_sexp_sprint (sexp, mode, buffer, maxlength);
148 gcry_sexp_dump (const gcry_sexp_t a)
154 gcry_sexp_cons (const gcry_sexp_t a, const gcry_sexp_t b)
156 return _gcry_sexp_cons (a, b);
160 gcry_sexp_alist (const gcry_sexp_t *array)
162 return _gcry_sexp_alist (array);
166 gcry_sexp_vlist (const gcry_sexp_t a, ...)
168 /* This is not yet implemented in sexp.c. */
175 gcry_sexp_append (const gcry_sexp_t a, const gcry_sexp_t n)
177 return _gcry_sexp_append (a, n);
181 gcry_sexp_prepend (const gcry_sexp_t a, const gcry_sexp_t n)
183 return _gcry_sexp_prepend (a, n);
188 gcry_sexp_find_token (gcry_sexp_t list, const char *tok, size_t toklen)
190 return _gcry_sexp_find_token (list, tok, toklen);
194 gcry_sexp_length (const gcry_sexp_t list)
196 return _gcry_sexp_length (list);
200 gcry_sexp_nth (const gcry_sexp_t list, int number)
202 return _gcry_sexp_nth (list, number);
206 gcry_sexp_car (const gcry_sexp_t list)
208 return _gcry_sexp_car (list);
212 gcry_sexp_cdr (const gcry_sexp_t list)
214 return _gcry_sexp_cdr (list);
218 gcry_sexp_cadr (const gcry_sexp_t list)
220 return _gcry_sexp_cadr (list);
224 gcry_sexp_nth_data (const gcry_sexp_t list, int number, size_t *datalen)
226 return _gcry_sexp_nth_data (list, number, datalen);
230 gcry_sexp_nth_string (gcry_sexp_t list, int number)
232 return _gcry_sexp_nth_string (list, number);
236 gcry_sexp_nth_mpi (gcry_sexp_t list, int number, int mpifmt)
238 return _gcry_sexp_nth_mpi (list, number, mpifmt);
242 gcry_mpi_new (unsigned int nbits)
244 return _gcry_mpi_new (nbits);
248 gcry_mpi_snew (unsigned int nbits)
250 return _gcry_mpi_snew (nbits);
254 gcry_mpi_release (gcry_mpi_t a)
256 _gcry_mpi_release (a);
260 gcry_mpi_copy (const gcry_mpi_t a)
262 return _gcry_mpi_copy (a);
266 gcry_mpi_snatch (gcry_mpi_t w, const gcry_mpi_t u)
268 return _gcry_mpi_snatch (w, u);
272 gcry_mpi_set (gcry_mpi_t w, const gcry_mpi_t u)
274 return _gcry_mpi_set (w, u);
278 gcry_mpi_set_ui (gcry_mpi_t w, unsigned long u)
280 return _gcry_mpi_set_ui (w, u);
284 gcry_mpi_swap (gcry_mpi_t a, gcry_mpi_t b)
286 _gcry_mpi_swap (a, b);
290 gcry_mpi_cmp (const gcry_mpi_t u, const gcry_mpi_t v)
292 return _gcry_mpi_cmp (u, v);
296 gcry_mpi_cmp_ui (const gcry_mpi_t u, unsigned long v)
298 return _gcry_mpi_cmp_ui (u, v);
302 gcry_mpi_scan (gcry_mpi_t *ret_mpi, enum gcry_mpi_format format,
303 const void *buffer, size_t buflen,
306 return _gcry_mpi_scan (ret_mpi, format, buffer, buflen, nscanned);
310 gcry_mpi_print (enum gcry_mpi_format format,
311 unsigned char *buffer, size_t buflen,
315 return _gcry_mpi_print (format, buffer, buflen, nwritten, a);
319 gcry_mpi_aprint (enum gcry_mpi_format format,
320 unsigned char **buffer, size_t *nwritten,
323 return _gcry_mpi_aprint (format, buffer, nwritten, a);
327 gcry_mpi_dump (const gcry_mpi_t a)
333 gcry_mpi_add (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v)
335 _gcry_mpi_add (w, u, v);
339 gcry_mpi_add_ui (gcry_mpi_t w, gcry_mpi_t u, unsigned long v)
341 _gcry_mpi_add_ui (w, u, v);
345 gcry_mpi_addm (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m)
347 _gcry_mpi_addm (w, u, v, m);
351 gcry_mpi_sub (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v)
353 _gcry_mpi_sub (w, u, v);
357 gcry_mpi_sub_ui (gcry_mpi_t w, gcry_mpi_t u, unsigned long v )
359 _gcry_mpi_sub_ui (w, u, v);
363 gcry_mpi_subm (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m)
365 _gcry_mpi_subm (w, u, v, m);
369 gcry_mpi_mul (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v)
371 _gcry_mpi_mul (w, u, v);
375 gcry_mpi_mul_ui (gcry_mpi_t w, gcry_mpi_t u, unsigned long v )
377 _gcry_mpi_mul_ui (w, u, v);
381 gcry_mpi_mulm (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m)
383 _gcry_mpi_mulm (w, u, v, m);
387 gcry_mpi_mul_2exp (gcry_mpi_t w, gcry_mpi_t u, unsigned long cnt)
389 _gcry_mpi_mul_2exp (w, u, cnt);
393 gcry_mpi_div (gcry_mpi_t q, gcry_mpi_t r,
394 gcry_mpi_t dividend, gcry_mpi_t divisor, int round)
396 _gcry_mpi_div (q, r, dividend, divisor, round);
400 gcry_mpi_mod (gcry_mpi_t r, gcry_mpi_t dividend, gcry_mpi_t divisor)
402 _gcry_mpi_mod (r, dividend, divisor);
406 gcry_mpi_powm (gcry_mpi_t w, const gcry_mpi_t b, const gcry_mpi_t e,
409 _gcry_mpi_powm (w, b, e, m);
413 gcry_mpi_gcd (gcry_mpi_t g, gcry_mpi_t a, gcry_mpi_t b)
415 return _gcry_mpi_gcd (g, a, b);
419 gcry_mpi_invm (gcry_mpi_t x, gcry_mpi_t a, gcry_mpi_t m)
421 return _gcry_mpi_invm (x, a, m);
425 gcry_mpi_point_new (unsigned int nbits)
427 return _gcry_mpi_point_new (nbits);
431 gcry_mpi_point_release (gcry_mpi_point_t point)
433 _gcry_mpi_point_release (point);
437 gcry_mpi_point_get (gcry_mpi_t x, gcry_mpi_t y, gcry_mpi_t z,
438 gcry_mpi_point_t point)
440 _gcry_mpi_point_get (x, y, z, point);
444 gcry_mpi_point_snatch_get (gcry_mpi_t x, gcry_mpi_t y, gcry_mpi_t z,
445 gcry_mpi_point_t point)
447 _gcry_mpi_point_snatch_get (x, y, z, point);
451 gcry_mpi_point_set (gcry_mpi_point_t point,
452 gcry_mpi_t x, gcry_mpi_t y, gcry_mpi_t z)
454 return _gcry_mpi_point_set (point, x, y, z);
458 gcry_mpi_point_snatch_set (gcry_mpi_point_t point,
459 gcry_mpi_t x, gcry_mpi_t y, gcry_mpi_t z)
461 return _gcry_mpi_point_snatch_set (point, x, y, z);
465 gcry_mpi_ec_new (gcry_ctx_t *r_ctx,
466 gcry_sexp_t keyparam, const char *curvename)
468 return gpg_error (_gcry_mpi_ec_new (r_ctx, keyparam, curvename));
472 gcry_mpi_ec_get_mpi (const char *name, gcry_ctx_t ctx, int copy)
474 return _gcry_mpi_ec_get_mpi (name, ctx, copy);
478 gcry_mpi_ec_get_point (const char *name, gcry_ctx_t ctx, int copy)
480 return _gcry_mpi_ec_get_point (name, ctx, copy);
484 gcry_mpi_ec_set_mpi (const char *name, gcry_mpi_t newvalue, gcry_ctx_t ctx)
486 return gpg_error (_gcry_mpi_ec_set_mpi (name, newvalue, ctx));
490 gcry_mpi_ec_set_point (const char *name, gcry_mpi_point_t newvalue,
493 return gpg_error (_gcry_mpi_ec_set_point (name, newvalue, ctx));
497 gcry_mpi_ec_get_affine (gcry_mpi_t x, gcry_mpi_t y, gcry_mpi_point_t point,
500 return _gcry_mpi_ec_get_affine (x, y, point,
501 _gcry_ctx_get_pointer (ctx, CONTEXT_TYPE_EC));
505 gcry_mpi_ec_dup (gcry_mpi_point_t w, gcry_mpi_point_t u, gcry_ctx_t ctx)
507 _gcry_mpi_ec_dup_point (w, u, _gcry_ctx_get_pointer (ctx, CONTEXT_TYPE_EC));
511 gcry_mpi_ec_add (gcry_mpi_point_t w,
512 gcry_mpi_point_t u, gcry_mpi_point_t v, gcry_ctx_t ctx)
514 _gcry_mpi_ec_add_points (w, u, v,
515 _gcry_ctx_get_pointer (ctx, CONTEXT_TYPE_EC));
519 gcry_mpi_ec_mul (gcry_mpi_point_t w, gcry_mpi_t n, gcry_mpi_point_t u,
522 _gcry_mpi_ec_mul_point (w, n, u,
523 _gcry_ctx_get_pointer (ctx, CONTEXT_TYPE_EC));
527 gcry_mpi_get_nbits (gcry_mpi_t a)
529 return _gcry_mpi_get_nbits (a);
533 gcry_mpi_test_bit (gcry_mpi_t a, unsigned int n)
535 return _gcry_mpi_test_bit (a, n);
539 gcry_mpi_set_bit (gcry_mpi_t a, unsigned int n)
541 _gcry_mpi_set_bit (a, n);
545 gcry_mpi_clear_bit (gcry_mpi_t a, unsigned int n)
547 _gcry_mpi_clear_bit (a, n);
551 gcry_mpi_set_highbit (gcry_mpi_t a, unsigned int n)
553 _gcry_mpi_set_highbit (a, n);
557 gcry_mpi_clear_highbit (gcry_mpi_t a, unsigned int n)
559 _gcry_mpi_clear_highbit (a, n);
563 gcry_mpi_rshift (gcry_mpi_t x, gcry_mpi_t a, unsigned int n)
565 _gcry_mpi_rshift (x, a, n);
569 gcry_mpi_lshift (gcry_mpi_t x, gcry_mpi_t a, unsigned int n)
571 _gcry_mpi_lshift (x, a, n);
575 gcry_mpi_set_opaque (gcry_mpi_t a, void *p, unsigned int nbits)
577 return _gcry_mpi_set_opaque (a, p, nbits);
581 gcry_mpi_get_opaque (gcry_mpi_t a, unsigned int *nbits)
583 return _gcry_mpi_get_opaque (a, nbits);
587 gcry_mpi_set_flag (gcry_mpi_t a, enum gcry_mpi_flag flag)
589 _gcry_mpi_set_flag (a, flag);
593 gcry_mpi_clear_flag (gcry_mpi_t a, enum gcry_mpi_flag flag)
595 _gcry_mpi_clear_flag (a, flag);
599 gcry_mpi_get_flag (gcry_mpi_t a, enum gcry_mpi_flag flag)
601 return _gcry_mpi_get_flag (a, flag);
605 _gcry_mpi_get_const (int no)
609 case 1: return _gcry_mpi_const (MPI_C_ONE);
610 case 2: return _gcry_mpi_const (MPI_C_TWO);
611 case 3: return _gcry_mpi_const (MPI_C_THREE);
612 case 4: return _gcry_mpi_const (MPI_C_FOUR);
613 case 8: return _gcry_mpi_const (MPI_C_EIGHT);
614 default: log_bug("unsupported GCRYMPI_CONST_ macro used\n");
619 gcry_cipher_open (gcry_cipher_hd_t *handle,
620 int algo, int mode, unsigned int flags)
622 if (!fips_is_operational ())
625 return gpg_error (fips_not_operational ());
628 return _gcry_cipher_open (handle, algo, mode, flags);
632 gcry_cipher_close (gcry_cipher_hd_t h)
634 _gcry_cipher_close (h);
638 gcry_cipher_setkey (gcry_cipher_hd_t hd, const void *key, size_t keylen)
640 if (!fips_is_operational ())
641 return gpg_error (fips_not_operational ());
643 return _gcry_cipher_setkey (hd, key, keylen);
647 gcry_cipher_setiv (gcry_cipher_hd_t hd, const void *iv, size_t ivlen)
649 if (!fips_is_operational ())
650 return gpg_error (fips_not_operational ());
652 return _gcry_cipher_setiv (hd, iv, ivlen);
656 gcry_cipher_setctr (gcry_cipher_hd_t hd, const void *ctr, size_t ctrlen)
658 if (!fips_is_operational ())
659 return gpg_error (fips_not_operational ());
661 return _gcry_cipher_setctr (hd, ctr, ctrlen);
666 gcry_cipher_ctl (gcry_cipher_hd_t h, int cmd, void *buffer, size_t buflen)
668 if (!fips_is_operational ())
669 return gpg_error (fips_not_operational ());
671 return _gcry_cipher_ctl (h, cmd, buffer, buflen);
675 gcry_cipher_info (gcry_cipher_hd_t h, int what, void *buffer, size_t *nbytes)
677 return _gcry_cipher_info (h, what, buffer, nbytes);
681 gcry_cipher_algo_info (int algo, int what, void *buffer, size_t *nbytes)
683 if (!fips_is_operational ())
684 return gpg_error (fips_not_operational ());
686 return _gcry_cipher_algo_info (algo, what, buffer, nbytes);
690 gcry_cipher_algo_name (int algorithm)
692 return _gcry_cipher_algo_name (algorithm);
696 gcry_cipher_map_name (const char *name)
698 return _gcry_cipher_map_name (name);
702 gcry_cipher_mode_from_oid (const char *string)
704 return _gcry_cipher_mode_from_oid (string);
708 gcry_cipher_encrypt (gcry_cipher_hd_t h,
709 void *out, size_t outsize,
710 const void *in, size_t inlen)
712 if (!fips_is_operational ())
714 /* Make sure that the plaintext will never make it to OUT. */
716 memset (out, 0x42, outsize);
717 return gpg_error (fips_not_operational ());
720 return _gcry_cipher_encrypt (h, out, outsize, in, inlen);
724 gcry_cipher_decrypt (gcry_cipher_hd_t h,
725 void *out, size_t outsize,
726 const void *in, size_t inlen)
728 if (!fips_is_operational ())
729 return gpg_error (fips_not_operational ());
731 return _gcry_cipher_decrypt (h, out, outsize, in, inlen);
735 gcry_cipher_get_algo_keylen (int algo)
737 return _gcry_cipher_get_algo_keylen (algo);
741 gcry_cipher_get_algo_blklen (int algo)
743 return _gcry_cipher_get_algo_blklen (algo);
747 gcry_pk_encrypt (gcry_sexp_t *result, gcry_sexp_t data, gcry_sexp_t pkey)
749 if (!fips_is_operational ())
752 return gpg_error (fips_not_operational ());
754 return _gcry_pk_encrypt (result, data, pkey);
758 gcry_pk_decrypt (gcry_sexp_t *result, gcry_sexp_t data, gcry_sexp_t skey)
760 if (!fips_is_operational ())
763 return gpg_error (fips_not_operational ());
765 return _gcry_pk_decrypt (result, data, skey);
769 gcry_pk_sign (gcry_sexp_t *result, gcry_sexp_t data, gcry_sexp_t skey)
771 if (!fips_is_operational ())
774 return gpg_error (fips_not_operational ());
776 return _gcry_pk_sign (result, data, skey);
780 gcry_pk_verify (gcry_sexp_t sigval, gcry_sexp_t data, gcry_sexp_t pkey)
782 if (!fips_is_operational ())
783 return gpg_error (fips_not_operational ());
784 return _gcry_pk_verify (sigval, data, pkey);
788 gcry_pk_testkey (gcry_sexp_t key)
790 if (!fips_is_operational ())
791 return gpg_error (fips_not_operational ());
792 return _gcry_pk_testkey (key);
796 gcry_pk_genkey (gcry_sexp_t *r_key, gcry_sexp_t s_parms)
798 if (!fips_is_operational ())
801 return gpg_error (fips_not_operational ());
803 return _gcry_pk_genkey (r_key, s_parms);
807 gcry_pk_ctl (int cmd, void *buffer, size_t buflen)
809 return _gcry_pk_ctl (cmd, buffer, buflen);
813 gcry_pk_algo_info (int algo, int what, void *buffer, size_t *nbytes)
815 if (!fips_is_operational ())
816 return gpg_error (fips_not_operational ());
818 return _gcry_pk_algo_info (algo, what, buffer, nbytes);
822 gcry_pk_algo_name (int algorithm)
824 return _gcry_pk_algo_name (algorithm);
828 gcry_pk_map_name (const char *name)
830 return _gcry_pk_map_name (name);
834 gcry_pk_get_nbits (gcry_sexp_t key)
836 if (!fips_is_operational ())
838 (void)fips_not_operational ();
842 return _gcry_pk_get_nbits (key);
846 gcry_pk_get_keygrip (gcry_sexp_t key, unsigned char *array)
848 if (!fips_is_operational ())
850 (void)fips_not_operational ();
853 return _gcry_pk_get_keygrip (key, array);
857 gcry_pk_get_curve (gcry_sexp_t key, int iterator, unsigned int *r_nbits)
859 if (!fips_is_operational ())
861 (void)fips_not_operational ();
864 return _gcry_pk_get_curve (key, iterator, r_nbits);
868 gcry_pk_get_param (int algo, const char *name)
870 if (!fips_is_operational ())
872 (void)fips_not_operational ();
875 return _gcry_pk_get_param (algo, name);
879 gcry_pubkey_get_sexp (gcry_sexp_t *r_sexp, int mode, gcry_ctx_t ctx)
881 if (!fips_is_operational ())
884 return gpg_error (fips_not_operational ());
886 return gpg_error (_gcry_pubkey_get_sexp (r_sexp, mode, ctx));
890 gcry_md_open (gcry_md_hd_t *h, int algo, unsigned int flags)
892 if (!fips_is_operational ())
895 return gpg_error (fips_not_operational ());
898 return _gcry_md_open (h, algo, flags);
902 gcry_md_close (gcry_md_hd_t hd)
908 gcry_md_enable (gcry_md_hd_t hd, int algo)
910 if (!fips_is_operational ())
911 return gpg_error (fips_not_operational ());
912 return _gcry_md_enable (hd, algo);
916 gcry_md_copy (gcry_md_hd_t *bhd, gcry_md_hd_t ahd)
918 if (!fips_is_operational ())
921 return gpg_error (fips_not_operational ());
923 return _gcry_md_copy (bhd, ahd);
927 gcry_md_reset (gcry_md_hd_t hd)
933 gcry_md_ctl (gcry_md_hd_t hd, int cmd, void *buffer, size_t buflen)
935 if (!fips_is_operational ())
936 return gpg_error (fips_not_operational ());
937 return _gcry_md_ctl (hd, cmd, buffer, buflen);
941 gcry_md_write (gcry_md_hd_t hd, const void *buffer, size_t length)
943 if (!fips_is_operational ())
945 (void)fips_not_operational ();
948 _gcry_md_write (hd, buffer, length);
952 gcry_md_read (gcry_md_hd_t hd, int algo)
954 return _gcry_md_read (hd, algo);
958 gcry_md_hash_buffer (int algo, void *digest,
959 const void *buffer, size_t length)
961 if (!fips_is_operational ())
963 (void)fips_not_operational ();
964 fips_signal_error ("called in non-operational state");
966 _gcry_md_hash_buffer (algo, digest, buffer, length);
970 gcry_md_get_algo (gcry_md_hd_t hd)
972 if (!fips_is_operational ())
974 (void)fips_not_operational ();
975 fips_signal_error ("used in non-operational state");
978 return _gcry_md_get_algo (hd);
982 gcry_md_get_algo_dlen (int algo)
984 return _gcry_md_get_algo_dlen (algo);
988 gcry_md_is_enabled (gcry_md_hd_t a, int algo)
990 if (!fips_is_operational ())
992 (void)fips_not_operational ();
996 return _gcry_md_is_enabled (a, algo);
1000 gcry_md_is_secure (gcry_md_hd_t a)
1002 return _gcry_md_is_secure (a);
1006 gcry_md_info (gcry_md_hd_t h, int what, void *buffer, size_t *nbytes)
1008 if (!fips_is_operational ())
1009 return gpg_error (fips_not_operational ());
1011 return _gcry_md_info (h, what, buffer, nbytes);
1015 gcry_md_algo_info (int algo, int what, void *buffer, size_t *nbytes)
1017 return _gcry_md_algo_info (algo, what, buffer, nbytes);
1021 gcry_md_algo_name (int algo)
1023 return _gcry_md_algo_name (algo);
1027 gcry_md_map_name (const char* name)
1029 return _gcry_md_map_name (name);
1033 gcry_md_setkey (gcry_md_hd_t hd, const void *key, size_t keylen)
1035 if (!fips_is_operational ())
1036 return gpg_error (fips_not_operational ());
1037 return _gcry_md_setkey (hd, key, keylen);
1041 gcry_md_debug (gcry_md_hd_t hd, const char *suffix)
1043 _gcry_md_debug (hd, suffix);
1047 gcry_kdf_derive (const void *passphrase, size_t passphraselen,
1048 int algo, int hashalgo,
1049 const void *salt, size_t saltlen,
1050 unsigned long iterations,
1051 size_t keysize, void *keybuffer)
1053 return _gcry_kdf_derive (passphrase, passphraselen, algo, hashalgo,
1054 salt, saltlen, iterations, keysize, keybuffer);
1058 gcry_randomize (void *buffer, size_t length, enum gcry_random_level level)
1060 if (!fips_is_operational ())
1062 (void)fips_not_operational ();
1063 fips_signal_fatal_error ("called in non-operational state");
1066 _gcry_randomize (buffer, length, level);
1070 gcry_random_add_bytes (const void *buffer, size_t length, int quality)
1072 if (!fips_is_operational ())
1073 return gpg_error (fips_not_operational ());
1074 return _gcry_random_add_bytes (buffer, length, quality);
1078 gcry_random_bytes (size_t nbytes, enum gcry_random_level level)
1080 if (!fips_is_operational ())
1082 (void)fips_not_operational ();
1083 fips_signal_fatal_error ("called in non-operational state");
1087 return _gcry_random_bytes (nbytes,level);
1091 gcry_random_bytes_secure (size_t nbytes, enum gcry_random_level level)
1093 if (!fips_is_operational ())
1095 (void)fips_not_operational ();
1096 fips_signal_fatal_error ("called in non-operational state");
1100 return _gcry_random_bytes_secure (nbytes, level);
1104 gcry_mpi_randomize (gcry_mpi_t w,
1105 unsigned int nbits, enum gcry_random_level level)
1107 _gcry_mpi_randomize (w, nbits, level);
1111 gcry_create_nonce (void *buffer, size_t length)
1113 if (!fips_is_operational ())
1115 (void)fips_not_operational ();
1116 fips_signal_fatal_error ("called in non-operational state");
1119 _gcry_create_nonce (buffer, length);
1123 gcry_prime_generate (gcry_mpi_t *prime,
1124 unsigned int prime_bits,
1125 unsigned int factor_bits,
1126 gcry_mpi_t **factors,
1127 gcry_prime_check_func_t cb_func,
1129 gcry_random_level_t random_level,
1132 return _gcry_prime_generate (prime, prime_bits, factor_bits, factors,
1133 cb_func, cb_arg, random_level, flags);
1137 gcry_prime_group_generator (gcry_mpi_t *r_g,
1138 gcry_mpi_t prime, gcry_mpi_t *factors,
1141 return _gcry_prime_group_generator (r_g, prime, factors, start_g);
1145 gcry_prime_release_factors (gcry_mpi_t *factors)
1147 _gcry_prime_release_factors (factors);
1151 gcry_prime_check (gcry_mpi_t x, unsigned int flags)
1153 return _gcry_prime_check (x, flags);
1157 gcry_ctx_release (gcry_ctx_t ctx)
1159 _gcry_ctx_release (ctx);
1163 gcry_set_progress_handler (gcry_handler_progress_t cb, void *cb_data)
1165 _gcry_set_progress_handler (cb, cb_data);
1169 gcry_set_allocation_handler (gcry_handler_alloc_t func_alloc,
1170 gcry_handler_alloc_t func_alloc_secure,
1171 gcry_handler_secure_check_t func_secure_check,
1172 gcry_handler_realloc_t func_realloc,
1173 gcry_handler_free_t func_free)
1175 _gcry_set_allocation_handler (func_alloc, func_alloc_secure,
1176 func_secure_check, func_realloc, func_free);
1180 gcry_set_outofcore_handler (gcry_handler_no_mem_t h, void *opaque)
1182 _gcry_set_outofcore_handler (h, opaque);
1186 gcry_set_fatalerror_handler (gcry_handler_error_t fnc, void *opaque)
1188 _gcry_set_fatalerror_handler (fnc, opaque);
1192 gcry_set_log_handler (gcry_handler_log_t f, void *opaque)
1194 _gcry_set_log_handler (f, opaque);
1198 gcry_set_gettext_handler (const char *(*f)(const char*))
1200 _gcry_set_gettext_handler (f);
1204 gcry_malloc (size_t n)
1206 return _gcry_malloc (n);
1210 gcry_calloc (size_t n, size_t m)
1212 return _gcry_calloc (n, m);
1216 gcry_malloc_secure (size_t n)
1218 return _gcry_malloc_secure (n);
1222 gcry_calloc_secure (size_t n, size_t m)
1224 return _gcry_calloc_secure (n,m);
1228 gcry_realloc (void *a, size_t n)
1230 return _gcry_realloc (a, n);
1234 gcry_strdup (const char *string)
1236 return _gcry_strdup (string);
1240 gcry_xmalloc (size_t n)
1242 return _gcry_xmalloc (n);
1246 gcry_xcalloc (size_t n, size_t m)
1248 return _gcry_xcalloc (n, m);
1252 gcry_xmalloc_secure (size_t n)
1254 return _gcry_xmalloc_secure (n);
1258 gcry_xcalloc_secure (size_t n, size_t m)
1260 return _gcry_xcalloc_secure (n, m);
1264 gcry_xrealloc (void *a, size_t n)
1266 return _gcry_xrealloc (a, n);
1270 gcry_xstrdup (const char *a)
1272 return _gcry_xstrdup (a);
1282 gcry_is_secure (const void *a)
1284 return _gcry_is_secure (a);