diff options
author | Adam Langley <alangley@gmail.com> | 2015-05-26 11:36:46 -0700 |
---|---|---|
committer | Adam Langley <agl@google.com> | 2015-06-05 18:39:44 +0000 |
commit | 839b881c612c698d7331191beac7d565649f5351 (patch) | |
tree | 0ab948fffb1c878944ef828f0cb567691b7ccebd /tool/args.cc | |
parent | af0e32cb84f0c9cc65b9233a3414d2562642b342 (diff) | |
download | boringssl-839b881c612c698d7331191beac7d565649f5351.zip boringssl-839b881c612c698d7331191beac7d565649f5351.tar.gz boringssl-839b881c612c698d7331191beac7d565649f5351.tar.bz2 |
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/args.cc')
-rw-r--r-- | tool/args.cc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tool/args.cc b/tool/args.cc index a164476..850d9d8 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; +} |