aboutsummaryrefslogtreecommitdiffstats
path: root/src/cmd
diff options
context:
space:
mode:
authorlloyd <[email protected]>2014-01-18 18:17:08 +0000
committerlloyd <[email protected]>2014-01-18 18:17:08 +0000
commitb96ad4c05c0a8f835b54ef4e2cff849c749409b0 (patch)
treed8a5805e6d85cd66d2336f624f0cbeaaf1d5bed3 /src/cmd
parent6b457468faa88180142de9bd2ba0fee90be43463 (diff)
Split off the keyed interfaces of transform to Keyed_Transform
Remove the unhelpful 'Algorithm' base class which had previously acted more or less as a global base.
Diffstat (limited to 'src/cmd')
-rw-r--r--src/cmd/speed/speed.cpp7
-rw-r--r--src/cmd/tls_client.cpp4
2 files changed, 6 insertions, 5 deletions
diff --git a/src/cmd/speed/speed.cpp b/src/cmd/speed/speed.cpp
index 2e3d2c6fa..9deb9cc63 100644
--- a/src/cmd/speed/speed.cpp
+++ b/src/cmd/speed/speed.cpp
@@ -133,9 +133,6 @@ void time_transform(std::unique_ptr<Transformation> tf,
if(!tf)
return;
- if(tf->maximum_keylength() > 0)
- tf->set_key(rng.random_vec(tf->maximum_keylength()));
-
for(size_t buf_size : { 16, 64, 256, 1024, 8192 })
{
secure_vector<byte> buffer(buf_size);
@@ -158,6 +155,10 @@ void time_transform(const std::string& algo, RandomNumberGenerator& rng)
{
std::unique_ptr<Transformation> tf;
tf.reset(get_aead(algo, ENCRYPTION));
+
+ if(Keyed_Transform* keyed = dynamic_cast<Keyed_Transform*>(tf.get()))
+ keyed->set_key(rng.random_vec(keyed->key_spec().maximum_keylength()));
+
time_transform(std::move(tf), rng);
}
diff --git a/src/cmd/tls_client.cpp b/src/cmd/tls_client.cpp
index 7f201d5a9..b7c4f619f 100644
--- a/src/cmd/tls_client.cpp
+++ b/src/cmd/tls_client.cpp
@@ -36,11 +36,11 @@ int connect_to_host(const std::string& host, u16bit port, const std::string& tra
{
hostent* host_addr = ::gethostbyname(host.c_str());
- if(host_addr == 0)
+ if(!host_addr)
throw std::runtime_error("gethostbyname failed for " + host);
if(host_addr->h_addrtype != AF_INET) // FIXME
- throw std::runtime_error(host + " has IPv6 address");
+ throw std::runtime_error(host + " has IPv6 address, not supported");
int type = (transport == "tcp") ? SOCK_STREAM : SOCK_DGRAM;