1 /* 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 
18 #include <openssl/base.h>
19 
20 #include <string>
21 #include <vector>
22 
23 #if defined(_MSC_VER)
24 #pragma warning(push)
25 // MSVC issues warning C4702 for unreachable code in its xtree header when
26 // compiling with -D_HAS_EXCEPTIONS=0. See
27 // https://connect.microsoft.com/VisualStudio/feedback/details/809962
28 #pragma warning(disable: 4702)
29 #endif
30 
31 #include <map>
32 
33 #if defined(_MSC_VER)
34 #pragma warning(pop)
35 #endif
36 
37 enum ArgumentType {
38   kRequiredArgument,
39   kOptionalArgument,
40   kBooleanArgument,
41 };
42 
43 struct argument {
44   const char *name;
45   ArgumentType type;
46   const char *description;
47 };
48 
49 bool ParseKeyValueArguments(std::map<std::string, std::string> *out_args, const
50     std::vector<std::string> &args, const struct argument *templates);
51 
52 void PrintUsage(const struct argument *templates);
53 
54 bool GetUnsigned(unsigned *out, const std::string &arg_name,
55                  unsigned default_value,
56                  const std::map<std::string, std::string> &args);
57 
58 // These values are DER encoded, RSA private keys.
59 extern const uint8_t kDERRSAPrivate2048[];
60 extern const size_t kDERRSAPrivate2048Len;
61 extern const uint8_t kDERRSAPrivate4096[];
62 extern const size_t kDERRSAPrivate4096Len;
63 extern const uint8_t kDERRSAPrivate3Prime2048[];
64 extern const size_t kDERRSAPrivate3Prime2048Len;
65 
66 
67 #endif /* !OPENSSL_HEADER_TOOL_INTERNAL_H */
68