dsa-keygen-test.c 867 Bytes
Newer Older
Niels Möller's avatar
Niels Möller committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "testutils.h"

#include "knuth-lfib.h"

static void
progress(void *ctx UNUSED, int c)
{
  fputc(c, stderr);
}

int
test_main(void)
{
  struct dsa_public_key pub;
  struct dsa_private_key key;
  
  struct knuth_lfib_ctx lfib;
  
  dsa_private_key_init(&key);
  dsa_public_key_init(&pub);

  knuth_lfib_init(&lfib, 13);

  if (!dsa_generate_keypair(&pub, &key,
25
			    &lfib, (nettle_random_func *) knuth_lfib_random,
Niels Möller's avatar
Niels Möller committed
26
			    NULL, verbose ? progress : NULL,
Niels Möller's avatar
Niels Möller committed
27
			    1024, 160))
Niels Möller's avatar
Niels Möller committed
28
29
    FAIL();

Niels Möller's avatar
Niels Möller committed
30
31
  test_dsa_key(&pub, &key, 160);
  test_dsa160(&pub, &key);
Niels Möller's avatar
Niels Möller committed
32

Niels Möller's avatar
Niels Möller committed
33
34
35
36
37
38
39
40
41
  if (!dsa_generate_keypair(&pub, &key,
			    &lfib, (nettle_random_func *) knuth_lfib_random,
			    NULL, verbose ? progress : NULL,
			    2048, 256))
    FAIL();

  test_dsa_key(&pub, &key, 256);
  test_dsa256(&pub, &key);
  
Niels Möller's avatar
Niels Möller committed
42
43
44
45
46
  dsa_public_key_clear(&pub);
  dsa_private_key_clear(&key);
  
  SUCCESS();
}