21 #ifndef QKDEncryptor_H
22 #define QKDEncryptor_H
27 #include "ns3/header.h"
28 #include "ns3/tcp-header.h"
29 #include "ns3/udp-header.h"
30 #include "ns3/icmpv4.h"
32 #include "ns3/dsdv-packet.h"
33 #include "ns3/aodv-packet.h"
34 #include "ns3/olsr-header.h"
36 #include "ns3/packet.h"
38 #include "ns3/object.h"
39 #include "ns3/callback.h"
40 #include "ns3/assert.h"
42 #include "ns3/deprecated.h"
43 #include "ns3/traced-value.h"
44 #include "ns3/packet-metadata.h"
45 #include "ns3/trace-source-accessor.h"
46 #include "ns3/qkd-buffer.h"
47 #include "ns3/qkd-key.h"
48 #include "ns3/net-device.h"
51 #include <crypto++/aes.h>
52 #include <crypto++/modes.h>
53 #include <crypto++/filters.h>
54 #include <crypto++/hex.h>
55 #include <crypto++/osrng.h>
56 #include <crypto++/ccm.h>
57 #include <crypto++/vmac.h>
58 #include <crypto++/iterhash.h>
59 #include <crypto++/secblock.h>
60 #include <crypto++/sha.h>
61 #include <cryptopp/base64.h>
64 typedef unsigned char byte;
65 #define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1
66 #include <crypto++/md5.h>
165 std::string
OTP (
const std::string& key,
const std::string&
data);
173 std::string
AESEncrypt (
const std::string& key,
const std::string&
data);
181 std::string
AESDecrypt (
const std::string& key,
const std::string&
data);
189 std::string
EncryptMsg(std::string input, std::string key);
197 std::string
DecryptMsg (std::string input, std::string key);
250 std::string
VMAC (std::string& key, std::string& inputString);
257 std::string
MD5 (std::string& inputString);
264 std::string
SHA1 (std::string& inputString);
268 byte m_iv [ CryptoPP::AES::BLOCKSIZE ];
A base class which provides memory management and object aggregation.
Introspection did not find any typical Config paths.
uint32_t m_index
An index in the qkd encryptor container.
bool m_encryptionEnabled
Execute the actual encryption algorithm?
std::string EncryptMsg(std::string input, std::string key)
Encrypt a plaintext.
std::string HexDecode(const std::string &data)
Decode the HEX string.
std::string AESEncrypt(const std::string &key, const std::string &data)
Encrypt data using AES algorithm.
EncryptionType
Encryption type.
uint32_t GetIndex()
Get the internal index identifier in the qkd encryptor container.
void SetNode(Ptr< Node > node)
Set node on which qkd encryptor is installed.
void SetIndex(uint32_t index)
Set the internal index identifier in the qkd encryptor container.
static TypeId GetTypeId(void)
Get the TypeId.
std::string Authenticate(std::string &data, std::string key="0")
Calculate an authentication tag on a message.
bool CheckAuthentication(std::string payload, std::string authTag, std::string key="0")
Authenticate the packet.
byte m_iv[CryptoPP::AES::BLOCKSIZE]
std::string Base64Decode(std::string input)
Base64 decoder.
TracedCallback< Ptr< Packet >, std::string > m_authenticationTrace
A trace callback for the authentication.
std::string VMAC(std::string &key, std::string &inputString)
Calculate authentication tag in Wegman-Carter fashion.
std::string OTP(const std::string &key, const std::string &data)
Apply the One-Time Pad cipher.
uint32_t m_authenticationTagLengthInBits
A length of the authentication tag in bits (32 by default).
std::string SHA1(std::string &inputString)
Calucale SHA1 authentication tag.
TracedCallback< Ptr< Packet >, std::string > m_deauthenticationTrace
A trace callback for the authentication check.
AuthenticationType m_authenticationType
The authentication algorithm.
Ptr< Node > m_node
A pointer to the node on which the encryptor is installed.
Ptr< Node > GetNode()
Get details about the node on which qkd encryptor is installed.
TracedCallback< Ptr< Packet > > m_decryptionTrace
A trace callback for the decryption.
AuthenticationType
Authentication type.
TracedCallback< Ptr< Packet > > m_encryptionTrace
A trace callback for the encryption.
QKDEncryptor(EncryptionType type1, AuthenticationType type2)
Constructor.
std::string HexEncode(const std::string &data)
Encode the string to the HEX string.
void ChangeSettings(EncryptionType type1, AuthenticationType type2, uint32_t authTagLength)
Constructor.
bool m_compressionEnabled
Should compression algorithms be used?
std::string DecryptMsg(std::string input, std::string key)
Decrypt a ciphertext.
std::string Base64Encode(std::string input)
Base64 encoder.
virtual ~QKDEncryptor()
Destructor.
EncryptionType m_encryptionType
The encryption algorithm.
std::string MD5(std::string &inputString)
Calculate MD5 authentication tag.
std::string AESDecrypt(const std::string &key, const std::string &data)
Decrypt data using AES algorithm.
Forward calls to a chain of Callback.
a unique identifier for an interface.
Every class exported by the ns3 library is enclosed in the ns3 namespace.