diff options
author | Jack Lloyd <[email protected]> | 2016-03-19 22:52:48 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2016-03-20 09:38:22 -0400 |
commit | b8966d0f89e520cecf3e822241aef38ed9a6d876 (patch) | |
tree | 9b5c0f6afa89e8e91ef230e3d7824b10e037802c /src/cli/tls_server.cpp | |
parent | ada363473a9491a3b07e3bb6fa2b5fd9f12aec98 (diff) |
Clean up PK decryption encoding.
Previously RSA and ElGamal stripped off leading zeros which were then
assumed by the padding decoders. Instead have them produce ciphertexts
with leading zeros. Changes EME_Raw to strip leading zeros to match
existing behavior.
Diffstat (limited to 'src/cli/tls_server.cpp')
-rw-r--r-- | src/cli/tls_server.cpp | 49 |
1 files changed, 28 insertions, 21 deletions
diff --git a/src/cli/tls_server.cpp b/src/cli/tls_server.cpp index 2ccacb1f7..2496f5508 100644 --- a/src/cli/tls_server.cpp +++ b/src/cli/tls_server.cpp @@ -117,35 +117,42 @@ class TLS_Server final : public Command protocol_chooser, !is_tcp); - while(!server.is_closed()) + try { - uint8_t buf[4*1024] = { 0 }; - ssize_t got = ::read(fd, buf, sizeof(buf)); - - if(got == -1) + while(!server.is_closed()) { - std::cout << "Error in socket read - " << strerror(errno) << std::endl; - break; - } + uint8_t buf[4*1024] = { 0 }; + ssize_t got = ::read(fd, buf, sizeof(buf)); - if(got == 0) - { - std::cout << "EOF on socket" << std::endl; - break; - } + if(got == -1) + { + std::cout << "Error in socket read - " << strerror(errno) << std::endl; + break; + } + + if(got == 0) + { + std::cout << "EOF on socket" << std::endl; + break; + } - server.received_data(buf, got); + server.received_data(buf, got); - while(server.is_active() && !pending_output.empty()) - { - std::string output = pending_output.front(); - pending_output.pop_front(); - server.send(output); + while(server.is_active() && !pending_output.empty()) + { + std::string output = pending_output.front(); + pending_output.pop_front(); + server.send(output); - if(output == "quit\n") - server.close(); + if(output == "quit\n") + server.close(); + } } } + catch(Botan::Exception& e) + { + error_output() << "Connection failed: " << e.what() << "\n"; + } if(is_tcp) ::close(fd); |