diff options
Diffstat (limited to 'plugins/MirOTR/Libgcrypt/src/visibility.c')
-rw-r--r-- | plugins/MirOTR/Libgcrypt/src/visibility.c | 881 |
1 files changed, 480 insertions, 401 deletions
diff --git a/plugins/MirOTR/Libgcrypt/src/visibility.c b/plugins/MirOTR/Libgcrypt/src/visibility.c index f187a65e7a..2989498e10 100644 --- a/plugins/MirOTR/Libgcrypt/src/visibility.c +++ b/plugins/MirOTR/Libgcrypt/src/visibility.c @@ -1,5 +1,6 @@ /* visibility.c - Wrapper for all public functions. - * Copyright (C) 2007, 2008 Free Software Foundation, Inc. + * Copyright (C) 2007, 2008, 2011 Free Software Foundation, Inc. + * Copyright (C) 2013 g10 Code GmbH * * This file is part of Libgcrypt. * @@ -20,11 +21,11 @@ #include <config.h> #include <stdarg.h> -#define _GCRY_INCLUDED_BY_VISIBILITY_C +#define _GCRY_INCLUDED_BY_VISIBILITY_C #include "g10lib.h" #include "cipher-proto.h" - - +#include "context.h" +#include "mpi.h" const char * gcry_strerror (gcry_error_t err) @@ -38,7 +39,7 @@ gcry_strsource (gcry_error_t err) return _gcry_strsource (err); } -gcry_err_code_t +gcry_err_code_t gcry_err_code_from_errno (int err) { return _gcry_err_code_from_errno (err); @@ -50,13 +51,13 @@ gcry_err_code_to_errno (gcry_err_code_t code) return _gcry_err_code_to_errno (code); } -gcry_error_t +gcry_error_t gcry_err_make_from_errno (gcry_err_source_t source, int err) { return _gcry_err_make_from_errno (source, err); } -gcry_err_code_t +gcry_err_code_t gcry_error_from_errno (int err) { return _gcry_error_from_errno (err); @@ -68,82 +69,88 @@ gcry_check_version (const char *req_version) return _gcry_check_version (req_version); } -gcry_error_t +gcry_error_t gcry_control (enum gcry_ctl_cmds cmd, ...) { gcry_error_t err; va_list arg_ptr; - + va_start (arg_ptr, cmd); - err = _gcry_vcontrol (cmd, arg_ptr); + err = gpg_error (_gcry_vcontrol (cmd, arg_ptr)); va_end(arg_ptr); return err; } -gcry_error_t +gcry_error_t gcry_sexp_new (gcry_sexp_t *retsexp, const void *buffer, size_t length, int autodetect) { - return _gcry_sexp_new (retsexp, buffer, length, autodetect); + return gpg_error (_gcry_sexp_new (retsexp, buffer, length, autodetect)); } -gcry_error_t +gcry_error_t gcry_sexp_create (gcry_sexp_t *retsexp, void *buffer, size_t length, int autodetect, void (*freefnc) (void *)) { - return _gcry_sexp_create (retsexp, buffer, length, - autodetect, freefnc); + return gpg_error (_gcry_sexp_create (retsexp, buffer, length, + autodetect, freefnc)); } -gcry_error_t +gcry_error_t gcry_sexp_sscan (gcry_sexp_t *retsexp, size_t *erroff, const char *buffer, size_t length) { - return _gcry_sexp_sscan (retsexp, erroff, buffer, length); + return gpg_error (_gcry_sexp_sscan (retsexp, erroff, buffer, length)); } -gcry_error_t +gcry_error_t gcry_sexp_build (gcry_sexp_t *retsexp, size_t *erroff, const char *format, ...) { - gcry_error_t err; + gcry_err_code_t rc; va_list arg_ptr; - + va_start (arg_ptr, format); - err = _gcry_sexp_vbuild (retsexp, erroff, format, arg_ptr); + rc = _gcry_sexp_vbuild (retsexp, erroff, format, arg_ptr); va_end (arg_ptr); - return err; + return gpg_error (rc); } -gcry_error_t +gcry_error_t gcry_sexp_build_array (gcry_sexp_t *retsexp, size_t *erroff, const char *format, void **arg_list) { - return _gcry_sexp_build_array (retsexp, erroff, format, arg_list); + return gpg_error (_gcry_sexp_build_array (retsexp, erroff, format, arg_list)); } -void +void gcry_sexp_release (gcry_sexp_t sexp) { _gcry_sexp_release (sexp); } -size_t -gcry_sexp_canon_len (const unsigned char *buffer, size_t length, +size_t +gcry_sexp_canon_len (const unsigned char *buffer, size_t length, size_t *erroff, gcry_error_t *errcode) { - return _gcry_sexp_canon_len (buffer, length, erroff, errcode); + size_t n; + gpg_err_code_t rc; + + n = _gcry_sexp_canon_len (buffer, length, erroff, &rc); + if (errcode) + *errcode = gpg_error (rc); + return n; } -size_t +size_t gcry_sexp_sprint (gcry_sexp_t sexp, int mode, void *buffer, size_t maxlength) { return _gcry_sexp_sprint (sexp, mode, buffer, maxlength); } -void +void gcry_sexp_dump (const gcry_sexp_t a) { _gcry_sexp_dump (a); @@ -225,6 +232,12 @@ gcry_sexp_nth_data (const gcry_sexp_t list, int number, size_t *datalen) return _gcry_sexp_nth_data (list, number, datalen); } +void * +gcry_sexp_nth_buffer (const gcry_sexp_t list, int number, size_t *rlength) +{ + return _gcry_sexp_nth_buffer (list, number, rlength); +} + char * gcry_sexp_nth_string (gcry_sexp_t list, int number) { @@ -237,6 +250,21 @@ gcry_sexp_nth_mpi (gcry_sexp_t list, int number, int mpifmt) return _gcry_sexp_nth_mpi (list, number, mpifmt); } +gpg_error_t +gcry_sexp_extract_param (gcry_sexp_t sexp, const char *path, + const char *list, ...) +{ + gcry_err_code_t rc; + va_list arg_ptr; + + va_start (arg_ptr, list); + rc = _gcry_sexp_vextract_param (sexp, path, list, arg_ptr); + va_end (arg_ptr); + return gpg_error (rc); +} + + + gcry_mpi_t gcry_mpi_new (unsigned int nbits) { @@ -249,7 +277,7 @@ gcry_mpi_snew (unsigned int nbits) return _gcry_mpi_snew (nbits); } -void +void gcry_mpi_release (gcry_mpi_t a) { _gcry_mpi_release (a); @@ -261,6 +289,12 @@ gcry_mpi_copy (const gcry_mpi_t a) return _gcry_mpi_copy (a); } +void +gcry_mpi_snatch (gcry_mpi_t w, const gcry_mpi_t u) +{ + return _gcry_mpi_snatch (w, u); +} + gcry_mpi_t gcry_mpi_set (gcry_mpi_t w, const gcry_mpi_t u) { @@ -273,6 +307,12 @@ gcry_mpi_set_ui (gcry_mpi_t w, unsigned long u) return _gcry_mpi_set_ui (w, u); } +gcry_error_t +gcry_mpi_get_ui (gcry_mpi_t w, unsigned long *u) +{ + return gpg_error (_gcry_mpi_get_ui (w, u)); +} + void gcry_mpi_swap (gcry_mpi_t a, gcry_mpi_t b) { @@ -280,6 +320,24 @@ gcry_mpi_swap (gcry_mpi_t a, gcry_mpi_t b) } int +gcry_mpi_is_neg (gcry_mpi_t a) +{ + return _gcry_mpi_is_neg (a); +} + +void +gcry_mpi_neg (gcry_mpi_t w, gcry_mpi_t u) +{ + _gcry_mpi_neg (w, u); +} + +void +gcry_mpi_abs (gcry_mpi_t w) +{ + _gcry_mpi_abs (w); +} + +int gcry_mpi_cmp (const gcry_mpi_t u, const gcry_mpi_t v) { return _gcry_mpi_cmp (u, v); @@ -293,10 +351,10 @@ gcry_mpi_cmp_ui (const gcry_mpi_t u, unsigned long v) gcry_error_t gcry_mpi_scan (gcry_mpi_t *ret_mpi, enum gcry_mpi_format format, - const void *buffer, size_t buflen, + const void *buffer, size_t buflen, size_t *nscanned) { - return _gcry_mpi_scan (ret_mpi, format, buffer, buflen, nscanned); + return gpg_error (_gcry_mpi_scan (ret_mpi, format, buffer, buflen, nscanned)); } gcry_error_t @@ -305,7 +363,7 @@ gcry_mpi_print (enum gcry_mpi_format format, size_t *nwritten, const gcry_mpi_t a) { - return _gcry_mpi_print (format, buffer, buflen, nwritten, a); + return gpg_error (_gcry_mpi_print (format, buffer, buflen, nwritten, a)); } gcry_error_t @@ -313,13 +371,13 @@ gcry_mpi_aprint (enum gcry_mpi_format format, unsigned char **buffer, size_t *nwritten, const gcry_mpi_t a) { - return _gcry_mpi_aprint (format, buffer, nwritten, a); + return gpg_error (_gcry_mpi_aprint (format, buffer, nwritten, a)); } void gcry_mpi_dump (const gcry_mpi_t a) { - _gcry_mpi_dump (a); + _gcry_log_printmpi (NULL, a); } void @@ -414,6 +472,114 @@ gcry_mpi_invm (gcry_mpi_t x, gcry_mpi_t a, gcry_mpi_t m) return _gcry_mpi_invm (x, a, m); } +gcry_mpi_point_t +gcry_mpi_point_new (unsigned int nbits) +{ + return _gcry_mpi_point_new (nbits); +} + +void +gcry_mpi_point_release (gcry_mpi_point_t point) +{ + _gcry_mpi_point_release (point); +} + +void +gcry_mpi_point_get (gcry_mpi_t x, gcry_mpi_t y, gcry_mpi_t z, + gcry_mpi_point_t point) +{ + _gcry_mpi_point_get (x, y, z, point); +} + +void +gcry_mpi_point_snatch_get (gcry_mpi_t x, gcry_mpi_t y, gcry_mpi_t z, + gcry_mpi_point_t point) +{ + _gcry_mpi_point_snatch_get (x, y, z, point); +} + +gcry_mpi_point_t +gcry_mpi_point_set (gcry_mpi_point_t point, + gcry_mpi_t x, gcry_mpi_t y, gcry_mpi_t z) +{ + return _gcry_mpi_point_set (point, x, y, z); +} + +gcry_mpi_point_t +gcry_mpi_point_snatch_set (gcry_mpi_point_t point, + gcry_mpi_t x, gcry_mpi_t y, gcry_mpi_t z) +{ + return _gcry_mpi_point_snatch_set (point, x, y, z); +} + +gpg_error_t +gcry_mpi_ec_new (gcry_ctx_t *r_ctx, + gcry_sexp_t keyparam, const char *curvename) +{ + return gpg_error (_gcry_mpi_ec_new (r_ctx, keyparam, curvename)); +} + +gcry_mpi_t +gcry_mpi_ec_get_mpi (const char *name, gcry_ctx_t ctx, int copy) +{ + return _gcry_mpi_ec_get_mpi (name, ctx, copy); +} + +gcry_mpi_point_t +gcry_mpi_ec_get_point (const char *name, gcry_ctx_t ctx, int copy) +{ + return _gcry_mpi_ec_get_point (name, ctx, copy); +} + +gpg_error_t +gcry_mpi_ec_set_mpi (const char *name, gcry_mpi_t newvalue, gcry_ctx_t ctx) +{ + return gpg_error (_gcry_mpi_ec_set_mpi (name, newvalue, ctx)); +} + +gpg_error_t +gcry_mpi_ec_set_point (const char *name, gcry_mpi_point_t newvalue, + gcry_ctx_t ctx) +{ + return gpg_error (_gcry_mpi_ec_set_point (name, newvalue, ctx)); +} + +int +gcry_mpi_ec_get_affine (gcry_mpi_t x, gcry_mpi_t y, gcry_mpi_point_t point, + gcry_ctx_t ctx) +{ + return _gcry_mpi_ec_get_affine (x, y, point, + _gcry_ctx_get_pointer (ctx, CONTEXT_TYPE_EC)); +} + +void +gcry_mpi_ec_dup (gcry_mpi_point_t w, gcry_mpi_point_t u, gcry_ctx_t ctx) +{ + _gcry_mpi_ec_dup_point (w, u, _gcry_ctx_get_pointer (ctx, CONTEXT_TYPE_EC)); +} + +void +gcry_mpi_ec_add (gcry_mpi_point_t w, + gcry_mpi_point_t u, gcry_mpi_point_t v, gcry_ctx_t ctx) +{ + _gcry_mpi_ec_add_points (w, u, v, + _gcry_ctx_get_pointer (ctx, CONTEXT_TYPE_EC)); +} + +void +gcry_mpi_ec_mul (gcry_mpi_point_t w, gcry_mpi_t n, gcry_mpi_point_t u, + gcry_ctx_t ctx) +{ + _gcry_mpi_ec_mul_point (w, n, u, + _gcry_ctx_get_pointer (ctx, CONTEXT_TYPE_EC)); +} + +int +gcry_mpi_ec_curve_point (gcry_mpi_point_t point, gcry_ctx_t ctx) +{ + return _gcry_mpi_ec_curve_point + (point, _gcry_ctx_get_pointer (ctx, CONTEXT_TYPE_EC)); +} unsigned int gcry_mpi_get_nbits (gcry_mpi_t a) @@ -469,6 +635,12 @@ gcry_mpi_set_opaque (gcry_mpi_t a, void *p, unsigned int nbits) return _gcry_mpi_set_opaque (a, p, nbits); } +gcry_mpi_t +gcry_mpi_set_opaque_copy (gcry_mpi_t a, const void *p, unsigned int nbits) +{ + return _gcry_mpi_set_opaque_copy (a, p, nbits); +} + void * gcry_mpi_get_opaque (gcry_mpi_t a, unsigned int *nbits) { @@ -493,6 +665,20 @@ gcry_mpi_get_flag (gcry_mpi_t a, enum gcry_mpi_flag flag) return _gcry_mpi_get_flag (a, flag); } +gcry_mpi_t +_gcry_mpi_get_const (int no) +{ + switch (no) + { + case 1: return _gcry_mpi_const (MPI_C_ONE); + case 2: return _gcry_mpi_const (MPI_C_TWO); + case 3: return _gcry_mpi_const (MPI_C_THREE); + case 4: return _gcry_mpi_const (MPI_C_FOUR); + case 8: return _gcry_mpi_const (MPI_C_EIGHT); + default: log_bug("unsupported GCRYMPI_CONST_ macro used\n"); + } +} + gcry_error_t gcry_cipher_open (gcry_cipher_hd_t *handle, int algo, int mode, unsigned int flags) @@ -503,7 +689,7 @@ gcry_cipher_open (gcry_cipher_hd_t *handle, return gpg_error (fips_not_operational ()); } - return _gcry_cipher_open (handle, algo, mode, flags); + return gpg_error (_gcry_cipher_open (handle, algo, mode, flags)); } void @@ -518,7 +704,7 @@ gcry_cipher_setkey (gcry_cipher_hd_t hd, const void *key, size_t keylen) if (!fips_is_operational ()) return gpg_error (fips_not_operational ()); - return _gcry_cipher_setkey (hd, key, keylen); + return gcry_error (_gcry_cipher_setkey (hd, key, keylen)); } gcry_error_t @@ -527,7 +713,7 @@ gcry_cipher_setiv (gcry_cipher_hd_t hd, const void *iv, size_t ivlen) if (!fips_is_operational ()) return gpg_error (fips_not_operational ()); - return _gcry_cipher_setiv (hd, iv, ivlen); + return gcry_error (_gcry_cipher_setiv (hd, iv, ivlen)); } gpg_error_t @@ -536,7 +722,34 @@ gcry_cipher_setctr (gcry_cipher_hd_t hd, const void *ctr, size_t ctrlen) if (!fips_is_operational ()) return gpg_error (fips_not_operational ()); - return _gcry_cipher_setctr (hd, ctr, ctrlen); + return gcry_error (_gcry_cipher_setctr (hd, ctr, ctrlen)); +} + +gcry_error_t +gcry_cipher_authenticate (gcry_cipher_hd_t hd, const void *abuf, size_t abuflen) +{ + if (!fips_is_operational ()) + return gpg_error (fips_not_operational ()); + + return gpg_error (_gcry_cipher_authenticate (hd, abuf, abuflen)); +} + +gcry_error_t +gcry_cipher_gettag (gcry_cipher_hd_t hd, void *outtag, size_t taglen) +{ + if (!fips_is_operational ()) + return gpg_error (fips_not_operational ()); + + return gpg_error (_gcry_cipher_gettag (hd, outtag, taglen)); +} + +gcry_error_t +gcry_cipher_checktag (gcry_cipher_hd_t hd, const void *intag, size_t taglen) +{ + if (!fips_is_operational ()) + return gpg_error (fips_not_operational ()); + + return gpg_error (_gcry_cipher_checktag (hd, intag, taglen)); } @@ -546,13 +759,13 @@ gcry_cipher_ctl (gcry_cipher_hd_t h, int cmd, void *buffer, size_t buflen) if (!fips_is_operational ()) return gpg_error (fips_not_operational ()); - return _gcry_cipher_ctl (h, cmd, buffer, buflen); + return gpg_error (_gcry_cipher_ctl (h, cmd, buffer, buflen)); } gcry_error_t gcry_cipher_info (gcry_cipher_hd_t h, int what, void *buffer, size_t *nbytes) { - return _gcry_cipher_info (h, what, buffer, nbytes); + return gpg_error (_gcry_cipher_info (h, what, buffer, nbytes)); } gcry_error_t @@ -561,7 +774,7 @@ gcry_cipher_algo_info (int algo, int what, void *buffer, size_t *nbytes) if (!fips_is_operational ()) return gpg_error (fips_not_operational ()); - return _gcry_cipher_algo_info (algo, what, buffer, nbytes); + return gpg_error (_gcry_cipher_algo_info (algo, what, buffer, nbytes)); } const char * @@ -591,11 +804,11 @@ gcry_cipher_encrypt (gcry_cipher_hd_t h, { /* Make sure that the plaintext will never make it to OUT. */ if (out) - memset (out, 0x42, outsize); + memset (out, 0x42, outsize); return gpg_error (fips_not_operational ()); } - return _gcry_cipher_encrypt (h, out, outsize, in, inlen); + return gpg_error (_gcry_cipher_encrypt (h, out, outsize, in, inlen)); } gcry_error_t @@ -606,7 +819,7 @@ gcry_cipher_decrypt (gcry_cipher_hd_t h, if (!fips_is_operational ()) return gpg_error (fips_not_operational ()); - return _gcry_cipher_decrypt (h, out, outsize, in, inlen); + return gpg_error (_gcry_cipher_decrypt (h, out, outsize, in, inlen)); } size_t @@ -622,9 +835,109 @@ gcry_cipher_get_algo_blklen (int algo) } gcry_error_t -gcry_cipher_list (int *list, int *list_length) +gcry_mac_algo_info (int algo, int what, void *buffer, size_t *nbytes) +{ + if (!fips_is_operational ()) + return gpg_error (fips_not_operational ()); + + return gpg_error (_gcry_mac_algo_info (algo, what, buffer, nbytes)); +} + +const char * +gcry_mac_algo_name (int algorithm) +{ + return _gcry_mac_algo_name (algorithm); +} + +int +gcry_mac_map_name (const char *string) +{ + return _gcry_mac_map_name (string); +} + +unsigned int +gcry_mac_get_algo_maclen (int algo) +{ + return _gcry_mac_get_algo_maclen (algo); +} + +unsigned int +gcry_mac_get_algo_keylen (int algo) { - return _gcry_cipher_list (list, list_length); + return _gcry_mac_get_algo_keylen (algo); +} + +gcry_error_t +gcry_mac_open (gcry_mac_hd_t *handle, int algo, unsigned int flags, + gcry_ctx_t ctx) +{ + if (!fips_is_operational ()) + { + *handle = NULL; + return gpg_error (fips_not_operational ()); + } + + return gpg_error (_gcry_mac_open (handle, algo, flags, ctx)); +} + +void +gcry_mac_close (gcry_mac_hd_t hd) +{ + _gcry_mac_close (hd); +} + +gcry_error_t +gcry_mac_setkey (gcry_mac_hd_t hd, const void *key, size_t keylen) +{ + if (!fips_is_operational ()) + return gpg_error (fips_not_operational ()); + + return gpg_error (_gcry_mac_setkey (hd, key, keylen)); +} + +gcry_error_t +gcry_mac_setiv (gcry_mac_hd_t hd, const void *iv, size_t ivlen) +{ + if (!fips_is_operational ()) + return gpg_error (fips_not_operational ()); + + return gpg_error (_gcry_mac_setiv (hd, iv, ivlen)); +} + +gcry_error_t +gcry_mac_write (gcry_mac_hd_t hd, const void *buf, size_t buflen) +{ + if (!fips_is_operational ()) + return gpg_error (fips_not_operational ()); + + return gpg_error (_gcry_mac_write (hd, buf, buflen)); +} + +gcry_error_t +gcry_mac_read (gcry_mac_hd_t hd, void *outbuf, size_t *outlen) +{ + if (!fips_is_operational ()) + return gpg_error (fips_not_operational ()); + + return gpg_error (_gcry_mac_read (hd, outbuf, outlen)); +} + +gcry_error_t +gcry_mac_verify (gcry_mac_hd_t hd, const void *buf, size_t buflen) +{ + if (!fips_is_operational ()) + return gpg_error (fips_not_operational ()); + + return gpg_error (_gcry_mac_verify (hd, buf, buflen)); +} + +gcry_error_t +gcry_mac_ctl (gcry_mac_hd_t h, int cmd, void *buffer, size_t buflen) +{ + if (!fips_is_operational ()) + return gpg_error (fips_not_operational ()); + + return gpg_error (_gcry_mac_ctl (h, cmd, buffer, buflen)); } gcry_error_t @@ -635,7 +948,7 @@ gcry_pk_encrypt (gcry_sexp_t *result, gcry_sexp_t data, gcry_sexp_t pkey) *result = NULL; return gpg_error (fips_not_operational ()); } - return _gcry_pk_encrypt (result, data, pkey); + return gpg_error (_gcry_pk_encrypt (result, data, pkey)); } gcry_error_t @@ -646,7 +959,7 @@ gcry_pk_decrypt (gcry_sexp_t *result, gcry_sexp_t data, gcry_sexp_t skey) *result = NULL; return gpg_error (fips_not_operational ()); } - return _gcry_pk_decrypt (result, data, skey); + return gpg_error (_gcry_pk_decrypt (result, data, skey)); } gcry_error_t @@ -657,7 +970,7 @@ gcry_pk_sign (gcry_sexp_t *result, gcry_sexp_t data, gcry_sexp_t skey) *result = NULL; return gpg_error (fips_not_operational ()); } - return _gcry_pk_sign (result, data, skey); + return gpg_error (_gcry_pk_sign (result, data, skey)); } gcry_error_t @@ -665,7 +978,7 @@ gcry_pk_verify (gcry_sexp_t sigval, gcry_sexp_t data, gcry_sexp_t pkey) { if (!fips_is_operational ()) return gpg_error (fips_not_operational ()); - return _gcry_pk_verify (sigval, data, pkey); + return gpg_error (_gcry_pk_verify (sigval, data, pkey)); } gcry_error_t @@ -673,7 +986,7 @@ gcry_pk_testkey (gcry_sexp_t key) { if (!fips_is_operational ()) return gpg_error (fips_not_operational ()); - return _gcry_pk_testkey (key); + return gpg_error (_gcry_pk_testkey (key)); } gcry_error_t @@ -684,13 +997,13 @@ gcry_pk_genkey (gcry_sexp_t *r_key, gcry_sexp_t s_parms) *r_key = NULL; return gpg_error (fips_not_operational ()); } - return _gcry_pk_genkey (r_key, s_parms); + return gpg_error (_gcry_pk_genkey (r_key, s_parms)); } gcry_error_t gcry_pk_ctl (int cmd, void *buffer, size_t buflen) { - return _gcry_pk_ctl (cmd, buffer, buflen); + return gpg_error (_gcry_pk_ctl (cmd, buffer, buflen)); } gcry_error_t @@ -699,7 +1012,7 @@ gcry_pk_algo_info (int algo, int what, void *buffer, size_t *nbytes) if (!fips_is_operational ()) return gpg_error (fips_not_operational ()); - return _gcry_pk_algo_info (algo, what, buffer, nbytes); + return gpg_error (_gcry_pk_algo_info (algo, what, buffer, nbytes)); } const char * @@ -737,10 +1050,37 @@ gcry_pk_get_keygrip (gcry_sexp_t key, unsigned char *array) return _gcry_pk_get_keygrip (key, array); } +const char * +gcry_pk_get_curve (gcry_sexp_t key, int iterator, unsigned int *r_nbits) +{ + if (!fips_is_operational ()) + { + (void)fips_not_operational (); + return NULL; + } + return _gcry_pk_get_curve (key, iterator, r_nbits); +} + +gcry_sexp_t +gcry_pk_get_param (int algo, const char *name) +{ + if (!fips_is_operational ()) + { + (void)fips_not_operational (); + return NULL; + } + return _gcry_pk_get_param (algo, name); +} + gcry_error_t -gcry_pk_list (int *list, int *list_length) +gcry_pubkey_get_sexp (gcry_sexp_t *r_sexp, int mode, gcry_ctx_t ctx) { - return _gcry_pk_list (list, list_length); + if (!fips_is_operational ()) + { + *r_sexp = NULL; + return gpg_error (fips_not_operational ()); + } + return gpg_error (_gcry_pubkey_get_sexp (r_sexp, mode, ctx)); } gcry_error_t @@ -752,10 +1092,10 @@ gcry_md_open (gcry_md_hd_t *h, int algo, unsigned int flags) return gpg_error (fips_not_operational ()); } - return _gcry_md_open (h, algo, flags); + return gpg_error (_gcry_md_open (h, algo, flags)); } -void +void gcry_md_close (gcry_md_hd_t hd) { _gcry_md_close (hd); @@ -766,7 +1106,7 @@ gcry_md_enable (gcry_md_hd_t hd, int algo) { if (!fips_is_operational ()) return gpg_error (fips_not_operational ()); - return _gcry_md_enable (hd, algo); + return gpg_error (_gcry_md_enable (hd, algo)); } gcry_error_t @@ -777,7 +1117,7 @@ gcry_md_copy (gcry_md_hd_t *bhd, gcry_md_hd_t ahd) *bhd = NULL; return gpg_error (fips_not_operational ()); } - return _gcry_md_copy (bhd, ahd); + return gpg_error (_gcry_md_copy (bhd, ahd)); } void @@ -791,7 +1131,7 @@ gcry_md_ctl (gcry_md_hd_t hd, int cmd, void *buffer, size_t buflen) { if (!fips_is_operational ()) return gpg_error (fips_not_operational ()); - return _gcry_md_ctl (hd, cmd, buffer, buflen); + return gpg_error (_gcry_md_ctl (hd, cmd, buffer, buflen)); } void @@ -811,7 +1151,7 @@ gcry_md_read (gcry_md_hd_t hd, int algo) return _gcry_md_read (hd, algo); } -void +void gcry_md_hash_buffer (int algo, void *digest, const void *buffer, size_t length) { @@ -823,6 +1163,18 @@ gcry_md_hash_buffer (int algo, void *digest, _gcry_md_hash_buffer (algo, digest, buffer, length); } +gpg_error_t +gcry_md_hash_buffers (int algo, unsigned int flags, void *digest, + const gcry_buffer_t *iov, int iovcnt) +{ + if (!fips_is_operational ()) + { + (void)fips_not_operational (); + fips_signal_error ("called in non-operational state"); + } + return gpg_error (_gcry_md_hash_buffers (algo, flags, digest, iov, iovcnt)); +} + int gcry_md_get_algo (gcry_md_hd_t hd) { @@ -865,13 +1217,13 @@ gcry_md_info (gcry_md_hd_t h, int what, void *buffer, size_t *nbytes) if (!fips_is_operational ()) return gpg_error (fips_not_operational ()); - return _gcry_md_info (h, what, buffer, nbytes); + return gpg_error (_gcry_md_info (h, what, buffer, nbytes)); } gcry_error_t gcry_md_algo_info (int algo, int what, void *buffer, size_t *nbytes) { - return _gcry_md_algo_info (algo, what, buffer, nbytes); + return gpg_error (_gcry_md_algo_info (algo, what, buffer, nbytes)); } const char * @@ -891,7 +1243,7 @@ gcry_md_setkey (gcry_md_hd_t hd, const void *key, size_t keylen) { if (!fips_is_operational ()) return gpg_error (fips_not_operational ()); - return _gcry_md_setkey (hd, key, keylen); + return gpg_error (_gcry_md_setkey (hd, key, keylen)); } void @@ -900,292 +1252,16 @@ gcry_md_debug (gcry_md_hd_t hd, const char *suffix) _gcry_md_debug (hd, suffix); } -gcry_error_t -gcry_md_list (int *list, int *list_length) -{ - return _gcry_md_list (list, list_length); -} - -gcry_error_t -gcry_ac_data_new (gcry_ac_data_t *data) -{ - return _gcry_ac_data_new (data); -} - -void -gcry_ac_data_destroy (gcry_ac_data_t data) -{ - _gcry_ac_data_destroy (data); -} - -gcry_error_t -gcry_ac_data_copy (gcry_ac_data_t *data_cp, gcry_ac_data_t data) -{ - return _gcry_ac_data_copy (data_cp, data); -} - -unsigned int -gcry_ac_data_length (gcry_ac_data_t data) -{ - return _gcry_ac_data_length (data); -} - -void -gcry_ac_data_clear (gcry_ac_data_t data) -{ - _gcry_ac_data_clear (data); -} - -gcry_error_t -gcry_ac_data_set (gcry_ac_data_t data, unsigned int flags, - const char *name, gcry_mpi_t mpi) -{ - return _gcry_ac_data_set (data, flags, name, mpi); -} - -gcry_error_t -gcry_ac_data_get_name (gcry_ac_data_t data, unsigned int flags, - const char *name, gcry_mpi_t *mpi) -{ - return _gcry_ac_data_get_name (data, flags, name, mpi); -} - -gcry_error_t -gcry_ac_data_get_index (gcry_ac_data_t data, unsigned int flags, - unsigned int idx, const char **name, gcry_mpi_t *mpi) -{ - return _gcry_ac_data_get_index (data, flags, idx, name, mpi); -} - -gcry_error_t -gcry_ac_data_to_sexp (gcry_ac_data_t data, gcry_sexp_t *sexp, - const char **identifiers) -{ - return _gcry_ac_data_to_sexp (data, sexp, identifiers); -} - -gcry_error_t -gcry_ac_data_from_sexp (gcry_ac_data_t *data, gcry_sexp_t sexp, - const char **identifiers) -{ - return _gcry_ac_data_from_sexp (data, sexp, identifiers); -} - -void -gcry_ac_io_init (gcry_ac_io_t *ac_io, gcry_ac_io_mode_t mode, - gcry_ac_io_type_t type, ...) -{ - va_list arg_ptr; - - va_start (arg_ptr, type); - _gcry_ac_io_init_va (ac_io, mode, type, arg_ptr); - va_end (arg_ptr); -} - -void -gcry_ac_io_init_va (gcry_ac_io_t *ac_io, gcry_ac_io_mode_t mode, - gcry_ac_io_type_t type, va_list ap) -{ - _gcry_ac_io_init_va (ac_io, mode, type, ap); -} - -gcry_error_t -gcry_ac_open (gcry_ac_handle_t *handle, - gcry_ac_id_t algorithm, unsigned int flags) -{ - return _gcry_ac_open (handle, algorithm, flags); -} - -void -gcry_ac_close (gcry_ac_handle_t handle) -{ - _gcry_ac_close (handle); -} - -gcry_error_t -gcry_ac_key_init (gcry_ac_key_t *key, gcry_ac_handle_t handle, - gcry_ac_key_type_t type, gcry_ac_data_t data) -{ - return _gcry_ac_key_init (key, handle, type, data); -} - -gcry_error_t -gcry_ac_key_pair_generate (gcry_ac_handle_t handle, - unsigned int nbits, void *spec, - gcry_ac_key_pair_t *key_pair, - gcry_mpi_t **miscdata) -{ - return _gcry_ac_key_pair_generate ( handle, nbits, spec, key_pair, miscdata); -} - -gcry_ac_key_t -gcry_ac_key_pair_extract (gcry_ac_key_pair_t keypair, gcry_ac_key_type_t which) -{ - return _gcry_ac_key_pair_extract (keypair, which); -} - -gcry_ac_data_t -gcry_ac_key_data_get (gcry_ac_key_t key) -{ - return _gcry_ac_key_data_get (key); -} - -gcry_error_t -gcry_ac_key_test (gcry_ac_handle_t handle, gcry_ac_key_t key) -{ - return _gcry_ac_key_test (handle, key); -} - -gcry_error_t -gcry_ac_key_get_nbits (gcry_ac_handle_t handle, - gcry_ac_key_t key, unsigned int *nbits) -{ - return _gcry_ac_key_get_nbits (handle, key, nbits); -} - -gcry_error_t -gcry_ac_key_get_grip (gcry_ac_handle_t handle, gcry_ac_key_t key, - unsigned char *key_grip) -{ - return _gcry_ac_key_get_grip (handle, key, key_grip); -} - -void -gcry_ac_key_destroy (gcry_ac_key_t key) -{ - _gcry_ac_key_destroy (key); -} - -void -gcry_ac_key_pair_destroy (gcry_ac_key_pair_t key_pair) -{ - _gcry_ac_key_pair_destroy (key_pair); -} - -gcry_error_t -gcry_ac_data_encode (gcry_ac_em_t method, unsigned int flags, void *options, - gcry_ac_io_t *io_read, gcry_ac_io_t *io_write) -{ - return _gcry_ac_data_encode (method, flags, options, io_read, io_write); -} - -gcry_error_t -gcry_ac_data_decode (gcry_ac_em_t method, unsigned int flags, void *options, - gcry_ac_io_t *io_read, gcry_ac_io_t *io_write) -{ - return _gcry_ac_data_decode (method, flags, options, io_read, io_write); -} - -gcry_error_t -gcry_ac_data_encrypt (gcry_ac_handle_t handle, - unsigned int flags, - gcry_ac_key_t key, - gcry_mpi_t data_plain, - gcry_ac_data_t *data_encrypted) -{ - return _gcry_ac_data_encrypt (handle, flags, key, - data_plain, data_encrypted); -} - -gcry_error_t -gcry_ac_data_decrypt (gcry_ac_handle_t handle, - unsigned int flags, - gcry_ac_key_t key, - gcry_mpi_t *data_plain, - gcry_ac_data_t data_encrypted) -{ - return _gcry_ac_data_decrypt (handle, flags, key, - data_plain, data_encrypted); -} - -gcry_error_t -gcry_ac_data_sign (gcry_ac_handle_t handle, - gcry_ac_key_t key, - gcry_mpi_t data, - gcry_ac_data_t *data_signature) -{ - return _gcry_ac_data_sign (handle, key, data, data_signature); -} - -gcry_error_t -gcry_ac_data_verify (gcry_ac_handle_t handle, - gcry_ac_key_t key, - gcry_mpi_t data, - gcry_ac_data_t data_signature) -{ - return _gcry_ac_data_verify (handle, key, data, data_signature); -} - -gcry_error_t -gcry_ac_data_encrypt_scheme (gcry_ac_handle_t handle, - gcry_ac_scheme_t scheme, - unsigned int flags, void *opts, - gcry_ac_key_t key, - gcry_ac_io_t *io_message, - gcry_ac_io_t *io_cipher) -{ - return _gcry_ac_data_encrypt_scheme (handle, scheme, flags, opts, key, - io_message, io_cipher); -} - -gcry_error_t -gcry_ac_data_decrypt_scheme (gcry_ac_handle_t handle, - gcry_ac_scheme_t scheme, - unsigned int flags, void *opts, - gcry_ac_key_t key, - gcry_ac_io_t *io_cipher, - gcry_ac_io_t *io_message) -{ - return _gcry_ac_data_decrypt_scheme (handle, scheme, flags, opts, key, - io_cipher, io_message); -} - -gcry_error_t -gcry_ac_data_sign_scheme (gcry_ac_handle_t handle, - gcry_ac_scheme_t scheme, - unsigned int flags, void *opts, - gcry_ac_key_t key, - gcry_ac_io_t *io_message, - gcry_ac_io_t *io_signature) -{ - return _gcry_ac_data_sign_scheme (handle, scheme, flags, opts, key, - io_message, io_signature); -} - -gcry_error_t -gcry_ac_data_verify_scheme (gcry_ac_handle_t handle, - gcry_ac_scheme_t scheme, - unsigned int flags, void *opts, - gcry_ac_key_t key, - gcry_ac_io_t *io_message, - gcry_ac_io_t *io_signature) -{ - return _gcry_ac_data_verify_scheme (handle, scheme, flags, opts, key, - io_message, io_signature); -} - -gcry_error_t -gcry_ac_id_to_name (gcry_ac_id_t algorithm, const char **name) -{ - /* This function is deprecated. We implement it in terms of the - suggested replacement. */ - const char *tmp = _gcry_pk_algo_name (algorithm); - if (!*tmp) - return gcry_error (GPG_ERR_PUBKEY_ALGO); - *name = tmp; - return 0; -} - -gcry_error_t -gcry_ac_name_to_id (const char *name, gcry_ac_id_t *algorithm) +gpg_error_t +gcry_kdf_derive (const void *passphrase, size_t passphraselen, + int algo, int hashalgo, + const void *salt, size_t saltlen, + unsigned long iterations, + size_t keysize, void *keybuffer) { - /* This function is deprecated. We implement it in terms of the - suggested replacement. */ - int algo = _gcry_pk_map_name (name); - if (!algo) - return gcry_error (GPG_ERR_PUBKEY_ALGO); - *algorithm = algo; - return 0; + return gpg_error (_gcry_kdf_derive (passphrase, passphraselen, algo, hashalgo, + salt, saltlen, iterations, + keysize, keybuffer)); } void @@ -1195,7 +1271,7 @@ gcry_randomize (void *buffer, size_t length, enum gcry_random_level level) { (void)fips_not_operational (); fips_signal_fatal_error ("called in non-operational state"); - fips_noreturn (); + fips_noreturn (); } _gcry_randomize (buffer, length, level); } @@ -1205,7 +1281,7 @@ gcry_random_add_bytes (const void *buffer, size_t length, int quality) { if (!fips_is_operational ()) return gpg_error (fips_not_operational ()); - return _gcry_random_add_bytes (buffer, length, quality); + return gpg_error (_gcry_random_add_bytes (buffer, length, quality)); } void * @@ -1215,7 +1291,7 @@ gcry_random_bytes (size_t nbytes, enum gcry_random_level level) { (void)fips_not_operational (); fips_signal_fatal_error ("called in non-operational state"); - fips_noreturn (); + fips_noreturn (); } return _gcry_random_bytes (nbytes,level); @@ -1228,7 +1304,7 @@ gcry_random_bytes_secure (size_t nbytes, enum gcry_random_level level) { (void)fips_not_operational (); fips_signal_fatal_error ("called in non-operational state"); - fips_noreturn (); + fips_noreturn (); } return _gcry_random_bytes_secure (nbytes, level); @@ -1248,7 +1324,7 @@ gcry_create_nonce (void *buffer, size_t length) { (void)fips_not_operational (); fips_signal_fatal_error ("called in non-operational state"); - fips_noreturn (); + fips_noreturn (); } _gcry_create_nonce (buffer, length); } @@ -1263,8 +1339,9 @@ gcry_prime_generate (gcry_mpi_t *prime, gcry_random_level_t random_level, unsigned int flags) { - return _gcry_prime_generate (prime, prime_bits, factor_bits, factors, - cb_func, cb_arg, random_level, flags); + return gpg_error (_gcry_prime_generate (prime, prime_bits, factor_bits, + factors, cb_func, cb_arg, + random_level, flags)); } gcry_error_t @@ -1272,7 +1349,7 @@ gcry_prime_group_generator (gcry_mpi_t *r_g, gcry_mpi_t prime, gcry_mpi_t *factors, gcry_mpi_t start_g) { - return _gcry_prime_group_generator (r_g, prime, factors, start_g); + return gpg_error (_gcry_prime_group_generator (r_g, prime, factors, start_g)); } void @@ -1284,7 +1361,49 @@ gcry_prime_release_factors (gcry_mpi_t *factors) gcry_error_t gcry_prime_check (gcry_mpi_t x, unsigned int flags) { - return _gcry_prime_check (x, flags); + return gpg_error (_gcry_prime_check (x, flags)); +} + +void +gcry_ctx_release (gcry_ctx_t ctx) +{ + _gcry_ctx_release (ctx); +} + +void +gcry_log_debug (const char *fmt, ...) +{ + va_list arg_ptr ; + + va_start( arg_ptr, fmt ) ; + _gcry_logv (GCRY_LOG_DEBUG, fmt, arg_ptr); + va_end (arg_ptr); +} + +void +gcry_log_debughex (const char *text, const void *buffer, size_t length) +{ + _gcry_log_printhex (text, buffer, length); +} + +void +gcry_log_debugmpi (const char *text, gcry_mpi_t mpi) +{ + _gcry_log_printmpi (text, mpi); +} + +void +gcry_log_debugpnt (const char *text, mpi_point_t point, gcry_ctx_t ctx) +{ + mpi_ec_t ec = ctx? _gcry_ctx_get_pointer (ctx, CONTEXT_TYPE_EC) : NULL; + + _gcry_mpi_point_log (text, point, ec); +} + +void +gcry_log_debugsxp (const char *text, gcry_sexp_t sexp) +{ + _gcry_log_printsxp (text, sexp); } void @@ -1411,43 +1530,3 @@ gcry_is_secure (const void *a) { return _gcry_is_secure (a); } - - -gcry_error_t -gcry_cipher_register (gcry_cipher_spec_t *cipher, int *algorithm_id, - gcry_module_t *module) -{ - return _gcry_cipher_register (cipher, NULL, algorithm_id, module); -} - -void -gcry_cipher_unregister (gcry_module_t module) -{ - _gcry_cipher_unregister (module); -} - -gcry_error_t -gcry_pk_register (gcry_pk_spec_t *pubkey, unsigned int *algorithm_id, - gcry_module_t *module) -{ - return _gcry_pk_register (pubkey, NULL, algorithm_id, module); -} - -void -gcry_pk_unregister (gcry_module_t module) -{ - _gcry_pk_unregister (module); -} - -gcry_error_t -gcry_md_register (gcry_md_spec_t *digest, unsigned int *algorithm_id, - gcry_module_t *module) -{ - return _gcry_md_register (digest, NULL, algorithm_id, module); -} - -void -gcry_md_unregister (gcry_module_t module) -{ - _gcry_md_unregister (module); -} |