2 * Copyright (c) 1997-2000 The Stanford SRP Authentication Project
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
18 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
20 * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
21 * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
22 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
23 * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
24 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
26 * In addition, the following conditions apply:
28 * 1. Any software that incorporates the SRP authentication technology
29 * must display the following acknowlegment:
30 * "This product uses the 'Secure Remote Password' cryptographic
31 * authentication system developed by Tom Wu (tjw@CS.Stanford.EDU)."
33 * 2. Any software that incorporates all or part of the SRP distribution
34 * itself must also display the following acknowledgment:
35 * "This product includes software developed by Tom Wu and Eugene
36 * Jhong for the SRP Distribution (http://srp.stanford.edu/srp/)."
38 * 3. Redistributions in source or binary form must retain an intact copy
39 * of this copyright notice and list of conditions.
42 #include <unistd.h> /* close getlogin */
43 #include <stdlib.h> /* atexit exit */
49 #define MIN_BASIS_BITS 512
50 #define BASIS_BITS 2048
68 char *configFile
= NULL
;
70 char b64buf
[MAXB64PARAMLEN
];
71 int c
, ch
, i
, lastidx
, keylen
, yesno
, fsize
, status
, nparams
;
74 struct t_preconf
* tpc
;
76 struct t_conf
* tc
= &tcs
;
77 struct t_confent
* tcent
;
80 if ((chp
= strrchr(progName
, '/')) != (char *) 0) progName
= chp
+ 1;
82 while ((ch
= getopt(argc
, argv
, "dv2c:")) != EOF
)
97 fprintf(stderr
, "usage: %s [-dv2] [-c configfile]\n", progName
);
107 tcent
= t_newconfent(tc
);
109 printf("\nThis program will generate a set of parameters for the EPS\n");
110 printf("password file. The size of these parameters, measured in bits,\n");
111 printf("determines the level of security offered by SRP, and is related\n");
112 printf("to the security of similarly-sized RSA or Diffie-Hellman keys.\n");
113 printf("Choosing a predefined field is generally preferable to generating\n");
114 printf("a new field because clients can avoid costly parameter verification.\n");
115 printf("Either way, the values generated by this program are public and\n");
116 printf("can even shared between systems.\n");
118 printf("\nEnter the new field size, in bits. Suggested sizes:\n\n");
119 printf(" 512 (fast, minimally secure)\n");
120 printf(" 768 (moderate security)\n");
121 printf("1024 (most popular default)\n");
122 printf("1536 (additional security, possibly slow)\n");
123 printf("2048 (maximum supported security level)\n");
124 printf("\nField size (%d to %d): ", MIN_BASIS_BITS
, BASIS_BITS
);
126 fgets(cbuf
, sizeof(cbuf
), stdin
);
128 if(fsize
< MIN_BASIS_BITS
|| fsize
> BASIS_BITS
) {
129 fprintf(stderr
, "%s: field size must be between %d and %d\n",
130 progName
, MIN_BASIS_BITS
, BASIS_BITS
);
135 fprintf(stderr
, "Warning: new field size is not larger than old field size\n");
137 printf("\nInitializing random number generator...");
142 printf("done.\n\nGenerating a %d-bit composite with safe prime factors. This may take a while.\n", fsize
);
144 printf("done.\n\nGenerating a %d-bit safe prime. This may take a while.\n", fsize
);
146 while((tcent
= (composite
? t_makeconfent_c(tc
, fsize
) :
147 t_makeconfent(tc
, fsize
))) == NULL
)
148 printf("Parameter generation failed, retrying...\n");
149 tcent
->index
= lastidx
+ 1;
151 printf("\nParameters successfully generated.\n");
152 printf("N = [%s]\n", t_tob64(b64buf
,
153 tcent
->modulus
.data
, tcent
->modulus
.len
));
154 printf("g = [%s]\n", t_tob64(b64buf
,
155 tcent
->generator
.data
, tcent
->generator
.len
));
156 printf("\nYou must update the pre_params array in t_getconf.c\n");
This page took 0.059143 seconds and 5 git commands to generate.