diff options
author | Werner Koch <wk@gnupg.org> | 2013-09-07 10:06:46 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2013-09-20 18:30:05 +0200 |
commit | 3e5cfa20acfeccb9df2c3fae2730344b40b36104 (patch) | |
tree | 7b1eb9a1d34da43b39ac44ad45104f3cdbf31f24 /cipher/elgamal.c | |
parent | 722bfc1e5f2268453db62f38cc46b5ec6ef3adee (diff) | |
download | libgcrypt-3e5cfa20acfeccb9df2c3fae2730344b40b36104.tar.gz |
sexp: Change internal versions to always use gpg_err_code_t.
* src/sexp.c (gcry_sexp_new, gcry_sexp_create, gcry_sexp_build)
(gcry_sexp_build_array, gcry_sexp_canon_len): Change error return type
from gpg_error_t to gpg_err_code_t. Remove all calls to gpg_error.
* src/visibility.c (gcry_sexp_new, gcry_sexp_create, gcry_sexp_sscan)
(gcry_sexp_build, gcry_sexp_build_array, gcry_sexp_canon_len): Map
error codes via gpg_error.
* cipher/dsa.c, cipher/ecc.c, cipher/elgamal.c, cipher/rsa.c: Remove
use gpg_err_code wrappers.
--
We should do such a change for all other use of internal functions.
It just does not make sense to use gpg_error in the internal interface
because the error source is always Libgcrypt.
Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'cipher/elgamal.c')
-rw-r--r-- | cipher/elgamal.c | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/cipher/elgamal.c b/cipher/elgamal.c index ecbac756..c63059d8 100644 --- a/cipher/elgamal.c +++ b/cipher/elgamal.c @@ -692,17 +692,16 @@ elg_generate (int algo, unsigned int nbits, unsigned long evalue, goto leave; } - rc = gcry_err_code (gcry_sexp_build - (r_skey, NULL, - "(key-data" - " (public-key" - " (elg(p%m)(g%m)(y%m)))" - " (private-key" + rc = gcry_sexp_build (r_skey, NULL, + "(key-data" + " (public-key" + " (elg(p%m)(g%m)(y%m)))" + " (private-key" " (elg(p%m)(g%m)(y%m)(x%m)))" - " %S)", - sk.p, sk.g, sk.y, - sk.p, sk.g, sk.y, sk.x, - misc_info)); + " %S)", + sk.p, sk.g, sk.y, + sk.p, sk.g, sk.y, sk.x, + misc_info); leave: mpi_free (sk.p); @@ -768,9 +767,7 @@ elg_encrypt (int algo, gcry_sexp_t *r_result, a = mpi_alloc (mpi_get_nlimbs (pk.p)); b = mpi_alloc (mpi_get_nlimbs (pk.p)); do_encrypt (a, b, data, &pk); - rc = gcry_err_code (gcry_sexp_build (r_result, NULL, - "(enc-val(elg(a%m)(b%m)))", - a, b)); + rc = gcry_sexp_build (r_result, NULL, "(enc-val(elg(a%m)(b%m)))", a, b); mpi_free (a); mpi_free (b); } @@ -817,8 +814,8 @@ elg_decrypt (int algo, gcry_sexp_t *r_plain, mpi_free (plain); plain = NULL; if (!rc) - rc = gcry_err_code (gcry_sexp_build (r_plain, NULL, "(value %b)", - (int)unpadlen, unpad)); + rc = gcry_sexp_build (r_plain, NULL, "(value %b)", + (int)unpadlen, unpad); break; case PUBKEY_ENC_OAEP: @@ -827,18 +824,17 @@ elg_decrypt (int algo, gcry_sexp_t *r_plain, mpi_free (plain); plain = NULL; if (!rc) - rc = gcry_err_code (gcry_sexp_build (r_plain, NULL, "(value %b)", - (int)unpadlen, unpad)); + rc = gcry_sexp_build (r_plain, NULL, "(value %b)", + (int)unpadlen, unpad); break; default: /* Raw format. For backward compatibility we need to assume a signed mpi by using the sexp format string "%m". */ - rc = gcry_err_code - (gcry_sexp_build (r_plain, NULL, - (flags & PUBKEY_FLAG_LEGACYRESULT) - ? "%m" : "(value %m)", - plain)); + rc = gcry_sexp_build (r_plain, NULL, + (flags & PUBKEY_FLAG_LEGACYRESULT) + ? "%m" : "(value %m)", + plain); break; } @@ -876,9 +872,7 @@ elg_sign (int algo, gcry_sexp_t *r_result, gcry_mpi_t data, gcry_mpi_t *skey, r = mpi_alloc (mpi_get_nlimbs (sk.p)); s = mpi_alloc (mpi_get_nlimbs (sk.p)); sign (r, s, data, &sk); - rc = gcry_err_code (gcry_sexp_build (r_result, NULL, - "(sig-val(elg(r%M)(s%M)))", - r, s)); + rc = gcry_sexp_build (r_result, NULL, "(sig-val(elg(r%M)(s%M)))", r, s); mpi_free (r); mpi_free (s); } |