Cryptography Reference
In-Depth Information
The function
xclint2str_l()
carries the required conversion of the
CLINT
representation into the representation to the specified base by means of a
sequence of divisions with remainder to the base
B
.
Conversion of a
CLINT
object into a character string
Function:
char * xclint2str_l (CLINT n_l, USHORT base,
int showbase);
Syntax:
n_l
(
CLINT
object to be converted)
base
(base of the numerical representation of the character
string to be specified);
showbase
(value
Input:
=0
: The numerical representation
has a “
0x
” in the case
base
=16
or “
0b
”if
base
=2
.
Value
=0
: there is no prefix.)
Return:
pointer to the calculated character string if all ok
NULL
if
base
<
2
or
base
>
16
static char ntable[16] =
{'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
char *
xclint2str_l (CLINT n_l, USHORT base, int showbase)
{
CLINTD u_l, r_l;
inti=0;
static char N[CLINTMAXBIT + 3];
if (2U > base || base > 16U)
{
return (char *)NULL;
/* error: invalid base */
}
cpy_l (u_l, n_l);
do
{
(void) udiv_l (u_l, base, u_l, r_l);
if (EQZ_L (r_l))
{
N[i++] = '0';
}
else