A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
onionmanager.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
3
4
/*
5
* Copyright (c) 2020 DLTLT
6
*
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License version 2 as
9
* published by the Free Software Foundation;
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
*
20
* Corresponding author: Niki Hrovatin <niki.hrovatin@famnit.upr.si>
21
*/
22
23
24
#ifndef ONIONMANAGER_H
25
#define ONIONMANAGER_H
26
27
#include <fstream>
28
#include <iostream>
29
#include <string.h>
30
#include <sodium.h>
31
#include <stdio.h>
32
33
#include "ns3/onion-routing.h"
34
#include "ns3/internet-module.h"
35
36
namespace
ns3
{
37
47
class
OnionManager
:
public
OnionRouting
48
{
49
public
:
54
static
TypeId
GetTypeId
(
void
);
55
61
OnionManager
();
62
68
~OnionManager
();
69
82
virtual
void
EncryptLayer
(
unsigned
char
*ciphertext,
unsigned
char
*message,
int
len,
83
unsigned
char
*key)
const
;
84
97
virtual
void
DecryptLayer
(
unsigned
char
*innerLayer,
unsigned
char
*onion, uint16_t onionLen,
98
unsigned
char
*pk,
unsigned
char
*sk)
const
;
99
105
void
GenerateNewKeyPair
(
void
);
113
unsigned
char
*
GetPK
(
void
);
121
unsigned
char
*
GetSK
(
void
);
122
130
std::string
GetPKtoString
();
138
std::string
GetSKtoString
();
139
147
void
SetPK
(
unsigned
char
*pk);
155
void
SetSK
(
unsigned
char
*sk);
156
166
unsigned
char
*
StringToUchar
(std::string in);
177
std::string
UcharToString
(
unsigned
char
*seq,
int
len);
178
188
unsigned
char
*
IpToBuff
(uint32_t in);
189
190
private
:
191
unsigned
char
m_publickey
[crypto_box_PUBLICKEYBYTES];
192
unsigned
char
m_secretkey
[crypto_box_SECRETKEYBYTES];
193
};
194
195
}
// namespace ns3
196
197
#endif
/* ONIONMANAGER_H */
ns3::OnionManager::IpToBuff
unsigned char * IpToBuff(uint32_t in)
Convert an Ipv4 address given as an unsigned integer value to buffer array of 4Bytes.
Definition:
onionmanager.cc:155
ns3::OnionManager::m_publickey
unsigned char m_publickey[crypto_box_PUBLICKEYBYTES]
the public encryption key
Definition:
onionmanager.h:191
ns3::OnionManager
Class that manages encryption keys and the encryption and decryption of layers of onion messagess The...
Definition:
onionmanager.h:47
ns3::OnionManager::GetPKtoString
std::string GetPKtoString()
accessor
Definition:
onionmanager.cc:103
ns3::OnionRouting
Abstract class for creation and decryption of Onion messages.
Definition:
onion-routing.h:29
ns3
Definition:
sensornode-helper.cc:26
ns3::OnionManager::m_secretkey
unsigned char m_secretkey[crypto_box_SECRETKEYBYTES]
the secret encryption key
Definition:
onionmanager.h:192
ns3::OnionManager::UcharToString
std::string UcharToString(unsigned char *seq, int len)
Convert an array of unsigned chars to a std::string.
Definition:
onionmanager.cc:147
ns3::OnionManager::StringToUchar
unsigned char * StringToUchar(std::string in)
Convert a string to an array of unsigned chars.
Definition:
onionmanager.cc:138
ns3::OnionManager::GetSKtoString
std::string GetSKtoString()
accessor
Definition:
onionmanager.cc:111
ns3::OnionManager::OnionManager
OnionManager()
Default constructor.
Definition:
onionmanager.cc:41
ns3::OnionManager::GetPK
unsigned char * GetPK(void)
accessor
Definition:
onionmanager.cc:88
ns3::OnionManager::GetTypeId
static TypeId GetTypeId(void)
Register this type.
Definition:
onionmanager.cc:34
ns3::OnionManager::EncryptLayer
virtual void EncryptLayer(unsigned char *ciphertext, unsigned char *message, int len, unsigned char *key) const
Implementing encryption using the libsodium library.
Definition:
onionmanager.cc:55
ns3::OnionManager::GenerateNewKeyPair
void GenerateNewKeyPair(void)
Generate a new public/private keypair using the libsodium library.
Definition:
onionmanager.cc:81
ns3::OnionManager::GetSK
unsigned char * GetSK(void)
accessor
Definition:
onionmanager.cc:96
ns3::OnionManager::SetSK
void SetSK(unsigned char *sk)
setter
Definition:
onionmanager.cc:126
ns3::OnionManager::DecryptLayer
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.
Definition:
onionmanager.cc:65
ns3::OnionManager::SetPK
void SetPK(unsigned char *pk)
setter
Definition:
onionmanager.cc:119
ns3::OnionManager::~OnionManager
~OnionManager()
Default destructor.
Definition:
onionmanager.cc:45
src
onion_routing_wsn
managers
onionmanager.h
Generated on Mon Feb 7 2022 13:31:58 for ns-3 by
1.8.17