Page MenuHome GnuPG

No OneTemporary

This file is larger than 256 KB, so syntax highlighting was skipped.
diff --git a/cipher/ChangeLog b/cipher/ChangeLog
index 2a28b204..fb051416 100644
--- a/cipher/ChangeLog
+++ b/cipher/ChangeLog
@@ -1,4115 +1,4120 @@
+2011-04-19 Werner Koch <wk@g10code.com>
+
+ * cipher.c (gcry_cipher_open): Replace gpg_err_code_from_errno by
+ gpg_err_code_from_syserror.
+
2011-04-11 Werner Koch <wk@g10code.com>
* pubkey.c (gcry_pk_get_keygrip): Avoid double free of L2.
* cipher.c (_gcry_cipher_setctr): Clear unused lastiv info.
(gcry_cipher_ctl) <GCRYCTL_SET_CTR>: Implement by calling
_gcry_cipher_setctr.
(do_ctr_encrypt): Save last counter and reuse it.
* cipher.c (do_ctr_encrypt): Allow arbitrary length inputs to
match the 1.4 behaviour.
2011-04-04 Werner Koch <wk@g10code.com>
* ecc.c (compute_keygrip): Release L1 while parsing "curve".
* pubkey.c (gcry_pk_get_keygrip): Always release NAME and L2.
Reported by Ben Kibbey.
2011-03-28 Werner Koch <wk@g10code.com>
* primegen.c (_gcry_generate_elg_prime): Make sure that PRIME is
NULL if the called func ever returns an error.
* pubkey.c (gcry_pk_decrypt): Remove unused var PUBKEY.
2011-03-09 Werner Koch <wk@g10code.com>
* kdf.c: New.
2011-02-22 Werner Koch <wk@g10code.com>
* rijndael.c (aesni_cleanup_2_4): New.
(aesenc_xmm1_xmm0, do_aesni_ctr_4): New.
(_gcry_aes_ctr_enc): New.
* cipher.c (struct gcry_cipher_handle): Add CTR_ENC. Move field
CTR into an u_ctr union and adjust all users.
(gcry_cipher_open): Use _gcry_aes_ctr_enc.
(do_ctr_encrypt): Use bulk mode.
2011-02-18 Werner Koch <wk@g10code.com>
* rijndael.c (u32_a_t): New.
(do_encrypt_aligned, do_encrypt_aligned): Use the new type to
avoid problems with strict aliasing rules.
2011-02-16 Werner Koch <wk@g10code.com>
* rijndael.c (do_aesni_cfb) [USE_AESNI]: New.
(_gcry_aes_cfb_enc, _gcry_aes_cfb_dec) [USE_AESNI]: Use new fucntion.
2011-02-15 Werner Koch <wk@g10code.com>
* rijndael.c (do_aesni_enc_aligned, do_aesni_dec_aligned): Use
movdqa for the key but keep using movdqu for the data.
(do_aesni): Remove alignment detection. Don't burn the stack.
(aesni_prepare, aesni_cleanup): New macros.
(rijndael_encrypt, _gcry_aes_cfb_enc, _gcry_aes_cbc_enc)
(rijndael_decrypt, _gcry_aes_cfb_dec, _gcry_aes_cbc_dec): Use
these macros. Don't burn the stack in the USE_AESNI case.
(do_setkey): Add disabled code to use aeskeygenassist.
2011-02-14 Werner Koch <wk@g10code.com>
* rijndael.c (ATTR_ALIGNED_16): New
(do_aesni): Do not copy if already aligned.
(do_encrypt, do_decrypt): Ditto.
(rijndael_decrypt, rijndael_encrypt): Increase stack burning amount.
* rijndael.c (RIJNDAEL_context): Reorder fields. Change fieldname
ROUNDS to rounds. Move padlock_key into u1.
(keySched, keySched2): Rename macros to keyscherr and keyschdec
and change all users.
(padlockkey): New macro. Change all users of padlock_key.
* cipher.c (NEED_16BYTE_ALIGNED_CONTEXT): Always define if using gcc.
(struct gcry_cipher_handle): Align U_IV to at least 16 byte.
2011-02-13 Werner Koch <wk@g10code.com>
* rijndael.c (USE_AESNI): New. Define for ia32 and gcc >= 4.
(m128i_t) [USE_AESNI]: New.
(RIJNDAEL_context) [USE_AESNI]: Add field use_aesni.
(do_setkey): Set USE_AESNI for all key lengths.
(prepare_decryption) [USE_AESNI]: Use aesimc instn if requested.
(do_aesni_enc_aligned, do_aesni_dec_aligned)
(do_aesni) [USE_AESNI]: New.
(rijndael_encrypt, _gcry_aes_cfb_enc, _gcry_aes_cbc_enc)
(rijndael_decrypt, _gcry_aes_cfb_dec)
(_gcry_aes_cbc_dec) [USE_AESNI]: Use do_aesni.
2011-02-01 Werner Koch <wk@g10code.com>
* pubkey.c (gcry_pk_get_curve): New.
(sexp_to_key): Add arg OVERRIDE_ELEMS.
(sexp_elements_extract_ecc): Allow for params only.
(gcry_pk_get_param): New.
* ecc.c (ecc_get_curve): New.
(ecc_get_param_sexp): New.
2011-01-28 Werner Koch <wk@g10code.com>
* pubkey.c (gcry_pk_genkey): Hack to insert the used curve name.
2011-01-27 Werner Koch <wk@g10code.com>
* ecc.c (fill_in_curve): Remove.
(generate_curve): Rename to ..
(fill_in_curve): this. Remove setting of NAME_OID.
(ecc_encrypt_raw): Change name of arg DATA to K for better
readability. Use ECC_public_key instead of ECC_secret_key.
Require a caller to pass a complete pkey array.
(ecc_decrypt_raw): Require a caller to pass a complete skey array.
(elliptic_curve_t): Add field NAME.
(fill_in_curve): Set field.
(generate_key): Add arg R_USED_CURVE.
(ecc_generate_ext): Return used curve name.
2011-01-13 Andrey Jivsov <openpgp@brainhub.org> (wk)
* ecc.c (ec2os): Do not free passed parameters X and Y. Adjust
callers.
(ecc_encrypt_raw, ecc_decrypt_raw): New.
(ecdh_names, _gcry_pubkey_spec_ecdh): New.
* pubkey.c (pubkey_table): Support ECDH.
2010-08-19 Werner Koch <wk@g10code.com>
* cipher.c (gcry_cipher_open): Remove double release of the module.
Fixes bug#1263.
2010-06-10 Jeff Johnson <n3npq@mac.com> (wk)
* ecc.c (ecc_generate_ext): Parse transient-key flag.
(generate_key): Add arg TRANSIENT_KEY and use it to set the random
level.
2010-04-12 Brad Hards <bradh@frogmouth.net> (wk)
Spelling fixes.
2010-03-26 Werner Koch <wk@g10code.com>
* tiger.c (asn): Unfetter the old TIGER from an OID.
(TIGER_CONTEXT): Add field VARIANT.
(tiger_init): Factor code out to ...
(do_init): New.
(tiger1_init, tiger2_init): New.
(_gcry_digest_spec_tiger1, _gcry_digest_spec_tiger2): New.
* md.c (digest_table): Add TIGER1 and TIGER2 variants.
2009-12-11 Werner Koch <wk@g10code.com>
* sha256.c (Cho, Maj, Sum0, Sum1): Turn macros into inline
functions.
(transform): Partly unroll to interweave the chain variables
* sha512.c (ROTR, Ch, Maj, Sum0, Sum1): Turn macros into inline
functions.
(transform): Partly unroll to interweave the chain variables.
Suggested by Christian Grothoff.
2009-12-10 Werner Koch <wk@g10code.com>
* Makefile.am (o_flag_munging): New.
(tiger.o, tiger.lo): Use it.
* cipher.c (do_ctr_encrypt): Add arg OUTBUFLEN. Check for
suitable value. Add check for valid inputlen. Wipe temporary
memory.
(do_ctr_decrypt): Likewise.
(do_cbc_encrypt, do_cbc_decrypt): Add arg OUTBUFLEN. Check for
suitable value. Move check for valid inputlen to here; change
returned error from INV_ARG to INV_LENGTH.
(do_ecb_encrypt, do_ecb_decrypt): Ditto.
(do_cfb_encrypt, do_cfb_decrypt): Ditto.
(do_ofb_encrypt, do_ofb_decrypt): Ditto.
(cipher_encrypt, cipher_encrypt): Adjust for above changes.
(gcry_cipher_encrypt, gcry_cipher_decrypt): Simplify.
2009-12-09 Werner Koch <wk@g10code.com>
* cipher.c (gcry_cipher_open): Allow for GCRY_CIPHER_MODE_AESWRAP.
(cipher_encrypt, cipher_decrypt): Ditto.
(do_aeswrap_encrypt, do_aeswrap_decrypt): New.
(struct gcry_cipher_handle): Add field marks.
(cipher_setkey, cipher_setiv): Update marks flags.
(cipher_reset): Reset marks.
(cipher_encrypt, cipher_decrypt): Add new arg OUTBUFLEN.
(gcry_cipher_encrypt, gcry_cipher_decrypt): Pass outbuflen to
cipher_encrypt. Replace GPG_ERR_TOO_SHORT by
GPG_ERR_BUFFER_TOO_SHORT.
2009-08-21 Werner Koch <wk@g10code.com>
* dsa.c (dsa_generate_ext): Release retfactors array before
setting it to NULL. Reported by Daiko Ueno.
2009-07-02 Werner Koch <wk@g10code.com>
* md.c (md_read): Fix incomplete check for NULL.
Reported by Fabian Kail.
2009-03-31 Werner Koch <wk@g10code.com>
* rsa.c (rsa_check_secret_key): Return GPG_ERR_BAD_SECKEY and not
GPG_ERR_PUBKEY_ALGO.
2009-02-16 Werner Koch <wk@g10code.com>
* rsa.c (generate_x931): Do not initialize TBL with automatic
variables.
* whirlpool.c, tiger.c, sha256.c, sha1.c, rmd160.c, md5.c
* md4.c, crc.c: Remove memory.h. This is garbage from gnupg.
Reported by Dan Fandrich.
2009-01-22 Werner Koch <wk@g10code.com>
* ecc.c (compute_keygrip): Remove superfluous const.
2009-01-06 Werner Koch <wk@g10code.com>
* rmd160.c (oid_spec_rmd160): Add TeleTrust identifier.
2008-12-10 Werner Koch <wk@g10code.com>
* dsa.c (generate): Add arg DOMAIN and use it if specified.
(generate_fips186): Ditto.
(dsa_generate_ext): Parse and check the optional "domain"
parameter and pass them to the generate functions.
* rijndael.c (rijndael_names): Add "AES128" and "AES-128".
(rijndael192_names): Add "AES-192".
(rijndael256_names): Add "AES-256".
2008-12-05 Werner Koch <wk@g10code.com>
* dsa.c (generate): Add arg TRANSIENT_KEY and use it to detrmine
the RNG quality needed.
(dsa_generate_ext): Parse the transient-key flag und pass it to
generate.
2008-11-28 Werner Koch <wk@g10code.com>
* dsa.c (generate_fips186): Add arg DERIVEPARMS and use the seed
value if available.
* primegen.c (_gcry_generate_fips186_2_prime): Fix inner p loop.
2008-11-26 Werner Koch <wk@g10code.com>
* primegen.c (_gcry_generate_fips186_3_prime): New.
* dsa.c (generate_fips186): Add arg USE_FIPS186_2.
(dsa_generate_ext): Parse new flag use-fips183-2.
2008-11-25 Werner Koch <wk@g10code.com>
* dsa.c (generate_fips186): New.
(dsa_generate_ext): Use new function if derive-parms are given or
if in FIPS mode.
* primegen.c (_gcry_generate_fips186_2_prime): New.
2008-11-24 Werner Koch <wk@g10code.com>
* pubkey.c (gcry_pk_genkey): Insert code to output extrainfo.
(pubkey_generate): Add arg R_EXTRAINFO and pass it to the extended
key generation function.
* rsa.c (gen_x931_parm_xp, gen_x931_parm_xi): New.
(generate_x931): Generate params if not given.
(rsa_generate_ext): Parse use-x931 flag. Return p-q-swapped
indicator.
* dsa.c (dsa_generate_ext): Put RETFACTORS into R_EXTRAINFO if
possible.
* pubkey.c (gcry_pk_genkey): Remove parsing of almost all
parameters and pass the parameter S-expression to pubkey_generate.
(pubkey_generate): Simplify by requitring modules to parse the
parameters. Remove the special cases for Elgamal and ECC.
(sexp_elements_extract_ecc): Add arg EXTRASPEC and use it. Fix
small memory leak.
(sexp_to_key): Pass EXTRASPEC to sexp_elements_extract_ecc.
(pubkey_table) [USE_ELGAMAL]: Add real extraspec.
* rsa.c (rsa_generate_ext): Adjust for new calling convention.
* dsa.c (dsa_generate_ext): Ditto.
* elgamal.c (_gcry_elg_generate): Ditto. Rename to elg_generate_ext.
(elg_generate): New.
(_gcry_elg_generate_using_x): Remove after merging code with
elg_generate_ext.
(_gcry_pubkey_extraspec_elg): New.
(_gcry_elg_check_secret_key, _gcry_elg_encrypt, _gcry_elg_sign)
(_gcry_elg_verify, _gcry_elg_get_nbits): Make static and remove
_gcry_ prefix.
* ecc.c (_gcry_ecc_generate): Rename to ecc_generate_ext and
adjust for new calling convention.
(_gcry_ecc_get_param): Rename to ecc_get_param and make static.
(_gcry_pubkey_extraspec_ecdsa): Add ecc_generate_ext and
ecc_get_param.
2008-11-20 Werner Koch <wk@g10code.com>
* pubkey.c (pubkey_generate): Add arg DERIVEPARMS.
(gcry_pk_genkey): Parse derive-parms and pass it to above.
* rsa.c (generate_x931): New.
(rsa_generate_ext): Add arg DERIVEPARMS and call new function in
fips mode or if DERIVEPARMS is given.
* primegen.c (_gcry_derive_x931_prime, find_x931_prime): New.
2008-11-19 Werner Koch <wk@g10code.com>
* rsa.c (rsa_decrypt): Use gcry_create_nonce for blinding.
(generate): Rename to generate_std.
2008-11-05 Werner Koch <wk@g10code.com>
* md.c (md_open): Use a switch to set the Bsize.
(prepare_macpads): Fix long key case for SHA384 and SHA512.
* cipher.c (gcry_cipher_handle): Add field EXTRASPEC.
(gcry_cipher_open): Set it.
(gcry_cipher_ctl): Add private control code to disable weak key
detection and to return the current input block.
* des.c (_tripledes_ctx): Add field FLAGS.
(do_tripledes_set_extra_info): New.
(_gcry_cipher_extraspec_tripledes): Add new function.
(do_tripledes_setkey): Disable weak key detection.
2008-10-24 Werner Koch <wk@g10code.com>
* md.c (digest_table): Allow MD5 in fips mode.
(md_register_default): Take special action for MD5.
(md_enable, gcry_md_hash_buffer): Ditto.
2008-09-30 Werner Koch <wk@g10code.com>
* rijndael.c (do_setkey): Properly align "t" and "tk".
(prepare_decryption): Properly align "w". Fixes bug #936.
2008-09-18 Werner Koch <wk@g10code.com>
* pubkey.c (gcry_pk_genkey): Parse domain parameter.
(pubkey_generate): Add new arg DOMAIN and remove special case for
DSA with qbits.
* rsa.c (rsa_generate): Add dummy args QBITS, NAME and DOMAIN and
rename to rsa_generate_ext. Change caller.
(_gcry_rsa_generate, _gcry_rsa_check_secret_key)
(_gcry_rsa_encrypt, _gcry_rsa_decrypt, _gcry_rsa_sign)
(_gcry_rsa_verify, _gcry_rsa_get_nbits): Make static and remove
_gcry_ prefix.
(_gcry_pubkey_spec_rsa, _gcry_pubkey_extraspec_rsa): Adjust names.
* dsa.c (dsa_generate_ext): New.
(_gcry_dsa_generate): Replace code by a call to dsa_generate.
(_gcry_dsa_check_secret_key, _gcry_dsa_sign, _gcry_dsa_verify)
(_gcry_dsa_get_nbits): Make static and remove _gcry prefix.
(_gcry_dsa_generate2): Remove.
(_gcry_pubkey_spec_dsa): Adjust to name changes.
(_gcry_pubkey_extraspec_rsa): Add dsa_generate_ext.
2008-09-16 Werner Koch <wk@g10code.com>
* ecc.c (run_selftests): Add arg EXTENDED.
2008-09-12 Werner Koch <wk@g10code.com>
* rsa.c (test_keys): Do a bad case signature check.
* dsa.c (test_keys): Do a bad case check.
* cipher.c (_gcry_cipher_selftest): Add arg EXTENDED and pass it
to the called tests.
* md.c (_gcry_md_selftest): Ditto.
* pubkey.c (_gcry_pk_selftest): Ditto.
* rijndael.c (run_selftests): Add arg EXTENDED and pass it to the
called tests.
(selftest_fips_128): Add arg EXTENDED and run only one test
non-extended mode.
(selftest_fips_192): Add dummy arg EXTENDED.
(selftest_fips_256): Ditto.
* hmac-tests.c (_gcry_hmac_selftest): Ditto.
(run_selftests): Ditto.
(selftests_sha1): Add arg EXTENDED and run only one test
non-extended mode.
(selftests_sha224, selftests_sha256): Ditto.
(selftests_sha384, selftests_sha512): Ditto.
* sha1.c (run_selftests): Add arg EXTENDED and pass it to the
called test.
(selftests_sha1): Add arg EXTENDED and run only one test
non-extended mode.
* sha256.c (run_selftests): Add arg EXTENDED and pass it to the
called tests.
(selftests_sha224): Add arg EXTENDED and run only one test
non-extended mode.
(selftests_sha256): Ditto.
* sha512.c (run_selftests): Add arg EXTENDED and pass it to the
called tests.
(selftests_sha384): Add arg EXTENDED and run only one test
non-extended mode.
(selftests_sha512): Ditto.
* des.c (run_selftests): Add arg EXTENDED and pass it to the
called test.
(selftest_fips): Add dummy arg EXTENDED.
* rsa.c (run_selftests): Add dummy arg EXTENDED.
* dsa.c (run_selftests): Add dummy arg EXTENDED.
* rsa.c (extract_a_from_sexp): New.
(selftest_encr_1024): Check that the ciphertext does not match the
plaintext.
(test_keys): Improve tests and return an error status.
(generate): Return an error if test_keys fails.
* dsa.c (test_keys): Add comments and return an error status.
(generate): Return an error if test_keys failed.
2008-09-11 Werner Koch <wk@g10code.com>
* rsa.c (_gcry_rsa_decrypt): Return an error instead of calling
BUG in case of a practically impossible condition.
(sample_secret_key, sample_public_key): New.
(selftest_sign_1024, selftest_encr_1024): New.
(selftests_rsa): Implement tests.
* dsa.c (sample_secret_key, sample_public_key): New.
(selftest_sign_1024): New.
(selftests_dsa): Implement tests.
2008-09-09 Werner Koch <wk@g10code.com>
* hmac-tests.c (selftests_sha1): Add tests.
(selftests_sha224, selftests_sha384, selftests_sha512): Make up tests.
* hash-common.c, hash-common.h: New.
* sha1.c (selftests_sha1): Add 3 tests.
* sha256.c (selftests_sha256, selftests_sha224): Ditto.
* sha512.c (selftests_sha512, selftests_sha384): Ditto.
2008-08-29 Werner Koch <wk@g10code.com>
* pubkey.c (gcry_pk_get_keygrip): Remove the special case for RSA
and check whether a custom computation function has been setup.
* rsa.c (compute_keygrip): New.
(_gcry_pubkey_extraspec_rsa): Setup this function.
* ecc.c (compute_keygrip): New.
(_gcry_pubkey_extraspec_ecdsa): Setup this function.
2008-08-28 Werner Koch <wk@g10code.com>
* cipher.c (cipher_decrypt, cipher_encrypt): Return an error if
mode NONE is used.
(gcry_cipher_open): Allow mode NONE only with a debug flag set and
if not in FIPS mode.
2008-08-26 Werner Koch <wk@g10code.com>
* pubkey.c (pubkey_generate): Add arg KEYGEN_FLAGS.
(gcry_pk_genkey): Implement new parameter "transient-key" and
pass it as flags to pubkey_generate.
(pubkey_generate): Make use of an ext_generate function.
* rsa.c (generate): Add new arg transient_key and pass appropriate
args to the prime generator.
(_gcry_rsa_generate): Factor all code out to ...
(rsa_generate): .. new func with extra arg KEYGEN_FLAGS.
(_gcry_pubkey_extraspec_ecdsa): Setup rsa_generate.
* primegen.c (_gcry_generate_secret_prime)
(_gcry_generate_public_prime): Add new arg RANDOM_LEVEL.
2008-08-21 Werner Koch <wk@g10code.com>
* primegen.c (_gcry_generate_secret_prime)
(_gcry_generate_public_prime): Use a constant macro for the random
level.
2008-08-19 Werner Koch <wk@g10code.com>
* pubkey.c (sexp_elements_extract_ecc) [!USE_ECC]: Do not allow
allow "curve" parameter.
2008-08-15 Werner Koch <wk@g10code.com>
* pubkey.c (_gcry_pk_selftest): New.
* dsa.c (selftests_dsa, run_selftests): New.
* rsa.c (selftests_rsa, run_selftests): New.
* ecc.c (selftests_ecdsa, run_selftests): New.
* md.c (_gcry_md_selftest): New.
* sha1.c (run_selftests, selftests_sha1): New.
* sha256.c (selftests_sha224, selftests_sha256, run_selftests): New.
* sha512.c (selftests_sha384, selftests_sha512, run_selftests): New.
* des.c (selftest): Remove static variable form selftest.
(des_setkey): No on-the-fly self test in fips mode.
(tripledes_set3keys): Ditto.
* cipher.c (_gcry_cipher_setkey, _gcry_cipher_setiv):
* dsa.c (generate): Bail out in fips mode if NBITS is less than 1024.
* rsa.c (generate): Return an error code if the the requested size
is less than 1024 and we are in fpis mode.
(_gcry_rsa_generate): Take care of that error code.
* ecc.c (generate_curve): In fips mode enable only NIST curves.
* cipher.c (_gcry_cipher_selftest): New.
* sha512.c (_gcry_digest_extraspec_sha384)
(_gcry_digest_extraspec_sha512): New.
* sha256.c (_gcry_digest_extraspec_sha224)
(_gcry_digest_extraspec_sha256): New.
* sha1.c (_gcry_digest_extraspec_sha1): New.
* ecc.c (_gcry_pubkey_extraspec_ecdsa): New.
* dsa.c (_gcry_pubkey_extraspec_dsa): New.
* rsa.c (_gcry_pubkey_extraspec_rsa): New.
* rijndael.c (_gcry_cipher_extraspec_aes)
(_gcry_cipher_extraspec_aes192, _gcry_cipher_extraspec_aes256): New.
* des.c (_gcry_cipher_extraspec_tripledes): New.
* cipher.c (gcry_cipher_register): Rename to _gcry_cipher_register.
Add arg EXTRASPEC.
(dummy_extra_spec): New.
(cipher_table_entry): Add extraspec field.
* md.c (_gcry_md_register): Rename to _gcry_md_register. Add
arg EXTRASPEC.
(dummy_extra_spec): New.
(digest_table_entry): Add extraspec field.
* pubkey.c (gcry_pk_register): Rename to _gcry_pk_register. Add
arg EXTRASPEC.
(dummy_extra_spec): New.
(pubkey_table_entry): Add extraspec field.
* ac.c: Let most public functions return GPG_ERR_UNSUPPORTED in
fips mode.
* pubkey.c (pubkey_table_entry): Add field FIPS_ALLOWED and mark
appropriate algorithms.
(dummy_generate, dummy_check_secret_key, dummy_encrypt)
(dummy_decrypt, dummy_sign, dummy_verify, dummy_get_nbits): Signal
a fips error when used.
(gcry_pk_register): In fips mode do not allow to register new
algorithms.
* md.c (digest_table): Add field FIPS_ALLOWED and mark appropriate
algorithms.
(md_register_default): In fips mode register only fips algorithms.
(gcry_md_register): In fips mode do not allow to register new
algorithms.
(gcry_md_get): Signal a fips error if called.
(gcry_md_hash_buffer): Do not allow rmd160 when not in fips mode.
(md_start_debug): Disable in fips_mode.
* md.c (gcry_md_register_default): Rename to ..
(md_register_default): .. this.
(md_digest): Remove this commented fucntion.
* pubkey.c (gcry_pk_register_default): Rename to ..
(pk_register_default): .. this.
* cipher.c (cipher_table_entry): Add field FIPS_ALLOWED.
(gcry_cipher_register_default): Register only fips approved
algorithms.
(gcry_cipher_register): Do not allow to register new ciphers.
(cipher_setiv): Signal fips error.
* cipher (gcry_cipher_register_default): Rename to ..
(cipher_register_default): .. this.
(REGISTER_DEFAULT_CIPHERS): Adjust for that change.
2008-07-05 Werner Koch <wk@g10code.com>
* random-daemon.c, random.h, rndhw.c, rndunix.c, rand-internal.h
* random.c, rndegd.c, rndlinux.c, rndw32.c: Move to ../cipher.
* Makefile.am: Remove random stuff.
2008-06-24 Szakats Istvan <szaki.ms@gmail.com> (wk)
* ac.c (_gcry_ac_key_destroy, _gcry_ac_key_pair_generate): Relase
some more memory.
2008-04-22 Werner Koch <wk@g10code.com>
* rijndael.c (_gcry_aes_cfb_enc, _gcry_aes_cbc_enc)
(_gcry_aes_cfb_dec, _gcry_aes_cbc_dec): Use Padlock if possible.
2008-04-18 Werner Koch <wk@g10code.com>
* sha1.c (transform_aligned): Remove. That is will obviosuly not
work because we need a scratch working area and our internal API
does not allow to modify the buffers.
* rijndael.c: Factor tables out to ..
* rijndael-tables.h: .. new.
* ac.c (ac_data_extract): Make static.
* camellia.h [HAVE_CONFIG_H]: Include config.h.
* rndw32.c (registry_poll): Only print the performance data
problem warning once. Suggested by Simon Josefsson.
2008-03-19 Werner Koch <wk@g10code.com>
* cipher.c (gcry_cipher_open) [USE_AES]: Init bulk encryption only
if requested. Suggested by Dirk Stoecker.
2008-03-18 Werner Koch <wk@g10code.com>
* sha1.c: Include stdint.h.
(transform): Add arg NBLOCKS so that we can work on more than one
block and avoid updates of the chaining variables. Changed all
callers to use 1.
(sha1_write): Replace loop around transform.
(transform_aligned) [WORDS_BIGENDIAN]: New.
(TRANSFORM): New macro to replace all direct calls of transform.
2008-03-17 Werner Koch <wk@g10code.com>
* rijndael.c (_gcry_aes_cfb_dec): New.
(do_encrypt): Factor code out to ..
(do_encrypt_aligned): .. New.
(_gcry_aes_cfb_enc, _gcry_aes_cfb_dec): Use new function.
(do_decrypt): Factor code out to ..
(do_decrypt_aligned): .. new.
(_gcry_aes_cbc_enc, _gcry_aes_cbc_dec): New.
* cipher.c (struct gcry_cipher_handle): Put field IV into new
union U_IV to enforce proper alignment. Change all users.
(do_cfb_decrypt): Optimize.
(do_cbc_encrypt, do_cbc_decrypt): Optimize.
2008-03-15 Werner Koch <wk@g10code.com>
* rijndael.c (_gcry_aes_cfb_enc): New.
* cipher.c (struct gcry_cipher_handle): Add field ALGO and BULK.
(gcry_cipher_open): Set ALGO and BULK.
(do_cfb_encrypt): Optimize.
2008-02-18 Werner Koch <wk@g10code.com>
* rsa.c (_gcry_rsa_verify) [IS_DEVELOPMENT_VERSION]: Print
intermediate results.
2008-01-08 Werner Koch <wk@g10code.com>
* random.c (add_randomness): Do not just increment
POOL_FILLED_COUNTER but update it by the actual amount of data.
2007-12-13 Werner Koch <wk@g10code.com>
* pubkey.c (sexp_data_to_mpi): Support SHA-224.
2007-12-05 Werner Koch <wk@g10code.com>
* rijndael.c (USE_PADLOCK): Depend on ENABLE_PADLOCK_SUPPORT.
* rndhw.c (USE_PADLOCK): Ditto
* rsa.c (secret): Fixed condition test for using CRT. Reported by
Dean Scarff. Fixes bug#864.
(_gcry_rsa_check_secret_key): Return an erro if the optional
parameters are missing.
* pubkey.c (sexp_elements_extract): Add arg ALGO_NAME. Changed all
callers to pass NULL. Add hack to allow for optional RSA
parameters.
(sexp_to_key): Pass algo name to sexp_elements_extract.
2007-12-03 Werner Koch <wk@g10code.com>
* random.c (gcry_random_add_bytes): Implement it.
* rand-internal.h (RANDOM_ORIGIN_EXTERNAL): New.
2007-11-30 Werner Koch <wk@g10code.com>
* rndhw.c: New.
* rndlinux.c (_gcry_rndlinux_gather_random): Try to read 50%
directly from the hwrng.
* random.c (do_fast_random_poll): Also run the hw rng fast poll.
(_gcry_random_dump_stats): Tell whether the hw rng failed.
2007-11-29 Werner Koch <wk@g10code.com>
* rijndael.c (USE_PADLOCK): Define new macro used for ia32.
(RIJNDAEL_context) [USE_PADLOCK]: Add fields USE_PADLOCK and
PADLOCK_KEY.
(do_setkey) [USE_PADLOCK]: Enable padlock if available for 128 bit
AES.
(do_padlock) [USE_PADLOCK]: New.
(rijndael_encrypt, rijndael_decrypt) [USE_PADLOCK]: Divert to
do_padlock.
* cipher.c (cipher_context_alignment_t): New. Use it in this
module in place of PROPERLY_ALIGNED_TYPE.
(NEED_16BYTE_ALIGNED_CONTEXT): Define macro for ia32.
(struct gcry_cipher_handle): Add field HANDLE_OFFSET.
(gcry_cipher_open): Take care of increased alignment requirements.
(gcry_cipher_close): Ditto.
2007-11-28 Werner Koch <wk@g10code.com>
* sha256.c (asn224): Fixed wrong template. It happened due to a
bug in RFC4880. SHA-224 is not in the stable version of libgcrypt
so the consequences are limited to users of this devel version.
2007-10-31 Werner Koch <wk@g10code.com>
* ac.c (gcry_ac_data_new): Remove due to the visibility wrapper.
(gcry_ac_data_destroy, gcry_ac_data_copy, gcry_ac_data_length)
(gcry_ac_data_set, gcry_ac_data_get_name, gcry_ac_data_get_index)
(gcry_ac_data_to_sexp, gcry_ac_data_from_sexp)
(gcry_ac_data_clear, gcry_ac_io_init, gcry_ac_open)
(gcry_ac_close, gcry_ac_key_init, gcry_ac_key_pair_generate)
(gcry_ac_key_pair_extract, gcry_ac_key_destroy)
(gcry_ac_key_pair_destroy, gcry_ac_key_data_get)
(gcry_ac_key_test, gcry_ac_key_get_nbits, gcry_ac_key_get_grip)
(gcry_ac_data_encrypt, gcry_ac_data_decrypt, gcry_ac_data_sign)
(gcry_ac_data_verify, gcry_ac_data_encode, gcry_ac_data_decode)
(gcry_ac_mpi_to_os, gcry_ac_mpi_to_os_alloc, gcry_ac_os_to_mpi)
(gcry_ac_data_encrypt_scheme, gcry_ac_data_decrypt_scheme)
(gcry_ac_data_sign_scheme, gcry_ac_data_verify_scheme)
(gcry_ac_io_init_va): Ditto.
(gcry_ac_id_to_name, gcry_ac_name_to_id): Remove as these
deprecated functions are now implemented by visibility.c.
2007-10-26 Werner Koch <wk@g10code.com>
* rndw32.c: Disable debug flag.
2007-10-25 Werner Koch <wk@g10code.com>
* rndw32.c: Updated from current cryptlib snapshot and modified
for our use. Removed support from pre NT systems.
(slow_gatherer_windows95): Remove.
(_gcry_rndw32_gather_random): Require an NT platform.
(init_system_rng, read_system_rng, read_mbm_data): New.
(slow_gatherer_windowsNT): Rename to ...
(slow_gatherer): .. this. Read system RNG and MBM.
(registry_poll): New with code factored out from slow_gatherer.
2007-08-23 Werner Koch <wk@g10code.com>
* random.c (pool_filled_counter): New.
(add_randomness): Use it.
2007-08-22 Werner Koch <wk@g10code.com>
* rndw32.c, rndunix.c: Switched to LGPL.
2007-05-30 Werner Koch <wk@g10code.com>
* camellia.h, camellia.c: Replace by new LGPL version and adjusted
camellia.h.
2007-05-09 Marcus Brinkmann <marcus@g10code.de>
* ac.c (_gcry_ac_io_init_va, _gcry_ac_io_write, _gcry_ac_io_read):
Adjust users of gcry_ac_io_t because union is not anonymous
anymore.
2007-05-02 Werner Koch <wk@g10code.com>
* camellia-glue.c (camellia_setkey, camellia_encrypt)
(camellia_decrypt): Recalculated used stack size in called
functions.
* camellia.h: Redefine external symbols.
2007-05-02 David Shaw <dshaw@jabberwocky.com>
* Makefile.am, cipher.c: Add Camellia.
* camellia-glue.c: New. The necessary glue to interface libgcrypt
to the stock NTT Camellia distribution.
* camellia.h, camellia.c: The stock NTT Camellia distribution
(GPL).
2007-04-30 David Shaw <dshaw@jabberwocky.com>
* cipher.c: Use #if instead of #ifdef as configure defines the
USE_cipher defines as 0 for disabled.
2007-04-30 Werner Koch <wk@g10code.com>
* rndegd.c (_gcry_rndegd_set_socket_name): New.
2007-04-30 Marcus Brinkmann <marcus@g10code.de>
* ecc.c (ec2os): Fix relocation of short numbers.
* ecc.c (generate_key): Do not allocate D, which will be allocated
by GEN_K. Remove G. Fix test if g_x, g_y resp. q_x, q_y are
requested.
(_gcry_ecc_generate): Release unneeded members of SK.
* pubkey.c (sexp_to_key): Release NAME.
2007-04-28 Marcus Brinkmann <marcus@g10code.de>
* ac.c (gcry_ac_mpi): Remove member NAME_PROVIDED.
(ac_data_mpi_copy, _gcry_ac_data_set, _gcry_ac_data_get_name)
(_gcry_ac_data_get_index, ac_data_construct): Adjust handling of
NAME accordingly.
2007-04-20 Werner Koch <wk@g10code.com>
* ecc.c (domain_parms): Add standard brainpool curves.
2007-04-18 Werner Koch <wk@g10code.com>
* ecc.c (generate_curve): Implement alias mechanism.
* pubkey.c (sexp_elements_extract_ecc): New.
(sexp_to_key): Add special case for ecc.
(sexp_to_key, sexp_to_sig, sexp_to_enc, gcry_pk_genkey): Replace
name_terminated stuff by a call to _gcry_sexp_nth_string.
(gcry_pk_get_keygrip): Ditto.
2007-04-16 Werner Koch <wk@g10code.com>
* ecc.c (_gcry_ecc_generate): Renamed DUMMY to CURVE and use it.
2007-04-13 Marcus Brinkmann <marcus@g10code.de>
* ac.c (ac_data_construct): Cast const away to suppress compiler
warning.
* ecc.c (ecc_generate): Avoid compiler warning for unused argument
DUMMY.
(ecc_verify): Avoid compiler warning for unused arguments CMP and
OPAQUEV.
2007-04-06 Werner Koch <wk@g10code.com>
* sha1.c (oid_spec_sha1): Add another oid from X9.62.
2007-03-28 Werner Koch <wk@g10code.com>
* pubkey.c (gcry_pk_genkey): Do not issue misc-key-info if it is
empty.
(gcry_pk_genkey): New parameter "curve".
* ecc.c: Entirely rewritten with only a few traces of the old
code left.
(_gcry_ecc_generate): New.
(generate_key) New arg NAME.
(generate_curve): Ditto. Return actual number of NBITS.
2007-03-26 Werner Koch <wk@g10code.com>
* pubkey.c (gcry_pk_genkey): Increase size of SKEY array and add a
runtime bounds check.
2007-03-23 Werner Koch <wk@g10code.com>
* ecc.c (ecc_ctx_init, ecc_ctx_free, ecc_mod, ecc_mulm): New.
(duplicate_point, sum_points, escalar_mult): Don't use a
copy of base->p. Replaced all mpi_mulm by ecc_mulm so that we can
experiment with different algorithms.
(generate_key, check_secret_key, sign, verify): Initialize a
computation context for use by ecc_mulm.
2007-03-22 Werner Koch <wk@g10code.com>
* pubkey.c (pubkey_table): Initialize ECC.
* Makefile.am (EXTRA_libcipher_la_SOURCES): Add ecc.c.
* ecc.c: New. Heavily reformatted and changed for use in libgcrypt.
(point_init): New.
(escalar_mult): Make arg R the first arg to be similar to the mpi
functions.
(duplicate_point): Ditto
(sum_points): Ditto
(sign, verify): Remove unneeded copy operations.
(sum_points): Removed memory leaks and optimized some compares.
(verify): Simplified input check.
2007-03-14 Werner Koch <wk@g10code.com>
* random.c (MASK_LEVEL): Removed macro as it was used only at one
place. Open coded it there.
(gcry_randomize, _gcry_update_random_seed_file)
(_gcry_fast_random_poll): Factor lock code out to ..
(lock_pool, unlock_pool): .. new.
(initialize): Look the pool while allocating.
(read_random_source, do_fast_random_poll): Moved intialization to ...
(initialize): .. here.
(_gcry_enable_quick_random_gen): No more need for initialization.
(is_initialized): Moved this global flag to ..
(initialize): .. here and changed all users to unconditionally call
initialize.
(add_randomness): Remove initalization here. It simply can't
happen.
* random.c (enum random_origins): Moved to ..
* rand-internal.h: .. here.
* rndunix.c (_gcry_rndunix_gather_random): Use enum in prototype
for ORIGIN and renamed REQUESTOR to ORIGIN.
* rndegd.c (_gcry_rndegd_gather_random): Ditto.
* rndlinux.c (_gcry_rndlinux_gather_random): Ditto.
* rndw32.c (_gcry_rndw32_gather_random): Ditto.
(_gcry_rndw32_gather_random_fast): Ditto.
2007-03-13 Werner Koch <wk@g10code.com>
* random.c (enum random_origins): New.
(add_randomness): Renamed arg SOURCE to ORIGIN.
(read_random_source): Renamed arg REQUESTOR to ORIGIN.
(getfnc_gather_random): Removed static variable because this
function is only called one and thus we don't need this
optimization.
(_gcry_quick_random_gen): Removed and replaced by..
(_gcry_enable_quick_random_gen): .. this. It is onlyu used to
enable it and it does not make sense to disable it later. Changed
the only one caller too.
(get_random_bytes): Removed.
(gcry_random_bytes, gcry_random_bytes_secure): Implement in terms
of gcry_randomize.
* random-daemon.c (_gcry_daemon_get_random_bytes): Removed.
2007-02-23 Werner Koch <wk@g10code.com>
* elgamal.c (generate): Removed unused variable TEMP.
(test_keys): New arg NODIE.
(generate_using_x, _gcry_elg_generate_using_x): New.
* pubkey.c (pubkey_generate): New arg XVALUE and direct call to
the new elgamal generate fucntion.
(gcry_pk_genkey): Parse the new "xvalue" tag.
2007-02-22 Werner Koch <wk@g10code.com>
* pubkey.c (sexp_data_to_mpi): Handle dynamically allocated
algorithms. Suggested by Neil Dunbar. Fixes bug#596.
* rndw32.c (_gcry_rndw32_gather_random_fast): Make it return void.
* cipher.c (gcry_cipher_algo_name): Simplified.
* random.c: Use the daemon only if compiled with USE_RANDOM_DAEMON.
* Makefile.am (libcipher_la_SOURCES): Build random-daemon support
only if requested.
2007-02-21 Werner Koch <wk@g10code.com>
* random.c (rndpool, keypool): Make unsigned.
(mix_pool): Change char* variables to unsigned char*.
(gcry_randomize): Make arg BUFFER a void*.
(gcry_create_nonce): Ditto.
* rmd160.c (gcry_rmd160_mixblock): Make BUFFER a void*.
(_gcry_rmd160_hash_buffer): Make OUTBUF and BUFFER void*.
* sha1.c (_gcry_sha1_hash_buffer): Ditto.
* cipher.c (gcry_cipher_encrypt, cry_cipher_decrypt): Change
buffer args to void*.
(gcry_cipher_register): Make ALGORITHM_ID a int *.
* md.c (md_start_debug): Make SUFFIX a const char*. Use snprintf.
(gcry_md_debug): New.
(gcry_md_ctl): Changed arg BUFFER from unsigned char*.
* md.c (md_write): Make INBUF a const void*.
(gcry_md_write): Remove needless cast.
* crc.c (crc32_write): Make INBUF a const void*
(update_crc32, crc24rfc2440_write): Ditto.
* sha512.c (sha512_write, transform): Ditto.
* sha256.c (sha256_write, transform): Ditto.
* rmd160.c (rmd160_write, transform): Ditto.
* md5.c (md5_write, transform): Ditto.
* md4.c (md4_write, transform): Ditto.
* sha1.c (sha1_write, transform): Ditto.
* tiger.c (tiger_write, transform): Ditto.
* whirlpool.c (whirlpool_write, whirlpool_add, transform): Ditto.
* elgamal.c (elg_names): Change to a const*.
* dsa.c (dsa_names): Ditto.
* rsa.c (rsa_names): Ditto.
* pubkey.c (gcry_pk_lookup_func_name): Make ALIASES a const.
2007-02-20 Werner Koch <wk@g10code.com>
* rndlinux.c (open_device): Remove unsused arg MINOR.
2007-01-30 Werner Koch <wk@g10code.com>
* sha256.c (oid_spec_sha256): Add alias from pkcs#1.
* sha512.c (oid_spec_sha512): Ditto.
(oid_spec_sha384): Ditto.
2006-12-18 Werner Koch <wk@g10code.com>
* rndlinux.c (set_cloexec_flag): New.
(open_device): Set close-on-exit flags. Suggested by Max
Kellermann. Fixes Debian#403613.
* Makefile.am (AM_CPPFLAGS, AM_CFLAGS): Splitted and merged
Moritz' changes.
(INCLUDES): Removed.
2006-11-30 Werner Koch <wk@g10code.com>
* serpent.c (byte_swap_32): Remove trailing semicolon.
2006-11-15 Werner Koch <wk@g10code.com>
* Makefile.am (INCLUDES): Include ../src/
2006-11-03 Werner Koch <wk@g10code.com>
* random.c [HAVE_GETTIMEOFDAY]: Included sys/time.h and not
sys/times.h. Reported by Rafaël Carré.
2006-11-05 Moritz Schulte <moritz@g10code.com>
* Makefile.am (AM_CFLAGS): Added -I$(top_builddir)/src so that the
new gcrypt.h is used, not the one installed in the system.
2006-10-25 Werner Koch <wk@g10code.com>
* primegen.c (prime_generate_internal): Tweaked use of secure
memory and entropy use. Safe unused primes from the pool. Allocate
at least a pool of 30.
(save_pool_prime, get_pool_prime): New.
2006-10-23 Werner Koch <wk@g10code.com>
* ac.c (_gcry_ac_data_from_sexp): Reset sexp_tmp for failsafe
means. Release sexp_cur if needed. Reported by Dirk Stoecker.
* pubkey.c (pubkeys_registered_lock): Intialized it. It is not
realy needed because this is a mere initialization to 0 anyway.
Noted by Victor Stinner.
2006-10-17 Werner Koch <wk@g10code.com>
* dsa.c (_gcry_dsa_generate2): New.
(generate): New arg QBITS. Add sanity checks for reasonable qbits
and nbits.
* pubkey.c (gcry_pk_genkey): Parse an qbits element.
(pubkey_generate): New arg QBITS. Pass it to the DSA generation.
2006-10-05 Werner Koch <wk@g10code.com>
* md.c (gcry_md_algo_info) <get_asnoid>: Check that the algo is
available.
2006-10-04 David Shaw <dshaw@jabberwocky.com> (wk)
* tiger.c (round): Rename to tiger_round as gcc 4 has a built-in
round function that this conflicts with.
2006-09-11 Werner Koch <wk@g10code.com>
* rndw32.c (slow_gatherer_windowsNT): While adding data use the
size of the diskPerformance and not its address. Has been fixed in
GnuPG more than a year ago. Noted by Lee Fisher.
2006-08-30 Werner Koch <wk@g10code.com>
* pubkey.c (sexp_data_to_mpi): Need to allow "ripemd160" here as
this is the canonical name.
2006-08-29 Hye-Shik Chang <perky@FreeBSD.org> (wk)
* seed.c: New.
2006-08-03 Werner Koch <wk@g10code.com>
* random-daemon.c (_gcry_daemon_initialize_basics): Don't
initialize the socket. Remove arg SOCKETNAME.
(connect_to_socket): Make sure that daemon is set to -1 on error.
(call_daemon): Initialize the socket on the first call.
(_gcry_daemon_randomize, _gcry_daemon_get_random_bytes)
(_gcry_daemon_create_nonce): New arg SOCKETNAME.
* random.c (initialize): Call new daemon initializator.
(get_random_bytes, gcry_randomize, gcry_create_nonce): Pass socket
name to daemon call and reset allow_daemon on failure.
2006-07-26 Werner Koch <wk@g10code.com>
* rmd160.c (_gcry_rmd160_mixblock): Add cast to transform call.
* blowfish.c (selftest): Cast string to usnigned char*.
* primegen.c (prime_generate_internal): Cast unsigned/char*
mismatch in calling m_out_of_n.
(is_prime): Changed COUNT to unsigned int *.
* ac.c (_gcry_ac_data_copy): Initialize DATA_MPIS.
* random.c (gcry_create_nonce): Update the pid after a fork.
Reported by Uoti Urpala.
2006-07-04 Marcus Brinkmann <marcus@g10code.de>
* sha512.c: Fix typo in copyright notice.
2006-06-21 Werner Koch <wk@g10code.com>
* rsa.c (_gcry_rsa_generate): Replace xcalloc by calloc.
* pubkey.c (gcry_pk_encrypt, gcry_pk_sign): Ditto.
(sexp_to_key, sexp_to_sig, sexp_to_enc, gcry_pk_encrypt)
(gcry_pk_sign, gcry_pk_genkey, gcry_pk_get_keygrip): Ditto.
* md.c (md_copy): Ditto.
2006-04-22 Moritz Schulte <moritz@g10code.com>
* random-daemon.c (_gcry_daemon_initialize_basics): New argument:
SOCKETNAME. Passing on to connect_to_socket() if non-NULL.
(connect_to_socket, writen, readn, call_daemon): New functions.
(_gcry_daemon_randomize, _gcry_daemon_get_random_bytes)
(_gcry_daemon_create_nonce): Call call_daemon().
(RANDOM_DAEMON_SOCKET): New symbol.
(daemon_socket): New static variable.
* random.h (_gcry_daemon_initialize_basics): New parameter:
SOCKETNAME.
(_gcry_set_random_daemon_socket): New declaration.
* random.c (initialize_basics): Pass DAEMON_SOCKET_NAME to
_gcry_daemon_initialize_basics.
(_gcry_set_random_daemon_socket): New function, setting
DAEMON_SOCKET_NAME.
2006-04-01 Moritz Schulte <moritz@g10code.com>
* ac.c (eme_pkcs_v1_5_encode): Use KEY_SIZE directly, no need to
call gcry_ac_key_get_nbits.
(eme_pkcs_v1_5_decode): Likewise.
(ac_es_dencode_prepare_pkcs_v1_5): Fill options_em structure with
key_size.
(_gcry_ac_data_dump, gcry_ac_data_dump): New functions.
(_gcry_ac_data_to_sexp, _gcry_ac_data_from_sexp): More or less
rewritten; changed S-Expression format so that it matches the one
used in pubkey.c.
2006-03-15 Werner Koch <wk@g10code.com>
* random-daemon.c: New.
* random.c (_gcry_use_random_daemon): New.
(get_random_bytes, gcry_randomize, gcry_create_nonce): Try
diverting to the daemon functions.
2006-03-14 Werner Koch <wk@g10code.com>
* random.c (lock_seed_file): New.
(read_seed_file, _gcry_update_random_seed_file): Use it.
* random.c (gcry_create_nonce): Detect a fork and re-seed.
(read_pool): Fixed the fork detection; it used to work only for
multi-threaded processes.
2006-03-12 Brad Hards <bradh@frogmouth.net> (wk)
* md.c (md_open): Use new variable macpads_Bsize instead of
hardwiring the block size. Changed at all places.
2006-03-10 Brad Hards <bradh@frogmouth.net> (wk, patch 2005-04-22)
* md.c, sha256.c: Add support for SHA-224.
(sha224_init): New.
2006-01-18 Brad Hards <bradh@frogmouth.net> (wk 2006-03-07)
* cipher.c (cipher_encrypt, cipher_decrypt, do_ofb_encrypt)
(do_ofb_decrypt, gcry_cipher_open): Implement Output Feedback Mode.
2005-11-02 Moritz Schulte <moritz@g10code.com>
* pubkey.c (gcry_pk_algo_name): Return "?" instead of NULL for
unknown algorithm IDs.
* cipher.c (cipher_algo_to_string): Likewise.
2005-11-01 Moritz Schulte <moritz@g10code.com>
* pubkey.c (gcry_pk_algo_info): Don't forget to break after switch
case.
2005-09-19 Werner Koch <wk@g10code.com>
* dsa.c (generate): Add preliminary support for 2 and 4 keys.
Return an error code if the key size is not supported.
(_gcry_dsa_generate): Return an error.
2005-08-22 Werner Koch <wk@g10code.com>
* primegen.c (check_prime): New arg RM_ROUNDS.
(prime_generate_internal): Call it here with 5 rounds as used
before.
(gcry_prime_check): But here with 64 rounds.
(is_prime): Make sure never to use less than 5 rounds.
2005-04-16 Moritz Schulte <moritz@g10code.com>
* ac.c (_gcry_ac_init): New function.
2005-04-12 Moritz Schulte <moritz@g10code.com>
* ac.c (_gcry_ac_io_write, _gcry_ac_io_read): Initialize err to
make the compiler happy.
Always use errno, now that gcry_malloc() is guaranteed to set
errno on failure.
(_gcry_ac_data_to_sexp): Don't forget to goto out after error in
loop.
(_gcry_ac_data_to_sexp): Remove unused variable: mpi_list;
(_gcry_ac_data_to_sexp): Always deallocate sexp_buffer.
(_gcry_ac_data_from_sexp): Don't forget to initialize data_set_new.
(_gcry_ac_data_from_sexp): Handle special case, which is
necessary, since gcry_sexp_nth() does not distinguish between
"element does not exist" and "element is the empty list".
(_gcry_ac_io_init_va): Use assert to make sure that mode and type
are correct.
Use gcry_error_t types where gcry_err_code_t types have been used
before.
2005-04-11 Moritz Schulte <moritz@g10code.com>
* ac.c (_gcry_ac_data_sign_scheme): Don't forget to initialize
buffer.
* whirlpool.c: New file.
* md.c (digest_table): Add whirlpool.
* Makefile.am (EXTRA_libcipher_la_SOURCES): Added: whirlpool.c.
2005-03-30 Moritz Schulte <moritz@g10code.com>
* ac.c (_gcry_ac_data_from_sexp): Use length of SEXP_CUR, not
length of SEXP; do not forget to set SEXP_TMP to NULL after it has
been released.
(struct gcry_ac_mpi): New member: name_provided.
(_gcry_ac_data_set): Rename variable `name_final' to `name_cp';
remove const qualifier; change code to not cast away const
qualifiers; use name_provided member as well.
(_gcry_ac_data_set, _gcry_ac_data_get_name): Use name_provided
member of named mpi structure.
(gcry_ac_name_to_id): Do not forget to initialize err.
(_gcry_ac_data_get_index): Do not forget to initialize mpi_return;
use gcry_free() instead of free(); remove unnecessary cast; rename
mpi_return and name_return to mpi_cp and name_cp; adjust code.
(ac_data_mpi_copy): Do not cast away const qualifier.
(ac_data_values_destroy): Likewise.
(ac_data_construct): Likewise.
(ac_data_mpi_copy): Initialize flags to GCRY_AC_FLAG_DEALLOC.
(ac_data_extract): Use GCRY_AC_FLAG_DEALLOC instead of
GCRY_AC_FLAG_COPY.
(_gcry_ac_io_init_va, _gcry_ac_io_init, gcry_ac_io_init)
(gcry_ac_io_init_va, _gcry_ac_io_write, _gcry_ac_io_read)
(_gcry_ac_io_read_all, _gcry_ac_io_process): New functions.
(gry_ac_em_dencode_t): Use gcry_ac_io_t in prototype instead of
memroy strings directly; adjust encode/decode functions to use io
objects.
(emsa_pkcs_v1_5_encode_data_cb): New function ...
(emsa_pkcs_v1_5_encode): ... use it here.
(ac_data_dencode): Use io objects.
(_gcry_ac_data_encode, _gcry_ac_data_decode, gcry_ac_data_encode)
(gcry_ac_data_decode): Likewise.
(_gcry_ac_data_encrypt_scheme, gcry_ac_data_encrypt_scheme)
(_gcry_ac_data_decrypt_scheme, gcry_ac_data_decrypt_scheme)
(_gcry_ac_data_sign_scheme, gcry_ac_data_sign_scheme)
(_gcry_ac_data_verify_scheme, gcry_ac_data_verify_scheme):
Likewise.
2005-03-23 Werner Koch <wk@g10code.com>
* rndw32.c (_gcry_rndw32_gather_random_fast): While adding data
use the size of the object and not the one of its address. Bug
reported by Sascha Kiefer.
2005-03-19 Moritz Schulte <moritz@g10code.com>
* cipher.c (do_cbc_encrypt): Be careful to not overwrite data,
which is to be used later on. This happend, in case CTS is
enabled and OUTBUF is equal to INBUF.
2005-02-25 Werner Koch <wk@g10code.com>
* pubkey.c (gcry_pk_get_keygrip): Allow for shadowed-private-key.
2005-02-13 Moritz Schulte <moritz@g10code.com>
* serpent.c: Updated from 1.2 branch:
s/u32_t/u32/ and s/byte_t/byte/. Too match what we have always
used and are using in all other files too
(serpent_test): Moved prototype out of a fucntion.
2005-02-07 Moritz Schulte <moritz@g10code.com>
* ac.c: Major parts rewritten.
* pubkey.c (_gcry_pk_get_elements): New function.
2004-12-09 Werner Koch <wk@g10code.com>
* serpent.c (serpent_setkey): Moved prototype of serpent_test to
outer scope.
2004-09-11 Moritz Schulte <moritz@g10code.com>
* pubkey.c (pubkey_table): Added an alias entry for GCRY_PK_ELG_E.
2004-08-23 Moritz Schulte <moritz@g10code.com>
* ac.c: Do not include <assert.h>.
* rndegd.c: Likewise.
* sha1.c: Likewise.
* rndunix.c: Likewise.
* rndlinux.c: Likewise.
* rmd160.c: Likewise.
* md5.c: Likewise.
* md4.c: Likewise.
* cipher.c: Likewise.
* crc.c: Likewise.
* blowfish.c: Likewise.
* pubkey.c (dummy_generate, dummy_check_secret_key)
(dummy_encrypt, dummy_decrypt, dummy_sign, dummy_verify): Return
err code GPG_ERR_NOT_IMPLEMENTED instead of aborting through
log_bug().
(dummy_get_nbits): Return 0 instead of aborting though log_bug().
2004-08-19 Werner Koch <wk@g10code.de>
* pubkey.c (sexp_data_to_mpi): Changed the zero random byte
substituting code to actually do clever things. Thanks to
Matthias Urlichs for noting the implementation problem.
2004-08-09 Moritz Schulte <moritz@g10code.com>
* pubkey.c (gcry_pk_sign): Fixed memory leak; fix provided by
Modestas Vainius.
2004-07-16 Werner Koch <wk@gnupg.org>
* rijndael.c (do_encrypt): Fix alignment problem. Bugs found by
Matthias Urlichs.
(do_decrypt): Ditto.
(keySched, keySched2): Use 2 macros along with unions in the key
schedule context.
2004-07-14 Moritz Schulte <moritz@g10code.com>
* rsa.c (_gcry_rsa_decrypt): Don't forget to free "a". Thanks to
Nikos Mavroyanopoulos.
2004-05-09 Werner Koch <wk@gnupg.org>
* random.c (read_pool): Mix the PID in to better protect after a
fork.
2004-07-04 Moritz Schulte <moritz@g10code.com>
* serpent.c: Use "u32_t" instead of "unsigned long", do not
declare S-Box variables as "register". Fixes failure on
OpenBSD/sparc64, reported by Nikolay Sturm.
2004-05-07 Werner Koch <wk@gnupg.org>
* random.c (initialize): Factored out some code to ..
(initialize_basics): .. new function.
(_gcry_random_initialize): Just call initialize_basics unless the
new arg FULL is set to TRUE.
(_gcry_fast_random_poll): Don't do anything unless the random
system has been really initialized.
2004-05-07 Moritz Schulte <moritz@g10code.de>
* ac.c (gcry_ac_open): Do not dereference NULL pointer. Reported
by Umberto Salsi.
2004-02-20 Werner Koch <wk@gnupg.org>
* primegen.c (check_prime): New args CB_FUNC and CB_ARG; call them
at different stages. Pass these arguments through all callers.
2004-02-06 Werner Koch <wk@gnupg.org>
* des.c: Add a new OID as used by pkcs#12.
* rfc2268.c: New. Taken from libgcrypt.
* cipher.c: Setup the rfc2268 algorithm.
2004-01-25 Moritz Schulte <mo@g10code.com>
* primegen.c (prime_generate_internal): Do not forget to free
`q_factor'; fixed by Brieuc Jeunhomme.
(prime_generate_internal): Do not forget to free `prime'.
2004-01-14 Moritz Schulte <mo@g10code.com>
* ac.c (gcry_ac_data_set): New argument: flags; slightly
rewritten.
(gcry_ac_data_get_name, gcry_ac_data_get_index): Likewise.
(gcry_ac_key_pair_generate): New argument: misc_data; modified
order of arguments.
(gcry_ac_key_test): New argument: handle.
(gcry_ac_key_get_nbits, gcry_ac_key_get_grip): Likewise.
Use GCRY_AC_FLAG_NO_BLINDING instead of
GCRY_AC_DATA_FLAG_NO_BLINDING.
(gcry_ac_mpi): New member: flags.
(gcry_ac_data_search, gcry_ac_data_add): Removed functions.
2003-12-22 Werner Koch <wk@gnupg.org>
* primegen.c (is_prime): Release A2.
2003-12-19 Werner Koch <wk@gnupg.org>
* md.c: Moved a couple of functions down below the data structure
definitions.
(struct gcry_md_context): New field ACTUAL_HANDLE_SIZE.
(md_open): Set it here.
(strcut gcry_md_list): New field ACTUAL_STRUCT_SIZE.
(md_enable): Set it here.
(md_close): Wipe the context memory.
secure memory.
* cipher.c (struct gcry_cipher_handle): New field ACTUAL_HANDLE_SIZE.
(gcry_cipher_open): Set it here.
(gcry_cipher_close): Use it to always wipe out the handle data.
* ac.c (gcry_ac_open): Make sure HANDLE gets initialized even when
the function is not successful.
(gcry_ac_close): Allow a NULL handle.
(gcry_ac_key_destroy, gcry_ac_key_pair_destroy): Ditto.
(gcry_ac_key_get_grip): Return INV_OBJ on error.
* primegen.c (prime_generate_internal): Fixed error code for
failed malloc. Replaced the !err if chain by gotos.
(gcry_prime_group_generator): Remove the extra sanity check.
* md.c: Minor code and comment cleanups.
2003-12-16 Werner Koch <wk@gnupg.org>
* primegen.c (gen_prime): Doc fix. Thanks to Newton Hammet.
2003-12-11 Werner Koch <wk@gnupg.org>
* rndunix.c (slow_poll): Don't use #warning but #error.
* rndegd.c: Changed indentation.
(my_make_filename): Removd the var_arg cruft becuase we
don't need it here. Changed caller.
* rndlinux.c: Changed indentation.
(open_device): Remove the superfluous stat call and clarify
comment.
* rsa.c: Changed indentation.
(secret): Use the standard algorithm if p, q and u are not
available.
(rsa_blind, rsa_unblind): Renamed from _gcry_rsa_blind,
_gcry_rsa_unblind and moved more to the top.
* md4.c: Changed indentation. Removed unnecessary casts.
* md5.c, rmd160.c, sha1.c, tiger.c: Ditto.
* rijndael.c, twofish.c: Ditto.
* serpent.c: Removed unnecessary casts.
* sha256.c, sha512.c: Ditto.
2003-12-09 Werner Koch <wk@gnupg.org>
* dsa.c: Unified indentation style.
* elgamal.c: Ditto.
* des.c (des_key_schedule): Code beautifications.
* blowfish.c: Changed indentation style.
* cast5.c (do_cast_setkey): Ditto.
* pubkey.c (gcry_pk_encrypt): Replaced the chain of if(!err) tests
by straightforward gotos. Other cleanups.
(gcry_pk_decrypt): Ditto.
(gcry_pk_sign): Ditto.
(gcry_pk_verify): Ditto.
(gcry_pk_genkey): Ditto. Use strtoul instead of strtol.
(gcry_pk_ctl): Use GPG_ERR_INV_ARG to indicate bad arguments.
2003-12-07 Werner Koch <wk@gnupg.org>
* pubkey.c (gcry_pk_register_default): Undef the helper macro.
(gcry_pk_map_name): Allow NULL for string.
(sexp_to_key): Use memcpy and not strncpy. Use gcry_free and not
free.
(sexp_to_sig): Ditto.
(sexp_to_enc): Ditto. Replaced the chain of if(!err) tests by
straightforward gotos.
2003-12-05 Werner Koch <wk@gnupg.org>
* cipher.c: Documentation cleanups.
(gcry_cipher_mode_from_oid): Allow NULL for STRING.
2003-12-03 Werner Koch <wk@gnupg.org>
* elgamal.c (sign, do_encrypt, gen_k): Make sure that a small K is
only used for encryption.
2003-11-18 Werner Koch <wk@gnupg.org>
* random.h (rndw32_set_dll_name): Removed unused prototype.
* Makefile.am (EXTRA_DIST): Added Manifest.
2003-11-11 Werner Koch <wk@gnupg.org>
* Manifest: New.
2003-11-04 Werner Koch <wk@gnupg.org>
* md.c (gcry_md_hash_buffer): Use shortcut for SHA1
* sha1.c (_gcry_sha1_hash_buffer): New.
* random.c: Reformatted most functions.
(mix_pool): Moved the failsafe_digest from global
scope to here.
(do_fast_random_poll): Use the generic fucntions even if a fast
gathering function has been used.
(read_pool): Detect a fork and retry.
(gcry_randomize, get_random_bytes): Don't distinguish anymore
between weak and strong random.
(gcry_create_nonce): New.
2003-10-31 Werner Koch <wk@gnupg.org>
* rndw32.c (slow_gatherer_windowsNT): Use a plain buffer for the
disk performance values and not the W32 API structure.
* dsa.c (verify): s/exp/ex/ due to shadowing of a builtin.
* elgamal.c (verify): Ditto.
* ac.c (gcry_ac_data_get_index): s/index/idx/
(gcry_ac_data_copy_internal): Remove the cast in _gcry_malloc.
(gcry_ac_data_add): Must use gcry_realloc instead of realloc.
* pubkey.c (sexp_elements_extract): s/index/idx/ as tribute to the
forehackers.
(gcry_pk_encrypt): Removed shadowed definition of I. Reordered
arguments to malloc for clarity.
(gcry_pk_sign, gcry_pk_genkey): Ditto.
* primegen.c (prime_generate_internal): s/random/randomlevel/.
2003-10-27 Moritz Schulte <mo@g10code.com>
* pubkey.c (gcry_pk_encrypt): Don't forget to deallocate pkey.
2003-10-27 Werner Koch <wk@gnupg.org>
* random.c (gcry_random_add_bytes): Return if buflen is zero to
avoid gcc warning about unsed parameter.
(MASK_LEVEL): Simplified; does now work for signed and unsigned
w/o warnings.
* md.c (md_start_debug): Removed the const from SUFFIX, because
this function is called from the control fucntion which does not
require const.
Prefixed all (pubkey,digest,cipher}_spec_* globale variables with
_gcry_.
* ac.c (ac_key_identifiers): Made static.
* random.c (getfnc_gather_random,getfnc_fast_random_poll): Move
prototypes to ..
* rand-internal.h: .. here
* random.c (getfnc_gather_random): Include rndw32 gatherer.
* rndunix.c, rndw32.c, rndegd.c: Include them here.
* rndlinux.c (_gcry_rndlinux_gather_random): Prepend the _gcry_
prefix. Changed all callers.
* rndegd.c (_gcry_rndegd_gather_random): Likewise.
(_gcry_rndegd_connect_socket): Likewise.
* rndunix.c (_gcry_rndunix_gather_random): Likewise.
(waitpid): Made static.
* rndw32.c: Removed the old and unused winseed.dll cruft.
(_gcry_rndw32_gather_random_fast): Renamed from
gather_random_fast.
(_gcry_rndw32_gather_random): Renamed from gather_random. Note,
that the changes 2003-04-08 somehow got lost.
* sha512.c (sha512_init, sha384_init): Made static.
* cipher.c (do_ctr_decrypt): Removed "return" from this void
function.
2003-10-24 Moritz Schulte <mo@g10code.com>
* serpent.c: Fix an issue on big-endian systems.
* rndw32.c: Removed IS_MODULE -cruft.
* rndlinux.c (rndlinux_gather_random): Likewise.
2003-10-10 Werner Koch <wk@gnupg.org>
* primegen.c (gen_prime): Bail out if NBITS is less than 16.
(prime_generate_internal): Initialize prime variable to suppress
compiler warning. Check pbits, initialize qbits when passed as
zero.
* primegen.c (prime_generate_internal): New arg
ALL_FACTORS. Changed all callers.
(gcry_prime_generate): Make the factors arg optional. Request
all_factors. Make sure PRIME is set to NULL even on error.
(gcry_prime_group_generator): New.
(gcry_prime_release_factors): New.
2003-10-06 Werner Koch <wk@gnupg.org>
* primegen.c (gen_prime): Assert that NBITS is never zero, it
would cause a segv.
2003-09-28 Moritz Schulte <mo@g10code.com>
* ac.c: Include "cipher.h".
2003-09-27 Moritz Schulte <mo@g10code.com>
* rndegd.c (do_read): Return nread instead of nbytes; thanks to
Michael Caerwyn.
2003-09-04 Werner Koch <wk@gnupg.org>
* pubkey.c (_gcry_pk_aliased_algo_name): New.
* ac.c (gcry_ac_open): Use it here.
* Makefile.am (EXTRA_libcipher_la_SOURCES): Add serpent.c
2003-09-02 Moritz Schulte <mo@g10code.com>
* primegen.c (gcry_prime_check, gcry_prime_generate): New
functions.
(prime_generate_internal): New function, based on
_gcry_generate_elg_prime.
(_gcry_generate_elg_prime): Rewritten as a wrapper for
prime_generate_internal.
2003-08-28 Werner Koch <wk@gnupg.org>
* pubkey.c (gcry_pk_encrypt): Don't include the flags list in the
return value. This does not make sense and breaks any programs
parsing the output strictly (e.g. current gpgsm).
(gcry_pk_encrypt): If aliases for the algorithm name exists, take
the first one instead of the regular name to adhere to SPKI
conventions.
(gcry_pk_genkey): Ditto.
(gcry_pk_sign): Ditto. Removed unused KEY_ALGO_NAME.
2003-08-19 Moritz Schulte <mo@g10code.com>
* cipher.c: Add support for Serpent
* serpent.c: New file.
2003-08-10 Moritz Schulte <moritz@g10code.com>
* rsa.c (_gcry_rsa_blind, _gcry_rsa_unblind): Declare static.
2003-08-09 Timo Schulz <twoaday@freakmail.de>
* random.c (getfnc_gather_random): Don't check NAME_OF_DEV_RANDOM
two times, but also the NAME_OF_DEV_URANDOM device.
2003-08-08 Moritz Schulte <moritz@g10code.com>
* pubkey.c (sexp_to_enc): Fixed extraction of S-Expression: do not
fail if no `flags' sub S-Expression is found.
2003-07-27 Werner Koch <wk@gnupg.org>
* md.c (gcry_md_lookup_func_oid): Allow for empty OID lists.
2003-07-23 Moritz Schulte <moritz@g10code.com>
* ac.c (gcry_ac_data_construct): New argument: include_flags, only
include `flags' S-expression, if include_flags is true. Adjust
callers. Thanks for triggering a bug caused by `flags'
sub-S-expression where they are not expected to Ralf Schneider.
2003-07-21 Moritz Schulte <moritz@g10code.com>
* pubkey.c (gcry_pk_lookup_func_name): Use new member name
`aliases' instead of `sexp_names'.
* ac.c (gcry_ac_key_data_get): New function.
* cipher.c (gcry_cipher_lookup_func_name): Fix return value.
2003-07-20 Moritz Schulte <moritz@g10code.com>
* blowfish.c: Adjusted for new gcry_cipher_spec_t structure.
* cast5.c: Likewise.
* twofish.c: Likewise.
* arcfour.c: Likewise.
* rijndael.c (rijndael_oids, rijndael192_oids, rijndael256_oids):
New variables, adjust for new gcry_cipher_spec_t structure.
* des.c (oids_tripledes): New variable, adjust for new
gcry_cipher_spec_t structure.
* md.c (oid_table): Removed.
* tiger.c (oid_spec_tiger): New variable.
(digest_spec_tiger): Adjusted for new gry_md_spec_t structure.
* sha512.c (oid_spec_sha512): New variable.
(digest_spec_sha512): Adjusted for new gry_md_spec_t structure.
* sha512.c (oid_spec_sha384): New variable.
(digest_spec_sha384): Adjusted for new gry_md_spec_t structure.
* sha256.c (oid_spec_sha256): New variable.
(digest_spec_sha256): Adjusted for new gry_md_spec_t structure.
* sha1.c (oid_spec_sha1): New variable.
(digest_spec_sha1): Adjusted for new gry_md_spec_t structure.
* rmd160.c (oid_spec_rmd160): New variable.
(digest_spec_rnd160): Adjusted for new gry_md_spec_t structure.
* md5.c (oid_spec_md5): New variable.
(digest_spec_md5): Adjusted for new gry_md_spec_t structure.
* md4.c (oid_spec_md4): New variable.
(digest_spec_md4): Adjusted for new gry_md_spec_t structure.
* crc.c (digest_spec_crc32, digest_spec_crc32_rfc1510,
digest_spec_crc32_rfc2440): Adjusted for new gry_md_spec_t
structure.
2003-07-19 Moritz Schulte <moritz@g10code.com>
* md.c (gcry_md_lookup_func_oid): New function.
(search_oid): New function, copied from cipher.c.
(gcry_md_map_name): Adjust for new search_oid_interface.
* cipher.c (oid_table): Removed table.
(gcry_cipher_lookup_func_oid): New function.
(search_oid): Rewritten to use the module functions.
(gcry_cipher_map_name): Adjust for new search_oid interface.
(gcry_cipher_mode_from_oid): Likewise.
2003-07-18 Werner Koch <wk@gnupg.org>
* md.c (gcry_md_hash_buffer): Convert ERR to gpg_error_t in
gpg_strerror.
2003-07-14 Moritz Schulte <moritz@g10code.com>
* cipher.c (gcry_cipher_lookup_func_name): Also check the cipher
name aliases, not just the primary name.
(gcry_cipher_map_name): Remove kludge for aliasing Rijndael to
AES.
* arcfour.c, blowfish.c, cast5.c, des.c, twofish.c: Adjust cipher
specification structures.
* rijndael.c (rijndael_names, rijndael192_names,
rijndael256_names): New variables, use them in the cipher
specifications.
* rmd160test.c: Removed file.
* ac.c, arcfour.c, blowfish.c, cast5.c, cipher.c, des.c, dsa.c,
elgamal.c, md.c, pubkey.c, random.c, rijndael.c, rsa.c, twofish.c:
Used gcry_err* wrappers for libgpg symbols.
* primegen.c (gen_prime): Correct the order arguments to
extra_check.
2003-07-12 Moritz Schulte <moritz@g10code.com>
* ac.c: Replaced all public occurences of gpg_error_t with
gcry_error_t.
* cipher.c: Likewise.
* md.c: Likewise.
* pubkey.c: Likewise.
* random.c: Likewise.
* cipher.c: Added support for TWOFISH128.
2003-07-08 Moritz Schulte <moritz@g10code.com>
* ac.c (gcry_ac_data_copy_internal): New function, based on
gcry_ac_data_copy.
(gcry_ac_data_copy): Made public, use gcry_ac_data_copy_internal.
(gcry_ac_key_init): Use gcry_ac_data_copy_internal.
2003-07-07 Moritz Schulte <moritz@g10code.com>
* ac.c (gcry_ac_data_set): Only release old MPI value if it is
different from the new value. Bug reported by Simon Josefsson
<jas@extundo.com>.
* pubkey.c (gcry_pk_list): New function.
* md.c (gcry_md_list): New function.
* ac.c (gcry_ac_key_pair_generate): Fix calculation of format
string size.
2003-07-05 Moritz Schulte <moritz@g10code.com>
* md.c: Named struct of digest_table `digest_table_entry'.
(digest_table_entry): New member: algorithm; filled in.
(digest_table_entry): Removed unused member: flags.
(gcry_md_register): New argument: algorithm_id, filled in.
(gcry_md_register_default): Used algorithm ID from module
structure.
(gcry_md_map_name): Likewise.
(md_enable): Likewise.
(md_read): Likewise.
(gcry_md_info): Likewise.
* pubkey.c: Named truct for pubkey_table `pubkey_table_entry'.
(pubkey_table_entry): New member: algorithm; filled in.
(gcry_pk_register_default): Used algorithm ID from pubkey_table.
(gcry_pk_register): New argument: algorithm_id, filled in.
(gcry_pk_map_name): Used algorithm ID from module structure.
(gcry_pk_decrypt): Likewise.
(gcry_pk_encrypt): Likewise.
(gcry_pk_verify): Likewise.
(gcry_pk_sign): Likewise.
(gcry_pk_testkey): Likewise.
(gcry_pk_genkey): Likewise.
(gcry_pk_get_nbits): Likewise.
(sexp_to_key): Removed unused variable: algo.
(sexp_to_sig): Likewise.
* cipher.c: Named struct for cipher_table `cipher_table_entry'.
(cipher_table_entry): New member: algorithm; filled in.
(gcry_cipher_register_default): Used algorithm ID from
cipher_table.
(gcry_cipher_register): New argument: algorithm_id, filled in.
(gcry_cipher_map_name): Used algorithm ID from module structure.
* arcfour.c (cipher_spec_arcfour): Removed algorithm ID.
* blowfish.c (cipher_spec_blowfish): Likewise.
* cast5.c (cipher_spec_cast5): Likewise.
* crc.c (digest_spec_crc32): Likewise.
* crc.c (digest_spec_crc32_rfc1510): Likewise.
* crc.c (digest_spec_crc32_rfc2440): Likewise.
* des.c (cipher_spec_des): Likewise.
* des.c (cipher_spec_tripledes): Likewise.
* dsa.c (pubkey_spec_dsa): Likewise.
* elgamal.c (pubkey_spec_elg): Likewise.
* md4.c (digest_spec_md4): Likewise.
* md5.c (digest_spec_md5): Likewise.
* aes.c (cipher_spec_aes): Likewise.
* aes.c (cipher_spec_aes192): Likewise.
* aes.c (cipher_spec_aes256): Likewise.
* rsa.c (pubkey_spec_rsa): Likewise.
* sha1.c (digest_spec_sha1): Likewise.
* sha256.c (digest_spec_sha256): Likewise.
* sha512.c (digest_spec_sha512): Likewise.
* tiger.c (digest_spec_tiger): Likewise.
* twofish.c (cipher_spec_twofish): Likewise.
* twofish.c (cipher_spec_twofish128): Likewise.
* Makefile.am (EXTRA_libcipher_la_SOURCES): Fix list of source
files; reported by Simon Josefsson <jas@extundo.com>.
* pubkey.c: Replaced all occurences of `id' with `algorithm',
since `id' is a keyword in obj-c.
* md.c: Likewise.
* cipher.c: Likewise.
* crc.c, md4.c, md5.c, rmd160.c, sha1.c, sha256.c, tiger.c:
Replaced all occurences of gcry_digest_spec_t with gcry_md_spec_t.
* dsa.c, rsa.c, elgamal.c: Replaced all occurencens of
gcry_pubkey_spec_t with gcry_pk_spec_t.
* md.c: Replaced all occurences of gcry_digest_spec_t with
gcry_md_spec_t.
(gcry_digest_register_default): Renamed to ...
(gcry_md_register_default): ... this; adjusted callers.
(gcry_digest_lookup_func_name): Renamed to ...
(gcry_md_lookup_func_name): ... this; adjusted callers.
(gcry_digest_lookup_name): Renamed to ...
(gcry_md_lookup_name): ... this; adjusted callers.
(gcry_digest_register): Renamed to ...
(gcry_md_register): ... this.
(gcry_digest_unregister): Renamed to ...
(gcry_md_unregister): ... this.
* pubkey.c (gcry_pubkey_register): Renamed to ...
(gcry_pk_register): ... this.
(gcry_pubkey_unregister): Renamed to ...
(gcry_pk_unregister): ... this.
Replaced all occurences of gcry_pubkey_spec_t with gcry_pk_spec_t.
(gcry_pubkey_register_default): Renamed to ...
(gcry_pk_register_default): ... this; adjusted callers.
(gcry_pubkey_lookup_func_name): Renamed to ...
(gcry_pk_lookup_func_name): ... this; adjusted callers.
(gcry_pubkey_lookup_name): Renamed to ...
(gcry_pk_lookup_name): ... this; adjusted callers.
* md.c (gcry_md_hash_buffer): Fix error checking. Thanks to Simon
Josefsson <jas@extunde.com>.
2003-07-04 Moritz Schulte <moritz@g10code.com>
* cipher.c (gcry_cipher_list): New function.
2003-07-01 Moritz Schulte <moritz@g10code.com>
* pubkey.c (sexp_to_sig): Accept a `flags' S-expression to be more
consistent with sexp_to_enc.
2003-06-30 Moritz Schulte <moritz@g10code.com>
* Makefile.am (libcipher_la_SOURCES): Added: ac.c.
* pubkey.c (_gcry_pk_module_lookup): New function.
(_gcry_pk_module_release): New function.
2003-06-29 Moritz Schulte <moritz@g10code.com>
* ac.c: New file.
2003-06-26 Werner Koch <wk@gnupg.org>
* md.c (gcry_md_hash_buffer): Trigger BUG correcly with new API.
2003-06-19 Werner Koch <wk@gnupg.org>
* md.c (gcry_md_is_enabled): Fixed.
2003-06-18 Werner Koch <wk@gnupg.org>
* cipher.c (gcry_cipher_get_algo_keylen): New.
(gcry_cipher_get_algo_blklen): New.
2003-06-18 Moritz Schulte <moritz@g10code.com>
* arcfour.c, cipher.c, blowfish.c, md.c, cast5.c, pubkey.c, crc.c,
des.c, dsa.c, elgamal.c, md4.c, md5.c, random.c, rijndael.c,
rmd160.c, rsa.c, sha1.c, sha256.c, sha512.c, tiger.c, twofish.c:
Replaced older types GcryDigestSpec, GcryCipherSpec and
GcryPubkeySpec with newer types: gcry_digest_spec_t,
gcry_cipher_spec_t and gcry_pubkey_spec_t.
* md.c (gcry_digest_id_new): Removed function.
(gcry_digest_register): Removed code for generating a new module
ID.
* pubkey.c (gcry_pubkey_id_new): Removed function.
(gcry_pubkey_register): Removed code for generating a new module
ID.
* cipher.c, md.c, pubkey.c: Replace old type GcryModule with newer
one: gcry_module_t.
(gcry_cipher_id_new): Removed function.
(gcry_cipher_register): Removed code for generating a new module
ID.
* cipher.c (gcry_cipher_register): Adjust call to
_gcry_module_add.
(gcry_cipher_register_default): Likewise.
* pubkey.c (gcry_pubkey_register_default): Likewise.
(gcry_pubkey_register): Likewise.
* md.c (gcry_digest_register_default): Likewise.
(gcry_digest_register): Likewise.
* md.c (gcry_digest_lookup_func_id): Removed function.
(gcry_digest_lookup_id): Likewise.
(gcry_digest_id_new): Use _gcry_module_lookup_id instead of
gcry_digest_lookup_id.
(digest_algo_to_string): Likewise.
(check_digest_algo): Likewise.
(md_enable): Likewise.
(md_digest_length): Likewise.
(md_asn_oid): Likewise.
* pubkey.c (gcry_pubkey_lookup_id): Removed function.
(gcry_pubkey_lookup_func_id): Likewise.
(gcry_pubkey_id_new): Use _gcry_module_lookup_id instead of
gcry_pubkey_id_new.
(gcry_pk_algo_name): Likewise.
(disable_pubkey_algo): Likewise.
(check_pubkey_algo): Likewise.
(pubkey_get_npkey): Likewise.
(pubkey_get_nskey): Likewise.
(pubkey_get_nsig): Likewise.
(pubkey_get_nenc): Likewise.
(pubkey_generate): Likewise.
(pubkey_check_secret_key): Likewise.
(pubkey_encrypt): Likewise.
(pubkey_decrypt): Likewise.
(pubkey_sign): Likewise.
(pubkey_verify): Likewise.
(gcry_pk_algo_info): Likewise.
* cipher.c (gcry_cipher_lookup_func_id): Removed function.
(gcry_cipher_lookup_id): Likewise.
(cipher_algo_to_string): use _gcry_module_lookup_id instead of
gcry_cipher_lookup_id.
(disable_cipher_algo): Likewise.
(check_cipher_algo): Likewise.
(cipher_get_blocksize): Likewise.
(gcry_cipher_open): Likewise.
(gcry_cipher_id_new): Likewise.
2003-06-17 Moritz Schulte <moritz@g10code.com>
* Makefile.am (GCRYPT_MODULES): Set to @GCRYPT_CIPHERS@,
@GCRYPT_PUBKEY_CIPHERS@, @GCRYPT_DIGESTS@ and @GCRYPT_RANDOM@.
(libcipher_la_DEPENDENCIES): Set to $(GCRYPT_MODULES).
(libcipher_la_LIBADD): Likewise.
(AM_CFLAGS): Added: @GPG_ERROR_CFLAGS@.
(EXTRA_libcipher_la_SOURCES): Added all conditional sources.
* md.c (md_open): Use _gcry_fast_random_poll instead of
fast_random_poll.
* cipher.c (gcry_cipher_open): Likewise.
* random.h (fast_random_poll): Removed macro.
* blowfish.c, md4.c, md5.c, rmd160.c, sha1.c, sha256.c, sha512.c,
tiger.c: Use Autoconf's WORDS_BIGENDIAN instead of our own
BIG_ENDIAN_HOST.
2003-06-16 Moritz Schulte <moritz@g10code.com>
* random.c (getfnc_gather_random): Do not special-case
USE_ALL_RANDOM_MODULES, make it the default.
* dsa.c: Replace last occurences of old type names with newer
names (i.e. replace MPI with gcry_mpi_t).
* elgamal.c: Likewise.
* primegen.c: Likewise.
* pubkey.c: Likewise.
* rsa.c: Likewise.
2003-06-14 Moritz Schulte <moritz@g10code.com>
* des.c (des_setkey): Add selftest check.
(tripledes_set3keys): Likewise.
(do_tripledes_setkey): Remove selftest check.
(do_des_setkey): Likewise.
2003-06-11 Moritz Schulte <moritz@g10code.com>
* md.c (_gcry_md_init): New function.
* cipher.c (_gcry_cipher_init): New function.
* pubkey.c (_gcry_pk_init): New function.
2003-06-13 Werner Koch <wk@gnupg.org>
* md.c (gcry_md_get_algo): Reverted to old API. This is a
convenience function anyway and error checking is not approriate.
(gcry_md_is_secure): New.
(gcry_md_is_enabled): New.
2003-06-12 Werner Koch <wk@gnupg.org>
* cipher.c (gcry_cipher_open): Make sure HANDLE is set to NULL on
error.
2003-06-11 Werner Koch <wk@gnupg.org>
* md.c (gcry_md_open): Make sure H receives either NULL or an
valid handle.
(gcry_md_copy): Swapped arguments so that it is more in lione with
md_open and most other API fucntions like memcpy (destination
comes first). Make sure HANDLE is set to NULL on error.
* rijndael.c (do_encrypt): Hack to force correct alignment. It
seems not to be not sufficient, though. We should rework this
fucntions and remove all these ugly casts. Let the compiler
optimize or have an assembler implementation.
2003-06-09 Moritz Schulte <moritz@g10code.com>
* Makefile.am: Removed rules serpent, since that is not commited
yet.
2003-06-08 Moritz Schulte <moritz@g10code.com>
* pubkey.c (gcry_pk_encrypt): Improve calculation for size of the
format string.
2003-06-07 Moritz Schulte <moritz@g10code.com>
* arcfour.c, bithelp.h, blowfish.c, cast5.c, cipher.c, crc.c,
des.c, dsa.c, elgamal.c, md4.c, md5.c, md.c, primegen.c, pubkey.c,
rand-internal.h, random.c, random.h, rijndael.c, rmd160.c,
rmd160test.c, rmd.h, rndeged.c, rndlinux.c, rndunix.c, rndw32.c,
rsa.c, sha1.c, sha256.c, sha512.c, tiger.c, twofish.c: Edited all
preprocessor instructions to remove whitespace before the '#'.
This is not required by C89, but there are some compilers out
there that don't like it. Replaced any occurence of the now
deprecated type names with the new ones.
2003-06-04 Moritz Schulte <moritz@g10code.com>
* pubkey.c (gcry_pk_encrypt): Construct an arg_list and use
gcry_sexp_build_array instead of gcry_sexp_build.
(gcry_pk_sign): Likewise.
(gcry_pk_genkey): Likewise.
2003-06-01 Moritz Schulte <moritz@g10code.com>
* dsa.c (_gcry_dsa_generate): Do not check wether the algorithm ID
does indeed belong to DSA.
(_gcry_dsa_sign): Likewise.
(_gcry_dsa_verify): Likewise.
(_gcry_dsa_get_nbits): Likewise.
* elgamal.c (_gcry_elg_check_secret_key): Do not check wether the
algorithm ID does indeed belong to ElGamal.
(_gcry_elg_encrypt): Likewise.
(_gcry_elg_decrypt): Likewise.
(_gcry_elg_sign): Likewise.
(_gcry_elg_verify): Likewise.
(_gcry_elg_get_nbits): Likewise.
(_gcry_elg_generate): Likewise.
* rsa.c (_gcry_rsa_generate): Do not check wether the algorithm ID
does indeed belong to RSA.
(_gcry_rsa_encrypt): Likewise.
(_gcry_rsa_decrypt): Likewise.
(_gcry_rsa_sign): Likewise.
(_gcry_rsa_verify): Likewise.
(_gcry_rsa_get_nbits): Likewise.
2003-05-30 Moritz Schulte <moritz@g10code.com>
* md.c (md_get_algo): Return zero in case to algorithm is enabled.
* md.c (gcry_md_info): Adjusted for new no-errno-API.
(md_final): Likewise.
(gcry_md_get_algo): Likewise.
* pubkey.c (gcry_pk_get_keygrip): Likewise.
(gcry_pk_ctl): Likewise.
(gcry_pk_algo_info): Likewise.
* des.c (selftest): Likewise.
2003-05-29 Moritz Schulte <moritz@g10code.com>
* md.c (md_enable): Do not forget to release module on error.
(gcry_md_open): Adjusted for new no-errno-API.
(md_open): Likewise.
(md_copy): Likewise.
(gcry_md_copy): Likewise.
(gcry_md_setkey): Likewise.
(gcry_md_algo_info): Likewise.
* cipher.c (gcry_cipher_open): Adjusted for new no-errno-API and
also fixed a locking bug.
(gcry_cipher_encrypt): Adjusted for new no-errno-API.
(gcry_cipher_decrypt): Likewise.
(gcry_cipher_ctl): Likewise.
(gcry_cipher_info): Likewise.
(gcry_cipher_algo_info): Likewise.
2003-05-28 Moritz Schulte <moritz@g10code.com>
* md.c (md_enable): Adjusted for libgpg-error.
(gcry_md_enable): Likewise.
(gcry_digest_register_default): Likewise.
(gcry_digest_register): Likewise.
(check_digest_algo): Likewise.
(prepare_macpads): Likewise.
(gcry_md_setkey): Likewise.
(gcry_md_ctl): Likewise.
(gcry_md_get): Likewise.
(gcry_md_algo_info): Likewise.
(gcry_md_info): Likewise.
* dsa.c (_gcry_dsa_generate): Likewise.
(_gcry_dsa_check_secret_key): Likewise.
(_gcry_dsa_sign): Likewie.
(_gcry_dsa_verify): Likewise.
* twofish.c (do_twofish_setkey): Likewise.
(twofish_setkey): Likewise.
* cipher.c (gcry_cipher_register): Likewise.
2003-05-25 Moritz Schulte <moritz@g10code.com>
* rijndael.c (do_setkey): Adjusted for libgpg-error.
(rijndael_setkey): Likewise.
* random.c (gcry_random_add_bytes): Likewise.
* elgamal.c (_gcry_elg_generate): Likewise.
(_gcry_elg_check_secret_key): Likewise.
(_gcry_elg_encrypt): Likewise.
(_gcry_elg_decrypt): Likewise.
(_gcry_elg_sign): Likewise.
(_gcry_elg_verify): Likewise.
* rsa.c (_gcry_rsa_generate): Likewise.
(_gcry_rsa_check_secret_key): Likewise.
(_gcry_rsa_encrypt): Likewise.
(_gcry_rsa_decrypt): Likewise.
(_gcry_rsa_sign): Likewise.
(_gcry_rsa_verify): Likewise.
* pubkey.c (dummy_generate, dummy_check_secret_key, dummy_encrypt,
dummy_decrypt, dummy_sign, dummy_verify): Likewise.
(gcry_pubkey_register): Likewise.
(check_pubkey_algo): Likewise.
(pubkey_generate): Likewise.
(pubkey_check_secret_key): Likewise.
(pubkey_encrypt): Likewise.
(pubkey_decrypt): Likewise.
(pubkey_sign): Likewise.
(pubkey_verify): Likewise.
(sexp_elements_extract): Likewise.
(sexp_to_key): Likewise.
(sexp_to_sig): Likewise.
(sexp_to_enc): Likewise.
(sexp_data_to_mpi): Likewise.
(gcry_pk_encrypt): Likewise.
(gcry_pk_decrypt): Likewise.
(gcry_pk_sign): Likewise.
(gcry_pk_verify): Likewise.
(gcry_pk_testkey): Likewise.
(gcry_pk_genkey): Likewise.
(gcry_pk_ctl): Likewise.
* cipher.c (dummy_setkey): Likewise.
(check_cipher_algo): Likewise.
(gcry_cipher_open): Likewise.
(cipher_setkey): Likewise.
(gcry_cipher_ctl): Likewise.
(cipher_encrypt): Likewise.
(gcry_cipher_encrypt): Likewise.
(cipher_decrypt): Likewise.
(gcry_cipher_decrypt): Likewise.
(gcry_cipher_info): Likewise.
(gcry_cipher_algo_info): Likewise.
* cast5.c (cast_setkey): Likewise.
(do_cast_setkey): Likewise.
* arcfour.c (arcfour_setkey): Likewise.
(do_arcfour_setkey): Likewise.
* blowfish.c (do_bf_setkey): Likewise.
(bf_setkey): Likewise.
* des.c (do_des_setkey): Likewise.
(do_tripledes_setkey): Likewise.
2003-05-22 Moritz Schulte <moritz@g10code.com>
* tiger.c: Merged code ussing the U64_C macro from GnuPG.
* sha512.c: Likewise.
2003-05-17 Moritz Schulte <moritz@g10code.com>
* pubkey.c (gcry_pk_genkey): Fix type: acquire a lock, instead of
releasing it.
2003-05-11 Moritz Schulte <moritz@g10code.com>
* pubkey.c (gcry_pk_testkey): Call REGISTER_DEFAULT_CIPHERS.
(gcry_pk_ctl): Likewise.
2003-04-27 Moritz Schulte <moritz@g10code.com>
* pubkey.c (gcry_pk_genkey): Release sexp after extracted data has
been used.
* md.c (gcry_md_get_algo_dlen): Simplified, simply call
md_digest_length to do the job.
* des.c (do_des_setkey): Check for selftest failure not only
during initialization.
(do_tripledes_setkey): Include check for selftest failure.
* pubkey.c (gcry_pubkey_register_default): New macro
`pubkey_use_dummy', use it.
* elgamal.c (elg_names): New variable.
(pubkey_spec_elg): Include elg_names.
* dsa.c (dsa_names): New variable.
(pubkey_spec_dsa): Include dsa_names.
* rsa.c (rsa_names): New variable.
(pubkey_spec_rsa): Include rsa_names.
* pubkey.c (gcry_pubkey_lookup_func_name): Compare name also with
the names listed in `sexp_names'.
2003-04-24 Moritz Schulte <moritz@g10code.com>
* pubkey.c (sexp_to_key): New variables: module, pubkey. Adjusted
to new module interface.
(sexp_to_key): Changend type of argument `retalgo' from `int *' to
`GcryModule **'. Adjusted all callers. Removed argument:
r_algotblidx.
(sexp_to_sig): Changend type of argument `retalgo' from `int *' to
`GcryModule **'. Adjusted all callers.
(sexp_to_enc): Likewise.
(pubkey_get_npkey, pubkey_get_nskey, pubkey_get_nsig,
pubkey_get_nenc): Use strlen to find out the number.
* rsa.c: Adjust pubkey_spec_rsa to new internal interface.
* dsa.c: Likewise.
* elgamal.c: Likewise.
2003-04-17 Moritz Schulte <moritz@g10code.com>
* pubkey.c (sexp_elements_extract): New function.
* pubkey.c (sexp_to_key): Removed variable `idx', added `err', use
sexp_elements_extract.
(sexp_to_sig): Likewise.
(sexp_to_enc): Likewise.
* pubkey.c: Terminate list correctly.
* md.c: Include sha512/sha384 in digest_table.
2003-04-16 Moritz Schulte <moritz@g10code.com>
* Makefile.am: Include support for sha512.c.
* sha512.c: New file, merged from GnuPG, with few modifications
for libgcrypt.
* rand-internal.h: Removed declarations for constructor functions.
* md.c (md_copy): Call _gcry_module_use for incrementing the usage
counter of the digest modules.
* rsa.c: Do not include "rsa.h".
* dsa.c: Do not include "dsa.h".
* elgamal.c: Do not include "elgamal.h".
* des.c: Do not include "des.h".
* cast5.c: Do not include "cast5.h".
* blowfish.c: Do not include "blowfish.h".
* arcfour.c: Do not include "arcfour.h".
* Makefile.am (libcipher_la_DEPENDENCIES): Removed.
(libcipher_la_LIBADD): Removed.
Use Automake conditionals for conditional compilation.
2003-04-13 Moritz Schulte <moritz@g10code.com>
* cipher.c (gcry_cipher_open): Call REGISTER_DEFAULT_CIPHERS.
* md.c (gcry_md_list): New member: module.
(md_enable): New variable: module, changed use of module and
digest.
(md_enable): Initialize member: module.
(md_close): Call _gcry_module_release.
* cipher.c (gcry_cipher_open): New variable: module, changed use of
module and cipher.
(struct gcry_cipher_handle): New member: module.
(gcry_cipher_open): Initialize member: module.
(gcry_cipher_close): Call _gcry_module_release.
2003-04-09 Moritz Schulte <moritz@g10code.com>
* cipher.c: Include "ath.h".
* md.c: Likewise.
* pubkey.c: Likewise.
* cipher.c (ciphers_registered_lock): New variable.
* md.c (digests_registered_lock): New variable.
* pubkey.c (pubkeys_registered_lock): New variable.
* rndlinux.c (gnupgext_version, func_table): Removed definitions.
(gnupgext_enum_func): Removed function.
(_gcry_rndlinux_constructor): Removed function.
* rndegd.c (gnupgext_version, func_table): Removed definitions.
(gnupgext_enum_func): Removed function.
(_gcry_rndegd_constructor): Removed function.
* rndunix.c (gnupgext_version, func_table): Removed definitions.
(gnupgext_enum_func): Removed function.
(_gcry_rndunix_constructor): Removed function.
* rndw32.c (gnupgext_version, func_table): Removed definitions.
(gnupgext_enum_func): Removed function.
(_gcry_rndw32_constructor): Removed function.
* rndegd.c (rndegd_connect_socket): Simplify code for creating the
egd socket address.
(rndegd_connect_socket): Call log_fatal use instead of
g10_log_fatal.
(egd_gather_random): Renamed to ...
(rndegd_gather_random): ... here.
2003-04-08 Moritz Schulte <moritz@g10code.com>
* rndlinux.c: Do not include "dynload.h".
* rndunix.c: Likewise.
* rndw32.c: Likewise.
* rndegd.c (rndegd_connect_socket): Factored out from ...
(egd_gather_random): here; call it.
(egd_socket): New variable.
(egd_gather_random): Initialize fd with egd_socket, do not declare
fd static.
(do_read): Merged few changes from GnuPG. FIXME - not finished?
Do not include "dynload.h".
* rndw32.c (gather_random): Renamed to rndw32_gather_random, do
not declare static.
(gather_random_fast): Renamed to rndw32_gather_random_fast, do not
declare static.
* rndunix.c (gather_random): Renamed to rndunix_gather_random, do
not declare static.
* rndegd.c (gather_random): Renamed to rndegd_gather_random, do
not declare static.
* rndlinux.c (gather_random): Renamed to rndlinux_gather_random,
do not declare static.
2003-04-07 Moritz Schulte <moritz@g10code.com>
* Makefile.am (libcipher_la_SOURCES): Removed construct.c.
(libcipher_la_SOURCES): Added sha1.c, sha256.c, rmd160.c, md4.c,
md5.c, tiger.c and crc.c
(EXTRA_PROGRAMS): Removed sha1, sha256, rmd160, md4, md5, tiger
and crc. Removed definitions: EXTRA_md4_SOURCES,
EXTRA_md5_SOURCES, EXTRA_rmd160_SOURCES, EXTRA_sha1_SOURCES,
EXTRA_sha256_SOURCES, EXTRA_tiger_SOURCES and EXTRA_crc_SOURCES,
BUILT_SOURCES, DISTCLEANFILES.
* pubkey.c: Do not include "elgamal.h", "dsa.h" and "rsa.h".
* Makefile.am (libcipher_la_SOURCES): Removed rsa.h, elgamal.h,
dsa.h, des.h, cast5.h, arcfour.h and blowfish.h.
* rsa.h: Removed file.
* elgamal.h: Removed file.
* dsa.h: Removed file.
* des.h: Removed file.
* cast5.h: Removed file.
* arcfour.h: Removed file.
* blowfish.h: Removed file.
* Makefile.am (libcipher_la_SOURCES): Removed dynload.c and
dynload.h.
* rsa.c (pubkey_spec_rsa): New variable.
* dsa.c (pubkey_spec_rsa): New variable.
* elgamal.c (pubkey_spec_elg): New variable.
* rsa.c (_gcry_rsa_get_info): Removed function.
* elgamal.c (_gcry_elg_get_info): Removed function.
* dsa.c (_gcry_dsa_get_info): Removed function.
* tiger.c (tiger_get_info): Removed function.
(gnupgext_version, func_table): Removed definitions.
(gnupgext_enum_func): Removed function.
(_gcry_tiger_constructor): Removed function.
* sha1.c (sha1_get_info): Removed function.
(gnupgext_version, func_table): Removed definitions.
(gnupgext_enum_func): Removed function.
(_gcry_sha1_constructor): Removed function.
* sha256.c (sha256_get_info): Removed function.
(gnupgext_version, func_table): Removed definitions.
(gnupgext_enum_func): Removed function.
(_gcry_sha256_constructor): Removed function.
* rmd160.c (rmd160_get_info): Removed function.
(gnupgext_version, func_table): Removed definitions.
(gnupgext_enum_func): Removed function.
(_gcry_rmd160_constructor): Removed function.
* md5.c (md5_get_info): Removed function.
(gnupgext_version, func_table): Removed definitions.
(gnupgext_enum_func): Removed function.
(_gcry_md5_constructor): Removed function.
* md4.c (md4_get_info): Removed function.
(gnupgext_version, func_table): Removed definitions.
(gnupgext_enum_func): Removed function.
(_gcry_md4_constructor): Removed function.
* crc.c (crc_get_info): Removed function.
* arcfour.c (do_arcfour_setkey): Changed type of context argument
to `void *', added local variable for cast, adjusted callers.
(arcfour_setkey): Likewise.
(encrypt_stream): Likewise.
* cast5.c (cast_setkey): Likewise.
(encrypt_block): Likewise.
* rijndael.c (rijndael_setkey): Likewise.
(rijndael_encrypt): Likewise.
(rijndael_decrypt): Likewise.
* twofish.c (twofish_setkey): Likewise.
(twofish_encrypt): Likewise.
(twofish_decrypt): Likewise.
* des.c (do_des_setkey): Likewise.
(do_des_encrypt): Likewise.
(do_des_encrypt): Likewise.
(do_tripledes_encrypt): Likewise.
(do_tripledes_encrypt): Likewise.
* blowfish.c (bf_setkey: Likewise.
(encrypt_block): Likewise.
(decrypt_block): Likewise.
* arcfour.c (encrypt_stream): Likewise.
* rijndael.c (gnupgext_version, func_table): Removed definitions.
(gnupgext_enum_func) Removed function.
* twofish.c (gnupgext_version, func_table): Removed definitions.
(gnupgext_enum_func) Removed function.
* cast5.c (CIPHER_ALGO_CAST5): Removed.
* blowfish.c (FNCCAST_SETKEY, FNCCAST_CRYPT): Removed macros.
(CIPHER_ALGO_BLOWFISH): Removed symbol.
* cast5.c (FNCCAST_SETKEY, FNCCAST_CRYPT): Likewise.
* des.c (selftest_failed): Removed.
(initialized): New variable.
(do_des_setkey): Run selftest, if not yet done.
(FNCCAST_SETKEY, FNCCAST_CRYPT): Removed macros.
* arcfour.c (_gcry_arcfour_get_info): Removed function.
* blowfish.c (_gcry_blowfish_get_info): Removed function.
* cast5.c (_gcry_cast5_get_info): Removed function.
* des.c (_gcry_des_get_info): Removed function.
* rijndael.c (_gcry_rijndael_get_info): Removed function.
* twofish.c (_gcry_twofish_get_info): Removed function.
* arcfour.c (cipher_spec_arcfour): New variable.
* twofish.c (cipher_spec_twofish, cipher_spec_twofish128): New
variables.
* rijndael.c (cipher_spec_aes, cipher_spec_aes192,
cipher_spec256): New variables.
* des.c (cipher_spec_des, cipher_spec_tripledes): New variables.
* cast5.c (cipher_spec_cast5): New variable.
* blowfish.c (cipher_spec_blowfish): Likewise.
* twofish.c: Do not include "dynload.h".
* rijndael.c: Likewise.
* des.c: Likewise.
* cast5.c: Likewise.
* blowfish.c: Likewise.
* cipher.c: Likewise.
* crc.c: Likewise.
* md4.c: Likewise.
* md5.c: Likewise.
* md.c: Likewise.
* pubkey.c: Likewise.
* rijndael.c: Likewise.
* sha1.c: Likewise.
* sha256.c: Likewise.
* arcfour.c: Include "cipher.h".
* twofish.c: Likewise.
* rijndael.c: Likewise.
* des.c: Likewise.
* cast5.c: Likewise.
* blowfish.c: Likewise.
* twofish.c (twofish_setkey): Declared argument `key' const.
(twofish_encrypt): Declared argument `inbuf' const.
(twofish_decrypt): Likewise.
* rijndael.c (rijndael_setkey): Declared argument `key' const.
(rijndael_encrypt): Declared argument `inbuf' const.
(rijndael_decrypt): Likewise.
* des.c (do_des_setkey): Declared argument `key' const.
(do_tripledes_setkey): Likewise.
(do_des_encrypt): Declared argument `inbuf' const.
(do_des_decrypt): Likewise.
(do_tripledes_encrypt): Likewise.
(do_tripledes_decrypt): Likewise.
* cast5.c (encrypt_block): Declared argument `inbuf' const.
(decrypt_block): Likewise.
(cast_setkey): Declared argument `key' const.
* blowfish.c (do_bf_setkey): Declared argument `key' const.
(encrypt_block): Declared argument `inbuf' const.
(encrypt_block): Likewise.
* cipher.c: Remove CIPHER_ALGO_DUMMY related code.
Removed struct cipher_table_s.
Changed definition of cipher_table.
Removed definition of disabled_algos.
(ciphers_registered, default_ciphers_registered): New variables.
(REGISTER_DEFAULT_CIPHERS): New macro.
(dummy_setkey): Declared argument `key' const.
(dummy_encrypt_block): Declared argument `inbuf' const.
(dummy_encrypt_block): Likewise.
(dummy_encrypt_stream): Likewise.
(dummy_encrypt_stream): Likewise.
(dummy_setkey): Use `unsigned char' instead of `byte'.
(dummy_encrypt_block): Likewise.
(dummy_decrypt_block): Likewise.
(dummy_encrypt_stream): Likewise.
(dummy_decrypt_stream): Likewise.
(gcry_cipher_register_default): New function.
(gcry_cipher_lookup_func_id): New function.
(gcry_cipher_lookup_func_name): New function.
(gcry_cipher_lookup_id): New function.
(gcry_cipher_lookup_name): New function.
(gcry_cipher_id_new): New function.
(gcry_cipher_register): New function.
(gcry_cipher_unregister): New function.
(setup_cipher_table): Removed function.
(load_cipher_modules): Removed function.
(gcry_cipher_map_name): Adjusted to use new module management.
(cipher_algo_to_string): Likewise.
(disable_cipher_algo): Likewise.
(check_cipher_algo): Likewise.
(cipher_get_keylen): Likewise.
(cipher_get_blocksize): Likewise.
(gcry_cipher_open): Likewise.
(struct gcry_cipher_handle): Replaced members algo, algo_index,
blocksize, setkey, encrypt, decrypt, stencrypt, stdecrypt with one
member: cipher.
(gcry_cipher_open): Adjusted code for new handle structure.
(cipher_setkey): Likewise.
(cipher_setiv): Likewise.
(cipher_reset): Likewise.
(do_ecb_encrypt): Likewise.
(do_ecb_decrypt): Likewise.
(do_cbc_encrypt): Likewise.
(do_cbc_decrypt): Likewise.
(do_cfb_encrypt): Likewise.
(do_cfb_decrypt): Likewise.
(do_ctr_encrypt): Likewise.
(cipher_encrypt): Likewise.
(gcry_cipher_encrypt): Likewise.
(cipher_decrypt): Likewise.
(gcry_cipher_decrypt): Likewise.
(cipher_sync): Likewise.
(gcry_cipher_ctl): Likewise.
* pubkey.c: Removed struct pubkey_table_s.
Changed definition of pubkey_table.
Removed definition of disabled_algos.
(pubkeys_registered, default_pubkeys_registered): New variables.
(REGISTER_DEFAULT_PUBKEYS): New macro.
(setup_pubkey_table): Removed function.
(load_pubkey_modules): Removed function.
(gcry_pubkey_register_default): New function.
(gcry_pubkey_lookup_func_id): New function.
(gcry_pubkey_lookup_func_name): New function.
(gcry_pubkey_lookup_id): New function.
(gcry_pubkey_lookup_name): New function.
(gcry_pubkey_id_new): New function.
(gcry_pubkey_register): New function.
(gcry_pubkey_unregister): New function.
(gcry_pk_map_name): Adjusted to use new module management.
(gcry_pk_algo_name): Likewise.
(disable_pubkey_algo): Likewise.
(check_pubkey_algo): Likewise.
(pubkey_get_npkey): Likewise.
(pubkey_get_nskey): Likewise.
(pubkey_get_nsig): Likewise.
(pubkey_get_nenc): Likewise.
(pubkey_generate): Likewise.
(pubkey_check_secret_key): Likewise.
(pubkey_encrypt): Likewise.
(pubkey_decrypt): Likewise.
(pubkey_sign): Likewise.
(pubkey_verify): Likewise.
(gcry_pk_get_nbits): Likewise.
(gcry_pk_algo_info): Likewise.
* md.c: Removed struct md_digest_list_s.
(digest_list): Changed definition.
(digests_registered, default_digests_registered): New variables.
(REGISTER_DEFAULT_DIGESTS): New macro.
(new_list_item): Removed function.
(setup_md_table): Removed function.
(load_digest_module): Removed function.
(gcry_digest_register_default): New function.
(gcry_digest_lookup_func_id): New function.
(gcry_digest_lookup_func_name): New function.
(gcry_digest_lookup_id): New function.
(gcry_digest_lookup_name): New function.
(gcry_digest_id_new): New function.
(gcry_digest_register): New function.
(gcry_digest_unregister): New function.
(GcryDigestEntry): New type.
(struct gcry_md_context): Adjusted type of `list'.
(gcry_md_map_name): Adjusted to use new module management.
(digest_algo_to_string): Likewise.
(check_digest_algo): Likewise.
(md_enable): Likewise.
(md_digest_length): Likewise.
(md_asn_oid): Likewise.
2003-04-07 Moritz Schulte <moritz@g10code.com>
* pubkey.c: Replaced PUBKEY_ALGO_DSA with GCRY_PK_DSA,
PUBKEY_ALGO_RSA with GCRY_PK_RSA and PUBKEY_ALGO_ELGAMAL with
GCRY_PK_ELG.
* dsa.c: Replaced PUBKEY_ALGO_DSA with GCRY_PK_DSA.
2003-04-01 Moritz Schulte <moritz@g10code.com>
* des.c: Removed checks for GCRY_CIPHER_3DES and GCRY_CIPHER_DES.
2003-03-31 Moritz Schulte <moritz@g10code.com>
* tiger.c (tiger_get_info): Do not declare static.
* sha256.c (sha256_get_info): Likewise.
* sha1.c (sha1_get_info): Likewise.
* rmd160.c (rmd160_get_info): Likewise.
* md5.c (md5_get_info): Likewise.
* md4.c (md4_get_info): Likewise.
* crc.c (crc_get_info): Likewise.
* md.c (load_digest_module): Call setup_md_table during
initialization.
(new_list_item): Link new element into digest_list.
* cipher.c (do_ctr_decrypt): Made do_ctr_encrypt act as a wrapper
for do_ctr_encrypt, since these functions are identical.
2003-03-30 Simon Josefsson <jas@extundo.com>
* cipher.c (struct gcry_cipher_handle): Add counter field.
(gcry_cipher_open): Add CTR.
(cipher_reset): Clear counter field.
(do_ctr_encrypt, do_ctr_decrypt): New functions.
(cipher_encrypt, cipher_decrypt): Call CTR functions.
(gcry_cipher_ctl): Add SET_CTR to set counter.
2003-03-30 Moritz Schulte <moritz@g10code.com>
* rsa.c (_gcry_rsa_blind): New function.
(_gcry_rsa_unblind): New function.
(_gcry_rsa_decrypt): Use _gcry_rsa_blind and _gcry_rsa_decrypt.
2003-03-26 Moritz Schulte <moritz@g10code.com>
* dynload.c (_gcry_enum_gnupgext_pubkeys): Adjust `encrypt' and
`decrypt' function arguments.
(_gcry_enum_gnupgext_pubkeys): Likewise.
* dynload.h: Likewise.
* pubkey.c (dummy_decrypt): Add argument: int flags.
(dummy_encrypt): Likewise.
* elgamal.c (_gcry_elg_encrypt): Add argument: int flags.
(_gcry_elg_decrypt): Likewise.
* rsa.c (_gcry_rsa_encrypt): Add argument: int flags.
(_gcry_rsa_decrypt): Likewise.
* pubkey.c: Add `flags' argument to members `encrypt' and
`decrypt' of struct `pubkey_table_s'.
* rsa.h: Add `flags' argument to function declarations.
* elgamal.h: Likewise.
* pubkey.c (sexp_data_to_mpi): New variable: int parsed_flags.
(sexp_data_to_mpi): Set `parsed_flags'.
(sexp_data_to_mpi): New argument: int *flags.
(gcry_pk_encrypt): New variable: int flags.
(gcry_pk_encrypt): Pass `flags' to pubkey_encrypt.
(pubkey_encrypt): New variable: int flags.
(pubkey_encrypt): Pass `flags' to pubkey encrypt function.
(pubkey_decrypt): Likewise.
(pubkey_decrypt): Pass `flags' to pubkey encrypt function.
(gcry_pk_encrypt): Include `flags' s-exp in return list.
(sexp_to_enc): New argument: int *flags.
(gcry_pk_decrypt): New variable: int flags.
(gcry_pk_decrypt): Pass `flags' to pubkey_decrypt.
(sexp_to_enc): New variable: int parsed_flags.
(sexp_to_enc): Set `parsed_flags'.
2003-03-22 Simon Josefsson <jas@extundo.com>
* cipher.c (gcry_cipher_open, do_cbc_encrypt)
(gcry_cipher_encrypt): Support GCRY_CIPHER_CBC_MAC.
(gcry_cipher_ctl): Support GCRYCTL_SET_CBC_MAC.
2003-03-19 Werner Koch <wk@gnupg.org>
* primegen.c (gen_prime): New args EXTRA_CHECK and EXTRA_CHECK_ARG
to allow for a user callback. Changed all callers.
(_gcry_generate_secret_prime)
(_gcry_generate_public_prime): Ditto, pass them to gen_prime.
* rsa.c (check_exponent): New.
(generate): Use a callback to ensure that a given exponent is
actually generated.
2003-03-12 Moritz Schulte <moritz@g10code.com>
* primegen.c: Initialize `no_of_small_prime_numbers' statically.
(gen_prime): Remove calculation of `no_of_small_prime_numbers'.
2003-03-03 Moritz Schulte <moritz@g10code.com>
* md.c (gcry_md_ctl): Rewritten to use same style like the other
functions dispatchers.
2003-03-02 Moritz Schulte <moritz@g10code.com>
* cipher.c (struct gcry_cipher_handle): New member: algo_index.
(gcry_cipher_open): Allocate memory for two cipher contexts.
Initialize algo_index.
(cipher_setkey): Duplicate context into reserved memory.
(cipher_reset): New function, which resets the context and clear
the IV.
(gcry_cipher_ctl): Call cipher_reset.
2003-02-23 Moritz Schulte <moritz@g10code.com>
* cipher.c: Remove (bogus) `digitp' macro definition.
* md.c: Likewise.
* blowfish.c (burn_stack): Removed.
* arcfour.c (burn_stack): Likewise.
* cast5.c (burn_stack): Likewise.
* des.c (burn_stack): Likewise.
* md4.c (burn_stack): Likewise.
* md5.c (burn_stack): Likewise.
* random.c (burn_stack): Likewise.
* rijndael.c (burn_stack): Likewise.
* rmd160.c (burn_stack): Likewise.
* sha1.c (burn_stack): Likewise.
* sha256.c (burn_stack): Likewise.
* tiger.c (burn_stack): Likewise.
* twofish.c (burn_stack): Likewise.
* blowfish.c: Changed all occurences of burn_stack to
_gcry_burn_stack.
* arcfour.c: Likewise.
* cast5.c: Likewise.
* des.c: Likewise.
* md4.c: Likewise.
* md5.c: Likewise.
* random.c: Likewise.
* rijndael.c: Likewise.
* rmd160.c: Likewise.
* sha1.c: Likewise.
* sha256.c: Likewise.
* tiger.c: Likewise.
* twofish.c: Likewise.
* arcfour.c (_gcry_arcfour_get_info): Use GCRY_CIPHER_ARCFOUR
instead of hard-coded value `301'.
2003-01-24 Werner Koch <wk@gnupg.org>
* random.c (_gcry_register_random_progress): New.
(_gcry_random_progress): New.
* rndlinux.c (gather_random): Call the random progress function.
2003-01-23 Werner Koch <wk@gnupg.org>
* rsa.c (generate): New arg USE_E to request a specific public
exponent.
(_gcry_rsa_generate): Ditto.
* elgamal.c (_gcry_elg_generate): Must add an dummy argument
instead of USE_E.
* dsa.c (_gcry_dsa_generate): Ditto.
* pubkey.c (dummy_generate): Ditto.
(pubkey_generate): Add USE_E arg and pass it down.
(gcry_pk_genkey): Detect "rsa-use-e" parameter and pass it to generate.
* pubkey.c (sexp_to_enc): New arg RET_MODERN.
(gcry_pk_decrypt): Make use of it to return a real S-expression.
Return better error codes.
(gcry_pk_verify): Return better error codes.
2003-01-21 Werner Koch <wk@gnupg.org>
* random.c (gcry_random_add_bytes): Add QUALITY argument, let
function return an error code and disable its core for now.
2003-01-21 Timo Schulz <twoaday@freakmail.de>
* random.c (gcry_random_add_bytes): New. Function to add external
random to the pool.
2003-01-20 Simon Josefsson <jas@extundo.com>
* crc.c: New.
* Makefile.am (EXTRA_PROGRAMS, EXTRA_crc_SOURCES): Add crc.c.
* md.c (gcry_md_get_algo_dlen): Add values for CRC.
2003-01-20 Werner Koch <wk@gnupg.org>
* sha256.c: New.
* bithelp.h (ror): New.
* Makfile.am: Add sha256.c.
* md.c (oid_table): Add values for SHA256 et al.
(gcry_md_get_algo_dlen): Likewise
2003-01-20 Werner Koch <wk@gnupg.org>
* pubkey.c (gcry_pk_get_keygrip): Implemented keygrips for DSA
and ElGamal.
2003-01-17 Werner Koch <wk@gnupg.org>
* cipher.c (gcry_cipher_encrypt): Reworked so that the output will
never contain the plaintext even if the caller did not checked the
return value.
* md.c (gcry_md_get_algo): Changed error code to GCRYERR_GENERAL
because we don't have an invalid md algo but no algorithm enabled.
* pubkey.c (gcry_pk_genkey): Changed error code for bounds check
of table parameters to GCRYERR_INTERNAL.
* md.c (gcry_md_open): Partly reverted Timo's change from
2002-10-10 by removing the check for the algorithm. An algorithm
of 0 is allowed and anyway we should not double check it or check
it using a different function. Also fixed the flags check.
* pubkey.c (gcry_pk_encrypt): Make sure that R_CIPH points to NULL
on error.
(gcry_pk_decrypt): Ditto for R_PLAIN.
(gcry_pk_sign): Ditto for R_SIG.
(gcry_pk_genkey): Ditto for R_KEY.
2003-01-16 Werner Koch <wk@gnupg.org>
* md.c (gcry_md_write): Changed 2nd argument type to void*.
(gcry_md_hash_buffer): Changed type of boths buffers to void*.
(gcry_md_setkey): Changed 2nd argument type to void*.
2003-01-15 Werner Koch <wk@gnupg.org>
* pubkey.c (sexp_data_to_mpi): New. This handles pkcs1 padding.
(gcry_pk_sign, gcry_pk_verify): Use it here.
(gcry_pk_encrypt): And here.
(pubkey_verify): Add debug code.
(sexp_to_enc): Handle flags in the input and return the pkcs1 flag
in a new parameter.
(gcry_pk_decrypt): Prepare for future pkcs1 handling.
2002-12-19 Werner Koch <wk@gnupg.org>
* random.c (_gcry_random_initialize): New.
2002-12-16 Werner Koch <wk@gnupg.org>
* cipher.c: Added a Teletrust specific OID for 3DES.
2002-12-12 Werner Koch <wk@gnupg.org>
* md.c: Added another oddball OIW OID (sha-1WithRSAEncryption).
2002-11-23 Werner Koch <wk@gnupg.org>
* md.c (load_digest_module): Enlarged checked_algos bitmap.
* md4.c (func_table): Fixed entry for md4.
Both by Simon Josephson.
(transform): Copy data to get the alignment straight. Tested only
on i386.
2002-11-10 Simon Josefsson <jas@extundo.com>
* cipher.c (gcry_cipher_open): Don't reject CTS flag.
(do_cbc_encrypt, do_cbc_decrypt, cipher_encrypt)
(gcry_cipher_encrypt, cipher_decrypt)
(gcry_cipher_decrypt): Support CTS flag.
(gcry_cipher_ctl): Toggle CTS flag.
2002-11-10 Werner Koch <wk@gnupg.org>
* md4.c: New. By Simon Josefsson.
* Makefile.am (EXTRA_PROGRAMS): Add md4.c.
* md.c (oid_table,gcry_md_get_algo_dlen): MD4 support.
2002-10-14 Werner Koch <wk@gnupg.org>
* arcfour.c (do_encrypt_stream): Don't use increment op when
assigning to the same variable.
2002-10-10 Timo Schulz <ts@winpt.org>
* pubkey.c (gcry_pk_genkey): Check boundaries.
* md.c (gcry_md_open): Check that algo is available and only
valid flag values are used.
(gcry_md_get_algo): Add error handling.
2002-09-26 Werner Koch <wk@gnupg.org>
* md.c: Include an OID for TIGER.
* tiger.c (tiger_get_info): Use a regular OID.
2002-09-17 Werner Koch <wk@gnupg.org>
* random.c: Replaced mutex.h by the new ath.h. Changed all calls.
2002-09-16 Werner Koch <wk@gnupg.org>
* arcfour.c (do_encrypt_stream): Use register modifier and modulo.
According to Nikos Mavroyanopoulos this increases perfromace on
i386 system noticable. And I always tought gcc is clever enough.
* md5.c (transform): Use register modifier.
* rmd160.c (transform): Ditto.
* sha1.c (transform): Ditto. We hope that there are 6 free registers.
* random.c (gcry_randomize): Rewrote to avoid malloc calls.
* rndlinux.c (gather_random): Replaced remaining fprintfs by log_*.
* arcfour.c (do_arcfour_setkey): Ditto.
* twofish.c (do_twofish_setkey): Ditto.
* rndegd.c (gather_random): Ditto.
* rijndael.c (do_setkey): Ditto.
* random.c (_gcry_random_dump_stats): Ditto.
* primegen.c (_gcry_generate_elg_prime): Ditto.
* des.c (_gcry_des_get_info): Ditto.
* cast5.c (do_cast_setkey): Ditto.
* blowfish.c (do_bf_setkey): Ditto.
2002-08-26 Werner Koch <wk@gnupg.org>
* des.c (weak_keys): Fixed one entry in the table and compared
all entries against the literature.
(selftest): Checksum the weak key table.
2002-08-21 Werner Koch <wk@gnupg.org>
* pubkey.c: Enable keygrip calculation for "openpgp-rsa".
2002-08-17 Werner Koch <wk@gnupg.org>
* cipher.c (setup_cipher_table): Don't overwrite the DES entry
with the entry for DUMMY.
2002-08-14 Werner Koch <wk@gnupg.org>
* des.c (do_des_setkey,do_des_encrypt, do_des_decrypt): New.
(_gcry_des_get_info): Support plain old DES.
* cipher.c (setup_cipher_table): Put DES into the table.
2002-07-25 Werner Koch <wk@gnupg.org>
* rndunix.c (_gcry_rndunix_constructor): Prefixed with _gcry_.
Noted by Stephan Austermuehle.
2002-07-08 Timo Schulz <ts@winpt.org>
* rndw32.c: Replaced the m_ memory functions with the real
gcry_ functions. Renamed all g10_ prefixed functions to log_.
2002-06-12 Werner Koch <wk@gnupg.org>
* rsa.c (generate): Use e = 65537 for now.
2002-06-11 Werner Koch <wk@gnupg.org>
* pubkey.c (gcry_pk_get_keygrip): Allow a "protected-private-key".
2002-06-05 Timo Schulz <ts@winpt.org>
* cipher.c (gcry_cipher_encrypt, gcry_cipher_decrypt):
Check that the input size is a multiple of the blocksize.
2002-05-23 Werner Koch <wk@gnupg.org>
* md.c (oid_table): Add an rsadsi OID for MD5.
2002-05-21 Werner Koch <wk@gnupg.org>
* primegen.c, elgamal.c, dsa.c (progress): Do not print anything
by default. Pass an extra identifying string to the callback and
reserved 2 argumenst for current and total counters. Changed the
register function prototype.
2002-05-17 Werner Koch <wk@gnupg.org>
* rndegd.c (rndegd_constructor): Fixed name of register function
and prefixed the function name with _gcry_.
* rndw32.c (rndw32_constructor): Ditto.
* tiger.c (tiger_constructor): Ditto.
* Makefile.am: Removed all dynamic loading stuff.
* dynload.c: Ditto. Now only used for the constructor system.
2002-05-15 Werner Koch <wk@gnupg.org>
* random.c (gcry_random_bytes,gcry_random_bytes_secure)
(gcry_randomize): Make sure we are initialized.
2002-05-14 Werner Koch <wk@gnupg.org>
Changed license of most files to the LGPL.
2002-05-02 Werner Koch <wk@gnupg.org>
* random.c (_gcry_fast_random_poll): Initialize the module so the
mutex can be used.
* primegen.c (small_prime_numbers): Moved table from smallprime.c
* smallprime.c: File removed.
* des.c (leftkey_swap, rightkey_swap, working_memcmp): Made static.
* cipher.c (gcry_cipher_map_name): Map "RIJNDAEL" to "AES".
* rijndael.c (rijndael_get_info): We do only support a 128 bit
blocksize so it makes sense to change the algorithm strings to
AES.
* tiger.c (tiger_final): Removed superfluous token pasting operators.
* md5.c (md5_final): Ditto.
2002-04-30 Werner Koch <wk@gnupg.org>
* cipher.c: Fixed list of copyright years.
2002-03-18 Werner Koch <wk@gnupg.org>
* random.c (initialize): Initialize the new pool lock mutex.
(_gcry_fast_random_poll): Add locking and moved main
code out to...
(do_fast_random_poll): new function.
(read_pool): Use the new function here.
(get_random_bytes): Add locking.
(_gcry_update_random_seed_file): Ditto.
2002-03-11 Werner Koch <wk@gnupg.org>
* md.c: Add rsaSignatureWithripemd160 to OID table.
2002-02-20 Werner Koch <wk@gnupg.org>
* sha1.c: Removed a left over comment note. The code has been
rewritten from scratch in 1998. Thanks to Niels Möller for
reporting this misleading comment.
2002-02-18 Werner Koch <wk@gnupg.org>
* rndunix.c (rndunix_constructor): Use the the new prefixed
function name. Reported by Jordi Mallach.
2002-02-10 Werner Koch <wk@gnupg.org>
* random.c (mix_pool): Carry an extra failsafe_digest buffer
around to make the function more robust.
2002-02-08 Werner Koch <wk@gnupg.org>
* random.c (add_randomness): Xor new data into the pool and not
just copy it. This avoids any choosen input attacks which are not
serious in our setting because an outsider won't be able to mix
data in and even then we keep going with a PRNG. Thanks to Stefan
Keller for pointing this out.
2002-01-04 Werner Koch <wk@gnupg.org>
* pubkey.c (gcry_pk_genkey): Do not release skey - it is static.
* primegen.c (gen_prime): Of course we should use set_bit
and not set_highbit to set the second high bit.
2001-12-18 Werner Koch <wk@gnupg.org>
* rsa.c (generate): Loop until we find the exact modulus size.
Changed the exponent to 41.
(rsa_get_info): s/usage/r_usage/ to avoid shadow warnings.
* primegen.c (gen_prime): Set 2 high order bits for secret primes.
* Makefile.am (DISTCLEANFILES): Include construct.c.
2001-12-17 Werner Koch <wk@gnupg.org>
* pubkey.c (gcry_pk_get_keygrip): New - experimental.
2001-12-11 Werner Koch <wk@gnupg.org>
* cipher.c: Added OIDs for AES.
(gcry_cipher_mode_from_oid): New.
(gcry_cipher_map_name): Moved OID search code to ..
(search_oid): .. new function.
2001-12-10 Werner Koch <wk@gnupg.org>
* pubkey.c (gcry_pk_encrypt): Find the signature algorithm by name
and not by number.
* pubkey.c (gcry_pk_encrypt,gcry_pk_decrypt,gcry_pk_sign)
(gcry_pk_verify,gcry_pk_testkey, gcry_pk_genkey)
(gcry_pk_get_nbits): Release the arrays. Noted by Nikos
Mavroyanopoulos.
2001-12-06 Werner Koch <wk@gnupg.org>
* cipher.c (gcry_cipher_map_name): Look also for OIDs prefixed
with "oid." or "OID.".
2001-12-05 Werner Koch <wk@gnupg.org>
* pubkey.c (algo_info_table): Fixed entry for openpgp-rsa.
2001-11-24 Werner Koch <wk@gnupg.org>
* pubkey.c: Added the rsaEncryption OID to the tables.
(sexp_to_key): Add an arg to return the index of the algorithm,
changed all callers.
(gcry_pk_sign): Find the signature algorithm by name and not by
number.
(gcry_pk_get_nbits): Fixed so that we can now really pass a secret
key to get the result.
* md.c (gcry_md_map_name): Look also for OIDs prefixed with "oid."
or "OID." so that an OID string can be used as an S-Exp token.
2001-11-20 Werner Koch <wk@gnupg.org>
* md.c (gcry_md_map_name): Lookup by OID if the the name begins
with a digit.
(oid_table): New.
2001-11-16 Werner Koch <wk@gnupg.org>
* md.c (gcry_md_info): New operator GCRYCTL_IS_ALGO_ENABLED.
2001-11-07 Werner Koch <wk@gnupg.org>
* md.c (gcry_md_hash_buffer): Close the handle which was left open
for algorithms other than rmd160.
2001-08-08 Werner Koch <wk@gnupg.org>
* rndw32.c (gather_random): Use toolhelp in addition to the NT
gatherer for Windows2000. Suggested by Sami Tolvanen.
* random.c (read_pool): Fixed length check, this used to be one
byte to strict. Made an assert out of it because the caller has
already made sure that only poolsize bytes are requested.
Reported by Marcus Brinkmann.
2001-08-03 Werner Koch <wk@gnupg.org>
* cipher.c (cipher_encrypt, cipher_decrypt): Prepare to return
errors. We have to change the interface to all ciphers to make
this really work but we should do so to prepare for hardware
encryption modules.
(gcry_cipher_encrypt, gcry_cipher_decrypt): Return the error and
set lasterr.
(gcry_cipher_ctl): Make sure that errors from setkey are returned.
2001-08-02 Werner Koch <wk@gnupg.org>
* rndlinux.c (gather_random): casted a size_t arg to int so that
the format string is correct. Casting is okay here and avoids
translation changes.
* random.c (fast_random_poll): Do not check the return code of
getrusage.
* rndunix.c: Add a signal.h header to avoid warnings on Solaris 7
and 8.
* tiger.c (print_abc,print_data): Removed.
* rijndael.c, des.c, blowfish.c, twofish.c, cast5.c, arcfour.c
(burn_stack): New. Add wrappers for most functions to be able to
call burn_stack after the function invocation. This methods seems
to be the most portable way to zeroise the stack used. It does
only work on stack frame based machines but it is highly portable
and has no side effects. Just setting the automatic variables at
the end of a function to zero does not work well because the
compiler will optimize them away - marking them as volatile would
be bad for performance.
* md5.c, sha1.c, rmd160.c, tiger.c (burn_stack): Likewise.
* random.c (burn_stack): New.
(mix_pool): Use it here to burn the stack of the mixblock function.
* primegen.c (_gcry_generate_elg_prime): Freed q at 3 places.
Thanks to Tommi Komulainen.
* arcfour.c (arcfour_setkey): Check the minimim keylength against
bytes and not bits.
(selftest): Must reset the key before decryption.
2001-05-31 Werner Koch <wk@gnupg.org>
* sha1.c (sha1_init): Made static.
Changed all g10_ prefixed function names as well as some mpi_
function names to cope with the introduced naming changes.
* md.c (prepare_macpads): Made key const.
2001-05-28 Werner Koch <wk@gnupg.org>
* rndegd.c (gather_random): Removed the use of tty_printf.
2001-03-29 Werner Koch <wk@gnupg.org>
* md5.c (md5_final): Fixed calculation of hashed length. Thanks
to disastry@saiknes.lv for pointing out that it was horrible wrong
for more than 512MB of input.
* sha1.c (sha1_final): Ditto.
* rmd160.c (rmd160_final): Ditto.
* tiger.c (tiger_final): Ditto.
* blowfish.c (encrypt,do_encrypt): Changed name to do_encrypt to
avoid name clashes with an encrypt function in stdlib.h of
Dynix/PIX. Thanks to Gene Carter.
* elgamal.c (encrypt,do_encrypt): Ditto.
* twofish.c (gnupgext_enum_func): Use only when when compiled as a
module.
* rijndael.c (gnupgext_enum_func): Ditto.
* tiger.c (tiger_get_info): Return "TIGER192" and not just
"TIGER". By Edwin Woudt.
* random.c: Always include time.h - standard requirement. Thanks
to James Troup.
* rndw32.c: Fixes to the macros.
2001-01-11 Werner Koch <wk@gnupg.org>
* cipher.c (cipher_encrypt,gcry_cipher_encrypt): Use blocksize and
not 8.
2000-12-19 Werner Koch <wk@gnupg.org>
Major change:
Removed all GnuPG stuff and renamed this piece of software
to gcrypt.
2000-11-14 Werner Koch <wk@gnupg.org>
* dsa.c (test_keys): Replaced mpi_alloc by gcry_mpi_new and
mpi_free by gcry_mpi_release.
* elgamal.c (test_keys,generate): Ditto, also for mpi_alloc_secure.
* rsa.c (test_keys,generate,rsa_verify): Ditto.
* primegen.c (generate_elg_prime): Ditto.
(gen_prime): Ditto and removed nlimbs.
* rsa.c (generate): Allocate 2 more vars in secure memory.
* Makefile.am (OMIT_DEPENDENCIES): Hack to work around dependency
problems.
2000-10-09 Werner Koch <wk@gnupg.org>
* arcfour.c, arcfour.h: New.
* cipher.c (cipher_encrypt, cipher_decrypt): Add stream mode.
(setup_cipher_table): Add Arcfour.
(gcry_cipher_open): Kludge to allow stream mode.
Wed Oct 4 13:16:18 CEST 2000 Werner Koch <wk@openit.de>
* sha1.c (transform): Use rol() macro. Actually this is not needed
for a newer gcc but there are still aoter compilers.
* rsa.c (test_keys): Use new random function.
* md.c (gcry_md_setkey): New function to overcome problems with
const conflics.
(gcry_md_ctl): Pass set key to the new functions.
* rijndael.c: New.
* cipher.c: Add Rijndael support.
Mon Sep 18 16:35:45 CEST 2000 Werner Koch <wk@openit.de>
* rndlinux.c (open_device): Loose random device checking.
By Nils Ellmenreich.
* random.c (fast_random_poll): Check ENOSYS for getrusage.
* rndunix.c: Add 2 sources for QNX. By Sam Roberts.
* pubkey.c (gcry_pk_algo_info): Add GCRYCTL_GET_ALGO_USAGE.
* rsa.c: Changed the comment about the patent.
(secret): Speed up by using the CRT. For a 2k keys this
is about 3 times faster.
(stronger_key_check): New but unused code to check the secret key.
* Makefile.am: Included rsa.[ch].
* pubkey.c: Enabled RSA support.
(pubkey_get_npkey): Removed RSA workaround.
Mon Jul 31 10:04:47 CEST 2000 Werner Koch <wk@openit.de>
* pubkey.c: Replaced all gcry_sexp_{car,cdr}_{data,mpi} by the new
gcry_sexp_nth_{data,mpi} functions.
Tue Jul 25 17:44:15 CEST 2000 Werner Koch <wk@openit.de>
* pubkey.c (exp_to_key,sexp_to_sig,sexp_to_enc,gcry_pk_encrypt,
gcry_pk_decrypt,gcry_pk_sign,gcry_pk_genkey): Changed to work with
the new S-Exp interface.
Mon Jul 17 16:35:47 CEST 2000 Werner Koch <wk@>
* random.c (gather_faked): Replaced make_timestamp by time(2) again.
Fri Jul 14 19:38:23 CEST 2000 Werner Koch <wk@>
* md.c (gcry_md_ctl): Support GCRYCTL_{START,STOP}_DUMP.
* Makefile.am: Never compile mingw32 as module.
* Makefile.am: Tweaked module build and removed libtool
* Makefile.am: Replaced -O1 by -O. Suggested by Alec Habig.
* elgamal.c (sign): Removed inactive code.
* rsa.c, rsa.h: New based on the old module version (only in CVS for now).
* pubkey.c (setup_pubkey_table): Added commented support for RSA.
* rndunix.c (waitpid): New. For UTS 2.1. All by Dave Dykstra.
(my_popen): Do the FD_CLOEXEC only if it is available
(start_gatherer): Cope with missing _SC_OPEN_MAX
* rndunix.c: Add some more headers for QNX. By Sam Roberts.
* rndegd.c (gather_random): Shortcut level 0.
* rndunix.c (gather_random): Ditto.
* rndw32.c (gather_random): Ditto.
* rndw32.c: Replaced with code from Cryptlib and commented the old stuff.
* rndw32.c: Add some debuging code enabled by an environment variable.
* random.c (read_seed_file): Binary open for DOSish system
(update_random_seed_file): Ditto.
* random.c [MINGW32]: Include process.h for getpid.
* random.c (fast_random_poll): Add clock_gettime() as fallback for
system which support this POSIX.4 fucntion. By Sam Roberts.
* random.c (read_seed_file): Removed the S_ISLNK test becuase it
is already covered by !S_ISREG and is not defined in Unixware.
Reported by Dave Dykstra.
(update_random_seed_file): Silently ignore update request when pool
is not filled.
* random.c (read_seed_file): New.
(set_random_seed_file): New.
(read_pool): Try to read the seeding file.
(update_random_seed_file): New.
(read_pool): Do an initial extra seeding when level 2 quality random
is requested the first time. This requestes at least POOLSIZE/2 bytes
of entropy. Compined with the seeding file this should make normal
random bytes cheaper and increase the quality of the random bytes
used for key generation.
* random.c (read_pool): Print a more friendly error message in
cases when too much random is requested in one call.
* random.c (fast_random_poll): Check whether RUSAGE_SELF is defined;
this is not the case for some ESIX and Unixware, although they have
getrusage().
* primegen.c (generate_elg_prime): All primes are now generated with
the lowest random quality level. Because they are public anyway we
don't need stronger random and by this we do not drain the systems
entropy so much.
* primegen.c (register_primegen_progress): New.
* dsa.c (register_pk_dsa_progress): New.
* elgamal.c (register_pk_elg_progress): New.
* elgamal.c (wiener_map): New.
(gen_k): Use a much smaller k.
(generate): Calculate the qbits using the wiener map and
choose an x at a size comparable to the one choosen in gen_k
* rmd160.c (rmd160_get_info): Moved casting to the left side due to a
problem with UTS4.3. Suggested by Dave Dykstra.
* sha1.c (sha1_get_info): Ditto.
* tiger.c (tiger_get_info): Ditto.
* md5.c (md5_get_info): Ditto
* des.c (des_get_info): Ditto.
* blowfish.c (blowfish_get_info): Ditto.
* cast5.c (cast5_get_info): Ditto.
* twofish.c (twofish_get_info): Ditto.
Fri Mar 24 11:25:45 CET 2000 Werner Koch <wk@openit.de>
* md.c (md_open): Add hmac arg and allocate space for the pads.
(md_finalize): Add HMAC support.
(md_copy): Ditto.
(md_close): Ditto.
(gcry_md_reset): Ditto.
(gcry_md_ctl): Ditto.
(prepare_macpdas): New.
Mon Mar 13 19:22:46 CET 2000 Werner Koch <wk@openit.de>
* md.c (gcry_md_hash_buffer): Add support for the other algorithms.
Mon Jan 31 16:37:34 CET 2000 Werner Koch <wk@gnupg.de>
* genprime.c (generate_elg_prime): Fixed returned factors which never
worked for non-DSA keys.
Thu Jan 27 18:00:44 CET 2000 Werner Koch <wk@gnupg.de>
* pubkey.c (sexp_to_key): Fixed mem leaks in case of errors.
Mon Jan 24 22:24:38 CET 2000 Werner Koch <wk@gnupg.de>
* pubkey.c (gcry_pk_decrypt): Implemented.
(gcry_pk_encrypt): Implemented.
(gcry_pk_testkey): New.
(gcry_pk_genkey): New.
(pubkey_decrypt): Made static.
(pubkey_encrypt): Ditto.
(pubkey_check_secret_key): Ditto.
(pubkey_generate): Ditto.
Mon Jan 24 13:04:28 CET 2000 Werner Koch <wk@gnupg.de>
* pubkey.c (pubkey_nbits): Removed and replaced by ...
(gcry_pk_get_nbits): this new one.
Wed Dec 8 21:58:32 CET 1999 Werner Koch <wk@gnupg.de>
* dsa.c: s/mpi_powm/gcry_mpi_powm/g
* elgamal.c: Ditto.
* primegen.c: Ditto.
* : Replaced g10_opt_verbose by g10_log_verbosity().
* Makefile.am (INCLUDES): removed intl, add ../gcrypt
Fri Nov 19 17:15:20 CET 1999 Werner Koch <wk@gnupg.de>
* dynload.c (cmp_filenames): New to replaced compare_filename() in
module.
(register_cipher_extension): Removed the tilde expansion stuff.
* rndeg.c (my_make_filename): New.
* : Replaced header util.h by g10lib.h
* random.c (gather_faked): Replaced make_timestamp by time(2).
Disabled wrning printed with tty_printf.
* rndlinux.c (gather_random): Always use fprintf instead of tty_xxx;
this should be replaced by a callback function.
* primegen.c (gen_prime): Use gcry_mpi_randomize.
(is_prime): Ditto.
* elgamal.c (test_keys): Ditto.
* dsa.c (test_keys): Ditto.
* cipher.c (gcry_cipher_close): Die on invalid handle.
Mon Nov 15 21:36:02 CET 1999 Werner Koch <wk@gnupg.de>
* elgamal.c (gen_k): Use the new random API.
(generate): Ditto.
* dsa.c (gen_k): Ditto.
(generate): Ditto.
Sat Nov 13 17:44:23 CET 1999 Werner Koch <wk@gnupg.de>
* pubkey.c (disable_pubkey_algo): Made static.
(gcry_pk_ctl): New.
* random.c (get_random_bits): Renamed to ...
(get_random_bytes): ... this and made static.
(gcry_random_bytes): New.
(gcry_random_bytes_secure): New.
(randomize_buffer): Renamed to ...
(gcry_randomize): ...this.
* md.c (gcry_md_hash_buffer): New.
* pubkey.c (gcry_pk_algo_info): 4 new commands.
(pubkey_get_npkey): Made static.
(pubkey_get_nskey): Made static.
(pubkey_get_nsig): Made static.
(pubkey_get_nenc): Made static.
* pubkey.c: Removed all G10ERR_xxx.
* cipher.c: Changed all GCRYERR_INV_ALGO to GCRYERR_INV_CIPHER_ALGO.
* md.c: Changed all GCRYERR_INV_ALGO to GCRYERR_INV_MD_ALGO.
* cast5.c (cast_setkey): Changed errocodes to GCRYERR_xxx.
* blowfish.c: Ditto.
* des.c: Ditto.
* twofish.c: Ditto.
* dsa.c: Ditto.
* elgamal.c: Ditto.
* g10c.c: Removed
* cipher.c (gcry_cipher_open): Replaced alloc functions and return NULL
if we are out of core.
* dynload.c: Replaced all memory allocation functions.
* md.c: Ditto.
* primegen.c: Ditto.
* pubkey.c: Ditto.
* random.c: Ditto.
* rndw32.c: Ditto.
* elgamal.c: Ditto.
* dsa.c: Ditto.
Tue Oct 26 14:10:21 CEST 1999 Werner Koch <wk@gnupg.de>
* elgamal.c (sign): Hugh found strange code here. Replaced by BUG().
* cipher.c: Merged with gcrypt/symapi.c.
* pubkey.c (string_to_pubkey_algo): Renamed function to ...
(gcry_pk_map_name): ... this.
(pubkey_algo_to_string): Renamed function to ...
(gcry_pk_algo_name): ... this.
(gcry_pk_algo_info): New.
* pubkey.c: Merged with gcrypt/pkapi.c.
* md.c (md_reset): Clear finalized; thanks to Ulf Moeller for
fixing this bug.
* md.c: Merged with gcrypt/mdapi.c
Wed Sep 15 14:39:59 CEST 1999 Michael Roth <mroth@nessie.de>
* des.c: Various speed improvements: One bit pre rotation
trick after initial permutation (Richard Outerbridge).
Finished test of SSLeay Tripple-DES patterns.
Wed Sep 15 16:22:17 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* rndw32.c: New.
Mon Sep 13 10:51:29 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* bithelp.h: New.
* rmd160.h, sha1.h, md5.h: Use the rol macro from bithelp.h
Tue Sep 7 16:23:36 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* Makefile.am: Fixed seds for latest egcc. By Ollivier Robert.
Mon Sep 6 19:59:08 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* des.c (selftest): Add some testpattern
Mon Aug 30 20:38:33 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* cipher.c (do_cbc_encrypt): Fixed serious bug occuring when not using
in place encryption. Pointed out by Frank Stajano.
Mon Jul 26 09:34:46 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* md5.c (md5_final): Fix for a SCO cpp bug.
Thu Jul 15 10:15:35 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* elgamal.c (elg_check_secret_key,elg_encrypt
elg_decrypt,elg_sign,elg_verify): Sanity check on the args.
* dsa.c (dsa_check_secret_key,dsa_sign,dsa_verify): Ditto.
* pubkey.c (disable_pubkey_algo): New.
(check_pubkey_algo2): Look at disabled algo table.
* cipher.c (disable_cipher_algo): New.
(check_cipher_algo): Look at disabled algo table.
Wed Jul 7 13:08:40 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* Makefile.am: Support for libtool.
Fri Jul 2 11:45:54 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* dsa.c (gen_k): Changed algorithm to consume less random bytes
* elgamal.c (gen_k): Ditto.
* random.c (random_dump_stats): New.
Thu Jul 1 12:47:31 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* primegen.c, elgamal.c, dsa.c (progess): New and replaced all
fputc with a call to this function.
Sat Jun 26 12:15:59 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* rndegd.c (do_write): s/ssize_t/int/ due to SunOS 4.1 probs.
* cipher.c (do_cbc_encrypt, do_cbc_decrypt): New.
* dynload.c (HAVE_DL_SHL_LOAD): Map hpux API to dlopen (Dave Dykstra).
* Makefile.am (install-exec-hook): Removed.
Sun May 23 14:20:22 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* cipher.c (setup_cipher_table): Enable Twofish
* random.c (fast_random_poll): Disable use of times() for mingw32.
Mon May 17 21:54:43 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* dynload.c (register_internal_cipher_extension): Minor init fix.
Tue May 4 15:47:53 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* primegen.c (gen_prime): Readded the Fermat test. Fixed the bug
that we didn't correct for step when passing the prime to the
Rabin-Miller test which led to bad performance (Stefan Keller).
(check_prime): Add a first Fermat test.
Sun Apr 18 10:11:28 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* cipher.c (cipher_setiv): Add ivlen arg, changed all callers.
* random.c (randomize_buffer): alway use secure memory because
we can't use m_is_secure() on a statically allocated buffer.
* twofish.c: Replaced some macros by a loop to reduce text size.
* Makefile.am (twofish): No more need for sed editing.
Fri Apr 9 12:26:25 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* cipher.c (cipher_open): Reversed the changes for AUTO_CFB.
* blowfish.c: Dropped the Blowfish 160 mode.
* cipher.c (cipher_open): Ditto.
(setup_cipher_table): Ditto. And removed support of twofish128
Wed Apr 7 20:51:39 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* random.c (get_random_bits): Can now handle requests > POOLSIZE
* cipher.c (cipher_open): Now uses standard CFB for automode if
the blocksize is gt 8 (according to rfc2440).
* twofish.c: Applied Matthew Skala's patches for 256 bit key.
Tue Apr 6 19:58:12 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* random.c (get_random_bits): Can now handle requests > POOLSIZE
* cipher.c (cipher_open): Now uses standard CFB for automode if
the blocksize is gt 8 (according to rfc2440).
Sat Mar 20 11:44:21 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* rndlinux.c (tty_printf) [IS_MODULE]: Removed.
* rndegd.c (gather_random): Some fixes.
Wed Mar 17 13:09:03 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* rndegd.c (do_read): New.
(gather_random): Changed the implementation.
Mon Mar 8 20:47:17 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* dynload.c (DLSYM_NEEDS_UNDERSCORE): Renamed.
Fri Feb 26 17:55:41 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* md.c: Nearly a total rewrote.
Wed Feb 24 11:07:27 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* cipher.c (context): Fixed alignment
* md.c: Ditto.
* rndegd.c: New
Mon Feb 22 20:04:00 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* rndegd.c: New.
Wed Feb 10 17:15:39 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* Makefile.am: Modules are now figured out by configure
* construct.c: New. Generated by configure. Changed all modules
to work with that.
* sha1.h: Removed.
* md5.h: Removed.
* twofish.c: Changed interface to allow Twofish/256
* rndunix.c (start_gatherer): Die on SIGPIPE.
Wed Jan 20 18:59:49 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* rndunix.c (gather_random): Fix to avoid infinite loop.
Sun Jan 17 11:04:33 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* des.c (is_weak_key): Replace system memcmp due to bugs
in SunOS's memcmp.
(des_get_info): Return error on failed selftest.
* twofish.c (twofish_setkey): Return error on failed selftest or
invalid keylength.
* cast5.c (cast_setkey): Ditto.
* blowfish.c (bf_setkey): Return error on failed selftest.
Tue Jan 12 11:17:18 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* random.c (random_is_faked): New.
* tiger.c: Only compile if we have the u64 type
Sat Jan 9 16:02:23 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* rndunix.c (gather_random): check for setuid.
* Makefile.am: Add a way to staically link random modules
Thu Jan 7 18:00:58 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* md.c (md_stop_debug): Do a flush first.
(md_open): size of buffer now depends on the secure parameter
Sun Jan 3 15:28:44 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* rndunix.c (start_gatherer): Fixed stupid ==/= bug
1998-12-31 Geoff Keating <geoffk@ozemail.com.au>
* des.c (is_weak_key): Rewrite loop end condition.
Tue Dec 29 14:41:47 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
* random.c: add unistd.h for getpid().
(RAND_MAX): Fallback value for Sun.
Wed Dec 23 17:12:24 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
* md.c (md_copy): Reset debug.
Mon Dec 14 21:18:49 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
* random.c (read_random_source): Changed the interface to the
random gathering function.
(gather_faked): Use new interface.
* dynload.c (dynload_getfnc_fast_random_poll): Ditto.
(dynload_getfnc_gather_random): Ditto.
* rndlinux.c (gather_random): Ditto.
* rndunix.c (gather_random): Ditto.
Sat Dec 12 18:40:32 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
* dynload.c (SYMBOL_VERSION): New to cope with system which needs
underscores.
* rndunix.c: Rewrote large parts
Thu Dec 10 20:15:36 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
* dynload.c (load_extension): increased needed verbosity level.
* random.c (fast_random_poll): Fallback to a default fast random
poll function.
(read_random_source): Always use the faked entroy gatherer if no
gather module is available.
* rndlinux.c (fast_poll): Removed.
* rndunix.c (fast_poll): Removed.
Wed Nov 25 12:33:41 1998 Werner Koch (wk@isil.d.shuttle.de)
* rand-*.c: Removed.
* rndlinux.c : New.
* rndunix.c : New.
* random.c : Restructured the interface to the gather modules.
(intialize): Call constructor functions
(read_radnom_source): Moved to here.
* dynload.c (dynload_getfnc_gather_random): New.
(dynload_getfnc_fast_random_poll): New.
(register_internal_cipher_extension): New.
(register_cipher_extension): Support of internal modules.
Sun Nov 8 17:44:36 1998 Werner Koch (wk@isil.d.shuttle.de)
* rand-unix.c (read_random_source): Removed the assert.
Mon Oct 19 18:34:30 1998 me,,, (wk@tobold)
* pubkey.c: Hack to allow us to give some info about RSA keys back.
Thu Oct 15 11:47:57 1998 Werner Koch (wk@isil.d.shuttle.de)
* dynload.c: Support for DLD
Wed Oct 14 12:13:07 1998 Werner Koch (wk@isil.d.shuttle.de)
* rand-unix.c: Now uses names from configure for /dev/random.
1998-10-10 SL Baur <steve@altair.xemacs.org>
* Makefile.am: fix sed -O substitutions to catch -O6, etc.
Tue Oct 6 10:06:32 1998 Werner Koch (wk@isil.d.shuttle.de)
* rand-unix.c (HAVE_GETTIMEOFDAY): Fixed (was ..GETTIMEOFTIME :-)
* rand-dummy.c (HAVE_GETTIMEOFDAY): Ditto.
Mon Sep 28 13:23:09 1998 Werner Koch (wk@isil.d.shuttle.de)
* md.c (md_digest): New.
(md_reset): New.
Wed Sep 23 12:27:02 1998 Werner Koch (wk@isil.d.shuttle.de)
* tiger.c (TIGER_CONTEXT): moved "buf", so that it is 64 bit aligned.
Mon Sep 21 06:22:53 1998 Werner Koch (wk@(none))
* des.c: Some patches from Michael.
Thu Sep 17 19:00:06 1998 Werner Koch (wk@(none))
* des.c : New file from Michael Roth <mroth@nessie.de>
Mon Sep 14 11:10:55 1998 Werner Koch (wk@(none))
* blowfish.c (bf_setkey): Niklas Hernaeus patch to detect weak keys.
Mon Sep 14 09:19:25 1998 Werner Koch (wk@(none))
* dynload.c (RTLD_NOW): Now defined to 1 if it is undefined.
Mon Sep 7 17:04:33 1998 Werner Koch (wk@(none))
* Makefile.am: Fixes to allow a different build directory
Thu Aug 6 17:25:38 1998 Werner Koch,mobil,,, (wk@tobold)
* random.c (get_random_byte): Removed and changed all callers
to use get_random_bits()
Mon Jul 27 10:30:22 1998 Werner Koch (wk@(none))
* cipher.c : Support for other blocksizes
(cipher_get_blocksize): New.
* twofish.c: New.
* Makefile.am: Add twofish module.
Mon Jul 13 21:30:52 1998 Werner Koch (wk@isil.d.shuttle.de)
* random.c (read_pool): Simple alloc if secure_alloc is not set.
(get_random_bits): Ditto.
Thu Jul 9 13:01:14 1998 Werner Koch (wk@isil.d.shuttle.de)
* dynload.c (load_extension): Function now nbails out if
the program is run setuid.
Wed Jul 8 18:58:23 1998 Werner Koch (wk@isil.d.shuttle.de)
* rmd160.c (rmd160_hash_buffer): New.
Thu Jul 2 10:50:30 1998 Werner Koch (wk@isil.d.shuttle.de)
* cipher.c (cipher_open): algos >=100 use standard CFB
Thu Jun 25 11:18:25 1998 Werner Koch (wk@isil.d.shuttle.de)
* Makefile.am: Support for extensions
Thu Jun 18 12:09:38 1998 Werner Koch (wk@isil.d.shuttle.de)
* random.c (mix_pool): simpler handling for level 0
Mon Jun 15 14:40:48 1998 Werner Koch (wk@isil.d.shuttle.de)
* tiger.c: Removed from dist, will reappear as dynload module
Sat Jun 13 14:16:57 1998 Werner Koch (wk@isil.d.shuttle.de)
* pubkey.c: Major changes to allow extensions. Changed the inteface
of all public key ciphers and added the ability to load extensions
on demand.
* misc.c: Removed.
Wed Jun 10 07:52:08 1998 Werner Koch,mobil,,, (wk@tobold)
* dynload.c: New.
* cipher.c: Major changes to allow extensions.
Mon Jun 8 22:43:00 1998 Werner Koch (wk@isil.d.shuttle.de)
* cipher.c: Major internal chnages to support extensions.
* blowfish.c (blowfish_get_info): New and made all internal
functions static, changed heder.
* cast5.c (cast5_get_info): Likewise.
Mon Jun 8 12:27:52 1998 Werner Koch (wk@isil.d.shuttle.de)
* tiger.c (transform): Fix for big endian
* cipher.c (do_cfb_decrypt): Big endian fix.
Fri May 22 07:30:39 1998 Werner Koch (wk@isil.d.shuttle.de)
* md.c (md_get_oid): Add a new one for TIGER.
Thu May 21 13:24:52 1998 Werner Koch (wk@isil.d.shuttle.de)
* cipher.c: Add support for a dummy cipher
Thu May 14 15:40:36 1998 Werner Koch (wk@isil.d.shuttle.de)
* rmd160.c (transform): fixed sigbus - I should better
add Christian von Roques's new implemenation of rmd160_write.
Fri May 8 18:07:44 1998 Werner Koch (wk@isil.d.shuttle.de)
* rand-internal.h, rand-unix.c, rand-w32.c, rand_dummy.c: New
* random.c: Moved system specific functions to rand-****.c
Fri May 8 14:01:17 1998 Werner Koch (wk@isil.d.shuttle.de)
* random.c (fast_random_poll): add call to gethrtime.
Tue May 5 21:28:55 1998 Werner Koch (wk@isil.d.shuttle.de)
* elgamal.c (elg_generate): choosing x was not correct, could
yield 6 bytes which are not from the random pool, tsss, tsss..
Tue May 5 14:09:06 1998 Werner Koch (wk@isil.d.shuttle.de)
* primegen.c (generate_elg_prime): Add arg mode, changed all
callers and implemented mode 1.
Mon Apr 27 14:41:58 1998 Werner Koch (wk@isil.d.shuttle.de)
* cipher.c (cipher_get_keylen): New.
Sun Apr 26 14:44:52 1998 Werner Koch (wk@isil.d.shuttle.de)
* tiger.c, tiger.h: New.
Wed Apr 8 14:57:11 1998 Werner Koch (wk@isil.d.shuttle.de)
* misc.c (check_pubkey_algo2): New.
Tue Apr 7 18:46:49 1998 Werner Koch (wk@isil.d.shuttle.de)
* cipher.c: New
* misc.c (check_cipher_algo): Moved to cipher.c
* cast5.c: Moved many functions to cipher.c
* blowfish.c: Likewise.
Sat Apr 4 19:52:08 1998 Werner Koch (wk@isil.d.shuttle.de)
* cast5.c: Implemented and tested.
Wed Apr 1 16:38:27 1998 Werner Koch (wk@isil.d.shuttle.de)
* elgamal.c (elg_generate): Faster generation of x in some cases.
Thu Mar 19 13:54:48 1998 Werner Koch (wk@isil.d.shuttle.de)
* blowfish.c (blowfish_decode_cfb): changed XOR operation
(blowfish_encode_cfb): Ditto.
Thu Mar 12 14:04:05 1998 Werner Koch (wk@isil.d.shuttle.de)
* sha1.c (transform): Rewrote
* blowfish.c (encrypt): Unrolled for rounds == 16
(decrypt): Ditto.
Tue Mar 10 16:32:08 1998 Werner Koch (wk@isil.d.shuttle.de)
* rmd160.c (transform): Unrolled the loop.
Tue Mar 10 13:05:14 1998 Werner Koch (wk@isil.d.shuttle.de)
* random.c (read_pool): Add pool_balance stuff.
(get_random_bits): New.
* elgamal.c (elg_generate): Now uses get_random_bits to generate x.
Tue Mar 10 11:33:51 1998 Werner Koch (wk@isil.d.shuttle.de)
* md.c (md_digest_length): New.
Tue Mar 10 11:27:41 1998 Werner Koch (wk@isil.d.shuttle.de)
* dsa.c (dsa_verify): Works.
Mon Mar 9 12:59:08 1998 Werner Koch (wk@isil.d.shuttle.de)
* dsa.c, dsa.h: Removed some unused code.
Wed Mar 4 10:39:22 1998 Werner Koch (wk@isil.d.shuttle.de)
* md.c (md_open): Add call to fast_random_poll.
blowfish.c (blowfish_setkey): Ditto.
Tue Mar 3 13:32:54 1998 Werner Koch (wk@isil.d.shuttle.de)
* rmd160.c (rmd160_mixblock): New.
* random.c: Restructured to start with a new RNG implementation.
* random.h: New.
Mon Mar 2 19:21:46 1998 Werner Koch (wk@isil.d.shuttle.de)
* gost.c, gost.h: Removed because they did only contain trash.
Sun Mar 1 16:42:29 1998 Werner Koch (wk@isil.d.shuttle.de)
* random.c (fill_buffer): removed error message if n == -1.
Fri Feb 27 16:39:34 1998 Werner Koch (wk@isil.d.shuttle.de)
* md.c (md_enable): No init if called twice.
Thu Feb 26 07:57:02 1998 Werner Koch (wk@isil.d.shuttle.de)
* primegen.c (generate_elg_prime): Changed the progress printing.
(gen_prime): Ditto.
Tue Feb 24 12:28:42 1998 Werner Koch (wk@isil.d.shuttle.de)
* md5.c, md.5 : Replaced by a modified version of md5.c from
GNU textutils 1.22.
Wed Feb 18 14:08:30 1998 Werner Koch (wk@isil.d.shuttle.de)
* md.c, md.h : New debugging support
Mon Feb 16 10:08:47 1998 Werner Koch (wk@isil.d.shuttle.de)
* misc.c (cipher_algo_to_string): New
(pubkey_algo_to_string): New.
(digest_algo_to_string): New.
Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
This file is free software; as a special exception the author gives
unlimited permission to copy and/or distribute it, with or without
modifications, as long as this notice is preserved.
This file is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/cipher/cipher.c b/cipher/cipher.c
index 90fdb173..b0a532af 100644
--- a/cipher/cipher.c
+++ b/cipher/cipher.c
@@ -1,2222 +1,2222 @@
/* cipher.c - cipher dispatcher
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
* 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
*
* This file is part of Libgcrypt.
*
* Libgcrypt is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser general Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* Libgcrypt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "g10lib.h"
#include "cipher.h"
#include "ath.h"
#define MAX_BLOCKSIZE 16
#define TABLE_SIZE 14
#define CTX_MAGIC_NORMAL 0x24091964
#define CTX_MAGIC_SECURE 0x46919042
/* Try to use 16 byte aligned cipher context for better performance.
We use the aligned attribute, thus it is only possible to implement
this with gcc. */
#undef NEED_16BYTE_ALIGNED_CONTEXT
#if defined (__GNUC__)
# define NEED_16BYTE_ALIGNED_CONTEXT 1
#endif
/* A dummy extraspec so that we do not need to tests the extraspec
field from the module specification against NULL and instead
directly test the respective fields of extraspecs. */
static cipher_extra_spec_t dummy_extra_spec;
/* This is the list of the default ciphers, which are included in
libgcrypt. */
static struct cipher_table_entry
{
gcry_cipher_spec_t *cipher;
cipher_extra_spec_t *extraspec;
unsigned int algorithm;
int fips_allowed;
} cipher_table[] =
{
#if USE_BLOWFISH
{ &_gcry_cipher_spec_blowfish,
&dummy_extra_spec, GCRY_CIPHER_BLOWFISH },
#endif
#if USE_DES
{ &_gcry_cipher_spec_des,
&dummy_extra_spec, GCRY_CIPHER_DES },
{ &_gcry_cipher_spec_tripledes,
&_gcry_cipher_extraspec_tripledes, GCRY_CIPHER_3DES, 1 },
#endif
#if USE_ARCFOUR
{ &_gcry_cipher_spec_arcfour,
&dummy_extra_spec, GCRY_CIPHER_ARCFOUR },
#endif
#if USE_CAST5
{ &_gcry_cipher_spec_cast5,
&dummy_extra_spec, GCRY_CIPHER_CAST5 },
#endif
#if USE_AES
{ &_gcry_cipher_spec_aes,
&_gcry_cipher_extraspec_aes, GCRY_CIPHER_AES, 1 },
{ &_gcry_cipher_spec_aes192,
&_gcry_cipher_extraspec_aes192, GCRY_CIPHER_AES192, 1 },
{ &_gcry_cipher_spec_aes256,
&_gcry_cipher_extraspec_aes256, GCRY_CIPHER_AES256, 1 },
#endif
#if USE_TWOFISH
{ &_gcry_cipher_spec_twofish,
&dummy_extra_spec, GCRY_CIPHER_TWOFISH },
{ &_gcry_cipher_spec_twofish128,
&dummy_extra_spec, GCRY_CIPHER_TWOFISH128 },
#endif
#if USE_SERPENT
{ &_gcry_cipher_spec_serpent128,
&dummy_extra_spec, GCRY_CIPHER_SERPENT128 },
{ &_gcry_cipher_spec_serpent192,
&dummy_extra_spec, GCRY_CIPHER_SERPENT192 },
{ &_gcry_cipher_spec_serpent256,
&dummy_extra_spec, GCRY_CIPHER_SERPENT256 },
#endif
#if USE_RFC2268
{ &_gcry_cipher_spec_rfc2268_40,
&dummy_extra_spec, GCRY_CIPHER_RFC2268_40 },
#endif
#if USE_SEED
{ &_gcry_cipher_spec_seed,
&dummy_extra_spec, GCRY_CIPHER_SEED },
#endif
#if USE_CAMELLIA
{ &_gcry_cipher_spec_camellia128,
&dummy_extra_spec, GCRY_CIPHER_CAMELLIA128 },
{ &_gcry_cipher_spec_camellia192,
&dummy_extra_spec, GCRY_CIPHER_CAMELLIA192 },
{ &_gcry_cipher_spec_camellia256,
&dummy_extra_spec, GCRY_CIPHER_CAMELLIA256 },
#endif
{ NULL }
};
/* List of registered ciphers. */
static gcry_module_t ciphers_registered;
/* This is the lock protecting CIPHERS_REGISTERED. */
static ath_mutex_t ciphers_registered_lock = ATH_MUTEX_INITIALIZER;
/* Flag to check whether the default ciphers have already been
registered. */
static int default_ciphers_registered;
/* Convenient macro for registering the default ciphers. */
#define REGISTER_DEFAULT_CIPHERS \
do \
{ \
ath_mutex_lock (&ciphers_registered_lock); \
if (! default_ciphers_registered) \
{ \
cipher_register_default (); \
default_ciphers_registered = 1; \
} \
ath_mutex_unlock (&ciphers_registered_lock); \
} \
while (0)
/* A VIA processor with the Padlock engine as well as the Intel AES_NI
instructions require an alignment of most data on a 16 byte
boundary. Because we trick out the compiler while allocating the
context, the align attribute as used in rijndael.c does not work on
its own. Thus we need to make sure that the entire context
structure is a aligned on that boundary. We achieve this by
defining a new type and use that instead of our usual alignment
type. */
typedef union
{
PROPERLY_ALIGNED_TYPE foo;
#ifdef NEED_16BYTE_ALIGNED_CONTEXT
char bar[16] __attribute__ ((aligned (16)));
#endif
char c[1];
} cipher_context_alignment_t;
/* The handle structure. */
struct gcry_cipher_handle
{
int magic;
size_t actual_handle_size; /* Allocated size of this handle. */
size_t handle_offset; /* Offset to the malloced block. */
gcry_cipher_spec_t *cipher;
cipher_extra_spec_t *extraspec;
gcry_module_t module;
/* The algorithm id. This is a hack required because the module
interface does not easily allow to retrieve this value. */
int algo;
/* A structure with function pointers for bulk operations. Due to
limitations of the module system (we don't want to change the
API) we need to keep these function pointers here. The cipher
open function intializes them and the actual encryption routines
use them if they are not NULL. */
struct {
void (*cfb_enc)(void *context, unsigned char *iv,
void *outbuf_arg, const void *inbuf_arg,
unsigned int nblocks);
void (*cfb_dec)(void *context, unsigned char *iv,
void *outbuf_arg, const void *inbuf_arg,
unsigned int nblocks);
void (*cbc_enc)(void *context, unsigned char *iv,
void *outbuf_arg, const void *inbuf_arg,
unsigned int nblocks, int cbc_mac);
void (*cbc_dec)(void *context, unsigned char *iv,
void *outbuf_arg, const void *inbuf_arg,
unsigned int nblocks);
void (*ctr_enc)(void *context, unsigned char *iv,
void *outbuf_arg, const void *inbuf_arg,
unsigned int nblocks);
} bulk;
int mode;
unsigned int flags;
struct {
unsigned int key:1; /* Set to 1 if a key has been set. */
unsigned int iv:1; /* Set to 1 if a IV has been set. */
} marks;
/* The initialization vector. For best performance we make sure
that it is properly aligned. In particular some implementations
of bulk operations expect an 16 byte aligned IV. */
union {
cipher_context_alignment_t iv_align;
unsigned char iv[MAX_BLOCKSIZE];
} u_iv;
/* The counter for CTR mode. This field is also used by AESWRAP and
thus we can't use the U_IV union. */
union {
cipher_context_alignment_t iv_align;
unsigned char ctr[MAX_BLOCKSIZE];
} u_ctr;
/* Space to save an IV or CTR for chaining operations. */
unsigned char lastiv[MAX_BLOCKSIZE];
int unused; /* Number of unused bytes in LASTIV. */
/* What follows are two contexts of the cipher in use. The first
one needs to be aligned well enough for the cipher operation
whereas the second one is a copy created by cipher_setkey and
used by cipher_reset. That second copy has no need for proper
aligment because it is only accessed by memcpy. */
cipher_context_alignment_t context;
};
/* These dummy functions are used in case a cipher implementation
refuses to provide it's own functions. */
static gcry_err_code_t
dummy_setkey (void *c, const unsigned char *key, unsigned int keylen)
{
(void)c;
(void)key;
(void)keylen;
return GPG_ERR_NO_ERROR;
}
static void
dummy_encrypt_block (void *c,
unsigned char *outbuf, const unsigned char *inbuf)
{
(void)c;
(void)outbuf;
(void)inbuf;
BUG();
}
static void
dummy_decrypt_block (void *c,
unsigned char *outbuf, const unsigned char *inbuf)
{
(void)c;
(void)outbuf;
(void)inbuf;
BUG();
}
static void
dummy_encrypt_stream (void *c,
unsigned char *outbuf, const unsigned char *inbuf,
unsigned int n)
{
(void)c;
(void)outbuf;
(void)inbuf;
(void)n;
BUG();
}
static void
dummy_decrypt_stream (void *c,
unsigned char *outbuf, const unsigned char *inbuf,
unsigned int n)
{
(void)c;
(void)outbuf;
(void)inbuf;
(void)n;
BUG();
}
/* Internal function. Register all the ciphers included in
CIPHER_TABLE. Note, that this function gets only used by the macro
REGISTER_DEFAULT_CIPHERS which protects it using a mutex. */
static void
cipher_register_default (void)
{
gcry_err_code_t err = GPG_ERR_NO_ERROR;
int i;
for (i = 0; !err && cipher_table[i].cipher; i++)
{
if (! cipher_table[i].cipher->setkey)
cipher_table[i].cipher->setkey = dummy_setkey;
if (! cipher_table[i].cipher->encrypt)
cipher_table[i].cipher->encrypt = dummy_encrypt_block;
if (! cipher_table[i].cipher->decrypt)
cipher_table[i].cipher->decrypt = dummy_decrypt_block;
if (! cipher_table[i].cipher->stencrypt)
cipher_table[i].cipher->stencrypt = dummy_encrypt_stream;
if (! cipher_table[i].cipher->stdecrypt)
cipher_table[i].cipher->stdecrypt = dummy_decrypt_stream;
if ( fips_mode () && !cipher_table[i].fips_allowed )
continue;
err = _gcry_module_add (&ciphers_registered,
cipher_table[i].algorithm,
(void *) cipher_table[i].cipher,
(void *) cipher_table[i].extraspec,
NULL);
}
if (err)
BUG ();
}
/* Internal callback function. Used via _gcry_module_lookup. */
static int
gcry_cipher_lookup_func_name (void *spec, void *data)
{
gcry_cipher_spec_t *cipher = (gcry_cipher_spec_t *) spec;
char *name = (char *) data;
const char **aliases = cipher->aliases;
int i, ret = ! stricmp (name, cipher->name);
if (aliases)
for (i = 0; aliases[i] && (! ret); i++)
ret = ! stricmp (name, aliases[i]);
return ret;
}
/* Internal callback function. Used via _gcry_module_lookup. */
static int
gcry_cipher_lookup_func_oid (void *spec, void *data)
{
gcry_cipher_spec_t *cipher = (gcry_cipher_spec_t *) spec;
char *oid = (char *) data;
gcry_cipher_oid_spec_t *oid_specs = cipher->oids;
int ret = 0, i;
if (oid_specs)
for (i = 0; oid_specs[i].oid && (! ret); i++)
if (! stricmp (oid, oid_specs[i].oid))
ret = 1;
return ret;
}
/* Internal function. Lookup a cipher entry by it's name. */
static gcry_module_t
gcry_cipher_lookup_name (const char *name)
{
gcry_module_t cipher;
cipher = _gcry_module_lookup (ciphers_registered, (void *) name,
gcry_cipher_lookup_func_name);
return cipher;
}
/* Internal function. Lookup a cipher entry by it's oid. */
static gcry_module_t
gcry_cipher_lookup_oid (const char *oid)
{
gcry_module_t cipher;
cipher = _gcry_module_lookup (ciphers_registered, (void *) oid,
gcry_cipher_lookup_func_oid);
return cipher;
}
/* Register a new cipher module whose specification can be found in
CIPHER. On success, a new algorithm ID is stored in ALGORITHM_ID
and a pointer representhing this module is stored in MODULE. */
gcry_error_t
_gcry_cipher_register (gcry_cipher_spec_t *cipher,
cipher_extra_spec_t *extraspec,
int *algorithm_id,
gcry_module_t *module)
{
gcry_err_code_t err = 0;
gcry_module_t mod;
/* We do not support module loading in fips mode. */
if (fips_mode ())
return gpg_error (GPG_ERR_NOT_SUPPORTED);
ath_mutex_lock (&ciphers_registered_lock);
err = _gcry_module_add (&ciphers_registered, 0,
(void *)cipher,
(void *)(extraspec? extraspec : &dummy_extra_spec),
&mod);
ath_mutex_unlock (&ciphers_registered_lock);
if (! err)
{
*module = mod;
*algorithm_id = mod->mod_id;
}
return gcry_error (err);
}
/* Unregister the cipher identified by MODULE, which must have been
registered with gcry_cipher_register. */
void
gcry_cipher_unregister (gcry_module_t module)
{
ath_mutex_lock (&ciphers_registered_lock);
_gcry_module_release (module);
ath_mutex_unlock (&ciphers_registered_lock);
}
/* Locate the OID in the oid table and return the index or -1 when not
found. An opitonal "oid." or "OID." prefix in OID is ignored, the
OID is expected to be in standard IETF dotted notation. The
internal algorithm number is returned in ALGORITHM unless it
ispassed as NULL. A pointer to the specification of the module
implementing this algorithm is return in OID_SPEC unless passed as
NULL.*/
static int
search_oid (const char *oid, int *algorithm, gcry_cipher_oid_spec_t *oid_spec)
{
gcry_module_t module;
int ret = 0;
if (oid && ((! strncmp (oid, "oid.", 4))
|| (! strncmp (oid, "OID.", 4))))
oid += 4;
module = gcry_cipher_lookup_oid (oid);
if (module)
{
gcry_cipher_spec_t *cipher = module->spec;
int i;
for (i = 0; cipher->oids[i].oid && !ret; i++)
if (! stricmp (oid, cipher->oids[i].oid))
{
if (algorithm)
*algorithm = module->mod_id;
if (oid_spec)
*oid_spec = cipher->oids[i];
ret = 1;
}
_gcry_module_release (module);
}
return ret;
}
/* Map STRING to the cipher algorithm identifier. Returns the
algorithm ID of the cipher for the given name or 0 if the name is
not known. It is valid to pass NULL for STRING which results in a
return value of 0. */
int
gcry_cipher_map_name (const char *string)
{
gcry_module_t cipher;
int ret, algorithm = 0;
if (! string)
return 0;
REGISTER_DEFAULT_CIPHERS;
/* If the string starts with a digit (optionally prefixed with
either "OID." or "oid."), we first look into our table of ASN.1
object identifiers to figure out the algorithm */
ath_mutex_lock (&ciphers_registered_lock);
ret = search_oid (string, &algorithm, NULL);
if (! ret)
{
cipher = gcry_cipher_lookup_name (string);
if (cipher)
{
algorithm = cipher->mod_id;
_gcry_module_release (cipher);
}
}
ath_mutex_unlock (&ciphers_registered_lock);
return algorithm;
}
/* Given a STRING with an OID in dotted decimal notation, this
function returns the cipher mode (GCRY_CIPHER_MODE_*) associated
with that OID or 0 if no mode is known. Passing NULL for string
yields a return value of 0. */
int
gcry_cipher_mode_from_oid (const char *string)
{
gcry_cipher_oid_spec_t oid_spec;
int ret = 0, mode = 0;
if (!string)
return 0;
ath_mutex_lock (&ciphers_registered_lock);
ret = search_oid (string, NULL, &oid_spec);
if (ret)
mode = oid_spec.mode;
ath_mutex_unlock (&ciphers_registered_lock);
return mode;
}
/* Map the cipher algorithm whose ID is contained in ALGORITHM to a
string representation of the algorithm name. For unknown algorithm
IDs this function returns "?". */
static const char *
cipher_algo_to_string (int algorithm)
{
gcry_module_t cipher;
const char *name;
REGISTER_DEFAULT_CIPHERS;
ath_mutex_lock (&ciphers_registered_lock);
cipher = _gcry_module_lookup_id (ciphers_registered, algorithm);
if (cipher)
{
name = ((gcry_cipher_spec_t *) cipher->spec)->name;
_gcry_module_release (cipher);
}
else
name = "?";
ath_mutex_unlock (&ciphers_registered_lock);
return name;
}
/* Map the cipher algorithm identifier ALGORITHM to a string
representing this algorithm. This string is the default name as
used by Libgcrypt. An pointer to an empty string is returned for
an unknown algorithm. NULL is never returned. */
const char *
gcry_cipher_algo_name (int algorithm)
{
return cipher_algo_to_string (algorithm);
}
/* Flag the cipher algorithm with the identifier ALGORITHM as
disabled. There is no error return, the function does nothing for
unknown algorithms. Disabled algorithms are vitually not available
in Libgcrypt. */
static void
disable_cipher_algo (int algorithm)
{
gcry_module_t cipher;
REGISTER_DEFAULT_CIPHERS;
ath_mutex_lock (&ciphers_registered_lock);
cipher = _gcry_module_lookup_id (ciphers_registered, algorithm);
if (cipher)
{
if (! (cipher->flags & FLAG_MODULE_DISABLED))
cipher->flags |= FLAG_MODULE_DISABLED;
_gcry_module_release (cipher);
}
ath_mutex_unlock (&ciphers_registered_lock);
}
/* Return 0 if the cipher algorithm with identifier ALGORITHM is
available. Returns a basic error code value if it is not
available. */
static gcry_err_code_t
check_cipher_algo (int algorithm)
{
gcry_err_code_t err = GPG_ERR_NO_ERROR;
gcry_module_t cipher;
REGISTER_DEFAULT_CIPHERS;
ath_mutex_lock (&ciphers_registered_lock);
cipher = _gcry_module_lookup_id (ciphers_registered, algorithm);
if (cipher)
{
if (cipher->flags & FLAG_MODULE_DISABLED)
err = GPG_ERR_CIPHER_ALGO;
_gcry_module_release (cipher);
}
else
err = GPG_ERR_CIPHER_ALGO;
ath_mutex_unlock (&ciphers_registered_lock);
return err;
}
/* Return the standard length of the key for the cipher algorithm with
the identifier ALGORITHM. This function expects a valid algorithm
and will abort if the algorithm is not available or the length of
the key is not known. */
static unsigned int
cipher_get_keylen (int algorithm)
{
gcry_module_t cipher;
unsigned len = 0;
REGISTER_DEFAULT_CIPHERS;
ath_mutex_lock (&ciphers_registered_lock);
cipher = _gcry_module_lookup_id (ciphers_registered, algorithm);
if (cipher)
{
len = ((gcry_cipher_spec_t *) cipher->spec)->keylen;
if (!len)
log_bug ("cipher %d w/o key length\n", algorithm);
_gcry_module_release (cipher);
}
else
log_bug ("cipher %d not found\n", algorithm);
ath_mutex_unlock (&ciphers_registered_lock);
return len;
}
/* Return the block length of the cipher algorithm with the identifier
ALGORITHM. This function expects a valid algorithm and will abort
if the algorithm is not available or the length of the key is not
known. */
static unsigned int
cipher_get_blocksize (int algorithm)
{
gcry_module_t cipher;
unsigned len = 0;
REGISTER_DEFAULT_CIPHERS;
ath_mutex_lock (&ciphers_registered_lock);
cipher = _gcry_module_lookup_id (ciphers_registered, algorithm);
if (cipher)
{
len = ((gcry_cipher_spec_t *) cipher->spec)->blocksize;
if (! len)
log_bug ("cipher %d w/o blocksize\n", algorithm);
_gcry_module_release (cipher);
}
else
log_bug ("cipher %d not found\n", algorithm);
ath_mutex_unlock (&ciphers_registered_lock);
return len;
}
/*
Open a cipher handle for use with cipher algorithm ALGORITHM, using
the cipher mode MODE (one of the GCRY_CIPHER_MODE_*) and return a
handle in HANDLE. Put NULL into HANDLE and return an error code if
something goes wrong. FLAGS may be used to modify the
operation. The defined flags are:
GCRY_CIPHER_SECURE: allocate all internal buffers in secure memory.
GCRY_CIPHER_ENABLE_SYNC: Enable the sync operation as used in OpenPGP.
GCRY_CIPHER_CBC_CTS: Enable CTS mode.
GCRY_CIPHER_CBC_MAC: Enable MAC mode.
Values for these flags may be combined using OR.
*/
gcry_error_t
gcry_cipher_open (gcry_cipher_hd_t *handle,
int algo, int mode, unsigned int flags)
{
int secure = (flags & GCRY_CIPHER_SECURE);
gcry_cipher_spec_t *cipher = NULL;
cipher_extra_spec_t *extraspec = NULL;
gcry_module_t module = NULL;
gcry_cipher_hd_t h = NULL;
gcry_err_code_t err = 0;
/* If the application missed to call the random poll function, we do
it here to ensure that it is used once in a while. */
_gcry_fast_random_poll ();
REGISTER_DEFAULT_CIPHERS;
/* Fetch the according module and check whether the cipher is marked
available for use. */
ath_mutex_lock (&ciphers_registered_lock);
module = _gcry_module_lookup_id (ciphers_registered, algo);
if (module)
{
/* Found module. */
if (module->flags & FLAG_MODULE_DISABLED)
{
/* Not available for use. */
err = GPG_ERR_CIPHER_ALGO;
}
else
{
cipher = (gcry_cipher_spec_t *) module->spec;
extraspec = module->extraspec;
}
}
else
err = GPG_ERR_CIPHER_ALGO;
ath_mutex_unlock (&ciphers_registered_lock);
/* check flags */
if ((! err)
&& ((flags & ~(0
| GCRY_CIPHER_SECURE
| GCRY_CIPHER_ENABLE_SYNC
| GCRY_CIPHER_CBC_CTS
| GCRY_CIPHER_CBC_MAC))
|| (flags & GCRY_CIPHER_CBC_CTS & GCRY_CIPHER_CBC_MAC)))
err = GPG_ERR_CIPHER_ALGO;
/* check that a valid mode has been requested */
if (! err)
switch (mode)
{
case GCRY_CIPHER_MODE_ECB:
case GCRY_CIPHER_MODE_CBC:
case GCRY_CIPHER_MODE_CFB:
case GCRY_CIPHER_MODE_OFB:
case GCRY_CIPHER_MODE_CTR:
case GCRY_CIPHER_MODE_AESWRAP:
if ((cipher->encrypt == dummy_encrypt_block)
|| (cipher->decrypt == dummy_decrypt_block))
err = GPG_ERR_INV_CIPHER_MODE;
break;
case GCRY_CIPHER_MODE_STREAM:
if ((cipher->stencrypt == dummy_encrypt_stream)
|| (cipher->stdecrypt == dummy_decrypt_stream))
err = GPG_ERR_INV_CIPHER_MODE;
break;
case GCRY_CIPHER_MODE_NONE:
/* This mode may be used for debugging. It copies the main
text verbatim to the ciphertext. We do not allow this in
fips mode or if no debug flag has been set. */
if (fips_mode () || !_gcry_get_debug_flag (0))
err = GPG_ERR_INV_CIPHER_MODE;
break;
default:
err = GPG_ERR_INV_CIPHER_MODE;
}
/* Perform selftest here and mark this with a flag in cipher_table?
No, we should not do this as it takes too long. Further it does
not make sense to exclude algorithms with failing selftests at
runtime: If a selftest fails there is something seriously wrong
with the system and thus we better die immediately. */
if (! err)
{
size_t size = (sizeof (*h)
+ 2 * cipher->contextsize
- sizeof (cipher_context_alignment_t)
#ifdef NEED_16BYTE_ALIGNED_CONTEXT
+ 15 /* Space for leading alignment gap. */
#endif /*NEED_16BYTE_ALIGNED_CONTEXT*/
);
if (secure)
h = gcry_calloc_secure (1, size);
else
h = gcry_calloc (1, size);
if (! h)
- err = gpg_err_code_from_errno (errno);
+ err = gpg_err_code_from_syserror ();
else
{
size_t off = 0;
#ifdef NEED_16BYTE_ALIGNED_CONTEXT
if ( ((unsigned long)h & 0x0f) )
{
/* The malloced block is not aligned on a 16 byte
boundary. Correct for this. */
off = 16 - ((unsigned long)h & 0x0f);
h = (void*)((char*)h + off);
}
#endif /*NEED_16BYTE_ALIGNED_CONTEXT*/
h->magic = secure ? CTX_MAGIC_SECURE : CTX_MAGIC_NORMAL;
h->actual_handle_size = size - off;
h->handle_offset = off;
h->cipher = cipher;
h->extraspec = extraspec;
h->module = module;
h->algo = algo;
h->mode = mode;
h->flags = flags;
/* Setup bulk encryption routines. */
switch (algo)
{
#ifdef USE_AES
case GCRY_CIPHER_AES128:
case GCRY_CIPHER_AES192:
case GCRY_CIPHER_AES256:
h->bulk.cfb_enc = _gcry_aes_cfb_enc;
h->bulk.cfb_dec = _gcry_aes_cfb_dec;
h->bulk.cbc_enc = _gcry_aes_cbc_enc;
h->bulk.cbc_dec = _gcry_aes_cbc_dec;
h->bulk.ctr_enc = _gcry_aes_ctr_enc;
break;
#endif /*USE_AES*/
default:
break;
}
}
}
/* Done. */
if (err)
{
if (module)
{
/* Release module. */
ath_mutex_lock (&ciphers_registered_lock);
_gcry_module_release (module);
ath_mutex_unlock (&ciphers_registered_lock);
}
}
*handle = err ? NULL : h;
return gcry_error (err);
}
/* Release all resources associated with the cipher handle H. H may be
NULL in which case this is a no-operation. */
void
gcry_cipher_close (gcry_cipher_hd_t h)
{
size_t off;
if (!h)
return;
if ((h->magic != CTX_MAGIC_SECURE)
&& (h->magic != CTX_MAGIC_NORMAL))
_gcry_fatal_error(GPG_ERR_INTERNAL,
"gcry_cipher_close: already closed/invalid handle");
else
h->magic = 0;
/* Release module. */
ath_mutex_lock (&ciphers_registered_lock);
_gcry_module_release (h->module);
ath_mutex_unlock (&ciphers_registered_lock);
/* We always want to wipe out the memory even when the context has
been allocated in secure memory. The user might have disabled
secure memory or is using his own implementation which does not
do the wiping. To accomplish this we need to keep track of the
actual size of this structure because we have no way to known
how large the allocated area was when using a standard malloc. */
off = h->handle_offset;
wipememory (h, h->actual_handle_size);
gcry_free ((char*)h - off);
}
/* Set the key to be used for the encryption context C to KEY with
length KEYLEN. The length should match the required length. */
static gcry_error_t
cipher_setkey (gcry_cipher_hd_t c, byte *key, unsigned int keylen)
{
gcry_err_code_t ret;
ret = (*c->cipher->setkey) (&c->context.c, key, keylen);
if (!ret)
{
/* Duplicate initial context. */
memcpy ((void *) ((char *) &c->context.c + c->cipher->contextsize),
(void *) &c->context.c,
c->cipher->contextsize);
c->marks.key = 1;
}
else
c->marks.key = 0;
return gcry_error (ret);
}
/* Set the IV to be used for the encryption context C to IV with
length IVLEN. The length should match the required length. */
static void
cipher_setiv( gcry_cipher_hd_t c, const byte *iv, unsigned ivlen )
{
memset (c->u_iv.iv, 0, c->cipher->blocksize);
if (iv)
{
if (ivlen != c->cipher->blocksize)
{
log_info ("WARNING: cipher_setiv: ivlen=%u blklen=%u\n",
ivlen, (unsigned int)c->cipher->blocksize);
fips_signal_error ("IV length does not match blocklength");
}
if (ivlen > c->cipher->blocksize)
ivlen = c->cipher->blocksize;
memcpy (c->u_iv.iv, iv, ivlen);
c->marks.iv = 1;
}
else
c->marks.iv = 0;
c->unused = 0;
}
/* Reset the cipher context to the initial context. This is basically
the same as an release followed by a new. */
static void
cipher_reset (gcry_cipher_hd_t c)
{
memcpy (&c->context.c,
(char *) &c->context.c + c->cipher->contextsize,
c->cipher->contextsize);
memset (&c->marks, 0, sizeof c->marks);
memset (c->u_iv.iv, 0, c->cipher->blocksize);
memset (c->lastiv, 0, c->cipher->blocksize);
memset (c->u_ctr.ctr, 0, c->cipher->blocksize);
}
static gcry_err_code_t
do_ecb_encrypt (gcry_cipher_hd_t c,
unsigned char *outbuf, unsigned int outbuflen,
const unsigned char *inbuf, unsigned int inbuflen)
{
unsigned int blocksize = c->cipher->blocksize;
unsigned int n, nblocks;
if (outbuflen < inbuflen)
return GPG_ERR_BUFFER_TOO_SHORT;
if ((inbuflen % blocksize))
return GPG_ERR_INV_LENGTH;
nblocks = inbuflen / c->cipher->blocksize;
for (n=0; n < nblocks; n++ )
{
c->cipher->encrypt (&c->context.c, outbuf, (byte*)/*arggg*/inbuf);
inbuf += blocksize;
outbuf += blocksize;
}
return 0;
}
static gcry_err_code_t
do_ecb_decrypt (gcry_cipher_hd_t c,
unsigned char *outbuf, unsigned int outbuflen,
const unsigned char *inbuf, unsigned int inbuflen)
{
unsigned int blocksize = c->cipher->blocksize;
unsigned int n, nblocks;
if (outbuflen < inbuflen)
return GPG_ERR_BUFFER_TOO_SHORT;
if ((inbuflen % blocksize))
return GPG_ERR_INV_LENGTH;
nblocks = inbuflen / c->cipher->blocksize;
for (n=0; n < nblocks; n++ )
{
c->cipher->decrypt (&c->context.c, outbuf, (byte*)/*arggg*/inbuf );
inbuf += blocksize;
outbuf += blocksize;
}
return 0;
}
static gcry_err_code_t
do_cbc_encrypt (gcry_cipher_hd_t c,
unsigned char *outbuf, unsigned int outbuflen,
const unsigned char *inbuf, unsigned int inbuflen)
{
unsigned int n;
unsigned char *ivp;
int i;
size_t blocksize = c->cipher->blocksize;
unsigned nblocks = inbuflen / blocksize;
if (outbuflen < ((c->flags & GCRY_CIPHER_CBC_MAC)? blocksize : inbuflen))
return GPG_ERR_BUFFER_TOO_SHORT;
if ((inbuflen % c->cipher->blocksize)
&& !(inbuflen > c->cipher->blocksize
&& (c->flags & GCRY_CIPHER_CBC_CTS)))
return GPG_ERR_INV_LENGTH;
if ((c->flags & GCRY_CIPHER_CBC_CTS) && inbuflen > blocksize)
{
if ((inbuflen % blocksize) == 0)
nblocks--;
}
if (c->bulk.cbc_enc)
{
c->bulk.cbc_enc (&c->context.c, c->u_iv.iv, outbuf, inbuf, nblocks,
(c->flags & GCRY_CIPHER_CBC_MAC));
inbuf += nblocks * blocksize;
if (!(c->flags & GCRY_CIPHER_CBC_MAC))
outbuf += nblocks * blocksize;
}
else
{
for (n=0; n < nblocks; n++ )
{
for (ivp=c->u_iv.iv,i=0; i < blocksize; i++ )
outbuf[i] = inbuf[i] ^ *ivp++;
c->cipher->encrypt ( &c->context.c, outbuf, outbuf );
memcpy (c->u_iv.iv, outbuf, blocksize );
inbuf += blocksize;
if (!(c->flags & GCRY_CIPHER_CBC_MAC))
outbuf += blocksize;
}
}
if ((c->flags & GCRY_CIPHER_CBC_CTS) && inbuflen > blocksize)
{
/* We have to be careful here, since outbuf might be equal to
inbuf. */
int restbytes;
unsigned char b;
if ((inbuflen % blocksize) == 0)
restbytes = blocksize;
else
restbytes = inbuflen % blocksize;
outbuf -= blocksize;
for (ivp = c->u_iv.iv, i = 0; i < restbytes; i++)
{
b = inbuf[i];
outbuf[blocksize + i] = outbuf[i];
outbuf[i] = b ^ *ivp++;
}
for (; i < blocksize; i++)
outbuf[i] = 0 ^ *ivp++;
c->cipher->encrypt (&c->context.c, outbuf, outbuf);
memcpy (c->u_iv.iv, outbuf, blocksize);
}
return 0;
}
static gcry_err_code_t
do_cbc_decrypt (gcry_cipher_hd_t c,
unsigned char *outbuf, unsigned int outbuflen,
const unsigned char *inbuf, unsigned int inbuflen)
{
unsigned int n;
unsigned char *ivp;
int i;
size_t blocksize = c->cipher->blocksize;
unsigned int nblocks = inbuflen / blocksize;
if (outbuflen < inbuflen)
return GPG_ERR_BUFFER_TOO_SHORT;
if ((inbuflen % c->cipher->blocksize)
&& !(inbuflen > c->cipher->blocksize
&& (c->flags & GCRY_CIPHER_CBC_CTS)))
return GPG_ERR_INV_LENGTH;
if ((c->flags & GCRY_CIPHER_CBC_CTS) && inbuflen > blocksize)
{
nblocks--;
if ((inbuflen % blocksize) == 0)
nblocks--;
memcpy (c->lastiv, c->u_iv.iv, blocksize);
}
if (c->bulk.cbc_dec)
{
c->bulk.cbc_dec (&c->context.c, c->u_iv.iv, outbuf, inbuf, nblocks);
inbuf += nblocks * blocksize;
outbuf += nblocks * blocksize;
}
else
{
for (n=0; n < nblocks; n++ )
{
/* Because outbuf and inbuf might be the same, we have to
* save the original ciphertext block. We use LASTIV for
* this here because it is not used otherwise. */
memcpy (c->lastiv, inbuf, blocksize);
c->cipher->decrypt ( &c->context.c, outbuf, inbuf );
for (ivp=c->u_iv.iv,i=0; i < blocksize; i++ )
outbuf[i] ^= *ivp++;
memcpy(c->u_iv.iv, c->lastiv, blocksize );
inbuf += c->cipher->blocksize;
outbuf += c->cipher->blocksize;
}
}
if ((c->flags & GCRY_CIPHER_CBC_CTS) && inbuflen > blocksize)
{
int restbytes;
if ((inbuflen % blocksize) == 0)
restbytes = blocksize;
else
restbytes = inbuflen % blocksize;
memcpy (c->lastiv, c->u_iv.iv, blocksize ); /* Save Cn-2. */
memcpy (c->u_iv.iv, inbuf + blocksize, restbytes ); /* Save Cn. */
c->cipher->decrypt ( &c->context.c, outbuf, inbuf );
for (ivp=c->u_iv.iv,i=0; i < restbytes; i++ )
outbuf[i] ^= *ivp++;
memcpy(outbuf + blocksize, outbuf, restbytes);
for(i=restbytes; i < blocksize; i++)
c->u_iv.iv[i] = outbuf[i];
c->cipher->decrypt (&c->context.c, outbuf, c->u_iv.iv);
for(ivp=c->lastiv,i=0; i < blocksize; i++ )
outbuf[i] ^= *ivp++;
/* c->lastiv is now really lastlastiv, does this matter? */
}
return 0;
}
static gcry_err_code_t
do_cfb_encrypt (gcry_cipher_hd_t c,
unsigned char *outbuf, unsigned int outbuflen,
const unsigned char *inbuf, unsigned int inbuflen)
{
unsigned char *ivp;
size_t blocksize = c->cipher->blocksize;
size_t blocksize_x_2 = blocksize + blocksize;
if (outbuflen < inbuflen)
return GPG_ERR_BUFFER_TOO_SHORT;
if ( inbuflen <= c->unused )
{
/* Short enough to be encoded by the remaining XOR mask. */
/* XOR the input with the IV and store input into IV. */
for (ivp=c->u_iv.iv+c->cipher->blocksize - c->unused;
inbuflen;
inbuflen--, c->unused-- )
*outbuf++ = (*ivp++ ^= *inbuf++);
return 0;
}
if ( c->unused )
{
/* XOR the input with the IV and store input into IV */
inbuflen -= c->unused;
for(ivp=c->u_iv.iv+blocksize - c->unused; c->unused; c->unused-- )
*outbuf++ = (*ivp++ ^= *inbuf++);
}
/* Now we can process complete blocks. We use a loop as long as we
have at least 2 blocks and use conditions for the rest. This
also allows to use a bulk encryption function if available. */
if (inbuflen >= blocksize_x_2 && c->bulk.cfb_enc)
{
unsigned int nblocks = inbuflen / blocksize;
c->bulk.cfb_enc (&c->context.c, c->u_iv.iv, outbuf, inbuf, nblocks);
outbuf += nblocks * blocksize;
inbuf += nblocks * blocksize;
inbuflen -= nblocks * blocksize;
}
else
{
while ( inbuflen >= blocksize_x_2 )
{
int i;
/* Encrypt the IV. */
c->cipher->encrypt ( &c->context.c, c->u_iv.iv, c->u_iv.iv );
/* XOR the input with the IV and store input into IV. */
for(ivp=c->u_iv.iv,i=0; i < blocksize; i++ )
*outbuf++ = (*ivp++ ^= *inbuf++);
inbuflen -= blocksize;
}
}
if ( inbuflen >= blocksize )
{
int i;
/* Save the current IV and then encrypt the IV. */
memcpy( c->lastiv, c->u_iv.iv, blocksize );
c->cipher->encrypt ( &c->context.c, c->u_iv.iv, c->u_iv.iv );
/* XOR the input with the IV and store input into IV */
for(ivp=c->u_iv.iv,i=0; i < blocksize; i++ )
*outbuf++ = (*ivp++ ^= *inbuf++);
inbuflen -= blocksize;
}
if ( inbuflen )
{
/* Save the current IV and then encrypt the IV. */
memcpy( c->lastiv, c->u_iv.iv, blocksize );
c->cipher->encrypt ( &c->context.c, c->u_iv.iv, c->u_iv.iv );
c->unused = blocksize;
/* Apply the XOR. */
c->unused -= inbuflen;
for(ivp=c->u_iv.iv; inbuflen; inbuflen-- )
*outbuf++ = (*ivp++ ^= *inbuf++);
}
return 0;
}
static gcry_err_code_t
do_cfb_decrypt (gcry_cipher_hd_t c,
unsigned char *outbuf, unsigned int outbuflen,
const unsigned char *inbuf, unsigned int inbuflen)
{
unsigned char *ivp;
unsigned long temp;
int i;
size_t blocksize = c->cipher->blocksize;
size_t blocksize_x_2 = blocksize + blocksize;
if (outbuflen < inbuflen)
return GPG_ERR_BUFFER_TOO_SHORT;
if (inbuflen <= c->unused)
{
/* Short enough to be encoded by the remaining XOR mask. */
/* XOR the input with the IV and store input into IV. */
for (ivp=c->u_iv.iv+blocksize - c->unused;
inbuflen;
inbuflen--, c->unused--)
{
temp = *inbuf++;
*outbuf++ = *ivp ^ temp;
*ivp++ = temp;
}
return 0;
}
if (c->unused)
{
/* XOR the input with the IV and store input into IV. */
inbuflen -= c->unused;
for (ivp=c->u_iv.iv+blocksize - c->unused; c->unused; c->unused-- )
{
temp = *inbuf++;
*outbuf++ = *ivp ^ temp;
*ivp++ = temp;
}
}
/* Now we can process complete blocks. We use a loop as long as we
have at least 2 blocks and use conditions for the rest. This
also allows to use a bulk encryption function if available. */
if (inbuflen >= blocksize_x_2 && c->bulk.cfb_dec)
{
unsigned int nblocks = inbuflen / blocksize;
c->bulk.cfb_dec (&c->context.c, c->u_iv.iv, outbuf, inbuf, nblocks);
outbuf += nblocks * blocksize;
inbuf += nblocks * blocksize;
inbuflen -= nblocks * blocksize;
}
else
{
while (inbuflen >= blocksize_x_2 )
{
/* Encrypt the IV. */
c->cipher->encrypt ( &c->context.c, c->u_iv.iv, c->u_iv.iv );
/* XOR the input with the IV and store input into IV. */
for (ivp=c->u_iv.iv,i=0; i < blocksize; i++ )
{
temp = *inbuf++;
*outbuf++ = *ivp ^ temp;
*ivp++ = temp;
}
inbuflen -= blocksize;
}
}
if (inbuflen >= blocksize )
{
/* Save the current IV and then encrypt the IV. */
memcpy ( c->lastiv, c->u_iv.iv, blocksize);
c->cipher->encrypt ( &c->context.c, c->u_iv.iv, c->u_iv.iv );
/* XOR the input with the IV and store input into IV */
for (ivp=c->u_iv.iv,i=0; i < blocksize; i++ )
{
temp = *inbuf++;
*outbuf++ = *ivp ^ temp;
*ivp++ = temp;
}
inbuflen -= blocksize;
}
if (inbuflen)
{
/* Save the current IV and then encrypt the IV. */
memcpy ( c->lastiv, c->u_iv.iv, blocksize );
c->cipher->encrypt ( &c->context.c, c->u_iv.iv, c->u_iv.iv );
c->unused = blocksize;
/* Apply the XOR. */
c->unused -= inbuflen;
for (ivp=c->u_iv.iv; inbuflen; inbuflen-- )
{
temp = *inbuf++;
*outbuf++ = *ivp ^ temp;
*ivp++ = temp;
}
}
return 0;
}
static gcry_err_code_t
do_ofb_encrypt (gcry_cipher_hd_t c,
unsigned char *outbuf, unsigned int outbuflen,
const unsigned char *inbuf, unsigned int inbuflen)
{
unsigned char *ivp;
size_t blocksize = c->cipher->blocksize;
if (outbuflen < inbuflen)
return GPG_ERR_BUFFER_TOO_SHORT;
if ( inbuflen <= c->unused )
{
/* Short enough to be encoded by the remaining XOR mask. */
/* XOR the input with the IV */
for (ivp=c->u_iv.iv+c->cipher->blocksize - c->unused;
inbuflen;
inbuflen--, c->unused-- )
*outbuf++ = (*ivp++ ^ *inbuf++);
return 0;
}
if( c->unused )
{
inbuflen -= c->unused;
for(ivp=c->u_iv.iv+blocksize - c->unused; c->unused; c->unused-- )
*outbuf++ = (*ivp++ ^ *inbuf++);
}
/* Now we can process complete blocks. */
while ( inbuflen >= blocksize )
{
int i;
/* Encrypt the IV (and save the current one). */
memcpy( c->lastiv, c->u_iv.iv, blocksize );
c->cipher->encrypt ( &c->context.c, c->u_iv.iv, c->u_iv.iv );
for (ivp=c->u_iv.iv,i=0; i < blocksize; i++ )
*outbuf++ = (*ivp++ ^ *inbuf++);
inbuflen -= blocksize;
}
if ( inbuflen )
{ /* process the remaining bytes */
memcpy( c->lastiv, c->u_iv.iv, blocksize );
c->cipher->encrypt ( &c->context.c, c->u_iv.iv, c->u_iv.iv );
c->unused = blocksize;
c->unused -= inbuflen;
for(ivp=c->u_iv.iv; inbuflen; inbuflen-- )
*outbuf++ = (*ivp++ ^ *inbuf++);
}
return 0;
}
static gcry_err_code_t
do_ofb_decrypt (gcry_cipher_hd_t c,
unsigned char *outbuf, unsigned int outbuflen,
const unsigned char *inbuf, unsigned int inbuflen)
{
unsigned char *ivp;
size_t blocksize = c->cipher->blocksize;
if (outbuflen < inbuflen)
return GPG_ERR_BUFFER_TOO_SHORT;
if( inbuflen <= c->unused )
{
/* Short enough to be encoded by the remaining XOR mask. */
for (ivp=c->u_iv.iv+blocksize - c->unused; inbuflen; inbuflen--,c->unused--)
*outbuf++ = *ivp++ ^ *inbuf++;
return 0;
}
if ( c->unused )
{
inbuflen -= c->unused;
for (ivp=c->u_iv.iv+blocksize - c->unused; c->unused; c->unused-- )
*outbuf++ = *ivp++ ^ *inbuf++;
}
/* Now we can process complete blocks. */
while ( inbuflen >= blocksize )
{
int i;
/* Encrypt the IV (and save the current one). */
memcpy( c->lastiv, c->u_iv.iv, blocksize );
c->cipher->encrypt ( &c->context.c, c->u_iv.iv, c->u_iv.iv );
for (ivp=c->u_iv.iv,i=0; i < blocksize; i++ )
*outbuf++ = *ivp++ ^ *inbuf++;
inbuflen -= blocksize;
}
if ( inbuflen )
{ /* Process the remaining bytes. */
/* Encrypt the IV (and save the current one). */
memcpy( c->lastiv, c->u_iv.iv, blocksize );
c->cipher->encrypt ( &c->context.c, c->u_iv.iv, c->u_iv.iv );
c->unused = blocksize;
c->unused -= inbuflen;
for (ivp=c->u_iv.iv; inbuflen; inbuflen-- )
*outbuf++ = *ivp++ ^ *inbuf++;
}
return 0;
}
static gcry_err_code_t
do_ctr_encrypt (gcry_cipher_hd_t c,
unsigned char *outbuf, unsigned int outbuflen,
const unsigned char *inbuf, unsigned int inbuflen)
{
unsigned int n;
int i;
unsigned int blocksize = c->cipher->blocksize;
unsigned int nblocks;
if (outbuflen < inbuflen)
return GPG_ERR_BUFFER_TOO_SHORT;
/* First process a left over encrypted counter. */
if (c->unused)
{
gcry_assert (c->unused < blocksize);
i = blocksize - c->unused;
for (n=0; c->unused && n < inbuflen; c->unused--, n++, i++)
{
/* XOR input with encrypted counter and store in output. */
outbuf[n] = inbuf[n] ^ c->lastiv[i];
}
inbuf += n;
outbuf += n;
inbuflen -= n;
}
/* Use a bulk method if available. */
nblocks = inbuflen / blocksize;
if (nblocks && c->bulk.ctr_enc)
{
c->bulk.ctr_enc (&c->context.c, c->u_ctr.ctr, outbuf, inbuf, nblocks);
inbuf += nblocks * blocksize;
outbuf += nblocks * blocksize;
inbuflen -= nblocks * blocksize;
}
/* If we don't have a bulk method use the standard method. We also
use this method for the a remaining partial block. */
if (inbuflen)
{
unsigned char tmp[MAX_BLOCKSIZE];
for (n=0; n < inbuflen; n++)
{
if ((n % blocksize) == 0)
{
c->cipher->encrypt (&c->context.c, tmp, c->u_ctr.ctr);
for (i = blocksize; i > 0; i--)
{
c->u_ctr.ctr[i-1]++;
if (c->u_ctr.ctr[i-1] != 0)
break;
}
}
/* XOR input with encrypted counter and store in output. */
outbuf[n] = inbuf[n] ^ tmp[n % blocksize];
}
/* Save the unused bytes of the counter. */
n %= blocksize;
c->unused = (blocksize - n) % blocksize;
if (c->unused)
memcpy (c->lastiv+n, tmp+n, c->unused);
wipememory (tmp, sizeof tmp);
}
return 0;
}
static gcry_err_code_t
do_ctr_decrypt (gcry_cipher_hd_t c,
unsigned char *outbuf, unsigned int outbuflen,
const unsigned char *inbuf, unsigned int inbuflen)
{
return do_ctr_encrypt (c, outbuf, outbuflen, inbuf, inbuflen);
}
/* Perform the AES-Wrap algorithm as specified by RFC3394. We
implement this as a mode usable with any cipher algorithm of
blocksize 128. */
static gcry_err_code_t
do_aeswrap_encrypt (gcry_cipher_hd_t c, byte *outbuf, unsigned int outbuflen,
const byte *inbuf, unsigned int inbuflen )
{
int j, x;
unsigned int n, i;
unsigned char *r, *a, *b;
unsigned char t[8];
#if MAX_BLOCKSIZE < 8
#error Invalid block size
#endif
/* We require a cipher with a 128 bit block length. */
if (c->cipher->blocksize != 16)
return GPG_ERR_INV_LENGTH;
/* The output buffer must be able to hold the input data plus one
additional block. */
if (outbuflen < inbuflen + 8)
return GPG_ERR_BUFFER_TOO_SHORT;
/* Input data must be multiple of 64 bits. */
if (inbuflen % 8)
return GPG_ERR_INV_ARG;
n = inbuflen / 8;
/* We need at least two 64 bit blocks. */
if (n < 2)
return GPG_ERR_INV_ARG;
r = outbuf;
a = outbuf; /* We store A directly in OUTBUF. */
b = c->u_ctr.ctr; /* B is also used to concatenate stuff. */
/* If an IV has been set we use that IV as the Alternative Initial
Value; if it has not been set we use the standard value. */
if (c->marks.iv)
memcpy (a, c->u_iv.iv, 8);
else
memset (a, 0xa6, 8);
/* Copy the inbuf to the outbuf. */
memmove (r+8, inbuf, inbuflen);
memset (t, 0, sizeof t); /* t := 0. */
for (j = 0; j <= 5; j++)
{
for (i = 1; i <= n; i++)
{
/* B := AES_k( A | R[i] ) */
memcpy (b, a, 8);
memcpy (b+8, r+i*8, 8);
c->cipher->encrypt (&c->context.c, b, b);
/* t := t + 1 */
for (x = 7; x >= 0; x--)
{
t[x]++;
if (t[x])
break;
}
/* A := MSB_64(B) ^ t */
for (x=0; x < 8; x++)
a[x] = b[x] ^ t[x];
/* R[i] := LSB_64(B) */
memcpy (r+i*8, b+8, 8);
}
}
return 0;
}
/* Perform the AES-Unwrap algorithm as specified by RFC3394. We
implement this as a mode usable with any cipher algorithm of
blocksize 128. */
static gcry_err_code_t
do_aeswrap_decrypt (gcry_cipher_hd_t c, byte *outbuf, unsigned int outbuflen,
const byte *inbuf, unsigned int inbuflen)
{
int j, x;
unsigned int n, i;
unsigned char *r, *a, *b;
unsigned char t[8];
#if MAX_BLOCKSIZE < 8
#error Invalid block size
#endif
/* We require a cipher with a 128 bit block length. */
if (c->cipher->blocksize != 16)
return GPG_ERR_INV_LENGTH;
/* The output buffer must be able to hold the input data minus one
additional block. Fixme: The caller has more restrictive checks
- we may want to fix them for this mode. */
if (outbuflen + 8 < inbuflen)
return GPG_ERR_BUFFER_TOO_SHORT;
/* Input data must be multiple of 64 bits. */
if (inbuflen % 8)
return GPG_ERR_INV_ARG;
n = inbuflen / 8;
/* We need at least three 64 bit blocks. */
if (n < 3)
return GPG_ERR_INV_ARG;
r = outbuf;
a = c->lastiv; /* We use c->LASTIV as buffer for A. */
b = c->u_ctr.ctr; /* B is also used to concatenate stuff. */
/* Copy the inbuf to the outbuf and save A. */
memcpy (a, inbuf, 8);
memmove (r, inbuf+8, inbuflen-8);
n--; /* Reduce to actual number of data blocks. */
/* t := 6 * n */
i = n * 6; /* The range is valid because: n = inbuflen / 8 - 1. */
for (x=0; x < 8 && x < sizeof (i); x++)
t[7-x] = i >> (8*x);
for (; x < 8; x++)
t[7-x] = 0;
for (j = 5; j >= 0; j--)
{
for (i = n; i >= 1; i--)
{
/* B := AES_k^1( (A ^ t)| R[i] ) */
for (x = 0; x < 8; x++)
b[x] = a[x] ^ t[x];
memcpy (b+8, r+(i-1)*8, 8);
c->cipher->decrypt (&c->context.c, b, b);
/* t := t - 1 */
for (x = 7; x >= 0; x--)
{
t[x]--;
if (t[x] != 0xff)
break;
}
/* A := MSB_64(B) */
memcpy (a, b, 8);
/* R[i] := LSB_64(B) */
memcpy (r+(i-1)*8, b+8, 8);
}
}
/* If an IV has been set we compare against this Alternative Initial
Value; if it has not been set we compare against the standard IV. */
if (c->marks.iv)
j = memcmp (a, c->u_iv.iv, 8);
else
{
for (j=0, x=0; x < 8; x++)
if (a[x] != 0xa6)
{
j=1;
break;
}
}
return j? GPG_ERR_CHECKSUM : 0;
}
/****************
* Encrypt INBUF to OUTBUF with the mode selected at open.
* inbuf and outbuf may overlap or be the same.
* Depending on the mode some constraints apply to INBUFLEN.
*/
static gcry_err_code_t
cipher_encrypt (gcry_cipher_hd_t c, byte *outbuf, unsigned int outbuflen,
const byte *inbuf, unsigned int inbuflen)
{
gcry_err_code_t rc;
switch (c->mode)
{
case GCRY_CIPHER_MODE_ECB:
rc = do_ecb_encrypt (c, outbuf, outbuflen, inbuf, inbuflen);
break;
case GCRY_CIPHER_MODE_CBC:
rc = do_cbc_encrypt (c, outbuf, outbuflen, inbuf, inbuflen);
break;
case GCRY_CIPHER_MODE_CFB:
rc = do_cfb_encrypt (c, outbuf, outbuflen, inbuf, inbuflen);
break;
case GCRY_CIPHER_MODE_OFB:
rc = do_ofb_encrypt (c, outbuf, outbuflen, inbuf, inbuflen);
break;
case GCRY_CIPHER_MODE_CTR:
rc = do_ctr_encrypt (c, outbuf, outbuflen, inbuf, inbuflen);
break;
case GCRY_CIPHER_MODE_AESWRAP:
rc = do_aeswrap_encrypt (c, outbuf, outbuflen, inbuf, inbuflen);
break;
case GCRY_CIPHER_MODE_STREAM:
c->cipher->stencrypt (&c->context.c,
outbuf, (byte*)/*arggg*/inbuf, inbuflen);
rc = 0;
break;
case GCRY_CIPHER_MODE_NONE:
if (fips_mode () || !_gcry_get_debug_flag (0))
{
fips_signal_error ("cipher mode NONE used");
rc = GPG_ERR_INV_CIPHER_MODE;
}
else
{
if (inbuf != outbuf)
memmove (outbuf, inbuf, inbuflen);
rc = 0;
}
break;
default:
log_fatal ("cipher_encrypt: invalid mode %d\n", c->mode );
rc = GPG_ERR_INV_CIPHER_MODE;
break;
}
return rc;
}
/****************
* Encrypt IN and write it to OUT. If IN is NULL, in-place encryption has
* been requested.
*/
gcry_error_t
gcry_cipher_encrypt (gcry_cipher_hd_t h, void *out, size_t outsize,
const void *in, size_t inlen)
{
gcry_err_code_t err;
if (!in) /* Caller requested in-place encryption. */
err = cipher_encrypt (h, out, outsize, out, outsize);
else
err = cipher_encrypt (h, out, outsize, in, inlen);
/* Failsafe: Make sure that the plaintext will never make it into
OUT if the encryption returned an error. */
if (err && out)
memset (out, 0x42, outsize);
return gcry_error (err);
}
/****************
* Decrypt INBUF to OUTBUF with the mode selected at open.
* inbuf and outbuf may overlap or be the same.
* Depending on the mode some some contraints apply to INBUFLEN.
*/
static gcry_err_code_t
cipher_decrypt (gcry_cipher_hd_t c, byte *outbuf, unsigned int outbuflen,
const byte *inbuf, unsigned int inbuflen)
{
gcry_err_code_t rc;
switch (c->mode)
{
case GCRY_CIPHER_MODE_ECB:
rc = do_ecb_decrypt (c, outbuf, outbuflen, inbuf, inbuflen);
break;
case GCRY_CIPHER_MODE_CBC:
rc = do_cbc_decrypt (c, outbuf, outbuflen, inbuf, inbuflen);
break;
case GCRY_CIPHER_MODE_CFB:
rc = do_cfb_decrypt (c, outbuf, outbuflen, inbuf, inbuflen);
break;
case GCRY_CIPHER_MODE_OFB:
rc = do_ofb_decrypt (c, outbuf, outbuflen, inbuf, inbuflen);
break;
case GCRY_CIPHER_MODE_CTR:
rc = do_ctr_decrypt (c, outbuf, outbuflen, inbuf, inbuflen);
break;
case GCRY_CIPHER_MODE_AESWRAP:
rc = do_aeswrap_decrypt (c, outbuf, outbuflen, inbuf, inbuflen);
break;
case GCRY_CIPHER_MODE_STREAM:
c->cipher->stdecrypt (&c->context.c,
outbuf, (byte*)/*arggg*/inbuf, inbuflen);
rc = 0;
break;
case GCRY_CIPHER_MODE_NONE:
if (fips_mode () || !_gcry_get_debug_flag (0))
{
fips_signal_error ("cipher mode NONE used");
rc = GPG_ERR_INV_CIPHER_MODE;
}
else
{
if (inbuf != outbuf)
memmove (outbuf, inbuf, inbuflen);
rc = 0;
}
break;
default:
log_fatal ("cipher_decrypt: invalid mode %d\n", c->mode );
rc = GPG_ERR_INV_CIPHER_MODE;
break;
}
return rc;
}
gcry_error_t
gcry_cipher_decrypt (gcry_cipher_hd_t h, void *out, size_t outsize,
const void *in, size_t inlen)
{
gcry_err_code_t err;
if (!in) /* Caller requested in-place encryption. */
err = cipher_decrypt (h, out, outsize, out, outsize);
else
err = cipher_decrypt (h, out, outsize, in, inlen);
return gcry_error (err);
}
/****************
* Used for PGP's somewhat strange CFB mode. Only works if
* the corresponding flag is set.
*/
static void
cipher_sync (gcry_cipher_hd_t c)
{
if ((c->flags & GCRY_CIPHER_ENABLE_SYNC) && c->unused)
{
memmove (c->u_iv.iv + c->unused,
c->u_iv.iv, c->cipher->blocksize - c->unused);
memcpy (c->u_iv.iv,
c->lastiv + c->cipher->blocksize - c->unused, c->unused);
c->unused = 0;
}
}
gcry_error_t
_gcry_cipher_setkey (gcry_cipher_hd_t hd, const void *key, size_t keylen)
{
return cipher_setkey (hd, (void*)key, keylen);
}
gcry_error_t
_gcry_cipher_setiv (gcry_cipher_hd_t hd, const void *iv, size_t ivlen)
{
cipher_setiv (hd, iv, ivlen);
return 0;
}
/* Set counter for CTR mode. (CTR,CTRLEN) must denote a buffer of
block size length, or (NULL,0) to set the CTR to the all-zero
block. */
gpg_error_t
_gcry_cipher_setctr (gcry_cipher_hd_t hd, const void *ctr, size_t ctrlen)
{
if (ctr && ctrlen == hd->cipher->blocksize)
{
memcpy (hd->u_ctr.ctr, ctr, hd->cipher->blocksize);
hd->unused = 0;
}
else if (!ctr || !ctrlen)
{
memset (hd->u_ctr.ctr, 0, hd->cipher->blocksize);
hd->unused = 0;
}
else
return gpg_error (GPG_ERR_INV_ARG);
return 0;
}
gcry_error_t
gcry_cipher_ctl( gcry_cipher_hd_t h, int cmd, void *buffer, size_t buflen)
{
gcry_err_code_t rc = GPG_ERR_NO_ERROR;
switch (cmd)
{
case GCRYCTL_SET_KEY: /* Deprecated; use gcry_cipher_setkey. */
rc = cipher_setkey( h, buffer, buflen );
break;
case GCRYCTL_SET_IV: /* Deprecated; use gcry_cipher_setiv. */
cipher_setiv( h, buffer, buflen );
break;
case GCRYCTL_RESET:
cipher_reset (h);
break;
case GCRYCTL_CFB_SYNC:
cipher_sync( h );
break;
case GCRYCTL_SET_CBC_CTS:
if (buflen)
if (h->flags & GCRY_CIPHER_CBC_MAC)
rc = GPG_ERR_INV_FLAG;
else
h->flags |= GCRY_CIPHER_CBC_CTS;
else
h->flags &= ~GCRY_CIPHER_CBC_CTS;
break;
case GCRYCTL_SET_CBC_MAC:
if (buflen)
if (h->flags & GCRY_CIPHER_CBC_CTS)
rc = GPG_ERR_INV_FLAG;
else
h->flags |= GCRY_CIPHER_CBC_MAC;
else
h->flags &= ~GCRY_CIPHER_CBC_MAC;
break;
case GCRYCTL_DISABLE_ALGO:
/* This command expects NULL for H and BUFFER to point to an
integer with the algo number. */
if( h || !buffer || buflen != sizeof(int) )
return gcry_error (GPG_ERR_CIPHER_ALGO);
disable_cipher_algo( *(int*)buffer );
break;
case GCRYCTL_SET_CTR: /* Deprecated; use gcry_cipher_setctr. */
rc = gpg_err_code (_gcry_cipher_setctr (h, buffer, buflen));
break;
case 61: /* Disable weak key detection (private). */
if (h->extraspec->set_extra_info)
rc = h->extraspec->set_extra_info
(&h->context.c, CIPHER_INFO_NO_WEAK_KEY, NULL, 0);
else
rc = GPG_ERR_NOT_SUPPORTED;
break;
case 62: /* Return current input vector (private). */
/* This is the input block as used in CFB and OFB mode which has
initially been set as IV. The returned format is:
1 byte Actual length of the block in bytes.
n byte The block.
If the provided buffer is too short, an error is returned. */
if (buflen < (1 + h->cipher->blocksize))
rc = GPG_ERR_TOO_SHORT;
else
{
unsigned char *ivp;
unsigned char *dst = buffer;
int n = h->unused;
if (!n)
n = h->cipher->blocksize;
gcry_assert (n <= h->cipher->blocksize);
*dst++ = n;
ivp = h->u_iv.iv + h->cipher->blocksize - n;
while (n--)
*dst++ = *ivp++;
}
break;
default:
rc = GPG_ERR_INV_OP;
}
return gcry_error (rc);
}
/* Return information about the cipher handle H. CMD is the kind of
information requested. BUFFER and NBYTES are reserved for now.
There are no values for CMD yet defined.
The function always returns GPG_ERR_INV_OP.
*/
gcry_error_t
gcry_cipher_info (gcry_cipher_hd_t h, int cmd, void *buffer, size_t *nbytes)
{
gcry_err_code_t err = GPG_ERR_NO_ERROR;
(void)h;
(void)buffer;
(void)nbytes;
switch (cmd)
{
default:
err = GPG_ERR_INV_OP;
}
return gcry_error (err);
}
/* Return information about the given cipher algorithm ALGO.
WHAT select the kind of information returned:
GCRYCTL_GET_KEYLEN:
Return the length of the key. If the algorithm ALGO
supports multiple key lengths, the maximum supported key length
is returned. The key length is returned as number of octets.
BUFFER and NBYTES must be zero.
GCRYCTL_GET_BLKLEN:
Return the blocklength of the algorithm ALGO counted in octets.
BUFFER and NBYTES must be zero.
GCRYCTL_TEST_ALGO:
Returns 0 if the specified algorithm ALGO is available for use.
BUFFER and NBYTES must be zero.
Note: Because this function is in most cases used to return an
integer value, we can make it easier for the caller to just look at
the return value. The caller will in all cases consult the value
and thereby detecting whether a error occurred or not (i.e. while
checking the block size)
*/
gcry_error_t
gcry_cipher_algo_info (int algo, int what, void *buffer, size_t *nbytes)
{
gcry_err_code_t err = GPG_ERR_NO_ERROR;
unsigned int ui;
switch (what)
{
case GCRYCTL_GET_KEYLEN:
if (buffer || (! nbytes))
err = GPG_ERR_CIPHER_ALGO;
else
{
ui = cipher_get_keylen (algo);
if ((ui > 0) && (ui <= 512))
*nbytes = (size_t) ui / 8;
else
/* The only reason is an invalid algo or a strange
blocksize. */
err = GPG_ERR_CIPHER_ALGO;
}
break;
case GCRYCTL_GET_BLKLEN:
if (buffer || (! nbytes))
err = GPG_ERR_CIPHER_ALGO;
else
{
ui = cipher_get_blocksize (algo);
if ((ui > 0) && (ui < 10000))
*nbytes = ui;
else
/* The only reason is an invalid algo or a strange
blocksize. */
err = GPG_ERR_CIPHER_ALGO;
}
break;
case GCRYCTL_TEST_ALGO:
if (buffer || nbytes)
err = GPG_ERR_INV_ARG;
else
err = check_cipher_algo (algo);
break;
default:
err = GPG_ERR_INV_OP;
}
return gcry_error (err);
}
/* This function returns length of the key for algorithm ALGO. If the
algorithm supports multiple key lengths, the maximum supported key
length is returned. On error 0 is returned. The key length is
returned as number of octets.
This is a convenience functions which should be preferred over
gcry_cipher_algo_info because it allows for proper type
checking. */
size_t
gcry_cipher_get_algo_keylen (int algo)
{
size_t n;
if (gcry_cipher_algo_info (algo, GCRYCTL_GET_KEYLEN, NULL, &n))
n = 0;
return n;
}
/* This functions returns the blocklength of the algorithm ALGO
counted in octets. On error 0 is returned.
This is a convenience functions which should be preferred over
gcry_cipher_algo_info because it allows for proper type
checking. */
size_t
gcry_cipher_get_algo_blklen (int algo)
{
size_t n;
if (gcry_cipher_algo_info( algo, GCRYCTL_GET_BLKLEN, NULL, &n))
n = 0;
return n;
}
/* Explicitly initialize this module. */
gcry_err_code_t
_gcry_cipher_init (void)
{
gcry_err_code_t err = GPG_ERR_NO_ERROR;
REGISTER_DEFAULT_CIPHERS;
return err;
}
/* Get a list consisting of the IDs of the loaded cipher modules. If
LIST is zero, write the number of loaded cipher modules to
LIST_LENGTH and return. If LIST is non-zero, the first
*LIST_LENGTH algorithm IDs are stored in LIST, which must be of
according size. In case there are less cipher modules than
*LIST_LENGTH, *LIST_LENGTH is updated to the correct number. */
gcry_error_t
gcry_cipher_list (int *list, int *list_length)
{
gcry_err_code_t err = GPG_ERR_NO_ERROR;
ath_mutex_lock (&ciphers_registered_lock);
err = _gcry_module_list (ciphers_registered, list, list_length);
ath_mutex_unlock (&ciphers_registered_lock);
return err;
}
/* Run the selftests for cipher algorithm ALGO with optional reporting
function REPORT. */
gpg_error_t
_gcry_cipher_selftest (int algo, int extended, selftest_report_func_t report)
{
gcry_module_t module = NULL;
cipher_extra_spec_t *extraspec = NULL;
gcry_err_code_t ec = 0;
REGISTER_DEFAULT_CIPHERS;
ath_mutex_lock (&ciphers_registered_lock);
module = _gcry_module_lookup_id (ciphers_registered, algo);
if (module && !(module->flags & FLAG_MODULE_DISABLED))
extraspec = module->extraspec;
ath_mutex_unlock (&ciphers_registered_lock);
if (extraspec && extraspec->selftest)
ec = extraspec->selftest (algo, extended, report);
else
{
ec = GPG_ERR_CIPHER_ALGO;
if (report)
report ("cipher", algo, "module",
module && !(module->flags & FLAG_MODULE_DISABLED)?
"no selftest available" :
module? "algorithm disabled" : "algorithm not found");
}
if (module)
{
ath_mutex_lock (&ciphers_registered_lock);
_gcry_module_release (module);
ath_mutex_unlock (&ciphers_registered_lock);
}
return gpg_error (ec);
}
diff --git a/src/ChangeLog b/src/ChangeLog
index 9476e82e..2907e854 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,2292 +1,2299 @@
+2011-04-19 Werner Koch <wk@g10code.com>
+
+ * stdmem.c (_gcry_private_malloc_secure, _gcry_private_malloc):
+ Set ERRNO on failure.
+ * secmem.c (mb_get_new): Set ERRNO on failure.
+ (_gcry_secmem_malloc_internal): Ditto.
+
2011-04-01 Werner Koch <wk@g10code.com>
* global.c (gcry_realloc): Divert to gcry_malloc or gcry_free.
2011-03-09 Werner Koch <wk@g10code.com>
* gcrypt.h.in (gcry_kdf_algos): New.
(gcry_kdf_derive): New.
* visibility.c (gcry_kdf_derive): New.
* visibility.h, libgcrypt.vers, libgcrypt.def: Add gcry_kdf_derive.
2011-02-23 Werner Koch <wk@g10code.com>
* libgcrypt-config.in: Add option --host.
* libgcrypt.m4: Use AC_PROG_TOOL to find the config script. Print
a warning is the config scripts does not match the configure host.
2011-02-21 Werner Koch <wk@g10code.com>
* global.c (gcry_check_version): Do not take the patchlevel in
account; it is not well defined.
2011-02-17 Werner Koch <wk@g10code.com>
* gcrypt-module.h (gcry_cipher_register, gcry_cipher_unregister)
(gcry_pk_register, gcry_pk_unregister, gcry_md_register)
(gcry_md_unregister): Mark as deprecated by the API; in a future
version the module register feature will be removed.
* gcrypt.h.in: Attribute all _ac_ functions and types as
deprecated by the API.
* hwfeatures.c (detect_ia32_gnuc): Fix AES-NI detection. Use AND
instead of SUB for bit testing.
2011-02-16 Werner Koch <wk@g10code.com>
* gcrypt.h.in (GCRYCTL_DISABLE_HWF): New.
* global.c (_gcry_vcontrol): Support new control code.
(print_config): Factor list of hwfeatures out to ...
(hwflist): new.
(disabled_hw_features): New.
(global_init): Pass new variable to _gcry_detect_hw_features.
* hwfeatures.c (_gcry_detect_hw_features): Add arg
DISABLED_FEATURES and disable detected features.
2011-02-11 Werner Koch <wk@g10code.com>
* g10lib.h (HWF_INTEL_AES): Rename to HWF_INTEL_AESNI.
* hwfeatures.c (detect_ia32_gnuc): Fix setting of this flag.
2011-02-01 Werner Koch <wk@g10code.com>
* gcrypt.h.in (gcry_pk_get_curve, gcry_pk_get_param): New.
* libgcrypt.vers (gcry_pk_get_curve, gcry_pk_get_param): Add.
* libgcrypt.def (gcry_pk_get_curve, gcry_pk_get_param): Add.
* visibility.c (gcry_pk_get_curve, gcry_pk_get_param): New.
* cipher-proto.h (pk_extra_spec): Add fields GET_CURVE and
GET_CURVE_PARM.
2011-01-31 Werner Koch <wk@g10code.com>
* sexp.c (vsexp_sscan): Allow opaque MPIs in "%m".
2010-08-27 Werner Koch <wk@g10code.com>
* g10lib.h (HWF_INTEL_AES): New.
* global.c (print_config): Print new flag.
* hwfeatures.c (detect_ia32_gnuc): Detect this flag.
2010-08-16 Werner Koch <wk@g10code.com>
* gcrypt.h.in [!WIN32]: Add INSERT_SYS_SELECT_H autoconf substitute.
2010-07-09 Werner Koch <wk@g10code.com>
* gcrypt.h.in [!__GNUC__ && W32]: Typedef ssize_t and pid_t to
help building with MSVC.
2010-06-24 Werner Koch <wk@g10code.com>
* gcrypt.h.in [W32]: Include time.h and not sys/time.h.
2010-04-19 Marcus Brinkmann <marcus@g10code.de>
* misc.c (write2stderr): Dummy variable to silence gcc warning.
2010-04-16 Marcus Brinkmann <marcus@g10code.de>
* sexp.c: (sexp_sscan): Make it variable length, and rename the
old version to ...
(vsexp_sscan): ... this new function. Also swap last two arguments.
(gcry_sexp_create): Remove dummy va_list.
(gcry_sexp_build): Use vsexp_sscan instead of sexp_sscan.
(_gcry_sexp_vbuild): Likewise.
(gcry_sexp_build_array): Remove dummy va_list.
(gcry_sexp_sscan): Likewise.
2010-04-12 Brad Hards <bradh@frogmouth.net> (wk)
Spelling fixes.
2010-03-15 Werner Koch <wk@g10code.com>
* gcrypt.h.in: Add autoconf template to set generated file to
read-only in an Emacs buffer.
2010-01-21 Werner Koch <wk@g10code.com>
* Makefile.am (arch_gpg_error_cflags, arch_gpg_error_libs): New.
(dumpsexp_CFLAGS): New.
(dumpsexp_LDADD): Add arch_gpg_error_libs.
(hmac256_CFLAGS, hmac256_LDADD): Add the arch variables.
(libgcrypt_la_DEPENDENCIES): Add libcompat.
* secmem.c (lock_pool): Mark unused args.
* global.c (do_malloc, gcry_realloc, gcry_free, gcry_calloc)
(gcry_calloc_secure, gcry_xcalloc, gcry_xcalloc_secure): Use
gpg_err_set_errno.
(_gcry_vcontrol): Call _gcry_compat_identification.
* hmac256.c [__MINGW32CE__]: Include gpg-error.h.
(_gcry_hmac256_file): Use gpg_err_set_errno.
(gpg_err_set_errno) [!GPG_ERR_INLINE]: Add macro.
* g10lib.h: Include libcompat.h.
2010-01-05 Werner Koch <wk@g10code.com>
* gcrypt.h.in (GCRY_PK_ECDH): New.
2009-12-08 Werner Koch <wk@g10code.com>
* gcrypt.h.in (GCRY_CIPHER_MODE_AESWRAP): New.
2009-12-08 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am (LTRCCOMPILE): Refactor with ...
(RCCOMPILE): ... this new macro. Add $(libgcrypt_la_CPPFLAGS).
(SUFFIXES): Add .lo.
(.rc.o): Change to ...
(.rc.lo): ... this implicit rule.
(gcrypt_res_ldflag): Removed.
(gcrypt_res): Use libtool object file name here.
(libgcrypt_la_LDFLAGS): Remove gcrypt_res_ldflag usage.
(libgcrypt_la_LIBADD): Add gcrypt_res.
2009-11-29 Werner Koch <wk@g10code.com>
* hwfeatures.c (detect_ia32_gnuc): Repalce "=r" by "+r" so that
HAS-CPUDID is always initialized. Thanks to Ben Hutchings for
pointing out this problem.
2009-08-05 Werner Koch <wk@g10code.com>
* ath.h: Include sys/msg.h.
2009-07-02 Werner Koch <wk@g10code.com>
* fips.c (_gcry_initialize_fips_mode): Do not use FIPS mode if
/proc/.../fips_enabled has insufficient permissions.
* dumpsexp.c (main): Fix handling multiple files.
(parse_and_print): Implement hex and octal escaping.
* sexp.c (unquote_string): Remove superfluous clearing of ESC.
* dumpsexp.c (parse_and_print): Add missing break.
(main): Fix return value.
Reported by Fabian Keil.
2009-02-16 Werner Koch <wk@g10code.com>
* ath.h [HAVE_SYS_SELECT_H]: Include <sys/select.h> for fd_set.
[!HAVE_SYS_SELECT_H]: Include <sys/time.h>. Move inclusion of
config.h to the top. The actual configure check was already
there.
* sexp.c: Remove memory.h.
* mpi.h: Remove memory.h. Add string.h.
2009-02-02 Werner Koch <wk@g10code.com>
* ath.h: Include sys/time.h. Fixes bug#993.
2009-01-22 Werner Koch <wk@g10code.com>
* fips.c (_gcry_initialize_fips_mode): Remove superfluous const
from static string. Reported by Albert Chin.
* hmac256.c (selftest): Ditto and change to unsigned char.
2008-12-10 Werner Koch <wk@g10code.com>
* hmac256.c (finalize): Fix for big endian hosts.
2008-12-05 Werner Koch <wk@g10code.com>
* global.c (gcry_free): Save and restore ERRNO if set.
2008-11-24 Werner Koch <wk@g10code.com>
* sexp.c (get_internal_buffer): New.
(sexp_sscan): Add format character S.
* cipher-proto.h (pk_ext_generate_t): Add field EXTRAINFO changed
all implementors.
* cipher-proto.h (pk_ext_generate_t): Simplify.
(pk_get_param): New.
(pk_extra_spec_t): Add field GET_PARAM.
* cipher.h (PUBKEY_FLAG_TRANSIENT_KEY): Remove.
(_gcry_pubkey_extraspec_elg): New.
2008-11-05 Werner Koch <wk@g10code.com>
* cipher.h (CIPHER_INFO_NO_WEAK_KEY): New.
* cipher-proto.h (cipher_set_extra_info_t): New.
(cipher_extra_spec): Add field SET_EXTRA_INFO.
2008-10-30 Werner Koch <wk@g10code.com>
* g10lib.h (GCC_ATTR_FORMAT_ARG): New.
(_gcry_gettext): Use it.
2008-10-24 Werner Koch <wk@g10code.com>
* global.c (inactive_fips_mode): Move to fips.c.
(gcry_set_allocation_handler): Factor code out to ...
* fips.c (_gcry_inactivate_fips_mode): New.
(_gcry_is_fips_mode_inactive): New.
2008-09-29 Werner Koch <wk@g10code.com>
* gcrypt-module.h (GCRY_MODULE_ID_USER, GCRY_MODULE_ID_USER_LAST):
New.
* module.c (MODULE_ID_USER, MODULE_ID_USER_LAST): Define using new
macros.
2008-09-20 Werner Koch <wk@g10code.com>
* hmac256.c (finalize) [WORDS_BIGENDIAN]: Fix sigbus problem.
2008-09-18 Werner Koch <wk@g10code.com>
* cipher-proto.h (pk_ext_generate_t): Add args QBITS, NAME, DOMAIN.
* fips.c (fips_new_state): Allow Error => Error transition.
2008-09-18 Werner Koch <wk@g10code.com>
* gcrypt.h.in (gcry_fips_mode_active): New.
* secmem.c (_gcry_secmem_init): Factor most code out to ..
(secmem_init): .. new.
(DEFAULT_POOL_SIZE): Rename to MINIMUM_POOL_SIZE.
(STANDARD_POOL_SIZE): New.
(_gcry_secmem_malloc_internal): Don't abort if the pool is not
initialized but try to out intialize it first and only then print
an error message and return NULL. If the pool is not locked while
in FIPS mode, return NULL.
* fips.c (FIPS_FORCE_FILE): New constant. Change the file name to
"/etc/gcrypt/fips_enabled".
(enforced_fips_mode): New.
(_gcry_initialize_fips_mode): Set that flag.
(_gcry_enforced_fips_mode): New.
* global.c (inactive_fips_mode): New.
(_gcry_vcontrol): Take that flag in account for GCRYCTL_FIPS_MODE_P.
(gcry_set_allocation_handler): Take care of the enforced fips mdoe
flag.
(get_no_secure_memory): New.
(do_malloc, gcry_is_secure): Use it.
2008-09-16 Werner Koch <wk@g10code.com>
* global.c (print_config): Use y/n for fips mode.
* fips.c (fips_new_state): Allow transition to Error and
Fatal-error from Init.
2008-09-15 Werner Koch <wk@g10code.com>
* fips.c [HAVE_SYSLOG]: Include syslog.h.
(_gcry_initialize_fips_mode, lock_fsm, unlock_fsm)
(_gcry_fips_signal_error, fips_new_state)
(_gcry_fips_noreturn) [HAVE_SYSLOG]: Also log via syslog.
(check_binary_integrity) [HAVE_SYSLOG]: Log failure.
* global.h [HAVE_SYSLOG]: Include syslog.h.
(_gcry_global_is_operational) [HAVE_SYSLOG]: Print warning.
* global.c (_gcry_vcontrol): Use GCRYCTL_INITIALIZATION_FINISHED
to run power-up tests. Add unpublished control commands 58-60.
* global.c (_gcry_global_is_operational): New.
* g10lib.h (fips_is_operational): Change to call this function.
2008-09-12 Werner Koch <wk@g10code.com>
* fips.c (_gcry_fips_run_selftests): Add arg EXTENDED.
(run_cipher_selftests, run_digest_selftests, run_hmac_selftests)
(run_pubkey_selftests): Ditto.
* cipher-proto.h (selftest_func_t): Add arg EXTENDED
2008-09-11 Werner Koch <wk@g10code.com>
* fips.c: Include string.h.
(loxtoi_1, loxtoi_2, loxdigit_p): New.
(check_binary_integrity): Change the format of the expected file.
* fips.c (_gcry_fips_run_selftests): Run random tests before the
pubkey tests.
2008-09-05 Werner Koch <wk@g10code.com>
* gcrypt.h.in (GCYRCTL_SELFTEST): New.
* global.c (_gcry_vcontrol): Implement.
* fips.c (_gcry_fips_run_selftests): Do state transitions only if
in fips mode. Return an error code.
2008-09-01 Werner Koch <wk@g10code.com>
* stdmem.c: Re-indented.
2008-08-29 Werner Koch <wk@g10code.com>
* fips.c (_gcry_initialize_fips_mode): Changed /proc file to test
for FIPS mode.
* cipher-proto.h (pk_compute_keygrip_t): New.
(pk_extra_spec): Add field comp_keygrip.
2008-08-28 Werner Koch <wk@g10code.com>
* hwfeatures.c (_gcry_detect_hw_features): Disable hardware
detection in FIPS mode.
2008-08-27 Werner Koch <wk@g10code.com>
* global.c (_gcry_vcontrol): Allow running selftests from error
state.
(gcry_set_outofcore_handler): Only print a warning if used in FIPS
mode.
(gcry_xmalloc, gcry_xrealloc, gcry_xmalloc_secure, gcry_xstrdup):
Ignore an outofcore handler in FIPS mode.
* fips.c (_gcry_fips_test_error_or_operational): New.
(fips_new_state): Allow transition from error into selftest.
Disallow error to init.
2008-08-26 Werner Koch <wk@g10code.com>
* fips.c (fips_new_state): Print state transitions only at
verbosity level of 2.
(reporter): Likewise.
* cipher-proto.h (pk_ext_generate_t): New.
(pk_extra_spec): Add member ext_generate.
* cipher.h (PUBKEY_FLAG_TRANSIENT_KEY): New.
2008-08-22 Werner Koch <wk@g10code.com>
* hmac256.c (_gcry_hmac256_file): New.
(main): New option --binary.
* fips.c (check_binary_integrity): New.
(_gcry_fips_run_selftests): Run it.
* global.c (_gcry_vcontrol) <GCRYCTL_UPDATE_RANDOM_SEED_FILE>:
Check for fips operational state.
(_gcry_vcontrol) <GCRYCTL_FAST_POLL>: Ditt.
2008-08-21 Werner Koch <wk@g10code.com>
* misc.c (_gcry_log_printhex): New.
2008-08-20 Werner Koch <wk@g10code.com>
* g10lib.h (gcry_assert): New. use this at almost all places
where we used a plain assert.
* misc.c (_gcry_assert_failed): New.
(_gcry_bug): Also use func variant for ISO-C99.
2008-08-19 Werner Koch <wk@g10code.com>
* visibility.c, visibility.h (gcry_mpi_lshift): New.
* libgcrypt.vers, libgcrypt.def, gcrypt.h.in: Ditto.
2008-08-15 Werner Koch <wk@g10code.com>
* gcrypt.h.in (gcry_cipher_setkey): Replace macro by function.
(gcry_cipher_setiv): Ditto.
(gcry_cipher_setctr): Ditto.
* visibility.c (gcry_cipher_setkey, gcry_cipher_setiv)
(gcry_cipher_setctr): New.
* visibility.h (gcry_cipher_setkey, gcry_cipher_setiv)
(gcry_cipher_setctr): New.
* libgcrypt.vers (gcry_cipher_setkey, gcry_cipher_setiv)
(gcry_cipher_setctr): New.
* libgcrypt.def (gcry_cipher_setkey, gcry_cipher_setiv)
(gcry_cipher_setctr): New.
* hmac256.h, hmac256.c: New.
* Makefile.am (hmac256_SOURCES): New.
* Makefile.am (bin_PROGRAMS): Add hmac256.
* gcrypt.h.in (struct gcry_thread_cbs): Change type of OPTION to
unsigned int. Although this is a type change it does not make a
difference.
* ath.c (ath_install): Take the version of the option field in
account.
* visibility.c (gcry_pk_encrypt, gcry_pk_decrypt, gcry_pk_sign)
(gcry_pk_verify, gcry_pk_testkey, gcry_pk_genkey)
(gcry_pk_get_nbits, gcry_pk_get_keygrip)
(gcry_md_open, gcry_md_copy, gcry_md_enable)
(gcry_md_write, md_final, gcry_md_ctl, gcry_md_setkey)
(gcry_md_hash_buffer, gcry_md_get_algo, gcry_md_info)
(gcry_md_is_enabled)
(gcry_cipher_open, gcry_cipher_encrypt)
(gcry_cipher_decrypt, gcry_cipher_ctl)
(gcry_cipher_algo_info): Check whether the library is operational.
* cipher-proto.h: New.
* cipher.h: Include cipher-proto.h.
* visibility.h: Remove duplicate macro definitions. Remove
gcry_cipher_register, gcry_md_register, gcry_pk_register macros.
* visibility.c: Include cipher-proto.h.
(gcry_cipher_register): Pass dummy extra args to the internal
register function.
(gcry_md_register, gcry_pk_register): Ditto.
* g10lib.h (struct gcry_module): Add field EXTRASPEC.
* module.c (_gcry_module_add): Add arg EXTRASPEC. Changed all
callers to pass NULL.
* fips.c: New.
* gcrypt.h.in (GCRYCTL_FIPS_MODE_P): New.
* global.c (global_init): Call fips initialization.
(_gcry_vcontrol): Add GCRYCTL_FIPS_MODE_P code.
(print_config): Add config item fips-mode.
(gcry_set_allocation_handler): Do not allow the use of custom
allocation handlers.
(gcry_set_outofcore_handler): Ditto.
(_gcry_get_debug_flag): Do not return any debug flags in fips mode.
* misc.c (_gcry_logv): Signal fips error on BUG or FATAL.
(_gcry_fatal_error): Ditto.
2008-07-05 Werner Koch <wk@g10code.com>
* Makefile.am: Include librandom.la.
2008-04-18 Werner Koch <wk@g10code.com>
* missing-string.c (vasprintf): Remove. It is not used. Reported
by Simon Josefsson.
2008-03-11 Werner Koch <wk@g10code.com>
* gcrypt.h.in (gcry_ac_em_t, gcry_ac_scheme_t): Remove trailing
comma for full C-89 compatibility.
2008-01-21 Marcus Brinkmann <marcus@g10code.de>
* hwfeatures.c (detect_ia32_gnuc): Fix inline asm.
2007-12-11 Werner Koch <wk@g10code.com>
* visibility.c (gcry_md_hash_buffer): Don't use return vor a void
function. Hey, why does gcc not complain about this?
(gcry_ac_io_init_va): Ditto.
2007-12-05 Werner Koch <wk@g10code.com>
* hwfeatures.c (detect_ia32_gnuc): Depend on ENABLE_PADLOCK_SUPPORT.
2007-12-03 Werner Koch <wk@g10code.com>
* misc.c (_gcry_logv): Use abort for error levels fatal and bug as
this is more approriate for a library. Terminate the secmem
before doing so.
(_gcry_fatal_error): Terminate secmem before abort.
* secmem.c (_gcry_secmem_malloc_internal): Use log_bug instead of
exit.
2007-11-29 Werner Koch <wk@g10code.com>
* hwfeatures.c (detect_ia32_gnuc): Detect Padlock engine.
2007-11-13 Werner Koch <wk@g10code.com>
* gcrypt.h.in (_GCRY_GCC_ATTR_MALLOC): Fixed gcc version check.
Reported by Gabriele Monti.
2007-10-31 Werner Koch <wk@g10code.com>
* global.c (gcry_control): Factor most code out to ..
(_gcry_vcontrol): .. new.
* sexp.c (_gcry_sexp_vbuild): New.
* mpi.h (_gcry_mpi_set, _gcry_mpi_set_ui, _gcry_mpi_invm): Remove
prototypes as they are already in gcrypt.h.
2007-10-30 Werner Koch <wk@g10code.com>
* sexp.c (gcry_sexp_nth_string): Replace by _gcry_sexp_nth_string.
* visibility.h, visibility.c: New.
* g10lib.h: Include visibility.h instead of gcrypt.h.
* globals.c (_gcry_malloc): Rename to ..
(do_malloc): .. this.
* hwfeatures.c: New.
* global.c (global_init): Detect features.
(print_config): Print them.
2007-08-22 Werner Koch <wk@g10code.com>
* dumpsexp.c: New.
* Makefile.am (bin_PROGRAMS): Install it.
* getrandom.c (print_version): Use new standard license line.
* gcryptrnd.c (print_version): Ditto.
2007-06-06 Werner Koch <wk@g10code.com>
* gcrypt.h.in (GCRY_THREAD_OPTION_PTH_IMPL): Factror network
related code out so that the prototypes can be adjusted for W32.
(_GCRY_THREAD_OPTION_PTH_IMPL_NET): New.
2007-05-09 Werner Koch <wk@g10code.com>
* libgcrypt.m4: Print found version on success.
2007-05-09 Marcus Brinkmann <marcus@g10code.de>
* gcrypt.h.in (gcry_ac_io_t): Add name for anonymous union, and mark
all members as internal (actually: deprecated).
2007-05-04 Werner Koch <wk@g10code.com>
* Makefile.am (.rc.lo): New to replace gmake specific suffix rule.
2007-05-03 Werner Koch <wk@g10code.com>
* libgcrypt.def (gcry_sexp_nth_string): New.
* Makefile.am (EXTRA_DIST): Add libgcrypt.def.
2007-05-02 Werner Koch <wk@g10code.com>
* global.c (print_config): Print ciphers, digests and pubkeys.
2007-05-02 David Shaw <dshaw@jabberwocky.com>
* cipher.h, gcrypt.h.in: Add Camellia.
2007-04-30 Werner Koch <wk@g10code.com>
* gcrypt.h.in (GCRYCTL_PRINT_CONFIG): New.
(GCRYCTL_SET_RNDEGD_SOCKET): New.
* global.c (gcry_control): Add GCRYCTL_PRINT_CONFIG and
GCRYCTL_SET_RNDEGD_SOCKET.
(print_config): New.
* misc.c (_gcry_log_info_with_dummy_fp): New.
2007-04-18 Werner Koch <wk@g10code.com>
* gcrypt.h.in (gcry_sexp_nth_string): New.
* sexp.c (gcry_sexp_nth_data): Factored code out to ...
(sexp_nth_data): ... new.
(gcry_sexp_nth_string): New.
(gcry_sexp_nth_mpi): Reimplemented in terms of sexp_ntd_data.
2007-04-16 Werner Koch <wk@g10code.com>
* secmem.c (init_pool): Use sysconf() if available to determine
page size.
2007-03-22 Werner Koch <wk@g10code.com>
* mpi.h (mpi_mod): New.
(mpi_new, mpi_snew): New.
* gcrypt.h.in: Add GCRY_PK_ECDSA.
2007-03-16 Werner Koch <wk@g10code.com>
* gcrypt.h.in (GCRY_THREAD_OPTION_PTHREAD_IMPL): Fixed typo
introduced by me on 2006-10-23.
2007-02-22 Werner Koch <wk@g10code.com>
* gcrypt.h.in (gcry_ac_id_to_name, gcry_ac_name_to_id): Mark as
deprecated.
* libgcrypt.def (gcry_fast_random_poll): Removed - it is a macro.
(gcry_cipher_register, gcry_cipher_unregister): New.
(gcry_md_register, gcry_md_unregister): New.
(gcry_pk_register, gcry_pk_unregister): New.
(gcry_ac_data_from_sexp, gcry_ac_data_to_sexp): New.
(gcry_ac_io_init, gcry_ac_io_init_va): New.
(gcry_ac_data_encrypt_scheme, gcry_ac_data_decrypt_scheme): New.
(gcry_ac_data_sign_scheme, gcry_ac_data_verify_scheme): New.
* missing-string.c: Include stdio.h for the vsprintf prototype.
* ath.h (struct ath_ops) [_WIN32]: Use int instead of socklen_t.
2007-02-21 Werner Koch <wk@g10code.com>
* libgcrypt.def (gcry_create_nonce, gcry_fast_random_poll)
(gcry_md_debug): New.
* libgcrypt-config.in: Remove duplicates from --cflags and --libs.
Print a error for option --thread.
* gcrypt.h.in (gcry_sexp_sprint): Change BUFFER from char* to void*.
(gcry_md_ctl): Change BUFFER from unsigned char* to void*.
(gcry_md_debug): New.
(gcry_cipher_encrypt, gcry_cipher_decrypt): Change buffer args to
void*.
(gcry_randomize): Change BUFFER to void.
(gcry_create_nonce): Ditto.
* libgcrypt.vers (gcry_md_debug): New.
* sexp.c (gcry_sexp_sprint): Ditto.
(normalize): Make P unsigned.
(gcry_sexp_nth_data): Cast return value to char*.
(sexp_sscan): Fix sign/unsigned conflicts.
(whitespacep): Change P to char*.
(unquote_string): Change STRING to char*.
(convert_to_hex): Change DEST to char*.
(convert_to_string): Change DEST and P to char*.
(convert_to_token): Chnage DEST to char*.
(gcry_sexp_canon_len): Change DISPHINT to unsigned char*.
* gcrypt-module.h (gcry_pk_spec): Made ALIASES a const.
(gcry_md_write_t): Changed BUF to a const void*.
2007-02-12 Werner Koch <wk@g10code.com>
* gcrypt.h.in: Include stdlib.h for the sake fo the trheading
macros. Suggested by Andreas Metzler.
* secmem.c (ptr_into_pool_p): New.
(_gcry_private_is_secure): Implement in terms of new function.
(BLOCK_VALID): Removed. Replaced all users by new function.
2007-01-31 Werner Koch <wk@g10code.com>
* secmem.c (_gcry_private_is_secure): Fixed severe implementation
flaw. Might be the reason for some of the more obscure bugs.
(MB_WIPE_OUT): Use wipememory2.
2006-10-23 Werner Koch <wk@g10code.com>
* gcrypt.h.in (GCRY_THREAD_OPTION_PTHREAD_IMPL): Add some cast for
use by C-doubleplus. In general I don't like this but due to
public demand I give up ;-)
2006-10-19 Werner Koch <wk@g10code.com>
* global.c (gcry_control) <GCRYCTL_INIT_SECMEM>: Return an error
if the memory could not be locked.
* secmem.c (not_locked): New.
(_gcry_secmem_get_flags): Return that flag.
* secmem.h (GCRY_SECMEM_FLAG_NOT_LOCKED): New.
2006-10-05 Werner Koch <wk@g10code.com>
* module.c (_gcry_module_id_new): Don't assign modules in the range
the range of 1024..4096.
* gcrypt.h (GCRY_MD_USER, GCRY_MD_USER_LAST): New
(GCRY_PK_USER, GCRY_PK_USER_LAST): New.
(GCRY_CIPHER_USER, GCRY_CIPHER_USER_LAST): New.
2006-10-12 Marcus Brinkmann <marcus@g10code.de>
* gcrypt.h.in: Replace socklen_t with gcry_socklen_t.
2006-10-11 Marcus Brinkmann <marcus@g10code.de>
* gcrypt.h.in: Replace version by @VERSION@.
2006-10-10 Marcus Brinkmann <marcus@g10code.de>
* gcrypt.h: Add fallback type for socklen_t. Move to ...
* gcrypt.h.in: ... this file.
* Makefile.am (EXTRA_DIST): Add gcrypt.h.in.
2006-09-04 Werner Koch <wk@g10code.com>
* gcrypt.h: Removed some trailing comma in enums.
2006-08-29 Werner Koch <wk@g10code.com>
* global.c (gcry_xrealloc): Pass secure flag to outofcore handler.
* gcrypt.h (GCRY_CIPHER_SEED): New.
2006-08-21 Werner Koch <wk@g10code.com>
* gcrypt.h (GCRYCTL_FAKED_RANDOM_P): New.
2006-07-29 Marcus Brinkmann <marcus@g10code.de>
* secmem.c (init_pool): Close FD after establishing the mapping.
2006-07-12 Marcus Brinkmann <marcus@g10code.de>
* ath.c (ath_mutex_destroy): Microoptimize destruction of unused
statitically initialized mutexes. Suggested by Victor Stinner
<victor.stinner@inl.fr>.
* gcrypt.h (GCRY_THREAD_OPTION_PTHREAD_IMPL,
(GCRY_THREAD_OPTION_PTH_IMPL): Add missing initializers to
suppress gcc warning.
Submitted by Victor Stinner <victor.stinner@inl.fr>.
2006-07-04 Marcus Brinkmann <marcus@g10code.de>
* ath.c: Avoid warning about double defined type byte and other
hacks to let it build for W32 (backported from LIBGCRYPT-1-2-BRANCH).
* ath.h, gcrypt.h, tests/benchmark.c, src/types.h: Likewise.
* gcrypt.h: Revert last change, and instead:
[_WIN32 || __WIN32__]: Do not include <sys/socket.h>, but
<winsock2.h> and <ws2tcpip.h>.
Suggested by Simon Josefsson <jas@extundo.com>.
* Makefile.am (install-data-local, uninstall-local, %.lo,
(install-def-file, uninstall-def-file): New targets.
(LTRCCOMPILE, gcrypt_res, gcrypt_res_ldflag, no_undefined,
(export_symbols, gcrypt_deps): New variables.
* versioninfo.rc.in: New file.
* libgcrypt.def: New file from ../w32-dll/libgcrypt.def.
* gcrypt.h [!HAVE_SYS_SOCKET_H]: Do not include sys/socket.h, but
the appropriate windows socket header.
2006-06-21 Werner Koch <wk@g10code.com>
* global.c (gcry_xcalloc, gcry_xcalloc_secure): Made safe against
integer overflow.
* sexp.c (make_space): Return an error on out of core.
(sexp_sscan): Remove all xmalloc style calls and return proper
error codes on allocation failures.
(gcry_sexp_find_token): Ditto.
(gcry_sexp_nth):
* sexp.c (gcry_sexp_find_token): Re-indented and removed a cruft
"while(level);" which fortunately had no effect.
2006-04-28 Werner Koch <wk@g10code.com>
* gcrypt.h (GCRY_MD_SHA224): Change value from 306 to 11 to match
the use in OpenPGP. There has been no release yet, so we can
safely do it.
2006-04-22 Moritz Schulte <moritz@g10code.com>
* gcrypt.h (gcry_ctl_cmds): New commands:
GCRYCTL_SET_RANDOM_DAEMON_SOCKET, GCRYCTL_USE_RANDOM_DAEMON.
* global.c (gcry_control): Handle new commands, calling
_gcry_set_random_daemon_socket() and _gcry_use_random_daemon().
2006-04-18 Werner Koch <wk@g10code.com>
* gcrypt.h (GCRY_PK_USAGE_CERT, GCRY_PK_USAGE_AUTH)
(GCRY_PK_USAGE_UNKN): New.
2006-04-01 Moritz Schulte <moritz@g10code.com>
* gcrypt.h (gcry_ac_eme_pkcs_v1_5): Removed members: key, handle;
added member: key_size.
* secmem.c (MB_FLAG_ACTIVE): Write braces around MB_FLAG_ACTIVE
definition.
2006-03-15 Werner Koch <wk@g10code.com>
* getrandom.c: New.
2006-03-14 Werner Koch <wk@g10code.com>
* gcryptrnd.c: New.
2006-03-10 Werner Koch <wk@g10code.com>
* gcrypt.h: Add GCRY_MD_SHA224.
2005-11-02 Moritz Schulte <moritz@g10code.com>
* gcrypt.h: Update comments for functions: gcry_cipher_algo_name,
gcry_pk_algo_name.
2005-10-31 Moritz Schulte <moritz@g10code.com>
* global.c: Added documentation.
2005-10-16 Moritz Schulte <moritz@g10code.com>
* global.c (global_init): Use gcry_error_t instead of
gcry_err_code_t; use goto instead of if constructs.
* stdmem.c: Inserted description of the layered memory management
in Libgcrypt.
* g10lib.h: Removed G10_I18N_H related check; it seems to be a
GnuPG relict (Libgcrypt does not define this symbol anywhere).
(FLAG_MODULE_DISABLED): Don't forget parantheses around shifted
value.
Removed GCC_ATTR_PURE macro definitions, since gcrypt.h does
already contain such a macro named _GCRY_GCC_ATTR_PURE, which we
can use here as well.
Likewise for GCC_ATTR_MALLOC and _GCRY_GCC_ATTR_MALLOC.
* stdmem.h: Use _GCRY_GCC_ATTR_MALLOC instead of GCC_ATTR_MALLOC.
* secmem.h: Likewise.
2005-10-09 Moritz Schulte <moritz@g10code.com>
* global.c (gcry_control): Call global_init() after passing thread
cbs to ath. global_init() MUST to be called AFTER passing the cbs
to ath and BEFORE calling library functions, which make use of
ath. This change combines cbs installing with ath initialization
and thus removes the need to call other library initialization
functions inbetween like e.g. gcry_check_version().
2005-10-01 Moritz Schulte <moritz@g10code.com>
* ath.c: Assign copyright to FSF.
* ath.h: Likewise.
2005-06-25 Moritz Schulte <moritz@g10code.com>
* Makefile.am (pkgconfigdir, pkgconfig_DATA): Removed variables.
* libgcrypt.pc.in: Removed file - we do not want to support a
second, foreign configuration system.
2005-06-17 Moritz Schulte <moritz@g10code.com>
* global.c (gcry_xstrdup): Removed superfluous strcpy call.
2005-04-22 Moritz Schulte <moritz@g10code.com>
* Makefile.am (pkgconfigdir, pkgconfig_DATA): New; support for
pkgconfig provided by Albert Chin.
* libgcrypt.pc.in (Cflags): New file.
2005-04-16 Moritz Schulte <moritz@g10code.com>
* g10lib.h (_gcry_ac_init): Declare.
* global.c (global_init): Call _gcry_ac_init; don't forget to set
err.
2005-04-14 Werner Koch <wk@g10code.com>
* sexp.c (whitespacep): New.
(sexp_sscan): Replaced isdigit and isspace by whitespacep and
digitp.
2005-04-11 Moritz Schulte <moritz@g10code.com>
* gcrypt.h (gcry_md_algos): Added: GCRY_MD_WHIRLPOOL.
* cipher.h (_gcry_digest_spec_whirlpool): Declare.
2005-03-30 Moritz Schulte <moritz@g10code.com>
* libgcrypt.vers: Added: gcry_ac_io_init, gry_ac_io_init_va.
* gcrypt.h (gcry_ac_data_read_cb_t, gcry_ac_data_write_cb_t,
gcry_ac_io_mode_t, gcry_ac_io_type_t, gcry_ac_io_t): New types.
(gcry_ac_io_init_va): Declare function.
(gcry_ac_data_encode, gcry_ac_data_decode,
gcry_ac_data_encrypt_scheme, gcry_ac_data_decrypt_scheme,
gcry_ac_data_sign_scheme, gcry_ac_data_verify_scheme): Use
gcry_ac_io_type_t objects instead of memory strings directly.
2005-03-03 Moritz Schulte <moritz@g10code.com>
* libgcrypt.vers: Added: gcry_ac_data_to_sexp() and
gcry_ac_data_from_sexp().
2005-02-22 Werner Koch <wk@g10code.com>
* global.c (_gcry_malloc): Make sure ERRNO is set if we return
NULL. Remove unneeded initialization of M to allow the compiler
to catch errors.
(gcry_realloc): Make sure ERRNO is set if we return NULL>
2005-02-13 Moritz Schulte <moritz@g10code.com>
* gcrypt.h: Declare new functions: gcry_ac_data_encrypt_scheme,
gcry_ac_data_decrypt_scheme, gcry_ac_data_sign_scheme,
gcry_ac_data_verify_scheme, gcry_ac_data_encode,
gcry_ac_data_decode, gcry_ac_data_to_sexp, gcry_ac_data_from_sexp.
New types: gcry_ac_emsa_pkcs_v1_5_t, gcry_ac_ssa_pkcs_v1_5_t,
gcry_md_algo_t.
New enumeration lists: gcry_ac_scheme_t, gcry_ac_em_t.
* libgcrypt.vers: Added new ac functions.
* g10lib.h: Declare function: _gcry_pk_get_elements.
* mpi.h (mpi_get_ui): New macro.
Declare function: _gcry_mpi_get_ui.
2004-11-09 Werner Koch <wk@g10code.com>
* gcrypt.h: Removed 3 trailing commas from enums. Noted by Heiko
Stamer.
2004-09-21 Werner Koch <wk@g10code.de>
* sexp.c (sexp_sscan): Removed C++ style comments. Noted by Yoann
Vandoorselaere.
2004-08-23 Moritz Schulte <moritz@g10code.com>
* global.c: Do not include <assert.h>.
* sexp.c: Likewise.
* module.c: Likewise.
* misc.c: Likewise.
2004-08-18 Moritz Schulte <moritz@g10code.com>
* secmem.c (_gcry_secmem_init): Try to lock pool into core not
only when running with root privileges.
2004-08-16 Werner Koch <wk@g10code.de>
* secmem.h (_gcry_secmem_set_flags,_gcry_secmem_get_flags):
Removed __pure__.
(GCRY_SECMEM_FLAG_NO_WARNING): Put macro value into parens.
* secmem.c (_gcry_secmem_init): Defer printing of the warning.
2004-08-10 Moritz Schulte <moritz@g10code.com>
* gcrypt.h: Include <sys/time.h>, thanks to Simon Josefsson.
2004-05-07 Werner Koch <wk@gnupg.org>
* gcrypt.h: Added GCRYCTL_FAST_POLL.
(gcry_fast_random_poll): New.
* global.c (gcry_control) <INITIALIZATION_FINISHED>: Do only basic
random subsystem init.
(gcry_control) <FAST_POLL>: New.
2004-04-22 Marcus Brinkmann <marcus@g10code.de>
* libgcrypt.m4: Quote first argument to AC_DEFUN.
2004-04-15 Werner Koch <wk@gnupg.org>
* secmem.c (_gcry_secmem_malloc_internal): Removed old extra info
error output.
(_gcry_secmem_term): Use wipememory2 here.
* misc.c (_gcry_burn_stack): Use wipememory to avoid optimizations.
* string.c: Removed. Was never used.
* global.c (gcry_strdup): Replaced by the version from string.c
(gcry_xstrdup): Rewritten.
* gcrypt.h: Removed duplicate prototype for gcry_strdup.
2004-03-29 Werner Koch <wk@gnupg.org>
* secmem.c (_gcry_secmem_realloc): Fixed double unlock; bug
manifested itself due to the more rigorous checking in the changed
ath.h
* libgcrypt-config.in (Options): Ignore the obsolete --threads
option for now.
2004-03-17 Marcus Brinkmann <marcus@g10code.de>
* libgcrypt-config.in (includedir, libdir): Quote'em. Use
$gpg_error_cflags and $gpg_error_libs. Fix construction of
$includes.
2004-03-14 Marcus Brinkmann <marcus@g10code.de>
* libgcrypt-config.in (includedir, libdir): New variables. For
--cflags, don't test $cflags. Also check against /include for the
GNU/Hurd. Don't overwrite but extend $cflags_final. Likewise for
--libs.
2004-03-10 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am (ltlib_libgcrypt_pthread, ltlib_libgcrypt_pth): Removed.
(lib_LTLIBRARIES): Remove those variables from here.
(libgcrypt_pthread_la_SOURCES, libgcrypt_pthread_la_LDFLAGS,
(libgcrypt_pthread_la_DEPENDENCIES, libgcrypt_pthread_la_LIBADD,
(libgcrypt_pth_la_SOURCES, libgcrypt_pth_la_LDFLAGS,
(libgcrypt_pth_la_DEPENDENCIES, libgcrypt_pth_la_LIBADD,
(noinst_LTLIBRARIES): Removed.
(libgcrypt_real_la_SOURCES): Merge with ...
(libgcrypt_la_SOURCES): ... likewise.
(libgcrypt_real_la_DEPENDENCIES): Merge with ...
(libgcrypt_la_DEPENDENCIES): ... this.
(libgcrypt_real_la_LIBADD): Merge with ...
(libgcrypt_la_LIBADD): ... this.
* libgcrypt-config.in (libs_pthread, libs_pth, cflags_pth)
(cflags_pthread, thread_module, thread_modules): Removed.
(Options): Remove --thread option from help output. If the option
is specified, output an error and exit.
For --cflags and --libs option, remove pth and pthread from output.
* gcrypt.h: Include <sys/types.h> and <sys/socket.h>.
(enum gcry_ctl_cmds): Add GCRYCTL_SET_THREAD_CBS.
(gcry_thread_cbs): New struct.
* global.c (gcry_control): Implement GCRYCTL_SET_THREAD_CBS.
(global_init): Don't call ath_init here.
* ath.h: Rewritten.
* ath.c: Rewritten.
2004-03-06 Werner Koch <wk@gnupg.org>
* libgcrypt-config.in: s/--soname-number/--api-version/
* libgcrypt.m4: Changed test for API version.
2004-03-05 Werner Koch <wk@gnupg.org>
* libgcrypt.m4: Optionally check the SONAME number.
* libgcrypt-config.in: Add option --soname-number
2004-03-01 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am (libgcrypt_la_SOURCES): Add ath.c.
* ath.c (ath_init): Add missing function.
* Makefile.am (ath_pth_src): Removed.
(ath_pthread_src): Removed.
(libgcrypt_la_SOURCES): Remove ath-compat, $(ath_pth_src) and
$(ath_pthread_src).
* ath-compat.c, ath-pth-compat.c, ath-pthread-compat.c: Files
removed.
2004-02-20 Werner Koch <wk@gnupg.org>
* gcrypt.h (GCRY_PRIME_CHECK_AT_GOT_PRIME)
(GCRY_PRIME_CHECK_AT_FINISH),
(GCRY_PRIME_CHECK_AT_MAYBE_PRIME): New.
2004-02-18 Werner Koch <wk@gnupg.org>
* libgcrypt-config.in: Ignore setting of --prefix.
2004-02-13 Werner Koch <wk@gnupg.org>
* gcrypt.h: Added GCRY_CIPHER_RFC2268_128, alsthough not yet
supported.
2004-02-06 Werner Koch <wk@gnupg.org>
* gcrypt.h: Added GCRY_CIPHER_RFC2268_40.
2004-02-03 Werner Koch <wk@gnupg.org>
* secmem.c (_gcry_secmem_init): Do not print the "not locked into
core warning" if the NO_WARNING flag has been set.
* sexp.c (sexp_sscan): Allocate result in secure memory if BUFFER
is in secure memory. Switch to secure memory for the a secure %b
format item. Extra paranoid wipe on error.
(gcry_sexp_release): Added paranoid wiping for securely allocated
S-expressions.
2004-01-25 Moritz Schulte <mo@g10code.com>
* ath.h: Include <config.h>.
2004-01-12 Moritz Schulte <mo@g10code.com>
* gcrypt.h: Adjusted declarations of: gcry_ac_data_set,
gcry_ac_data_get_name, gcry_ac_data_get_index,
gcry_ac_key_pair_generate, gcry_ac_key_test,
gcry_ac_key_get_nbits, gcry_ac_key_get_grip.
* gcrypt.h (GCRY_AC_FLAG_DATA_NO_BLINDING): Removed symbol.
(GCRY_AC_FLAG_DEALLOC, GCRY_AC_FLAG_COPY)
(GCRY_AC_FLAG_NO_BLINDING): New symbols.
* global.c (gcry_strdup): Removed function.
* string.c: New file.
* Makefile.am (libgcrypt_real_la_SOURCES): Added: string.c.
* string.c (gcry_strdup): New function.
* gcrypt.h (gcry_strdup): Declare.
2003-12-19 Werner Koch <wk@gnupg.org>
* g10lib.h (wipememory, wipememory2): New; taken from gnupg.
2003-11-14 Werner Koch <wk@gnupg.org>
* global.c (gcry_strdup): Don't copy the string after a malloc
error.
2003-11-11 Werner Koch <wk@gnupg.org>
* sexp.c (sexp_sscan): Implemented "%b" format specifier.
2003-11-11 Moritz Schulte <mo@g10code.com>
* libgcrypt.m4: Do not set prefix when calling libgcrypt-config.
Thanks to Nikos Mavroyanopoulos.
2003-11-08 Moritz Schulte <mo@g10code.com>
* cipher.h (small_prime_numbers): Removed declaration.
(PUBKEY_FLAG_NO_BLINDING): Put braces around shift.
2003-11-04 Werner Koch <wk@gnupg.org>
* cipher.h (_gcry_sha1_has_buffer): New.
* gcrypt.h (gcry_create_nonce): New.
2003-10-31 Werner Koch <wk@gnupg.org>
* libgcrypt.vers (_gcry_generate_elg_prime): Removed this symbol;
gnutls does not need it anymore.
* secmem.c (mb_get_new): s/pool/block/ due to global pool.
* misc.c (gcry_set_log_handler): s/logf/f/ to avoid shadowing
warning against a builtin.
* ath-pth-compat.c: cast pth_connect to get rid of the const
prototype.
2003-10-27 Werner Koch <wk@gnupg.org>
* ath.h (ATH_MUTEX_INITIALIZER): Removed spurious semicolon.
2003-10-27 Moritz Schulte <mo@g10code.com>
* libgcrypt-config.in: Include libs/cflags of libgpg-error.
* sexp.c (sexp_sscan): Cleaned up, deallocate scanned sexp on
error.
* module.c (MODULE_ID_MIN): New symbol, use it.
2003-10-27 Werner Koch <wk@gnupg.org>
* gcrypt.h (gcry_pk_testkey): Doc fix.
2003-09-29 Moritz Schulte <mo@g10code.com>
* libgcrypt-config.in: Fix --algorithms option.
2003-10-23 Werner Koch <wk@gnupg.org>
* gcrypt.h (gcry_err_code): Use GPG_ERR_INLINE instead of
__inline__.
* secmem.c (lock_pool): Don't print the warning for certain
systems, handle ENOMEM.
2003-10-21 Werner Koch <wk@gnupg.org>
* secmem.c (_gcry_secmem_dump_stats): Fixed format sepcifier for a
size_t. Reported by Stephane Corthesy.
2003-10-10 Werner Koch <wk@gnupg.org>
* global.c (_gcry_malloc): Handle the no_secure_memory option.
* gcrypt.h (gcry_prime_group_generator): New.
(gcry_prime_release_factors): New.
2003-10-07 Werner Koch <wk@gnupg.org>
* sexp.c (sexp_sscan): Check that parenthesis are matching.
2003-09-28 Moritz Schulte <mo@g10code.com>
* g10lib.h: Declare: _gcry_malloc.
(GCRY_ALLOC_FLAG_SECURE): New symbol.
* global.c (_gcry_malloc): New function...
(gcry_malloc): ... use it.
(gcry_malloc_secure): Likewise.
* ath.c: Change License to LGPL.
* ath-pthread-compat.c: Likewise.
* ath-pthread.c: Likewise.
* ath-pth-compat.c: Likewise.
* ath-pth.c: Likewise.
* ath.h: Likewise.
* ath-compat.c: Likewise.
* secmem.c (_gcry_secmem_realloc): Do not forget to release secmem
lock. Thanks to low halo for triggering this bug.
2003-09-04 Werner Koch <wk@gnupg.org>
* gcrypt.h (_GCRY_ERR_SOURCE_DEFAULT): Removed cruft.
(gcry_prime_check_func_t): Renamed arg for clarity.
2003-09-02 Moritz Schulte <mo@g10code.com>
* gcrypt.h (GCRY_PRIME_FLAG_SPECIAL_FACTOR): New symbol.
2003-09-01 Moritz Schulte <mo@g10code.com>
* gcrypt.h (gcry_random_level_t): New type.
(gcry_prime_check_func_t): Likewise.
(GCRY_PRIME_FLAG_SECRET): New symbol.
(gcry_prime_generate, gcry_prime_check): Declare functions.
2003-08-28 Werner Koch <wk@gnupg.org>
* Makefile.am (libgcrypt_pth_la_LDFLAGS): Removed PTH_CFLAGS cruft.
2003-08-27 Moritz Schulte <mo@g10code.com>
* global.c (gcry_control): Remove call to ath_deinit.
* Makefile.am (libgcrypt_real_la_DEPENDENCIES): Fixed.
(libgcrypt_real_la_LIBADD): Fixed.
Removed unecessary variables.
* libgcrypt-config.in: Adjusted script for new thread handling.
* Makefile.am: New version, based on GPGMEs Makefile.am.
* ath.c, ath-compat.c, ath.h, ath-pth.c, ath-pth-compat.c,
ath-pthread.c, ath-pthread-compat.c: New files, merged from GPGME.
* ath.c, ath.h, ath-pthread.c, ath-pth.c: Removed files.
2003-08-08 Moritz Schulte <moritz@g10code.com>
* global.c (gcry_realloc): Remove FIXME about `clearing out
realloced memory', since _gcry_secmem_realloc takes care of
overwriting old memory.
2003-08-07 Werner Koch <wk@gnupg.org>
* module.c (_gcry_module_release): Don't act if module is NULL.
2003-07-30 Moritz Schulte <moritz@g10code.com>
* gcrypt.h (enum gcry_ac_id): Added: GCRY_AC_ELG_E.
Reverted change: use gcry_md_flags enumeration list instead of
defines.
2003-07-29 Werner Koch <wk@gnupg.org>
* global.c (gcry_control): Add GCRYCTL_SET_RANDOM_SEED_FILE and
GCRYCTL_UPDATE_RANDOM_SEED_FILE.
* gcrypt.h: Ditto. Renamed index to idx, so avoid warning
related to the old index function.
2003-07-28 Moritz Schulte <moritz@g10code.com>
* global.c (gcry_err_code_from_errno, gcry_err_code_to_errno)
(gcry_err_make_from_errno, gcry_error_from_errno): New functions.
* gcrypt.h: Declared: gcry_err_code_from_errno,
gcry_err_code_to_errno, gcry_err_make_from_errno,
gcry_error_from_errno.
* Makefile.am (include_HEADERS): Added: gcrypt-module.h.
* gcrypt.h: Include <gcrypt-module.h>.
* gcrypt-module.h: New file.
2003-07-27 Werner Koch <wk@gnupg.org>
* gcrypt.h (gcry_mpi_scan, gcry_mpi_print): API change.
(gcry_mpi_dump): New.
2003-07-21 Moritz Schulte <moritz@g10code.com>
* gcrypt.h: Declared: gcry_ac_key_data_get.
(gcry_pk_spec): Renamed member `sexp_names' into `aliases'.
2003-07-20 Moritz Schulte <moritz@g10code.com>
* gcrypt.h (gcry_md_oid_spec_t): New type.
(gcry_md_spec): New member: oids.
2003-07-19 Moritz Schulte <moritz@g10code.com>
* gcrypt.h (gcry_cipher_oid_spec_t): New type.
(gcry_cipher_spec): New member: oids;
2003-07-18 Werner Koch <wk@gnupg.org>
* gcrypt.h (gcry_mpi_set_opaque): Add a warning comment.
2003-07-15 Moritz Schulte <moritz@g10code.com>
* secmem.c (compress_pool): Remove function, since unused blocks
are automatically concatenad.
* gcrypt.h: Bumped version number up to 1.1.42-cvs.
2003-07-14 Moritz Schulte <moritz@g10code.com>
* gcrypt.h (gcry_cipher_spec): New member: aliases.
* Makefile.am (noinst_PROGRAMS, testapi_SOURCES, testapai_LDADD,
benchmark_SOURCES, benchmark_LDADD): Removed.
* benchmark.c, testapi.c: Removed files.
* mpi.h: Removed disabled typedef.
* g10lib.h: Likewise.
* benchmark.c, g10lib.h, gcrypt.h, global.c, module.c, sexp.c:
Used gcry_err* wrappers for libgpg-error symbols.
2003-07-12 Moritz Schulte <moritz@g10code.com>
* global.c: Likewise.
* gcrypt.h: New type: gcry_error_t, gcry_err_code_t and
gcry_err_source_t.
(gcry_err_make, gcry_error, gcry_err_code, gcry_err_source): New
functions.
* global.c (gcry_strerror): New function.
(gcry_strsource): New function.
* gcrypt.h: New symbol: GCRY_CIPHER_TWOFISH128.
2003-07-09 Moritz Schulte <moritz@g10code.com>
* gcrypt.h (enum gcry_md_flags): Removed, used define instead,
since that is more common than an enumeration list when it comes
to flags that can be bitwise ORed.
2003-07-08 Moritz Schulte <moritz@g10code.com>
* global.c: Use new types for handlers.
* gcrypt.h: Declare: gcry_ac_data_copy.
2003-07-07 Moritz Schulte <moritz@g10code.com>
* sexp.c (gcry_sexp_build_array): Use dummy argument pointer.
Thanks to Simon Josefsson <jas@extunde.com>.
* gcrypt.h: Declare: gcry_cipher_list, gcry_pk_list, gcry_md_list.
2003-07-05 Moritz Schulte <moritz@g10code.com>
* gcrypt.h: Declare: gcry_cipher_register, gcry_cipher_unregister,
gcry_md_register, gcry_md_unregister, gcry_pk_register,
gcry_pk_unregister.
(gcry_cipher_spec): Removed member: algorithm.
(gcry_pk_spec): Likewise.
(gcry_md_spec): Likewise.
Adjusted declarations: gcry_cipher_register, gcry_pk_register,
gcry_md_register.
* module.c: Replaced all occurences of `id' with `mod_id', since
`id' is a keyword in obj-c.
* gcrypt.h (gcry_cipher_spec): Renamed member `id' to `algorithm'.
(gcry_pk_spec): Likewise.
(gcry_md_spec): Likewise.
* cipher.h: Removed types: gcry_pubkey_generate_t,
gcry_pubkey_check_secret_key_t, gcry_pubkey_encrypt_t,
gcry_pubkey_decrypt_t, gcry_pubkey_sign_t, gcry_pubkey_verify_t,
gcry_pubkey_get_nbits_t, gcry_pk_spec_t, gcry_digest_init_t,
gcry_digest_write_t, gcry_digest_final_t, gcry_digest_read_t,
gcry_digest_spec_t, gcry_cipher_setkey_t, gcry_cipher_encrypt_t,
gcry_cipher_decrypt_t, gcry_cipher_stencrypt_t,
gcry_cipher_stdecrypt_t, gcry_cipher_spec_t.
* gcrypt.h: New types: gcry_pk_generate_t,
gcry_pk_check_secret_key_t, gcry_pk_encrypt_t, gcry_pk_decrypt_t,
gcry_pk_sign_t, gcry_pk_verify_t, gcry_pk_get_nbits_t,
gcry_pk_spec_t, gcry_md_init_t, gcry_md_write_t, gcry_md_final_t,
gcry_md_read_t, gcry_md_spec_t, gcry_cipher_setkey_t,
gcry_cipher_encrypt_t, gcry_cipher_decrypt_t,
gcry_cipher_stencrypt_t, gcry_cipher_stdecrypt_t,
gcry_cipher_spec_t, gcry_module_t.
2003-07-04 Moritz Schulte <moritz@g10code.com>
* module.c (_gcry_module_list): New function.
2003-07-02 Moritz Schulte <moritz@g10code.com>
* module.c (_gcry_module_lookup): Fixed typo.
* gcrypt.h: Added all definitions and declarations necessary for
the new ac interface.
2003-06-30 Moritz Schulte <moritz@g10code.com>
* g10lib.h: Added declarations: _gcry_pk_module_lookup,
_gcry_pk_module_release.
2003-06-18 Werner Koch <wk@gnupg.org>
* benchmark.c (cipher_bench): Adjusted for new API of get_blklen
and get_keylen.
* gcrypt.h (gcry_cipher_get_algo_blklen)
(gcry_cipher_get_algo_keylen): Replaced macro by funcion.
2003-06-18 Moritz Schulte <moritz@g10code.com>
* cipher.h: Renamed types GcryDigestSpec, GcryCipherSpec and
GcryPubkeySpec into: gcry_digest_spec_t, gcry_cipher_spec_t and
gcry_pubkey_spec_t.
(gcry_pubkey_spec): Defined member `id' as unsigned.
(gcry_digest_spec): Likewise.
(gcry_cipher_spec): Likewise.
* module.c (_gcry_module_id_new): New function.
(_gcry_module_add): Generate a new ID via _gcry_module_id_new in
case `id' is zero.
* g10lib.h, module.c: Replace old type GcryModule with newer one:
gcry_module_t.
* module.c (_gcry_module_add): Added argument `id', use it.
* g10lib.h: Added declaration: _gcry_module_lookup_id.
(_gcry_module_add): Added argument `id'.
* module.c (_gcry_module_lookup_id): New function.
* g10lib.h (struct gcry_module): New member: id.
* gcrypt.h: New type: gcry_handler_progress_t,
gcry_handler_alloc_t, gcry_haandler_secure_check_t,
gcry_handler_realloc_t, gcry_handler_free_t,
gcry_handler_no_mem_t, gcry_handler_error_t, gcry_handler_log_t.
Use new types.
* cipher.h: Include <gcrypt.h>.
New types: gcry_pk_generate_t, gcry_pk_check_secret_key_t,
gcry_pk_encrypt_t, gcry_pk_decrypt_t, gcry_pk_sign_t,
gcry_pk_verify_t, gcry_pk_get_nbits_t, gcry_md_init_t,
gcry_md_write_t, gcry_md_final_t, gcry_md_read_t,
gcry_cipher_setkey_t, gcry_cipher_encrypt_t,
gcry_cipher_decrypt_t, gcry_cipher_stencrypt_t,
gcry_cipher_stdecrypt_t.
Use new types.
2003-06-17 Moritz Schulte <moritz@g10code.com>
* Makefile.am (AM_CFLAGS): Added: @GPG_ERROR_CFLAGS@.
2003-06-16 Moritz Schulte <moritz@g10code.com>
* g10lib.h: Replace last occurences of old type names with newer
names (i.e. replace MPI with gcry_mpi_t).
* mpi.h: Likewise.
* sexp.c: Likewise.
2003-06-15 Moritz Schulte <moritz@g10code.com>
* testapi.c (test_genkey): Use gpg_strerror instead of
gcry_strerror.
* global.c (gcry_control): Fixed typo.
* misc.c (_gcry_fatal_error): Use gpg_strerror instead of
gcry_strerror.
* types.h (STRLIST): Removed type since it is not used.
2003-06-11 Moritz Schulte <moritz@g10code.com>
* global.c (global_init): Call: _gcry_cipher_init, _gcry_md_init,
_gcry_pk_init.
* g10lib.h: Declare: _gcry_cipher_init, _gcry_md_init,
_gcry_pk_init.
* global.c (gcry_strerror): Remove compatibility code.
* Makefile.am: Remove support libgpg-error special handling.
(AM_CPPFLAGS): Add @GPG_ERROR_CFLAGS@
* gcrypt.h: Likewise.
2003-06-13 Werner Koch <wk@gnupg.org>
* gcrypt.h (gcry_md_get_algo): Reverted to old API. This is a
convenience function anyway and error checking is not approriate.
(gcry_md_is_enabled): New.
(gcry_md_is_secure): Replaced macro by function and reverted to old
API.
2003-06-11 Werner Koch <wk@gnupg.org>
* gcrypt.h (GCRYERR): Define _GCRY_ERR_SOURCE_DEFAULT instead of
GPG_ERR_SOURCE_DEFAULT, so that libgpg-error still works despite
the use of the old gcrypt error codes.
(gcry_md_copy): Swapped arguments.
2003-06-09 Moritz Schulte <moritz@g10code.com>
* Makefile.am: Support for libgpg-error.
2003-06-08 Moritz Schulte <moritz@g10code.com>
* sexp.c (gcry_sexp_create): Expect sane error values from
gcry_sexp_canon_len instead of the `historical' values.
2003-06-07 Moritz Schulte <moritz@g10code.com>
* ath.c, ath.c, ath-pth.c, ath-pthread.c, benchmark.c, cipher.h,
g10lib.h, gcrypt.h, global.c, misc.c, missing-string.c, module.c,
mpi.h, secmem.c, secmem.h, sexp.c, stdmem.c, stdmem.h, testapi.c,
types.h: Edited all preprocessor instructions to remove whitespace
before the '#'. This is not required by C89, but there are some
compilers out there that don't like it. Replaced any occurence of
the now deprecated type names with the new ones.
* gcrypt.h: Re-organized checking for gcc features; New macro:
_GCRY_GCC_ATTR_DEPRECATED.
Include copy of libgpg-error's gpg-error.h in order to make it
easy to build libgcrypt without needing libgpg-error.h.
(GCRY_MPI, GcryMPI, GCRY_SEXP, GcrySexp, GCRY_CIPHER_HD,
GcryCipherHd, GCRY_MD_HD, GcryMDHd): Declared deprecated.
(gcry_mpi_t, gcry_sexp_t, gcry_cipher_hd_t, gcry_md_hd_t): New
types.
2003-06-04 Moritz Schulte <moritz@g10code.com>
* sexp.c (sexp_sscan): New argument: arg_list, adjusted all
callers.
(ARG_NEXT): New macro.
(sexp_sscan): Use ARG_NEXT for receiving format string arguments.
(gcry_sexp_build_array): New function.
2003-06-02 Moritz Schulte <moritz@g10code.com>
* gcrypt.h: Added some comments describing the gcry_sexp_*
functions.
Include <gpg-error.h> instead of <gpg/error.h>.
2003-06-01 Moritz Schulte <moritz@g10code.com>
* sexp.c (OLDPARSECODE): Removed macro...
(gcry_sexp_canon_len): ... and do not use it.
* gcrypt.h (gcry_errno): Removed declaration.
* g10lib.h (string_to_pubkey_algo, pubkey_algo_to_string,
pubkey_nbits): Removed declarations for non-existing functions.
2003-05-31 Moritz Schulte <moritz@g10code.com>
* cipher.h (is_RSA, is_ELGAMAL): Removed macros.
* g10lib.h (set_lasterr): Removed macro.
(_gcry_set_lasterr): Removed declaration.
* gcrypt.h: Changed declarations for: gcry_pk_algo_info,
gcry_md_open, gcry_md_copy, gcry_md_algo_info, gcry_md_info,
gcry_md_get_algo, gcry_random_add_bytes.
(gcry_md_is_secure): Adjust macro for new API.
2003-05-29 Moritz Schulte <moritz@g10code.com>
* gcrypt.h: Changed declarations for: gcry_cipher_open,
gcry_cipher_info, gcry_cipher_algo_info.
(gcry_cipher_get_algo_keylen): Adjuster for new
gcry_cipher_algo_info interface.
(gcry_cipher_get_algo_blklen): Likewise.
* global.c (gcry_errno): Removed function.
(gcry_strerror): Do not use gcry_errno.
(_gcry_set_lasterr): Removed function.
(last_ec): Removed variable.
2003-05-27 Moritz Schulte <moritz@g10code.com>
* gcrypt.h (enum gcry_cipher_algos): Make Serpent IDs do not
conflict with OpenPGP. Reported by Timo Schulz.
* global.c (gcry_control): Fixed name of enum list.
2003-05-25 Moritz Schulte <moritz@g10code.com>
* cipher.h (gcry_cipher_spec): Adjust return type of `setkey' for
libgpg-error.
(gcry_pubkey_spec): Adjust return type of `generate',
`check_secret_key', `encrypt', `decrypt', `sign' and `verify' for
libgpg-error.
* sexp.c (gcry_sexp_canon_len): Adjusted for libgpg-error.
(gcry_sexp_create): Likewise.
(gcry_sexp_new): Likewise.
(sexp_sscan): Likewise.
(gcry_sexp_build): Likewise.
(gcry_sexp_sscan): Likewise.
* module.c (_gcry_module_add): Likewise.
* global.c (last_ec): Change type to gpg_error_t.
(gcry_control): Adjust for libgpg-error.
(gcry_errno): Likewise.
(gcry_strerror): Likewise.
(_gcry_set_lasterr): Likewise.
(gcry_xmalloc): Likewise.
(gcry_xrealloc): Likewise.
2003-05-22 Moritz Schulte <moritz@g10code.com>
* types.h: Merged code from GnuPG regarding U64_C.
* missing-string.c (strsep): Removed function.
* g10lib.h: Removed declarations: strsep, strlwr.
* secmem.c (secmem_lock): New variable.
(SECMEM_LOCK, SECMEM_UNLOCK): New macros.
(_gcry_secmem_set_flags): Use SECMEM_LOCK and SECMEM_UNLOCK.
(_gcry_secmem_get_flags): Likewise.
(_gcry_secmem_init): Likewie.
(_gcry_secmem_malloc): Likewise.
(_gcry_secmem_free): Likewise.
(_gcry_secmem_malloc): Renamed to ...
(_gcry_secmem_malloc_internal): ... this.
(_gcry_secmem_malloc): New function, use SECMEM_LOCK,
SECMEM_UNLOCK, call _gcry_secmem_malloc_internal.
(_gcry_secmem_free): Renamed to ...
(_gcry_secmem_free_internal): ... this.
(_gcry_secmem_free): New function, use SECMEM_LOCK, SECMEM_UNLOCK,
call _gcry_secmem_free_internal.
(_gcry_secmem_realloc): Use SECMEM_LOCK, SECMEM_UNLOCK, call
_gcry_secmem_malloc_internal and _gcry_secmem_free_internal.
(_gcry_private_is_secure): Use SECMEM_LOCK, SECMEM_UNLOCK.
(_gcry_secmem_dump_stats): Likewise.
(_gcry_secmem_malloc_internal): Removed unused variable:
compressed.
Include "ath.h".
2003-05-21 Moritz Schulte <moritz@g10code.com>
* gcrypt.h (GCRY_CIPHER_SERPENT128, GCRY_CIPHER_SERPENT192,
GCRY_CIPHER_SERPENT256): New symbols.
2003-05-19 Moritz Schulte <moritz@g10code.com>
* gcrypt.h: Reversed changes from 2003-03-03 since they would have
been an unnecessary ABI break.
2003-05-13 Moritz Schulte <moritz@g10code.com>
* secmem.c (stats_update): New function.
(BLOCK_HEAD_SIZE): New symbol.
(MB_FLAG_ACTIVE): New symbol.
(ADDR_TO_BLOCK, BLOCK_VALID): New macros.
(mb_get_next): New function.
(mb_get_prev): New function.
(mb_merge): New function.
(mb_get_new): New function.
(unused_blocks): Removed variable.
(init_pool): Initialize new memory pool.
(_gcry_secmem_malloc): Use new heap management code.
(_gcry_secmem_free): Likewise.
(_gcry_secmem_realloc): Likewise.
Renamed type MEMBLOCK to memblock_t.
2003-04-27 Moritz Schulte <moritz@g10code.com>
* cipher.h (gcry_pubkey_spec): New member: sexp_names.
2003-04-23 Moritz Schulte <moritz@g10code.com>
* cipher.h (gcry_pubkey_spec): Removed members: npkey, nskey,
nenc, nsig.
(gcry_pubkey_spec): Added members: elements_pkey, elements_skey,
elements_enc, elements_sig, elements_grip.
2003-04-17 Moritz Schulte <moritz@g10code.com>
* g10lib.h (GcryModule): New typedef.
* gcrypt.h (gcry_cipher_register, gcry_cipher_unregister,
gcry_digest_register, gcry_digest_unregister,
gcry_pubkey_register, gcry_pubkey_unregister): Function
declarations removed - for now.
* gcrypt.h (GcryModule): Declaration removed.
* gcrypt.h (GcryPubkeySpec, GcryDigestSpec, GcryCipherSpec):
Types Moved...
* cipher.h: ... here.
2003-04-17 Moritz Schulte <moritz@g10code.com>
* cipher.h: Declare digest_spec_sha512 and digest_spec_384.
2003-04-16 Moritz Schulte <moritz@g10code.com>
* module.c (_gcry_module_use): New function.
* g10lib.h (_gcry_module_use): Declare function.
* libgcrypt-config.in: Support for --algorithms switch, which
prints the algorithms included in the built libgcrypt.
* global.c (gcry_set_progress_handler): Register progress
functions depending on the enabled algorithms.
2003-04-07 Moritz Schulte <moritz@g10code.com>
* Makefile.am (libgcrypt_la_SOURCES): Added module.c
* module.c: New file.
(_gcry_module_add): New function.
(_gcry_module_drop): New function.
(_gcry_module_lookup): New function.
(_gcry_module_release): New function.
* g10lib.h (GcryModule): New types.
(FLAG_MODULE_DISABLED): New symbol.
Added declarations for _gcry_module_add, _gcry_module_release and
_gcry_module_lookup.
* gcrypt.h: New types: GcryPubkeySpec, GcryDigestSpec,
GcryCipherSpec.
Added declarations for: gcry_cipher_register,
gcry_cipher_unregister, gcry_digest_register,
gcry_digest_unregister, gcry_pubkey_register and
gcry_pubkey_unregister.
* cipher.h: Removed symbols: CIPHER_ALGO_NONE, CIPHER_ALGO_IDEA,
CIPHER_ALGO_3DES, CIPHER_ALGO_CAST5, CIPHER_ALGO_BLOWFISH,
CIPHER_ALGO_SAFER_SK128, CIPHER_ALGO_DES_SK, CIPHER_ALGO_TWOFISH,
CIPHER_ALGO_TWOFISH_OLD, CIPHER_ALGO_DUMMY, PUBKEY_USAGE_SIG,
PUBKEY_USAGE_ENC, DIGEST_ALGO_MD5, DIGEST_ALGO_SHA1,
DIGEST_ALGO_RMD160, DIGEST_ALGO_TIGER, PUBKEY_ALGO_RSA,
PUBKEY_ALGO_RSA_E, PUBKEY_ALGO_RSA_S, PUBKEY_ALGO_DSA,
PUBKEY_ALGO_ELGAMAL, PUBKEY_ALGO_ELGAMAL_E.
2003-04-02 Moritz Schulte <moritz@g10code.com>
* benchmark.c (md_bench): Fix error message.
2003-03-31 Moritz Schulte <moritz@g10code.com>
* benchmark.c (cipher_bench): Added CTR mode.
2003-03-30 Simon Josefsson <jas@extundo.com>
* gcrypt.h (enum gcry_control_cmds): Add GCRY_SET_CTR.
(enum gcry_cipher_modes): Add GCRY_CIPHER_MODE_CTR.
(gcry_cipher_setctr): New macro to set counter.
2003-03-19 Moritz Schulte <moritz@g10code.com>
* cipher.h (PUBKEY_FLAG_NO_BLINDING): New symbol.
2003-03-22 Simon Josefsson <jas@extundo.com>
* gcrypt.h: Add GCRYCTL_SET_CBC_MAC and GCRY_CIPHER_CBC_MAC.
2003-03-19 Werner Koch <wk@gnupg.org>
* g10lib.h: Adjusted primegen.c prototypes.
2003-03-12 Werner Koch <wk@gnupg.org>
* sexp.c (sexp_sscan): Initialize NM. Thanks to Ian Peters for
valgrinding this.
2003-03-06 Moritz Schulte <mo@g10code.com>
* secmem.h (GCRY_SECMEM_FLAG_NO_WARNING,
GCRY_SECMEM_FLAG_SUSPEND_WARNING): New symbols.
* global.c (gcry_control): Use
GCRY_SECMEM_FLAG_{NO,SUSPEND}_WARNING, instead of hard-coded
values.
* secmem.c (_gcry_secmem_set_flags): Likewise.
* secmem.c (_gcry_secmem_get_flags): Likewise.
2003-03-03 Moritz Schulte <moritz@g10code.com>
* misc.c: Removed old FIXME, since there is already a function to
set the value of `verbosity_level'.
* gcrypt.h: Removed enumeration list: gcry_ctl_cmds.
New enumeration lists: gcry_global_control_cmds,
gcry_control_cmds, gcry_info_cmds, gcry_algo_info_cmds.
2003-03-02 Moritz Schulte <moritz@g10code.com>
* gcrypt.h (gcry_cipher_reset): New macro for resetting a handle.
2003-02-28 Moritz Schulte <moritz@g10code.com>
* secmem.c (DEFAULT_PAGESIZE): New symbol.
(init_pool): Use DEFAULT_PAGESIZE.
2003-02-23 Moritz Schulte <moritz@g10code.com>
* secmem.h: Fix typo in declaration of _gcry_secmem_term.
* sexp.c: Move macro definitions of `digitp', `octdigit', `alphap'
and `hexdigit' ...
* g10lib.h: ... here.
* misc.c (_gcry_burn_stack): New function (former name:
burn_stack).
* g10lib.h (burn_stack): Declare _gcry_burn_stack().
2003-01-24 Werner Koch <wk@gnupg.org>
* global.c (gcry_set_progress_handler): Register a random progress
handler.
2003-01-23 Werner Koch <wk@gnupg.org>
* gcrypt.h (GCRY_ENABLE_QUICK_RANDOM): New.
* global.c (gcry_control): Make use of it.
2003-01-21 Werner Koch <wk@gnupg.org>
* gcrypt.h (gcry_random_add_bytes): Add QUALITY argument.
2003-01-21 Timo Schulz <twoaday@freakmail.de>
* gcrypt.h (gcry_random_add_bytes): New.
2003-01-20 Simon Josefsson <jas@extundo.com>
* gcrypt.h (gcry_md_algos): Add GCRY_MD_CRC32,
GCRY_MD_CRC32_RFC1510, GCRY_MD_CRC24_RFC2440.
2003-01-16 Werner Koch <wk@gnupg.org>
* gcrypt.h (gcry_md_write): Changed type of 2nd argument to void*.
(gcry_md_hash_buffer): Changed type of both buffers to void*.
(gcry_md_setkey): Changed type of 2nd argument to void*.
(gcry_md_get_asnoid): New.
2003-01-15 Werner Koch <wk@gnupg.org>
* sexp.c (gcry_sexp_length): Fixed. This was seriously broken.
2003-01-14 Werner Koch <wk@gnupg.org>
* gcrypt.h (GCRYERR_INV_FLAG), global.c (gcry_strerror): New.
2003-01-02 Werner Koch <wk@gnupg.org>
* libgcrypt.vers: Temporary export _gcry_generate_elg_prime for
use by GNUTLS.
2002-12-21 Werner Koch <wk@gnupg.org>
* gcrypt.h: Make use of gcc's pure and malloc attributes
(gcry_md_putc): Use a helper variable to avoid multiple
evaluation of H.
* g10lib.h, stdmem.h, secmem.h: Use gcc attributes pure and malloc.
* stdmem.c (use_m_guard): Don't default to yes.
2002-12-19 Werner Koch <wk@gnupg.org>
* global.c (global_init): The meat was never run due to a faulty
check. Thanks to Nikos for pointing this out.
* global.c (gcry_control): Return 1 and not -1 for the
initialization tests.
* libgcrypt.vers: New.
* Makefile.am: Use this instead of the build symbol file.
* global.c (gcry_control) <initialization>: Call the random module
initializer to make sure that the pool lock flag has been
initialized.
2002-12-09 Werner Koch <wk@gnupg.org>
* global.c (gcry_calloc,gcry_calloc_secure): Check for overflow.
Noted by Florian Weimer.
2002-11-10 Simon Josefsson <jas@extundo.com>
* gcrypt.h (gcry_ctl_cmds): New GCRYCTL_SET_CBC_CTS control flag.
(gcry_cipher_flags): New GCRY_CIPHER_CBC_CTS gcry_cipher_open() flag.
(gcry_cipher_cts): New macro for toggling CTS.
2002-11-10 Werner Koch <wk@gnupg.org>
* gcrypt.h (GCRY_MD_MD4): New. We use a non OpenPGP value here.
2002-09-20 Werner Koch <wk@gnupg.org>
* ath.c: Include sys.time.h if sys/select.h does not exist.
(ath_select, ath_waitpid): Shortcut for Windows.
* ath.h: Include some Windows headers. By Timo.
2002-09-18 Werner Koch <wk@gnupg.org>
* ath.h: Prefix ath_deinit.
2002-09-17 Werner Koch <wk@gnupg.org>
* benchmark.c: New.
(mpi_bench, do_powm): Add a a simple test for RSA.
* global.c (global_init): New. Use it instead of the setting
any_init_done. Initialize the ATH system.
(gcry_check_version): Hook global_init in. This is the suggested
way to initialize the library.
(_gcry_no_internal_locking): Removed. We simply call a ath_deinit
and leave it to ATH to disbale the locking.
* ath.c, ath.h, ath-pth.c, ath-pthread.c: New. Taken from GPGME.
* mutex.h: Removed.
* Makefile.am (ath_components): New.
2002-09-16 Werner Koch <wk@gnupg.org>
* secmem.c (_gcry_secmem_dump_stats): Replaced fprintf by log_*.
2002-08-23 Werner Koch <wk@gnupg.org>
* missing-string.c: Removed unneeded strlwr.
* libgcrypt.m4: Made much more simple.
* libgcrypt-config.in: Made --prefix work for --libs.
2002-08-14 Werner Koch <wk@gnupg.org>
* gcrypt.h: Add GCRY_CIPGER_DES. Included string.h for size_t.
Suggested by Simon Josefsson.
2002-07-25 Werner Koch <wk@gnupg.org>
* cipher.h: Added prototypes for progress functions.
* global.c: Include cipher.h for those prototypes.
* stdmem.c (_gcry_private_realloc): Replaced void* by char * for
pointer arithmetic reasons. Noted by Stephan Austermuehle.
2002-06-24 Werner Koch <wk@gnupg.org>
* missing-string.c: Include ctype.h.
* gcrypt.h (gcry_mpi_invm, gcry_mpi_div, gcry_mpi_mod)
(gcry_mpi_swap): New.
2002-06-18 Werner Koch <wk@gnupg.org>
* gcrypt.h: Added a bunch of brief function descriptions.
2002-05-21 Werner Koch <wk@gnupg.org>
* misc.c (_gcry_log_printf): Don't initialize a va_list. Noted by
Jeff Johnson.
* global.c (gcry_set_progress_handler): New.
* gcrypt.h: Replaced the typedef for byte.
2002-05-16 Werner Koch <wk@gnupg.org>
* missing-string.c: New.
* gcrypt.h: Add new error codes GCRYERR_SEXP_ and typedefs
GcryMPI, GcrySexp, GcryCipherHd, GcryMDHd as aliases for the old
ones using an underscore.
* global.c (gcry_strerror): Add strings fro the new error codes.
* sexp.c (gcry_sexp_canon_len): Use a macro to convert from new to
old error codes.
(gcry_sexp_create,gcry_sexp_new): New.
2002-05-15 Werner Koch <wk@gnupg.org>
* mutex.h (DEFINE_LOCAL_MUTEX): Macro to define a mutex and
initialize it so that we can detect an unitialized mutex and don't
read from stdin.
2002-05-14 Werner Koch <wk@gnupg.org>
Changed license of all files to the LGPL.
2002-05-07 Werner Koch <wk@gnupg.org>
* global.c (gcry_control): Add commands
GCRYCTL_ANY_INITIALIZATION_P and GCRYCTL_INITIALIZATION_FINISHED_P
so that other libraries are able to check for required
initializations.
2002-05-02 Werner Koch <wk@gnupg.org>
* gcrypt.h (GCRYCTL_DISABLE_INTERNAL_LOCKING): New.
* global.c (gcry_control): Implement it.
(_gcry_no_internal_locking): New.
* mutex.h: Prefixed all fucntions with _gcry_. Bypass all
functions when desired.
* gcrypt.h (GCRYCTL_DISABLE_SECMEM): New.
* global.c (gcry_control,gcry_malloc_secure,gcry_is_secure):
Implement it here.
* secmem.c (_gcry_private_is_secure): Return false if the pool is
not initialized.
* gcrypt.h (GCRYCTL_INITIALIZATION_FINISHED): New.
* gcrypt.h (gcry_cipher_algos): Replaced RINDAEL by AES and change
the macros to expand from rijdael to aes.
* stdmem.c (_gcry_private_malloc): Return NULL for 0 byte allocation.
(_gcry_private_malloc_secure): Ditto.
* g10lib.h: Copied the JNLIB_GCC macros from ../jnlib/mischelp.h
and removed the inclusion of that file.
2002-04-15 Werner Koch <wk@gnupg.org>
* global.c (gcry_strdup): New.
2002-03-18 Werner Koch <wk@gnupg.org>
* mutex.h: New file with a portable thread mutex implementation
written by Marcus Brinkmann. Taken from GPGME.
2002-02-18 Werner Koch <wk@gnupg.org>
* sexp.c (gcry_sexp_sscan): Don't initialize the dummy
variable. Suggested by Jordi Mallach.
2002-01-31 Werner Koch <wk@gnupg.org>
* sexp.c (suitable_encoding,convert_to_hex,convert_to_string)
(convert_to_token): New.
(gcry_sexp_sprint): Better formatting of advanced encoding, does
now insert LFs and escapes all unprintable characters.
(unquote_string): New.
(sexp_sscan): Implemented the missing conversion of quoted strings.
2002-01-26 Werner Koch <wk@gnupg.org>
* libgcrypt-config.in: Add copyright notice.
2002-01-11 Werner Koch <wk@gnupg.org>
* sexp.c (gcry_sexp_canon_len): Fixed last change.
2002-01-01 Timo Schulz <ts@winpt.org>
* stdmem.c (_gcry_private_realloc): If pointer is NULL now realloc
behaves like malloc.
2001-12-20 Werner Koch <wk@gnupg.org>
* sexp.c (gcry_sexp_canon_len): Describe the error codes and
return an error if this is not a S-Exp; i.e. it does not start
with an open parenthesis.
2001-12-18 Werner Koch <wk@gnupg.org>
* sexp.c (gcry_sexp_canon_len): Fixed the test on NULL buffer.
* Makefile.am (DISTCLEANFILES): Include libgcrypt.sym
* sexp.c: Removed the commented test code because we now have a
test in ../tests/
2001-12-17 Werner Koch <wk@gnupg.org>
* sexp.c (gcry_sexp_canon_len): New.
2001-12-11 Werner Koch <wk@gnupg.org>
* gcrypt.h: Fixed AES128 macro, add enum for OFB mode.
2001-12-05 Werner Koch <wk@gnupg.org>
* misc.c (_gcry_log_printf): New.
* sexp.c (dump_string,gcry_sexp_dump): Use logging functions
instead of stderr.
2001-11-16 Werner Koch <wk@gnupg.org>
* gcrypt.h: New constant GCRYCTL_IS_ALGO_ENABLED.
2001-10-02 Werner Koch <wk@gnupg.org>
* gcrypt.h: Removed a couple of trailing commas.
2001-08-28 Werner Koch <wk@gnupg.org>
* sexp.c (sexp_sscan): Add an argument to enable the
arg_ptr. Changed all callers. Suggested by Tom Holroyd.
2001-08-03 Werner Koch <wk@gnupg.org>
* global.c (gcry_strerror): Updated list of error codes.
2001-07-23 Werner Koch <wk@gnupg.org>
* gcrypt.h: Replaced the last ulong. Noted by Rami Lehti.
2001-05-31 Werner Koch <wk@gnupg.org>
* gcrypt.h, mpi.h: Made some mpi functions public.
* wrapper.c: Removed.
* global.c: Renamed all g10_ prefixed functions which had wrappers
to gcry_xxx. So we now use the exported memory functions inernally.
Renamed all g10_ prefixed functions to _gcry_ prefixed ones.
* g10lib.h (_GCRYPT_IN_LIBGCRYPT): Replace defintion by a test on it.
2001-05-28 Werner Koch <wk@gnupg.org>
* libgcrypt.m4: Check GCRYPT_VERSION macro and not LIBGCRYPT_VERSION.
* mpi.h: Removed mpi_fromstr prototype.
2001-01-11 Werner Koch <wk@gnupg.org>
* Makefile.am (libgcrypt_la_SOURCES): Add mpi.h
2000-12-19 Werner Koch <wk@gnupg.org>
* types.h: Moved from ../include to here.
Major change:
Removed all GnuPG stuff and renamed this piece of software
to gcrypt.
2000-11-14 Werner Koch <wk@gnupg.org>
* mpi.h: Moved to ../mpi.
* Makefile.am (OMIT_DEPENDENCIES): Hack to work around dependency
problems.
2000-10-11 Werner Koch <wk@gnupg.org>
* mpi.h: Changed the way mpi_limb_t is defined.
2000-10-10 Werner Koch <wk@gnupg.org>
* Makefile.am: Take version-info from configure.
2000-10-09 Werner Koch <wk@gnupg.org>
* gcrypt.h: New cipher mode, new algo Arcfour and new error code
GCRYERR_INV_CIPHER_MODE.
* global.c (gcry_strerror): New errorcode.
Wed Oct 4 13:16:18 CEST 2000 Werner Koch <wk@openit.de>
* gcrypt.h (gcry_md_setkey): Replaced macro by function prototype.
Mon Sep 18 16:35:45 CEST 2000 Werner Koch <wk@openit.de>
* gcrypt.h (GCRYCTL_GET_ALGO_USAGE): New.
* secmem.c (secmem_realloc): check for failed secmem_malloc. By
Matt Kraai.
Mon Jul 31 10:04:47 CEST 2000 Werner Koch <wk@openit.de>
* sexp.c: Removed the datalen fields from list tags.
(gcry_sexp_car_data,gcry_sexp_cdr_data,gcry_sexp_car_mpi,
gcry_sexp_cdr_mpi): Removed.
(gcry_sexp_nth,gcry_sexp_nth_data,gcry_sexp_nth_mpi): New.
Fri Jul 28 18:19:11 CEST 2000 Werner Koch <wk@openit.de>
* sexp.c (sexp_sscan): Fixed reallocation to secure memory.
(new_empty_list): Removed
(gcry_sexp_length): New.
(gcry_sexp_enum): Removed.
(normalize): New. Reworked the whole thing to use NULL for an empty list.
(make_space): New instead of the macro.
Tue Jul 25 17:44:15 CEST 2000 Werner Koch <wk@openit.de>
* sexp.c: Major rewrite.
(gcry_sexp_sscan): Reordered arguments. Moved functionality to ..
(sexp_sscan): .. this.
(gcry_sexp_build): New.
(gcry_sexp_new_name_mpi, gcry_sexp_new_name_data, gcry_sexp_new_data,
gcry_sexp_new_mpi): Removed.
Fri Jul 14 19:38:23 CEST 2000 Werner Koch <wk@>
* gcrypt.h (gcry_md_start_debug, gcry_md_stop_debug): New.
(gcry_ctl_cmds): New control values
* sexp.c (gcry_sexp_sscan): Add hex format parsing.
* secmem.c (lock_pool): Check for ENOSYS return my mlock() on old SCOs.
(pool_is_mmapped): Made volatile.
(lock_pool): No more warning for QNX. By Sam Roberts.
(lock_pool,secmem_init): Additional check for dropped privs.
2000-03-21 09:18:48 Werner Koch (wk@habibti.gnupg.de)
* gcrypt.h (gcry_md_setkey): New.
(GCRY_MD_FLAG_HMAC): New.
Mon Jan 31 16:37:34 CET 2000 Werner Koch <wk@gnupg.de>
* Makefile.am: Add g10lib.h
Thu Jan 27 18:00:44 CET 2000 Werner Koch <wk@gnupg.de>
* sexp.c (gcry_sexp_sscan): Allow NULL for erroff.
Mon Jan 24 22:24:38 CET 2000 Werner Koch <wk@gnupg.de>
* sexp.c (gcry_sexp_alist): New.
Mon Jan 24 13:04:28 CET 2000 Werner Koch <wk@gnupg.de>
* secmem.c: Moved from ../util to here.
* secmem.h: New.
* stdmem.c: New. Based on the old ../util/memory.c.
* stdmem.h: New.
Wed Dec 8 21:58:32 CET 1999 Werner Koch <wk@gnupg.de>
* gcrypt.m4: New.
* gcrypt-config: New.
* mpi.h (mpi_get_nbit_info): Removed
(mpi_set_nbit_info): Removed.
(struct gcry_mpi): Removed the nbits field.
* misc.c (g10_log_verbosity): New.
* global.c (g10_xstrdup): New.
* mpiapi.c: Removed.
* mpi.h: Moved from ../include to here. Removed some obsolete
prototypes and the iobuf.h header.
* cipher.h: Moved from ../include to here. Removed the mpi.h header.
* g10lib.h: Moved from ../include to here.
Fri Nov 19 17:15:20 CET 1999 Werner Koch <wk@gnupg.de>
* sexp.c (dump_string): New. Taken from gnupg/util/miscutil.c.
(do_dump_list): s/print_string/dump_string/.
* testapi.c: New.
* mpiapi.c (gcry_mpi_randomize): Use new random API.
Sat Nov 13 17:44:23 CET 1999 Werner Koch <wk@gnupg.de>
* gloabl.c (gcry_control): Add cases for dumping random
and secmem stats.
Tue Oct 26 14:10:21 CEST 1999 Werner Koch <wk@gnupg.de>
* pkapi.c: Removed.
* symapi.c: Removed.
* g10lib.h: Moved to ../include.
* mdapi.c: Removed.
Wed Jul 7 13:08:40 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* sexp.c: New.
Tue Dec 8 13:15:16 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
* gcrypt.h: New
* mpiapi.c: New
Copyright (C) 1998,1999,2000,2001,2002,2003
2004,2005,2008,2009,2011 Free Software Foundation, Inc.
This file is free software; as a special exception the author gives
unlimited permission to copy and/or distribute it, with or without
modifications, as long as this notice is preserved.
This file is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/src/secmem.c b/src/secmem.c
index 30c27774..2beb234a 100644
--- a/src/secmem.c
+++ b/src/secmem.c
@@ -1,691 +1,696 @@
/* secmem.c - memory allocation from a secure heap
* Copyright (C) 1998, 1999, 2000, 2001, 2002,
* 2003, 2007 Free Software Foundation, Inc.
*
* This file is part of Libgcrypt.
*
* Libgcrypt is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser general Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* Libgcrypt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <stdarg.h>
#include <unistd.h>
#include <stddef.h>
#if defined(HAVE_MLOCK) || defined(HAVE_MMAP)
#include <sys/mman.h>
#include <sys/types.h>
#include <fcntl.h>
#ifdef USE_CAPABILITIES
#include <sys/capability.h>
#endif
#endif
#include "ath.h"
#include "g10lib.h"
#include "secmem.h"
#if defined (MAP_ANON) && ! defined (MAP_ANONYMOUS)
#define MAP_ANONYMOUS MAP_ANON
#endif
#define MINIMUM_POOL_SIZE 16384
#define STANDARD_POOL_SIZE 32768
#define DEFAULT_PAGE_SIZE 4096
typedef struct memblock
{
unsigned size; /* Size of the memory available to the
user. */
int flags; /* See below. */
PROPERLY_ALIGNED_TYPE aligned;
} memblock_t;
/* This flag specifies that the memory block is in use. */
#define MB_FLAG_ACTIVE (1 << 0)
/* The pool of secure memory. */
static void *pool;
/* Size of POOL in bytes. */
static size_t pool_size;
/* True, if the memory pool is ready for use. May be checked in an
atexit function. */
static volatile int pool_okay;
/* True, if the memory pool is mmapped. */
static volatile int pool_is_mmapped;
/* FIXME? */
static int disable_secmem;
static int show_warning;
static int not_locked;
static int no_warning;
static int suspend_warning;
/* Stats. */
static unsigned int cur_alloced, cur_blocks;
/* Lock protecting accesses to the memory pool. */
static ath_mutex_t secmem_lock;
/* Convenient macros. */
#define SECMEM_LOCK ath_mutex_lock (&secmem_lock)
#define SECMEM_UNLOCK ath_mutex_unlock (&secmem_lock)
/* The size of the memblock structure; this does not include the
memory that is available to the user. */
#define BLOCK_HEAD_SIZE \
offsetof (memblock_t, aligned)
/* Convert an address into the according memory block structure. */
#define ADDR_TO_BLOCK(addr) \
(memblock_t *) ((char *) addr - BLOCK_HEAD_SIZE)
/* Check whether P points into the pool. */
static int
ptr_into_pool_p (const void *p)
{
/* We need to convert pointers to addresses. This is required by
C-99 6.5.8 to avoid undefined behaviour. Using size_t is at
least only implementation defined. See also
http://lists.gnupg.org/pipermail/gcrypt-devel/2007-February/001102.html
*/
size_t p_addr = (size_t)p;
size_t pool_addr = (size_t)pool;
return p_addr >= pool_addr && p_addr < pool_addr+pool_size;
}
/* Update the stats. */
static void
stats_update (size_t add, size_t sub)
{
if (add)
{
cur_alloced += add;
cur_blocks++;
}
if (sub)
{
cur_alloced -= sub;
cur_blocks--;
}
}
/* Return the block following MB or NULL, if MB is the last block. */
static memblock_t *
mb_get_next (memblock_t *mb)
{
memblock_t *mb_next;
mb_next = (memblock_t *) ((char *) mb + BLOCK_HEAD_SIZE + mb->size);
if (! ptr_into_pool_p (mb_next))
mb_next = NULL;
return mb_next;
}
/* Return the block preceding MB or NULL, if MB is the first
block. */
static memblock_t *
mb_get_prev (memblock_t *mb)
{
memblock_t *mb_prev, *mb_next;
if (mb == pool)
mb_prev = NULL;
else
{
mb_prev = (memblock_t *) pool;
while (1)
{
mb_next = mb_get_next (mb_prev);
if (mb_next == mb)
break;
else
mb_prev = mb_next;
}
}
return mb_prev;
}
/* If the preceding block of MB and/or the following block of MB
exist and are not active, merge them to form a bigger block. */
static void
mb_merge (memblock_t *mb)
{
memblock_t *mb_prev, *mb_next;
mb_prev = mb_get_prev (mb);
mb_next = mb_get_next (mb);
if (mb_prev && (! (mb_prev->flags & MB_FLAG_ACTIVE)))
{
mb_prev->size += BLOCK_HEAD_SIZE + mb->size;
mb = mb_prev;
}
if (mb_next && (! (mb_next->flags & MB_FLAG_ACTIVE)))
mb->size += BLOCK_HEAD_SIZE + mb_next->size;
}
/* Return a new block, which can hold SIZE bytes. */
static memblock_t *
mb_get_new (memblock_t *block, size_t size)
{
memblock_t *mb, *mb_split;
for (mb = block; ptr_into_pool_p (mb); mb = mb_get_next (mb))
if (! (mb->flags & MB_FLAG_ACTIVE) && mb->size >= size)
{
/* Found a free block. */
mb->flags |= MB_FLAG_ACTIVE;
if (mb->size - size > BLOCK_HEAD_SIZE)
{
/* Split block. */
mb_split = (memblock_t *) (((char *) mb) + BLOCK_HEAD_SIZE + size);
mb_split->size = mb->size - size - BLOCK_HEAD_SIZE;
mb_split->flags = 0;
mb->size = size;
mb_merge (mb_split);
}
break;
}
if (! ptr_into_pool_p (mb))
- mb = NULL;
+ {
+ gpg_err_set_errno (ENOMEM);
+ mb = NULL;
+ }
return mb;
}
/* Print a warning message. */
static void
print_warn (void)
{
if (!no_warning)
log_info (_("Warning: using insecure memory!\n"));
}
/* Lock the memory pages into core and drop privileges. */
static void
lock_pool (void *p, size_t n)
{
#if defined(USE_CAPABILITIES) && defined(HAVE_MLOCK)
int err;
cap_set_proc (cap_from_text ("cap_ipc_lock+ep"));
err = mlock (p, n);
if (err && errno)
err = errno;
cap_set_proc (cap_from_text ("cap_ipc_lock+p"));
if (err)
{
if (errno != EPERM
#ifdef EAGAIN /* OpenBSD returns this */
&& errno != EAGAIN
#endif
#ifdef ENOSYS /* Some SCOs return this (function not implemented) */
&& errno != ENOSYS
#endif
#ifdef ENOMEM /* Linux might return this. */
&& errno != ENOMEM
#endif
)
log_error ("can't lock memory: %s\n", strerror (err));
show_warning = 1;
not_locked = 1;
}
#elif defined(HAVE_MLOCK)
uid_t uid;
int err;
uid = getuid ();
#ifdef HAVE_BROKEN_MLOCK
/* Under HP/UX mlock segfaults if called by non-root. Note, we have
noch checked whether mlock does really work under AIX where we
also detected a broken nlock. Note further, that using plock ()
is not a good idea under AIX. */
if (uid)
{
errno = EPERM;
err = errno;
}
else
{
err = mlock (p, n);
if (err && errno)
err = errno;
}
#else /* !HAVE_BROKEN_MLOCK */
err = mlock (p, n);
if (err && errno)
err = errno;
#endif /* !HAVE_BROKEN_MLOCK */
if (uid && ! geteuid ())
{
/* check that we really dropped the privs.
* Note: setuid(0) should always fail */
if (setuid (uid) || getuid () != geteuid () || !setuid (0))
log_fatal ("failed to reset uid: %s\n", strerror (errno));
}
if (err)
{
if (errno != EPERM
#ifdef EAGAIN /* OpenBSD returns this. */
&& errno != EAGAIN
#endif
#ifdef ENOSYS /* Some SCOs return this (function not implemented). */
&& errno != ENOSYS
#endif
#ifdef ENOMEM /* Linux might return this. */
&& errno != ENOMEM
#endif
)
log_error ("can't lock memory: %s\n", strerror (err));
show_warning = 1;
not_locked = 1;
}
#elif defined ( __QNX__ )
/* QNX does not page at all, so the whole secure memory stuff does
* not make much sense. However it is still of use because it
* wipes out the memory on a free().
* Therefore it is sufficient to suppress the warning. */
(void)p;
(void)n;
#elif defined (HAVE_DOSISH_SYSTEM) || defined (__CYGWIN__)
/* It does not make sense to print such a warning, given the fact that
* this whole Windows !@#$% and their user base are inherently insecure. */
(void)p;
(void)n;
#elif defined (__riscos__)
/* No virtual memory on RISC OS, so no pages are swapped to disc,
* besides we don't have mmap, so we don't use it! ;-)
* But don't complain, as explained above. */
(void)p;
(void)n;
#else
(void)p;
(void)n;
log_info ("Please note that you don't have secure memory on this system\n");
#endif
}
/* Initialize POOL. */
static void
init_pool (size_t n)
{
size_t pgsize;
long int pgsize_val;
memblock_t *mb;
pool_size = n;
if (disable_secmem)
log_bug ("secure memory is disabled");
#if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)
pgsize_val = sysconf (_SC_PAGESIZE);
#elif defined(HAVE_GETPAGESIZE)
pgsize_val = getpagesize ();
#else
pgsize_val = -1;
#endif
pgsize = (pgsize_val != -1 && pgsize_val > 0)? pgsize_val:DEFAULT_PAGE_SIZE;
#if HAVE_MMAP
pool_size = (pool_size + pgsize - 1) & ~(pgsize - 1);
#ifdef MAP_ANONYMOUS
pool = mmap (0, pool_size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
#else /* map /dev/zero instead */
{
int fd;
fd = open ("/dev/zero", O_RDWR);
if (fd == -1)
{
log_error ("can't open /dev/zero: %s\n", strerror (errno));
pool = (void *) -1;
}
else
{
pool = mmap (0, pool_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
close (fd);
}
}
#endif
if (pool == (void *) -1)
log_info ("can't mmap pool of %u bytes: %s - using malloc\n",
(unsigned) pool_size, strerror (errno));
else
{
pool_is_mmapped = 1;
pool_okay = 1;
}
#endif
if (!pool_okay)
{
pool = malloc (pool_size);
if (!pool)
log_fatal ("can't allocate memory pool of %u bytes\n",
(unsigned) pool_size);
else
pool_okay = 1;
}
/* Initialize first memory block. */
mb = (memblock_t *) pool;
mb->size = pool_size;
mb->flags = 0;
}
void
_gcry_secmem_set_flags (unsigned flags)
{
int was_susp;
SECMEM_LOCK;
was_susp = suspend_warning;
no_warning = flags & GCRY_SECMEM_FLAG_NO_WARNING;
suspend_warning = flags & GCRY_SECMEM_FLAG_SUSPEND_WARNING;
/* and now issue the warning if it is not longer suspended */
if (was_susp && !suspend_warning && show_warning)
{
show_warning = 0;
print_warn ();
}
SECMEM_UNLOCK;
}
unsigned int
_gcry_secmem_get_flags (void)
{
unsigned flags;
SECMEM_LOCK;
flags = no_warning ? GCRY_SECMEM_FLAG_NO_WARNING : 0;
flags |= suspend_warning ? GCRY_SECMEM_FLAG_SUSPEND_WARNING : 0;
flags |= not_locked ? GCRY_SECMEM_FLAG_NOT_LOCKED : 0;
SECMEM_UNLOCK;
return flags;
}
/* See _gcry_secmem_init. This function is expected to be called with
the secmem lock held. */
static void
secmem_init (size_t n)
{
if (!n)
{
#ifdef USE_CAPABILITIES
/* drop all capabilities */
cap_set_proc (cap_from_text ("all-eip"));
#elif !defined(HAVE_DOSISH_SYSTEM)
uid_t uid;
disable_secmem = 1;
uid = getuid ();
if (uid != geteuid ())
{
if (setuid (uid) || getuid () != geteuid () || !setuid (0))
log_fatal ("failed to drop setuid\n");
}
#endif
}
else
{
if (n < MINIMUM_POOL_SIZE)
n = MINIMUM_POOL_SIZE;
if (! pool_okay)
{
init_pool (n);
lock_pool (pool, n);
}
else
log_error ("Oops, secure memory pool already initialized\n");
}
}
/* Initialize the secure memory system. If running with the necessary
privileges, the secure memory pool will be locked into the core in
order to prevent page-outs of the data. Furthermore allocated
secure memory will be wiped out when released. */
void
_gcry_secmem_init (size_t n)
{
SECMEM_LOCK;
secmem_init (n);
SECMEM_UNLOCK;
}
static void *
_gcry_secmem_malloc_internal (size_t size)
{
memblock_t *mb;
if (!pool_okay)
{
/* Try to initialize the pool if the user forgot about it. */
secmem_init (STANDARD_POOL_SIZE);
if (!pool_okay)
{
log_info (_("operation is not possible without "
"initialized secure memory\n"));
+ gpg_err_set_errno (ENOMEM);
return NULL;
}
}
if (not_locked && fips_mode ())
{
log_info (_("secure memory pool is not locked while in FIPS mode\n"));
+ gpg_err_set_errno (ENOMEM);
return NULL;
}
if (show_warning && !suspend_warning)
{
show_warning = 0;
print_warn ();
}
/* Blocks are always a multiple of 32. */
size = ((size + 31) / 32) * 32;
mb = mb_get_new ((memblock_t *) pool, size);
if (mb)
stats_update (size, 0);
return mb ? &mb->aligned.c : NULL;
}
void *
_gcry_secmem_malloc (size_t size)
{
void *p;
SECMEM_LOCK;
p = _gcry_secmem_malloc_internal (size);
SECMEM_UNLOCK;
return p;
}
static void
_gcry_secmem_free_internal (void *a)
{
memblock_t *mb;
int size;
if (!a)
return;
mb = ADDR_TO_BLOCK (a);
size = mb->size;
/* This does not make much sense: probably this memory is held in the
* cache. We do it anyway: */
#define MB_WIPE_OUT(byte) \
wipememory2 ((memblock_t *) ((char *) mb + BLOCK_HEAD_SIZE), (byte), size);
MB_WIPE_OUT (0xff);
MB_WIPE_OUT (0xaa);
MB_WIPE_OUT (0x55);
MB_WIPE_OUT (0x00);
stats_update (0, size);
mb->flags &= ~MB_FLAG_ACTIVE;
/* Update stats. */
mb_merge (mb);
}
/* Wipe out and release memory. */
void
_gcry_secmem_free (void *a)
{
SECMEM_LOCK;
_gcry_secmem_free_internal (a);
SECMEM_UNLOCK;
}
/* Realloc memory. */
void *
_gcry_secmem_realloc (void *p, size_t newsize)
{
memblock_t *mb;
size_t size;
void *a;
SECMEM_LOCK;
mb = (memblock_t *) ((char *) p - ((size_t) &((memblock_t *) 0)->aligned.c));
size = mb->size;
if (newsize < size)
{
/* It is easier to not shrink the memory. */
a = p;
}
else
{
a = _gcry_secmem_malloc_internal (newsize);
if (a)
{
memcpy (a, p, size);
memset ((char *) a + size, 0, newsize - size);
_gcry_secmem_free_internal (p);
}
}
SECMEM_UNLOCK;
return a;
}
/* Return true if P points into the secure memory area. */
int
_gcry_private_is_secure (const void *p)
{
return pool_okay && ptr_into_pool_p (p);
}
/****************
* Warning: This code might be called by an interrupt handler
* and frankly, there should really be such a handler,
* to make sure that the memory is wiped out.
* We hope that the OS wipes out mlocked memory after
* receiving a SIGKILL - it really should do so, otherwise
* there is no chance to get the secure memory cleaned.
*/
void
_gcry_secmem_term ()
{
if (!pool_okay)
return;
wipememory2 (pool, 0xff, pool_size);
wipememory2 (pool, 0xaa, pool_size);
wipememory2 (pool, 0x55, pool_size);
wipememory2 (pool, 0x00, pool_size);
#if HAVE_MMAP
if (pool_is_mmapped)
munmap (pool, pool_size);
#endif
pool = NULL;
pool_okay = 0;
pool_size = 0;
not_locked = 0;
}
void
_gcry_secmem_dump_stats ()
{
#if 1
SECMEM_LOCK;
if (pool_okay)
log_info ("secmem usage: %u/%lu bytes in %u blocks\n",
cur_alloced, (unsigned long)pool_size, cur_blocks);
SECMEM_UNLOCK;
#else
memblock_t *mb;
int i;
SECMEM_LOCK;
for (i = 0, mb = (memblock_t *) pool;
ptr_into_pool_p (mb);
mb = mb_get_next (mb), i++)
log_info ("SECMEM: [%s] block: %i; size: %i\n",
(mb->flags & MB_FLAG_ACTIVE) ? "used" : "free",
i,
mb->size);
SECMEM_UNLOCK;
#endif
}
diff --git a/src/stdmem.c b/src/stdmem.c
index c20c4b4f..189da372 100644
--- a/src/stdmem.c
+++ b/src/stdmem.c
@@ -1,233 +1,242 @@
/* stdmem.c - private memory allocator
* Copyright (C) 1998, 2000, 2002, 2005, 2008 Free Software Foundation, Inc.
*
* This file is part of Libgcrypt.
*
* Libgcrypt is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser general Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* Libgcrypt is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
/*
* Description of the layered memory management in Libgcrypt:
*
* [User]
* |
* |
* \ /
* global.c: [MM entrance points] -----> [user callbacks]
* | |
* | |
* \ / \ /
*
* stdmem.c: [non-secure handlers] [secure handlers]
*
* | |
* | |
* \ / \ /
*
* stdmem.c: [ memory guard ]
*
* | |
* | |
* \ / \ /
*
* libc: [ MM functions ] secmem.c: [ secure MM functions]
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
+#include <errno.h>
#include "g10lib.h"
#include "stdmem.h"
#include "secmem.h"
#define MAGIC_NOR_BYTE 0x55
#define MAGIC_SEC_BYTE 0xcc
#define MAGIC_END_BYTE 0xaa
#if SIZEOF_UNSIGNED_LONG == 8
#define EXTRA_ALIGN 4
#else
#define EXTRA_ALIGN 0
#endif
static int use_m_guard = 0;
/****************
* Warning: Never use this function after any of the functions
* here have been used.
*/
void
_gcry_private_enable_m_guard (void)
{
use_m_guard = 1;
}
/*
* Allocate memory of size n.
* Return NULL if we are out of memory.
*/
void *
_gcry_private_malloc (size_t n)
{
if (!n)
- return NULL; /* Allocating 0 bytes is undefined - we better return
- an error to detect such coding errors. */
+ {
+ gpg_err_set_errno (EINVAL);
+ return NULL; /* Allocating 0 bytes is undefined - we better return
+ an error to detect such coding errors. */
+ }
+
if (use_m_guard)
{
char *p;
if ( !(p = malloc (n + EXTRA_ALIGN+5)) )
return NULL;
((byte*)p)[EXTRA_ALIGN+0] = n;
((byte*)p)[EXTRA_ALIGN+1] = n >> 8 ;
((byte*)p)[EXTRA_ALIGN+2] = n >> 16 ;
((byte*)p)[EXTRA_ALIGN+3] = MAGIC_NOR_BYTE;
p[4+EXTRA_ALIGN+n] = MAGIC_END_BYTE;
return p+EXTRA_ALIGN+4;
}
else
{
return malloc( n );
}
}
/*
* Allocate memory of size N from the secure memory pool. Return NULL
* if we are out of memory.
*/
void *
_gcry_private_malloc_secure (size_t n)
{
if (!n)
- return NULL; /* Allocating 0 bytes is undefined - better return an
- error to detect such coding errors. */
+ {
+ gpg_err_set_errno (EINVAL);
+ return NULL; /* Allocating 0 bytes is undefined - better return an
+ error to detect such coding errors. */
+ }
+
if (use_m_guard)
{
char *p;
if ( !(p = _gcry_secmem_malloc (n +EXTRA_ALIGN+ 5)) )
return NULL;
((byte*)p)[EXTRA_ALIGN+0] = n;
((byte*)p)[EXTRA_ALIGN+1] = n >> 8 ;
((byte*)p)[EXTRA_ALIGN+2] = n >> 16 ;
((byte*)p)[EXTRA_ALIGN+3] = MAGIC_SEC_BYTE;
p[4+EXTRA_ALIGN+n] = MAGIC_END_BYTE;
return p+EXTRA_ALIGN+4;
}
else
{
return _gcry_secmem_malloc( n );
}
}
/*
* Realloc and clear the old space
* Return NULL if there is not enough memory.
*/
void *
_gcry_private_realloc ( void *a, size_t n )
{
if (use_m_guard)
{
unsigned char *p = a;
char *b;
size_t len;
if (!a)
return _gcry_private_malloc(n);
_gcry_private_check_heap(p);
len = p[-4];
len |= p[-3] << 8;
len |= p[-2] << 16;
if( len >= n ) /* We don't shrink for now. */
return a;
if (p[-1] == MAGIC_SEC_BYTE)
b = _gcry_private_malloc_secure(n);
else
b = _gcry_private_malloc(n);
if (!b)
return NULL;
memcpy (b, a, len);
memset (b+len, 0, n-len);
_gcry_private_free (p);
return b;
}
else if ( _gcry_private_is_secure(a) )
{
return _gcry_secmem_realloc( a, n );
}
else
{
return realloc( a, n );
}
}
void
_gcry_private_check_heap (const void *a)
{
if (use_m_guard)
{
const byte *p = a;
size_t len;
if (!p)
return;
if ( !(p[-1] == MAGIC_NOR_BYTE || p[-1] == MAGIC_SEC_BYTE) )
_gcry_log_fatal ("memory at %p corrupted (underflow=%02x)\n", p, p[-1]);
len = p[-4];
len |= p[-3] << 8;
len |= p[-2] << 16;
if ( p[len] != MAGIC_END_BYTE )
_gcry_log_fatal ("memory at %p corrupted (overflow=%02x)\n", p, p[-1]);
}
}
/*
* Free a memory block allocated by this or the secmem module
*/
void
_gcry_private_free (void *a)
{
unsigned char *p = a;
if (!p)
return;
if (use_m_guard )
{
_gcry_private_check_heap(p);
if ( _gcry_private_is_secure(a) )
_gcry_secmem_free(p-EXTRA_ALIGN-4);
else
{
free(p-EXTRA_ALIGN-4);
}
}
else if ( _gcry_private_is_secure(a) )
_gcry_secmem_free(p);
else
free(p);
}

File Metadata

Mime Type
text/x-diff
Expires
Mon, May 12, 6:36 PM (1 d, 18 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
80/39/031db9e47b05fea0a5cf1e8aa691

Event Timeline