CVSROOT:        /cvs
Module name:    src
Changes by:     [email protected]    2020/06/17 00:36:56

Modified files:
        sys/net        : toeplitz.c 

Log message:
Remove some of the unnecessary complications in the calculation of the
stoeplitz_cache and bring them into a form more suitable for mathematical
reasoning. Add a comment explaining the full construction which will also
help justifying upcoming diffs.

The observations for the code changes are the following:

First, scache->bytes[val] is a uint16_t, and we only need the lower
16 bits of res in the second nested pair of for loops.  The values of
key[b] are only xored together to compute res, so we only need the lower
16 bits of those, too.

Second, looking at the first nested for loop, we see that the values 0..15
of j only touch the top 16 bits of key[b], so we can skip them.  For b = 0,
the inner loop for j in 16..31 scans backwards through skey and sets the
corresponding bits of key[b], so key[0] = skey.  A bit of pondering then
leads to key[b] = skey << b | skey >> (NBSK - b).

The key array is renamed into column since it stores columns of the
Toeplitz matrix.

It's not very expensive to brute-force verify that scache->bytes[val]
remains the same for all values of val and all values of skey. I did
this on amd64, sparc64 and powerpc.

ok dlg

Reply via email to