2014-06-20 20:00:00 +01:00
|
|
|
/* Copyright (c) 2014, Google Inc.
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
|
|
|
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
|
|
|
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <openssl/err.h>
|
2014-06-20 20:00:00 +01:00
|
|
|
#include <openssl/ssl.h>
|
2014-06-20 20:00:00 +01:00
|
|
|
|
|
|
|
|
2014-10-31 20:01:29 +00:00
|
|
|
#if !defined(OPENSSL_WINDOWS)
|
2014-06-20 20:00:00 +01:00
|
|
|
bool Client(const std::vector<std::string> &args);
|
2014-12-11 00:09:52 +00:00
|
|
|
bool Server(const std::vector<std::string> &args);
|
2014-10-31 20:01:29 +00:00
|
|
|
#endif
|
2014-09-19 18:49:56 +01:00
|
|
|
bool DoPKCS12(const std::vector<std::string> &args);
|
2014-08-21 22:11:39 +01:00
|
|
|
bool Speed(const std::vector<std::string> &args);
|
2014-06-20 20:00:00 +01:00
|
|
|
|
2014-06-20 20:00:00 +01:00
|
|
|
static void usage(const char *name) {
|
2014-12-11 00:09:52 +00:00
|
|
|
printf("Usage: %s [speed|client|server|pkcs12]\n", name);
|
2014-06-20 20:00:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
std::string tool;
|
|
|
|
if (argc >= 2) {
|
|
|
|
tool = argv[1];
|
|
|
|
}
|
|
|
|
|
2014-06-20 20:00:00 +01:00
|
|
|
SSL_library_init();
|
2014-06-20 20:00:00 +01:00
|
|
|
|
|
|
|
std::vector<std::string> args;
|
|
|
|
for (int i = 2; i < argc; i++) {
|
|
|
|
args.push_back(argv[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tool == "speed") {
|
|
|
|
return !Speed(args);
|
2014-10-31 20:01:29 +00:00
|
|
|
#if !defined(OPENSSL_WINDOWS)
|
2014-06-20 20:00:00 +01:00
|
|
|
} else if (tool == "s_client" || tool == "client") {
|
|
|
|
return !Client(args);
|
2014-12-11 00:09:52 +00:00
|
|
|
} else if (tool == "s_server" || tool == "server") {
|
|
|
|
return !Server(args);
|
2014-10-31 20:01:29 +00:00
|
|
|
#endif
|
2014-08-21 22:11:39 +01:00
|
|
|
} else if (tool == "pkcs12") {
|
2014-09-19 18:49:56 +01:00
|
|
|
return !DoPKCS12(args);
|
2014-06-20 20:00:00 +01:00
|
|
|
} else {
|
|
|
|
usage(argv[0]);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|