Ejemplo n.º 1
0
void Decrypt(uint8_t *block, uint8_t *roundKeys)
{
	uint8_t i;
	uint8_t temp[4];

	for(i=0;i<8;i++) block[i] ^= READ_ROUND_KEY_BYTE(roundKeys[i]);
	S_layer(block);
	for(i=1;i<NUMBER_OF_ROUNDS;i++) decryption_round_function(block,roundKeys+BLOCK_SIZE*i, temp);
	for(i=0;i<BLOCK_SIZE;i++) block[i] ^= READ_ROUND_KEY_BYTE(roundKeys[i])^READ_ROUND_KEY_BYTE(roundKeys[160+i]);
}
Ejemplo n.º 2
0
void Decrypt(uint8_t *block, uint8_t *roundKeys)
{
	uint8_t i;
	for(i=0;i<BLOCK_SIZE;i++) block[i] ^= READ_ROUND_KEY_BYTE(roundKeys[i]);
	S_layer(block);
	for(i=0;i<(NUMBER_OF_ROUNDS-1);i++) decryption_round_function(block,roundKeys+BLOCK_SIZE,i);
	for(i=0;i<4;i++){
		block[2*i] ^= READ_ROUND_KEY_BYTE(roundKeys[2*i])^READ_ROUND_KEY_BYTE(roundKeys[8+2*i]);
		block[2*i+1] ^= READ_ROUND_KEY_BYTE(roundKeys[2*i+1])^(READ_ROUND_KEY_BYTE(roundKeys[8+2*i+1])+READ_ROUND_CONSTANT_BYTE(round_constants[i]));
	}
}