Class that manages encryption keys and the encryption and decryption of layers of onion messagess The class is implementing the OnionRouting abstract class with the encryption and decryption methods. More...
#include "onionmanager.h"
Inheritance diagram for ns3::OnionManager:
Collaboration diagram for ns3::OnionManager:Public Member Functions | |
| OnionManager () | |
| Default constructor. More... | |
| ~OnionManager () | |
| Default destructor. More... | |
| virtual void | DecryptLayer (unsigned char *innerLayer, unsigned char *onion, uint16_t onionLen, unsigned char *pk, unsigned char *sk) const |
| Implementing decryption using the libsodium library. More... | |
| virtual void | EncryptLayer (unsigned char *ciphertext, unsigned char *message, int len, unsigned char *key) const |
| Implementing encryption using the libsodium library. More... | |
| void | GenerateNewKeyPair (void) |
| Generate a new public/private keypair using the libsodium library. More... | |
| unsigned char * | GetPK (void) |
| accessor More... | |
| std::string | GetPKtoString () |
| accessor More... | |
| unsigned char * | GetSK (void) |
| accessor More... | |
| std::string | GetSKtoString () |
| accessor More... | |
| unsigned char * | IpToBuff (uint32_t in) |
| Convert an Ipv4 address given as an unsigned integer value to buffer array of 4Bytes. More... | |
| void | SetPK (unsigned char *pk) |
| setter More... | |
| void | SetSK (unsigned char *sk) |
| setter More... | |
| unsigned char * | StringToUchar (std::string in) |
| Convert a string to an array of unsigned chars. More... | |
| std::string | UcharToString (unsigned char *seq, int len) |
| Convert an array of unsigned chars to a std::string. More... | |
Public Member Functions inherited from ns3::OnionRouting | |
| OnionRouting () | |
| OnionRouting (uint16_t keySize, uint16_t sealPadding, uint16_t addressSize) | |
| OnionRouting (uint16_t sealPadding, const uint16_t protocolNumber) | |
| Constructor – Setup parameters for the creation of onions. More... | |
| virtual | ~OnionRouting () |
| void | AddressToStream (uint8_t *ip) |
| void | AddressToStream (uint8_t *ip) |
| Output an ip address to a stream variable, used to LOG the onion message. More... | |
| int | BuildOnion (uint8_t *cipher, uint8_t **route, uint16_t routeLen, uint8_t **keys, uint8_t *content, uint16_t contentLen) |
| void | BuildOnion (uint8_t *cipher, uint8_t **route, uint8_t **keys, uint16_t routeLen) |
| Manage construction of the onion ONION_NO_CONTENT. More... | |
| void | BuildOnion (uint8_t *cipher, uint8_t **route, uint8_t **keys, uint16_t routeLen, uint8_t *endContent, uint16_t endContentLen) |
| Manage construction of the onion ONION_ENDCONTENT. More... | |
| void | BuildOnion (uint8_t *cipher, uint8_t **route, uint8_t **keys, uint8_t **layerContent, uint16_t layerContentLen, uint16_t routeLen) |
| Manage construction of the onion ONION_LAYERCONTENT. More... | |
| void | BuildOnion (uint8_t *cipher, uint8_t **route, uint8_t **keys, uint8_t **layerContent, uint16_t layerContentLen, uint16_t routeLen, uint8_t *endContent, uint16_t endContentLen) |
| Manage construction of the onion ONION_LAYERCONTENT_ENDCONTENT. More... | |
| int | CreateOnion (uint8_t *cipher, uint8_t **route, uint16_t index, uint16_t routeLen, uint8_t **keys, uint8_t *content, uint16_t contentLen) |
| void | CreateOnion (uint8_t *cipher, uint8_t **route, uint8_t **keys, uint16_t index, uint16_t routeLen, uint8_t **layerContent, uint16_t layerContentLen, uint8_t *endContent, uint16_t endContentLen) |
| Constructs the onion message *. More... | |
| virtual void | DecryptLayer (uint8_t *innerLayer, uint8_t *onion, uint16_t onionLen, uint8_t *pk, uint8_t *sk) const =0 |
| virtual void | DecryptLayer (uint8_t *plaintext, uint8_t *ciphertext, uint16_t len, uint8_t *publicKey, uint8_t *secretKey) const =0 |
| virtual method, implement decryption More... | |
| virtual void | EncryptLayer (uint8_t *ciphertext, uint8_t *message, int len, uint8_t *key) const =0 |
| virtual void | EncryptLayer (uint8_t *ciphertext, uint8_t *plaintext, int len, uint8_t *key) const =0 |
| virtual method, implement encryption More... | |
| enum OnionErrno | GetErrno (void) |
| Return the last error code of the OnionErrno enum. More... | |
| uint16_t | OnionLength (uint16_t routeLen, uint16_t contentLen) |
| uint16_t | OnionLength (uint16_t routeLen, uint16_t layerContentLen, uint16_t endContentLen) |
| Compute the length in bytes of the onion message at given parameters. More... | |
| orLayer * | PeelOnion (uint8_t *onion, uint16_t onionLen, uint8_t *pk, uint8_t *sk) |
| orLayer * | PeelOnion (uint8_t *onion, uint16_t onionLen, uint8_t *publicKey, uint8_t *secretKey) |
| Decipher the outer layer of the onion and return details. More... | |
Static Public Member Functions | |
| static TypeId | GetTypeId (void) |
| Register this type. More... | |
Static Public Member Functions inherited from ns3::OnionRouting | |
| static TypeId | GetTypeId (void) |
| static TypeId | GetTypeId (void) |
| Register this type. More... | |
Private Attributes | |
| unsigned char | m_publickey [crypto_box_PUBLICKEYBYTES] |
| the public encryption key More... | |
| unsigned char | m_secretkey [crypto_box_SECRETKEYBYTES] |
| the secret encryption key More... | |
Additional Inherited Members | |
Public Types inherited from ns3::OnionRouting | |
| enum | OnionErrno { ERROR_NOTERROR, ERROR_PROT_NUMBER, ERROR_ROUTE_TO_SHORT, ERROR_ENCRYPTION, ERROR_DECRYPTION } |
| Enumeration of the possible errors using the class onion-routing. More... | |
Public Attributes inherited from ns3::OnionRouting | |
| uint16_t | m_addressSize |
| size in bytes of the used address type (4-Ipv4, 16-Ipv6) More... | |
| enum OnionErrno | m_errno |
| error status while using the onion class More... | |
| uint16_t | m_keySize |
| std::stringstream | m_onionStream |
| stringstream used to LOG onion construction More... | |
| uint16_t | m_sealPadding |
| size increase of the ciphertext in bytes, intorduced by the encryption method More... | |
Class that manages encryption keys and the encryption and decryption of layers of onion messagess The class is implementing the OnionRouting abstract class with the encryption and decryption methods.
Definition at line 47 of file onionmanager.h.
| ns3::OnionManager::OnionManager | ( | ) |
Default constructor.
Definition at line 41 of file onionmanager.cc.
| ns3::OnionManager::~OnionManager | ( | ) |
Default destructor.
Definition at line 45 of file onionmanager.cc.
|
virtual |
Implementing decryption using the libsodium library.
| [in,out] | innerLayer | memory on which the inner onion layer will be stored |
| [in] | onion | memory locations containing the data to be decrypted |
| [in] | len | length in bytes of the onion |
| [in] | pk | pointer to the public encryption key |
| [in] | sk | pointer to the secret encryption key |
Definition at line 65 of file onionmanager.cc.
|
virtual |
Implementing encryption using the libsodium library.
implement onion routing class
| [in,out] | ciphertext | memory on which the ciphertext will be stored |
| [in] | mesage | memory locations containing the data to be encrypted |
| [in] | len | length in bytes of the plaintext |
| [in] | key | pointer to the encryption key |
Definition at line 55 of file onionmanager.cc.
| void ns3::OnionManager::GenerateNewKeyPair | ( | void | ) |
Generate a new public/private keypair using the libsodium library.
handling encryption keys
Definition at line 81 of file onionmanager.cc.
References m_publickey, and m_secretkey.
Referenced by ns3::Sink::StartApplication(), and ns3::SensorNode::StartApplication().
Here is the caller graph for this function:| unsigned char * ns3::OnionManager::GetPK | ( | void | ) |
accessor
Definition at line 88 of file onionmanager.cc.
References m_publickey.
Referenced by ns3::SensorNode::ProcessOnionHead().
Here is the caller graph for this function:| std::string ns3::OnionManager::GetPKtoString | ( | ) |
accessor
Definition at line 103 of file onionmanager.cc.
References m_publickey.
Referenced by ns3::SensorNode::Handshake(), and ns3::Sink::StartApplication().
Here is the caller graph for this function:| unsigned char * ns3::OnionManager::GetSK | ( | void | ) |
accessor
Definition at line 96 of file onionmanager.cc.
References m_secretkey.
Referenced by ns3::SensorNode::ProcessOnionHead().
Here is the caller graph for this function:| std::string ns3::OnionManager::GetSKtoString | ( | ) |
accessor
Definition at line 111 of file onionmanager.cc.
References m_secretkey.
Referenced by ns3::Sink::StartApplication().
Here is the caller graph for this function:
|
static |
| unsigned char * ns3::OnionManager::IpToBuff | ( | uint32_t | in | ) |
Convert an Ipv4 address given as an unsigned integer value to buffer array of 4Bytes.
| [in] | in | an Ipv4 address given as an unsigned integer value |
Definition at line 155 of file onionmanager.cc.
Referenced by ns3::Sink::PrepareOnion().
Here is the caller graph for this function:| void ns3::OnionManager::SetPK | ( | unsigned char * | pk | ) |
setter
| [in] | pk | pointer to the public encryption key |
Definition at line 119 of file onionmanager.cc.
References m_publickey.
| void ns3::OnionManager::SetSK | ( | unsigned char * | sk | ) |
setter
| [in] | pk | pointer to the secret encryption key |
Definition at line 126 of file onionmanager.cc.
References m_secretkey.
| unsigned char * ns3::OnionManager::StringToUchar | ( | std::string | in | ) |
Convert a string to an array of unsigned chars.
Other methods.
| [in] | in | a std::string |
Definition at line 138 of file onionmanager.cc.
Referenced by ns3::Sink::PrepareOnion(), and ns3::SensorNode::ProcessOnionHead().
Here is the caller graph for this function:| std::string ns3::OnionManager::UcharToString | ( | unsigned char * | seq, |
| int | len | ||
| ) |
Convert an array of unsigned chars to a std::string.
| [in] | seq | an array of unsigned chars |
| [in] | len | the length of the seq the array of unsigned chars |
Definition at line 147 of file onionmanager.cc.
Referenced by ns3::SensorNode::ProcessOnionHead(), and ns3::Sink::SendOnion().
Here is the caller graph for this function:
|
private |
the public encryption key
Definition at line 191 of file onionmanager.h.
Referenced by GenerateNewKeyPair(), GetPK(), GetPKtoString(), and SetPK().
|
private |
the secret encryption key
Definition at line 192 of file onionmanager.h.
Referenced by GenerateNewKeyPair(), GetSK(), GetSKtoString(), and SetSK().