summaryrefslogtreecommitdiffstats
path: root/libtommath/bn_mp_import.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-06-13 19:07:13 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-06-13 19:07:13 (GMT)
commit505f963287b050bd46871d4659cebc65986ca5ac (patch)
tree853ad3262ab07f7c5755e76b8154f36f24608014 /libtommath/bn_mp_import.c
parent689987ea924a8fded1801777c1a14ab1205fa826 (diff)
downloadtcl-505f963287b050bd46871d4659cebc65986ca5ac.zip
tcl-505f963287b050bd46871d4659cebc65986ca5ac.tar.gz
tcl-505f963287b050bd46871d4659cebc65986ca5ac.tar.bz2
Update to latest libtommath's "develop" branch. On the way to 1.2.0
Diffstat (limited to 'libtommath/bn_mp_import.c')
-rw-r--r--libtommath/bn_mp_import.c29
1 files changed, 8 insertions, 21 deletions
diff --git a/libtommath/bn_mp_import.c b/libtommath/bn_mp_import.c
index 066c5b3..bd83b96 100644
--- a/libtommath/bn_mp_import.c
+++ b/libtommath/bn_mp_import.c
@@ -1,24 +1,15 @@
#include "tommath_private.h"
#ifdef BN_MP_IMPORT_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis
- *
- * LibTomMath is a library that provides multiple-precision
- * integer arithmetic as well as number theoretic functionality.
- *
- * The library was designed directly after the MPI library by
- * Michael Fromberger but has been written from scratch with
- * additional optimizations in place.
- *
- * SPDX-License-Identifier: Unlicense
- */
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
/* based on gmp's mpz_import.
* see http://gmplib.org/manual/Integer-Import-and-Export.html
*/
-int mp_import(mp_int *rop, size_t count, int order, size_t size,
- int endian, size_t nails, const void *op)
+mp_err mp_import(mp_int *rop, size_t count, int order, size_t size,
+ int endian, size_t nails, const void *op)
{
- int result;
+ mp_err err;
size_t odd_nails, nail_bytes, i, j;
unsigned char odd_nail_mask;
@@ -43,12 +34,12 @@ int mp_import(mp_int *rop, size_t count, int order, size_t size,
for (i = 0; i < count; ++i) {
for (j = 0; j < (size - nail_bytes); ++j) {
- unsigned char byte = *((unsigned char *)op +
+ unsigned char byte = *((const unsigned char *)op +
(((order == 1) ? i : ((count - 1u) - i)) * size) +
((endian == 1) ? (j + nail_bytes) : (((size - 1u) - j) - nail_bytes)));
- if ((result = mp_mul_2d(rop, (j == 0u) ? (int)(8u - odd_nails) : 8, rop)) != MP_OKAY) {
- return result;
+ if ((err = mp_mul_2d(rop, (j == 0u) ? (int)(8u - odd_nails) : 8, rop)) != MP_OKAY) {
+ return err;
}
rop->dp[0] |= (j == 0u) ? (mp_digit)(byte & odd_nail_mask) : (mp_digit)byte;
@@ -62,7 +53,3 @@ int mp_import(mp_int *rop, size_t count, int order, size_t size,
}
#endif
-
-/* ref: $Format:%D$ */
-/* git commit: $Format:%H$ */
-/* commit time: $Format:%ai$ */