aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/https/x509/dsa.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon/https/x509/dsa.c')
-rw-r--r--src/daemon/https/x509/dsa.c142
1 files changed, 0 insertions, 142 deletions
diff --git a/src/daemon/https/x509/dsa.c b/src/daemon/https/x509/dsa.c
deleted file mode 100644
index d344c38f..00000000
--- a/src/daemon/https/x509/dsa.c
+++ /dev/null
@@ -1,142 +0,0 @@
1/*
2 * Copyright (C) 2003, 2004, 2005 Free Software Foundation
3 *
4 * Author: Nikos Mavrogiannopoulos
5 *
6 * This file is part of GNUTLS.
7 *
8 * The GNUTLS library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 2.1 of
11 * the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21 * USA
22 *
23 */
24
25/* This file contains code for DSA keys.
26 */
27
28#include <gnutls_int.h>
29#include <gnutls_errors.h>
30#include <gnutls_datum.h>
31#include <debug.h>
32
33/* resarr will contain: p(0), q(1), g(2), y(3), x(4).
34 */
35int
36MHD__gnutls_dsa_generate_params (mpi_t * resarr, int *resarr_len, int bits)
37{
38
39 int ret;
40 gcry_sexp_t parms, key, list;
41
42 /* FIXME: Remove me once we depend on 1.3.1 */
43 if (bits > 1024 && gcry_check_version ("1.3.1") == NULL)
44 {
45 MHD_gnutls_assert ();
46 return GNUTLS_E_INVALID_REQUEST;
47 }
48
49 if (bits < 512)
50 {
51 MHD_gnutls_assert ();
52 return GNUTLS_E_INVALID_REQUEST;
53 }
54
55 ret = gcry_sexp_build (&parms, NULL, "(genkey(dsa(nbits %d)))", bits);
56 if (ret != 0)
57 {
58 MHD_gnutls_assert ();
59 return GNUTLS_E_INTERNAL_ERROR;
60 }
61
62 /* generate the DSA key
63 */
64 ret = gcry_pk_genkey (&key, parms);
65 gcry_sexp_release (parms);
66
67 if (ret != 0)
68 {
69 MHD_gnutls_assert ();
70 return GNUTLS_E_INTERNAL_ERROR;
71 }
72
73 list = gcry_sexp_find_token (key, "p", 0);
74 if (list == NULL)
75 {
76 MHD_gnutls_assert ();
77 gcry_sexp_release (key);
78 return GNUTLS_E_INTERNAL_ERROR;
79 }
80
81 resarr[0] = gcry_sexp_nth_mpi (list, 1, 0);
82 gcry_sexp_release (list);
83
84 list = gcry_sexp_find_token (key, "q", 0);
85 if (list == NULL)
86 {
87 MHD_gnutls_assert ();
88 gcry_sexp_release (key);
89 return GNUTLS_E_INTERNAL_ERROR;
90 }
91
92 resarr[1] = gcry_sexp_nth_mpi (list, 1, 0);
93 gcry_sexp_release (list);
94
95 list = gcry_sexp_find_token (key, "g", 0);
96 if (list == NULL)
97 {
98 MHD_gnutls_assert ();
99 gcry_sexp_release (key);
100 return GNUTLS_E_INTERNAL_ERROR;
101 }
102
103 resarr[2] = gcry_sexp_nth_mpi (list, 1, 0);
104 gcry_sexp_release (list);
105
106 list = gcry_sexp_find_token (key, "y", 0);
107 if (list == NULL)
108 {
109 MHD_gnutls_assert ();
110 gcry_sexp_release (key);
111 return GNUTLS_E_INTERNAL_ERROR;
112 }
113
114 resarr[3] = gcry_sexp_nth_mpi (list, 1, 0);
115 gcry_sexp_release (list);
116
117
118 list = gcry_sexp_find_token (key, "x", 0);
119 if (list == NULL)
120 {
121 MHD_gnutls_assert ();
122 gcry_sexp_release (key);
123 return GNUTLS_E_INTERNAL_ERROR;
124 }
125
126 resarr[4] = gcry_sexp_nth_mpi (list, 1, 0);
127 gcry_sexp_release (list);
128
129
130 gcry_sexp_release (key);
131
132 MHD__gnutls_dump_mpi ("p: ", resarr[0]);
133 MHD__gnutls_dump_mpi ("q: ", resarr[1]);
134 MHD__gnutls_dump_mpi ("g: ", resarr[2]);
135 MHD__gnutls_dump_mpi ("y: ", resarr[3]);
136 MHD__gnutls_dump_mpi ("x: ", resarr[4]);
137
138 *resarr_len = 5;
139
140 return 0;
141
142}