fix last occurrences of mp_toradix()
This commit is contained in:
parent
33ba5f0b4b
commit
72f9251939
@ -22,7 +22,7 @@ static void ndraw(mp_int *a, const char *name)
|
||||
char buf[4096];
|
||||
|
||||
printf("%s: ", name);
|
||||
mp_toradix(a, buf, 64);
|
||||
mp_to_radix(a, buf, sizeof(buf), 64);
|
||||
printf("%s\n", buf);
|
||||
}
|
||||
|
||||
|
30
doc/bn.tex
30
doc/bn.tex
@ -2100,19 +2100,13 @@ The random number generated with these two functions is cryptographically secure
|
||||
\subsection{To ASCII}
|
||||
\index{mp\_toradix}
|
||||
\begin{alltt}
|
||||
int mp_toradix (mp_int * a, char *str, int radix);
|
||||
int mp_to_radix (mp_int * a, char *str, size_t maxlen, int radix);
|
||||
\end{alltt}
|
||||
This still store $a$ in ``str'' as a base-``radix'' string of ASCII chars. This function appends a NUL character
|
||||
to terminate the string. Valid values of ``radix'' line in the range $[2, 64]$. To determine the size (exact) required
|
||||
This stores $a$ in ``str'' of maximum length ``maxlen'' as a base-``radix'' string of ASCII chars.
|
||||
This function appends a NUL character to terminate the string.
|
||||
Valid values of ``radix'' line in the range $[2, 64]$. To determine the size (exact) required
|
||||
by the conversion before storing any data use the following function.
|
||||
|
||||
\index{mp\_toradix\_n}
|
||||
\begin{alltt}
|
||||
int mp_toradix_n (mp_int * a, char *str, int radix, int maxlen);
|
||||
\end{alltt}
|
||||
|
||||
Like \texttt{mp\_toradix} but stores upto maxlen-1 chars and always a NULL byte.
|
||||
|
||||
\index{mp\_radix\_size}
|
||||
\begin{alltt}
|
||||
int mp_radix_size (mp_int * a, int radix, int *size)
|
||||
@ -2374,27 +2368,27 @@ Other macros which are either shortcuts to normal functions or just other names
|
||||
|
||||
\subsection{Shortcuts}
|
||||
|
||||
\index{mp\_tobinary}
|
||||
\index{mp\_to\_binary}
|
||||
\begin{alltt}
|
||||
#define mp_tobinary(M, S) mp_toradix((M), (S), 2)
|
||||
#define mp_to_binary(M, S, N) mp_to_radix((M), (S), (N), 2)
|
||||
\end{alltt}
|
||||
|
||||
|
||||
\index{mp\_tooctal}
|
||||
\index{mp\_to\_octal}
|
||||
\begin{alltt}
|
||||
#define mp_tooctal(M, S) mp_toradix((M), (S), 8)
|
||||
#define mp_to_octal(M, S, N) mp_to_radix((M), (S), (N), 8)
|
||||
\end{alltt}
|
||||
|
||||
|
||||
\index{mp\_todecimal}
|
||||
\index{mp\_to\_decimal}
|
||||
\begin{alltt}
|
||||
#define mp_todecimal(M, S) mp_toradix((M), (S), 10)
|
||||
#define mp_to_decimal(M, S, N) mp_to_radix((M), (S), (N), 10)
|
||||
\end{alltt}
|
||||
|
||||
|
||||
\index{mp\_tohex}
|
||||
\index{mp\_to\_hex}
|
||||
\begin{alltt}
|
||||
#define mp_tohex(M, S) mp_toradix((M), (S), 16)
|
||||
#define mp_to_hex(M, S, N) mp_to_radix((M), (S), (N), 16)
|
||||
\end{alltt}
|
||||
|
||||
|
||||
|
@ -69,7 +69,7 @@ top:
|
||||
goto top;
|
||||
}
|
||||
|
||||
mp_toradix(&q, buf, 10);
|
||||
mp_to_decimal(&q, buf, sizeof(buf));
|
||||
printf("\n\n%d-bits (k = %lu) = %s\n", sizes[x], z, buf);
|
||||
fprintf(out, "%d-bits (k = %lu) = %s\n", sizes[x], z, buf);
|
||||
fflush(out);
|
||||
|
@ -50,7 +50,7 @@ top:
|
||||
sizes[x] += 1;
|
||||
goto top;
|
||||
} else {
|
||||
mp_toradix(&a, buf, 10);
|
||||
mp_to_decimal(&a, buf, sizeof(buf));
|
||||
printf("\n\np == %s\n\n", buf);
|
||||
fprintf(out, "%d-bit prime:\np == %s\n\n", mp_count_bits(&a), buf);
|
||||
fflush(out);
|
||||
|
10
etc/pprime.c
10
etc/pprime.c
@ -331,11 +331,11 @@ top:
|
||||
{
|
||||
char buf[4096];
|
||||
|
||||
mp_toradix(&n, buf, 10);
|
||||
mp_to_decimal(&n, buf, sizeof(buf));
|
||||
printf("Certificate of primality for:\n%s\n\n", buf);
|
||||
mp_toradix(&a, buf, 10);
|
||||
mp_to_decimal(&a, buf, sizeof(buf));
|
||||
printf("A == \n%s\n\n", buf);
|
||||
mp_toradix(&b, buf, 10);
|
||||
mp_to_decimal(&b, buf, sizeof(buf));
|
||||
printf("B == \n%s\n\nG == %lu\n", buf, bases[ii]);
|
||||
printf("----------------------------------------------------------------\n");
|
||||
}
|
||||
@ -400,9 +400,9 @@ int main(void)
|
||||
|
||||
printf("\n\nTook %d ticks, %d bits\n", t1, mp_count_bits(&p));
|
||||
|
||||
mp_toradix(&p, buf, 10);
|
||||
mp_to_decimal(&p, buf, sizeof(buf));
|
||||
printf("P == %s\n", buf);
|
||||
mp_toradix(&q, buf, 10);
|
||||
mp_to_decimal(&q, buf, sizeof(buf));
|
||||
printf("Q == %s\n", buf);
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user