Commit 0dca3f8f authored by Niels Möller's avatar Niels Möller
Browse files

Renamed gmp-glue functions. Use new GMP functions if available.

parent e5512f32
2013-02-27 Niels Möller <nisse@lysator.liu.se>
* gmp-glue.h: Check if GMP provides mpz_limbs_read (expected in
next release).
* gmp-glue.c: Use GMP's mpz_limbs_read and friends if available.
Renamed all functions for consistency with GMP. Updated all
callers.
2013-02-20 Niels Möller <nisse@lysator.liu.se> 2013-02-20 Niels Möller <nisse@lysator.liu.se>
* examples/Makefile.in (HOGWEED_TARGETS): Added * examples/Makefile.in (HOGWEED_TARGETS): Added
......
...@@ -47,7 +47,7 @@ ecc_hash (const struct ecc_curve *ecc, ...@@ -47,7 +47,7 @@ ecc_hash (const struct ecc_curve *ecc,
if (length > ((unsigned) ecc->bit_size + 7) / 8) if (length > ((unsigned) ecc->bit_size + 7) / 8)
length = (ecc->bit_size + 7) / 8; length = (ecc->bit_size + 7) / 8;
_mpn_set_base256 (hp, ecc->size + 1, digest, length); mpn_set_base256 (hp, ecc->size + 1, digest, length);
if (8 * length > ecc->bit_size) if (8 * length > ecc->bit_size)
/* We got a few extra bits, at the low end. Discard them. */ /* We got a few extra bits, at the low end. Discard them. */
......
...@@ -34,13 +34,13 @@ void ...@@ -34,13 +34,13 @@ void
ecc_point_init (struct ecc_point *p, const struct ecc_curve *ecc) ecc_point_init (struct ecc_point *p, const struct ecc_curve *ecc)
{ {
p->ecc = ecc; p->ecc = ecc;
p->p = _gmp_alloc_limbs (2*ecc->size); p->p = gmp_alloc_limbs (2*ecc->size);
} }
void void
ecc_point_clear (struct ecc_point *p) ecc_point_clear (struct ecc_point *p)
{ {
_gmp_free_limbs (p->p, 2*p->ecc->size); gmp_free_limbs (p->p, 2*p->ecc->size);
} }
int int
...@@ -53,8 +53,8 @@ ecc_point_set (struct ecc_point *p, const mpz_t x, const mpz_t y) ...@@ -53,8 +53,8 @@ ecc_point_set (struct ecc_point *p, const mpz_t x, const mpz_t y)
size = p->ecc->size; size = p->ecc->size;
if (mpz_sgn (x) < 0 || _mpz_cmp_limbs (x, p->ecc->p, size) >= 0 if (mpz_sgn (x) < 0 || mpz_limbs_cmp (x, p->ecc->p, size) >= 0
|| mpz_sgn (y) < 0 || _mpz_cmp_limbs (y, p->ecc->p, size) >= 0) || mpz_sgn (y) < 0 || mpz_limbs_cmp (y, p->ecc->p, size) >= 0)
return 0; return 0;
mpz_init (lhs); mpz_init (lhs);
...@@ -65,9 +65,9 @@ ecc_point_set (struct ecc_point *p, const mpz_t x, const mpz_t y) ...@@ -65,9 +65,9 @@ ecc_point_set (struct ecc_point *p, const mpz_t x, const mpz_t y)
mpz_mul (rhs, x, x); mpz_mul (rhs, x, x);
mpz_sub_ui (rhs, rhs, 3); mpz_sub_ui (rhs, rhs, 3);
mpz_mul (rhs, rhs, x); mpz_mul (rhs, rhs, x);
mpz_add (rhs, rhs, _mpz_init_mpn (t, p->ecc->b, size)); mpz_add (rhs, rhs, mpz_roinit_n (t, p->ecc->b, size));
res = mpz_congruent_p (lhs, rhs, _mpz_init_mpn (t, p->ecc->p, size)); res = mpz_congruent_p (lhs, rhs, mpz_roinit_n (t, p->ecc->p, size));
mpz_clear (lhs); mpz_clear (lhs);
mpz_clear (rhs); mpz_clear (rhs);
...@@ -75,8 +75,8 @@ ecc_point_set (struct ecc_point *p, const mpz_t x, const mpz_t y) ...@@ -75,8 +75,8 @@ ecc_point_set (struct ecc_point *p, const mpz_t x, const mpz_t y)
if (!res) if (!res)
return 0; return 0;
_mpz_copy_limbs (p->p, x, size); mpz_limbs_copy (p->p, x, size);
_mpz_copy_limbs (p->p + size, y, size); mpz_limbs_copy (p->p + size, y, size);
return 1; return 1;
} }
...@@ -85,6 +85,6 @@ void ...@@ -85,6 +85,6 @@ void
ecc_point_get (const struct ecc_point *p, mpz_t x, mpz_t y) ecc_point_get (const struct ecc_point *p, mpz_t x, mpz_t y)
{ {
mp_size_t size = p->ecc->size; mp_size_t size = p->ecc->size;
_mpz_set_mpn (x, p->p, size); mpz_set_n (x, p->p, size);
_mpz_set_mpn (y, p->p + size, size); mpz_set_n (y, p->p + size, size);
} }
...@@ -72,7 +72,7 @@ ecc_modq_random (const struct ecc_curve *ecc, mp_limb_t *xp, ...@@ -72,7 +72,7 @@ ecc_modq_random (const struct ecc_curve *ecc, mp_limb_t *xp,
random (ctx, nbytes, buf); random (ctx, nbytes, buf);
buf[0] &= 0xff >> (nbytes * 8 - ecc->bit_size); buf[0] &= 0xff >> (nbytes * 8 - ecc->bit_size);
_mpn_set_base256 (xp, ecc->size, buf, nbytes); mpn_set_base256 (xp, ecc->size, buf, nbytes);
} }
while (!ecdsa_in_range (ecc, xp, scratch)); while (!ecdsa_in_range (ecc, xp, scratch));
} }
......
...@@ -34,13 +34,13 @@ void ...@@ -34,13 +34,13 @@ void
ecc_scalar_init (struct ecc_scalar *s, const struct ecc_curve *ecc) ecc_scalar_init (struct ecc_scalar *s, const struct ecc_curve *ecc)
{ {
s->ecc = ecc; s->ecc = ecc;
s->p = _gmp_alloc_limbs (ecc->size); s->p = gmp_alloc_limbs (ecc->size);
} }
void void
ecc_scalar_clear (struct ecc_scalar *s) ecc_scalar_clear (struct ecc_scalar *s)
{ {
_gmp_free_limbs (s->p, s->ecc->size); gmp_free_limbs (s->p, s->ecc->size);
} }
int int
...@@ -48,15 +48,15 @@ ecc_scalar_set (struct ecc_scalar *s, const mpz_t z) ...@@ -48,15 +48,15 @@ ecc_scalar_set (struct ecc_scalar *s, const mpz_t z)
{ {
mp_size_t size = s->ecc->size; mp_size_t size = s->ecc->size;
if (mpz_sgn (z) <= 0 || _mpz_cmp_limbs (z, s->ecc->q, size) >= 0) if (mpz_sgn (z) <= 0 || mpz_limbs_cmp (z, s->ecc->q, size) >= 0)
return 0; return 0;
_mpz_copy_limbs (s->p, z, size); mpz_limbs_copy (s->p, z, size);
return 1; return 1;
} }
void void
ecc_scalar_get (const struct ecc_scalar *s, mpz_t z) ecc_scalar_get (const struct ecc_scalar *s, mpz_t z)
{ {
_mpz_set_mpn (z, s->p, s->ecc->size); mpz_set_n (z, s->p, s->ecc->size);
} }
...@@ -44,8 +44,8 @@ ecdsa_sign (const struct ecc_scalar *key, ...@@ -44,8 +44,8 @@ ecdsa_sign (const struct ecc_scalar *key,
/* At most 936 bytes. */ /* At most 936 bytes. */
TMP_DECL(k, mp_limb_t, ECC_MAX_SIZE + ECC_ECDSA_SIGN_ITCH (ECC_MAX_SIZE)); TMP_DECL(k, mp_limb_t, ECC_MAX_SIZE + ECC_ECDSA_SIGN_ITCH (ECC_MAX_SIZE));
mp_limb_t size = key->ecc->size; mp_limb_t size = key->ecc->size;
mp_limb_t *rp = _mpz_write_limbs (signature->r, size); mp_limb_t *rp = mpz_limbs_write (signature->r, size);
mp_limb_t *sp = _mpz_write_limbs (signature->s, size); mp_limb_t *sp = mpz_limbs_write (signature->s, size);
TMP_ALLOC (k, size + ECC_ECDSA_SIGN_ITCH (size)); TMP_ALLOC (k, size + ECC_ECDSA_SIGN_ITCH (size));
...@@ -56,8 +56,8 @@ ecdsa_sign (const struct ecc_scalar *key, ...@@ -56,8 +56,8 @@ ecdsa_sign (const struct ecc_scalar *key,
ecc_modq_random (key->ecc, k, random_ctx, random, k + size); ecc_modq_random (key->ecc, k, random_ctx, random, k + size);
ecc_ecdsa_sign (key->ecc, key->p, k, digest_length, digest, ecc_ecdsa_sign (key->ecc, key->p, k, digest_length, digest,
rp, sp, k + size); rp, sp, k + size);
_mpz_done_limbs (signature->r, size); mpz_limbs_finish (signature->r, size);
_mpz_done_limbs (signature->s, size); mpz_limbs_finish (signature->s, size);
} }
while (mpz_sgn (signature->r) == 0 || mpz_sgn (signature->s) == 0); while (mpz_sgn (signature->r) == 0 || mpz_sgn (signature->s) == 0);
} }
...@@ -43,7 +43,7 @@ ecdsa_verify (const struct ecc_point *pub, ...@@ -43,7 +43,7 @@ ecdsa_verify (const struct ecc_point *pub,
/* For ECC_MUL_A_WBITS == 0, at most 1512 bytes. With /* For ECC_MUL_A_WBITS == 0, at most 1512 bytes. With
ECC_MUL_A_WBITS == 4, currently needs 67 * ecc->size, at most ECC_MUL_A_WBITS == 4, currently needs 67 * ecc->size, at most
4824 bytes. Don't use stack allocation for this. */ 4824 bytes. Don't use stack allocation for this. */
mp_limb_t *scratch = _gmp_alloc_limbs (itch); mp_limb_t *scratch = gmp_alloc_limbs (itch);
int res; int res;
#define rp scratch #define rp scratch
...@@ -54,12 +54,12 @@ ecdsa_verify (const struct ecc_point *pub, ...@@ -54,12 +54,12 @@ ecdsa_verify (const struct ecc_point *pub,
|| mpz_sgn (signature->s) <= 0 || mpz_size (signature->s) > size) || mpz_sgn (signature->s) <= 0 || mpz_size (signature->s) > size)
return 0; return 0;
_mpz_copy_limbs (rp, signature->r, size); mpz_limbs_copy (rp, signature->r, size);
_mpz_copy_limbs (sp, signature->s, size); mpz_limbs_copy (sp, signature->s, size);
res = ecc_ecdsa_verify (pub->ecc, pub->p, length, digest, rp, sp, scratch_out); res = ecc_ecdsa_verify (pub->ecc, pub->p, length, digest, rp, sp, scratch_out);
_gmp_free_limbs (scratch, itch); gmp_free_limbs (scratch, itch);
return res; return res;
#undef rp #undef rp
......
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
#include "gmp-glue.h" #include "gmp-glue.h"
#if !GMP_HAVE_mpz_limbs_read
/* This implementation tries to make a minimal use of GMP internals. /* This implementation tries to make a minimal use of GMP internals.
We access and _mp_size and _mp_d, but not _mp_alloc. */ We access and _mp_size and _mp_d, but not _mp_alloc. */
...@@ -51,69 +53,22 @@ ...@@ -51,69 +53,22 @@
#define MPZ_NEWALLOC MPZ_REALLOC #define MPZ_NEWALLOC MPZ_REALLOC
int
_mpz_cmp_limbs (mpz_srcptr a, const mp_limb_t *bp, mp_size_t bn)
{
mp_size_t an = SIZ (a);
if (an < bn)
return -1;
if (an > bn)
return 1;
if (an == 0)
return 0;
return mpn_cmp (PTR(a), bp, an);
}
/* Read access to mpz numbers. */ /* Read access to mpz numbers. */
/* Return limb pointer, for read-only operations. Use mpz_size to get /* Return limb pointer, for read-only operations. Use mpz_size to get
the number of limbs. */ the number of limbs. */
const mp_limb_t * const mp_limb_t *
_mpz_read_limbs (mpz_srcptr x) mpz_limbs_read (mpz_srcptr x)
{ {
return PTR (x); return PTR (x);
} }
/* Get a pointer to an n limb area, for read-only operation. n must be
greater or equal to the current size, and the mpz is zero-padded if
needed. */
const mp_limb_t *
_mpz_read_limbs_n (mpz_ptr x, mp_size_t n)
{
mp_size_t xn = ABSIZ (x);
assert (xn <= n);
if (xn < n)
{
/* Makes an unnecessary realloc if allocation is already large
enough. */
mpz_realloc (x, n);
mpn_zero (PTR(x) + xn, n - xn);
}
return PTR(x);
}
void
_mpz_copy_limbs (mp_limb_t *xp, mpz_srcptr x, mp_size_t n)
{
mp_size_t xn = ABSIZ (x);
assert (xn <= n);
mpn_copyi (xp, PTR(x), xn);
if (xn < n)
mpn_zero (xp + xn, n - xn);
}
/* Write access to mpz numbers. */ /* Write access to mpz numbers. */
/* Get a limb pointer for writing, previous contents may be /* Get a limb pointer for writing, previous contents may be
destroyed. */ destroyed. */
mp_limb_t * mp_limb_t *
_mpz_write_limbs (mpz_ptr x, mp_size_t n) mpz_limbs_write (mpz_ptr x, mp_size_t n)
{ {
assert (n > 0); assert (n > 0);
return MPZ_NEWALLOC (x, n); return MPZ_NEWALLOC (x, n);
...@@ -121,14 +76,14 @@ _mpz_write_limbs (mpz_ptr x, mp_size_t n) ...@@ -121,14 +76,14 @@ _mpz_write_limbs (mpz_ptr x, mp_size_t n)
/* Get a limb pointer for writing, previous contents is intact. */ /* Get a limb pointer for writing, previous contents is intact. */
mp_limb_t * mp_limb_t *
_mpz_modify_limbs (mpz_ptr x, mp_size_t n) mpz_limbs_modify (mpz_ptr x, mp_size_t n)
{ {
assert (n > 0); assert (n > 0);
return MPZ_REALLOC (x, n); return MPZ_REALLOC (x, n);
} }
void void
_mpz_done_limbs (mpz_ptr x, mp_size_t n) mpz_limbs_finish (mpz_ptr x, mp_size_t n)
{ {
assert (n >= 0); assert (n >= 0);
MPN_NORMALIZE (PTR(x), n); MPN_NORMALIZE (PTR(x), n);
...@@ -136,16 +91,9 @@ _mpz_done_limbs (mpz_ptr x, mp_size_t n) ...@@ -136,16 +91,9 @@ _mpz_done_limbs (mpz_ptr x, mp_size_t n)
SIZ (x) = n; SIZ (x) = n;
} }
void
_mpz_set_mpn (mpz_t r, const mp_limb_t *xp, mp_size_t xn)
{
mpn_copyi (_mpz_write_limbs (r, xn), xp, xn);
_mpz_done_limbs (r, xn);
}
/* Needs some ugly casts. */ /* Needs some ugly casts. */
mpz_srcptr mpz_srcptr
_mpz_init_mpn (mpz_ptr x, const mp_limb_t *xp, mp_size_t xs) mpz_roinit_n (mpz_ptr x, const mp_limb_t *xp, mp_size_t xs)
{ {
mp_size_t xn = ABS (xs); mp_size_t xn = ABS (xs);
...@@ -156,9 +104,63 @@ _mpz_init_mpn (mpz_ptr x, const mp_limb_t *xp, mp_size_t xs) ...@@ -156,9 +104,63 @@ _mpz_init_mpn (mpz_ptr x, const mp_limb_t *xp, mp_size_t xs)
x->_mp_d = (mp_limb_t *) xp; x->_mp_d = (mp_limb_t *) xp;
return x; return x;
} }
#endif /* !GMP_HAVE_mpz_limbs_read */
/* Additional convenience functions. */
int
mpz_limbs_cmp (mpz_srcptr a, const mp_limb_t *bp, mp_size_t bn)
{
mp_size_t an = SIZ (a);
if (an < bn)
return -1;
if (an > bn)
return 1;
if (an == 0)
return 0;
return mpn_cmp (PTR(a), bp, an);
}
/* Get a pointer to an n limb area, for read-only operation. n must be
greater or equal to the current size, and the mpz is zero-padded if
needed. */
const mp_limb_t *
mpz_limbs_read_n (mpz_ptr x, mp_size_t n)
{
mp_size_t xn = mpz_size (x);
mp_ptr xp;
assert (xn <= n);
xp = mpz_limbs_modify (x, n);
if (xn < n)
mpn_zero (xp + xn, n - xn);
return xp;
}
void
mpz_limbs_copy (mp_limb_t *xp, mpz_srcptr x, mp_size_t n)
{
mp_size_t xn = mpz_size (x);
assert (xn <= n);
mpn_copyi (xp, mpz_limbs_read (x), xn);
if (xn < n)
mpn_zero (xp + xn, n - xn);
}
void
mpz_set_n (mpz_t r, const mp_limb_t *xp, mp_size_t xn)
{
mpn_copyi (mpz_limbs_write (r, xn), xp, xn);
mpz_limbs_finish (r, xn);
}
void void
_mpn_set_base256 (mp_limb_t *rp, mp_size_t rn, mpn_set_base256 (mp_limb_t *rp, mp_size_t rn,
const uint8_t *xp, size_t xn) const uint8_t *xp, size_t xn)
{ {
size_t xi; size_t xi;
...@@ -187,7 +189,7 @@ _mpn_set_base256 (mp_limb_t *rp, mp_size_t rn, ...@@ -187,7 +189,7 @@ _mpn_set_base256 (mp_limb_t *rp, mp_size_t rn,
} }
mp_limb_t * mp_limb_t *
_gmp_alloc_limbs (mp_size_t n) gmp_alloc_limbs (mp_size_t n)
{ {
void *(*alloc_func)(size_t); void *(*alloc_func)(size_t);
...@@ -199,7 +201,7 @@ _gmp_alloc_limbs (mp_size_t n) ...@@ -199,7 +201,7 @@ _gmp_alloc_limbs (mp_size_t n)
} }
void void
_gmp_free_limbs (mp_limb_t *p, mp_size_t n) gmp_free_limbs (mp_limb_t *p, mp_size_t n)
{ {
void (*free_func)(void *, size_t); void (*free_func)(void *, size_t);
assert (n > 0); assert (n > 0);
......
...@@ -27,81 +27,94 @@ ...@@ -27,81 +27,94 @@
#include "nettle-stdint.h" #include "nettle-stdint.h"
#ifdef mpz_limbs_read
#define GMP_HAVE_mpz_limbs_read 1
#else
#define GMP_HAVE_mpz_limbs_read 0
#endif
/* Name mangling. */ /* Name mangling. */
#define _mpz_cmp_limbs _nettle_mpz_cmp_limbs #if !GMP_HAVE_mpz_limbs_read
#define _mpz_read_limbs _nettle_mpz_read_limbs #define mpz_limbs_read _nettle_mpz_limbs_read
#define _mpz_read_limbs_n _nettle_mpz_read_limbs_n #define mpz_limbs_write _nettle_mpz_limbs_write
#define _mpz_copy_limbs _nettle_mpz_copy_limbs #define mpz_limbs_modify _nettle_mpz_limbs_modify
#define _mpz_write_limbs _nettle_mpz_write_limbs #define mpz_limbs_finish _nettle_mpz_limbs_finish
#define _mpz_modify_limbs _nettle_mpz_modify_limbs #define mpz_roinit_n _nettle_mpz_roinit_n
#define _mpz_done_limbs _nettle_mpz_done_limbs #endif
#define _mpz_set_mpn _nettle_mpz_set_mpn
#define _mpz_init_mpn _nettle_mpz_init_mpn #define mpz_limbs_cmp _nettle_mpz_limbs_cmp
#define _mpn_set_base256 _nettle_mpn_set_base256 #define mpz_limbs_read_n _nettle_mpz_limbs_read_n
#define _gmp_alloc_limbs _nettle_gmp_alloc_limbs #define mpz_limbs_copy _nettle_mpz_limbs_copy
#define _gmp_free_limbs _nettle_gmp_free_limbs #define mpz_set_n _nettle_mpz_set_n
#define mpn_set_base256 _nettle_mpn_set_base256
#define gmp_alloc_limbs _nettle_gmp_alloc_limbs
#define gmp_free_limbs _nettle_gmp_free_limbs
/* Some functions for interfacing between mpz and mpn code. Signs of /* Some functions for interfacing between mpz and mpn code. Signs of
the mpz numbers are generally ignored. */ the mpz numbers are generally ignored. */
int #if !GMP_HAVE_mpz_limbs_read
_mpz_cmp_limbs (mpz_srcptr a, const mp_limb_t *bp, mp_size_t bn);
/* Read access to mpz numbers. */ /* Read access to mpz numbers. */
/* Return limb pointer, for read-only operations. Use mpz_size to get /* Return limb pointer, for read-only operations. Use mpz_size to get
the number of limbs. */ the number of limbs. */
const mp_limb_t * const mp_limb_t *
_mpz_read_limbs (const mpz_srcptr x); mpz_limbs_read (const mpz_srcptr x);
/* Get a pointer to an n limb area, for read-only operation. n must be
greater or equal to the current size, and the mpz is zero-padded if
needed. */
const mp_limb_t *
_mpz_read_limbs_n (mpz_ptr x, mp_size_t n);
/* Copy limbs, with zero-padding. */
/* FIXME: Reorder arguments, on the theory that the first argument of
an _mpz_* fucntion should be an mpz_t? Or rename to _mpz_get_limbs,
with argument order consistent with mpz_get_*. */
void
_mpz_copy_limbs (mp_limb_t *xp, mpz_srcptr x, mp_size_t n);
/* Write access to mpz numbers. */ /* Write access to mpz numbers. */
/* Get a limb pointer for writing, previous contents may be /* Get a limb pointer for writing, previous contents may be
destroyed. */ destroyed. */
mp_limb_t * mp_limb_t *
_mpz_write_limbs (mpz_ptr x, mp_size_t n); mpz_limbs_write (mpz_ptr x, mp_size_t n);
/* Get a limb pointer for writing, previous contents is intact. */ /* Get a limb pointer for writing, previous contents is intact. */
mp_limb_t * mp_limb_t *
_mpz_modify_limbs (mpz_ptr x, mp_size_t n); mpz_limbs_modify (mpz_ptr x, mp_size_t n);
/* Update size. */ /* Update size. */
void void
_mpz_done_limbs (mpz_ptr x, mp_size_t n); mpz_limbs_finish (mpz_ptr x, mp_size_t n);
void
_mpz_set_mpn (mpz_t r, const mp_limb_t *xp, mp_size_t xn);
/* Using an mpn number as an mpz. Can be used for read-only access /* Using an mpn number as an mpz. Can be used for read-only access
only. x must not be cleared or reallocated. */ only. x must not be cleared or reallocated. */
mpz_srcptr mpz_srcptr
_mpz_init_mpn (mpz_ptr x, const mp_limb_t *xp, mp_size_t xs); mpz_roinit_n (mpz_ptr x, const mp_limb_t *xp, mp_size_t xs);
#endif /* !GMP_HAVE_mpz_limbs_read */
/* Convenience functions */
int
mpz_limbs_cmp (mpz_srcptr a, const mp_limb_t *bp, mp_size_t bn);
/* Get a pointer to an n limb area, for read-only operation. n must be
greater or equal to the current size, and the mpz is zero-padded if
needed. */
const mp_limb_t *
mpz_limbs_read_n (mpz_ptr x, mp_size_t n);
/* Copy limbs, with zero-padding. */
/* FIXME: Reorder arguments, on the theory that the first argument of
an _mpz_* fucntion should be an mpz_t? Or rename to _mpz_get_limbs,
with argument order consistent with mpz_get_*. */
void
mpz_limbs_copy (mp_limb_t *xp, mpz_srcptr x, mp_size_t n);
void
mpz_set_n (mpz_t r, const mp_limb_t *xp, mp_size_t xn);
/* Like mpn_set_str, but always writes rn limbs. If input is larger, /* Like mpn_set_str, but always writes rn limbs. If input is larger,
higher bits are ignored. */ higher bits are ignored. */
void void
_mpn_set_base256 (mp_limb_t *rp, mp_size_t rn, mpn_set_base256 (mp_limb_t *rp, mp_size_t rn,
const uint8_t *xp, size_t xn); const uint8_t *xp, size_t xn);