diff options
Diffstat (limited to 'libtommath/bn_mp_export.c')
-rw-r--r-- | libtommath/bn_mp_export.c | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/libtommath/bn_mp_export.c b/libtommath/bn_mp_export.c index ea48e90..c9de48b 100644 --- a/libtommath/bn_mp_export.c +++ b/libtommath/bn_mp_export.c @@ -1,31 +1,22 @@ #include "tommath_private.h" #ifdef BN_MP_EXPORT_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_export. * see http://gmplib.org/manual/Integer-Import-and-Export.html */ -int mp_export(void *rop, size_t *countp, int order, size_t size, - int endian, size_t nails, const mp_int *op) +mp_err mp_export(void *rop, size_t *countp, int order, size_t size, + int endian, size_t nails, const mp_int *op) { - int result; + mp_err err; size_t odd_nails, nail_bytes, i, j, bits, count; unsigned char odd_nail_mask; mp_int t; - if ((result = mp_init_copy(&t, op)) != MP_OKAY) { - return result; + if ((err = mp_init_copy(&t, op)) != MP_OKAY) { + return err; } if (endian == 0) { @@ -61,9 +52,9 @@ int mp_export(void *rop, size_t *countp, int order, size_t size, *byte = (unsigned char)((j == ((size - nail_bytes) - 1u)) ? (t.dp[0] & odd_nail_mask) : (t.dp[0] & 0xFFuL)); - if ((result = mp_div_2d(&t, (j == ((size - nail_bytes) - 1u)) ? (int)(8u - odd_nails) : 8, &t, NULL)) != MP_OKAY) { + if ((err = mp_div_2d(&t, (j == ((size - nail_bytes) - 1u)) ? (int)(8u - odd_nails) : 8, &t, NULL)) != MP_OKAY) { mp_clear(&t); - return result; + return err; } } } @@ -78,7 +69,3 @@ int mp_export(void *rop, size_t *countp, int order, size_t size, } #endif - -/* ref: $Format:%D$ */ -/* git commit: $Format:%H$ */ -/* commit time: $Format:%ai$ */ |