2017-02-01 12:52:09 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-02-01 17:14:52 +00:00
|
|
|
#include "libp2p/crypto/key.h"
|
2017-02-02 19:10:12 +00:00
|
|
|
#include "libp2p/crypto/rsa.h"
|
2017-02-01 17:14:52 +00:00
|
|
|
|
2017-02-01 12:52:09 +00:00
|
|
|
/**
|
|
|
|
* A secure connection
|
|
|
|
*/
|
|
|
|
|
2017-02-02 19:10:12 +00:00
|
|
|
enum IPTrafficType { TCP, UDP };
|
|
|
|
|
2017-02-01 12:52:09 +00:00
|
|
|
struct SecureSession {
|
2017-02-02 19:10:12 +00:00
|
|
|
// to get the connection started
|
|
|
|
char* host;
|
|
|
|
int port;
|
|
|
|
enum IPTrafficType traffic_type;
|
|
|
|
// once the connection is established
|
2017-02-01 12:52:09 +00:00
|
|
|
int socket_descriptor;
|
2017-02-01 17:14:52 +00:00
|
|
|
struct PublicKey remote_key;
|
2017-02-02 19:10:12 +00:00
|
|
|
char* remote_peer_id;
|
2017-02-01 12:52:09 +00:00
|
|
|
};
|
2017-02-02 19:10:12 +00:00
|
|
|
|
|
|
|
/***
|
|
|
|
* performs initial communication over an insecure channel to share
|
|
|
|
* keys, IDs, and initiate connection. This is a framed messaging system
|
|
|
|
* @param session the secure session to be filled
|
|
|
|
* @returns true(1) on success, false(0) otherwise
|
|
|
|
*/
|
|
|
|
int libp2p_secio_handshake(struct SecureSession* session, struct RsaPrivateKey* private_key);
|