blob: b5a704d79c983084af1bc7f9313e5eb6c923bb17 [file] [log] [blame]
Alexander Afanasyevc169a812014-05-20 20:37:29 -04001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Jeff Thompson7b79eb62013-09-12 18:48:29 -07002/**
Yingdi Yu6ee2d362015-07-16 21:48:05 -07003 * Copyright (c) 2013-2017 Regents of the University of California.
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07004 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07006 *
Alexander Afanasyevc169a812014-05-20 20:37:29 -04007 * 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 Thompson7b79eb62013-09-12 18:48:29 -070020 */
21
Yingdi Yu6ee2d362015-07-16 21:48:05 -070022#ifndef NDN_SECURITY_SECURITY_COMMON_HPP
23#define NDN_SECURITY_SECURITY_COMMON_HPP
Jeff Thompson7b79eb62013-09-12 18:48:29 -070024
Yingdi Yuae734272015-07-04 17:38:48 -070025#include "../common.hpp"
26
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070027#define NDN_CXX_KEEP_SECURITY_V1_ALIASES
28
Jeff Thompson7b79eb62013-09-12 18:48:29 -070029namespace ndn {
30
Yingdi Yuae734272015-07-04 17:38:48 -070031namespace signed_interest {
Yingdi Yu0f5fb692014-06-10 12:07:28 -070032
Yingdi Yuae734272015-07-04 17:38:48 -070033const ssize_t POS_SIG_VALUE = -1;
34const ssize_t POS_SIG_INFO = -2;
Alexander Afanasyev70244f42017-01-04 12:47:12 -080035
36/** \brief minimal number of components for Signed Interest
37 * \sa https://redmine.named-data.net/projects/ndn-cxx/wiki/SignedInterest
38 */
39const size_t MIN_SIZE = 2;
40
41/** \deprecated To avoid a potentially breaking change, this value is kept based on the Command
42 * Interest definition. This value will be eliminated in favor of `MIN_SIZE=2`.
43 */
44const size_t MIN_LENGTH = 4;
45
46/** \deprecated Use `MIN_SIZE`
47 */
48const size_t MIN_LENGTH_SIG_ONLY = 2;
49
50} // namespace signed_interest
51
52namespace command_interest {
53
54using signed_interest::POS_SIG_VALUE;
55using signed_interest::POS_SIG_INFO;
Yingdi Yuae734272015-07-04 17:38:48 -070056const ssize_t POS_RANDOM_VAL = -3;
57const ssize_t POS_TIMESTAMP = -4;
Yingdi Yu0f5fb692014-06-10 12:07:28 -070058
Junxiao Shi198c3812016-08-12 19:24:18 +000059/** \brief minimal number of components for Command Interest
60 * \sa https://redmine.named-data.net/projects/ndn-cxx/wiki/CommandInterest
61 */
Alexander Afanasyev70244f42017-01-04 12:47:12 -080062const size_t MIN_SIZE = 4;
Yingdi Yu0f5fb692014-06-10 12:07:28 -070063
Alexander Afanasyev70244f42017-01-04 12:47:12 -080064} // namespace command_interest
65
66namespace signed_interest {
67
68/**
69 * @deprecated Use command_interest::POS_RANDOM_VAL
Junxiao Shi198c3812016-08-12 19:24:18 +000070 */
Alexander Afanasyev70244f42017-01-04 12:47:12 -080071using command_interest::POS_RANDOM_VAL;
72
73/**
74 * @deprecated Use command_interest::POS_TIMESTAMP
75 */
76using command_interest::POS_TIMESTAMP;
Junxiao Shi198c3812016-08-12 19:24:18 +000077
Yingdi Yu0f5fb692014-06-10 12:07:28 -070078} // namespace signed_interest
79
Yingdi Yuc08d7d62015-07-16 21:05:11 -070080/**
81 * @brief The type of KeyId component in a key name
82 */
83enum class KeyIdType {
84 /**
85 * @brief User-specified key ID
86 *
87 * It is user's responsibility to assure the uniqueness of the key names.
88 */
89 USER_SPECIFIED = 0,
90 /**
91 * @brief Use the SHA256 hash of the public key as the key id
92 *
93 * This KeyId type guarantees the uniqueness of the key names.
94 */
95 SHA256 = 1,
96 /**
97 * @brief Use a 64-bit random number as the key id
98 *
99 * This KeyId provides roughly uniqueness of the key names.
100 */
101 RANDOM = 2
102};
103
104std::ostream&
105operator<<(std::ostream& os, KeyIdType keyIdType);
106
Yingdi Yu99b2a002015-08-12 12:47:44 -0700107enum class KeyType {
108 NONE = 0,
109 RSA = 1,
110 EC = 2,
111 AES = 128
Jeff Thompson7b79eb62013-09-12 18:48:29 -0700112};
113
Yingdi Yu99b2a002015-08-12 12:47:44 -0700114std::ostream&
115operator<<(std::ostream& os, KeyType keyType);
116
117enum class KeyClass {
118 NONE,
119 PUBLIC,
120 PRIVATE,
121 SYMMETRIC
Jeff Thompson7b79eb62013-09-12 18:48:29 -0700122};
Alexander Afanasyevb78bc4d2014-04-09 21:20:52 -0700123
Yingdi Yu99b2a002015-08-12 12:47:44 -0700124std::ostream&
125operator<<(std::ostream& os, KeyClass keyClass);
126
127enum class DigestAlgorithm {
128 NONE = 0,
129 SHA256 = 1
Jeff Thompson7b79eb62013-09-12 18:48:29 -0700130};
131
Yingdi Yu99b2a002015-08-12 12:47:44 -0700132std::ostream&
133operator<<(std::ostream& os, DigestAlgorithm algorithm);
134
135enum class BlockCipherAlgorithm {
136 NONE,
137 AES_CBC
Jeff Thompson7b79eb62013-09-12 18:48:29 -0700138};
139
Yingdi Yu99b2a002015-08-12 12:47:44 -0700140std::ostream&
141operator<<(std::ostream& os, BlockCipherAlgorithm algorithm);
142
Yingdi Yu87516612015-07-10 18:03:52 -0700143enum class CipherOperator {
144 DECRYPT = 0,
145 ENCRYPT = 1
146};
147
148std::ostream&
149operator<<(std::ostream& os, CipherOperator op);
150
Yingdi Yu99b2a002015-08-12 12:47:44 -0700151enum class AclType {
152 NONE,
153 PUBLIC,
154 PRIVATE
Yingdi Yu2e57a582014-02-20 23:34:43 -0800155};
156
Yingdi Yu99b2a002015-08-12 12:47:44 -0700157std::ostream&
158operator<<(std::ostream& os, AclType aclType);
159
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800160namespace security {
161namespace transform {
162class PublicKey;
163} // namespace transform
164namespace v2 {
165using transform::PublicKey;
166} // namespace v2
167} // namespace security
168
Yingdi Yu0f5fb692014-06-10 12:07:28 -0700169} // namespace ndn
Jeff Thompson7b79eb62013-09-12 18:48:29 -0700170
Yingdi Yu6ee2d362015-07-16 21:48:05 -0700171#endif // NDN_SECURITY_SECURITY_COMMON_HPP