Initialize Tizen 2.3
[external/nettle.git] / testsuite / dsa-keygen-test.c
1 #include "testutils.h"
2
3 #include "knuth-lfib.h"
4
5 static void
6 progress(void *ctx UNUSED, int c)
7 {
8   fputc(c, stderr);
9 }
10
11 int
12 test_main(void)
13 {
14   struct dsa_public_key pub;
15   struct dsa_private_key key;
16   
17   struct knuth_lfib_ctx lfib;
18   
19   dsa_private_key_init(&key);
20   dsa_public_key_init(&pub);
21
22   knuth_lfib_init(&lfib, 13);
23
24   if (!dsa_generate_keypair(&pub, &key,
25                             &lfib, (nettle_random_func *) knuth_lfib_random,
26                             NULL, verbose ? progress : NULL,
27                             1024, 160))
28     FAIL();
29
30   test_dsa_key(&pub, &key, 160);
31   test_dsa160(&pub, &key, NULL);
32
33   if (!dsa_generate_keypair(&pub, &key,
34                             &lfib, (nettle_random_func *) knuth_lfib_random,
35                             NULL, verbose ? progress : NULL,
36                             2048, 256))
37     FAIL();
38
39   test_dsa_key(&pub, &key, 256);
40   test_dsa256(&pub, &key, NULL);
41   
42   dsa_public_key_clear(&pub);
43   dsa_private_key_clear(&key);
44   
45   SUCCESS();
46 }