Commit 3cba4644 authored by Niels Möller's avatar Niels Möller
Browse files

(nettle_mpz_from_octets): Improved loop. Removed the

digit temporary (suggested by Torbjörn Granlund).

Rev: src/nettle/bignum.c:1.8
parent 94cb88c0
...@@ -137,17 +137,14 @@ nettle_mpz_from_octets(mpz_t x, ...@@ -137,17 +137,14 @@ nettle_mpz_from_octets(mpz_t x,
uint8_t sign) uint8_t sign)
{ {
unsigned i; unsigned i;
mpz_t digit;
mpz_init(digit);
/* FIXME: See if we can use something like
mpz_import(x, length, 1, 1, 0, 0, s). */
for (i = 0; i < length; i++) for (i = 0; i < length; i++)
{ {
mpz_set_ui(digit, sign ^ s[i]); mpz_mul_2exp(x, x, 8);
mpz_mul_2exp(digit, digit, (length - i - 1) * 8); mpz_add_ui(x, x, sign ^ s[i]);
mpz_ior(x, x, digit);
} }
mpz_clear(digit);
} }
void void
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment