File: | src/certtool-gaa.c |
Location: | line 1158, column 3 |
Description: | Value stored to 'gaa_index' is never read |
1 | /* File generated by GAA 1.6.6 |
2 | */ |
3 | #define GAA_NO_WIN32 |
4 | #line 1 "certtool.gaa" |
5 | |
6 | |
7 | /* C declarations */ |
8 | |
9 | #include <config.h> |
10 | #ifdef _WIN32 |
11 | # include <io.h> |
12 | #endif |
13 | |
14 | #include "certtool-common.h" |
15 | |
16 | #include <stdio.h> |
17 | #include <string.h> |
18 | #include <stdlib.h> |
19 | |
20 | #ifndef GAA_NO_WIN32 |
21 | #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(WINDOWS) |
22 | #define GAA_WIN32 |
23 | #endif |
24 | #endif |
25 | |
26 | static void* gaa_malloc( size_t size) { |
27 | void* ret; |
28 | ret = malloc(size); |
29 | if (ret==NULL((void*)0)) { |
30 | fprintf(stderrstderr, "gaa: could not allocate memory"); |
31 | exit(1); |
32 | } |
33 | return ret; |
34 | } |
35 | |
36 | static void __gaa_helpsingle(char short_name, char *name, |
37 | char *arg_desc, char *opt_help) |
38 | { |
39 | int col1, col3, col4, tabsize = 3, curr; |
40 | int i; |
41 | |
42 | col1 = 5; /* Default values */ |
43 | col3 = 30; |
44 | col4 = 70; |
45 | |
46 | curr = 0; |
47 | for(i = 0; i < col1; i++) |
48 | { |
49 | printf(" "); |
50 | curr++; |
51 | } |
52 | if(short_name) |
53 | { |
54 | if(name && *name) |
55 | { |
56 | printf("-%c, ", short_name); |
57 | curr += 4; |
58 | } |
59 | else |
60 | { |
61 | printf("-%c ", short_name); |
62 | curr += 3; |
63 | } |
64 | } |
65 | if(name && *name) |
66 | { |
67 | printf("--%s ", name); |
68 | curr += 3 + strlen(name); |
69 | } |
70 | if(arg_desc && *arg_desc) |
71 | { |
72 | printf("%s ", arg_desc); |
73 | curr += 1 + strlen(arg_desc); |
74 | } |
75 | if(curr >= col3) |
76 | { |
77 | printf("\n"); |
78 | curr = 0; |
79 | } |
80 | if(opt_help) /* let's print the option's help body */ |
81 | { |
82 | const char *str = opt_help; |
83 | while(*str) |
84 | { |
85 | while(curr < col3) |
86 | { |
87 | printf(" "); |
88 | curr++; |
89 | } |
90 | switch(*str) |
91 | { |
92 | case '\n': |
93 | printf("\n"); |
94 | curr = 0; |
95 | break; |
96 | case '\t': |
97 | do |
98 | { |
99 | printf(" "); |
100 | curr++; |
101 | } |
102 | while((curr - col3) % tabsize != 0 && curr < col4); |
103 | case ' ': |
104 | if(*str == ' ') |
105 | { |
106 | curr++; |
107 | printf(" "); |
108 | } |
109 | for(i = 1; str[i] && str[i] != ' ' && str[i] != '\n' |
110 | && str[i] != '\t'; i++); |
111 | if(curr + i - 1 >= col4) |
112 | curr = col4; |
113 | break; |
114 | default: |
115 | printf("%c", *str); |
116 | curr++; |
117 | } |
118 | if(curr >= col4) |
119 | { |
120 | printf("\n"); |
121 | curr = 0; |
122 | } |
123 | str++; |
124 | } |
125 | } |
126 | printf("\n"); |
127 | } |
128 | |
129 | void gaa_help(void) |
130 | { |
131 | printf("Certtool help\nUsage: certtool [options]\n"); |
132 | __gaa_helpsingle('s', "generate-self-signed", "", "Generate a self-signed certificate."); |
133 | __gaa_helpsingle('c', "generate-certificate", "", "Generate a signed certificate."); |
134 | __gaa_helpsingle(0, "generate-proxy", "", "Generate a proxy certificate."); |
135 | __gaa_helpsingle(0, "generate-crl", "", "Generate a CRL."); |
136 | __gaa_helpsingle('u', "update-certificate", "", "Update a signed certificate."); |
137 | __gaa_helpsingle('p', "generate-privkey", "", "Generate a private key."); |
138 | __gaa_helpsingle('q', "generate-request", "", "Generate a PKCS #10 certificate request."); |
139 | __gaa_helpsingle('e', "verify-chain", "", "Verify a PEM encoded certificate chain. The last certificate in the chain must be a self signed one."); |
140 | __gaa_helpsingle(0, "verify", "", "Verify a PEM encoded certificate chain. CA certificates must be loaded with --load-ca-certificate."); |
141 | __gaa_helpsingle(0, "verify-crl", "", "Verify a CRL."); |
142 | __gaa_helpsingle(0, "generate-dh-params", "", "Generate PKCS #3 encoded Diffie-Hellman parameters."); |
143 | __gaa_helpsingle(0, "get-dh-params", "", "Get the included PKCS #3 encoded Diffie-Hellman parameters."); |
144 | __gaa_helpsingle(0, "dh-info", "", "Print information on Diffie-Hellman parameters."); |
145 | __gaa_helpsingle(0, "load-privkey", "FILE ", "Private key file to use."); |
146 | __gaa_helpsingle(0, "load-pubkey", "FILE ", "Public key file to use."); |
147 | __gaa_helpsingle(0, "load-request", "FILE ", "Certificate request file to use."); |
148 | __gaa_helpsingle(0, "load-certificate", "FILE ", "Certificate file to use."); |
149 | __gaa_helpsingle(0, "load-ca-privkey", "FILE ", "Certificate authority's private key file to use."); |
150 | __gaa_helpsingle(0, "load-ca-certificate", "FILE ", "Certificate authority's certificate file to use."); |
151 | __gaa_helpsingle(0, "password", "PASSWORD ", "Password to use."); |
152 | __gaa_helpsingle('i', "certificate-info", "", "Print information on a certificate."); |
153 | __gaa_helpsingle(0, "certificate-pubkey", "", "Print certificate public key."); |
154 | __gaa_helpsingle(0, "pgp-certificate-info", "", "Print information on a OpenPGP certificate."); |
155 | __gaa_helpsingle(0, "pgp-ring-info", "", "Print information on a keyring structure."); |
156 | __gaa_helpsingle('l', "crl-info", "", "Print information on a CRL."); |
157 | __gaa_helpsingle(0, "crq-info", "", "Print information on a Certificate Request."); |
158 | __gaa_helpsingle(0, "no-crq-extensions", "", "Do not use extensions in certificate requests."); |
159 | __gaa_helpsingle(0, "p12-info", "", "Print information on a PKCS #12 structure."); |
160 | __gaa_helpsingle(0, "p7-info", "", "Print information on a PKCS #7 structure."); |
161 | __gaa_helpsingle(0, "smime-to-p7", "", "Convert S/MIME to PKCS #7 structure."); |
162 | __gaa_helpsingle('k', "key-info", "", "Print information on a private key."); |
163 | __gaa_helpsingle(0, "pgp-key-info", "", "Print information on a OpenPGP private key."); |
164 | __gaa_helpsingle(0, "pubkey-info", "", "Print information on a public key."); |
165 | __gaa_helpsingle(0, "fix-key", "", "Regenerate the parameters in a private key."); |
166 | __gaa_helpsingle(0, "v1", "", "Generate an X.509 version 1 certificate (no extensions)."); |
167 | __gaa_helpsingle(0, "to-p12", "", "Generate a PKCS #12 structure."); |
168 | __gaa_helpsingle(0, "to-p8", "", "Generate a PKCS #8 key structure."); |
169 | __gaa_helpsingle('8', "pkcs8", "", "Use PKCS #8 format for private keys."); |
170 | __gaa_helpsingle(0, "dsa", "", "Use DSA keys."); |
171 | __gaa_helpsingle(0, "rsa", "", "Use RSA keys."); |
172 | __gaa_helpsingle(0, "ecc", "", "Use ECC (ECDSA) keys."); |
173 | __gaa_helpsingle(0, "hash", "STR ", "Hash algorithm to use for signing (MD5,SHA1,RMD160,SHA256,SHA384,SHA512)."); |
174 | __gaa_helpsingle(0, "export-ciphers", "", "Use weak encryption algorithms."); |
175 | __gaa_helpsingle(0, "inder", "", "Use DER format for input certificates and private keys."); |
176 | __gaa_helpsingle(0, "inraw", "", "Use RAW/DER format for input certificates and private keys."); |
177 | __gaa_helpsingle(0, "outder", "", "Use DER format for output certificates and private keys."); |
178 | __gaa_helpsingle(0, "outraw", "", "Use RAW/DER format for output certificates and private keys."); |
179 | __gaa_helpsingle(0, "bits", "BITS ", "specify the number of bits for key generation."); |
180 | __gaa_helpsingle(0, "sec-param", "PARAM ", "specify the security level [low|normal|high|ultra]."); |
181 | __gaa_helpsingle(0, "disable-quick-random", "", "Use /dev/random for key generationg, thus increasing the quality of randomness used."); |
182 | __gaa_helpsingle(0, "outfile", "FILE ", "Output file."); |
183 | __gaa_helpsingle(0, "infile", "FILE ", "Input file."); |
184 | __gaa_helpsingle(0, "template", "FILE ", "Template file to use for non interactive operation."); |
185 | __gaa_helpsingle(0, "pkcs-cipher", "CIPHER ", "Cipher to use for pkcs operations (3des,3des-pkcs12,aes-128,aes-192,aes-256,rc2-40,arcfour)."); |
186 | __gaa_helpsingle('d', "debug", "LEVEL ", "specify the debug level. Default is 1."); |
187 | __gaa_helpsingle('h', "help", "", "shows this help text"); |
188 | __gaa_helpsingle('v', "version", "", "shows the program's version"); |
189 | |
190 | #line 100 "gaa.skel" |
191 | } |
192 | /* Copy of C area */ |
193 | |
194 | #line 104 "gaa.skel" |
195 | /* GAA HEADER */ |
196 | #ifndef GAA_HEADER_POKY |
197 | #define GAA_HEADER_POKY |
198 | |
199 | typedef struct _gaainfo gaainfo; |
200 | |
201 | struct _gaainfo |
202 | { |
203 | #line 148 "certtool.gaa" |
204 | int debug; |
205 | #line 145 "certtool.gaa" |
206 | char *pkcs_cipher; |
207 | #line 142 "certtool.gaa" |
208 | char *template; |
209 | #line 139 "certtool.gaa" |
210 | char *infile; |
211 | #line 136 "certtool.gaa" |
212 | char *outfile; |
213 | #line 133 "certtool.gaa" |
214 | int quick_random; |
215 | #line 130 "certtool.gaa" |
216 | char* sec_param; |
217 | #line 127 "certtool.gaa" |
218 | int bits; |
219 | #line 123 "certtool.gaa" |
220 | int outcert_format; |
221 | #line 119 "certtool.gaa" |
222 | int incert_format; |
223 | #line 116 "certtool.gaa" |
224 | int export; |
225 | #line 113 "certtool.gaa" |
226 | char *hash; |
227 | #line 110 "certtool.gaa" |
228 | int ecc; |
229 | #line 105 "certtool.gaa" |
230 | int dsa; |
231 | #line 102 "certtool.gaa" |
232 | int pkcs8; |
233 | #line 95 "certtool.gaa" |
234 | int v1_cert; |
235 | #line 92 "certtool.gaa" |
236 | int fix_key; |
237 | #line 75 "certtool.gaa" |
238 | int crq_extensions; |
239 | #line 60 "certtool.gaa" |
240 | char *pass; |
241 | #line 57 "certtool.gaa" |
242 | char *ca; |
243 | #line 54 "certtool.gaa" |
244 | char *ca_privkey; |
245 | #line 51 "certtool.gaa" |
246 | char *cert; |
247 | #line 48 "certtool.gaa" |
248 | char *request; |
249 | #line 45 "certtool.gaa" |
250 | char *pubkey; |
251 | #line 42 "certtool.gaa" |
252 | char *privkey; |
253 | #line 17 "certtool.gaa" |
254 | int action; |
255 | #line 16 "certtool.gaa" |
256 | int privkey_op; |
257 | |
258 | #line 114 "gaa.skel" |
259 | }; |
260 | |
261 | #ifdef __cplusplus |
262 | extern "C" |
263 | { |
264 | #endif |
265 | |
266 | int gaa(int argc, char *argv[], gaainfo *gaaval); |
267 | |
268 | void gaa_help(void); |
269 | |
270 | int gaa_file(const char *name, gaainfo *gaaval); |
271 | |
272 | #ifdef __cplusplus |
273 | } |
274 | #endif |
275 | |
276 | |
277 | #endif |
278 | |
279 | #line 135 "gaa.skel" |
280 | |
281 | /* C declarations */ |
282 | |
283 | #define GAAERROR(x){ gaa_error = 1; return x; } \ |
284 | { \ |
285 | gaa_error = 1; \ |
286 | return x; \ |
287 | } |
288 | |
289 | static char *gaa_current_option; |
290 | static int gaa_error = 0; |
291 | |
292 | /* Generated by gaa */ |
293 | |
294 | #include <string.h> |
295 | #include <stdlib.h> |
296 | |
297 | |
298 | #define GAA_OK-1 -1 |
299 | |
300 | #define GAA_ERROR_NOMATCH0 0 |
301 | #define GAA_ERROR_NOTENOUGH_ARGS1 1 |
302 | #define GAA_ERROR_INVALID_ARG2 2 |
303 | #define GAA_ERROR_UNKNOWN3 3 |
304 | |
305 | #define GAA_NOT_AN_OPTION0 0 |
306 | #define GAA_WORD_OPTION1 1 |
307 | #define GAA_LETTER_OPTION2 2 |
308 | #define GAA_MULTIPLE_OPTION3 3 |
309 | |
310 | #define GAA_REST0 0 |
311 | #define GAA_NB_OPTION57 57 |
312 | #define GAAOPTID_version1 1 |
313 | #define GAAOPTID_help2 2 |
314 | #define GAAOPTID_debug3 3 |
315 | #define GAAOPTID_pkcs_cipher4 4 |
316 | #define GAAOPTID_template5 5 |
317 | #define GAAOPTID_infile6 6 |
318 | #define GAAOPTID_outfile7 7 |
319 | #define GAAOPTID_disable_quick_random8 8 |
320 | #define GAAOPTID_sec_param9 9 |
321 | #define GAAOPTID_bits10 10 |
322 | #define GAAOPTID_outraw11 11 |
323 | #define GAAOPTID_outder12 12 |
324 | #define GAAOPTID_inraw13 13 |
325 | #define GAAOPTID_inder14 14 |
326 | #define GAAOPTID_export_ciphers15 15 |
327 | #define GAAOPTID_hash16 16 |
328 | #define GAAOPTID_ecc17 17 |
329 | #define GAAOPTID_rsa18 18 |
330 | #define GAAOPTID_dsa19 19 |
331 | #define GAAOPTID_pkcs820 20 |
332 | #define GAAOPTID_to_p821 21 |
333 | #define GAAOPTID_to_p1222 22 |
334 | #define GAAOPTID_v123 23 |
335 | #define GAAOPTID_fix_key24 24 |
336 | #define GAAOPTID_pubkey_info25 25 |
337 | #define GAAOPTID_pgp_key_info26 26 |
338 | #define GAAOPTID_key_info27 27 |
339 | #define GAAOPTID_smime_to_p728 28 |
340 | #define GAAOPTID_p7_info29 29 |
341 | #define GAAOPTID_p12_info30 30 |
342 | #define GAAOPTID_no_crq_extensions31 31 |
343 | #define GAAOPTID_crq_info32 32 |
344 | #define GAAOPTID_crl_info33 33 |
345 | #define GAAOPTID_pgp_ring_info34 34 |
346 | #define GAAOPTID_pgp_certificate_info35 35 |
347 | #define GAAOPTID_certificate_pubkey36 36 |
348 | #define GAAOPTID_certificate_info37 37 |
349 | #define GAAOPTID_password38 38 |
350 | #define GAAOPTID_load_ca_certificate39 39 |
351 | #define GAAOPTID_load_ca_privkey40 40 |
352 | #define GAAOPTID_load_certificate41 41 |
353 | #define GAAOPTID_load_request42 42 |
354 | #define GAAOPTID_load_pubkey43 43 |
355 | #define GAAOPTID_load_privkey44 44 |
356 | #define GAAOPTID_dh_info45 45 |
357 | #define GAAOPTID_get_dh_params46 46 |
358 | #define GAAOPTID_generate_dh_params47 47 |
359 | #define GAAOPTID_verify_crl48 48 |
360 | #define GAAOPTID_verify49 49 |
361 | #define GAAOPTID_verify_chain50 50 |
362 | #define GAAOPTID_generate_request51 51 |
363 | #define GAAOPTID_generate_privkey52 52 |
364 | #define GAAOPTID_update_certificate53 53 |
365 | #define GAAOPTID_generate_crl54 54 |
366 | #define GAAOPTID_generate_proxy55 55 |
367 | #define GAAOPTID_generate_certificate56 56 |
368 | #define GAAOPTID_generate_self_signed57 57 |
369 | |
370 | #line 168 "gaa.skel" |
371 | |
372 | #define GAA_CHECK1STR(a,b)if(a[0] == str[0]) { gaa_current_option = a; return b; } \ |
373 | if(a[0] == str[0]) \ |
374 | { \ |
375 | gaa_current_option = a; \ |
376 | return b; \ |
377 | } |
378 | |
379 | #define GAA_CHECKSTR(a,b)if(strcmp(a,str) == 0) { gaa_current_option = a; return b; } \ |
380 | if(strcmp(a,str) == 0) \ |
381 | { \ |
382 | gaa_current_option = a; \ |
383 | return b; \ |
384 | } |
385 | |
386 | #define GAA_TESTMOREARGSif(!OK) { while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) gaa_index++; if(gaa_last_non_option == gaa_index) return 1; } \ |
387 | if(!OK) \ |
388 | { \ |
389 | while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) \ |
390 | gaa_index++; \ |
391 | if(gaa_last_non_option == gaa_index) \ |
392 | return GAA_ERROR_NOTENOUGH_ARGS1; \ |
393 | } |
394 | |
395 | #define GAA_TESTMOREOPTIONALARGSif(!OK) { while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) gaa_index++; if(gaa_last_non_option == gaa_index) OK = 1; } \ |
396 | if(!OK) \ |
397 | { \ |
398 | while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) \ |
399 | gaa_index++; \ |
400 | if(gaa_last_non_option == gaa_index) \ |
401 | OK = 1; \ |
402 | } |
403 | |
404 | #define GAA_FILL_2ARGS(target, func)target = func(GAAargv[gaa_index]); gaa_arg_used[gaa_index] = 1 ; if(gaa_error == 1) { gaa_error = 0; return 2; } \ |
405 | target = func(GAAargv[gaa_index]); \ |
406 | gaa_arg_used[gaa_index] = 1; \ |
407 | if(gaa_error == 1) \ |
408 | { \ |
409 | gaa_error = 0; \ |
410 | return GAA_ERROR_INVALID_ARG2; \ |
411 | } |
412 | |
413 | |
414 | |
415 | #define GAA_FILL(target, func, num)if(!OK) { target = func(GAAargv[gaa_index]); gaa_arg_used[gaa_index ] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } num = 1 ; } else { num = 0; } \ |
416 | if(!OK) \ |
417 | { \ |
418 | target = func(GAAargv[gaa_index]); \ |
419 | gaa_arg_used[gaa_index] = 1; \ |
420 | if(gaa_error == 1) \ |
421 | { \ |
422 | gaa_error = 0; \ |
423 | return GAA_ERROR_INVALID_ARG2; \ |
424 | } \ |
425 | num = 1; \ |
426 | } \ |
427 | else \ |
428 | { \ |
429 | num = 0; \ |
430 | } |
431 | |
432 | #define GAA_LIST_FILL(target, func, type ,num)if(!OK) { num = 0; target = ((void*)0); if ( gaa_last_non_option - gaa_index > 0) target = gaa_malloc((gaa_last_non_option - gaa_index) * sizeof(type));for(; gaa_index < gaa_last_non_option ; gaa_index++) { if(gaa_arg_used[gaa_index] == 0) { target[num ] = func(GAAargv[gaa_index]); gaa_arg_used[gaa_index] = 1; if (gaa_error == 1) { gaa_error = 0; return 2; }; num++; } } if( num == 0) return 1; } \ |
433 | if(!OK) \ |
434 | { \ |
435 | num = 0; \ |
436 | target = NULL((void*)0); \ |
437 | if ( gaa_last_non_option - gaa_index > 0) \ |
438 | target = gaa_malloc((gaa_last_non_option - gaa_index) * sizeof(type));\ |
439 | for(; gaa_index < gaa_last_non_option; gaa_index++) \ |
440 | { \ |
441 | if(gaa_arg_used[gaa_index] == 0) \ |
442 | { \ |
443 | GAA_FILL_2ARGS(target[num], func)target[num] = func(GAAargv[gaa_index]); gaa_arg_used[gaa_index ] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; }; \ |
444 | num++; \ |
445 | } \ |
446 | } \ |
447 | if(num == 0) \ |
448 | return GAA_ERROR_NOTENOUGH_ARGS1; \ |
449 | } |
450 | |
451 | #define GAA_OPTIONALLIST_FILL(target, func, type ,num)if(!OK) { num = 0; target = ((void*)0); if ( gaa_last_non_option - gaa_index > 0) target = gaa_malloc((gaa_last_non_option - gaa_index) * sizeof(type));for(; gaa_index < gaa_last_non_option ; gaa_index++) { if(gaa_arg_used[gaa_index] == 0) { target[num ] = func(GAAargv[gaa_index]); gaa_arg_used[gaa_index] = 1; if (gaa_error == 1) { gaa_error = 0; return 2; }; num++; } } } \ |
452 | if(!OK) \ |
453 | { \ |
454 | num = 0; \ |
455 | target = NULL((void*)0); \ |
456 | if ( gaa_last_non_option - gaa_index > 0) \ |
457 | target = gaa_malloc((gaa_last_non_option - gaa_index) * sizeof(type));\ |
458 | for(; gaa_index < gaa_last_non_option; gaa_index++) \ |
459 | { \ |
460 | if(gaa_arg_used[gaa_index] == 0) \ |
461 | { \ |
462 | GAA_FILL_2ARGS(target[num], func)target[num] = func(GAAargv[gaa_index]); gaa_arg_used[gaa_index ] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; }; \ |
463 | num++; \ |
464 | } \ |
465 | } \ |
466 | } |
467 | |
468 | #define GAA_OBLIGAT(str)k = 0; for(i = 0; i < strlen(str); i++) { j = gaa_get_option_num (str + i, 2); if(j == 0) { printf("Error: invalid 'obligat' set\n" ); exit(-1); } if(opt_list[j] == 1) k = 1; } if(k == 0) { if( strlen(str) == 1) printf("You must give the -%s option\n", str ); else printf("You must give at least one option of '%s'\n", str); return 0; } \ |
469 | k = 0; \ |
470 | for(i = 0; i < strlen(str); i++) \ |
471 | { \ |
472 | j = gaa_get_option_num(str + i, GAA_LETTER_OPTION2); \ |
473 | if(j == GAA_ERROR_NOMATCH0) \ |
474 | { \ |
475 | printf("Error: invalid 'obligat' set\n"); \ |
476 | exit(-1); \ |
477 | } \ |
478 | if(opt_list[j] == 1) \ |
479 | k = 1; \ |
480 | } \ |
481 | if(k == 0) \ |
482 | { \ |
483 | if(strlen(str) == 1) \ |
484 | printf("You must give the -%s option\n", str); \ |
485 | else \ |
486 | printf("You must give at least one option of '%s'\n", str); \ |
487 | return 0; \ |
488 | } |
489 | |
490 | #define GAA_INCOMP(str)k = 0; for(i = 0; i < strlen(str); i++) { j = gaa_get_option_num (str + i, 2); if(j == 0) { printf("Error: invalid 'obligat' set\n" ); exit(-1); } if(opt_list[j] == 1) k++; } if(k > 1) { printf ("The options '%s' are incompatible\n", str); return 0; } \ |
491 | k = 0; \ |
492 | for(i = 0; i < strlen(str); i++) \ |
493 | { \ |
494 | j = gaa_get_option_num(str + i, GAA_LETTER_OPTION2); \ |
495 | if(j == GAA_ERROR_NOMATCH0) \ |
496 | { \ |
497 | printf("Error: invalid 'obligat' set\n"); \ |
498 | exit(-1); \ |
499 | } \ |
500 | if(opt_list[j] == 1) \ |
501 | k++; \ |
502 | } \ |
503 | if(k > 1) \ |
504 | { \ |
505 | printf("The options '%s' are incompatible\n", str); \ |
506 | return 0; \ |
507 | } |
508 | |
509 | |
510 | static char **GAAargv; |
511 | static int GAAargc; |
512 | static char *gaa_arg_used; |
513 | static int gaa_processing_file = 0; |
514 | static int inited = 0; |
515 | |
516 | static int gaa_getint(char *arg) |
517 | { |
518 | int tmp; |
519 | char a; |
520 | if(sscanf(arg, "%d%c", &tmp, &a) < 1) |
521 | { |
522 | printf("Option %s: '%s' isn't an integer\n", gaa_current_option, arg); |
523 | GAAERROR(-1){ gaa_error = 1; return -1; }; |
524 | } |
525 | return tmp; |
526 | } |
527 | |
528 | static char gaa_getchar(char *arg) |
529 | { |
530 | if(strlen(arg) != 1) |
531 | { |
532 | printf("Option %s: '%s' isn't an character\n", gaa_current_option, arg); |
533 | GAAERROR(-1){ gaa_error = 1; return -1; }; |
534 | } |
535 | return arg[0]; |
536 | } |
537 | |
538 | static char* gaa_getstr(char *arg) |
539 | { |
540 | return arg; |
541 | } |
542 | static float gaa_getfloat(char *arg) |
543 | { |
544 | float tmp; |
545 | char a; |
546 | if(sscanf(arg, "%f%c", &tmp, &a) < 1) |
547 | { |
548 | printf("Option %s: '%s' isn't a float number\n", gaa_current_option, arg); |
549 | GAAERROR(-1){ gaa_error = 1; return -1; }; |
550 | } |
551 | return tmp; |
552 | } |
553 | /* option structures */ |
554 | |
555 | struct GAAOPTION_debug |
556 | { |
557 | int arg1; |
558 | int size1; |
559 | }; |
560 | |
561 | struct GAAOPTION_pkcs_cipher |
562 | { |
563 | char* arg1; |
564 | int size1; |
565 | }; |
566 | |
567 | struct GAAOPTION_template |
568 | { |
569 | char* arg1; |
570 | int size1; |
571 | }; |
572 | |
573 | struct GAAOPTION_infile |
574 | { |
575 | char* arg1; |
576 | int size1; |
577 | }; |
578 | |
579 | struct GAAOPTION_outfile |
580 | { |
581 | char* arg1; |
582 | int size1; |
583 | }; |
584 | |
585 | struct GAAOPTION_sec_param |
586 | { |
587 | char* arg1; |
588 | int size1; |
589 | }; |
590 | |
591 | struct GAAOPTION_bits |
592 | { |
593 | int arg1; |
594 | int size1; |
595 | }; |
596 | |
597 | struct GAAOPTION_hash |
598 | { |
599 | char* arg1; |
600 | int size1; |
601 | }; |
602 | |
603 | struct GAAOPTION_password |
604 | { |
605 | char* arg1; |
606 | int size1; |
607 | }; |
608 | |
609 | struct GAAOPTION_load_ca_certificate |
610 | { |
611 | char* arg1; |
612 | int size1; |
613 | }; |
614 | |
615 | struct GAAOPTION_load_ca_privkey |
616 | { |
617 | char* arg1; |
618 | int size1; |
619 | }; |
620 | |
621 | struct GAAOPTION_load_certificate |
622 | { |
623 | char* arg1; |
624 | int size1; |
625 | }; |
626 | |
627 | struct GAAOPTION_load_request |
628 | { |
629 | char* arg1; |
630 | int size1; |
631 | }; |
632 | |
633 | struct GAAOPTION_load_pubkey |
634 | { |
635 | char* arg1; |
636 | int size1; |
637 | }; |
638 | |
639 | struct GAAOPTION_load_privkey |
640 | { |
641 | char* arg1; |
642 | int size1; |
643 | }; |
644 | |
645 | #line 349 "gaa.skel" |
646 | static int gaa_is_an_argument(char *str) |
647 | { |
648 | #ifdef GAA_WIN32 |
649 | if(str[0] == '/' && str[1] != 0) |
650 | return GAA_MULTIPLE_OPTION3; |
651 | #endif |
652 | if(str[0] != '-') |
653 | return GAA_NOT_AN_OPTION0; |
654 | if(str[1] == 0) |
655 | return GAA_NOT_AN_OPTION0; |
656 | if(str[1] == '-') |
657 | { |
658 | if(str[2] != 0) |
659 | return GAA_WORD_OPTION1; |
660 | else |
661 | return GAA_NOT_AN_OPTION0; |
662 | } |
663 | if(str[2] == 0) |
664 | return GAA_LETTER_OPTION2; |
665 | else |
666 | return GAA_MULTIPLE_OPTION3; |
667 | } |
668 | |
669 | static int gaa_get_option_num(char *str, int status) |
670 | { |
671 | switch(status) |
672 | { |
673 | case GAA_LETTER_OPTION2: |
674 | GAA_CHECK1STR("d", GAAOPTID_debug)if("d"[0] == str[0]) { gaa_current_option = "d"; return 3; }; |
675 | GAA_CHECK1STR("", GAAOPTID_pkcs_cipher)if(""[0] == str[0]) { gaa_current_option = ""; return 4; }; |
676 | GAA_CHECK1STR("", GAAOPTID_template)if(""[0] == str[0]) { gaa_current_option = ""; return 5; }; |
677 | GAA_CHECK1STR("", GAAOPTID_infile)if(""[0] == str[0]) { gaa_current_option = ""; return 6; }; |
678 | GAA_CHECK1STR("", GAAOPTID_outfile)if(""[0] == str[0]) { gaa_current_option = ""; return 7; }; |
679 | GAA_CHECK1STR("", GAAOPTID_sec_param)if(""[0] == str[0]) { gaa_current_option = ""; return 9; }; |
680 | GAA_CHECK1STR("", GAAOPTID_bits)if(""[0] == str[0]) { gaa_current_option = ""; return 10; }; |
681 | GAA_CHECK1STR("", GAAOPTID_hash)if(""[0] == str[0]) { gaa_current_option = ""; return 16; }; |
682 | GAA_CHECK1STR("", GAAOPTID_password)if(""[0] == str[0]) { gaa_current_option = ""; return 38; }; |
683 | GAA_CHECK1STR("", GAAOPTID_load_ca_certificate)if(""[0] == str[0]) { gaa_current_option = ""; return 39; }; |
684 | GAA_CHECK1STR("", GAAOPTID_load_ca_privkey)if(""[0] == str[0]) { gaa_current_option = ""; return 40; }; |
685 | GAA_CHECK1STR("", GAAOPTID_load_certificate)if(""[0] == str[0]) { gaa_current_option = ""; return 41; }; |
686 | GAA_CHECK1STR("", GAAOPTID_load_request)if(""[0] == str[0]) { gaa_current_option = ""; return 42; }; |
687 | GAA_CHECK1STR("", GAAOPTID_load_pubkey)if(""[0] == str[0]) { gaa_current_option = ""; return 43; }; |
688 | GAA_CHECK1STR("", GAAOPTID_load_privkey)if(""[0] == str[0]) { gaa_current_option = ""; return 44; }; |
689 | case GAA_MULTIPLE_OPTION3: |
690 | #line 375 "gaa.skel" |
691 | GAA_CHECK1STR("v", GAAOPTID_version)if("v"[0] == str[0]) { gaa_current_option = "v"; return 1; }; |
692 | GAA_CHECK1STR("h", GAAOPTID_help)if("h"[0] == str[0]) { gaa_current_option = "h"; return 2; }; |
693 | GAA_CHECK1STR("", GAAOPTID_disable_quick_random)if(""[0] == str[0]) { gaa_current_option = ""; return 8; }; |
694 | GAA_CHECK1STR("", GAAOPTID_outraw)if(""[0] == str[0]) { gaa_current_option = ""; return 11; }; |
695 | GAA_CHECK1STR("", GAAOPTID_outder)if(""[0] == str[0]) { gaa_current_option = ""; return 12; }; |
696 | GAA_CHECK1STR("", GAAOPTID_inraw)if(""[0] == str[0]) { gaa_current_option = ""; return 13; }; |
697 | GAA_CHECK1STR("", GAAOPTID_inder)if(""[0] == str[0]) { gaa_current_option = ""; return 14; }; |
698 | GAA_CHECK1STR("", GAAOPTID_export_ciphers)if(""[0] == str[0]) { gaa_current_option = ""; return 15; }; |
699 | GAA_CHECK1STR("", GAAOPTID_ecc)if(""[0] == str[0]) { gaa_current_option = ""; return 17; }; |
700 | GAA_CHECK1STR("", GAAOPTID_rsa)if(""[0] == str[0]) { gaa_current_option = ""; return 18; }; |
701 | GAA_CHECK1STR("", GAAOPTID_dsa)if(""[0] == str[0]) { gaa_current_option = ""; return 19; }; |
702 | GAA_CHECK1STR("8", GAAOPTID_pkcs8)if("8"[0] == str[0]) { gaa_current_option = "8"; return 20; }; |
703 | GAA_CHECK1STR("", GAAOPTID_to_p8)if(""[0] == str[0]) { gaa_current_option = ""; return 21; }; |
704 | GAA_CHECK1STR("", GAAOPTID_to_p12)if(""[0] == str[0]) { gaa_current_option = ""; return 22; }; |
705 | GAA_CHECK1STR("", GAAOPTID_v1)if(""[0] == str[0]) { gaa_current_option = ""; return 23; }; |
706 | GAA_CHECK1STR("", GAAOPTID_fix_key)if(""[0] == str[0]) { gaa_current_option = ""; return 24; }; |
707 | GAA_CHECK1STR("", GAAOPTID_pubkey_info)if(""[0] == str[0]) { gaa_current_option = ""; return 25; }; |
708 | GAA_CHECK1STR("", GAAOPTID_pgp_key_info)if(""[0] == str[0]) { gaa_current_option = ""; return 26; }; |
709 | GAA_CHECK1STR("k", GAAOPTID_key_info)if("k"[0] == str[0]) { gaa_current_option = "k"; return 27; }; |
710 | GAA_CHECK1STR("", GAAOPTID_smime_to_p7)if(""[0] == str[0]) { gaa_current_option = ""; return 28; }; |
711 | GAA_CHECK1STR("", GAAOPTID_p7_info)if(""[0] == str[0]) { gaa_current_option = ""; return 29; }; |
712 | GAA_CHECK1STR("", GAAOPTID_p12_info)if(""[0] == str[0]) { gaa_current_option = ""; return 30; }; |
713 | GAA_CHECK1STR("", GAAOPTID_no_crq_extensions)if(""[0] == str[0]) { gaa_current_option = ""; return 31; }; |
714 | GAA_CHECK1STR("", GAAOPTID_crq_info)if(""[0] == str[0]) { gaa_current_option = ""; return 32; }; |
715 | GAA_CHECK1STR("l", GAAOPTID_crl_info)if("l"[0] == str[0]) { gaa_current_option = "l"; return 33; }; |
716 | GAA_CHECK1STR("", GAAOPTID_pgp_ring_info)if(""[0] == str[0]) { gaa_current_option = ""; return 34; }; |
717 | GAA_CHECK1STR("", GAAOPTID_pgp_certificate_info)if(""[0] == str[0]) { gaa_current_option = ""; return 35; }; |
718 | GAA_CHECK1STR("", GAAOPTID_certificate_pubkey)if(""[0] == str[0]) { gaa_current_option = ""; return 36; }; |
719 | GAA_CHECK1STR("i", GAAOPTID_certificate_info)if("i"[0] == str[0]) { gaa_current_option = "i"; return 37; }; |
720 | GAA_CHECK1STR("", GAAOPTID_dh_info)if(""[0] == str[0]) { gaa_current_option = ""; return 45; }; |
721 | GAA_CHECK1STR("", GAAOPTID_get_dh_params)if(""[0] == str[0]) { gaa_current_option = ""; return 46; }; |
722 | GAA_CHECK1STR("", GAAOPTID_generate_dh_params)if(""[0] == str[0]) { gaa_current_option = ""; return 47; }; |
723 | GAA_CHECK1STR("", GAAOPTID_verify_crl)if(""[0] == str[0]) { gaa_current_option = ""; return 48; }; |
724 | GAA_CHECK1STR("", GAAOPTID_verify)if(""[0] == str[0]) { gaa_current_option = ""; return 49; }; |
725 | GAA_CHECK1STR("e", GAAOPTID_verify_chain)if("e"[0] == str[0]) { gaa_current_option = "e"; return 50; }; |
726 | GAA_CHECK1STR("q", GAAOPTID_generate_request)if("q"[0] == str[0]) { gaa_current_option = "q"; return 51; }; |
727 | GAA_CHECK1STR("p", GAAOPTID_generate_privkey)if("p"[0] == str[0]) { gaa_current_option = "p"; return 52; }; |
728 | GAA_CHECK1STR("u", GAAOPTID_update_certificate)if("u"[0] == str[0]) { gaa_current_option = "u"; return 53; }; |
729 | GAA_CHECK1STR("", GAAOPTID_generate_crl)if(""[0] == str[0]) { gaa_current_option = ""; return 54; }; |
730 | GAA_CHECK1STR("", GAAOPTID_generate_proxy)if(""[0] == str[0]) { gaa_current_option = ""; return 55; }; |
731 | GAA_CHECK1STR("c", GAAOPTID_generate_certificate)if("c"[0] == str[0]) { gaa_current_option = "c"; return 56; }; |
732 | GAA_CHECK1STR("s", GAAOPTID_generate_self_signed)if("s"[0] == str[0]) { gaa_current_option = "s"; return 57; }; |
733 | |
734 | #line 277 "gaa.skel" |
735 | break; |
736 | case GAA_WORD_OPTION1: |
737 | GAA_CHECKSTR("version", GAAOPTID_version)if(strcmp("version",str) == 0) { gaa_current_option = "version" ; return 1; }; |
738 | GAA_CHECKSTR("help", GAAOPTID_help)if(strcmp("help",str) == 0) { gaa_current_option = "help"; return 2; }; |
739 | GAA_CHECKSTR("debug", GAAOPTID_debug)if(strcmp("debug",str) == 0) { gaa_current_option = "debug"; return 3; }; |
740 | GAA_CHECKSTR("pkcs-cipher", GAAOPTID_pkcs_cipher)if(strcmp("pkcs-cipher",str) == 0) { gaa_current_option = "pkcs-cipher" ; return 4; }; |
741 | GAA_CHECKSTR("template", GAAOPTID_template)if(strcmp("template",str) == 0) { gaa_current_option = "template" ; return 5; }; |
742 | GAA_CHECKSTR("infile", GAAOPTID_infile)if(strcmp("infile",str) == 0) { gaa_current_option = "infile" ; return 6; }; |
743 | GAA_CHECKSTR("outfile", GAAOPTID_outfile)if(strcmp("outfile",str) == 0) { gaa_current_option = "outfile" ; return 7; }; |
744 | GAA_CHECKSTR("disable-quick-random", GAAOPTID_disable_quick_random)if(strcmp("disable-quick-random",str) == 0) { gaa_current_option = "disable-quick-random"; return 8; }; |
745 | GAA_CHECKSTR("sec-param", GAAOPTID_sec_param)if(strcmp("sec-param",str) == 0) { gaa_current_option = "sec-param" ; return 9; }; |
746 | GAA_CHECKSTR("bits", GAAOPTID_bits)if(strcmp("bits",str) == 0) { gaa_current_option = "bits"; return 10; }; |
747 | GAA_CHECKSTR("outraw", GAAOPTID_outraw)if(strcmp("outraw",str) == 0) { gaa_current_option = "outraw" ; return 11; }; |
748 | GAA_CHECKSTR("outder", GAAOPTID_outder)if(strcmp("outder",str) == 0) { gaa_current_option = "outder" ; return 12; }; |
749 | GAA_CHECKSTR("inraw", GAAOPTID_inraw)if(strcmp("inraw",str) == 0) { gaa_current_option = "inraw"; return 13; }; |
750 | GAA_CHECKSTR("inder", GAAOPTID_inder)if(strcmp("inder",str) == 0) { gaa_current_option = "inder"; return 14; }; |
751 | GAA_CHECKSTR("export-ciphers", GAAOPTID_export_ciphers)if(strcmp("export-ciphers",str) == 0) { gaa_current_option = "export-ciphers" ; return 15; }; |
752 | GAA_CHECKSTR("hash", GAAOPTID_hash)if(strcmp("hash",str) == 0) { gaa_current_option = "hash"; return 16; }; |
753 | GAA_CHECKSTR("ecc", GAAOPTID_ecc)if(strcmp("ecc",str) == 0) { gaa_current_option = "ecc"; return 17; }; |
754 | GAA_CHECKSTR("rsa", GAAOPTID_rsa)if(strcmp("rsa",str) == 0) { gaa_current_option = "rsa"; return 18; }; |
755 | GAA_CHECKSTR("dsa", GAAOPTID_dsa)if(strcmp("dsa",str) == 0) { gaa_current_option = "dsa"; return 19; }; |
756 | GAA_CHECKSTR("pkcs8", GAAOPTID_pkcs8)if(strcmp("pkcs8",str) == 0) { gaa_current_option = "pkcs8"; return 20; }; |
757 | GAA_CHECKSTR("to-p8", GAAOPTID_to_p8)if(strcmp("to-p8",str) == 0) { gaa_current_option = "to-p8"; return 21; }; |
758 | GAA_CHECKSTR("to-p12", GAAOPTID_to_p12)if(strcmp("to-p12",str) == 0) { gaa_current_option = "to-p12" ; return 22; }; |
759 | GAA_CHECKSTR("v1", GAAOPTID_v1)if(strcmp("v1",str) == 0) { gaa_current_option = "v1"; return 23; }; |
760 | GAA_CHECKSTR("fix-key", GAAOPTID_fix_key)if(strcmp("fix-key",str) == 0) { gaa_current_option = "fix-key" ; return 24; }; |
761 | GAA_CHECKSTR("pubkey-info", GAAOPTID_pubkey_info)if(strcmp("pubkey-info",str) == 0) { gaa_current_option = "pubkey-info" ; return 25; }; |
762 | GAA_CHECKSTR("pgp-key-info", GAAOPTID_pgp_key_info)if(strcmp("pgp-key-info",str) == 0) { gaa_current_option = "pgp-key-info" ; return 26; }; |
763 | GAA_CHECKSTR("key-info", GAAOPTID_key_info)if(strcmp("key-info",str) == 0) { gaa_current_option = "key-info" ; return 27; }; |
764 | GAA_CHECKSTR("smime-to-p7", GAAOPTID_smime_to_p7)if(strcmp("smime-to-p7",str) == 0) { gaa_current_option = "smime-to-p7" ; return 28; }; |
765 | GAA_CHECKSTR("p7-info", GAAOPTID_p7_info)if(strcmp("p7-info",str) == 0) { gaa_current_option = "p7-info" ; return 29; }; |
766 | GAA_CHECKSTR("p12-info", GAAOPTID_p12_info)if(strcmp("p12-info",str) == 0) { gaa_current_option = "p12-info" ; return 30; }; |
767 | GAA_CHECKSTR("no-crq-extensions", GAAOPTID_no_crq_extensions)if(strcmp("no-crq-extensions",str) == 0) { gaa_current_option = "no-crq-extensions"; return 31; }; |
768 | GAA_CHECKSTR("crq-info", GAAOPTID_crq_info)if(strcmp("crq-info",str) == 0) { gaa_current_option = "crq-info" ; return 32; }; |
769 | GAA_CHECKSTR("crl-info", GAAOPTID_crl_info)if(strcmp("crl-info",str) == 0) { gaa_current_option = "crl-info" ; return 33; }; |
770 | GAA_CHECKSTR("pgp-ring-info", GAAOPTID_pgp_ring_info)if(strcmp("pgp-ring-info",str) == 0) { gaa_current_option = "pgp-ring-info" ; return 34; }; |
771 | GAA_CHECKSTR("pgp-certificate-info", GAAOPTID_pgp_certificate_info)if(strcmp("pgp-certificate-info",str) == 0) { gaa_current_option = "pgp-certificate-info"; return 35; }; |
772 | GAA_CHECKSTR("certificate-pubkey", GAAOPTID_certificate_pubkey)if(strcmp("certificate-pubkey",str) == 0) { gaa_current_option = "certificate-pubkey"; return 36; }; |
773 | GAA_CHECKSTR("certificate-info", GAAOPTID_certificate_info)if(strcmp("certificate-info",str) == 0) { gaa_current_option = "certificate-info"; return 37; }; |
774 | GAA_CHECKSTR("password", GAAOPTID_password)if(strcmp("password",str) == 0) { gaa_current_option = "password" ; return 38; }; |
775 | GAA_CHECKSTR("load-ca-certificate", GAAOPTID_load_ca_certificate)if(strcmp("load-ca-certificate",str) == 0) { gaa_current_option = "load-ca-certificate"; return 39; }; |
776 | GAA_CHECKSTR("load-ca-privkey", GAAOPTID_load_ca_privkey)if(strcmp("load-ca-privkey",str) == 0) { gaa_current_option = "load-ca-privkey"; return 40; }; |
777 | GAA_CHECKSTR("load-certificate", GAAOPTID_load_certificate)if(strcmp("load-certificate",str) == 0) { gaa_current_option = "load-certificate"; return 41; }; |
778 | GAA_CHECKSTR("load-request", GAAOPTID_load_request)if(strcmp("load-request",str) == 0) { gaa_current_option = "load-request" ; return 42; }; |
779 | GAA_CHECKSTR("load-pubkey", GAAOPTID_load_pubkey)if(strcmp("load-pubkey",str) == 0) { gaa_current_option = "load-pubkey" ; return 43; }; |
780 | GAA_CHECKSTR("load-privkey", GAAOPTID_load_privkey)if(strcmp("load-privkey",str) == 0) { gaa_current_option = "load-privkey" ; return 44; }; |
781 | GAA_CHECKSTR("dh-info", GAAOPTID_dh_info)if(strcmp("dh-info",str) == 0) { gaa_current_option = "dh-info" ; return 45; }; |
782 | GAA_CHECKSTR("get-dh-params", GAAOPTID_get_dh_params)if(strcmp("get-dh-params",str) == 0) { gaa_current_option = "get-dh-params" ; return 46; }; |
783 | GAA_CHECKSTR("generate-dh-params", GAAOPTID_generate_dh_params)if(strcmp("generate-dh-params",str) == 0) { gaa_current_option = "generate-dh-params"; return 47; }; |
784 | GAA_CHECKSTR("verify-crl", GAAOPTID_verify_crl)if(strcmp("verify-crl",str) == 0) { gaa_current_option = "verify-crl" ; return 48; }; |
785 | GAA_CHECKSTR("verify", GAAOPTID_verify)if(strcmp("verify",str) == 0) { gaa_current_option = "verify" ; return 49; }; |
786 | GAA_CHECKSTR("verify-chain", GAAOPTID_verify_chain)if(strcmp("verify-chain",str) == 0) { gaa_current_option = "verify-chain" ; return 50; }; |
787 | GAA_CHECKSTR("generate-request", GAAOPTID_generate_request)if(strcmp("generate-request",str) == 0) { gaa_current_option = "generate-request"; return 51; }; |
788 | GAA_CHECKSTR("generate-privkey", GAAOPTID_generate_privkey)if(strcmp("generate-privkey",str) == 0) { gaa_current_option = "generate-privkey"; return 52; }; |
789 | GAA_CHECKSTR("update-certificate", GAAOPTID_update_certificate)if(strcmp("update-certificate",str) == 0) { gaa_current_option = "update-certificate"; return 53; }; |
790 | GAA_CHECKSTR("generate-crl", GAAOPTID_generate_crl)if(strcmp("generate-crl",str) == 0) { gaa_current_option = "generate-crl" ; return 54; }; |
791 | GAA_CHECKSTR("generate-proxy", GAAOPTID_generate_proxy)if(strcmp("generate-proxy",str) == 0) { gaa_current_option = "generate-proxy" ; return 55; }; |
792 | GAA_CHECKSTR("generate-certificate", GAAOPTID_generate_certificate)if(strcmp("generate-certificate",str) == 0) { gaa_current_option = "generate-certificate"; return 56; }; |
793 | GAA_CHECKSTR("generate-self-signed", GAAOPTID_generate_self_signed)if(strcmp("generate-self-signed",str) == 0) { gaa_current_option = "generate-self-signed"; return 57; }; |
794 | |
795 | #line 281 "gaa.skel" |
796 | break; |
797 | default: break; |
798 | } |
799 | return GAA_ERROR_NOMATCH0; |
800 | } |
801 | |
802 | static int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list) |
803 | { |
804 | int OK = 0; |
805 | int gaa_last_non_option; |
806 | struct GAAOPTION_debug GAATMP_debug; |
807 | struct GAAOPTION_pkcs_cipher GAATMP_pkcs_cipher; |
808 | struct GAAOPTION_template GAATMP_template; |
809 | struct GAAOPTION_infile GAATMP_infile; |
810 | struct GAAOPTION_outfile GAATMP_outfile; |
811 | struct GAAOPTION_sec_param GAATMP_sec_param; |
812 | struct GAAOPTION_bits GAATMP_bits; |
813 | struct GAAOPTION_hash GAATMP_hash; |
814 | struct GAAOPTION_password GAATMP_password; |
815 | struct GAAOPTION_load_ca_certificate GAATMP_load_ca_certificate; |
816 | struct GAAOPTION_load_ca_privkey GAATMP_load_ca_privkey; |
817 | struct GAAOPTION_load_certificate GAATMP_load_certificate; |
818 | struct GAAOPTION_load_request GAATMP_load_request; |
819 | struct GAAOPTION_load_pubkey GAATMP_load_pubkey; |
820 | struct GAAOPTION_load_privkey GAATMP_load_privkey; |
821 | |
822 | #line 393 "gaa.skel" |
823 | #ifdef GAA_REST_EXISTS |
824 | struct GAAREST GAAREST_tmp; |
825 | #endif |
826 | |
827 | opt_list[gaa_num] = 1; |
828 | |
829 | for(gaa_last_non_option = gaa_index; |
830 | (gaa_last_non_option != GAAargc) && (gaa_is_an_argument(GAAargv[gaa_last_non_option]) == GAA_NOT_AN_OPTION0); |
831 | gaa_last_non_option++); |
832 | |
833 | if(gaa_num == GAA_REST0) |
834 | { |
835 | gaa_index = 1; |
836 | gaa_last_non_option = GAAargc; |
837 | } |
838 | |
839 | switch(gaa_num) |
840 | { |
841 | case GAAOPTID_version1: |
842 | OK = 0; |
843 | #line 153 "certtool.gaa" |
844 | { certtool_version(); exit(0); ;}; |
845 | |
846 | return GAA_OK-1; |
847 | break; |
848 | case GAAOPTID_help2: |
849 | OK = 0; |
850 | #line 151 "certtool.gaa" |
851 | { gaa_help(); exit(0); ;}; |
852 | |
853 | return GAA_OK-1; |
854 | break; |
855 | case GAAOPTID_debug3: |
856 | OK = 0; |
857 | GAA_TESTMOREARGSif(!OK) { while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) gaa_index++; if(gaa_last_non_option == gaa_index) return 1; }; |
858 | GAA_FILL(GAATMP_debug.arg1, gaa_getint, GAATMP_debug.size1)if(!OK) { GAATMP_debug.arg1 = gaa_getint(GAAargv[gaa_index]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } GAATMP_debug.size1 = 1; } else { GAATMP_debug .size1 = 0; }; |
859 | gaa_index++; |
860 | #line 149 "certtool.gaa" |
861 | { gaaval->debug = GAATMP_debug.arg1 ;}; |
862 | |
863 | return GAA_OK-1; |
864 | break; |
865 | case GAAOPTID_pkcs_cipher4: |
866 | OK = 0; |
867 | GAA_TESTMOREARGSif(!OK) { while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) gaa_index++; if(gaa_last_non_option == gaa_index) return 1; }; |
868 | GAA_FILL(GAATMP_pkcs_cipher.arg1, gaa_getstr, GAATMP_pkcs_cipher.size1)if(!OK) { GAATMP_pkcs_cipher.arg1 = gaa_getstr(GAAargv[gaa_index ]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } GAATMP_pkcs_cipher.size1 = 1; } else { GAATMP_pkcs_cipher .size1 = 0; }; |
869 | gaa_index++; |
870 | #line 146 "certtool.gaa" |
871 | { gaaval->pkcs_cipher = GAATMP_pkcs_cipher.arg1 ;}; |
872 | |
873 | return GAA_OK-1; |
874 | break; |
875 | case GAAOPTID_template5: |
876 | OK = 0; |
877 | GAA_TESTMOREARGSif(!OK) { while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) gaa_index++; if(gaa_last_non_option == gaa_index) return 1; }; |
878 | GAA_FILL(GAATMP_template.arg1, gaa_getstr, GAATMP_template.size1)if(!OK) { GAATMP_template.arg1 = gaa_getstr(GAAargv[gaa_index ]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } GAATMP_template.size1 = 1; } else { GAATMP_template .size1 = 0; }; |
879 | gaa_index++; |
880 | #line 143 "certtool.gaa" |
881 | { gaaval->template = GAATMP_template.arg1 ;}; |
882 | |
883 | return GAA_OK-1; |
884 | break; |
885 | case GAAOPTID_infile6: |
886 | OK = 0; |
887 | GAA_TESTMOREARGSif(!OK) { while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) gaa_index++; if(gaa_last_non_option == gaa_index) return 1; }; |
888 | GAA_FILL(GAATMP_infile.arg1, gaa_getstr, GAATMP_infile.size1)if(!OK) { GAATMP_infile.arg1 = gaa_getstr(GAAargv[gaa_index]) ; gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } GAATMP_infile.size1 = 1; } else { GAATMP_infile .size1 = 0; }; |
889 | gaa_index++; |
890 | #line 140 "certtool.gaa" |
891 | { gaaval->infile = GAATMP_infile.arg1 ;}; |
892 | |
893 | return GAA_OK-1; |
894 | break; |
895 | case GAAOPTID_outfile7: |
896 | OK = 0; |
897 | GAA_TESTMOREARGSif(!OK) { while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) gaa_index++; if(gaa_last_non_option == gaa_index) return 1; }; |
898 | GAA_FILL(GAATMP_outfile.arg1, gaa_getstr, GAATMP_outfile.size1)if(!OK) { GAATMP_outfile.arg1 = gaa_getstr(GAAargv[gaa_index] ); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } GAATMP_outfile.size1 = 1; } else { GAATMP_outfile .size1 = 0; }; |
899 | gaa_index++; |
900 | #line 137 "certtool.gaa" |
901 | { gaaval->outfile = GAATMP_outfile.arg1 ;}; |
902 | |
903 | return GAA_OK-1; |
904 | break; |
905 | case GAAOPTID_disable_quick_random8: |
906 | OK = 0; |
907 | #line 134 "certtool.gaa" |
908 | { gaaval->quick_random = 0; ;}; |
909 | |
910 | return GAA_OK-1; |
911 | break; |
912 | case GAAOPTID_sec_param9: |
913 | OK = 0; |
914 | GAA_TESTMOREARGSif(!OK) { while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) gaa_index++; if(gaa_last_non_option == gaa_index) return 1; }; |
915 | GAA_FILL(GAATMP_sec_param.arg1, gaa_getstr, GAATMP_sec_param.size1)if(!OK) { GAATMP_sec_param.arg1 = gaa_getstr(GAAargv[gaa_index ]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } GAATMP_sec_param.size1 = 1; } else { GAATMP_sec_param .size1 = 0; }; |
916 | gaa_index++; |
917 | #line 131 "certtool.gaa" |
918 | { gaaval->sec_param = GAATMP_sec_param.arg1 ;}; |
919 | |
920 | return GAA_OK-1; |
921 | break; |
922 | case GAAOPTID_bits10: |
923 | OK = 0; |
924 | GAA_TESTMOREARGSif(!OK) { while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) gaa_index++; if(gaa_last_non_option == gaa_index) return 1; }; |
925 | GAA_FILL(GAATMP_bits.arg1, gaa_getint, GAATMP_bits.size1)if(!OK) { GAATMP_bits.arg1 = gaa_getint(GAAargv[gaa_index]); gaa_arg_used [gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2 ; } GAATMP_bits.size1 = 1; } else { GAATMP_bits.size1 = 0; }; |
926 | gaa_index++; |
927 | #line 128 "certtool.gaa" |
928 | { gaaval->bits = GAATMP_bits.arg1 ;}; |
929 | |
930 | return GAA_OK-1; |
931 | break; |
932 | case GAAOPTID_outraw11: |
933 | OK = 0; |
934 | #line 125 "certtool.gaa" |
935 | { gaaval->outcert_format=1 ;}; |
936 | |
937 | return GAA_OK-1; |
938 | break; |
939 | case GAAOPTID_outder12: |
940 | OK = 0; |
941 | #line 124 "certtool.gaa" |
942 | { gaaval->outcert_format=1 ;}; |
943 | |
944 | return GAA_OK-1; |
945 | break; |
946 | case GAAOPTID_inraw13: |
947 | OK = 0; |
948 | #line 121 "certtool.gaa" |
949 | { gaaval->incert_format=1 ;}; |
950 | |
951 | return GAA_OK-1; |
952 | break; |
953 | case GAAOPTID_inder14: |
954 | OK = 0; |
955 | #line 120 "certtool.gaa" |
956 | { gaaval->incert_format=1 ;}; |
957 | |
958 | return GAA_OK-1; |
959 | break; |
960 | case GAAOPTID_export_ciphers15: |
961 | OK = 0; |
962 | #line 117 "certtool.gaa" |
963 | { gaaval->export=1 ;}; |
964 | |
965 | return GAA_OK-1; |
966 | break; |
967 | case GAAOPTID_hash16: |
968 | OK = 0; |
969 | GAA_TESTMOREARGSif(!OK) { while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) gaa_index++; if(gaa_last_non_option == gaa_index) return 1; }; |
970 | GAA_FILL(GAATMP_hash.arg1, gaa_getstr, GAATMP_hash.size1)if(!OK) { GAATMP_hash.arg1 = gaa_getstr(GAAargv[gaa_index]); gaa_arg_used [gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2 ; } GAATMP_hash.size1 = 1; } else { GAATMP_hash.size1 = 0; }; |
971 | gaa_index++; |
972 | #line 114 "certtool.gaa" |
973 | { gaaval->hash = GAATMP_hash.arg1 ;}; |
974 | |
975 | return GAA_OK-1; |
976 | break; |
977 | case GAAOPTID_ecc17: |
978 | OK = 0; |
979 | #line 111 "certtool.gaa" |
980 | { gaaval->ecc=1 ;}; |
981 | |
982 | return GAA_OK-1; |
983 | break; |
984 | case GAAOPTID_rsa18: |
985 | OK = 0; |
986 | #line 108 "certtool.gaa" |
987 | { ;}; |
988 | |
989 | return GAA_OK-1; |
990 | break; |
991 | case GAAOPTID_dsa19: |
992 | OK = 0; |
993 | #line 106 "certtool.gaa" |
994 | { gaaval->dsa=1 ;}; |
995 | |
996 | return GAA_OK-1; |
997 | break; |
998 | case GAAOPTID_pkcs820: |
999 | OK = 0; |
1000 | #line 103 "certtool.gaa" |
1001 | { gaaval->pkcs8=1 ;}; |
1002 | |
1003 | return GAA_OK-1; |
1004 | break; |
1005 | case GAAOPTID_to_p821: |
1006 | OK = 0; |
1007 | #line 100 "certtool.gaa" |
1008 | { gaaval->action = ACTION_GENERATE_PKCS8; ;}; |
1009 | |
1010 | return GAA_OK-1; |
1011 | break; |
1012 | case GAAOPTID_to_p1222: |
1013 | OK = 0; |
1014 | #line 98 "certtool.gaa" |
1015 | { gaaval->action = ACTION_TO_PKCS12; ;}; |
1016 | |
1017 | return GAA_OK-1; |
1018 | break; |
1019 | case GAAOPTID_v123: |
1020 | OK = 0; |
1021 | #line 96 "certtool.gaa" |
1022 | { gaaval->v1_cert = 1; ;}; |
1023 | |
1024 | return GAA_OK-1; |
1025 | break; |
1026 | case GAAOPTID_fix_key24: |
1027 | OK = 0; |
1028 | #line 93 "certtool.gaa" |
1029 | { gaaval->privkey_op=1; gaaval->fix_key = 1; ;}; |
1030 | |
1031 | return GAA_OK-1; |
1032 | break; |
1033 | case GAAOPTID_pubkey_info25: |
1034 | OK = 0; |
1035 | #line 90 "certtool.gaa" |
1036 | { gaaval->action = ACTION_PUBKEY_INFO; ;}; |
1037 | |
1038 | return GAA_OK-1; |
1039 | break; |
1040 | case GAAOPTID_pgp_key_info26: |
1041 | OK = 0; |
1042 | #line 88 "certtool.gaa" |
1043 | { gaaval->privkey_op=1; gaaval->action = ACTION_PGP_PRIVKEY_INFO; ;}; |
1044 | |
1045 | return GAA_OK-1; |
1046 | break; |
1047 | case GAAOPTID_key_info27: |
1048 | OK = 0; |
1049 | #line 86 "certtool.gaa" |
1050 | { gaaval->privkey_op=1; gaaval->action = ACTION_PRIVKEY_INFO; ;}; |
1051 | |
1052 | return GAA_OK-1; |
1053 | break; |
1054 | case GAAOPTID_smime_to_p728: |
1055 | OK = 0; |
1056 | #line 82 "certtool.gaa" |
1057 | { gaaval->action = ACTION_SMIME_TO_P7; ;}; |
1058 | |
1059 | return GAA_OK-1; |
1060 | break; |
1061 | case GAAOPTID_p7_info29: |
1062 | OK = 0; |
1063 | #line 80 "certtool.gaa" |
1064 | { gaaval->action = ACTION_P7_INFO; ;}; |
1065 | |
1066 | return GAA_OK-1; |
1067 | break; |
1068 | case GAAOPTID_p12_info30: |
1069 | OK = 0; |
1070 | #line 78 "certtool.gaa" |
1071 | { gaaval->action = ACTION_PKCS12_INFO; ;}; |
1072 | |
1073 | return GAA_OK-1; |
1074 | break; |
1075 | case GAAOPTID_no_crq_extensions31: |
1076 | OK = 0; |
1077 | #line 76 "certtool.gaa" |
1078 | { gaaval->crq_extensions = 0; ;}; |
1079 | |
1080 | return GAA_OK-1; |
1081 | break; |
1082 | case GAAOPTID_crq_info32: |
1083 | OK = 0; |
1084 | #line 73 "certtool.gaa" |
1085 | { gaaval->action = ACTION_REQUEST; ;}; |
1086 | |
1087 | return GAA_OK-1; |
1088 | break; |
1089 | case GAAOPTID_crl_info33: |
1090 | OK = 0; |
1091 | #line 71 "certtool.gaa" |
1092 | { gaaval->action = ACTION_CRL_INFO; ;}; |
1093 | |
1094 | return GAA_OK-1; |
1095 | break; |
1096 | case GAAOPTID_pgp_ring_info34: |
1097 | OK = 0; |
1098 | #line 69 "certtool.gaa" |
1099 | { gaaval->action = ACTION_RING_INFO; ;}; |
1100 | |
1101 | return GAA_OK-1; |
1102 | break; |
1103 | case GAAOPTID_pgp_certificate_info35: |
1104 | OK = 0; |
1105 | #line 67 "certtool.gaa" |
1106 | { gaaval->action = ACTION_PGP_INFO; ;}; |
1107 | |
1108 | return GAA_OK-1; |
1109 | break; |
1110 | case GAAOPTID_certificate_pubkey36: |
1111 | OK = 0; |
1112 | #line 65 "certtool.gaa" |
1113 | { gaaval->action = ACTION_CERT_PUBKEY; ;}; |
1114 | |
1115 | return GAA_OK-1; |
1116 | break; |
1117 | case GAAOPTID_certificate_info37: |
1118 | OK = 0; |
1119 | #line 63 "certtool.gaa" |
1120 | { gaaval->action = ACTION_CERT_INFO; ;}; |
1121 | |
1122 | return GAA_OK-1; |
1123 | break; |
1124 | case GAAOPTID_password38: |
1125 | OK = 0; |
1126 | GAA_TESTMOREARGSif(!OK) { while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) gaa_index++; if(gaa_last_non_option == gaa_index) return 1; }; |
1127 | GAA_FILL(GAATMP_password.arg1, gaa_getstr, GAATMP_password.size1)if(!OK) { GAATMP_password.arg1 = gaa_getstr(GAAargv[gaa_index ]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } GAATMP_password.size1 = 1; } else { GAATMP_password .size1 = 0; }; |
1128 | gaa_index++; |
1129 | #line 61 "certtool.gaa" |
1130 | { gaaval->pass = GAATMP_password.arg1 ;}; |
1131 | |
1132 | return GAA_OK-1; |
1133 | break; |
1134 | case GAAOPTID_load_ca_certificate39: |
1135 | OK = 0; |
1136 | GAA_TESTMOREARGSif(!OK) { while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) gaa_index++; if(gaa_last_non_option == gaa_index) return 1; }; |
1137 | GAA_FILL(GAATMP_load_ca_certificate.arg1, gaa_getstr, GAATMP_load_ca_certificate.size1)if(!OK) { GAATMP_load_ca_certificate.arg1 = gaa_getstr(GAAargv [gaa_index]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } GAATMP_load_ca_certificate.size1 = 1; } else { GAATMP_load_ca_certificate.size1 = 0; }; |
1138 | gaa_index++; |
1139 | #line 58 "certtool.gaa" |
1140 | { gaaval->ca = GAATMP_load_ca_certificate.arg1 ;}; |
1141 | |
1142 | return GAA_OK-1; |
1143 | break; |
1144 | case GAAOPTID_load_ca_privkey40: |
1145 | OK = 0; |
1146 | GAA_TESTMOREARGSif(!OK) { while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) gaa_index++; if(gaa_last_non_option == gaa_index) return 1; }; |
1147 | GAA_FILL(GAATMP_load_ca_privkey.arg1, gaa_getstr, GAATMP_load_ca_privkey.size1)if(!OK) { GAATMP_load_ca_privkey.arg1 = gaa_getstr(GAAargv[gaa_index ]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } GAATMP_load_ca_privkey.size1 = 1; } else { GAATMP_load_ca_privkey .size1 = 0; }; |
1148 | gaa_index++; |
1149 | #line 55 "certtool.gaa" |
1150 | { gaaval->ca_privkey = GAATMP_load_ca_privkey.arg1 ;}; |
1151 | |
1152 | return GAA_OK-1; |
1153 | break; |
1154 | case GAAOPTID_load_certificate41: |
1155 | OK = 0; |
1156 | GAA_TESTMOREARGSif(!OK) { while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) gaa_index++; if(gaa_last_non_option == gaa_index) return 1; }; |
1157 | GAA_FILL(GAATMP_load_certificate.arg1, gaa_getstr, GAATMP_load_certificate.size1)if(!OK) { GAATMP_load_certificate.arg1 = gaa_getstr(GAAargv[gaa_index ]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } GAATMP_load_certificate.size1 = 1; } else { GAATMP_load_certificate.size1 = 0; }; |
1158 | gaa_index++; |
Value stored to 'gaa_index' is never read | |
1159 | #line 52 "certtool.gaa" |
1160 | { gaaval->cert = GAATMP_load_certificate.arg1 ;}; |
1161 | |
1162 | return GAA_OK-1; |
1163 | break; |
1164 | case GAAOPTID_load_request42: |
1165 | OK = 0; |
1166 | GAA_TESTMOREARGSif(!OK) { while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) gaa_index++; if(gaa_last_non_option == gaa_index) return 1; }; |
1167 | GAA_FILL(GAATMP_load_request.arg1, gaa_getstr, GAATMP_load_request.size1)if(!OK) { GAATMP_load_request.arg1 = gaa_getstr(GAAargv[gaa_index ]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } GAATMP_load_request.size1 = 1; } else { GAATMP_load_request .size1 = 0; }; |
1168 | gaa_index++; |
1169 | #line 49 "certtool.gaa" |
1170 | { gaaval->request = GAATMP_load_request.arg1 ;}; |
1171 | |
1172 | return GAA_OK-1; |
1173 | break; |
1174 | case GAAOPTID_load_pubkey43: |
1175 | OK = 0; |
1176 | GAA_TESTMOREARGSif(!OK) { while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) gaa_index++; if(gaa_last_non_option == gaa_index) return 1; }; |
1177 | GAA_FILL(GAATMP_load_pubkey.arg1, gaa_getstr, GAATMP_load_pubkey.size1)if(!OK) { GAATMP_load_pubkey.arg1 = gaa_getstr(GAAargv[gaa_index ]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } GAATMP_load_pubkey.size1 = 1; } else { GAATMP_load_pubkey .size1 = 0; }; |
1178 | gaa_index++; |
1179 | #line 46 "certtool.gaa" |
1180 | { gaaval->pubkey = GAATMP_load_pubkey.arg1 ;}; |
1181 | |
1182 | return GAA_OK-1; |
1183 | break; |
1184 | case GAAOPTID_load_privkey44: |
1185 | OK = 0; |
1186 | GAA_TESTMOREARGSif(!OK) { while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) gaa_index++; if(gaa_last_non_option == gaa_index) return 1; }; |
1187 | GAA_FILL(GAATMP_load_privkey.arg1, gaa_getstr, GAATMP_load_privkey.size1)if(!OK) { GAATMP_load_privkey.arg1 = gaa_getstr(GAAargv[gaa_index ]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } GAATMP_load_privkey.size1 = 1; } else { GAATMP_load_privkey .size1 = 0; }; |
1188 | gaa_index++; |
1189 | #line 43 "certtool.gaa" |
1190 | { gaaval->privkey = GAATMP_load_privkey.arg1 ;}; |
1191 | |
1192 | return GAA_OK-1; |
1193 | break; |
1194 | case GAAOPTID_dh_info45: |
1195 | OK = 0; |
1196 | #line 40 "certtool.gaa" |
1197 | { gaaval->action = ACTION_DH_INFO; ;}; |
1198 | |
1199 | return GAA_OK-1; |
1200 | break; |
1201 | case GAAOPTID_get_dh_params46: |
1202 | OK = 0; |
1203 | #line 39 "certtool.gaa" |
1204 | { gaaval->action=ACTION_GET_DH; ;}; |
1205 | |
1206 | return GAA_OK-1; |
1207 | break; |
1208 | case GAAOPTID_generate_dh_params47: |
1209 | OK = 0; |
1210 | #line 38 "certtool.gaa" |
1211 | { gaaval->action=ACTION_GENERATE_DH; ;}; |
1212 | |
1213 | return GAA_OK-1; |
1214 | break; |
1215 | case GAAOPTID_verify_crl48: |
1216 | OK = 0; |
1217 | #line 36 "certtool.gaa" |
1218 | { gaaval->action=ACTION_VERIFY_CRL; ;}; |
1219 | |
1220 | return GAA_OK-1; |
1221 | break; |
1222 | case GAAOPTID_verify49: |
1223 | OK = 0; |
1224 | #line 34 "certtool.gaa" |
1225 | { gaaval->action=ACTION_VERIFY; ;}; |
1226 | |
1227 | return GAA_OK-1; |
1228 | break; |
1229 | case GAAOPTID_verify_chain50: |
1230 | OK = 0; |
1231 | #line 32 "certtool.gaa" |
1232 | { gaaval->action=ACTION_VERIFY_CHAIN; ;}; |
1233 | |
1234 | return GAA_OK-1; |
1235 | break; |
1236 | case GAAOPTID_generate_request51: |
1237 | OK = 0; |
1238 | #line 30 "certtool.gaa" |
1239 | { gaaval->privkey_op=1; gaaval->action=ACTION_GENERATE_REQUEST; ;}; |
1240 | |
1241 | return GAA_OK-1; |
1242 | break; |
1243 | case GAAOPTID_generate_privkey52: |
1244 | OK = 0; |
1245 | #line 28 "certtool.gaa" |
1246 | { gaaval->privkey_op=1; gaaval->action=ACTION_GENERATE_PRIVKEY; ;}; |
1247 | |
1248 | return GAA_OK-1; |
1249 | break; |
1250 | case GAAOPTID_update_certificate53: |
1251 | OK = 0; |
1252 | #line 26 "certtool.gaa" |
1253 | { gaaval->action=ACTION_UPDATE_CERTIFICATE; ;}; |
1254 | |
1255 | return GAA_OK-1; |
1256 | break; |
1257 | case GAAOPTID_generate_crl54: |
1258 | OK = 0; |
1259 | #line 24 "certtool.gaa" |
1260 | { gaaval->action=ACTION_GENERATE_CRL; ;}; |
1261 | |
1262 | return GAA_OK-1; |
1263 | break; |
1264 | case GAAOPTID_generate_proxy55: |
1265 | OK = 0; |
1266 | #line 22 "certtool.gaa" |
1267 | { gaaval->action=ACTION_GENERATE_PROXY; ;}; |
1268 | |
1269 | return GAA_OK-1; |
1270 | break; |
1271 | case GAAOPTID_generate_certificate56: |
1272 | OK = 0; |
1273 | #line 20 "certtool.gaa" |
1274 | { gaaval->action=ACTION_GENERATE_CERTIFICATE; ;}; |
1275 | |
1276 | return GAA_OK-1; |
1277 | break; |
1278 | case GAAOPTID_generate_self_signed57: |
1279 | OK = 0; |
1280 | #line 18 "certtool.gaa" |
1281 | { gaaval->action=ACTION_SELF_SIGNED; ;}; |
1282 | |
1283 | return GAA_OK-1; |
1284 | break; |
1285 | |
1286 | #line 413 "gaa.skel" |
1287 | default: break; |
1288 | } |
1289 | return GAA_ERROR_UNKNOWN3; |
1290 | } |
1291 | |
1292 | int gaa(int argc, char **argv, gaainfo *gaaval) |
1293 | { |
1294 | int tmp1, tmp2; |
1295 | int i, j; |
1296 | char *opt_list; |
1297 | |
1298 | GAAargv = argv; |
1299 | GAAargc = argc; |
1300 | |
1301 | opt_list = (char*) gaa_malloc(GAA_NB_OPTION57 + 1); |
1302 | |
1303 | for(i = 0; i < GAA_NB_OPTION57 + 1; i++) |
1304 | opt_list[i] = 0; |
1305 | /* initialization */ |
1306 | if(inited == 0) |
1307 | { |
1308 | |
1309 | #line 155 "certtool.gaa" |
1310 | { gaaval->bits = 0; gaaval->pkcs8 = 0; gaaval->privkey = NULL((void*)0); gaaval->ca=NULL((void*)0); gaaval->ca_privkey = NULL((void*)0); |
1311 | gaaval->debug=1; gaaval->request = NULL((void*)0); gaaval->infile = NULL((void*)0); gaaval->outfile = NULL((void*)0); gaaval->cert = NULL((void*)0); |
1312 | gaaval->incert_format = 0; gaaval->outcert_format = 0; gaaval->action=-1; gaaval->pass = NULL((void*)0); gaaval->v1_cert = 0; |
1313 | gaaval->export = 0; gaaval->template = NULL((void*)0); gaaval->hash=NULL((void*)0); gaaval->fix_key = 0; gaaval->quick_random=1; |
1314 | gaaval->privkey_op = 0; gaaval->pkcs_cipher = "aes-128"; gaaval->crq_extensions=1; gaaval->ecc=0; |
1315 | gaaval->sec_param = NULL((void*)0); ;}; |
1316 | |
1317 | } |
1318 | inited = 1; |
1319 | #line 438 "gaa.skel" |
1320 | gaa_arg_used = NULL((void*)0); |
1321 | |
1322 | if (argc > 0) { |
1323 | gaa_arg_used = gaa_malloc(argc * sizeof(char)); |
1324 | } |
1325 | |
1326 | for(i = 1; i < argc; i++) |
1327 | gaa_arg_used[i] = 0; |
1328 | for(i = 1; i < argc; i++) |
1329 | { |
1330 | if(gaa_arg_used[i] == 0) |
1331 | { |
1332 | j = 0; |
1333 | tmp1 = gaa_is_an_argument(GAAargv[i]); |
1334 | switch(tmp1) |
1335 | { |
1336 | case GAA_WORD_OPTION1: |
1337 | j++; |
1338 | case GAA_LETTER_OPTION2: |
1339 | j++; |
1340 | tmp2 = gaa_get_option_num(argv[i]+j, tmp1); |
1341 | if(tmp2 == GAA_ERROR_NOMATCH0) |
1342 | { |
1343 | printf("Invalid option '%s'\n", argv[i]+j); |
1344 | return 0; |
1345 | } |
1346 | switch(gaa_try(tmp2, i+1, gaaval, opt_list)) |
1347 | { |
1348 | case GAA_ERROR_NOTENOUGH_ARGS1: |
1349 | printf("'%s': not enough arguments\n",gaa_current_option); |
1350 | return 0; |
1351 | case GAA_ERROR_INVALID_ARG2: |
1352 | printf("Invalid arguments\n"); |
1353 | return 0; |
1354 | case GAA_OK-1: |
1355 | break; |
1356 | default: |
1357 | printf("Unknown error\n"); |
1358 | } |
1359 | gaa_arg_used[i] = 1; |
1360 | break; |
1361 | case GAA_MULTIPLE_OPTION3: |
1362 | for(j = 1; j < strlen(argv[i]); j++) |
1363 | { |
1364 | tmp2 = gaa_get_option_num(argv[i]+j, tmp1); |
1365 | if(tmp2 == GAA_ERROR_NOMATCH0) |
1366 | { |
1367 | printf("Invalid option '%c'\n", *(argv[i]+j)); |
1368 | return 0; |
1369 | } |
1370 | switch(gaa_try(tmp2, i+1, gaaval, opt_list)) |
1371 | { |
1372 | case GAA_ERROR_NOTENOUGH_ARGS1: |
1373 | printf("'%s': not enough arguments\n",gaa_current_option); |
1374 | return 0; |
1375 | case GAA_ERROR_INVALID_ARG2: |
1376 | printf("Invalid arguments\n"); |
1377 | return 0; |
1378 | case GAA_OK-1: |
1379 | break; |
1380 | default: |
1381 | printf("Unknown error\n"); |
1382 | } |
1383 | } |
1384 | gaa_arg_used[i] = 1; |
1385 | break; |
1386 | default: break; |
1387 | } |
1388 | } |
1389 | } |
1390 | if(gaa_processing_file == 0) |
1391 | { |
1392 | |
1393 | #line 507 "gaa.skel" |
1394 | #ifdef GAA_REST_EXISTS |
1395 | switch(gaa_try(GAA_REST0, 1, gaaval, opt_list)) |
1396 | { |
1397 | case GAA_ERROR_NOTENOUGH_ARGS1: |
1398 | printf("Rest: not enough arguments\n"); |
1399 | return 0; |
1400 | case GAA_ERROR_INVALID_ARG2: |
1401 | printf("Invalid arguments\n"); |
1402 | return 0; |
1403 | case GAA_OK-1: |
1404 | break; |
1405 | default: |
1406 | printf("Unknown error\n"); |
1407 | } |
1408 | #endif |
1409 | } |
1410 | for(i = 1; i < argc; i++) |
1411 | { |
1412 | if(gaa_arg_used[i] == 0) |
1413 | { |
1414 | printf("Too many arguments\n"); |
1415 | return 0; |
1416 | } |
1417 | } |
1418 | free(gaa_arg_used); |
1419 | free(opt_list); |
1420 | return -1; |
1421 | } |
1422 | |
1423 | struct gaastrnode |
1424 | { |
1425 | char *str; |
1426 | struct gaastrnode *next; |
1427 | }; |
1428 | |
1429 | typedef struct gaastrnode gaa_str_node; |
1430 | |
1431 | static int gaa_internal_get_next_str(FILE *file, gaa_str_node *tmp_str, int argc) |
1432 | { |
1433 | int pos_ini; |
1434 | int a; |
1435 | int i = 0, len = 0, newline = 0; |
1436 | |
1437 | if(argc == 1) { |
1438 | newline = 1; |
1439 | len = 2; |
1440 | } |
1441 | |
1442 | a = fgetc( file); |
1443 | if (a == EOF(-1)) return 0; |
1444 | |
1445 | while(a == ' ' || a == 9 || a == '\n') |
1446 | { |
1447 | if(a == '\n') |
1448 | { |
1449 | newline=1; |
1450 | len = 2; |
1451 | } |
1452 | a = fgetc( file); |
1453 | if (a == EOF(-1)) return 0; |
1454 | } |
1455 | |
1456 | pos_ini = ftell(file) - 1; |
1457 | |
1458 | while(a != ' ' && a != 9 && a != '\n') |
1459 | { |
1460 | |
1461 | len++; |
1462 | a = fgetc( file); |
1463 | if(a==EOF(-1)) return 0; |
1464 | } |
1465 | |
1466 | len += 1; |
1467 | tmp_str->str = gaa_malloc((len) * sizeof(char)); |
1468 | |
1469 | if(newline == 1) |
1470 | { |
1471 | tmp_str->str[0] = '-'; |
1472 | tmp_str->str[1] = '-'; |
1473 | i = 2; |
1474 | } |
1475 | else |
1476 | { |
1477 | i = 0; |
1478 | } |
1479 | |
1480 | fseek(file,pos_ini, SEEK_SET0); |
1481 | do |
1482 | { |
1483 | a = fgetc( file); |
1484 | |
1485 | if (a == EOF(-1)) { |
1486 | i+=2; |
1487 | break; |
1488 | } |
1489 | tmp_str->str[i] = a; |
1490 | i++; |
1491 | } |
1492 | while(a != ' ' && a != 9 && a != '\n' && i < len); |
1493 | |
1494 | tmp_str->str[i - 1] = 0; |
1495 | |
1496 | fseek(file,- 1, SEEK_CUR1); |
1497 | /* printf("%d\n", ftell(file)); */ |
1498 | |
1499 | return -1; |
1500 | } |
1501 | |
1502 | int gaa_file(const char *name, gaainfo *gaaval) |
1503 | { |
1504 | gaa_str_node *first_str, **tmp_str, *tmp_str2; |
1505 | int rval, i; |
1506 | char **argv; |
1507 | int argc = 0; |
1508 | FILE *file; |
1509 | |
1510 | gaa_processing_file = 1; |
1511 | |
1512 | if((file = fopen(name, "r")) == NULL((void*)0)) |
1513 | { |
1514 | printf("Couldn't open '%s' configuration file for reading\n", name); |
1515 | return 1; |
1516 | } |
1517 | |
1518 | tmp_str = &first_str; |
1519 | do |
1520 | { |
1521 | argc++; |
1522 | *tmp_str = gaa_malloc(sizeof(gaa_str_node)); |
1523 | |
1524 | (*tmp_str)->str = NULL((void*)0); |
1525 | (*tmp_str)->next = NULL((void*)0); |
1526 | |
1527 | rval = gaa_internal_get_next_str(file, *tmp_str, argc); |
1528 | tmp_str = &((*tmp_str)->next); |
1529 | } |
1530 | while(rval == -1); |
1531 | |
1532 | if(rval == 1) |
1533 | return 0; |
1534 | |
1535 | argv = gaa_malloc((1 + argc) * sizeof(char*)); |
1536 | |
1537 | tmp_str2 = first_str; |
1538 | argv[0] = "cfg"; |
1539 | for(i = 1; i < argc; i++) |
1540 | { |
1541 | argv[i] = tmp_str2->str; |
1542 | tmp_str2 = tmp_str2->next; |
1543 | } |
1544 | |
1545 | rval = gaa(argc, argv, gaaval); |
1546 | gaa_processing_file = 0; |
1547 | return rval; |
1548 | } |