A Discrete-Event Network Simulator
API
onion-routing-example.cc
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 * Author: Niki Hrovatin <niki.hrovatin@famnit.upr.si>
21 */
22 
23 
24 
25 /*
26  * Example of implementation and use of the OnionRouting class
27  *
28  *
29  * The given example can be used to construct onion messages of the following features:
30  * 0- ONION_NO_CONTENT - onion message including only routing information
31  * 1- ONION_ENDCONTENT - onion message including content to be delivered to the last node in the path
32  * 2- ONION_LAYERCONTENT - onion message including a content of fixed length (in bytes) in each layer
33  * 3- ONION_LAYERCONTENT_ENDCONTENT - onion message including a content of fixed length in each layer and
34  * content of arbitrary length to be delivered to the last node in the path
35  *
36  * The listed onion messagess are selected through the cmd argument onionMode. This argument defines the mode of operation of the example code.
37  * (The value preceeding the name should be given to the cmd argument)
38  *
39  * !!NOTE!! the given example uses the external library <a href="https://libsodium.gitbook.io/doc/">libsodium</a> for encryption and decryption.
40  *
41  *
42  * Network topology
43  *
44  *
45  *
46  *
47  * n2-------------n3
48  * / \ /
49  * / \(1Mbps,3ms)/
50  * / \ /
51  * (5Mbps,2ms)/ \ /
52  * / \ /
53  * / \ /
54  * / \ /
55  * n0-----------n1 n4----------n5
56  * (5Mbps,2ms) (5Mbps,2ms)
57  *
58  *
59  * - all links are point-to-point links with indicated delay
60  * - onion messagess are sent using the UDP protocol
61  *
62  * Instructions:
63  * 1) Download & setup libsodium library
64  * 2) run in terminal: ./waf --run "src/internet-apps/examples/onion-routing-example.cc --onionMode=1"
65  * --note~ the argument onionMode defines the mode of operation of the example -- see the upper list
66  *
67  *
68  */
69 
71 
72 
73 #include "ns3/point-to-point-module.h"
74 #include "ns3/internet-module.h"
75 #include "ns3/onion-routing.h"
76 #include "ns3/applications-module.h"
77 
78 
79 #include <sodium.h>
80 
81 #define ONION_NO_CONTENT 0
82 #define ONION_ENDCONTENT 1
83 #define ONION_LAYERCONTENT 2
84 #define ONION_LAYERCONTENT_ENDCONTENT 3
85 
86 
87 
88 using namespace ns3;
89 
90 
91 NS_LOG_COMPONENT_DEFINE ("OnionRoutingExample");
92 
93 
94 //Serialize an Ipv4Address
95 uint8_t * IpToBuff (Ipv4Address in)
96 {
97  uint8_t * out = new uint8_t[4];
98  in.Serialize (&out[0]);
99  return out;
100 }
101 
102 //Construct Ipv4 address from the serialized form
103 Ipv4Address ConstructIpv4 (uint8_t * buf)
104 {
105  uint32_t ip = 0;
106 
107  ip += buf[0];
108  ip = ip << 8;
109  ip += buf[1];
110  ip = ip << 8;
111  ip += buf[2];
112  ip = ip << 8;
113  ip += buf[3];
114 
115  return Ipv4Address (ip);
116 }
117 
118 
119 
120 //Serialize a string
121 uint8_t * StringToUchar (std::string in)
122 {
123  uint8_t * out = new uint8_t[in.length ()];
124  memcpy (&out[0], &in[0], in.length ());
125  return out;
126 }
127 
128 //Deserialize a string
129 std::string UcharToString (uint8_t* seq, int len)
130 {
131  std::string strForm (&seq[0], &seq[0] + len);
132  return strForm;
133 }
134 
135 
136 
137 
138 //Class that implements the Onion Routing class using the libsodium lybrary
139 class OnionManager : public OnionRouting
140 {
141 public:
142  //get the typeid
143  static TypeId GetTypeId (void);
144  //constructor, need to setup encryption params
145  OnionManager ();
146  //dummy destructor
147  ~OnionManager ();
148 
149  //Generate new key pair
150  void GenerateNewKeyPair ();
151 
152  //return pk
153  uint8_t * GetPublicKey ();
154  //return sk
155  uint8_t * GetSecretKey ();
156 
157  //implement encryption
158  virtual void EncryptLayer (uint8_t * ciphertext, uint8_t* message, int len, uint8_t * key) const;
159  //implement decryption
160  virtual void DecryptLayer (uint8_t * innerLayer, uint8_t* onion, uint16_t onionLen, uint8_t * pk, uint8_t * sk) const;
161 
162  //the publickey
163  uint8_t m_publickey[crypto_box_PUBLICKEYBYTES];
164  //the secretkey
165  uint8_t m_secretkey[crypto_box_SECRETKEYBYTES];
166 };
167 
168 
169 TypeId
171 {
172  static TypeId tid = TypeId ("ns3::OnionManager")
173  .SetParent<OnionRouting> ()
174  .SetGroupName ("OnionRouting");
175  return tid;
176 
177 }
178 
179 
180 
181 
183  : OnionRouting (crypto_box_SEALBYTES,Ipv4L3Protocol::PROT_NUMBER)
184 {}
185 
186 
187 
188 OnionManager::~OnionManager ()
189 {}
190 
191 
193 {
194  crypto_box_keypair (m_publickey, m_secretkey);
195 }
196 
197 uint8_t * OnionManager::GetPublicKey ()
198 {
199  return m_publickey;
200 }
201 
202 uint8_t * OnionManager::GetSecretKey ()
203 {
204  return m_secretkey;
205 }
206 
207 
208 void OnionManager::EncryptLayer (uint8_t * ciphertext, uint8_t* message, int len, uint8_t * key) const
209 {
210  if (crypto_box_seal (ciphertext, message, len, key) != 0)
211  {
212  NS_LOG_WARN ("Error during encryption");
214  }
215 }
216 
217 
218 
219 void OnionManager::DecryptLayer (uint8_t * innerLayer, uint8_t* onion, uint16_t onionLen, uint8_t * pk, uint8_t * sk) const
220 {
221  if (crypto_box_seal_open (innerLayer, onion, onionLen, pk, sk) != 0)
222  {
223  NS_LOG_WARN ("Messge corrupted or not for this node");
225  }
226 }
227 
228 
229 
230 
231 
232 //Application to be installed on nodes
233 class MyApp : public Application
234 {
235 public:
236  MyApp (); //constructor
237  MyApp (uint8_t onionMode,uint16_t layerContentLen); //constructor to setup onionMode and layerContent
238  virtual ~MyApp (); //destructor
239 
240  static TypeId GetTypeId (void);//return the typeid
241 
242  //return the pk
243  uint8_t * GetPublicKey ();
244  //return ip address of the node
245  Ipv4Address GetAddress ();
246  //Setting up encryption & address
247  void Setup ();
248  void SetRoute (uint16_t routeLen, uint8_t ** ipRoute, uint8_t ** keys, uint8_t ** layerContent, uint8_t layerContentLen);
249 
250 private:
251  virtual void StartApplication (void);
252  virtual void StopApplication (void);
253 
254  void SendOnion ();
255  void RecvOnion (Ptr<Socket> socket);
256 
257  Ptr<Socket> m_socket;
258  Address m_peer;
259  uint16_t m_port;
260  Ipv4Address m_address;
261  OnionManager m_onionManager;
262  uint8_t m_onionMode;
263  uint16_t m_routeLen;
264  uint8_t ** m_ipRoute;
265  uint8_t ** m_keys;
266  uint8_t ** m_layerContent;
267  uint16_t m_layerContentLen;
268 
269 };
270 
271 MyApp::MyApp ()
272  : m_socket (0),
273  m_peer (),
274  m_port (4242),
275  m_routeLen (0)
276 {}
277 
278 
279 //setup onion mode and length of data to be encrypted in layers
280 MyApp::MyApp (uint8_t onionMode,uint16_t layerContentLen)
281  : m_socket (0),
282  m_peer (),
283  m_port (4242),
284  m_onionMode (onionMode),
285  m_routeLen (0),
286  m_layerContentLen (layerContentLen)
287 {}
288 
289 
290 MyApp::~MyApp ()
291 {
292  m_socket = 0;
293 }
294 
295 
296 
297 
298 uint8_t * MyApp::GetPublicKey ()
299 {
300  return m_onionManager.GetPublicKey ();
301 }
302 
303 Ipv4Address MyApp::GetAddress ()
304 {
305  return m_address;
306 }
307 
308 
309 
310 void MyApp::Setup ()
311 {
312 
313  //setup encryption
314  m_onionManager.GenerateNewKeyPair ();
315 
316 
317  //Get node details
318  Ptr<Node> PtrNode = this->GetNode ();
319  Ptr<Ipv4> ipv4 = PtrNode->GetObject<Ipv4> ();
320  Ipv4InterfaceAddress iaddr = ipv4->GetAddress (1, 0);
321  m_address = iaddr.GetLocal ();
322 
323 }
324 
325 //called only on the node who will send the onion
326 //used to set-up the route and content of the onion message
327 void MyApp::SetRoute (uint16_t routeLen, uint8_t ** ipRoute, uint8_t ** keys, uint8_t ** layerContent, uint8_t layerContentLen)
328 {
329  m_routeLen = routeLen;
330  m_ipRoute = ipRoute;
331  m_keys = keys;
332  m_layerContent = layerContent;
333  m_layerContentLen = layerContentLen;
334 }
335 
336 
337 
338 /* static */
339 TypeId MyApp::GetTypeId (void)
340 {
341  static TypeId tid = TypeId ("MyApp")
342  .SetParent<Application> ()
343  .SetGroupName ("ORexample")
344  .AddConstructor<MyApp> ()
345  ;
346  return tid;
347 }
348 
349 
350 //Construct and send the onion made using the class Onion Routing
351 void
352 MyApp::SendOnion ()
353 {
354 
355  //set the content of the onion message
356  std::string s ("Some content to send anonymously.");
357  uint8_t * content = StringToUchar (s);
358  uint16_t contentLen = s.length ();
359 
360  int cipherLen = 0;
361  uint8_t * cipher;
362 
363  //Construct the onion based on the selected mode
364  if (m_onionMode == ONION_NO_CONTENT)
365  {
366  cipherLen = m_onionManager.OnionLength (m_routeLen,0,0);
367  cipher = new uint8_t[cipherLen];
368 
369  m_onionManager.BuildOnion (cipher, m_ipRoute, m_keys, m_routeLen);
370  }
371  else if (m_onionMode == ONION_ENDCONTENT)
372  {
373  cipherLen = m_onionManager.OnionLength (m_routeLen,0,contentLen);
374  cipher = new uint8_t[cipherLen];
375 
376  m_onionManager.BuildOnion (cipher, m_ipRoute, m_keys, m_routeLen,content,contentLen);
377  }
378  else if (m_onionMode == ONION_LAYERCONTENT)
379  {
380  cipherLen = m_onionManager.OnionLength (m_routeLen,m_layerContentLen,0);
381  cipher = new uint8_t[cipherLen];
382 
383  m_onionManager.BuildOnion (cipher, m_ipRoute, m_keys, m_layerContent, m_layerContentLen, m_routeLen);
384  }
385  else // the case (m_onionMode == ONION_LAYERCONTENT_ENDCONTENT)
386  {
387  cipherLen = m_onionManager.OnionLength (m_routeLen,m_layerContentLen,contentLen);
388  cipher = new uint8_t[cipherLen];
389 
390  m_onionManager.BuildOnion (cipher, m_ipRoute, m_keys, m_layerContent, m_layerContentLen, m_routeLen,content,contentLen);
391  }
392 
393 
394  //Insert the onion in a packet & send to the first node in the route
395  uint8_t const * buff = cipher;
396  Ptr<Packet> p = Create<Packet> (buff,cipherLen);
397  m_socket->SendTo (p, 0, InetSocketAddress (ConstructIpv4 (m_ipRoute[0]),m_port));
398  NS_LOG_INFO ("Onion construction--Onion sent to: " << ConstructIpv4 (m_ipRoute[0]) << " of size: " << p->GetSize () << " bytes" );
399 
400 }
401 
402 //Performed when the node receives an onion
403 void
404 MyApp::RecvOnion (Ptr<Socket> socket)
405 {
406  Address from;
407  Ptr<Packet> p = socket->RecvFrom (from);
408 
409  //extract onion from the packet
410  uint32_t cipherLen = p->GetSize ();
411 
412  if (cipherLen == 0 )//execute if onion mode -- ONION_NO_CONTENT -- was selected
413  {
414  NS_LOG_INFO ("Onion reveal--Empty onion sent from: " << InetSocketAddress::ConvertFrom (from).GetIpv4 () << " received at: " << m_address );
415  return;
416  }
417 
418  uint8_t cipher[cipherLen];
419  p->CopyData (cipher, cipherLen);
420 
421  //decrypt onion layer
422  orLayer * onionLayer = m_onionManager.PeelOnion (cipher,cipherLen,m_onionManager.GetPublicKey (),m_onionManager.GetSecretKey ());
423 
424 
425  if (ConstructIpv4 (onionLayer->nextHopIP).Get () == 0) //execute if onion mode -- -- was selected
426  {//Onion totally decrypted
427  NS_LOG_INFO ("Onion reveal--Onion sent from: " << InetSocketAddress::ConvertFrom (from).GetIpv4 () << " received at: " << m_address << " of size: " << p->GetSize () << " bytes, containing the end content:" << UcharToString (onionLayer->innerLayer,onionLayer->innerLayerLen));
428  }
429  else
430  {//Onion routing step
431  if (m_onionMode == ONION_LAYERCONTENT || m_onionMode == ONION_LAYERCONTENT_ENDCONTENT) //execute if onion mode -- ONION_LAYERCONTENT,ONION_LAYERCONTENT_ENDCONTENT -- was selected
432  {
433  uint8_t const * buff = &onionLayer->innerLayer[m_layerContentLen];
434  Ptr<Packet> np = Create<Packet> (buff,onionLayer->innerLayerLen - m_layerContentLen);
435  m_socket->SendTo (np, 0, InetSocketAddress (ConstructIpv4 (onionLayer->nextHopIP),m_port));
436  NS_LOG_INFO ("Onion routing--Onion sent from: " << InetSocketAddress::ConvertFrom (from).GetIpv4 () << " received at: " << m_address << " of size: " << p->GetSize () << " bytes, containing the layer content: " << UcharToString (onionLayer->innerLayer,m_layerContentLen) << ", sent to: " << ConstructIpv4 (onionLayer->nextHopIP));
437 
438  }
439  else //execute if onion mode -- ONION_NO_CONTENT, ONION_ENDCONTENT, -- was selected
440  {
441  uint8_t const * buff = onionLayer->innerLayer;
442  Ptr<Packet> np = Create<Packet> (buff,onionLayer->innerLayerLen);
443  m_socket->SendTo (np, 0, InetSocketAddress (ConstructIpv4 (onionLayer->nextHopIP),m_port));
444  NS_LOG_INFO ("Onion routing--Onion sent from: " << InetSocketAddress::ConvertFrom (from).GetIpv4 () << " received at: " << m_address << " of size: " << p->GetSize () << " bytes, sent to: " << ConstructIpv4 (onionLayer->nextHopIP));
445  }
446  }
447 
448 
449 }
450 
451 
452 void
453 MyApp::StartApplication (void)
454 {
455 
456  //Create socket
457  m_socket = Socket::CreateSocket (this->GetNode (), TypeId::LookupByName ("ns3::UdpSocketFactory"));
458  m_socket->Bind (InetSocketAddress (Ipv4Address::GetAny (), m_port));
459  m_socket->SetRecvCallback (MakeCallback (&MyApp::RecvOnion,this));
460 
461  //Check if the node has a route for the onion
462  if (m_routeLen != 0)
463  {
464  //Schedule an onion routing
465  Simulator::Schedule (Seconds (2), &MyApp::SendOnion, this);
466  }
467 
468 }
469 
470 void
471 MyApp::StopApplication (void)
472 {
473 
474  m_socket->Close ();
475 
476 }
477 
478 
479 
480 
481 
482 
483 
484 
485 int
486 main (int argc, char *argv[])
487 {
488  bool verbose = true;
489  uint8_t onionMode = ONION_ENDCONTENT;
490 
491  CommandLine cmd (__FILE__);
492  cmd.AddValue ("verbose", "Tell application to log if true", verbose);
493  cmd.AddValue ("onionMode", "Select the mode of operation", onionMode);
494 
495  cmd.Parse (argc,argv);
496 
497  if (verbose)
498  {
499  LogComponentEnable ("OnionRoutingExample", LOG_LEVEL_INFO);
500  LogComponentEnable ("onionrouting", LOG_LEVEL_INFO);
501 
502  }
503 
504  if ( onionMode > 3)
505  {
506  NS_FATAL_ERROR ("Wrong mode of operation selected, select one in range 0 to 3");
507  }
508 
509  /* ... */
510 
511 
512  //create the topology of six nodes
513  NodeContainer nc;
514  nc.Create (6);
515  NodeContainer n0n1 = NodeContainer(nc.Get(0),nc.Get(1));
516  NodeContainer n1n2 = NodeContainer(nc.Get(1),nc.Get(2));
517  NodeContainer n2n3 = NodeContainer(nc.Get(2),nc.Get(3));
518  NodeContainer n2n4 = NodeContainer(nc.Get(2),nc.Get(4));
519  NodeContainer n3n4 = NodeContainer(nc.Get(3),nc.Get(4));
520  NodeContainer n4n5 = NodeContainer(nc.Get(4),nc.Get(5));
521 
522 
523  //Install internet stack
524  InternetStackHelper stack;
525  stack.Install (nc);
526 
527  //Create Point-to-Point Channels
528  NS_LOG_INFO ("Create channels.");
529  PointToPointHelper p2p;
530  p2p.SetDeviceAttribute ("DataRate",StringValue ("5Mbps"));
531  p2p.SetChannelAttribute("Delay",StringValue("2ms"));
532  NetDeviceContainer d0d1 = p2p.Install (n0n1);
533 
534  NetDeviceContainer d1d2 = p2p.Install (n1n2);
535 
536  NetDeviceContainer d4d5 = p2p.Install (n4n5);
537 
538  p2p.SetDeviceAttribute ("DataRate",StringValue ("1Mbps"));
539  p2p.SetChannelAttribute("Delay",StringValue("3ms"));
540  NetDeviceContainer d2d3 = p2p.Install (n2n3);
541  NetDeviceContainer d3d4 = p2p.Install (n3n4);
542  NetDeviceContainer d2d4 = p2p.Install (n2n4);
543 
544 
545 
546  //setup ip addressses
547  Ipv4AddressHelper address;
548 
549  address.SetBase ("10.1.1.0", "255.255.255.0");
550  Ipv4InterfaceContainer i0i1 = address.Assign (d0d1);
551 
552  address.SetBase ("10.1.2.0", "255.255.255.0");
553  Ipv4InterfaceContainer i1i2 = address.Assign (d1d2);
554 
555  address.SetBase ("10.1.3.0", "255.255.255.0");
556  Ipv4InterfaceContainer i2i3 = address.Assign (d2d3);
557 
558  address.SetBase ("10.1.4.0", "255.255.255.0");
559  Ipv4InterfaceContainer i3i4 = address.Assign (d3d4);
560 
561  address.SetBase ("10.1.5.0", "255.255.255.0");
562  Ipv4InterfaceContainer i2i4 = address.Assign (d2d4);
563 
564  address.SetBase ("10.1.6.0", "255.255.255.0");
565  Ipv4InterfaceContainer i4i5 = address.Assign (d4d5);
566 
567  //set routing
568  Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
569 
570 
571  //define route of the onion
572  uint16_t routeLen = 5;
573  uint8_t * ipRoute[routeLen];
574  uint8_t * keys[routeLen];
575  uint16_t layerContentLen = 27; //hardcoded
576  uint8_t * layerContent[routeLen];
577 
578 
579  //Install apps on nodes
580  ApplicationContainer applications (CreateObject<MyApp> (onionMode,layerContentLen));
581  applications.Add (CreateObject<MyApp> (onionMode,layerContentLen));
582  applications.Add (CreateObject<MyApp> (onionMode,layerContentLen));
583  applications.Add (CreateObject<MyApp> (onionMode,layerContentLen));
584  applications.Add (CreateObject<MyApp> (onionMode,layerContentLen));
585  applications.Add (CreateObject<MyApp> (onionMode,layerContentLen));
586 
587  nc.Get (0)->AddApplication (applications.Get (0));
588  nc.Get (1)->AddApplication (applications.Get (1));
589  nc.Get (2)->AddApplication (applications.Get (2));
590  nc.Get (3)->AddApplication (applications.Get (3));
591  nc.Get (4)->AddApplication (applications.Get (4));
592  nc.Get (5)->AddApplication (applications.Get (5));
593 
594 
595  //setup encryption & address
596  for (uint32_t i = 0; i < applications.GetN (); ++i)
597  {
598  /* code */
599  applications.Get (i)->GetObject<MyApp> ()->Setup ();
600  }
601 
602 
603  //ip addresses of the route
604  ipRoute[0] = IpToBuff (applications.Get (2)->GetObject<MyApp> ()->GetAddress ());
605  ipRoute[1] = IpToBuff (applications.Get (3)->GetObject<MyApp> ()->GetAddress ());
606  ipRoute[2] = IpToBuff (applications.Get (1)->GetObject<MyApp> ()->GetAddress ());
607  ipRoute[3] = IpToBuff (applications.Get (4)->GetObject<MyApp> ()->GetAddress ());
608  ipRoute[4] = IpToBuff (applications.Get (5)->GetObject<MyApp> ()->GetAddress ());
609 
610  //encryption keys of nodes in the route
611  keys[0] = applications.Get (2)->GetObject<MyApp> ()->GetPublicKey ();
612  keys[1] = applications.Get (3)->GetObject<MyApp> ()->GetPublicKey ();
613  keys[2] = applications.Get (1)->GetObject<MyApp> ()->GetPublicKey ();
614  keys[3] = applications.Get (4)->GetObject<MyApp> ()->GetPublicKey ();
615  keys[4] = applications.Get (5)->GetObject<MyApp> ()->GetPublicKey ();
616 
617  //set content of each layer
618  layerContent[0] = StringToUchar ("OnionLayer 4 secret content");
619  layerContent[1] = StringToUchar ("OnionLayer 3 secret content");
620  layerContent[2] = StringToUchar ("OnionLayer 2 secret content");
621  layerContent[3] = StringToUchar ("OnionLayer 1 secret content");
622  layerContent[4] = StringToUchar ("OnionLayer 0 secret content");
623 
624 
625  //setup the route at node 0, the node 0 will send the onion
626  applications.Get (0)->GetObject<MyApp> ()->SetRoute (routeLen,ipRoute,keys,layerContent,layerContentLen);
627 
628 
629  applications.Start (Seconds (1));
630  applications.Stop (Seconds (20));
631 
632 
633  Simulator::Stop (Seconds (20));
634  Simulator::Run ();
635  Simulator::Destroy ();
636  return 0;
637 }
638 
639 
640 
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::OnionRouting
Abstract class for creation and decryption of Onion messages.
Definition: onion-routing.h:29
ns3
Definition: sensornode-helper.cc:26
ns3::orLayer::nextHopIP
uint8_t * nextHopIP
ip address given in the serialized form
Definition: onion-routing.h:23
ns3::OnionManager::m_secretkey
unsigned char m_secretkey[crypto_box_SECRETKEYBYTES]
the secret encryption key
Definition: onionmanager.h:192
ns3::OnionRouting::m_errno
enum OnionErrno m_errno
error status while using the onion class
Definition: onion-routing.h:320
ns3::OnionManager::OnionManager
OnionManager()
Default constructor.
Definition: onionmanager.cc:41
ns3::orLayer
structure holding details resulting from layer decryption of an onion message
Definition: onion-routing.h:22
ns3::OnionRouting::ERROR_DECRYPTION
@ ERROR_DECRYPTION
Definition: onion-routing.h:109
ns3::orLayer::innerLayer
uint8_t * innerLayer
inner content of the onion message without the next hop address
Definition: onion-routing.h:24
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::orLayer::innerLayerLen
uint16_t innerLayerLen
length of the inner content of the onion message
Definition: onion-routing.h:25
ns3::OnionRouting::ERROR_ENCRYPTION
@ ERROR_ENCRYPTION
Definition: onion-routing.h:108
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::~OnionManager
~OnionManager()
Default destructor.
Definition: onionmanager.cc:45