Added Twrch support.
This commit is contained in:
parent
ce1c57909a
commit
93681c2830
7 changed files with 1100 additions and 11 deletions
File diff suppressed because one or more lines are too long
|
|
@ -290,6 +290,7 @@ toolssrc=" \
|
|||
tools/skey.c \
|
||||
tools/sslio.c \
|
||||
tools/ta.c \
|
||||
tools/twrch.c \
|
||||
tools/vector.c \
|
||||
tools/verify.c \
|
||||
tools/xmem.c"
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ usage(void)
|
|||
fprintf(stderr, " skey decode private key\n");
|
||||
fprintf(stderr, " ta decode trust anchors\n");
|
||||
fprintf(stderr, " chain make C code for certificate chains\n");
|
||||
fprintf(stderr, " twrch run the Twrch protocol\n");
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -98,6 +99,15 @@ main(int argc, char *argv[])
|
|||
if (do_chain(argc - 2, argv + 2) < 0) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
} else if (eqstr(cmd, "twrch")) {
|
||||
int ret;
|
||||
|
||||
ret = do_twrch(argc - 2, argv + 2);
|
||||
if (ret < 0) {
|
||||
return EXIT_FAILURE;
|
||||
} else {
|
||||
return ret;
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "unknown command: '%s'\n", cmd);
|
||||
usage();
|
||||
|
|
|
|||
|
|
@ -485,7 +485,8 @@ const char *get_algo_name(const void *algo, int long_name);
|
|||
|
||||
/*
|
||||
* Run a SSL engine, with a socket connected to the peer, and using
|
||||
* stdin/stdout to exchange application data.
|
||||
* stdin/stdout to exchange application data. The socket must be a
|
||||
* non-blocking descriptor.
|
||||
*
|
||||
* To help with Win32 compatibility, the socket descriptor is provided
|
||||
* as an "unsigned long" value.
|
||||
|
|
@ -538,4 +539,11 @@ int do_ta(int argc, char *argv[]);
|
|||
*/
|
||||
int do_chain(int argc, char *argv[]);
|
||||
|
||||
/*
|
||||
* Do the "twrch" command. Returned value is 0 on success, -1 on failure
|
||||
* (processing or arguments), or a non-zero exit code. Command-line
|
||||
* arguments start _after_ the command name.
|
||||
*/
|
||||
int do_twrch(int argc, char *argv[]);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -764,7 +764,7 @@ do_client(int argc, char *argv[])
|
|||
}
|
||||
arg = argv[i];
|
||||
if (minhello_len != (size_t)-1) {
|
||||
fprintf(stderr, "ERROR: duplicate minium"
|
||||
fprintf(stderr, "ERROR: duplicate minimum"
|
||||
" ClientHello length\n");
|
||||
usage_client();
|
||||
goto client_exit_error;
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ host_bind(const char *host, const char *port, int verbose)
|
|||
}
|
||||
|
||||
static SOCKET
|
||||
accept_client(SOCKET server_fd, int verbose)
|
||||
accept_client(SOCKET server_fd, int verbose, int nonblock)
|
||||
{
|
||||
int fd;
|
||||
SOCKADDR_STORAGE sa;
|
||||
|
|
@ -209,16 +209,16 @@ accept_client(SOCKET server_fd, int verbose)
|
|||
* We make the socket non-blocking, since we are going to use
|
||||
* poll() or select() to organise I/O.
|
||||
*/
|
||||
if (nonblock) {
|
||||
#ifdef _WIN32
|
||||
{
|
||||
u_long arg;
|
||||
|
||||
arg = 1;
|
||||
ioctlsocket(fd, FIONBIO, &arg);
|
||||
}
|
||||
#else
|
||||
fcntl(fd, F_SETFL, O_NONBLOCK);
|
||||
#endif
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
|
|
@ -1177,15 +1177,16 @@ do_server(int argc, char *argv[])
|
|||
*/
|
||||
for (;;) {
|
||||
int x;
|
||||
unsigned run_flags;
|
||||
|
||||
fd = accept_client(server_fd, verbose);
|
||||
fd = accept_client(server_fd, verbose, 1);
|
||||
if (fd == INVALID_SOCKET) {
|
||||
goto server_exit_error;
|
||||
}
|
||||
br_ssl_server_reset(&cc);
|
||||
x = run_ssl_engine(&cc.eng, fd,
|
||||
(verbose ? RUN_ENGINE_VERBOSE : 0)
|
||||
| (trace ? RUN_ENGINE_TRACE : 0));
|
||||
run_flags = (verbose ? RUN_ENGINE_VERBOSE : 0)
|
||||
| (trace ? RUN_ENGINE_TRACE : 0);
|
||||
x = run_ssl_engine(&cc.eng, fd, run_flags);
|
||||
#ifdef _WIN32
|
||||
closesocket(fd);
|
||||
#else
|
||||
|
|
|
|||
1066
tools/twrch.c
Normal file
1066
tools/twrch.c
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue