Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
authorAdam Langley <alangley@gmail.com>2015-05-26 21:36:46 +0300
committerAdam Langley <agl@google.com>2015-06-05 21:39:44 +0300
commit839b881c612c698d7331191beac7d565649f5351 (patch)
tree0ab948fffb1c878944ef828f0cb567691b7ccebd /tool
parentaf0e32cb84f0c9cc65b9233a3414d2562642b342 (diff)
Multi-prime RSA support.
RSA with more than two primes is specified in https://tools.ietf.org/html/rfc3447, although the idea goes back far earier than that. This change ports some of the changes in http://rt.openssl.org/Ticket/Display.html?id=3477&user=guest&pass=guest to BoringSSL—specifically those bits that are under an OpenSSL license. Change-Id: I51e8e345e2148702b8ce12e00518f6ef4683d3e1 Reviewed-on: https://boringssl-review.googlesource.com/4870 Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'tool')
-rw-r--r--tool/CMakeLists.txt1
-rw-r--r--tool/args.cc26
-rw-r--r--tool/const.cc111
-rw-r--r--tool/genrsa.cc69
-rw-r--r--tool/internal.h4
-rw-r--r--tool/speed.cc16
-rw-r--r--tool/tool.cc18
7 files changed, 236 insertions, 9 deletions
diff --git a/tool/CMakeLists.txt b/tool/CMakeLists.txt
index 74c1ac8f..79077455 100644
--- a/tool/CMakeLists.txt
+++ b/tool/CMakeLists.txt
@@ -7,6 +7,7 @@ add_executable(
client.cc
const.cc
digest.cc
+ genrsa.cc
pkcs12.cc
rand.cc
server.cc
diff --git a/tool/args.cc b/tool/args.cc
index a1644767..850d9d84 100644
--- a/tool/args.cc
+++ b/tool/args.cc
@@ -15,6 +15,7 @@
#include <string>
#include <vector>
+#include <limits.h>
#include <stdio.h>
#include <string.h>
@@ -75,3 +76,28 @@ void PrintUsage(const struct argument *templates) {
fprintf(stderr, "%s\t%s\n", templ->name, templ->description);
}
}
+
+bool GetUnsigned(unsigned *out, const std::string &arg_name,
+ unsigned default_value,
+ const std::map<std::string, std::string> &args) {
+ const auto &it = args.find(arg_name);
+ if (it == args.end()) {
+ *out = default_value;
+ return true;
+ }
+
+ const std::string &value = it->second;
+ if (value.empty()) {
+ return false;
+ }
+
+ char *endptr;
+ unsigned long int num = strtoul(value.c_str(), &endptr, 10);
+ if (*endptr ||
+ num > UINT_MAX) {
+ return false;
+ }
+
+ *out = num;
+ return true;
+}
diff --git a/tool/const.cc b/tool/const.cc
index 5222667e..b364cd41 100644
--- a/tool/const.cc
+++ b/tool/const.cc
@@ -323,4 +323,113 @@ uint8_t kDERRSAPrivate4096[] = {
size_t kDERRSAPrivate4096Len = sizeof(kDERRSAPrivate4096);
-}
+uint8_t kDERRSAPrivate3Prime2048[] = {
+ 0x30, 0x82, 0x04, 0xd7, 0x02, 0x01, 0x01, 0x02, 0x82, 0x01, 0x00, 0x62,
+ 0x91, 0xe9, 0xea, 0xb3, 0x5d, 0x6c, 0x29, 0xae, 0x21, 0x83, 0xbb, 0xb5,
+ 0x82, 0xb1, 0x9e, 0xea, 0xe0, 0x64, 0x5b, 0x1e, 0x2f, 0x5e, 0x2c, 0x0a,
+ 0x80, 0x3d, 0x29, 0xd4, 0xfa, 0x9a, 0xe7, 0x44, 0xe6, 0x21, 0xbd, 0x98,
+ 0xc0, 0x3d, 0xe0, 0x53, 0x59, 0xae, 0xd3, 0x3e, 0xfe, 0xc4, 0xc2, 0xc4,
+ 0x5a, 0x5a, 0x89, 0x07, 0xf4, 0x4f, 0xdc, 0xb0, 0x6a, 0xd4, 0x3e, 0x99,
+ 0x7d, 0x7a, 0x97, 0x26, 0x4e, 0xe1, 0x93, 0xca, 0x6e, 0xed, 0x07, 0xfc,
+ 0xb4, 0xfa, 0x95, 0x1e, 0x73, 0x7b, 0x86, 0x08, 0x6a, 0xb9, 0xd4, 0x29,
+ 0xb0, 0x7e, 0x59, 0xb7, 0x9d, 0x7b, 0xeb, 0x67, 0x6e, 0xf0, 0xbb, 0x5e,
+ 0xcf, 0xb9,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, 0x7d, 0x22, 0x59,
+ 0x2a, 0x35, 0xea, 0x50, 0x4e, 0x47, 0x6b, 0x92, 0x2d, 0x30, 0xa1, 0x01,
+ 0xa5, 0x9e, 0x26, 0x6e, 0x27, 0xca, 0xf5, 0xf2, 0x87, 0x5d, 0x31, 0xaf,
+ 0xe9, 0x32, 0xcd, 0x10, 0xfd, 0x4d, 0xdb, 0xf9, 0x86, 0x05, 0x12, 0x1b,
+ 0x01, 0x84, 0x55, 0x97, 0x5f, 0xe2, 0x78, 0x27, 0xd9, 0xe4, 0x26, 0x7d,
+ 0xab, 0x0e, 0xe0, 0x1b, 0x6f, 0xcb, 0x4b, 0x14, 0xdd, 0xdc, 0xdc, 0x8b,
+ 0xe8, 0x9f, 0xd0, 0x62, 0x96, 0xca, 0xcf,
+};
+
+size_t kDERRSAPrivate3Prime2048Len = sizeof(kDERRSAPrivate3Prime2048);
+
+} /* extern "C" */
diff --git a/tool/genrsa.cc b/tool/genrsa.cc
new file mode 100644
index 00000000..f5296cee
--- /dev/null
+++ b/tool/genrsa.cc
@@ -0,0 +1,69 @@
+/* Copyright (c) 2015, 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 <openssl/bio.h>
+#include <openssl/bn.h>
+#include <openssl/err.h>
+#include <openssl/pem.h>
+#include <openssl/rsa.h>
+
+#include "../crypto/test/scoped_types.h"
+#include "internal.h"
+
+
+static const struct argument kArguments[] = {
+ {
+ "-nprimes", kOptionalArgument,
+ "The number of primes to generate (default: 2)",
+ },
+ {
+ "-bits", kOptionalArgument,
+ "The number of bits in the modulus (default: 2048)",
+ },
+ {
+ "", kOptionalArgument, "",
+ },
+};
+
+bool GenerateRSAKey(const std::vector<std::string> &args) {
+ std::map<std::string, std::string> args_map;
+
+ if (!ParseKeyValueArguments(&args_map, args, kArguments)) {
+ PrintUsage(kArguments);
+ return false;
+ }
+
+ unsigned bits, nprimes;
+ if (!GetUnsigned(&bits, "-bits", 2048, args_map) ||
+ !GetUnsigned(&nprimes, "-nprimes", 2, args_map)) {
+ PrintUsage(kArguments);
+ return false;
+ }
+
+ ScopedRSA rsa(RSA_new());
+ ScopedBIGNUM e(BN_new());
+ ScopedBIO bio(BIO_new_fp(stdout, BIO_NOCLOSE));
+
+ if (!BN_set_word(e.get(), RSA_F4) ||
+ !RSA_generate_multi_prime_key(rsa.get(), bits, nprimes, e.get(), NULL) ||
+ !PEM_write_bio_RSAPrivateKey(bio.get(), rsa.get(), NULL /* cipher */,
+ NULL /* key */, 0 /* key len */,
+ NULL /* password callback */,
+ NULL /* callback arg */)) {
+ ERR_print_errors_fp(stderr);
+ return false;
+ }
+
+ return true;
+}
diff --git a/tool/internal.h b/tool/internal.h
index 277d0998..95030caf 100644
--- a/tool/internal.h
+++ b/tool/internal.h
@@ -49,5 +49,9 @@ bool ParseKeyValueArguments(std::map<std::string, std::string> *out_args, const
void PrintUsage(const struct argument *templates);
+bool GetUnsigned(unsigned *out, const std::string &arg_name,
+ unsigned default_value,
+ const std::map<std::string, std::string> &args);
+
#endif /* !OPENSSL_HEADER_TOOL_INTERNAL_H */
diff --git a/tool/speed.cc b/tool/speed.cc
index ab17c2f6..151dc2b2 100644
--- a/tool/speed.cc
+++ b/tool/speed.cc
@@ -44,6 +44,8 @@ extern const uint8_t kDERRSAPrivate2048[];
extern size_t kDERRSAPrivate2048Len;
extern const uint8_t kDERRSAPrivate4096[];
extern size_t kDERRSAPrivate4096Len;
+extern const uint8_t kDERRSAPrivate3Prime2048[];
+extern size_t kDERRSAPrivate3Prime2048Len;
}
// TimeResults represents the results of benchmarking a function.
@@ -429,6 +431,20 @@ bool Speed(const std::vector<std::string> &args) {
RSA_free(key);
key = NULL;
+ inp = kDERRSAPrivate3Prime2048;
+ if (NULL == d2i_RSAPrivateKey(&key, &inp, kDERRSAPrivate3Prime2048Len)) {
+ fprintf(stderr, "Failed to parse RSA key.\n");
+ ERR_print_errors_fp(stderr);
+ return false;
+ }
+
+ if (!SpeedRSA("RSA 2048 (3 prime, e=3)", key, selected)) {
+ return false;
+ }
+
+ RSA_free(key);
+ key = NULL;
+
inp = kDERRSAPrivate4096;
if (NULL == d2i_RSAPrivateKey(&key, &inp, kDERRSAPrivate4096Len)) {
fprintf(stderr, "Failed to parse 4096-bit RSA key.\n");
diff --git a/tool/tool.cc b/tool/tool.cc
index 4bd7d1af..e4d5201b 100644
--- a/tool/tool.cc
+++ b/tool/tool.cc
@@ -27,16 +27,17 @@
bool Client(const std::vector<std::string> &args);
-bool Server(const std::vector<std::string> &args);
+bool DoPKCS12(const std::vector<std::string> &args);
+bool GenerateRSAKey(const std::vector<std::string> &args);
bool MD5Sum(const std::vector<std::string> &args);
+bool Rand(const std::vector<std::string> &args);
bool SHA1Sum(const std::vector<std::string> &args);
bool SHA224Sum(const std::vector<std::string> &args);
bool SHA256Sum(const std::vector<std::string> &args);
bool SHA384Sum(const std::vector<std::string> &args);
bool SHA512Sum(const std::vector<std::string> &args);
-bool DoPKCS12(const std::vector<std::string> &args);
+bool Server(const std::vector<std::string> &args);
bool Speed(const std::vector<std::string> &args);
-bool Rand(const std::vector<std::string> &args);
typedef bool (*tool_func_t)(const std::vector<std::string> &args);
@@ -46,19 +47,20 @@ struct Tool {
};
static const Tool kTools[] = {
- { "speed", Speed },
- { "pkcs12", DoPKCS12 },
{ "client", Client },
+ { "genrsa", GenerateRSAKey },
+ { "md5sum", MD5Sum },
+ { "pkcs12", DoPKCS12 },
+ { "rand", Rand },
{ "s_client", Client },
- { "server", Server },
{ "s_server", Server },
- { "md5sum", MD5Sum },
+ { "server", Server },
{ "sha1sum", SHA1Sum },
{ "sha224sum", SHA224Sum },
{ "sha256sum", SHA256Sum },
{ "sha384sum", SHA384Sum },
{ "sha512sum", SHA512Sum },
- { "rand", Rand },
+ { "speed", Speed },
{ "", nullptr },
};