Cryptography Reference
In-Depth Information
it is helpful deliberately to build errors into the arithmetic functions that lead to
false results (and then after the test phase to remove these errors without a trace!).
Since we cannot test every value in the range of definition for CLINT objects,
we need, in addition to fixed preset test values, randomly generated input values
that are uniformly distributed across the range of definition [0 ,N max ] .Tothisend
we use our function rand_l(r_l, bitlen) , where we select the number of binary
digits to be set in the variable bitlen with the help of the function usrand64_l()
modulo (MAX 2 +1) randomly from the interval [0 , MAX 2 ] . The first pass at
testing must be the functions for generating pseudorandom numbers, which were
discussed in Chapter 12, where among other things we employ the chi-squared
test described there for testing the statistical quality of the functions usrand64_l()
and usrandBBS_l() . Additionally, we must convince ourselves that the functions
rand_l() and randBBS_l() properly generate the CLINT number format and return
numbers of precisely the predetermined length. This test is also required for all
other functions that output CLINT objects. For recognizing erroneous formats of
CLINT arguments we have the function vcheck_l() , which is therefore to be placed
at the beginning of the sequence of tests.
A further condition for most of the tests is the possibility of determining
the equality or inequality and size comparison of integers represented by CLINT
objects. We must also test the functions ld_l() , equ_l() , mequ_l() ,and cmp_l() .
This can be accomplished with the use of both predefined and random numbers,
where all cases—equality as well as inequality with the corresponding size
relations—are to be tested.
The input of predefined values proceeds optimally, depending on the
purpose, by means of the function str2clint_l() or as an unsigned type with the
conversion function u2clint_l() or ul2clint_l() . The function xclint2str_l() ,
complementary to str2clint_l() , is used for the generation of test output. These
functions are therefore the next to appear on our list of functions to be tested.
For the testing of string functions we exploit their complementarity and check
whether executing one function after the other produces the original character
string or, for the other order, the output value in CLINT format. We shall return to
this principle repeatedly below.
All that now remains to test are the dynamic registers and their control
mechanisms from Chapter 9, which in general we would like to include in the
test functions. The use of registers as dynamically allocated memory supports us
in our efforts to test the FLINT/C functions, where we additionally implement
a debug library for the malloc() functions for allocation of memory. A typical
function in such a package, of which there are to be found both public-domain
and commercial products (cf. [Spul], Chapter 11), is checking for maintenance of
the bounds of dynamically allocated memory. With access to the CLINT registers
we can keep close tabs on our FLINT/C functions: Every penetration of the border
into foreign memory territory will be reported.
Search WWH ::




Custom Search