encryptor.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
23 #ifndef NDN_ENCRYPTOR_HPP
24 #define NDN_ENCRYPTOR_HPP
25 
26 #include "../../data.hpp"
27 #include "encrypt-params.hpp"
28 
29 namespace ndn {
30 
35 class Encryptor {
36 public:
53  static void
55  (Data& data, const Blob& payload, const Name& keyName, const Blob& key,
56  const EncryptParams& params);
57 
58  static const Name::Component&
59  getNAME_COMPONENT_FOR() { return getValues().NAME_COMPONENT_FOR; }
60 
61  static const Name::Component&
62  getNAME_COMPONENT_READ() { return getValues().NAME_COMPONENT_READ; }
63 
64  static const Name::Component&
65  getNAME_COMPONENT_SAMPLE() { return getValues().NAME_COMPONENT_SAMPLE; }
66 
67  static const Name::Component&
68  getNAME_COMPONENT_ACCESS() { return getValues().NAME_COMPONENT_ACCESS; }
69 
70  static const Name::Component&
71  getNAME_COMPONENT_E_KEY() { return getValues().NAME_COMPONENT_E_KEY; }
72 
73  static const Name::Component&
74  getNAME_COMPONENT_D_KEY() { return getValues().NAME_COMPONENT_D_KEY; }
75 
76  static const Name::Component&
77  getNAME_COMPONENT_C_KEY() { return getValues().NAME_COMPONENT_C_KEY; }
78 
79 private:
83  class Values {
84  public:
85  Values()
86  : NAME_COMPONENT_FOR("FOR"),
87  NAME_COMPONENT_READ("READ"),
88  NAME_COMPONENT_SAMPLE("SAMPLE"),
89  NAME_COMPONENT_ACCESS("ACCESS"),
90  NAME_COMPONENT_E_KEY("E-KEY"),
91  NAME_COMPONENT_D_KEY("D-KEY"),
92  NAME_COMPONENT_C_KEY("C-KEY")
93  {}
94 
95  Name::Component NAME_COMPONENT_FOR;
96  Name::Component NAME_COMPONENT_READ;
97  Name::Component NAME_COMPONENT_SAMPLE;
98  Name::Component NAME_COMPONENT_ACCESS;
99  Name::Component NAME_COMPONENT_E_KEY;
100  Name::Component NAME_COMPONENT_D_KEY;
101  Name::Component NAME_COMPONENT_C_KEY;
102  };
103 
109  static Values&
110  getValues()
111  {
112  if (!values_)
113  values_ = new Values();
114 
115  return *values_;
116  }
117 
118  static Values* values_;
119 };
120 
121 }
122 
123 #endif
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:36
Definition: data.hpp:37
An EncryptParams holds an algorithm type and other parameters used to encrypt and decrypt...
Definition: encrypt-params.hpp:36
Encryptor has static constants and utility methods for encryption, such as encryptData.
Definition: encryptor.hpp:35
A Name::Component holds a read-only name component value.
Definition: name.hpp:45
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:40
A Blob holds a pointer to an immutable byte array implemented as const std::vector.
Definition: blob.hpp:42
static void encryptData(Data &data, const Blob &payload, const Name &keyName, const Blob &key, const EncryptParams &params)
Prepare an encrypted data packet by encrypting the payload using the key according to the params...
Definition: encryptor.cpp:109