Start of a connection state machine, start of a TLV framework.
This commit is contained in:
12
Makefile
12
Makefile
@@ -3,11 +3,11 @@ all: auth-server gen-key gen-keypair
|
||||
%.o: %.cc
|
||||
g++ -std=c++11 -c -o $@ $<
|
||||
|
||||
auth-server: auth-server.o crypto.o
|
||||
g++ -o auth-server auth-server.o crypto.o nacl/build/instance1/lib/amd64/randombytes.o nacl/build/instance1/lib/amd64/libnacl.a
|
||||
auth-server: auth-server.o crypto.o tlv.o
|
||||
g++ -o auth-server auth-server.o crypto.o tlv.o nacl/build/instance1/lib/amd64/randombytes.o nacl/build/instance1/lib/amd64/libnacl.a
|
||||
|
||||
gen-key: gen-key.o crypto.o
|
||||
g++ -o gen-key gen-key.o crypto.o nacl/build/instance1/lib/amd64/randombytes.o nacl/build/instance1/lib/amd64/libnacl.a
|
||||
gen-key: gen-key.o crypto.o tlv.o
|
||||
g++ -o gen-key gen-key.o crypto.o tlv.o nacl/build/instance1/lib/amd64/randombytes.o nacl/build/instance1/lib/amd64/libnacl.a
|
||||
|
||||
gen-keypair: gen-keypair.o crypto.o
|
||||
g++ -o gen-keypair gen-keypair.o crypto.o nacl/build/instance1/lib/amd64/randombytes.o nacl/build/instance1/lib/amd64/libnacl.a
|
||||
gen-keypair: gen-keypair.o crypto.o tlv.o
|
||||
g++ -o gen-keypair gen-keypair.o crypto.o tlv.o nacl/build/instance1/lib/amd64/randombytes.o nacl/build/instance1/lib/amd64/libnacl.a
|
||||
|
||||
@@ -89,7 +89,8 @@ void CryptoPubServer::Loop() {
|
||||
|
||||
CryptoPubServerConnection::CryptoPubServerConnection(const int fd, const std::string secret_key)
|
||||
: CryptoBase(fd),
|
||||
secret_key_(secret_key) {
|
||||
secret_key_(secret_key),
|
||||
state_(AWAITING_HANDSHAKE) {
|
||||
}
|
||||
|
||||
void CryptoPubServerConnection::OnReadable() {
|
||||
|
||||
5
crypto.h
5
crypto.h
@@ -23,6 +23,11 @@ class CryptoPubServerConnection : public CryptoBase {
|
||||
private:
|
||||
const std::string secret_key_;
|
||||
const std::string ephemeral_secret_key_;
|
||||
const std::string client_public_key_;
|
||||
enum {
|
||||
AWAITING_HANDSHAKE,
|
||||
READY,
|
||||
} state_;
|
||||
};
|
||||
|
||||
class CryptoPubServer : public CryptoBase {
|
||||
|
||||
8
tlv.cc
Normal file
8
tlv.cc
Normal file
@@ -0,0 +1,8 @@
|
||||
#include "tlv.h"
|
||||
|
||||
TLVNode::TLVNode(const uint16_t type)
|
||||
: type_(type) {}
|
||||
|
||||
TLVNode::TLVNode(const uint16_t type, const std::string value)
|
||||
: type_(type),
|
||||
value_(value) {}
|
||||
18
tlv.h
Normal file
18
tlv.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
class TLVNode {
|
||||
public:
|
||||
TLVNode(const uint16_t type);
|
||||
TLVNode(const uint16_t type, const std::string value);
|
||||
|
||||
static TLVNode* Decode(const std::string& input);
|
||||
void Encode(std::string *output);
|
||||
|
||||
private:
|
||||
const uint16_t type_;
|
||||
const std::string value_;
|
||||
std::list<TLVNode> children_;
|
||||
};
|
||||
Reference in New Issue
Block a user