/*
This file is part of GNUnet.
- (C) 2012, 2013 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2012, 2013 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
*/
/**
*/
#include "platform.h"
#include <gcrypt.h>
-#include "gnunet_util_lib.h"
+#include "gnunet_crypto_lib.h"
#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
size_t size,
size_t target)
{
+ char *p = buf;
+
if (size < target)
{
- memmove (&buf[target - size], buf, size);
+ memmove (&p[target - size], buf, size);
memset (buf, 0, target - size);
}
}
gcry_mpi_t val)
{
size_t rsize;
+ int rc;
if (gcry_mpi_get_flag (val, GCRYMPI_FLAG_OPAQUE))
{
rsize = (nbits+7)/8;
if (rsize > size)
rsize = size;
- memcpy (buf, p, rsize);
+ GNUNET_memcpy (buf, p, rsize);
if (rsize < size)
memset (buf+rsize, 0, size - rsize);
}
/* Store regular MPIs as unsigned integers right aligned into
the buffer. */
rsize = size;
- GNUNET_assert (0 ==
- gcry_mpi_print (GCRYMPI_FMT_USG, buf, rsize, &rsize,
- val));
+ if (0 !=
+ (rc = gcry_mpi_print (GCRYMPI_FMT_USG,
+ buf,
+ rsize, &rsize,
+ val)))
+ {
+ LOG_GCRY (GNUNET_ERROR_TYPE_ERROR,
+ "gcry_mpi_print",
+ rc);
+ GNUNET_assert (0);
+ }
adjust (buf, rsize, size);
}
}
GCRYMPI_FMT_USG,
data, size, &size)))
{
- LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_mpi_scan", rc);
+ LOG_GCRY (GNUNET_ERROR_TYPE_ERROR,
+ "gcry_mpi_scan",
+ rc);
GNUNET_assert (0);
}
}