Cryptography Reference
In-Depth Information
test and set a bit in a
CLINT
object
Function:
int setbit_l (CLINT a_l, unsigned int pos);
Syntax:
a_l
(CLINT argument)
pos
(bit position counted from
0
)
Input:
a_l
(result)
Output:
1
if the bit at position
pos
was already set
0
if the bit at position
pos
was not set
E_CLINT_OFL
if overflow
Return:
int
setbit_l (CLINT a_l, unsigned int pos)
{
int res = 0;
unsigned int i;
USHORT shorts = (USHORT)(pos >> LDBITPERDGT);
USHORT bitpos = (USHORT)(pos & (BITPERDGT - 1));
USHORTm=1U<<bitpos;
if (pos >= CLINTMAXBIT)
{
return E_CLINT_OFL;
}
if (shorts >= DIGITS_L (a_l))
{
If necessary,
a_l
is zero filled word by word, and the new length is stored in
a_l[0]
.
for (i = DIGITS_L (a_l) + 1; i <= shorts + 1; i++)
{
a_l[i] = 0;
}
SETDIGITS_L (a_l, shorts + 1);
}
The digit of
a_l
that contains the specified bit position is tested by means of the
mask prepared in
m
, and then the bit position is set to
1
via an OR of the relevant
digit with
m
. The function ends by returning the previous status.