diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-10-05 11:54:54 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-10-05 11:54:54 +0000 |
commit | ce9d4213d520db280b5c3e75c36387e5f34fe3e2 (patch) | |
tree | 989e0d854f6f524bd0d98f706846d1bbf4937723 /src/util | |
parent | ae006a7ff8003fde7749b8a2e76f578977ea8db9 (diff) | |
download | gnunet-ce9d4213d520db280b5c3e75c36387e5f34fe3e2.tar.gz gnunet-ce9d4213d520db280b5c3e75c36387e5f34fe3e2.zip |
generate keys to use 2048 bit rsa
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/gnunet-rsa.c | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/src/util/gnunet-rsa.c b/src/util/gnunet-rsa.c index a013793e7..cdf693841 100644 --- a/src/util/gnunet-rsa.c +++ b/src/util/gnunet-rsa.c | |||
@@ -63,14 +63,13 @@ struct GNUNET_CRYPTO_RsaPrivateKey | |||
63 | }; | 63 | }; |
64 | 64 | ||
65 | 65 | ||
66 | #if 0 | ||
67 | /** | 66 | /** |
68 | * Create a new private key. Caller must free return value. | 67 | * Create a new private key. Caller must free return value. |
69 | * | 68 | * |
70 | * @return fresh private key | 69 | * @return fresh private key |
71 | */ | 70 | */ |
72 | struct GNUNET_CRYPTO_RsaPrivateKey * | 71 | static struct GNUNET_CRYPTO_RsaPrivateKey * |
73 | GNUNET_CRYPTO_rsa_key_create () | 72 | rsa_key_create () |
74 | { | 73 | { |
75 | struct GNUNET_CRYPTO_RsaPrivateKey *ret; | 74 | struct GNUNET_CRYPTO_RsaPrivateKey *ret; |
76 | gcry_sexp_t s_key; | 75 | gcry_sexp_t s_key; |
@@ -79,7 +78,7 @@ GNUNET_CRYPTO_rsa_key_create () | |||
79 | GNUNET_assert (0 == | 78 | GNUNET_assert (0 == |
80 | gcry_sexp_build (&s_keyparam, NULL, | 79 | gcry_sexp_build (&s_keyparam, NULL, |
81 | "(genkey(rsa(nbits %d)(rsa-use-e 3:257)))", | 80 | "(genkey(rsa(nbits %d)(rsa-use-e 3:257)))", |
82 | HOSTKEY_LEN)); | 81 | 2048)); |
83 | GNUNET_assert (0 == gcry_pk_genkey (&s_key, s_keyparam)); | 82 | GNUNET_assert (0 == gcry_pk_genkey (&s_key, s_keyparam)); |
84 | gcry_sexp_release (s_keyparam); | 83 | gcry_sexp_release (s_keyparam); |
85 | #if EXTRA_CHECKS | 84 | #if EXTRA_CHECKS |
@@ -89,7 +88,6 @@ GNUNET_CRYPTO_rsa_key_create () | |||
89 | ret->sexp = s_key; | 88 | ret->sexp = s_key; |
90 | return ret; | 89 | return ret; |
91 | } | 90 | } |
92 | #endif | ||
93 | 91 | ||
94 | 92 | ||
95 | /** | 93 | /** |
@@ -98,16 +96,10 @@ GNUNET_CRYPTO_rsa_key_create () | |||
98 | static void | 96 | static void |
99 | create_keys (const char *fn) | 97 | create_keys (const char *fn) |
100 | { | 98 | { |
101 | time_t start; | ||
102 | struct GNUNET_HashCode hc; | ||
103 | struct GNUNET_HashCode h2; | ||
104 | struct GNUNET_HashCode h3; | ||
105 | FILE *f; | 99 | FILE *f; |
106 | struct GNUNET_CRYPTO_RsaPrivateKey *pk; | 100 | struct GNUNET_CRYPTO_RsaPrivateKey *pk; |
107 | struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded *enc; | 101 | struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded *enc; |
108 | 102 | ||
109 | start = time (NULL); | ||
110 | GNUNET_CRYPTO_hash (&start, sizeof (start), &hc); | ||
111 | if (NULL == (f = fopen (fn, "w+"))) | 103 | if (NULL == (f = fopen (fn, "w+"))) |
112 | { | 104 | { |
113 | fprintf (stderr, | 105 | fprintf (stderr, |
@@ -123,11 +115,8 @@ create_keys (const char *fn) | |||
123 | { | 115 | { |
124 | fprintf (stderr, | 116 | fprintf (stderr, |
125 | "."); | 117 | "."); |
126 | GNUNET_CRYPTO_hash (&make_keys, sizeof (make_keys), &h2); | 118 | if (NULL == (pk = rsa_key_create ())) |
127 | GNUNET_CRYPTO_hash (&hc, sizeof (hc), &h3); | 119 | { |
128 | GNUNET_CRYPTO_hash_xor (&h2, &h3, &hc); | ||
129 | if (NULL == (pk = GNUNET_CRYPTO_rsa_key_create_from_hash (&hc))) | ||
130 | { | ||
131 | GNUNET_break (0); | 120 | GNUNET_break (0); |
132 | break; | 121 | break; |
133 | } | 122 | } |