Switch to unique_ptr for ownership clarity in places, combine more code.

This commit is contained in:
Ian Gulliver
2015-02-07 15:07:34 -08:00
parent 844db000f6
commit d82cb789e3
4 changed files with 56 additions and 71 deletions

View File

@@ -16,8 +16,8 @@ class CryptoUtil {
static void ReadKeyFromFile(const std::string& filename, std::string* key);
static void WriteKeyToFile(const std::string& filename, const std::string& key);
static void EncodeEncryptAppend(const std::string& secret_key, const std::string& public_key, const TLVNode& input, TLVNode* container);
static TLVNode *DecryptDecode(const std::string& secret_key, const std::string& public_key, const TLVNode& input);
static std::unique_ptr<TLVNode> EncodeEncrypt(const std::string& secret_key, const std::string& public_key, const TLVNode& input);
static std::unique_ptr<TLVNode> DecryptDecode(const std::string& secret_key, const std::string& public_key, const TLVNode& input);
};
class CryptoBase {
@@ -30,6 +30,9 @@ class CryptoConnBase : public CryptoBase {
protected:
CryptoConnBase(const std::string& secret_key);
std::unique_ptr<TLVNode> BuildSecureHandshake();
bool HandleSecureHandshake(const TLVNode& node);
enum {
AWAITING_HANDSHAKE,
READY,