use same parameter name as in the prototype

This commit is contained in:
Francois Perrad 2019-10-06 15:24:17 +02:00
parent 3da2842939
commit 763b40b490
4 changed files with 15 additions and 15 deletions

View File

@ -4,17 +4,17 @@
/* SPDX-License-Identifier: Unlicense */
/* read signed bin, big endian, first byte is 0==positive or 1==negative */
mp_err mp_from_sbin(mp_int *a, const unsigned char *b, size_t c)
mp_err mp_from_sbin(mp_int *a, const unsigned char *buf, size_t size)
{
mp_err err;
/* read magnitude */
if ((err = mp_from_ubin(a, b + 1, c - 1u)) != MP_OKAY) {
if ((err = mp_from_ubin(a, buf + 1, size - 1u)) != MP_OKAY) {
return err;
}
/* first byte is 0 for positive, non-zero for negative */
if (b[0] == (unsigned char)0) {
if (buf[0] == (unsigned char)0) {
a->sign = MP_ZPOS;
} else {
a->sign = MP_NEG;

View File

@ -4,7 +4,7 @@
/* SPDX-License-Identifier: Unlicense */
/* reads a unsigned char array, assumes the msb is stored first [big endian] */
mp_err mp_from_ubin(mp_int *a, const unsigned char *b, size_t size)
mp_err mp_from_ubin(mp_int *a, const unsigned char *buf, size_t size)
{
mp_err err;
@ -25,11 +25,11 @@ mp_err mp_from_ubin(mp_int *a, const unsigned char *b, size_t size)
}
#ifndef MP_8BIT
a->dp[0] |= *b++;
a->dp[0] |= *buf++;
a->used += 1;
#else
a->dp[0] = (*b & MP_MASK);
a->dp[1] |= ((*b++ >> 7) & 1u);
a->dp[0] = (*buf & MP_MASK);
a->dp[1] |= ((*buf++ >> 7) & 1u);
a->used += 2;
#endif
}

View File

@ -4,20 +4,20 @@
/* SPDX-License-Identifier: Unlicense */
/* store in signed [big endian] format */
mp_err mp_to_sbin(const mp_int *a, unsigned char *b, size_t maxlen, size_t *written)
mp_err mp_to_sbin(const mp_int *a, unsigned char *buf, size_t maxlen, size_t *written)
{
mp_err err;
if (maxlen == 0u) {
return MP_VAL;
}
if ((err = mp_to_ubin(a, b + 1, maxlen - 1u, written)) != MP_OKAY) {
if ((err = mp_to_ubin(a, buf + 1, maxlen - 1u, written)) != MP_OKAY) {
return err;
}
if (written != NULL) {
(*written)++;
}
b[0] = (a->sign == MP_ZPOS) ? (unsigned char)0 : (unsigned char)1;
buf[0] = (a->sign == MP_ZPOS) ? (unsigned char)0 : (unsigned char)1;
return MP_OKAY;
}
#endif

View File

@ -4,13 +4,13 @@
/* SPDX-License-Identifier: Unlicense */
/* store in unsigned [big endian] format */
mp_err mp_to_ubin(const mp_int *a, unsigned char *b, size_t maxlen, size_t *written)
mp_err mp_to_ubin(const mp_int *a, unsigned char *buf, size_t maxlen, size_t *written)
{
size_t x;
mp_err err;
mp_int t;
if (b == NULL) {
if (buf == NULL) {
return MP_MEM;
}
@ -30,15 +30,15 @@ mp_err mp_to_ubin(const mp_int *a, unsigned char *b, size_t maxlen, size_t *writ
}
maxlen--;
#ifndef MP_8BIT
b[x++] = (unsigned char)(t.dp[0] & 255u);
buf[x++] = (unsigned char)(t.dp[0] & 255u);
#else
b[x++] = (unsigned char)(t.dp[0] | ((t.dp[1] & 1u) << 7));
buf[x++] = (unsigned char)(t.dp[0] | ((t.dp[1] & 1u) << 7));
#endif
if ((err = mp_div_2d(&t, 8, &t, NULL)) != MP_OKAY) {
goto LBL_ERR;
}
}
s_mp_reverse(b, x);
s_mp_reverse(buf, x);
err = MP_OKAY;
if (written != NULL) {