aboutsummaryrefslogtreecommitdiffstats
path: root/src/cli
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli')
-rw-r--r--src/cli/cc_enc.cpp2
-rw-r--r--src/cli/cli.h7
-rw-r--r--src/cli/tls_client.cpp12
-rw-r--r--src/cli/tls_server.cpp12
4 files changed, 18 insertions, 15 deletions
diff --git a/src/cli/cc_enc.cpp b/src/cli/cc_enc.cpp
index 25c9b960b..35932b487 100644
--- a/src/cli/cc_enc.cpp
+++ b/src/cli/cc_enc.cpp
@@ -75,7 +75,7 @@ uint64_t encrypt_cc_number(uint64_t cc_number,
const Botan::BigInt c = Botan::FPE::fe1_encrypt(n, cc_ranked, key, tweak);
if(c.bits() > 50)
- throw std::runtime_error("FPE produced a number too large");
+ throw Botan::Internal_Error("FPE produced a number too large");
uint64_t enc_cc = 0;
for(size_t i = 0; i != 7; ++i)
diff --git a/src/cli/cli.h b/src/cli/cli.h
index b2be2bd39..d079afbc5 100644
--- a/src/cli/cli.h
+++ b/src/cli/cli.h
@@ -9,6 +9,8 @@
#include <botan/build.h>
#include <botan/parsing.h>
+#include <botan/rng.h>
+
#include <fstream>
#include <iostream>
#include <functional>
@@ -492,10 +494,11 @@ class Command
if(reg.count(name) > 0)
{
- throw std::logic_error("Duplicated registration of command " + name);
+ throw CLI_Error("Duplicated registration of command " + name);
}
- Command::global_registry().insert(std::make_pair(name, std::unique_ptr<Command>(cmd)));
+ Command::global_registry().insert(
+ std::make_pair(name, std::unique_ptr<Command>(cmd)));
}
};
};
diff --git a/src/cli/tls_client.cpp b/src/cli/tls_client.cpp
index c13e9019e..1f69473c1 100644
--- a/src/cli/tls_client.cpp
+++ b/src/cli/tls_client.cpp
@@ -198,16 +198,16 @@ class TLS_Client : public Command
hostent* host_addr = ::gethostbyname(host.c_str());
if(!host_addr)
- throw std::runtime_error("gethostbyname failed for " + host);
+ throw CLI_Error("gethostbyname failed for " + host);
if(host_addr->h_addrtype != AF_INET) // FIXME
- throw std::runtime_error(host + " has IPv6 address, not supported");
+ throw CLI_Error(host + " has IPv6 address, not supported");
int type = tcp ? SOCK_STREAM : SOCK_DGRAM;
int fd = ::socket(PF_INET, type, 0);
if(fd == -1)
- throw std::runtime_error("Unable to acquire socket");
+ throw CLI_Error("Unable to acquire socket");
sockaddr_in socket_info;
::memset(&socket_info, 0, sizeof(socket_info));
@@ -223,7 +223,7 @@ class TLS_Client : public Command
if(::connect(fd, (sockaddr*)&socket_info, sizeof(struct sockaddr)) != 0)
{
::close(fd);
- throw std::runtime_error("connect failed");
+ throw CLI_Error("connect failed");
}
return fd;
@@ -248,7 +248,7 @@ class TLS_Client : public Command
int r = send(sockfd, buf, length, MSG_NOSIGNAL);
if(r == -1)
- throw std::runtime_error("Socket write failed errno=" + std::to_string(errno));
+ throw CLI_Error("Socket write failed errno=" + std::to_string(errno));
}
static void stream_socket_write(int sockfd, const uint8_t buf[], size_t length)
@@ -265,7 +265,7 @@ class TLS_Client : public Command
if(errno == EINTR)
sent = 0;
else
- throw std::runtime_error("Socket write failed errno=" + std::to_string(errno));
+ throw CLI_Error("Socket write failed errno=" + std::to_string(errno));
}
offset += sent;
diff --git a/src/cli/tls_server.cpp b/src/cli/tls_server.cpp
index 6a5b4e812..f6a3a311e 100644
--- a/src/cli/tls_server.cpp
+++ b/src/cli/tls_server.cpp
@@ -79,10 +79,10 @@ class TLS_Server : public Command
if(::recvfrom(server_fd, nullptr, 0, MSG_PEEK,
(struct sockaddr*)&from, &from_len) != 0)
- throw std::runtime_error("Could not peek next packet");
+ throw CLI_Error("Could not peek next packet");
if(::connect(server_fd, (struct sockaddr*)&from, from_len) != 0)
- throw std::runtime_error("Could not connect UDP socket");
+ throw CLI_Error("Could not connect UDP socket");
fd = server_fd;
}
@@ -161,7 +161,7 @@ class TLS_Server : public Command
int fd = ::socket(PF_INET, type, 0);
if(fd == -1)
- throw std::runtime_error("Unable to acquire socket");
+ throw CLI_Error("Unable to acquire socket");
sockaddr_in socket_info;
::memset(&socket_info, 0, sizeof(socket_info));
@@ -174,7 +174,7 @@ class TLS_Server : public Command
if(::bind(fd, (sockaddr*)&socket_info, sizeof(struct sockaddr)) != 0)
{
::close(fd);
- throw std::runtime_error("server bind failed");
+ throw CLI_Error("server bind failed");
}
if(is_tcp)
@@ -182,7 +182,7 @@ class TLS_Server : public Command
if(::listen(fd, 100) != 0)
{
::close(fd);
- throw std::runtime_error("listen failed");
+ throw CLI_Error("listen failed");
}
}
@@ -224,7 +224,7 @@ class TLS_Server : public Command
if(errno == EINTR)
sent = 0;
else
- throw std::runtime_error("Socket write failed");
+ throw CLI_Error("Socket write failed");
}
buf += sent;