aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2019-01-03 09:33:59 -0500
committerJack Lloyd <[email protected]>2019-01-03 09:33:59 -0500
commit8deddb4da07bfb901b90860bdf67f8dd84e05ec3 (patch)
tree46a0acfd792150c0838a2a2bd8a3ce2d10e4e7f4
parent21cd8e74c93fdb7dde95bdb20f7011a14f53c1c8 (diff)
Casts to avoid MSVC warnings
-rw-r--r--src/cli/tss.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/cli/tss.cpp b/src/cli/tss.cpp
index 60149ee29..0756616b2 100644
--- a/src/cli/tss.cpp
+++ b/src/cli/tss.cpp
@@ -42,8 +42,14 @@ class TSS_Split final : public Command
const size_t N = get_arg_sz("N");
const size_t M = get_arg_sz("M");
+ if(M <= 1 || N <= 1 || M > N || N >= 255)
+ throw CLI_Usage_Error("Invalid N/M parameters for secret splitting");
+
Botan::secure_vector<uint8_t> secret = slurp_file_lvec(input);
+ if(secret.size() > 0xFFFF)
+ throw CLI_Usage_Error("Secret is too large for this TSS format");
+
std::vector<uint8_t> id = Botan::hex_decode(id_str);
if(id.empty())
@@ -53,7 +59,9 @@ class TSS_Split final : public Command
}
std::vector<Botan::RTSS_Share> shares =
- Botan::RTSS_Share::split(M, N, secret.data(), secret.size(), id, hash_algo, rng());
+ Botan::RTSS_Share::split(static_cast<uint8_t>(M), static_cast<uint8_t>(N),
+ secret.data(), static_cast<uint16_t>(secret.size()),
+ id, hash_algo, rng());
for(size_t i = 0; i != shares.size(); ++i)
{