Ensure the table sizes are OK.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
This commit is contained in:
Steffen Jaeckel 2026-05-19 11:38:53 +02:00 committed by Karel Miko
parent 5a2bc6b131
commit 97f5d72457
3 changed files with 9 additions and 3 deletions

View file

@ -54,7 +54,7 @@ int cipher_hash_test(void)
int x;
/* test block ciphers */
for (x = 0; cipher_descriptor[x].name != NULL; x++) {
for (x = 0; x < TAB_SIZE && cipher_descriptor[x].name != NULL; x++) {
DOX(cipher_descriptor[x].test(), cipher_descriptor[x].name);
}
@ -100,7 +100,7 @@ int cipher_hash_test(void)
#endif
/* test hashes */
for (x = 0; hash_descriptor[x].name != NULL; x++) {
for (x = 0; x < TAB_SIZE && hash_descriptor[x].name != NULL; x++) {
DOX(hash_descriptor[x].test(), hash_descriptor[x].name);
/* test that state can be cloned via memcpy */
DOX(s_hash_state_clone_test(&hash_descriptor[x], hash_descriptor[x].name), hash_descriptor[x].name);

View file

@ -51,7 +51,7 @@ int prng_test(void)
#endif
/* test prngs (test, import/export) */
for (x = 0; prng_descriptor[x].name != NULL; x++) {
for (x = 0; x < TAB_SIZE && prng_descriptor[x].name != NULL; x++) {
if(strstr(prng_descriptor[x].name, "no_prng") == prng_descriptor[x].name) continue;
DOX(prng_descriptor[x].test(), prng_descriptor[x].name);
DOX(prng_descriptor[x].start(&nprng), prng_descriptor[x].name);

View file

@ -501,6 +501,12 @@ int main(int argc, char **argv)
XFREE(tinfo);
#endif
if (cipher_descriptor[TAB_SIZE - 1].name != NULL)
printf("cipher_descriptor Table full\n");
if (hash_descriptor[TAB_SIZE - 1].name != NULL)
printf("hash_descriptor Table full\n");
if (prng_descriptor[TAB_SIZE - 1].name != NULL)
printf("prng_descriptor Table full\n");
x = (fail > 0 || fail+pass+nop == 0) ? EXIT_FAILURE : EXIT_SUCCESS;
printf("\n\n%s: passed=%d failed=%d nop=%d duration=%.1fsec real=%.1fsec\n", x ? "FAILURE" : "SUCCESS", pass, fail, nop, (double)(dur)/(1000*1000), (double)(real)/(1000*1000));
return x;