ksft_print_header(); if (!cpu_has_capabilities())
ksft_exit_skip("Required CPU capabilities missing\n");
ksft_set_plan(1);
for (unsignedint trial = 0; trial < TRIALS; ++trial) { if (getrandom(key, sizeof(key), 0) != sizeof(key))
ksft_exit_skip("getrandom() failed unexpectedly\n");
memset(counter1, 0, sizeof(counter1));
reference_chacha20_blocks(output1, key, counter1, BLOCKS); for (unsignedint split = 0; split < BLOCKS; ++split) {
memset(output2, 'X', sizeof(output2));
memset(counter2, 0, sizeof(counter2)); if (split)
__arch_chacha20_blocks_nostack(output2, key, counter2, split);
__arch_chacha20_blocks_nostack(output2 + split * BLOCK_SIZE, key, counter2, BLOCKS - split); if (memcmp(output1, output2, sizeof(output1)))
ksft_exit_fail_msg("Main loop outputs do not match on trial %u, split %u\n", trial, split); if (memcmp(counter1, counter2, sizeof(counter1)))
ksft_exit_fail_msg("Main loop counters do not match on trial %u, split %u\n", trial, split);
}
}
memset(counter1, 0, sizeof(counter1));
counter1[0] = (uint32_t)-BLOCKS + 2;
memset(counter2, 0, sizeof(counter2));
counter2[0] = (uint32_t)-BLOCKS + 2;
reference_chacha20_blocks(output1, key, counter1, BLOCKS);
__arch_chacha20_blocks_nostack(output2, key, counter2, BLOCKS); if (memcmp(output1, output2, sizeof(output1)))
ksft_exit_fail_msg("Block limit outputs do not match after first round\n"); if (memcmp(counter1, counter2, sizeof(counter1)))
ksft_exit_fail_msg("Block limit counters do not match after first round\n");
reference_chacha20_blocks(output1, key, counter1, BLOCKS);
__arch_chacha20_blocks_nostack(output2, key, counter2, BLOCKS); if (memcmp(output1, output2, sizeof(output1)))
ksft_exit_fail_msg("Block limit outputs do not match after second round\n"); if (memcmp(counter1, counter2, sizeof(counter1)))
ksft_exit_fail_msg("Block limit counters do not match after second round\n");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.