NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
security-common.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2019 Regents of the University of California.
4  *
5  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6  *
7  * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later version.
10  *
11  * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13  * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14  *
15  * You should have received copies of the GNU General Public License and GNU Lesser
16  * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17  * <http://www.gnu.org/licenses/>.
18  *
19  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20  */
21 
23 
24 #include <ostream>
25 
26 namespace ndn {
27 
28 std::ostream&
29 operator<<(std::ostream& os, KeyIdType keyIdType)
30 {
31  switch (keyIdType) {
33  return os << "USER-SPECIFIED";
34  case KeyIdType::SHA256:
35  return os << "SHA256";
36  case KeyIdType::RANDOM:
37  return os << "RANDOM";
38  }
39  return os << to_underlying(keyIdType);
40 }
41 
42 std::ostream&
43 operator<<(std::ostream& os, KeyType keyType)
44 {
45  switch (keyType) {
46  case KeyType::NONE:
47  return os << "NONE";
48  case KeyType::RSA:
49  return os << "RSA";
50  case KeyType::EC:
51  return os << "EC";
52  case KeyType::AES:
53  return os << "AES";
54  case KeyType::HMAC:
55  return os << "HMAC";
56  }
57  return os << to_underlying(keyType);
58 }
59 
60 std::ostream&
61 operator<<(std::ostream& os, DigestAlgorithm algorithm)
62 {
63  switch (algorithm) {
65  return os << "NONE";
67  return os << "SHA224";
69  return os << "SHA256";
71  return os << "SHA384";
73  return os << "SHA512";
75  return os << "BLAKE2b-512";
77  return os << "BLAKE2s-256";
79  return os << "SHA3-224";
81  return os << "SHA3-256";
83  return os << "SHA3-384";
85  return os << "SHA3-512";
86  }
87  return os << to_underlying(algorithm);
88 }
89 
90 std::ostream&
91 operator<<(std::ostream& os, BlockCipherAlgorithm algorithm)
92 {
93  switch (algorithm) {
95  return os << "NONE";
97  return os << "AES-CBC";
98  }
99  return os << to_underlying(algorithm);
100 }
101 
102 std::ostream&
103 operator<<(std::ostream& os, CipherOperator op)
104 {
105  switch (op) {
107  return os << "DECRYPT";
109  return os << "ENCRYPT";
110  }
111  return os << to_underlying(op);
112 }
113 
114 } // namespace ndn
ndn::KeyType
KeyType
The type of a cryptographic key.
Definition: security-common.hpp:85
ndn::DigestAlgorithm::SHA224
@ SHA224
ndn::KeyIdType::RANDOM
@ RANDOM
Use a 64-bit random number as key id.
ndn::KeyIdType
KeyIdType
The type of KeyId component in a key name.
Definition: security-common.hpp:58
security-common.hpp
ndn::DigestAlgorithm::SHA256
@ SHA256
ndn::DigestAlgorithm::NONE
@ NONE
ndn::CipherOperator::DECRYPT
@ DECRYPT
ndn::KeyType::EC
@ EC
Elliptic Curve key (e.g. for ECDSA), supports sign/verify operations.
ndn::BlockCipherAlgorithm::NONE
@ NONE
ndn::DigestAlgorithm
DigestAlgorithm
Definition: security-common.hpp:96
ndn::DigestAlgorithm::SHA3_384
@ SHA3_384
ndn::CipherOperator::ENCRYPT
@ ENCRYPT
ndn::KeyIdType::SHA256
@ SHA256
Use the SHA256 hash of the public key as key id.
ndn::DigestAlgorithm::SHA512
@ SHA512
ndn::KeyType::HMAC
@ HMAC
HMAC key, supports sign/verify operations.
ndn::DigestAlgorithm::SHA3_256
@ SHA3_256
ndn::DigestAlgorithm::BLAKE2S_256
@ BLAKE2S_256
ndn::DigestAlgorithm::SHA3_512
@ SHA3_512
ndn::DigestAlgorithm::BLAKE2B_512
@ BLAKE2B_512
ndn::BlockCipherAlgorithm::AES_CBC
@ AES_CBC
ndn::DigestAlgorithm::SHA3_224
@ SHA3_224
ndn::DigestAlgorithm::SHA384
@ SHA384
ndn::KeyType::NONE
@ NONE
Unknown or unsupported key type.
ndn::operator<<
std::ostream & operator<<(std::ostream &os, const Data &data)
Definition: data.cpp:322
ndn::KeyIdType::USER_SPECIFIED
@ USER_SPECIFIED
User-specified key id.
ndn::CipherOperator
CipherOperator
Definition: security-common.hpp:121
ndn::BlockCipherAlgorithm
BlockCipherAlgorithm
Definition: security-common.hpp:113
ndn::KeyType::AES
@ AES
AES key, supports encrypt/decrypt operations.
ndn::KeyType::RSA
@ RSA
RSA key, supports sign/verify and encrypt/decrypt operations.
ndn::to_underlying
constexpr std::underlying_type_t< T > to_underlying(T val) noexcept
Definition: backports.hpp:141
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-strategy-choice-helper.hpp:34