aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/https/tls/gnutls_rsa_export.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon/https/tls/gnutls_rsa_export.c')
-rw-r--r--src/daemon/https/tls/gnutls_rsa_export.c163
1 files changed, 0 insertions, 163 deletions
diff --git a/src/daemon/https/tls/gnutls_rsa_export.c b/src/daemon/https/tls/gnutls_rsa_export.c
index 64834a98..d48ee327 100644
--- a/src/daemon/https/tls/gnutls_rsa_export.c
+++ b/src/daemon/https/tls/gnutls_rsa_export.c
@@ -35,13 +35,6 @@
35#include "x509.h" 35#include "x509.h"
36#include "privkey.h" 36#include "privkey.h"
37 37
38/* This function takes a number of bits and returns a supported
39 * number of bits. Ie a number of bits that we have a prime in the
40 * dh_primes structure.
41 */
42
43#define MAX_SUPPORTED_BITS 512
44
45/* returns e and m, depends on the requested bits. 38/* returns e and m, depends on the requested bits.
46 * We only support limited key sizes. 39 * We only support limited key sizes.
47 */ 40 */
@@ -52,144 +45,9 @@ MHD__gnutls_rsa_params_to_mpi (MHD_gtls_rsa_params_t rsa_params)
52 { 45 {
53 return NULL; 46 return NULL;
54 } 47 }
55
56 return rsa_params->params; 48 return rsa_params->params;
57
58}
59
60/* resarr will contain: modulus(0), public exponent(1), private exponent(2),
61 * prime1 - p (3), prime2 - q(4), u (5).
62 */
63int
64MHD__gnutls_rsa_generate_params (mpi_t * resarr, int *resarr_len, int bits)
65{
66
67 int ret;
68 gcry_sexp_t parms, key, list;
69
70 ret = gcry_sexp_build (&parms, NULL, "(genkey(rsa(nbits %d)))", bits);
71 if (ret != 0)
72 {
73 MHD_gnutls_assert ();
74 return GNUTLS_E_INTERNAL_ERROR;
75 }
76
77 /* generate the RSA key */
78 ret = gcry_pk_genkey (&key, parms);
79 gcry_sexp_release (parms);
80
81 if (ret != 0)
82 {
83 MHD_gnutls_assert ();
84 return GNUTLS_E_INTERNAL_ERROR;
85 }
86
87 list = gcry_sexp_find_token (key, "n", 0);
88 if (list == NULL)
89 {
90 MHD_gnutls_assert ();
91 gcry_sexp_release (key);
92 return GNUTLS_E_INTERNAL_ERROR;
93 }
94
95 resarr[0] = gcry_sexp_nth_mpi (list, 1, 0);
96 gcry_sexp_release (list);
97
98 list = gcry_sexp_find_token (key, "e", 0);
99 if (list == NULL)
100 {
101 MHD_gnutls_assert ();
102 gcry_sexp_release (key);
103 return GNUTLS_E_INTERNAL_ERROR;
104 }
105
106 resarr[1] = gcry_sexp_nth_mpi (list, 1, 0);
107 gcry_sexp_release (list);
108
109 list = gcry_sexp_find_token (key, "d", 0);
110 if (list == NULL)
111 {
112 MHD_gnutls_assert ();
113 gcry_sexp_release (key);
114 return GNUTLS_E_INTERNAL_ERROR;
115 }
116
117 resarr[2] = gcry_sexp_nth_mpi (list, 1, 0);
118 gcry_sexp_release (list);
119
120 list = gcry_sexp_find_token (key, "p", 0);
121 if (list == NULL)
122 {
123 MHD_gnutls_assert ();
124 gcry_sexp_release (key);
125 return GNUTLS_E_INTERNAL_ERROR;
126 }
127
128 resarr[3] = gcry_sexp_nth_mpi (list, 1, 0);
129 gcry_sexp_release (list);
130
131
132 list = gcry_sexp_find_token (key, "q", 0);
133 if (list == NULL)
134 {
135 MHD_gnutls_assert ();
136 gcry_sexp_release (key);
137 return GNUTLS_E_INTERNAL_ERROR;
138 }
139
140 resarr[4] = gcry_sexp_nth_mpi (list, 1, 0);
141 gcry_sexp_release (list);
142
143
144 list = gcry_sexp_find_token (key, "u", 0);
145 if (list == NULL)
146 {
147 MHD_gnutls_assert ();
148 gcry_sexp_release (key);
149 return GNUTLS_E_INTERNAL_ERROR;
150 }
151
152 resarr[5] = gcry_sexp_nth_mpi (list, 1, 0);
153 gcry_sexp_release (list);
154
155 gcry_sexp_release (key);
156
157 MHD__gnutls_dump_mpi ("n: ", resarr[0]);
158 MHD__gnutls_dump_mpi ("e: ", resarr[1]);
159 MHD__gnutls_dump_mpi ("d: ", resarr[2]);
160 MHD__gnutls_dump_mpi ("p: ", resarr[3]);
161 MHD__gnutls_dump_mpi ("q: ", resarr[4]);
162 MHD__gnutls_dump_mpi ("u: ", resarr[5]);
163
164 *resarr_len = 6;
165
166 return 0;
167
168} 49}
169 50
170/**
171 * MHD__gnutls_rsa_params_init - This function will initialize the temporary RSA parameters
172 * @rsa_params: Is a structure that will hold the parameters
173 *
174 * This function will initialize the temporary RSA parameters structure.
175 *
176 **/
177int
178MHD__gnutls_rsa_params_init (MHD_gtls_rsa_params_t * rsa_params)
179{
180 int ret;
181
182 ret = MHD_gnutls_x509_privkey_init (rsa_params);
183 if (ret < 0)
184 {
185 MHD_gnutls_assert ();
186 return ret;
187 }
188
189 (*rsa_params)->crippled = 1;
190
191 return 0;
192}
193 51
194/** 52/**
195 * MHD__gnutls_rsa_params_deinit - This function will deinitialize the RSA parameters 53 * MHD__gnutls_rsa_params_deinit - This function will deinitialize the RSA parameters
@@ -204,24 +62,3 @@ MHD__gnutls_rsa_params_deinit (MHD_gtls_rsa_params_t rsa_params)
204 MHD_gnutls_x509_privkey_deinit (rsa_params); 62 MHD_gnutls_x509_privkey_deinit (rsa_params);
205} 63}
206 64
207/**
208 * MHD__gnutls_rsa_params_generate2 - This function will generate temporary RSA parameters
209 * @params: The structure where the parameters will be stored
210 * @bits: is the prime's number of bits
211 *
212 * This function will generate new temporary RSA parameters for use in
213 * RSA-EXPORT ciphersuites. This function is normally slow.
214 *
215 * Note that if the parameters are to be used in export cipher suites the
216 * bits value should be 512 or less.
217 * Also note that the generation of new RSA parameters is only useful
218 * to servers. Clients use the parameters sent by the server, thus it's
219 * no use calling this in client side.
220 *
221 **/
222int
223MHD__gnutls_rsa_params_generate2 (MHD_gtls_rsa_params_t params,
224 unsigned int bits)
225{
226 return MHD_gnutls_x509_privkey_generate (params, MHD_GNUTLS_PK_RSA, bits, 0);
227}