security-common.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #include "security-common.hpp"
23 #include <ostream>
24 
25 namespace ndn {
26 
27 std::ostream&
28 operator<<(std::ostream& os, KeyIdType keyIdType)
29 {
30  switch (keyIdType) {
32  return os << "USER_SPECIFIED";
33  case KeyIdType::SHA256:
34  return os << "SHA256";
35  case KeyIdType::RANDOM:
36  return os << "RANDOM";
37  }
38  return os << static_cast<int>(keyIdType);
39 }
40 
41 std::ostream&
42 operator<<(std::ostream& os, KeyType keyType)
43 {
44  switch (keyType) {
45  case KeyType::NONE:
46  return os << "NONE";
47  case KeyType::RSA:
48  return os << "RSA";
49  case KeyType::EC:
50  return os << "EC";
51  case KeyType::AES:
52  return os << "AES";
53  };
54  return os << static_cast<int>(keyType);
55 }
56 
57 std::ostream&
58 operator<<(std::ostream& os, KeyClass keyClass)
59 {
60  switch (keyClass) {
61  case KeyClass::NONE:
62  return os << "NONE";
63  case KeyClass::PUBLIC:
64  return os << "PUBLIC";
65  case KeyClass::PRIVATE:
66  return os << "PRIVATE";
68  return os << "SYMMETRIC";
69  };
70  return os << static_cast<int>(keyClass);
71 }
72 
73 std::ostream&
74 operator<<(std::ostream& os, DigestAlgorithm algorithm)
75 {
76  switch (algorithm) {
78  return os << "NONE";
80  return os << "SHA256";
81  };
82  return os << static_cast<int>(algorithm);
83 }
84 
85 std::ostream&
86 operator<<(std::ostream& os, BlockCipherAlgorithm algorithm)
87 {
88  switch (algorithm) {
90  return os << "NONE";
92  return os << "AES_CBC";
93  };
94  return os << static_cast<int>(algorithm);
95 }
96 
97 std::ostream&
98 operator<<(std::ostream& os, CipherOperator op)
99 {
100  switch (op) {
102  return os << "DECRYPT";
104  return os << "ENCRYPT";
105  };
106  return os << static_cast<int>(op);
107 }
108 
109 std::ostream&
110 operator<<(std::ostream& os, AclType aclType)
111 {
112  switch (aclType) {
113  case AclType::NONE:
114  return os << "NONE";
115  case AclType::PUBLIC:
116  return os << "PUBLIC";
117  case AclType::PRIVATE:
118  return os << "PRIVATE";
119  };
120  return os << static_cast<int>(aclType);
121 }
122 
123 } // namespace ndn
Copyright (c) 2013-2016 Regents of the University of California.
Definition: common.hpp:74
KeyIdType
The type of KeyId component in a key name.
BlockCipherAlgorithm
std::ostream & operator<<(std::ostream &os, const Data &data)
Definition: data.cpp:320
Use the SHA256 hash of the public key as the key id.
Use a 64-bit random number as the key id.
User-specified key ID.