blob: cda5fc5020a2b67612f1e04229f78d8d46600f32 [file] [log] [blame]
Yingdi Yu99b2a002015-08-12 12:47:44 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2013-2016 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
22#include "security-common.hpp"
23#include <ostream>
24
25namespace ndn {
26
27std::ostream&
Yingdi Yuc08d7d62015-07-16 21:05:11 -070028operator<<(std::ostream& os, KeyIdType keyIdType)
29{
30 switch (keyIdType) {
31 case KeyIdType::USER_SPECIFIED:
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
41std::ostream&
Yingdi Yu99b2a002015-08-12 12:47:44 -070042operator<<(std::ostream& os, KeyType keyType)
43{
44 switch (keyType) {
Yingdi Yuc08d7d62015-07-16 21:05:11 -070045 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";
Yingdi Yu99b2a002015-08-12 12:47:44 -070053 };
Yingdi Yuc08d7d62015-07-16 21:05:11 -070054 return os << static_cast<int>(keyType);
Yingdi Yu99b2a002015-08-12 12:47:44 -070055}
56
57std::ostream&
58operator<<(std::ostream& os, KeyClass keyClass)
59{
60 switch (keyClass) {
Yingdi Yuc08d7d62015-07-16 21:05:11 -070061 case KeyClass::NONE:
62 return os << "NONE";
63 case KeyClass::PUBLIC:
64 return os << "PUBLIC";
65 case KeyClass::PRIVATE:
66 return os << "PRIVATE";
67 case KeyClass::SYMMETRIC:
68 return os << "SYMMETRIC";
Yingdi Yu99b2a002015-08-12 12:47:44 -070069 };
Yingdi Yuc08d7d62015-07-16 21:05:11 -070070 return os << static_cast<int>(keyClass);
Yingdi Yu99b2a002015-08-12 12:47:44 -070071}
72
73std::ostream&
74operator<<(std::ostream& os, DigestAlgorithm algorithm)
75{
76 switch (algorithm) {
Yingdi Yuc08d7d62015-07-16 21:05:11 -070077 case DigestAlgorithm::NONE:
78 return os << "NONE";
79 case DigestAlgorithm::SHA256:
80 return os << "SHA256";
Yingdi Yu99b2a002015-08-12 12:47:44 -070081 };
Yingdi Yuc08d7d62015-07-16 21:05:11 -070082 return os << static_cast<int>(algorithm);
Yingdi Yu99b2a002015-08-12 12:47:44 -070083}
84
85std::ostream&
86operator<<(std::ostream& os, BlockCipherAlgorithm algorithm)
87{
88 switch (algorithm) {
Yingdi Yuc08d7d62015-07-16 21:05:11 -070089 case BlockCipherAlgorithm::NONE:
90 return os << "NONE";
91 case BlockCipherAlgorithm::AES_CBC:
92 return os << "AES_CBC";
Yingdi Yu99b2a002015-08-12 12:47:44 -070093 };
Yingdi Yuc08d7d62015-07-16 21:05:11 -070094 return os << static_cast<int>(algorithm);
Yingdi Yu99b2a002015-08-12 12:47:44 -070095}
96
97std::ostream&
Yingdi Yu87516612015-07-10 18:03:52 -070098operator<<(std::ostream& os, CipherOperator op)
99{
100 switch (op) {
Yingdi Yuc08d7d62015-07-16 21:05:11 -0700101 case CipherOperator::DECRYPT:
102 return os << "DECRYPT";
103 case CipherOperator::ENCRYPT:
104 return os << "ENCRYPT";
Yingdi Yu87516612015-07-10 18:03:52 -0700105 };
Yingdi Yuc08d7d62015-07-16 21:05:11 -0700106 return os << static_cast<int>(op);
Yingdi Yu87516612015-07-10 18:03:52 -0700107}
108
109std::ostream&
Yingdi Yu99b2a002015-08-12 12:47:44 -0700110operator<<(std::ostream& os, AclType aclType)
111{
112 switch (aclType) {
Yingdi Yuc08d7d62015-07-16 21:05:11 -0700113 case AclType::NONE:
114 return os << "NONE";
115 case AclType::PUBLIC:
116 return os << "PUBLIC";
117 case AclType::PRIVATE:
118 return os << "PRIVATE";
Yingdi Yu99b2a002015-08-12 12:47:44 -0700119 };
Yingdi Yuc08d7d62015-07-16 21:05:11 -0700120 return os << static_cast<int>(aclType);
Yingdi Yu99b2a002015-08-12 12:47:44 -0700121}
122
123} // namespace ndn