Yingdi Yu | 99b2a00 | 2015-08-12 12:47:44 -0700 | [diff] [blame] | 1 | /* -*- 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 | |
| 25 | namespace ndn { |
| 26 | |
| 27 | std::ostream& |
Yingdi Yu | c08d7d6 | 2015-07-16 21:05:11 -0700 | [diff] [blame^] | 28 | operator<<(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 | |
| 41 | std::ostream& |
Yingdi Yu | 99b2a00 | 2015-08-12 12:47:44 -0700 | [diff] [blame] | 42 | operator<<(std::ostream& os, KeyType keyType) |
| 43 | { |
| 44 | switch (keyType) { |
Yingdi Yu | c08d7d6 | 2015-07-16 21:05:11 -0700 | [diff] [blame^] | 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"; |
Yingdi Yu | 99b2a00 | 2015-08-12 12:47:44 -0700 | [diff] [blame] | 53 | }; |
Yingdi Yu | c08d7d6 | 2015-07-16 21:05:11 -0700 | [diff] [blame^] | 54 | return os << static_cast<int>(keyType); |
Yingdi Yu | 99b2a00 | 2015-08-12 12:47:44 -0700 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | std::ostream& |
| 58 | operator<<(std::ostream& os, KeyClass keyClass) |
| 59 | { |
| 60 | switch (keyClass) { |
Yingdi Yu | c08d7d6 | 2015-07-16 21:05:11 -0700 | [diff] [blame^] | 61 | 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 Yu | 99b2a00 | 2015-08-12 12:47:44 -0700 | [diff] [blame] | 69 | }; |
Yingdi Yu | c08d7d6 | 2015-07-16 21:05:11 -0700 | [diff] [blame^] | 70 | return os << static_cast<int>(keyClass); |
Yingdi Yu | 99b2a00 | 2015-08-12 12:47:44 -0700 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | std::ostream& |
| 74 | operator<<(std::ostream& os, DigestAlgorithm algorithm) |
| 75 | { |
| 76 | switch (algorithm) { |
Yingdi Yu | c08d7d6 | 2015-07-16 21:05:11 -0700 | [diff] [blame^] | 77 | case DigestAlgorithm::NONE: |
| 78 | return os << "NONE"; |
| 79 | case DigestAlgorithm::SHA256: |
| 80 | return os << "SHA256"; |
Yingdi Yu | 99b2a00 | 2015-08-12 12:47:44 -0700 | [diff] [blame] | 81 | }; |
Yingdi Yu | c08d7d6 | 2015-07-16 21:05:11 -0700 | [diff] [blame^] | 82 | return os << static_cast<int>(algorithm); |
Yingdi Yu | 99b2a00 | 2015-08-12 12:47:44 -0700 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | std::ostream& |
| 86 | operator<<(std::ostream& os, BlockCipherAlgorithm algorithm) |
| 87 | { |
| 88 | switch (algorithm) { |
Yingdi Yu | c08d7d6 | 2015-07-16 21:05:11 -0700 | [diff] [blame^] | 89 | case BlockCipherAlgorithm::NONE: |
| 90 | return os << "NONE"; |
| 91 | case BlockCipherAlgorithm::AES_CBC: |
| 92 | return os << "AES_CBC"; |
Yingdi Yu | 99b2a00 | 2015-08-12 12:47:44 -0700 | [diff] [blame] | 93 | }; |
Yingdi Yu | c08d7d6 | 2015-07-16 21:05:11 -0700 | [diff] [blame^] | 94 | return os << static_cast<int>(algorithm); |
Yingdi Yu | 99b2a00 | 2015-08-12 12:47:44 -0700 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | std::ostream& |
Yingdi Yu | 8751661 | 2015-07-10 18:03:52 -0700 | [diff] [blame] | 98 | operator<<(std::ostream& os, CipherOperator op) |
| 99 | { |
| 100 | switch (op) { |
Yingdi Yu | c08d7d6 | 2015-07-16 21:05:11 -0700 | [diff] [blame^] | 101 | case CipherOperator::DECRYPT: |
| 102 | return os << "DECRYPT"; |
| 103 | case CipherOperator::ENCRYPT: |
| 104 | return os << "ENCRYPT"; |
Yingdi Yu | 8751661 | 2015-07-10 18:03:52 -0700 | [diff] [blame] | 105 | }; |
Yingdi Yu | c08d7d6 | 2015-07-16 21:05:11 -0700 | [diff] [blame^] | 106 | return os << static_cast<int>(op); |
Yingdi Yu | 8751661 | 2015-07-10 18:03:52 -0700 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | std::ostream& |
Yingdi Yu | 99b2a00 | 2015-08-12 12:47:44 -0700 | [diff] [blame] | 110 | operator<<(std::ostream& os, AclType aclType) |
| 111 | { |
| 112 | switch (aclType) { |
Yingdi Yu | c08d7d6 | 2015-07-16 21:05:11 -0700 | [diff] [blame^] | 113 | case AclType::NONE: |
| 114 | return os << "NONE"; |
| 115 | case AclType::PUBLIC: |
| 116 | return os << "PUBLIC"; |
| 117 | case AclType::PRIVATE: |
| 118 | return os << "PRIVATE"; |
Yingdi Yu | 99b2a00 | 2015-08-12 12:47:44 -0700 | [diff] [blame] | 119 | }; |
Yingdi Yu | c08d7d6 | 2015-07-16 21:05:11 -0700 | [diff] [blame^] | 120 | return os << static_cast<int>(aclType); |
Yingdi Yu | 99b2a00 | 2015-08-12 12:47:44 -0700 | [diff] [blame] | 121 | } |
| 122 | |
| 123 | } // namespace ndn |