1 /* File generated by GAA 1.6.6
12 void cli_version(void);
19 #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(WINDOWS)
24 static void* gaa_malloc( size_t size
) {
28 fprintf(stderr
, "gaa: could not allocate memory");
34 static void __gaa_helpsingle(char short_name
, char *name
,
35 char *arg_desc
, char *opt_help
)
37 int col1
, col3
, col4
, tabsize
= 3, curr
;
40 col1
= 5; /* Default values */
45 for(i
= 0; i
< col1
; i
++)
54 printf("-%c, ", short_name
);
59 printf("-%c ", short_name
);
65 printf("--%s ", name
);
66 curr
+= 3 + strlen(name
);
68 if(arg_desc
&& *arg_desc
)
70 printf("%s ", arg_desc
);
71 curr
+= 1 + strlen(arg_desc
);
78 if(opt_help
) /* let's print the option's help body */
80 const char *str
= opt_help
;
100 while((curr
- col3
) % tabsize
!= 0 && curr
< col4
);
107 for(i
= 1; str
[i
] && str
[i
] != ' ' && str
[i
] != '\n'
108 && str
[i
] != '\t'; i
++);
109 if(curr
+ i
- 1 >= col4
)
129 printf("GNU TLS test client\nUsage: gnutls-cli [options] hostname\n\n\n");
130 __gaa_helpsingle('d', "debug", "integer ", "Enable debugging");
131 __gaa_helpsingle('r', "resume", "", "Connect, establish a session. Connect again and resume this session.");
132 __gaa_helpsingle('e', "rehandshake", "", "Connect, establish a session and rehandshake immediately.");
133 __gaa_helpsingle(0, "noticket", "", "Doen't accept session tickets.");
134 __gaa_helpsingle('s', "starttls", "", "Connect, establish a plain session and start TLS when EOF or a SIGALRM is received.");
135 __gaa_helpsingle(0, "crlf", "", "Send CR LF instead of LF.");
136 __gaa_helpsingle(0, "x509fmtder", "", "Use DER format for certificates to read from.");
137 __gaa_helpsingle('f', "fingerprint", "", "Send the openpgp fingerprint, instead of the key.");
138 __gaa_helpsingle(0, "disable-extensions", "", "Disable all the TLS extensions.");
139 __gaa_helpsingle(0, "print-cert", "", "Print the certificate in PEM format.");
140 __gaa_helpsingle(0, "recordsize", "integer ", "The maximum record size to advertize.");
141 __gaa_helpsingle('V', "verbose", "", "More verbose output.");
142 __gaa_helpsingle(0, "ciphers", "cipher1 cipher2... ", "Ciphers to enable.");
143 __gaa_helpsingle(0, "protocols", "protocol1 protocol2... ", "Protocols to enable.");
144 __gaa_helpsingle(0, "comp", "comp1 comp2... ", "Compression methods to enable.");
145 __gaa_helpsingle(0, "macs", "mac1 mac2... ", "MACs to enable.");
146 __gaa_helpsingle(0, "kx", "kx1 kx2... ", "Key exchange methods to enable.");
147 __gaa_helpsingle(0, "ctypes", "certType1 certType2... ", "Certificate types to enable.");
148 __gaa_helpsingle(0, "priority", "PRIORITY STRING ", "Priorities string.");
149 __gaa_helpsingle(0, "x509cafile", "FILE ", "Certificate file to use.");
150 __gaa_helpsingle(0, "x509crlfile", "FILE ", "CRL file to use.");
151 __gaa_helpsingle(0, "pgpkeyfile", "FILE ", "PGP Key file to use.");
152 __gaa_helpsingle(0, "pgpkeyring", "FILE ", "PGP Key ring file to use.");
153 __gaa_helpsingle(0, "pgpcertfile", "FILE ", "PGP Public Key (certificate) file to use.");
154 __gaa_helpsingle(0, "pgpsubkey", "HEX|auto ", "PGP subkey to use.");
155 __gaa_helpsingle(0, "x509keyfile", "FILE ", "X.509 key file to use.");
156 __gaa_helpsingle(0, "x509certfile", "FILE ", "X.509 Certificate file to use.");
157 __gaa_helpsingle(0, "srpusername", "NAME ", "SRP username to use.");
158 __gaa_helpsingle(0, "srppasswd", "PASSWD ", "SRP password to use.");
159 __gaa_helpsingle(0, "pskusername", "NAME ", "PSK username to use.");
160 __gaa_helpsingle(0, "pskkey", "KEY ", "PSK key (in hex) to use.");
161 __gaa_helpsingle(0, "opaque-prf-input", "DATA ", "Use Opaque PRF Input DATA.");
162 __gaa_helpsingle('p', "port", "PORT ", "The port to connect to.");
163 __gaa_helpsingle(0, "insecure", "", "Don't abort program if server certificate can't be validated.");
164 __gaa_helpsingle('l', "list", "", "Print a list of the supported algorithms and modes.");
165 __gaa_helpsingle('h', "help", "", "prints this help");
166 __gaa_helpsingle('v', "version", "", "prints the program's version number");
174 #ifndef GAA_HEADER_POKY
175 #define GAA_HEADER_POKY
177 typedef struct _gaainfo gaainfo
;
188 char *opaque_prf_input
;
246 int disable_extensions
;
272 int gaa(int argc
, char *argv
[], gaainfo
*gaaval
);
276 int gaa_file(const char *name
, gaainfo
*gaaval
);
289 #define GAAERROR(x) \
295 static char *gaa_current_option
;
296 static int gaa_error
= 0;
298 /* Generated by gaa */
306 #define GAA_ERROR_NOMATCH 0
307 #define GAA_ERROR_NOTENOUGH_ARGS 1
308 #define GAA_ERROR_INVALID_ARG 2
309 #define GAA_ERROR_UNKNOWN 3
311 #define GAA_NOT_AN_OPTION 0
312 #define GAA_WORD_OPTION 1
313 #define GAA_LETTER_OPTION 2
314 #define GAA_MULTIPLE_OPTION 3
317 #define GAA_NB_OPTION 37
318 #define GAAOPTID_version 1
319 #define GAAOPTID_help 2
320 #define GAAOPTID_list 3
321 #define GAAOPTID_insecure 4
322 #define GAAOPTID_port 5
323 #define GAAOPTID_opaque_prf_input 6
324 #define GAAOPTID_pskkey 7
325 #define GAAOPTID_pskusername 8
326 #define GAAOPTID_srppasswd 9
327 #define GAAOPTID_srpusername 10
328 #define GAAOPTID_x509certfile 11
329 #define GAAOPTID_x509keyfile 12
330 #define GAAOPTID_pgpsubkey 13
331 #define GAAOPTID_pgpcertfile 14
332 #define GAAOPTID_pgpkeyring 15
333 #define GAAOPTID_pgpkeyfile 16
334 #define GAAOPTID_x509crlfile 17
335 #define GAAOPTID_x509cafile 18
336 #define GAAOPTID_priority 19
337 #define GAAOPTID_ctypes 20
338 #define GAAOPTID_kx 21
339 #define GAAOPTID_macs 22
340 #define GAAOPTID_comp 23
341 #define GAAOPTID_protocols 24
342 #define GAAOPTID_ciphers 25
343 #define GAAOPTID_verbose 26
344 #define GAAOPTID_recordsize 27
345 #define GAAOPTID_print_cert 28
346 #define GAAOPTID_disable_extensions 29
347 #define GAAOPTID_fingerprint 30
348 #define GAAOPTID_x509fmtder 31
349 #define GAAOPTID_crlf 32
350 #define GAAOPTID_starttls 33
351 #define GAAOPTID_noticket 34
352 #define GAAOPTID_rehandshake 35
353 #define GAAOPTID_resume 36
354 #define GAAOPTID_debug 37
358 #define GAA_CHECK1STR(a,b) \
361 gaa_current_option = a; \
365 #define GAA_CHECKSTR(a,b) \
366 if(strcmp(a,str) == 0) \
368 gaa_current_option = a; \
372 #define GAA_TESTMOREARGS \
375 while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) \
377 if(gaa_last_non_option == gaa_index) \
378 return GAA_ERROR_NOTENOUGH_ARGS; \
381 #define GAA_TESTMOREOPTIONALARGS \
384 while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) \
386 if(gaa_last_non_option == gaa_index) \
390 #define GAA_FILL_2ARGS(target, func) \
391 target = func(GAAargv[gaa_index]); \
392 gaa_arg_used[gaa_index] = 1; \
396 return GAA_ERROR_INVALID_ARG; \
401 #define GAA_FILL(target, func, num) \
404 target = func(GAAargv[gaa_index]); \
405 gaa_arg_used[gaa_index] = 1; \
409 return GAA_ERROR_INVALID_ARG; \
418 #define GAA_LIST_FILL(target, func, type ,num) \
423 if ( gaa_last_non_option - gaa_index > 0) \
424 target = gaa_malloc((gaa_last_non_option - gaa_index) * sizeof(type));\
425 for(; gaa_index < gaa_last_non_option; gaa_index++) \
427 if(gaa_arg_used[gaa_index] == 0) \
429 GAA_FILL_2ARGS(target[num], func); \
434 return GAA_ERROR_NOTENOUGH_ARGS; \
437 #define GAA_OPTIONALLIST_FILL(target, func, type ,num) \
442 if ( gaa_last_non_option - gaa_index > 0) \
443 target = gaa_malloc((gaa_last_non_option - gaa_index) * sizeof(type));\
444 for(; gaa_index < gaa_last_non_option; gaa_index++) \
446 if(gaa_arg_used[gaa_index] == 0) \
448 GAA_FILL_2ARGS(target[num], func); \
454 #define GAA_OBLIGAT(str) \
456 for(i = 0; i < strlen(str); i++) \
458 j = gaa_get_option_num(str + i, GAA_LETTER_OPTION); \
459 if(j == GAA_ERROR_NOMATCH) \
461 printf("Error: invalid 'obligat' set\n"); \
464 if(opt_list[j] == 1) \
469 if(strlen(str) == 1) \
470 printf("You must give the -%s option\n", str); \
472 printf("You must give at least one option of '%s'\n", str); \
476 #define GAA_INCOMP(str) \
478 for(i = 0; i < strlen(str); i++) \
480 j = gaa_get_option_num(str + i, GAA_LETTER_OPTION); \
481 if(j == GAA_ERROR_NOMATCH) \
483 printf("Error: invalid 'obligat' set\n"); \
486 if(opt_list[j] == 1) \
491 printf("The options '%s' are incompatible\n", str); \
496 static char **GAAargv
;
498 static char *gaa_arg_used
;
499 static int gaa_processing_file
= 0;
500 static int inited
= 0;
502 static int gaa_getint(char *arg
)
506 if(sscanf(arg
, "%d%c", &tmp
, &a
) < 1)
508 printf("Option %s: '%s' isn't an integer\n", gaa_current_option
, arg
);
514 static char gaa_getchar(char *arg
)
518 printf("Option %s: '%s' isn't an character\n", gaa_current_option
, arg
);
524 static char* gaa_getstr(char *arg
)
528 static float gaa_getfloat(char *arg
)
532 if(sscanf(arg
, "%f%c", &tmp
, &a
) < 1)
534 printf("Option %s: '%s' isn't a float number\n", gaa_current_option
, arg
);
539 /* option structures */
541 struct GAAOPTION_port
547 struct GAAOPTION_opaque_prf_input
553 struct GAAOPTION_pskkey
559 struct GAAOPTION_pskusername
565 struct GAAOPTION_srppasswd
571 struct GAAOPTION_srpusername
577 struct GAAOPTION_x509certfile
583 struct GAAOPTION_x509keyfile
589 struct GAAOPTION_pgpsubkey
595 struct GAAOPTION_pgpcertfile
601 struct GAAOPTION_pgpkeyring
607 struct GAAOPTION_pgpkeyfile
613 struct GAAOPTION_x509crlfile
619 struct GAAOPTION_x509cafile
625 struct GAAOPTION_priority
631 struct GAAOPTION_ctypes
643 struct GAAOPTION_macs
649 struct GAAOPTION_comp
655 struct GAAOPTION_protocols
661 struct GAAOPTION_ciphers
667 struct GAAOPTION_recordsize
673 struct GAAOPTION_debug
678 #define GAA_REST_EXISTS
687 static int gaa_is_an_argument(char *str
)
690 if(str
[0] == '/' && str
[1] != 0)
691 return GAA_MULTIPLE_OPTION
;
694 return GAA_NOT_AN_OPTION
;
696 return GAA_NOT_AN_OPTION
;
700 return GAA_WORD_OPTION
;
702 return GAA_NOT_AN_OPTION
;
705 return GAA_LETTER_OPTION
;
707 return GAA_MULTIPLE_OPTION
;
710 static int gaa_get_option_num(char *str
, int status
)
714 case GAA_LETTER_OPTION
:
715 GAA_CHECK1STR("p", GAAOPTID_port
);
716 GAA_CHECK1STR("", GAAOPTID_opaque_prf_input
);
717 GAA_CHECK1STR("", GAAOPTID_pskkey
);
718 GAA_CHECK1STR("", GAAOPTID_pskusername
);
719 GAA_CHECK1STR("", GAAOPTID_srppasswd
);
720 GAA_CHECK1STR("", GAAOPTID_srpusername
);
721 GAA_CHECK1STR("", GAAOPTID_x509certfile
);
722 GAA_CHECK1STR("", GAAOPTID_x509keyfile
);
723 GAA_CHECK1STR("", GAAOPTID_pgpsubkey
);
724 GAA_CHECK1STR("", GAAOPTID_pgpcertfile
);
725 GAA_CHECK1STR("", GAAOPTID_pgpkeyring
);
726 GAA_CHECK1STR("", GAAOPTID_pgpkeyfile
);
727 GAA_CHECK1STR("", GAAOPTID_x509crlfile
);
728 GAA_CHECK1STR("", GAAOPTID_x509cafile
);
729 GAA_CHECK1STR("", GAAOPTID_priority
);
730 GAA_CHECK1STR("", GAAOPTID_ctypes
);
731 GAA_CHECK1STR("", GAAOPTID_kx
);
732 GAA_CHECK1STR("", GAAOPTID_macs
);
733 GAA_CHECK1STR("", GAAOPTID_comp
);
734 GAA_CHECK1STR("", GAAOPTID_protocols
);
735 GAA_CHECK1STR("", GAAOPTID_ciphers
);
736 GAA_CHECK1STR("", GAAOPTID_recordsize
);
737 GAA_CHECK1STR("d", GAAOPTID_debug
);
738 case GAA_MULTIPLE_OPTION
:
740 GAA_CHECK1STR("v", GAAOPTID_version
);
741 GAA_CHECK1STR("h", GAAOPTID_help
);
742 GAA_CHECK1STR("l", GAAOPTID_list
);
743 GAA_CHECK1STR("", GAAOPTID_insecure
);
744 GAA_CHECK1STR("V", GAAOPTID_verbose
);
745 GAA_CHECK1STR("", GAAOPTID_print_cert
);
746 GAA_CHECK1STR("", GAAOPTID_disable_extensions
);
747 GAA_CHECK1STR("f", GAAOPTID_fingerprint
);
748 GAA_CHECK1STR("", GAAOPTID_x509fmtder
);
749 GAA_CHECK1STR("", GAAOPTID_crlf
);
750 GAA_CHECK1STR("s", GAAOPTID_starttls
);
751 GAA_CHECK1STR("", GAAOPTID_noticket
);
752 GAA_CHECK1STR("e", GAAOPTID_rehandshake
);
753 GAA_CHECK1STR("r", GAAOPTID_resume
);
757 case GAA_WORD_OPTION
:
758 GAA_CHECKSTR("version", GAAOPTID_version
);
759 GAA_CHECKSTR("help", GAAOPTID_help
);
760 GAA_CHECKSTR("list", GAAOPTID_list
);
761 GAA_CHECKSTR("insecure", GAAOPTID_insecure
);
762 GAA_CHECKSTR("port", GAAOPTID_port
);
763 GAA_CHECKSTR("opaque-prf-input", GAAOPTID_opaque_prf_input
);
764 GAA_CHECKSTR("pskkey", GAAOPTID_pskkey
);
765 GAA_CHECKSTR("pskusername", GAAOPTID_pskusername
);
766 GAA_CHECKSTR("srppasswd", GAAOPTID_srppasswd
);
767 GAA_CHECKSTR("srpusername", GAAOPTID_srpusername
);
768 GAA_CHECKSTR("x509certfile", GAAOPTID_x509certfile
);
769 GAA_CHECKSTR("x509keyfile", GAAOPTID_x509keyfile
);
770 GAA_CHECKSTR("pgpsubkey", GAAOPTID_pgpsubkey
);
771 GAA_CHECKSTR("pgpcertfile", GAAOPTID_pgpcertfile
);
772 GAA_CHECKSTR("pgpkeyring", GAAOPTID_pgpkeyring
);
773 GAA_CHECKSTR("pgpkeyfile", GAAOPTID_pgpkeyfile
);
774 GAA_CHECKSTR("x509crlfile", GAAOPTID_x509crlfile
);
775 GAA_CHECKSTR("x509cafile", GAAOPTID_x509cafile
);
776 GAA_CHECKSTR("priority", GAAOPTID_priority
);
777 GAA_CHECKSTR("ctypes", GAAOPTID_ctypes
);
778 GAA_CHECKSTR("kx", GAAOPTID_kx
);
779 GAA_CHECKSTR("macs", GAAOPTID_macs
);
780 GAA_CHECKSTR("comp", GAAOPTID_comp
);
781 GAA_CHECKSTR("protocols", GAAOPTID_protocols
);
782 GAA_CHECKSTR("ciphers", GAAOPTID_ciphers
);
783 GAA_CHECKSTR("verbose", GAAOPTID_verbose
);
784 GAA_CHECKSTR("recordsize", GAAOPTID_recordsize
);
785 GAA_CHECKSTR("print-cert", GAAOPTID_print_cert
);
786 GAA_CHECKSTR("disable-extensions", GAAOPTID_disable_extensions
);
787 GAA_CHECKSTR("fingerprint", GAAOPTID_fingerprint
);
788 GAA_CHECKSTR("x509fmtder", GAAOPTID_x509fmtder
);
789 GAA_CHECKSTR("crlf", GAAOPTID_crlf
);
790 GAA_CHECKSTR("starttls", GAAOPTID_starttls
);
791 GAA_CHECKSTR("noticket", GAAOPTID_noticket
);
792 GAA_CHECKSTR("rehandshake", GAAOPTID_rehandshake
);
793 GAA_CHECKSTR("resume", GAAOPTID_resume
);
794 GAA_CHECKSTR("debug", GAAOPTID_debug
);
800 return GAA_ERROR_NOMATCH
;
803 static int gaa_try(int gaa_num
, int gaa_index
, gaainfo
*gaaval
, char *opt_list
)
806 int gaa_last_non_option
;
807 struct GAAOPTION_port GAATMP_port
;
808 struct GAAOPTION_opaque_prf_input GAATMP_opaque_prf_input
;
809 struct GAAOPTION_pskkey GAATMP_pskkey
;
810 struct GAAOPTION_pskusername GAATMP_pskusername
;
811 struct GAAOPTION_srppasswd GAATMP_srppasswd
;
812 struct GAAOPTION_srpusername GAATMP_srpusername
;
813 struct GAAOPTION_x509certfile GAATMP_x509certfile
;
814 struct GAAOPTION_x509keyfile GAATMP_x509keyfile
;
815 struct GAAOPTION_pgpsubkey GAATMP_pgpsubkey
;
816 struct GAAOPTION_pgpcertfile GAATMP_pgpcertfile
;
817 struct GAAOPTION_pgpkeyring GAATMP_pgpkeyring
;
818 struct GAAOPTION_pgpkeyfile GAATMP_pgpkeyfile
;
819 struct GAAOPTION_x509crlfile GAATMP_x509crlfile
;
820 struct GAAOPTION_x509cafile GAATMP_x509cafile
;
821 struct GAAOPTION_priority GAATMP_priority
;
822 struct GAAOPTION_ctypes GAATMP_ctypes
;
823 struct GAAOPTION_kx GAATMP_kx
;
824 struct GAAOPTION_macs GAATMP_macs
;
825 struct GAAOPTION_comp GAATMP_comp
;
826 struct GAAOPTION_protocols GAATMP_protocols
;
827 struct GAAOPTION_ciphers GAATMP_ciphers
;
828 struct GAAOPTION_recordsize GAATMP_recordsize
;
829 struct GAAOPTION_debug GAATMP_debug
;
832 #ifdef GAA_REST_EXISTS
833 struct GAAREST GAAREST_tmp
;
836 opt_list
[gaa_num
] = 1;
838 for(gaa_last_non_option
= gaa_index
;
839 (gaa_last_non_option
!= GAAargc
) && (gaa_is_an_argument(GAAargv
[gaa_last_non_option
]) == GAA_NOT_AN_OPTION
);
840 gaa_last_non_option
++);
842 if(gaa_num
== GAA_REST
)
845 gaa_last_non_option
= GAAargc
;
850 case GAAOPTID_version
:
853 { cli_version(); exit(0); ;};
860 { gaa_help(); exit(0); ;};
867 { print_list(gaaval
->verbose
); exit(0); ;};
871 case GAAOPTID_insecure
:
874 { gaaval
->insecure
= 1 ;};
881 GAA_FILL(GAATMP_port
.arg1
, gaa_getstr
, GAATMP_port
.size1
);
884 { gaaval
->port
= GAATMP_port
.arg1
;};
888 case GAAOPTID_opaque_prf_input
:
891 GAA_FILL(GAATMP_opaque_prf_input
.arg1
, gaa_getstr
, GAATMP_opaque_prf_input
.size1
);
894 { gaaval
->opaque_prf_input
= GAATMP_opaque_prf_input
.arg1
;};
898 case GAAOPTID_pskkey
:
901 GAA_FILL(GAATMP_pskkey
.arg1
, gaa_getstr
, GAATMP_pskkey
.size1
);
904 { gaaval
->psk_key
= GAATMP_pskkey
.arg1
;};
908 case GAAOPTID_pskusername
:
911 GAA_FILL(GAATMP_pskusername
.arg1
, gaa_getstr
, GAATMP_pskusername
.size1
);
914 { gaaval
->psk_username
= GAATMP_pskusername
.arg1
;};
918 case GAAOPTID_srppasswd
:
921 GAA_FILL(GAATMP_srppasswd
.arg1
, gaa_getstr
, GAATMP_srppasswd
.size1
);
924 { gaaval
->srp_passwd
= GAATMP_srppasswd
.arg1
;};
928 case GAAOPTID_srpusername
:
931 GAA_FILL(GAATMP_srpusername
.arg1
, gaa_getstr
, GAATMP_srpusername
.size1
);
934 { gaaval
->srp_username
= GAATMP_srpusername
.arg1
;};
938 case GAAOPTID_x509certfile
:
941 GAA_FILL(GAATMP_x509certfile
.arg1
, gaa_getstr
, GAATMP_x509certfile
.size1
);
944 { gaaval
->x509_certfile
= GAATMP_x509certfile
.arg1
;};
948 case GAAOPTID_x509keyfile
:
951 GAA_FILL(GAATMP_x509keyfile
.arg1
, gaa_getstr
, GAATMP_x509keyfile
.size1
);
954 { gaaval
->x509_keyfile
= GAATMP_x509keyfile
.arg1
;};
958 case GAAOPTID_pgpsubkey
:
961 GAA_FILL(GAATMP_pgpsubkey
.arg1
, gaa_getstr
, GAATMP_pgpsubkey
.size1
);
964 { gaaval
->pgp_subkey
= GAATMP_pgpsubkey
.arg1
;};
968 case GAAOPTID_pgpcertfile
:
971 GAA_FILL(GAATMP_pgpcertfile
.arg1
, gaa_getstr
, GAATMP_pgpcertfile
.size1
);
974 { gaaval
->pgp_certfile
= GAATMP_pgpcertfile
.arg1
;};
978 case GAAOPTID_pgpkeyring
:
981 GAA_FILL(GAATMP_pgpkeyring
.arg1
, gaa_getstr
, GAATMP_pgpkeyring
.size1
);
984 { gaaval
->pgp_keyring
= GAATMP_pgpkeyring
.arg1
;};
988 case GAAOPTID_pgpkeyfile
:
991 GAA_FILL(GAATMP_pgpkeyfile
.arg1
, gaa_getstr
, GAATMP_pgpkeyfile
.size1
);
994 { gaaval
->pgp_keyfile
= GAATMP_pgpkeyfile
.arg1
;};
998 case GAAOPTID_x509crlfile
:
1001 GAA_FILL(GAATMP_x509crlfile
.arg1
, gaa_getstr
, GAATMP_x509crlfile
.size1
);
1004 { gaaval
->x509_crlfile
= GAATMP_x509crlfile
.arg1
;};
1008 case GAAOPTID_x509cafile
:
1011 GAA_FILL(GAATMP_x509cafile
.arg1
, gaa_getstr
, GAATMP_x509cafile
.size1
);
1014 { gaaval
->x509_cafile
= GAATMP_x509cafile
.arg1
;};
1018 case GAAOPTID_priority
:
1021 GAA_FILL(GAATMP_priority
.arg1
, gaa_getstr
, GAATMP_priority
.size1
);
1024 { gaaval
->priorities
= GAATMP_priority
.arg1
;};
1028 case GAAOPTID_ctypes
:
1030 GAA_LIST_FILL(GAATMP_ctypes
.arg1
, gaa_getstr
, char*, GAATMP_ctypes
.size1
);
1032 { gaaval
->ctype
= GAATMP_ctypes
.arg1
; gaaval
->nctype
= GAATMP_ctypes
.size1
;};
1038 GAA_LIST_FILL(GAATMP_kx
.arg1
, gaa_getstr
, char*, GAATMP_kx
.size1
);
1040 { gaaval
->kx
= GAATMP_kx
.arg1
; gaaval
->nkx
= GAATMP_kx
.size1
;};
1046 GAA_LIST_FILL(GAATMP_macs
.arg1
, gaa_getstr
, char*, GAATMP_macs
.size1
);
1048 { gaaval
->macs
= GAATMP_macs
.arg1
; gaaval
->nmacs
= GAATMP_macs
.size1
;};
1054 GAA_LIST_FILL(GAATMP_comp
.arg1
, gaa_getstr
, char*, GAATMP_comp
.size1
);
1056 { gaaval
->comp
= GAATMP_comp
.arg1
; gaaval
->ncomp
= GAATMP_comp
.size1
;};
1060 case GAAOPTID_protocols
:
1062 GAA_LIST_FILL(GAATMP_protocols
.arg1
, gaa_getstr
, char*, GAATMP_protocols
.size1
);
1064 { gaaval
->proto
= GAATMP_protocols
.arg1
; gaaval
->nproto
= GAATMP_protocols
.size1
;};
1068 case GAAOPTID_ciphers
:
1070 GAA_LIST_FILL(GAATMP_ciphers
.arg1
, gaa_getstr
, char*, GAATMP_ciphers
.size1
);
1072 { gaaval
->ciphers
= GAATMP_ciphers
.arg1
; gaaval
->nciphers
= GAATMP_ciphers
.size1
;};
1076 case GAAOPTID_verbose
:
1079 { gaaval
->verbose
= 1 ;};
1083 case GAAOPTID_recordsize
:
1086 GAA_FILL(GAATMP_recordsize
.arg1
, gaa_getint
, GAATMP_recordsize
.size1
);
1089 { gaaval
->record_size
= GAATMP_recordsize
.arg1
;};
1093 case GAAOPTID_print_cert
:
1096 { gaaval
->print_cert
= 1 ;};
1100 case GAAOPTID_disable_extensions
:
1103 { gaaval
->disable_extensions
= 1 ;};
1107 case GAAOPTID_fingerprint
:
1110 { gaaval
->fingerprint
= 1 ;};
1114 case GAAOPTID_x509fmtder
:
1117 { gaaval
->fmtder
= 1 ;};
1124 { gaaval
->crlf
= 1 ;};
1128 case GAAOPTID_starttls
:
1131 { gaaval
->starttls
= 1 ;};
1135 case GAAOPTID_noticket
:
1138 { gaaval
->noticket
= 1 ;};
1142 case GAAOPTID_rehandshake
:
1145 { gaaval
->rehandshake
= 1 ;};
1149 case GAAOPTID_resume
:
1152 { gaaval
->resume
= 1 ;};
1156 case GAAOPTID_debug
:
1159 GAA_FILL(GAATMP_debug
.arg1
, gaa_getint
, GAATMP_debug
.size1
);
1162 { gaaval
->debug
= GAATMP_debug
.arg1
;};
1168 GAA_FILL(GAAREST_tmp
.arg1
, gaa_getstr
, GAAREST_tmp
.size1
);
1171 { gaaval
->rest_args
= GAAREST_tmp
.arg1
; ;};
1176 #line 413 "gaa.skel"
1179 return GAA_ERROR_UNKNOWN
;
1182 int gaa(int argc
, char **argv
, gaainfo
*gaaval
)
1191 opt_list
= (char*) gaa_malloc(GAA_NB_OPTION
+ 1);
1193 for(i
= 0; i
< GAA_NB_OPTION
+ 1; i
++)
1195 /* initialization */
1200 { gaaval
->resume
=0; gaaval
->noticket
=0; gaaval
->port
="443"; gaaval
->rest_args
=NULL
; gaaval
->ciphers
=NULL
;
1201 gaaval
->kx
=NULL
; gaaval
->comp
=NULL
; gaaval
->macs
=NULL
; gaaval
->ctype
=NULL
; gaaval
->nciphers
=0;
1202 gaaval
->nkx
=0; gaaval
->ncomp
=0; gaaval
->nmacs
=0; gaaval
->nctype
= 0; gaaval
->record_size
=0;
1203 gaaval
->fingerprint
=0; gaaval
->pgp_keyring
=NULL
; gaaval
->x509_crlfile
= NULL
;
1204 gaaval
->x509_cafile
= NULL
; gaaval
->pgp_keyfile
=NULL
; gaaval
->pgp_certfile
=NULL
; gaaval
->disable_extensions
= 0;
1205 gaaval
->x509_keyfile
=NULL
; gaaval
->x509_certfile
=NULL
; gaaval
->crlf
= 0;
1206 gaaval
->srp_username
=NULL
; gaaval
->srp_passwd
=NULL
; gaaval
->fmtder
= 0; gaaval
->starttls
=0;
1207 gaaval
->debug
= 0; gaaval
->print_cert
= 0; gaaval
->verbose
= 0; gaaval
->psk_key
= NULL
;
1208 gaaval
->psk_username
= NULL
; gaaval
->priorities
= NULL
;
1209 gaaval
->opaque_prf_input
= NULL
; gaaval
->pgp_subkey
= NULL
; gaaval
->rehandshake
= 0; ;};
1213 #line 438 "gaa.skel"
1214 gaa_arg_used
= NULL
;
1217 gaa_arg_used
= gaa_malloc(argc
* sizeof(char));
1220 for(i
= 1; i
< argc
; i
++)
1221 gaa_arg_used
[i
] = 0;
1222 for(i
= 1; i
< argc
; i
++)
1224 if(gaa_arg_used
[i
] == 0)
1227 tmp1
= gaa_is_an_argument(GAAargv
[i
]);
1230 case GAA_WORD_OPTION
:
1232 case GAA_LETTER_OPTION
:
1234 tmp2
= gaa_get_option_num(argv
[i
]+j
, tmp1
);
1235 if(tmp2
== GAA_ERROR_NOMATCH
)
1237 printf("Invalid option '%s'\n", argv
[i
]+j
);
1240 switch(gaa_try(tmp2
, i
+1, gaaval
, opt_list
))
1242 case GAA_ERROR_NOTENOUGH_ARGS
:
1243 printf("'%s': not enough arguments\n",gaa_current_option
);
1245 case GAA_ERROR_INVALID_ARG
:
1246 printf("Invalid arguments\n");
1251 printf("Unknown error\n");
1253 gaa_arg_used
[i
] = 1;
1255 case GAA_MULTIPLE_OPTION
:
1256 for(j
= 1; j
< strlen(argv
[i
]); j
++)
1258 tmp2
= gaa_get_option_num(argv
[i
]+j
, tmp1
);
1259 if(tmp2
== GAA_ERROR_NOMATCH
)
1261 printf("Invalid option '%c'\n", *(argv
[i
]+j
));
1264 switch(gaa_try(tmp2
, i
+1, gaaval
, opt_list
))
1266 case GAA_ERROR_NOTENOUGH_ARGS
:
1267 printf("'%s': not enough arguments\n",gaa_current_option
);
1269 case GAA_ERROR_INVALID_ARG
:
1270 printf("Invalid arguments\n");
1275 printf("Unknown error\n");
1278 gaa_arg_used
[i
] = 1;
1284 if(gaa_processing_file
== 0)
1287 #line 507 "gaa.skel"
1288 #ifdef GAA_REST_EXISTS
1289 switch(gaa_try(GAA_REST
, 1, gaaval
, opt_list
))
1291 case GAA_ERROR_NOTENOUGH_ARGS
:
1292 printf("Rest: not enough arguments\n");
1294 case GAA_ERROR_INVALID_ARG
:
1295 printf("Invalid arguments\n");
1300 printf("Unknown error\n");
1304 for(i
= 1; i
< argc
; i
++)
1306 if(gaa_arg_used
[i
] == 0)
1308 printf("Too many arguments\n");
1320 struct gaastrnode
*next
;
1323 typedef struct gaastrnode gaa_str_node
;
1325 static int gaa_internal_get_next_str(FILE *file
, gaa_str_node
*tmp_str
, int argc
)
1329 int i
= 0, len
= 0, newline
= 0;
1337 if (a
== EOF
) return 0;
1339 while(a
== ' ' || a
== 9 || a
== '\n')
1347 if (a
== EOF
) return 0;
1350 pos_ini
= ftell(file
) - 1;
1352 while(a
!= ' ' && a
!= 9 && a
!= '\n')
1357 if(a
==EOF
) return 0; //a = ' ';
1361 tmp_str
->str
= gaa_malloc((len
) * sizeof(char));
1365 tmp_str
->str
[0] = '-';
1366 tmp_str
->str
[1] = '-';
1374 fseek(file
,pos_ini
, SEEK_SET
);
1383 tmp_str
->str
[i
] = a
;
1386 while(a
!= ' ' && a
!= 9 && a
!= '\n' && i
< len
);
1388 tmp_str
->str
[i
- 1] = 0;
1390 fseek(file
,- 1, SEEK_CUR
);
1391 /* printf("%d\n", ftell(file)); */
1396 int gaa_file(const char *name
, gaainfo
*gaaval
)
1398 gaa_str_node
*first_str
, **tmp_str
, *tmp_str2
;
1404 gaa_processing_file
= 1;
1406 if((file
= fopen(name
, "r")) == NULL
)
1408 printf("Couldn't open '%s' configuration file for reading\n", name
);
1412 tmp_str
= &first_str
;
1416 *tmp_str
= gaa_malloc(sizeof(gaa_str_node
));
1418 (*tmp_str
)->str
= NULL
;
1419 (*tmp_str
)->next
= NULL
;
1421 rval
= gaa_internal_get_next_str(file
, *tmp_str
, argc
);
1422 tmp_str
= &((*tmp_str
)->next
);
1429 argv
= gaa_malloc((1 + argc
) * sizeof(char*));
1431 tmp_str2
= first_str
;
1433 for(i
= 1; i
< argc
; i
++)
1435 argv
[i
] = tmp_str2
->str
;
1436 tmp_str2
= tmp_str2
->next
;
1439 rval
= gaa(argc
, argv
, gaaval
);
1440 gaa_processing_file
= 0;