blob: 1d0d4f2f9eab0b4d6db3e354dab6d7e1e864d7f9 [file] [log] [blame]
Yingdi Yu99b2a002015-08-12 12:47:44 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesaventodef60f12017-09-17 17:26:07 -04002/*
Davide Pesaventoe80d1162018-09-08 19:23:09 -04003 * Copyright (c) 2013-2018 Regents of the University of California.
Yingdi Yu99b2a002015-08-12 12:47:44 -07004 *
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"
Davide Pesaventodef60f12017-09-17 17:26:07 -040023
Yingdi Yu99b2a002015-08-12 12:47:44 -070024#include <ostream>
25
26namespace ndn {
27
28std::ostream&
Yingdi Yuc08d7d62015-07-16 21:05:11 -070029operator<<(std::ostream& os, KeyIdType keyIdType)
30{
31 switch (keyIdType) {
32 case KeyIdType::USER_SPECIFIED:
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 << static_cast<int>(keyIdType);
40}
41
42std::ostream&
Yingdi Yu99b2a002015-08-12 12:47:44 -070043operator<<(std::ostream& os, KeyType keyType)
44{
45 switch (keyType) {
Yingdi Yuc08d7d62015-07-16 21:05:11 -070046 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";
Davide Pesaventodef60f12017-09-17 17:26:07 -040054 }
Yingdi Yuc08d7d62015-07-16 21:05:11 -070055 return os << static_cast<int>(keyType);
Yingdi Yu99b2a002015-08-12 12:47:44 -070056}
57
58std::ostream&
59operator<<(std::ostream& os, KeyClass keyClass)
60{
61 switch (keyClass) {
Yingdi Yuc08d7d62015-07-16 21:05:11 -070062 case KeyClass::NONE:
63 return os << "NONE";
64 case KeyClass::PUBLIC:
65 return os << "PUBLIC";
66 case KeyClass::PRIVATE:
67 return os << "PRIVATE";
68 case KeyClass::SYMMETRIC:
69 return os << "SYMMETRIC";
Davide Pesaventodef60f12017-09-17 17:26:07 -040070 }
Yingdi Yuc08d7d62015-07-16 21:05:11 -070071 return os << static_cast<int>(keyClass);
Yingdi Yu99b2a002015-08-12 12:47:44 -070072}
73
74std::ostream&
75operator<<(std::ostream& os, DigestAlgorithm algorithm)
76{
77 switch (algorithm) {
Yingdi Yuc08d7d62015-07-16 21:05:11 -070078 case DigestAlgorithm::NONE:
79 return os << "NONE";
Davide Pesaventodef60f12017-09-17 17:26:07 -040080 case DigestAlgorithm::SHA224:
81 return os << "SHA224";
Yingdi Yuc08d7d62015-07-16 21:05:11 -070082 case DigestAlgorithm::SHA256:
83 return os << "SHA256";
Davide Pesaventodef60f12017-09-17 17:26:07 -040084 case DigestAlgorithm::SHA384:
85 return os << "SHA384";
86 case DigestAlgorithm::SHA512:
87 return os << "SHA512";
Davide Pesavento720f3ba2017-12-29 22:06:29 -050088 case DigestAlgorithm::BLAKE2B_512:
89 return os << "BLAKE2b-512";
90 case DigestAlgorithm::BLAKE2S_256:
91 return os << "BLAKE2s-256";
Davide Pesaventoe80d1162018-09-08 19:23:09 -040092 case DigestAlgorithm::SHA3_224:
93 return os << "SHA3-224";
94 case DigestAlgorithm::SHA3_256:
95 return os << "SHA3-256";
96 case DigestAlgorithm::SHA3_384:
97 return os << "SHA3-384";
98 case DigestAlgorithm::SHA3_512:
99 return os << "SHA3-512";
Davide Pesaventodef60f12017-09-17 17:26:07 -0400100 }
Yingdi Yuc08d7d62015-07-16 21:05:11 -0700101 return os << static_cast<int>(algorithm);
Yingdi Yu99b2a002015-08-12 12:47:44 -0700102}
103
104std::ostream&
105operator<<(std::ostream& os, BlockCipherAlgorithm algorithm)
106{
107 switch (algorithm) {
Yingdi Yuc08d7d62015-07-16 21:05:11 -0700108 case BlockCipherAlgorithm::NONE:
109 return os << "NONE";
110 case BlockCipherAlgorithm::AES_CBC:
111 return os << "AES_CBC";
Davide Pesaventodef60f12017-09-17 17:26:07 -0400112 }
Yingdi Yuc08d7d62015-07-16 21:05:11 -0700113 return os << static_cast<int>(algorithm);
Yingdi Yu99b2a002015-08-12 12:47:44 -0700114}
115
116std::ostream&
Yingdi Yu87516612015-07-10 18:03:52 -0700117operator<<(std::ostream& os, CipherOperator op)
118{
119 switch (op) {
Yingdi Yuc08d7d62015-07-16 21:05:11 -0700120 case CipherOperator::DECRYPT:
121 return os << "DECRYPT";
122 case CipherOperator::ENCRYPT:
123 return os << "ENCRYPT";
Davide Pesaventodef60f12017-09-17 17:26:07 -0400124 }
Yingdi Yuc08d7d62015-07-16 21:05:11 -0700125 return os << static_cast<int>(op);
Yingdi Yu87516612015-07-10 18:03:52 -0700126}
127
128std::ostream&
Yingdi Yu99b2a002015-08-12 12:47:44 -0700129operator<<(std::ostream& os, AclType aclType)
130{
131 switch (aclType) {
Yingdi Yuc08d7d62015-07-16 21:05:11 -0700132 case AclType::NONE:
133 return os << "NONE";
134 case AclType::PUBLIC:
135 return os << "PUBLIC";
136 case AclType::PRIVATE:
137 return os << "PRIVATE";
Davide Pesaventodef60f12017-09-17 17:26:07 -0400138 }
Yingdi Yuc08d7d62015-07-16 21:05:11 -0700139 return os << static_cast<int>(aclType);
Yingdi Yu99b2a002015-08-12 12:47:44 -0700140}
141
142} // namespace ndn