summaryrefslogtreecommitdiff
path: root/cipher/ecc-misc.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2013-12-12 15:13:09 +0100
committerWerner Koch <wk@gnupg.org>2013-12-12 15:28:06 +0100
commit3b30e9840d4b351c4de73b126e561154cb7df4cc (patch)
treeef3d2d1127165ef5866840d33ccde9d35a2dee33 /cipher/ecc-misc.c
parentcd548ba2dc777b8b27d8d33182ba733c20222120 (diff)
downloadlibgcrypt-3b30e9840d4b351c4de73b126e561154cb7df4cc.tar.gz
Remove macro hacks for internal vs. external functions. Part 2 and last.
* src/visibility.h: Remove remaining define/undef hacks for symbol visibility. Add macros to detect the use of the public functions. Change all affected functions by replacing them by the x-macros. * src/g10lib.h: Add internal prototypes. (xtrymalloc, xtrycalloc, xtrymalloc_secure, xtrycalloc_secure) (xtryrealloc, xtrystrdup, xmalloc, xcalloc, xmalloc_secure) (xcalloc_secure, xrealloc, xstrdup, xfree): New macros. -- The use of xmalloc/xtrymalloc/xfree is a more common pattern than the gcry_free etc. functions. Those functions behave like those defined by C and thus for better readability we use these macros and not the underscore prefixed functions. Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'cipher/ecc-misc.c')
-rw-r--r--cipher/ecc-misc.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/cipher/ecc-misc.c b/cipher/ecc-misc.c
index ae3e4f04..7b750c01 100644
--- a/cipher/ecc-misc.c
+++ b/cipher/ecc-misc.c
@@ -110,7 +110,7 @@ _gcry_ecc_ec2os (gcry_mpi_t x, gcry_mpi_t y, gcry_mpi_t p)
unsigned char *buf, *ptr;
gcry_mpi_t result;
- buf = gcry_xmalloc ( 1 + 2*pbytes );
+ buf = xmalloc ( 1 + 2*pbytes );
*buf = 04; /* Uncompressed point. */
ptr = buf+1;
rc = _gcry_mpi_print (GCRYMPI_FMT_USG, ptr, pbytes, &n, x);
@@ -134,7 +134,7 @@ _gcry_ecc_ec2os (gcry_mpi_t x, gcry_mpi_t y, gcry_mpi_t p)
rc = _gcry_mpi_scan (&result, GCRYMPI_FMT_USG, buf, 1+2*pbytes, NULL);
if (rc)
log_fatal ("mpi_scan failed: %s\n", gpg_strerror (rc));
- gcry_free (buf);
+ xfree (buf);
return result;
}
@@ -185,11 +185,11 @@ _gcry_ecc_os2ec (mpi_point_t result, gcry_mpi_t value)
else
{
n = (mpi_get_nbits (value)+7)/8;
- buf_memory= gcry_xmalloc (n);
+ buf_memory = xmalloc (n);
rc = _gcry_mpi_print (GCRYMPI_FMT_USG, buf_memory, n, &n, value);
if (rc)
{
- gcry_free (buf_memory);
+ xfree (buf_memory);
return rc;
}
buf = buf_memory;
@@ -197,28 +197,28 @@ _gcry_ecc_os2ec (mpi_point_t result, gcry_mpi_t value)
if (n < 1)
{
- gcry_free (buf_memory);
+ xfree (buf_memory);
return GPG_ERR_INV_OBJ;
}
if (*buf != 4)
{
- gcry_free (buf_memory);
+ xfree (buf_memory);
return GPG_ERR_NOT_IMPLEMENTED; /* No support for point compression. */
}
if ( ((n-1)%2) )
{
- gcry_free (buf_memory);
+ xfree (buf_memory);
return GPG_ERR_INV_OBJ;
}
n = (n-1)/2;
rc = _gcry_mpi_scan (&x, GCRYMPI_FMT_USG, buf+1, n, NULL);
if (rc)
{
- gcry_free (buf_memory);
+ xfree (buf_memory);
return rc;
}
rc = _gcry_mpi_scan (&y, GCRYMPI_FMT_USG, buf+1+n, n, NULL);
- gcry_free (buf_memory);
+ xfree (buf_memory);
if (rc)
{
mpi_free (x);
@@ -266,7 +266,7 @@ _gcry_ecc_compute_public (mpi_point_t Q, mpi_ec_t ec,
a = mpi_snew (0);
_gcry_mpi_set_buffer (a, digest, 32, 0);
- gcry_free (digest);
+ xfree (digest);
/* And finally the public key. */
if (!Q)