projects
/
u
/
mdw
/
catacomb
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
73b9b84
)
Allow explicit group parameters for DH groups.
author
mdw
<mdw>
Sat, 3 Apr 2004 03:31:01 +0000
(
03:31
+0000)
committer
mdw
<mdw>
Sat, 3 Apr 2004 03:31:01 +0000
(
03:31
+0000)
keyutil.c
patch
|
blob
|
blame
|
history
diff --git
a/keyutil.c
b/keyutil.c
index
1619707
..
4bd42fe
100644
(file)
--- a/
keyutil.c
+++ b/
keyutil.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: keyutil.c,v 1.1
8 2004/04/01 12:50:09
mdw Exp $
+ * $Id: keyutil.c,v 1.1
9 2004/04/03 03:31:01
mdw Exp $
*
* Simple key manager program
*
*
* Simple key manager program
*
@@
-30,6
+30,9
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: keyutil.c,v $
/*----- Revision history --------------------------------------------------*
*
* $Log: keyutil.c,v $
+ * Revision 1.19 2004/04/03 03:31:01 mdw
+ * Allow explicit group parameters for DH groups.
+ *
* Revision 1.18 2004/04/01 12:50:09 mdw
* Add cyclic group abstraction, with test code. Separate off exponentation
* functions for better static linking. Fix a buttload of bugs on the way.
* Revision 1.18 2004/04/01 12:50:09 mdw
* Add cyclic group abstraction, with test code. Separate off exponentation
* functions for better static linking. Fix a buttload of bugs on the way.
@@
-130,6
+133,7
@@
#include "mprand.h"
#include "mptext.h"
#include "pgen.h"
#include "mprand.h"
#include "mptext.h"
#include "pgen.h"
+#include "ptab.h"
#include "rsa.h"
#include "sha-mgf.h"
#include "rsa.h"
#include "sha-mgf.h"
@@
-625,6
+629,22
@@
static void alg_dhparam(keyopts *k)
dh_param dp;
int rc;
dh_param dp;
int rc;
+ if (k->curve) {
+ qd_parse qd;
+
+ if (strcmp(k->curve, "list") == 0) {
+ const pentry *pe;
+ printf("Built-in prime groups:\n");
+ for (pe = ptab; pe->name; pe++)
+ printf(" %s\n", pe->name);
+ exit(0);
+ }
+ qd.p = k->curve;
+ if (dh_parse(&qd, &dp))
+ die(EXIT_FAILURE, "error in group spec: %s", qd.e);
+ goto done;
+ }
+
if (!k->bits)
k->bits = 1024;
if (!k->bits)
k->bits = 1024;
@@
-658,6
+678,7
@@
static void alg_dhparam(keyopts *k)
if (rc)
die(EXIT_FAILURE, "Diffie-Hellman parameter generation failed");
if (rc)
die(EXIT_FAILURE, "Diffie-Hellman parameter generation failed");
+ done:
key_structure(kd);
mpkey(kd, "p", dp.p, KCAT_SHARE);
mpkey(kd, "q", dp.q, KCAT_SHARE);
key_structure(kd);
mpkey(kd, "p", dp.p, KCAT_SHARE);
mpkey(kd, "q", dp.q, KCAT_SHARE);
@@
-751,6
+772,13
@@
static void alg_ecparam(keyopts *k)
/* --- Decide on a curve --- */
if (!k->bits) k->bits = 256;
/* --- Decide on a curve --- */
if (!k->bits) k->bits = 256;
+ if (k->curve && strcmp(k->curve, "list") == 0) {
+ const ecentry *ee;
+ printf("Built-in elliptic curves:\n");
+ for (ee = ectab; ee->name; ee++)
+ printf(" %s\n", ee->name);
+ exit(0);
+ }
if (!k->curve) {
if (k->bits <= 56) k->curve = "secp112r1";
else if (k->bits <= 64) k->curve = "secp128r1";
if (!k->curve) {
if (k->bits <= 56) k->curve = "secp112r1";
else if (k->bits <= 64) k->curve = "secp128r1";
@@
-961,13
+989,6
@@
static int cmd_add(int argc, char *argv[])
/* --- Elliptic curve parameters --- */
case 'C':
/* --- Elliptic curve parameters --- */
case 'C':
- if (strcmp(optarg, "list") == 0) {
- const ecentry *ee;
- printf("Built-in elliptic curves:\n");
- for (ee = ectab; ee->name; ee++)
- printf(" %s\n", ee->name);
- exit(0);
- }
k.curve = optarg;
break;
k.curve = optarg;
break;