lib_hash_drbg/src/drvr.c
/*
 * Turn a 64-bit random value (8 bytes) into an DRVR code word
 *  modifying the input data array in place
 * Note that there is an off-by-1 issue in the definition of
 *  a DRVR code word, so you will see (code_bit = code_bit-1) below
 *  and bit 63 is the parity bit, rather than bit 0.
 *
 * Parameters:
 * uint8_t* drvr - 8 byte array holding the random value (both input and output)
 */
Turn a 64-bit random value (8 bytes) into an DRVR code word
modifying the input data array in place
Note that there is an off-by-1 issue in the definition of
a DRVR code word, so you will see (code_bit = code_bit-1) below
and bit 63 is the parity bit, rather than bit 0.

uint8_t* drvr - 8 byte array holding the random value (both input and output)
Turn a 64 - bit random value ( 8 bytes ) into an DRVR code word modifying the input data array in place Note that there is an off - by - 1 issue in the definition of a DRVR code word so you will see ( code_bit = code_bit - 1 ) below and bit 63 is the parity bit rather than bit 0 . uint8_t * drvr - 8 byte array holding the random value ( both input and output )
void
drvr_b_make_code_word_64(uint8_t* drvr)
{
    int i;
    uint8_t parity_bit;     
    uint8_t code_bit;       
    parity_bit = 0;
    code_bit = 0;
    for (i = 0; i < 64; i += 1) {
        if ((drvr[i/8] & (1 << (i%8))) != 0) {
            parity_bit ^= 1;
            code_bit   ^= (i+1) & 0x3f;
        }
    }
    if (code_bit < 32) {
        code_bit = (code_bit - 1) & 0x3f;
        drvr[code_bit/8] ^= (1 << (code_bit%8));
        parity_bit  ^= 1;  
    } else {
        code_bit = (code_bit - 1) & 0x3f;
        drvr[(code_bit^32)/8] ^= (1 << ((code_bit^32)%8));
        drvr[31/8] ^= (1 << (31%8));
    }
    drvr[7] ^= (parity_bit<<7);  
}
void drvr_b_make_code_word_64 ( uint8_t * drvr ) { int i ; uint8_t parity_bit ; uint8_t code_bit ; parity_bit = 0 ; code_bit = 0 ; for ( i = 0 ; i < 64 ; i += 1 ) { if ( ( drvr [ i / 8 ] & ( 1 << ( i % 8 ) ) ) != 0 ) { parity_bit ^= 1 ; code_bit ^= ( i + 1 ) & 0x3f ; } } if ( code_bit < 32 ) { code_bit = ( code_bit - 1 ) & 0x3f ; drvr [ code_bit / 8 ] ^= ( 1 << ( code_bit % 8 ) ) ; parity_bit ^= 1 ; } else { code_bit = ( code_bit - 1 ) & 0x3f ; drvr [ ( code_bit ^ 32 ) / 8 ] ^= ( 1 << ( ( code_bit ^ 32 ) % 8 ) ) ; drvr [ 31 / 8 ] ^= ( 1 << ( 31 % 8 ) ) ; } drvr [ 7 ] ^= ( parity_bit << 7 ) ; }
Turn a 64-bit random value (8 bytes) into an DRVR code word
  modifying the input data array in place
 Note that there is an off-by-1 issue in the definition of
  a DRVR code word, so you will see (code_bit = code_bit-1) below
  and bit 63 is the parity bit, rather than bit 0.
Turn a 64 - bit random value ( 8 bytes ) into an DRVR code word modifying the input data array in place Note that there is an off - by - 1 issue in the definition of a DRVR code word so you will see ( code_bit = code_bit - 1 ) below and bit 63 is the parity bit rather than bit 0 .
/* Parity bit of drvr when */ /* Bit, which if changed, will make the drvr a code word */ /*
     * Generate the hamming code for the code word
     */ /*
     * Inverting drvr[code_bit-1] will cause the drvr
     *  to become a valid code word (except for overall parity)
     */ /* account for flipping a bit changing the parity */ /*
         * Avoid modifying the high bits, so modify two low bits instead
         */ /*
     * Finally, adjust the overall parity of the otpmk
     */ /* drvr bit 0 */