blob: a3d608af2bdebe00cd7f708f58c592a6433da2bd [file] [log] [blame]
Adam Langleyaacec172014-06-20 12:00:00 -07001/* Copyright (c) 2014, Google Inc.
2 *
3 * Permission to use, copy, modify, and/or distribute this software for any
4 * purpose with or without fee is hereby granted, provided that the above
5 * copyright notice and this permission notice appear in all copies.
6 *
7 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
14
15#ifndef OPENSSL_HEADER_TOOL_INTERNAL_H
16#define OPENSSL_HEADER_TOOL_INTERNAL_H
17
Adam Langley3d960e52015-06-08 14:52:13 -070018#include <openssl/base.h>
19
Adam Langleyaacec172014-06-20 12:00:00 -070020#include <string>
21#include <vector>
Brian Smithefed2212015-01-28 16:20:02 -080022
David Benjamina353cdb2016-06-09 16:48:33 -040023OPENSSL_MSVC_PRAGMA(warning(push))
Brian Smithefed2212015-01-28 16:20:02 -080024// MSVC issues warning C4702 for unreachable code in its xtree header when
25// compiling with -D_HAS_EXCEPTIONS=0. See
26// https://connect.microsoft.com/VisualStudio/feedback/details/809962
David Benjamina353cdb2016-06-09 16:48:33 -040027OPENSSL_MSVC_PRAGMA(warning(disable: 4702))
Brian Smithefed2212015-01-28 16:20:02 -080028
Adam Langleyaacec172014-06-20 12:00:00 -070029#include <map>
30
David Benjamina353cdb2016-06-09 16:48:33 -040031OPENSSL_MSVC_PRAGMA(warning(pop))
Adam Langleyaacec172014-06-20 12:00:00 -070032
nmittlerf0322b22016-05-19 08:49:59 -070033#if defined(OPENSSL_WINDOWS)
34 #define BORINGSSL_OPEN _open
35 #define BORINGSSL_FDOPEN _fdopen
36 #define BORINGSSL_CLOSE _close
37 #define BORINGSSL_READ _read
38 #define BORINGSSL_WRITE _write
39#else
40 #define BORINGSSL_OPEN open
41 #define BORINGSSL_FDOPEN fdopen
42 #define BORINGSSL_CLOSE close
43 #define BORINGSSL_READ read
44 #define BORINGSSL_WRITE write
45#endif
46
David Benjamin05709232015-03-23 19:01:33 -040047enum ArgumentType {
48 kRequiredArgument,
49 kOptionalArgument,
50 kBooleanArgument,
51};
52
Adam Langleyaacec172014-06-20 12:00:00 -070053struct argument {
David Benjamin05709232015-03-23 19:01:33 -040054 const char *name;
55 ArgumentType type;
Adam Langleyaacec172014-06-20 12:00:00 -070056 const char *description;
57};
58
59bool ParseKeyValueArguments(std::map<std::string, std::string> *out_args, const
60 std::vector<std::string> &args, const struct argument *templates);
61
62void PrintUsage(const struct argument *templates);
63
Adam Langley839b8812015-05-26 11:36:46 -070064bool GetUnsigned(unsigned *out, const std::string &arg_name,
65 unsigned default_value,
66 const std::map<std::string, std::string> &args);
67
David Benjamin4e78e302017-03-30 10:16:07 -050068bool ReadAll(std::vector<uint8_t> *out, FILE *in);
69
Piotr Sikoraf9328942016-03-18 18:24:50 -070070bool Ciphers(const std::vector<std::string> &args);
71bool Client(const std::vector<std::string> &args);
72bool DoPKCS12(const std::vector<std::string> &args);
73bool GenerateEd25519Key(const std::vector<std::string> &args);
74bool GenerateRSAKey(const std::vector<std::string> &args);
75bool MD5Sum(const std::vector<std::string> &args);
76bool Rand(const std::vector<std::string> &args);
77bool SHA1Sum(const std::vector<std::string> &args);
78bool SHA224Sum(const std::vector<std::string> &args);
79bool SHA256Sum(const std::vector<std::string> &args);
80bool SHA384Sum(const std::vector<std::string> &args);
81bool SHA512Sum(const std::vector<std::string> &args);
82bool Server(const std::vector<std::string> &args);
David Benjamin4e78e302017-03-30 10:16:07 -050083bool Sign(const std::vector<std::string> &args);
Piotr Sikoraf9328942016-03-18 18:24:50 -070084bool Speed(const std::vector<std::string> &args);
85
David Benjamin58084af2015-06-07 00:25:15 -040086// These values are DER encoded, RSA private keys.
87extern const uint8_t kDERRSAPrivate2048[];
88extern const size_t kDERRSAPrivate2048Len;
89extern const uint8_t kDERRSAPrivate4096[];
90extern const size_t kDERRSAPrivate4096Len;
David Benjamin58084af2015-06-07 00:25:15 -040091
Adam Langleyaacec172014-06-20 12:00:00 -070092
93#endif /* !OPENSSL_HEADER_TOOL_INTERNAL_H */