Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Davide Pesavento | 8703953 | 2017-09-16 15:15:39 -0400 | [diff] [blame] | 2 | /* |
Yingdi Yu | 6ee2d36 | 2015-07-16 21:48:05 -0700 | [diff] [blame] | 3 | * Copyright (c) 2013-2017 Regents of the University of California. |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 4 | * |
| 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 6 | * |
Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 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. |
Jeff Thompson | 7b79eb6 | 2013-09-12 18:48:29 -0700 | [diff] [blame] | 20 | */ |
| 21 | |
Yingdi Yu | 6ee2d36 | 2015-07-16 21:48:05 -0700 | [diff] [blame] | 22 | #ifndef NDN_SECURITY_SECURITY_COMMON_HPP |
| 23 | #define NDN_SECURITY_SECURITY_COMMON_HPP |
Jeff Thompson | 7b79eb6 | 2013-09-12 18:48:29 -0700 | [diff] [blame] | 24 | |
Yingdi Yu | ae73427 | 2015-07-04 17:38:48 -0700 | [diff] [blame] | 25 | #include "../common.hpp" |
| 26 | |
Jeff Thompson | 7b79eb6 | 2013-09-12 18:48:29 -0700 | [diff] [blame] | 27 | namespace ndn { |
| 28 | |
Yingdi Yu | ae73427 | 2015-07-04 17:38:48 -0700 | [diff] [blame] | 29 | namespace signed_interest { |
Yingdi Yu | 0f5fb69 | 2014-06-10 12:07:28 -0700 | [diff] [blame] | 30 | |
Yingdi Yu | ae73427 | 2015-07-04 17:38:48 -0700 | [diff] [blame] | 31 | const ssize_t POS_SIG_VALUE = -1; |
| 32 | const ssize_t POS_SIG_INFO = -2; |
Alexander Afanasyev | 70244f4 | 2017-01-04 12:47:12 -0800 | [diff] [blame] | 33 | |
| 34 | /** \brief minimal number of components for Signed Interest |
| 35 | * \sa https://redmine.named-data.net/projects/ndn-cxx/wiki/SignedInterest |
| 36 | */ |
| 37 | const size_t MIN_SIZE = 2; |
| 38 | |
Alexander Afanasyev | 70244f4 | 2017-01-04 12:47:12 -0800 | [diff] [blame] | 39 | } // namespace signed_interest |
| 40 | |
| 41 | namespace command_interest { |
| 42 | |
| 43 | using signed_interest::POS_SIG_VALUE; |
| 44 | using signed_interest::POS_SIG_INFO; |
Yingdi Yu | ae73427 | 2015-07-04 17:38:48 -0700 | [diff] [blame] | 45 | const ssize_t POS_RANDOM_VAL = -3; |
| 46 | const ssize_t POS_TIMESTAMP = -4; |
Yingdi Yu | 0f5fb69 | 2014-06-10 12:07:28 -0700 | [diff] [blame] | 47 | |
Junxiao Shi | 198c381 | 2016-08-12 19:24:18 +0000 | [diff] [blame] | 48 | /** \brief minimal number of components for Command Interest |
| 49 | * \sa https://redmine.named-data.net/projects/ndn-cxx/wiki/CommandInterest |
| 50 | */ |
Alexander Afanasyev | 70244f4 | 2017-01-04 12:47:12 -0800 | [diff] [blame] | 51 | const size_t MIN_SIZE = 4; |
Yingdi Yu | 0f5fb69 | 2014-06-10 12:07:28 -0700 | [diff] [blame] | 52 | |
Alexander Afanasyev | 70244f4 | 2017-01-04 12:47:12 -0800 | [diff] [blame] | 53 | } // namespace command_interest |
| 54 | |
Yingdi Yu | c08d7d6 | 2015-07-16 21:05:11 -0700 | [diff] [blame] | 55 | /** |
| 56 | * @brief The type of KeyId component in a key name |
| 57 | */ |
| 58 | enum class KeyIdType { |
| 59 | /** |
| 60 | * @brief User-specified key ID |
| 61 | * |
| 62 | * It is user's responsibility to assure the uniqueness of the key names. |
| 63 | */ |
| 64 | USER_SPECIFIED = 0, |
| 65 | /** |
| 66 | * @brief Use the SHA256 hash of the public key as the key id |
| 67 | * |
| 68 | * This KeyId type guarantees the uniqueness of the key names. |
| 69 | */ |
| 70 | SHA256 = 1, |
| 71 | /** |
| 72 | * @brief Use a 64-bit random number as the key id |
| 73 | * |
| 74 | * This KeyId provides roughly uniqueness of the key names. |
| 75 | */ |
Davide Pesavento | 8703953 | 2017-09-16 15:15:39 -0400 | [diff] [blame] | 76 | RANDOM = 2, |
Yingdi Yu | c08d7d6 | 2015-07-16 21:05:11 -0700 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | std::ostream& |
| 80 | operator<<(std::ostream& os, KeyIdType keyIdType); |
| 81 | |
Davide Pesavento | 8703953 | 2017-09-16 15:15:39 -0400 | [diff] [blame] | 82 | /** |
| 83 | * @brief The type of a cryptographic key |
| 84 | */ |
Yingdi Yu | 99b2a00 | 2015-08-12 12:47:44 -0700 | [diff] [blame] | 85 | enum class KeyType { |
Davide Pesavento | 8703953 | 2017-09-16 15:15:39 -0400 | [diff] [blame] | 86 | NONE = 0, ///< Unknown key type |
| 87 | RSA = 1, ///< RSA key, supports sign/verify and encrypt/decrypt operations |
| 88 | EC = 2, ///< Elliptic Curve key (e.g. for ECDSA), supports sign/verify operations |
| 89 | AES = 128, ///< AES key, supports encrypt/decrypt operations |
Jeff Thompson | 7b79eb6 | 2013-09-12 18:48:29 -0700 | [diff] [blame] | 90 | }; |
| 91 | |
Yingdi Yu | 99b2a00 | 2015-08-12 12:47:44 -0700 | [diff] [blame] | 92 | std::ostream& |
| 93 | operator<<(std::ostream& os, KeyType keyType); |
| 94 | |
| 95 | enum class KeyClass { |
| 96 | NONE, |
| 97 | PUBLIC, |
| 98 | PRIVATE, |
Davide Pesavento | 8703953 | 2017-09-16 15:15:39 -0400 | [diff] [blame] | 99 | SYMMETRIC, |
Jeff Thompson | 7b79eb6 | 2013-09-12 18:48:29 -0700 | [diff] [blame] | 100 | }; |
Alexander Afanasyev | b78bc4d | 2014-04-09 21:20:52 -0700 | [diff] [blame] | 101 | |
Yingdi Yu | 99b2a00 | 2015-08-12 12:47:44 -0700 | [diff] [blame] | 102 | std::ostream& |
| 103 | operator<<(std::ostream& os, KeyClass keyClass); |
| 104 | |
| 105 | enum class DigestAlgorithm { |
| 106 | NONE = 0, |
Davide Pesavento | 8703953 | 2017-09-16 15:15:39 -0400 | [diff] [blame] | 107 | SHA256 = 1, |
Jeff Thompson | 7b79eb6 | 2013-09-12 18:48:29 -0700 | [diff] [blame] | 108 | }; |
| 109 | |
Yingdi Yu | 99b2a00 | 2015-08-12 12:47:44 -0700 | [diff] [blame] | 110 | std::ostream& |
| 111 | operator<<(std::ostream& os, DigestAlgorithm algorithm); |
| 112 | |
| 113 | enum class BlockCipherAlgorithm { |
| 114 | NONE, |
Davide Pesavento | 8703953 | 2017-09-16 15:15:39 -0400 | [diff] [blame] | 115 | AES_CBC, |
Jeff Thompson | 7b79eb6 | 2013-09-12 18:48:29 -0700 | [diff] [blame] | 116 | }; |
| 117 | |
Yingdi Yu | 99b2a00 | 2015-08-12 12:47:44 -0700 | [diff] [blame] | 118 | std::ostream& |
| 119 | operator<<(std::ostream& os, BlockCipherAlgorithm algorithm); |
| 120 | |
Yingdi Yu | 8751661 | 2015-07-10 18:03:52 -0700 | [diff] [blame] | 121 | enum class CipherOperator { |
| 122 | DECRYPT = 0, |
Davide Pesavento | 8703953 | 2017-09-16 15:15:39 -0400 | [diff] [blame] | 123 | ENCRYPT = 1, |
Yingdi Yu | 8751661 | 2015-07-10 18:03:52 -0700 | [diff] [blame] | 124 | }; |
| 125 | |
| 126 | std::ostream& |
| 127 | operator<<(std::ostream& os, CipherOperator op); |
| 128 | |
Yingdi Yu | 99b2a00 | 2015-08-12 12:47:44 -0700 | [diff] [blame] | 129 | enum class AclType { |
| 130 | NONE, |
| 131 | PUBLIC, |
Davide Pesavento | 8703953 | 2017-09-16 15:15:39 -0400 | [diff] [blame] | 132 | PRIVATE, |
Yingdi Yu | 2e57a58 | 2014-02-20 23:34:43 -0800 | [diff] [blame] | 133 | }; |
| 134 | |
Yingdi Yu | 99b2a00 | 2015-08-12 12:47:44 -0700 | [diff] [blame] | 135 | std::ostream& |
| 136 | operator<<(std::ostream& os, AclType aclType); |
| 137 | |
Alexander Afanasyev | 574aa86 | 2017-01-10 19:53:28 -0800 | [diff] [blame] | 138 | namespace security { |
| 139 | namespace transform { |
| 140 | class PublicKey; |
| 141 | } // namespace transform |
| 142 | namespace v2 { |
| 143 | using transform::PublicKey; |
| 144 | } // namespace v2 |
| 145 | } // namespace security |
| 146 | |
Yingdi Yu | 0f5fb69 | 2014-06-10 12:07:28 -0700 | [diff] [blame] | 147 | } // namespace ndn |
Jeff Thompson | 7b79eb6 | 2013-09-12 18:48:29 -0700 | [diff] [blame] | 148 | |
Yingdi Yu | 6ee2d36 | 2015-07-16 21:48:05 -0700 | [diff] [blame] | 149 | #endif // NDN_SECURITY_SECURITY_COMMON_HPP |