Rename CryptoConnBase to CryptoPubConnBase
This commit is contained in:
16
crypto.cc
16
crypto.cc
@@ -130,11 +130,11 @@ std::ostream& CryptoBase::LogFatal(void *obj) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CryptoConnBase::CryptoConnBase(const std::string& secret_key)
|
CryptoPubConnBase::CryptoPubConnBase(const std::string& secret_key)
|
||||||
: secret_key_(secret_key),
|
: secret_key_(secret_key),
|
||||||
state_(AWAITING_HANDSHAKE) {}
|
state_(AWAITING_HANDSHAKE) {}
|
||||||
|
|
||||||
std::unique_ptr<TLVNode> CryptoConnBase::BuildSecureHandshake() {
|
std::unique_ptr<TLVNode> CryptoPubConnBase::BuildSecureHandshake() {
|
||||||
std::string ephemeral_public_key;
|
std::string ephemeral_public_key;
|
||||||
CryptoUtil::GenKeyPair(&ephemeral_secret_key_, &ephemeral_public_key);
|
CryptoUtil::GenKeyPair(&ephemeral_secret_key_, &ephemeral_public_key);
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ std::unique_ptr<TLVNode> CryptoConnBase::BuildSecureHandshake() {
|
|||||||
return CryptoUtil::EncodeEncrypt(secret_key_, peer_public_key_, secure_handshake);
|
return CryptoUtil::EncodeEncrypt(secret_key_, peer_public_key_, secure_handshake);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CryptoConnBase::HandleSecureHandshake(const TLVNode& node) {
|
bool CryptoPubConnBase::HandleSecureHandshake(const TLVNode& node) {
|
||||||
assert(node.GetType() == TLV_TYPE_ENCRYPTED);
|
assert(node.GetType() == TLV_TYPE_ENCRYPTED);
|
||||||
|
|
||||||
std::unique_ptr<TLVNode> decrypted(CryptoUtil::DecryptDecode(secret_key_, peer_public_key_, node));
|
std::unique_ptr<TLVNode> decrypted(CryptoUtil::DecryptDecode(secret_key_, peer_public_key_, node));
|
||||||
@@ -165,12 +165,12 @@ bool CryptoConnBase::HandleSecureHandshake(const TLVNode& node) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CryptoConnBase::OnReadable_(struct bufferevent* bev, void* this__) {
|
void CryptoPubConnBase::OnReadable_(struct bufferevent* bev, void* this__) {
|
||||||
auto this_ = (CryptoConnBase*)this__;
|
auto this_ = (CryptoPubConnBase*)this__;
|
||||||
this_->OnReadable();
|
this_->OnReadable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CryptoConnBase::OnReadable() {
|
void CryptoPubConnBase::OnReadable() {
|
||||||
char buf[UINT16_MAX];
|
char buf[UINT16_MAX];
|
||||||
int bytes = bufferevent_read(bev_, buf, UINT16_MAX);
|
int bytes = bufferevent_read(bev_, buf, UINT16_MAX);
|
||||||
const std::string input(buf, bytes);
|
const std::string input(buf, bytes);
|
||||||
@@ -249,7 +249,7 @@ void CryptoPubServer::Loop() {
|
|||||||
|
|
||||||
|
|
||||||
CryptoPubServerConnection::CryptoPubServerConnection(struct bufferevent* bev, const std::string& secret_key)
|
CryptoPubServerConnection::CryptoPubServerConnection(struct bufferevent* bev, const std::string& secret_key)
|
||||||
: CryptoConnBase(secret_key) {
|
: CryptoPubConnBase(secret_key) {
|
||||||
bev_ = bev;
|
bev_ = bev;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,7 +315,7 @@ void CryptoPubServerConnection::OnError(const short what) {
|
|||||||
|
|
||||||
|
|
||||||
CryptoPubClient::CryptoPubClient(struct sockaddr* addr, socklen_t addrlen, const std::string& secret_key, const std::string& server_public_key, const std::list<uint64_t>& channel_bitrates)
|
CryptoPubClient::CryptoPubClient(struct sockaddr* addr, socklen_t addrlen, const std::string& secret_key, const std::string& server_public_key, const std::list<uint64_t>& channel_bitrates)
|
||||||
: CryptoConnBase(secret_key),
|
: CryptoPubConnBase(secret_key),
|
||||||
event_base_(event_base_new()),
|
event_base_(event_base_new()),
|
||||||
channel_bitrates_(channel_bitrates) {
|
channel_bitrates_(channel_bitrates) {
|
||||||
bev_ = bufferevent_socket_new(event_base_, -1, BEV_OPT_CLOSE_ON_FREE);
|
bev_ = bufferevent_socket_new(event_base_, -1, BEV_OPT_CLOSE_ON_FREE);
|
||||||
|
|||||||
8
crypto.h
8
crypto.h
@@ -26,9 +26,9 @@ class CryptoBase {
|
|||||||
std::ostream& LogFatal(void *obj=nullptr);
|
std::ostream& LogFatal(void *obj=nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CryptoConnBase : public CryptoBase {
|
class CryptoPubConnBase : public CryptoBase {
|
||||||
protected:
|
protected:
|
||||||
CryptoConnBase(const std::string& secret_key);
|
CryptoPubConnBase(const std::string& secret_key);
|
||||||
|
|
||||||
std::unique_ptr<TLVNode> BuildSecureHandshake();
|
std::unique_ptr<TLVNode> BuildSecureHandshake();
|
||||||
bool HandleSecureHandshake(const TLVNode& node);
|
bool HandleSecureHandshake(const TLVNode& node);
|
||||||
@@ -69,7 +69,7 @@ class CryptoPubServer : public CryptoBase {
|
|||||||
const std::string secret_key_;
|
const std::string secret_key_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CryptoPubServerConnection : public CryptoConnBase {
|
class CryptoPubServerConnection : public CryptoPubConnBase {
|
||||||
public:
|
public:
|
||||||
CryptoPubServerConnection(struct bufferevent* bev, const std::string& secret_key);
|
CryptoPubServerConnection(struct bufferevent* bev, const std::string& secret_key);
|
||||||
~CryptoPubServerConnection();
|
~CryptoPubServerConnection();
|
||||||
@@ -86,7 +86,7 @@ class CryptoPubServerConnection : public CryptoConnBase {
|
|||||||
friend CryptoPubServer;
|
friend CryptoPubServer;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CryptoPubClient : public CryptoConnBase {
|
class CryptoPubClient : public CryptoPubConnBase {
|
||||||
public:
|
public:
|
||||||
CryptoPubClient(struct sockaddr* addr, socklen_t addrlen, const std::string& secret_key, const std::string& server_public_key, const std::list<uint64_t>& channel_bitrates);
|
CryptoPubClient(struct sockaddr* addr, socklen_t addrlen, const std::string& secret_key, const std::string& server_public_key, const std::list<uint64_t>& channel_bitrates);
|
||||||
~CryptoPubClient();
|
~CryptoPubClient();
|
||||||
|
|||||||
Reference in New Issue
Block a user