Esempio n. 1
0
int main(void)
{
	// Configure GPIOs:
	gpio_set_direction(IO_ADDRESS(GPIO1_BASE), 0x0000); // Switches
	gpio_set_direction(IO_ADDRESS(GPIO2_BASE), 0xffff); // LEDs

	// Configure the 7-segment displays:
	seg7_set_enabled_displays(IO_ADDRESS(SEG7_BASE), 0xff);
	seg7_set_value(IO_ADDRESS(SEG7_BASE), 0);

	// Set up the timer:
	timer_set(IO_ADDRESS(TIMER_BASE), SYSTEM_CLK_FREQ);

	// Print a startup message:
	uart_puts(IO_ADDRESS(UART_BASE), "The Potato Processor SHA256 Benchmark\n\r\n\r");

	// Enable interrupts:
	potato_enable_irq(IRQ_TIMER);
	potato_enable_interrupts();

	struct sha256_context context;

	// Prepare a block for hashing:
	uint32_t block[16];
	uint8_t * block_ptr = (uint8_t *) block;
	block_ptr[0] = 'a';
	block_ptr[1] = 'b';
	block_ptr[2] = 'c';
	sha256_pad_le_block(block_ptr, 3, 3);

	// Repeatedly hash the same data over and over again:
	while(true)
	{
		uint8_t hash[32];

		sha256_reset(&context);
		sha256_hash_block(&context, block);
		sha256_get_hash(&context, hash);
		++hashes_per_second;
	}

	return 0;
}
Esempio n. 2
0
static void noise_sha256_reset(NoiseHashState *state)
{
    NoiseSHA256State *st = (NoiseSHA256State *)state;
    sha256_reset(&(st->sha256));
}