summaryrefslogtreecommitdiff
path: root/src/gcrypt-int.h
Commit message (Collapse)AuthorAgeFilesLines
* Fix _gcry_err_code_to_errno.NIIBE Yutaka2022-09-161-1/+1
| | | | | | | | * src/gcrypt-int.h: Use gpg_err_code_to_errno. -- Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* cipher: Support internal generation of IV for AEAD cipher mode.NIIBE Yutaka2022-08-251-0/+6
| | | | | | | | | | | | | | | | | | | | | | | * cipher/cipher-gcm.c (_gcry_cipher_gcm_setiv_zero): New. (_gcry_cipher_gcm_encrypt, _gcry_cipher_gcm_decrypt) (_gcry_cipher_gcm_authenticate): Use _gcry_cipher_gcm_setiv_zero. * cipher/cipher-internal.h (struct gcry_cipher_handle): Add aead field. * cipher/cipher.c (_gcry_cipher_setiv): Check calling setiv to reject direct invocation in FIPS mode. (_gcry_cipher_setup_geniv, _gcry_cipher_geniv): New. * doc/gcrypt.texi: Add explanation for two new functions. * src/gcrypt-int.h (_gcry_cipher_setup_geniv, _gcry_cipher_geniv): New. * src/gcrypt.h.in (enum gcry_cipher_geniv_methods): New. (gcry_cipher_setup_geniv, gcry_cipher_geniv): New. * src/libgcrypt.def (gcry_cipher_setup_geniv, gcry_cipher_geniv): Add. * src/libgcrypt.vers: Likewise. * src/visibility.c (gcry_cipher_setup_geniv, gcry_cipher_geniv): Add. * src/visibility.h: Likewise. -- GnuPG-bug-id: 4873 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* Fix internal declaration of _gcry_kdf_compute.NIIBE Yutaka2022-05-171-2/+2
| | | | | | | | | * src/gcrypt-int.h (_gcry_kdf_compute): Return gcry_err_code_t. -- GnuPG-bug-id: 5980 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* kdf: Change new KDF API.NIIBE Yutaka2022-01-281-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | * cipher/kdf.c (argon2_ctl): Remove. (argon2_iterator): Remove. (argon2_compute_segment): Change the API. (argon2_compute): New. (argon2_open): No optional N_THERADS any more. (_gcry_kdf_ctl): Remove. (_gcry_kdf_iterator, _gcry_kdf_compute_segment): Remove. (_gcry_kdf_compute): New. * src/gcrypt-int.h: Update declarations. * src/gcrypt.h.in: Likewise. * src/libgcrypt.def: Update. * src/libgcrypt.vers: Update. * src/visibility.c: Update. * src/visibility.h: Update. * tests/t-kdf.c (check_argon2): Update the test with change of new API. -- GnuPG-bug-id: 5797 Co-authored-by: Jussi Kivilinna <jussi.kivilinna@iki.fi> Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* kdf: Improve new KDF API.NIIBE Yutaka2022-01-261-3/+6
| | | | | | | | | | | | | | | | | | | | * cipher/kdf.c (struct argon2_thread_data): Change layout. (argon2_iterator): Use struct gcry_kdf_pt_head. (argon2_compute_segment): Rename from argon2_compute_row. (argon2_open): Handle N_THREAD maximum. (_gcry_kdf_iterator): Use struct gcry_kdf_pt_head. (_gcry_kdf_compute_segment): Rename from _gcry_kdf_compute_row. * src/gcrypt-int.h: Update declarations. * src/gcrypt.h.in (struct gcry_kdf_pt_head): Expose the data type. * src/libgcrypt.def, src/libgcrypt.vers: Update. * src/visibility.c, src/visibility.h: Update. * tests/t-kdf.c (start_thread, my_kdf_derive): Follow the change. -- Fixes-commit: bafdb90d97b65db541ea917088ca956e6a364f6b GnuPG-bug-id: 5797 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* cipher: Add new API for modern KDF function.NIIBE Yutaka2022-01-261-3/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * cipher/kdf.c (hash, argon2_genh0_first_blocks): New for Argon2. (argon2_init, argon2_ctl, argon2_iterator): Likewise. (argon2_compute_row, argon2_final, argon2_close): Likewise. (argon2_open): Likewise. (balloon_open): New for Balloon. (_gcry_kdf_open, _gcry_kdf_ctl, _gcry_kdf_iterator): Add new API. (_gcry_kdf_compute_row, _gcry_kdf_final, _gcry_kdf_close): Likewise. * src/gcrypt-int.h: Add declarations for new API. * src/gcrypt.h.in: Likewise. (enum gcry_kdf_algos): Add GCRY_KDF_ARGON2 and GCRY_KDF_BALLOON. (enum gcry_kdf_subalgo_argon2): Add GCRY_KDF_ARGON2D, GCRY_KDF_ARGON2I, and GCRY_KDF_ARGON2ID. * src/libgcrypt.def, src/libgcrypt.vers: Update. * src/visibility.h: Likewise. * src/visibility.c: Add new API. * tests/Makefile.am (t_kdf_LDADD, t_kdf_CFLAGS): Enable use of pthread. * tests/t-kdf.c (check_argon2): New, not enabled yet. -- New API has been added, decoupling thread support. Implementation of Argon2 is on-going. Test is not enabled yet. GnuPG-bug-id: 5797 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* cipher: Add sign+hash, verify+hash, and random-override API.NIIBE Yutaka2021-10-071-1/+12
| | | | | | | | | | | | | | | | | | | | | | * cipher/pubkey.c (_gcry_pk_sign_md, _gcry_pk_verify_md): New. (_gcry_pk_random_override_new): New. (_gcry_pk_get_random_override): New. * src/gcrypt-int.h: Add those routines. * src/context.h (CONTEXT_TYPE_RANDOM_OVERRIDE): New. * src/context.c (_gcry_ctx_alloc, _gcry_ctx_release): Handle CONTEXT_TYPE_RANDOM_OVERRIDE. * src/gcrypt.h.in (gcry_error_t gcry_pk_hash_sign): New. (gcry_error_t gcry_pk_hash_verify): New. (gcry_pk_random_override_new): New. * src/libgcrypt.def, src/libgcrypt.vers: Update. * src/visibility.c (gcry_pk_hash_sign, gcry_pk_hash_verify): New. (gcry_pk_random_override_new): New. * src/visibility.h: Add those routines. -- GnuPG-bug-id: 4894 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* Add XOF output support for internal _gcry_md_hash_buffersJussi Kivilinna2021-04-261-0/+4
| | | | | | | | | | | | | | * cipher/ecc-eddsa.c (_gcry_ecc_eddsa_compute_h_d, _gcry_ecc_eddsa_sign) (_gcry_ecc_eddsa_verify): Use same _gcry_md_hash_buffers_extract code path for SHA512 and SHAKE256. * cipher/md.c (_gcry_md_hash_buffers): Rename to ... (_gcry_md_hash_buffers_extract): ... this; Add digestlen and handling for XOF algorithms (SHAKE128, SHAKE256). (_gcry_md_hash_buffers): New. * src/gcrypt-int.h (_gcry_md_hash_buffers_extract): New. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
* ecc: Fix the regression of gcry_mpi_ec_add.NIIBE Yutaka2021-03-301-0/+2
| | | | | | | | | | | | | | | | * mpi/ec.c (_gcry_mpi_ec_point_resize): Export the routine for internal use. (add_points_edwards, _gcry_mpi_ec_mul_point): Use mpi_point_resize. * src/gcrypt-int.h (_gcry_mpi_ec_point_resize): Declare. * src/visibility.c (gcry_mpi_ec_dup, gcry_mpi_ec_add): Make sure for the size of limb before calling the internal functions. (gcry_mpi_ec_sub): Likewise. -- GnuPG-bug-id: 5372 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* ecc: Improve new ECDH API.NIIBE Yutaka2019-06-211-1/+2
| | | | | | | | | | | | | | | * cipher/ecc-ecdh.c (_gcry_ecc_get_algo_keylen): New. (_gcry_ecc_mul_point): Fill into the RESULT buffer, instead of allocating new buffer. * src/gcrypt-int.h: Change the API. * src/gcrypt.h.in: Likewise. * src/libgcrypt.def (gcry_ecc_get_algo_keylen): New. * src/libgcrypt.vers (gcry_ecc_get_algo_keylen): New. * src/visibility.c (gcry_ecc_get_algo_keylen): New. * src/visibility.h (gcry_ecc_get_algo_keylen): New. * tests/t-cv25519.c: Fix the use case. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* ecc: Add an API for X25519 function as gcry_ecc_mul_point.NIIBE Yutaka2019-06-201-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * configure.ac: Add ecc-ecdh.lo. * cipher/Makefile.am: Add ecc-ecdh.c. * cipher/ecc-common.h (reverse_buffer): Expose. * cipher/ecc-eddsa.c (reverse_buffer): Expose. * cipher/ecc-curves.c (domain_parms): Fix as the errata of RFC. * cipher/ecc-ecdh.c: New. * cipher/ecc-misc.c (_gcry_ecc_mont_decodepoint): Fix for other curves than Curve25519. * src/gcrypt-int.h (_gcry_ecc_mul_point): New. * src/gcrypt.h.in (enum gcry_ecc_curves): New. (gcry_ecc_mul_point): new. * src/libgcrypt.def (gcry_ecc_mul_point): New. * src/libgcrypt.vers (gcry_ecc_mul_point): New. * src/visibility.h (gcry_ecc_mul_point): New. * src/visibility.c (gcry_ecc_mul_point): New. * tests/t-cv25519.c (test_cv_hl): Rename from test_cv. (test_cv_x25519): New. (test_cv): Call both of test_cv_hl and test_cv_x25519. -- Add new API gcry_ecc_mul_point for direct use of X25519 function. "Direct use" means, its inputs and output are binary octet in native format, while no lengths check inside. It's a responsibility of caller. We can use gcry_pk_encrypt for implementing X25519, but the API of gcry_pk_encrypt uses SEXP format, which is a bit cumbersome. GnuPG-bug-id: 4293 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* mpi: New internal function _gcry_mpi_cmpabs.Werner Koch2018-06-051-0/+2
| | | | | | | | | * mpi/mpi-cmp.c (_gcry_mpi_cmp): Factor out to ... (do_mpi_cmp): New. Add arg absmode. (_gcry_mpi_cmpabs): New. * src/gcrypt-int.h (mpi_cmpabs): New macro. Signed-off-by: Werner Koch <wk@gnupg.org>
* api: New function gcry_mpi_get_ui.Werner Koch2017-10-171-2/+2
| | | | | | | | | | | | | | | | | | | * src/gcrypt.h.in (gcry_mpi_get_ui): New. (mpi_get_ui): New macro. * src/libgcrypt.def, src/libgcrypt.vers: Add new function. * src/visibility.c (gcry_mpi_get_ui): New. * src/visibility.h: Mark that function. (gcry_mpi_get_ui): New. * mpi/mpiutil.c (MY_UINT_MAX): New macro. (_gcry_mpi_get_ui): Re-implemented. This function existed but was never imported or used. * tests/mpitests.c (test_maxsize): Add some test for this function. -- Note that in libgcrypt.def the cardinal 91 is used which was never used in the past. Signed-off-by: Werner Koch <wk@gnupg.org>
* Fix return value type for _gcry_md_extractJussi Kivilinna2017-07-291-3/+3
| | | | | | | | | * src/gcrypt-int.h (_gcry_md_extract): Use gpg_err_code_t instead of gpg_error_t for internal function return type. -- GnuPG-bug-id: 3314 Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
* api: New function gcry_mpi_point_copy.Werner Koch2017-07-181-0/+3
| | | | | | | | | | | * src/gcrypt.h.in (gcry_mpi_point_copy): New. (mpi_point_copy): New macro. * src/visibility.c (gcry_mpi_point_copy): New. * src/libgcrypt.def, src/libgcrypt.vers: Add function. * mpi/ec.c (_gcry_mpi_point_copy): New. * tests/t-mpi-point.c (set_get_point): Add test. Signed-off-by: Werner Koch <wk@gnupg.org>
* cipher: New function for reading the counter in CTR modeStephan Mueller2016-12-081-0/+2
| | | | | | | | | | | * cipher/cipher.c (gcry_cipher_getctr): New. -- The API call allows reading the current counter of the CTR mode. The API remains internal to libgcrypt and is not exported to external callers. Signed-off-by: Stephan Mueller <smueller@chronox.de> ChangeLog entry above added by -wk
* Put blocking calls into Libgpg-error's system call clamp.Werner Koch2016-11-121-12/+1
| | | | | | | | | | | | | | | * src/gcrypt.h.in (GCRYCTL_REINIT_SYSCALL_CLAMP): New. * configure.ac: Require Libgpg-error 1.25. Set version number to 1.8.0. * src/gcrypt-int.h: Remove error code emulation. * src/global.c (pre_syscall_func, post_syscall_func): New. (global_init): Call gpgrt_get_syscall_clamp. (_gcry_vcontrol) <GCRYCTL_REINIT_SYSCALL_CLAMP>: Ditto. (_gcry_pre_syscall, _gcry_post_syscall): New. * random/rndlinux.c (_gcry_rndlinux_gather_random): Use the new functions. Signed-off-by: Werner Koch <wk@gnupg.org>
* md: add variable length output interfaceJussi Kivilinna2015-10-281-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * cipher/crc.c (_gcry_digest_spec_crc32) (_gcry_digest_spec_crc32_rfc1510, _gcry_digest_spec_crc24_rfc2440): Set 'extract' NULL. * cipher/gostr3411-94.c (_gcry_digest_spec_gost3411_94) (_gcry_digest_spec_gost3411_cp): Ditto. * cipher/keccak.c (_gcry_digest_spec_sha3_224) (_gcry_digest_spec_sha3_256, _gcry_digest_spec_sha3_384) (_gcry_digest_spec_sha3_512): Ditto. * cipher/md2.c (_gcry_digest_spec_md2): Ditto. * cipher/md4.c (_gcry_digest_spec_md4): Ditto. * cipher/md5.c (_gcry_digest_spec_md5): Ditto. * cipher/rmd160.c (_gcry_digest_spec_rmd160): Ditto. * cipher/sha1.c (_gcry_digest_spec_sha1): Ditto. * cipher/sha256.c (_gcry_digest_spec_sha224) (_gcry_digest_spec_sha256): Ditto. * cipher/sha512.c (_gcry_digest_spec_sha384) (_gcry_digest_spec_sha512): Ditto. * cipher/stribog.c (_gcry_digest_spec_stribog_256) (_gcry_digest_spec_stribog_512): Ditto. * cipher/tiger.c (_gcry_digest_spec_tiger) (_gcry_digest_spec_tiger1, _gcry_digest_spec_tiger2): Ditto. * cipher/whirlpool.c (_gcry_digest_spec_whirlpool): Ditto. * cipher/md.c (md_enable): Do not allow combination of HMAC and 'expandable-output function'. (md_final): Check if spec->read is NULL before calling. (md_read): Ditto. (md_extract, _gcry_md_extract): New. * doc/gcrypt.texi: Add SHA3 algorithms and gcry_md_extract. * src/cipher-proto.h (gcry_md_extract_t): New. (gcry_md_spec_t): Add 'extract'. * src/gcrypt-int.g (_gcry_md_extract): New. * src/gcrypt.h.in (gcry_md_extract): New. * src/libgcrypt.def: Add gcry_md_extract. * src/libgcrypt.vers: Add gcry_md_extract. * src/visibility.c (gcry_md_extract): New. * src/visibility.h (gcry_md_extract): New. -- Patch adds new interface for reading output from 'expandable-output function' MD algorithms that can give variable length output (ie. SHAKE algorithms from FIPS-202). New function to read output is gpg_error_t gcry_md_extract(gcry_md_hd_t md, int algo, void *buffer, size_t length); Function implicitly finalizes algorithm so that no new input can be given. Subsequents calls of the function return more output bytes from the algorithm. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
* Fix gpg_error_t and gpg_err_code_t confusion.NIIBE Yutaka2015-10-141-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | * src/gcrypt-int.h (_gcry_sexp_extract_param): Revert the change. * cipher/dsa.c (dsa_check_secret_key): Ditto. * src/sexp.c (_gcry_sexp_extract_param): Return gpg_err_code_t. * src/gcrypt-int.h (_gcry_err_make_from_errno) (_gcry_error_from_errno): Return gpg_error_t. * cipher/cipher.c (_gcry_cipher_open_internal) (_gcry_cipher_ctl, _gcry_cipher_ctl): Don't use gcry_error. * src/global.c (_gcry_vcontrol): Likewise. * cipher/ecc-eddsa.c (_gcry_ecc_eddsa_genkey): Use gpg_err_code_from_syserror. * cipher/mac.c (mac_reset, mac_setkey, mac_setiv, mac_write) (mac_read, mac_verify): Return gcry_err_code_t. * cipher/rsa-common.c (mgf1): Use gcry_err_code_t for ERR. * src/visibility.c (gcry_error_from_errno): Return gpg_error_t. -- Reverting a part of 73374fdd and fix _gcry_sexp_extract_param return type, instead. Fix similar coding mistakes, throughout.
* Fix declaration of return type.NIIBE Yutaka2015-10-131-4/+4
| | | | | | | | | | | * src/gcrypt-int.h (_gcry_sexp_extract_param): Return gpg_error_t. * cipher/dsa.c (dsa_generate): Fix call to _gcry_sexp_extract_param. * src/g10lib.h (_gcry_vcontrol): Return gcry_err_code_t. * src/visibility.c (gcry_mpi_snatch): Fix call to _gcry_mpi_snatch. -- GnuPG-bug-id: 2074
* Remove duplicated prototypes.Werner Koch2014-11-241-6/+1
| | | | | | | | | | | * src/gcrypt-int.h (_gcry_mpi_ec_new, _gcry_mpi_ec_set_mpi) (gcry_mpi_ec_set_point): Remove. -- Thos used gpg_error_t instead of gpg_err_code_t and the picky AIX compiler takes this as a severe error. Signed-off-by: Werner Koch <wk@gnupg.org>
* mpi: Add gcry_mpi_ec_sub.Markus Teich2014-10-081-0/+2
| | | | | | | | | | | | | | | | | | | | * NEWS (gcry_mpi_ec_sub): New. * doc/gcrypt.texi (gcry_mpi_ec_sub): New. * mpi/ec.c (_gcry_mpi_ec_sub, sub_points_edwards): New. (sub_points_montgomery, sub_points_weierstrass): New stubs. * src/gcrypt-int.h (_gcry_mpi_ec_sub): New. * src/gcrypt.h.in (gcry_mpi_ec_sub): New. * src/libgcrypt.def (gcry_mpi_ec_sub): New. * src/libgcrypt.vers (gcry_mpi_ec_sub): New. * src/mpi.h (_gcry_mpi_ec_sub_points): New. * src/visibility.c (gcry_mpi_ec_sub): New. * src/visibility.h (gcry_mpi_ec_sub): New. -- This function subtracts two points on the curve. Only Twisted Edwards curves are supported with this change. Signed-off-by: Markus Teich <markus dot teich at stusta dot mhn dot de>
* Add a function to retrieve algorithm used by MAC handlerDmitry Eremin-Solenikov2014-01-131-0/+1
| | | | | | | | | | | | | | * cipher/mac.c (_gcry_mac_get_algo): New function, returns used algo. * src/visibility.c (gcry_mac_get_algo): New wrapper. * src/visibility.h: Hanlde gcry_mac_get_algo. * src/gcrypt-int.h (_gcry_mac_get_algo): New. * src/gcrypt.h.in (gcry_mac_get_algo): New. * src/libgcrypt.def (gcry_mac_get_algo): New. * src/libgcrypt.vers (gcry_mac_get_algo): New. * doc/gcrypt.texi: Document gcry_mac_get_algo. * tests/basic.c (check_one_mac): Verify gcry_mac_get_algo. Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
* Remove macro hacks for internal vs. external functions. Part 2 and last.Werner Koch2013-12-121-1/+6
| | | | | | | | | | | | | | | | | | | * src/visibility.h: Remove remaining define/undef hacks for symbol visibility. Add macros to detect the use of the public functions. Change all affected functions by replacing them by the x-macros. * src/g10lib.h: Add internal prototypes. (xtrymalloc, xtrycalloc, xtrymalloc_secure, xtrycalloc_secure) (xtryrealloc, xtrystrdup, xmalloc, xcalloc, xmalloc_secure) (xcalloc_secure, xrealloc, xstrdup, xfree): New macros. -- The use of xmalloc/xtrymalloc/xfree is a more common pattern than the gcry_free etc. functions. Those functions behave like those defined by C and thus for better readability we use these macros and not the underscore prefixed functions. Signed-off-by: Werner Koch <wk@gnupg.org>
* Fix building on mingw32Jussi Kivilinna2013-12-061-0/+1
| | | | | | | | | | | | | | | * src/gcrypt-int.h: Include <types.h>. -- 'ulong' is not defined on W32, so we need to include "types.h" in 'gcrypt-int.h'. In file included from ../src/visibility.h:53:0, from ../src/g10lib.h:39, from compat.c:22: ../src/gcrypt-int.h:365:49: error: unknown type name 'ulong' Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
* Remove macro hacks for internal vs. external functions. Part 1.Werner Koch2013-12-051-0/+484
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/visibility.h: Remove almost all define/undef hacks for symbol visibility. Add macros to detect the use of the public functions. Change all affected functions by prefixing them explicitly with an underscore and change all internal callers to call the underscore prefixed versions. Provide convenience macros from sexp and mpi functions. * src/visibility.c: Change all functions to use only gpg_err_code_t and translate to gpg_error_t only in visibility.c. -- The use of the macro magic made if hard to follow the function calls in the source. It was not easy to see if an internal or external function (as defined by visibility.c) was called. The change is quite large but hopefully makes Libgcrypt easier to maintain. Some function have not yet been fixed; this will be done soon. Because Libgcrypt does no make use of any other libgpg-error using libraries it is useless to always translate between gpg_error_t and gpg_err_code_t (i.e with and w/o error source identifier). This translation has no mostly be moved to the function wrappers in visibility.c. An additional advantage of using gpg_err_code_t is that comparison can be done without using gpg_err_code(). I am sorry for that large patch, but a series of patches would actually be more work to audit. Signed-off-by: Werner Koch <wk@gnupg.org>
* Add new MAC API, initially with HMACJussi Kivilinna2013-11-161-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * cipher/Makefile.am: Add 'mac.c', 'mac-internal.h' and 'mac-hmac.c'. * cipher/bufhelp.h (buf_eq_const): New. * cipher/cipher-ccm.c (_gcry_cipher_ccm_tag): Use 'buf_eq_const' for constant-time compare. * cipher/mac-hmac.c: New. * cipher/mac-internal.h: New. * cipher/mac.c: New. * doc/gcrypt.texi: Add documentation for MAC API. * src/gcrypt-int.h [GPG_ERROR_VERSION_NUMBER < 1.13] (GPG_ERR_MAC_ALGO): New. * src/gcrypt.h.in (gcry_mac_handle, gcry_mac_hd_t, gcry_mac_algos) (gcry_mac_flags, gcry_mac_open, gcry_mac_close, gcry_mac_ctl) (gcry_mac_algo_info, gcry_mac_setkey, gcry_mac_setiv, gcry_mac_write) (gcry_mac_read, gcry_mac_verify, gcry_mac_get_algo_maclen) (gcry_mac_get_algo_keylen, gcry_mac_algo_name, gcry_mac_map_name) (gcry_mac_reset, gcry_mac_test_algo): New. * src/libgcrypt.def (gcry_mac_open, gcry_mac_close, gcry_mac_ctl) (gcry_mac_algo_info, gcry_mac_setkey, gcry_mac_setiv, gcry_mac_write) (gcry_mac_read, gcry_mac_verify, gcry_mac_get_algo_maclen) (gcry_mac_get_algo_keylen, gcry_mac_algo_name, gcry_mac_map_name): New. * src/libgcrypt.vers (gcry_mac_open, gcry_mac_close, gcry_mac_ctl) (gcry_mac_algo_info, gcry_mac_setkey, gcry_mac_setiv, gcry_mac_write) (gcry_mac_read, gcry_mac_verify, gcry_mac_get_algo_maclen) (gcry_mac_get_algo_keylen, gcry_mac_algo_name, gcry_mac_map_name): New. * src/visibility.c (gcry_mac_open, gcry_mac_close, gcry_mac_ctl) (gcry_mac_algo_info, gcry_mac_setkey, gcry_mac_setiv, gcry_mac_write) (gcry_mac_read, gcry_mac_verify, gcry_mac_get_algo_maclen) (gcry_mac_get_algo_keylen, gcry_mac_algo_name, gcry_mac_map_name): New. * src/visibility.h (gcry_mac_open, gcry_mac_close, gcry_mac_ctl) (gcry_mac_algo_info, gcry_mac_setkey, gcry_mac_setiv, gcry_mac_write) (gcry_mac_read, gcry_mac_verify, gcry_mac_get_algo_maclen) (gcry_mac_get_algo_keylen, gcry_mac_algo_name, gcry_mac_map_name): New. * tests/basic.c (check_one_mac, check_mac): New. (main): Call 'check_mac'. * tests/bench-slope.c (bench_print_header, bench_print_footer): Allow variable algorithm name width. (_cipher_bench, hash_bench): Update to above change. (bench_hash_do_bench): Add 'gcry_md_reset'. (bench_mac_mode, bench_mac_init, bench_mac_free, bench_mac_do_bench) (mac_ops, mac_modes, mac_bench_one, _mac_bench, mac_bench): New. (main): Add 'mac' benchmark options. * tests/benchmark.c (mac_repetitions, mac_bench): New. (main): Add 'mac' benchmark options. -- Add MAC API, with HMAC algorithms. Internally uses HMAC functionality of the MD module. [v2]: - Add documentation for MAC API. - Change length argument for gcry_mac_read from size_t to size_t* for returning number of written bytes. [v3]: - HMAC algorithm ids start from 101. - Fix coding style for new files. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
* Do not check with cpp for typedefed constants.Werner Koch2013-09-041-1/+1
| | | | | | | * src/gcrypt-int.h: Include error code replacements depeding on the version of libgpg-error. Signed-off-by: Werner Koch <wk@gnupg.org>
* Make gpg-error replacement defines more robust.Werner Koch2013-06-261-0/+40
* configure.ac (AH_BOTTOM): Move GPG_ERR_ replacement defines to ... * src/gcrypt-int.h: new file. * src/visibility.h, src/cipher.h: Replace gcrypt.h by gcrypt-int.h. * tests/: Ditto for all test files. -- Defining newer gpg-error codes in config.h was not a good idea, because config.h is usually included before gpg-error.h and thus gpg-error.h would be double defines to lead to faulty code there like typedef enum { [...] 191 = 191, [...] };