Yingdi Yu | 99b2a00 | 2015-08-12 12:47:44 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Davide Pesavento | def60f1 | 2017-09-17 17:26:07 -0400 | [diff] [blame^] | 2 | /* |
| 3 | * Copyright (c) 2013-2017 Regents of the University of California. |
Yingdi Yu | 99b2a00 | 2015-08-12 12:47:44 -0700 | [diff] [blame] | 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" |
Davide Pesavento | def60f1 | 2017-09-17 17:26:07 -0400 | [diff] [blame^] | 23 | |
Yingdi Yu | 99b2a00 | 2015-08-12 12:47:44 -0700 | [diff] [blame] | 24 | #include <ostream> |
| 25 | |
| 26 | namespace ndn { |
| 27 | |
| 28 | std::ostream& |
Yingdi Yu | c08d7d6 | 2015-07-16 21:05:11 -0700 | [diff] [blame] | 29 | operator<<(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 | |
| 42 | std::ostream& |
Yingdi Yu | 99b2a00 | 2015-08-12 12:47:44 -0700 | [diff] [blame] | 43 | operator<<(std::ostream& os, KeyType keyType) |
| 44 | { |
| 45 | switch (keyType) { |
Yingdi Yu | c08d7d6 | 2015-07-16 21:05:11 -0700 | [diff] [blame] | 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"; |
Davide Pesavento | def60f1 | 2017-09-17 17:26:07 -0400 | [diff] [blame^] | 54 | } |
Yingdi Yu | c08d7d6 | 2015-07-16 21:05:11 -0700 | [diff] [blame] | 55 | return os << static_cast<int>(keyType); |
Yingdi Yu | 99b2a00 | 2015-08-12 12:47:44 -0700 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | std::ostream& |
| 59 | operator<<(std::ostream& os, KeyClass keyClass) |
| 60 | { |
| 61 | switch (keyClass) { |
Yingdi Yu | c08d7d6 | 2015-07-16 21:05:11 -0700 | [diff] [blame] | 62 | 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 Pesavento | def60f1 | 2017-09-17 17:26:07 -0400 | [diff] [blame^] | 70 | } |
Yingdi Yu | c08d7d6 | 2015-07-16 21:05:11 -0700 | [diff] [blame] | 71 | return os << static_cast<int>(keyClass); |
Yingdi Yu | 99b2a00 | 2015-08-12 12:47:44 -0700 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | std::ostream& |
| 75 | operator<<(std::ostream& os, DigestAlgorithm algorithm) |
| 76 | { |
| 77 | switch (algorithm) { |
Yingdi Yu | c08d7d6 | 2015-07-16 21:05:11 -0700 | [diff] [blame] | 78 | case DigestAlgorithm::NONE: |
| 79 | return os << "NONE"; |
Davide Pesavento | def60f1 | 2017-09-17 17:26:07 -0400 | [diff] [blame^] | 80 | case DigestAlgorithm::SHA224: |
| 81 | return os << "SHA224"; |
Yingdi Yu | c08d7d6 | 2015-07-16 21:05:11 -0700 | [diff] [blame] | 82 | case DigestAlgorithm::SHA256: |
| 83 | return os << "SHA256"; |
Davide Pesavento | def60f1 | 2017-09-17 17:26:07 -0400 | [diff] [blame^] | 84 | case DigestAlgorithm::SHA384: |
| 85 | return os << "SHA384"; |
| 86 | case DigestAlgorithm::SHA512: |
| 87 | return os << "SHA512"; |
| 88 | } |
Yingdi Yu | c08d7d6 | 2015-07-16 21:05:11 -0700 | [diff] [blame] | 89 | return os << static_cast<int>(algorithm); |
Yingdi Yu | 99b2a00 | 2015-08-12 12:47:44 -0700 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | std::ostream& |
| 93 | operator<<(std::ostream& os, BlockCipherAlgorithm algorithm) |
| 94 | { |
| 95 | switch (algorithm) { |
Yingdi Yu | c08d7d6 | 2015-07-16 21:05:11 -0700 | [diff] [blame] | 96 | case BlockCipherAlgorithm::NONE: |
| 97 | return os << "NONE"; |
| 98 | case BlockCipherAlgorithm::AES_CBC: |
| 99 | return os << "AES_CBC"; |
Davide Pesavento | def60f1 | 2017-09-17 17:26:07 -0400 | [diff] [blame^] | 100 | } |
Yingdi Yu | c08d7d6 | 2015-07-16 21:05:11 -0700 | [diff] [blame] | 101 | return os << static_cast<int>(algorithm); |
Yingdi Yu | 99b2a00 | 2015-08-12 12:47:44 -0700 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | std::ostream& |
Yingdi Yu | 8751661 | 2015-07-10 18:03:52 -0700 | [diff] [blame] | 105 | operator<<(std::ostream& os, CipherOperator op) |
| 106 | { |
| 107 | switch (op) { |
Yingdi Yu | c08d7d6 | 2015-07-16 21:05:11 -0700 | [diff] [blame] | 108 | case CipherOperator::DECRYPT: |
| 109 | return os << "DECRYPT"; |
| 110 | case CipherOperator::ENCRYPT: |
| 111 | return os << "ENCRYPT"; |
Davide Pesavento | def60f1 | 2017-09-17 17:26:07 -0400 | [diff] [blame^] | 112 | } |
Yingdi Yu | c08d7d6 | 2015-07-16 21:05:11 -0700 | [diff] [blame] | 113 | return os << static_cast<int>(op); |
Yingdi Yu | 8751661 | 2015-07-10 18:03:52 -0700 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | std::ostream& |
Yingdi Yu | 99b2a00 | 2015-08-12 12:47:44 -0700 | [diff] [blame] | 117 | operator<<(std::ostream& os, AclType aclType) |
| 118 | { |
| 119 | switch (aclType) { |
Yingdi Yu | c08d7d6 | 2015-07-16 21:05:11 -0700 | [diff] [blame] | 120 | case AclType::NONE: |
| 121 | return os << "NONE"; |
| 122 | case AclType::PUBLIC: |
| 123 | return os << "PUBLIC"; |
| 124 | case AclType::PRIVATE: |
| 125 | return os << "PRIVATE"; |
Davide Pesavento | def60f1 | 2017-09-17 17:26:07 -0400 | [diff] [blame^] | 126 | } |
Yingdi Yu | c08d7d6 | 2015-07-16 21:05:11 -0700 | [diff] [blame] | 127 | return os << static_cast<int>(aclType); |
Yingdi Yu | 99b2a00 | 2015-08-12 12:47:44 -0700 | [diff] [blame] | 128 | } |
| 129 | |
| 130 | } // namespace ndn |