Commit b1643165 authored by Davide Galassi's avatar Davide Galassi

RSA keygen test using constant seed

parent 36023f33
#include "test.h"
#include <cry/rsa.h>
#include <cry/prng.h>
/* Just for... coverage :-) */
#define KEYGEN_BITS 256
static void keygen(void)
{
cry_rsa_ctx rsa;
ASSERT_OK(cry_rsa_keygen(&rsa, 1024));
/* Seed the PRNG to make results predictable */
cry_prng_init((unsigned char *)RAND_SEED_RAW, RAND_SEED_SIZ);
ASSERT_OK(cry_rsa_keygen(&rsa, KEYGEN_BITS));
}
static const unsigned char modulus[] = {
......@@ -119,8 +124,8 @@ static void sign_verify(void)
void rsa_test(void)
{
printf("* RSA Test\n");
run("keygen", keygen, NULL, NULL);
run("encrypt-decrypt", encrypt_decrypt, NULL, NULL);
run("sign-verify", sign_verify, NULL, NULL);
run("Keygen 512", keygen, NULL, NULL);
run("Encrypt-Decrypt", encrypt_decrypt, NULL, NULL);
run("Sign-Verify", sign_verify, NULL, NULL);
printf("\n");
}
......@@ -80,5 +80,8 @@ void run(const char *name, void (* test)(void),
cry_mpi_print(mpi, rad); \
} while(0)
/* Constant seed to make "rand" results predictable */
#define RAND_SEED_RAW "RANDSEED"
#define RAND_SEED_SIZ (sizeof(RAND_SEED_RAW) - 1)
#endif /* _TEST_H_ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment