lib_hash_drbg/src/drvr.c
/*
 * Check that a 64-bit random value (8 bytes) is a DRVR code word
 *
 * For this check, the 8 bytes are treated as an array, with byte 0
 *  containing bits 7 - 0, and byte 7 containing bits 63 - 56.
 *
 * Parameters:
 * uint8_t* otpmk - 8 byte array holding the random value (both input and output)
 *
 * Return code:
 *  0 - All is well
 * >0 - The intpu is not a code word
 */
Check that a 64-bit random value (8 bytes) is a DRVR code word
For this check, the 8 bytes are treated as an array, with byte 0
containing bits 7 - 0, and byte 7 containing bits 63 - 56.

uint8_t* otpmk - 8 byte array holding the random value (both input and output)

Return code:
0 - All is well
>0 - The intpu is not a code word
Check that a 64 - bit random value ( 8 bytes ) is a DRVR code word For this check the 8 bytes are treated as an array with byte 0 containing bits 7 - 0 and byte 7 containing bits 63 - 56 . uint8_t * otpmk - 8 byte array holding the random value ( both input and output ) Return code : 0 - All is well > 0 - The intpu is not a code word
int
drvr_b_check_code_word_64(uint8_t* drvr)
{
    int i;
    int j;
    uint8_t parity_bit;     
    uint8_t cbit1;
    uint8_t cbit2;
    uint8_t cbit3;
    uint8_t cbit4;
    uint8_t cbit5;
    uint8_t cbit6;
    parity_bit = 0;
    cbit1 = 0;
    cbit2 = 0;
    cbit3 = 0;
    cbit4 = 0;
    cbit5 = 0;
    cbit6 = 0;
    for (i = 0; i < 64; i += 2) {
        if((drvr[i/8] & (1 << (i%8))) != 0) {
            cbit1  ^= 1;
        }
    }
    for (i = 1; i <= 62; i += 4) {
      for (j = 0; j < 2; j += 1) {
        if ((drvr[(j+i)/8] & (1 << ((j+i)%8))) != 0) {
            cbit2  ^= 1;
	}
      }
    }
    for (i = 3; i <= 62; i += 8) {
      for (j = 0; j < 4; j += 1) {
        if ((drvr[(j+i)/8] & (1 << ((j+i)%8))) != 0) {
            cbit3  ^= 1;
	}
      }
    }
    for (i = 7; i <= 62; i += 16) {
      for (j = 0; j < 8; j += 1) {
        if ((drvr[(j+i)/8] & (1 << ((j+i)%8))) != 0) {
            cbit4  ^= 1;
	}
      }
    }
    for (i = 15; i <= 62; i += 32) {
      for (j = 0; j < 16; j += 1) {
        if ((drvr[(j+i)/8] & (1 << ((j+i)%8))) != 0) {
            cbit5  ^= 1;
	}
      }
    }
    for (i = 31; i <= 62; i += 64) {
      for (j = 0; j < 32; j += 1) {
        if ((drvr[(j+i)/8] & (1 << ((j+i)%8))) != 0) {
            cbit6  ^= 1;
	}
      }
    }
    for (i = 0; i < 64; i += 1) {
        if ((drvr[i/8] & (1 << (i%8))) != 0) {
            parity_bit  ^= 1;
        }
    }
    parity_bit ^= (cbit1 << 1);
    parity_bit ^= (cbit2 << 2);
    parity_bit ^= (cbit3 << 3);
    parity_bit ^= (cbit4 << 4);
    parity_bit ^= (cbit5 << 5);
    parity_bit ^= (cbit6 << 6);
    return(parity_bit);
}
int drvr_b_check_code_word_64 ( uint8_t * drvr ) { int i ; int j ; uint8_t parity_bit ; uint8_t cbit1 ; uint8_t cbit2 ; uint8_t cbit3 ; uint8_t cbit4 ; uint8_t cbit5 ; uint8_t cbit6 ; parity_bit = 0 ; cbit1 = 0 ; cbit2 = 0 ; cbit3 = 0 ; cbit4 = 0 ; cbit5 = 0 ; cbit6 = 0 ; for ( i = 0 ; i < 64 ; i += 2 ) { if ( ( drvr [ i / 8 ] & ( 1 << ( i % 8 ) ) ) != 0 ) { cbit1 ^= 1 ; } } for ( i = 1 ; i <= 62 ; i += 4 ) { for ( j = 0 ; j < 2 ; j += 1 ) { if ( ( drvr [ ( j + i ) / 8 ] & ( 1 << ( ( j + i ) % 8 ) ) ) != 0 ) { cbit2 ^= 1 ; } } } for ( i = 3 ; i <= 62 ; i += 8 ) { for ( j = 0 ; j < 4 ; j += 1 ) { if ( ( drvr [ ( j + i ) / 8 ] & ( 1 << ( ( j + i ) % 8 ) ) ) != 0 ) { cbit3 ^= 1 ; } } } for ( i = 7 ; i <= 62 ; i += 16 ) { for ( j = 0 ; j < 8 ; j += 1 ) { if ( ( drvr [ ( j + i ) / 8 ] & ( 1 << ( ( j + i ) % 8 ) ) ) != 0 ) { cbit4 ^= 1 ; } } } for ( i = 15 ; i <= 62 ; i += 32 ) { for ( j = 0 ; j < 16 ; j += 1 ) { if ( ( drvr [ ( j + i ) / 8 ] & ( 1 << ( ( j + i ) % 8 ) ) ) != 0 ) { cbit5 ^= 1 ; } } } for ( i = 31 ; i <= 62 ; i += 64 ) { for ( j = 0 ; j < 32 ; j += 1 ) { if ( ( drvr [ ( j + i ) / 8 ] & ( 1 << ( ( j + i ) % 8 ) ) ) != 0 ) { cbit6 ^= 1 ; } } } for ( i = 0 ; i < 64 ; i += 1 ) { if ( ( drvr [ i / 8 ] & ( 1 << ( i % 8 ) ) ) != 0 ) { parity_bit ^= 1 ; } } parity_bit ^= ( cbit1 << 1 ) ; parity_bit ^= ( cbit2 << 2 ) ; parity_bit ^= ( cbit3 << 3 ) ; parity_bit ^= ( cbit4 << 4 ) ; parity_bit ^= ( cbit5 << 5 ) ; parity_bit ^= ( cbit6 << 6 ) ; return ( parity_bit ) ; }
Check that a 64-bit random value (8 bytes) is a DRVR code word
 For this check, the 8 bytes are treated as an array, with byte 0
  containing bits 7 - 0, and byte 7 containing bits 63 - 56.
Check that a 64 - bit random value ( 8 bytes ) is a DRVR code word For this check the 8 bytes are treated as an array with byte 0 containing bits 7 - 0 and byte 7 containing bits 63 - 56 .
/* Parity bit of drvr when */ /*
     * Generate the hamming code for the code word
     */