tools/key_generation/gen_drv_drbg.c
/* Generate the Hamming code bits for the 64 bits stored in number*/
/* according to sfp's ECC algorithm. */
Generate the Hamming code bits for the 64 bits stored in number
according to sfp's ECC algorithm.
Generate the Hamming code bits for the 64 bits stored in number according to sfp ' s ECC algorithm .
void generate_code_bits_hamming_B(bool number[])
{
	int i, j;
	char k[9];
	u8 parity;
	for (i = 0; i < 64; i = (2*(i+1) - 1))
		number[i] = 0;
	for (i = 0; i < 32; i = (2*(i+1) - 1)) {
		parity = number[i];
		for (j = i+1; j < 64; j++) {
			if (((i+1) & (j+1)) != 0)
				parity ^= number[j];
		number[i] = (number[i] & 0) | parity;
		}
	}
		parity = 0;
		for (j = 0; j < 64; j++)
			parity ^= number[j];
		number[63] = number[63] | parity;
#ifdef DEBUG
	printf("\nHamming code -\n");
	for (i = 0; i < DRV_SIZE_BITS; i++)
		printf("%d", number[i]);
#endif
	for (i = 0; i < DRV_SIZE_BYTES; i++) {
		for (j = 0; j < 8; j++) {
			k[j] =
			    (number[(DRV_SIZE_BYTES - i) * 8 - (j + 1)]) + 48;
		}
		k[8] = '\0';
		drv_hex[i] = (u8)strtoul(k, NULL, 2);
	}
}
void generate_code_bits_hamming_B ( bool number [ ] ) { int i , j ; char k [ 9 ] ; u8 parity ; for ( i = 0 ; i < 64 ; i = ( 2 * ( i + 1 ) - 1 ) ) number [ i ] = 0 ; for ( i = 0 ; i < 32 ; i = ( 2 * ( i + 1 ) - 1 ) ) { parity = number [ i ] ; for ( j = i + 1 ; j < 64 ; j ++ ) { if ( ( ( i + 1 ) & ( j + 1 ) ) != 0 ) parity ^= number [ j ] ; number [ i ] = ( number [ i ] & 0 ) | parity ; } } parity = 0 ; for ( j = 0 ; j < 64 ; j ++ ) parity ^= number [ j ] ; number [ 63 ] = number [ 63 ] | parity ; #ifdef DEBUG printf ( " \n \n " ) ; for ( i = 0 ; i < DRV_SIZE_BITS ; i ++ ) printf ( " " , number [ i ] ) ; #endif for ( i = 0 ; i < DRV_SIZE_BYTES ; i ++ ) { for ( j = 0 ; j < 8 ; j ++ ) { k [ j ] = ( number [ ( DRV_SIZE_BYTES - i ) * 8 - ( j + 1 ) ] ) + 48 ; } k [ 8 ] = ' \0 ' ; drv_hex [ i ] = ( u8 ) strtoul ( k , NULL , 2 ) ; } }
Generate the Hamming code bits for the 64 bits stored in number
according to sfp's ECC algorithm.
Generate the Hamming code bits for the 64 bits stored in number according to sfp ' s ECC algorithm .
/* response must be masked out the hamming coding bits first */ /* Calculate each code bit in turn */ /* Calculate the overall parity */