security-common.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2024 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 #ifndef NDN_CXX_SECURITY_SECURITY_COMMON_HPP
23 #define NDN_CXX_SECURITY_SECURITY_COMMON_HPP
24 
25 #include "ndn-cxx/util/span.hpp"
26 
27 #include <cstdint>
28 #include <iosfwd>
29 #include <vector>
30 
31 namespace ndn {
32 
33 namespace signed_interest {
34 
36 inline constexpr ssize_t POS_SIG_VALUE = -1;
38 inline constexpr ssize_t POS_SIG_INFO = -2;
39 
45 inline constexpr size_t MIN_SIZE = 2;
46 
47 } // namespace signed_interest
48 
49 namespace command_interest {
50 
52 inline constexpr ssize_t POS_SIG_VALUE = -1;
54 inline constexpr ssize_t POS_SIG_INFO = -2;
56 inline constexpr ssize_t POS_RANDOM_VAL = -3;
58 inline constexpr ssize_t POS_TIMESTAMP = -4;
59 
65 inline constexpr size_t MIN_SIZE = 4;
66 
67 } // namespace command_interest
68 
69 #ifndef DOXYGEN
70 using InputBuffers = std::vector<span<const uint8_t>>;
71 #else
73 class InputBuffers;
74 #endif
75 
79 enum class KeyIdType {
85  USER_SPECIFIED = 0,
91  SHA256 = 1,
97  RANDOM = 2,
98 };
99 
100 std::ostream&
101 operator<<(std::ostream& os, KeyIdType keyIdType);
102 
106 enum class KeyType {
107  NONE = 0,
108  RSA,
109  EC,
110  AES,
111  HMAC,
112 };
113 
114 std::ostream&
115 operator<<(std::ostream& os, KeyType keyType);
116 
117 enum class DigestAlgorithm {
118  NONE = 0,
119  SHA224,
120  SHA256,
121  SHA384,
122  SHA512,
123  BLAKE2B_512,
124  BLAKE2S_256,
125  SHA3_224,
126  SHA3_256,
127  SHA3_384,
128  SHA3_512,
129 };
130 
131 std::ostream&
132 operator<<(std::ostream& os, DigestAlgorithm algorithm);
133 
135  NONE,
136  AES_CBC,
137 };
138 
139 std::ostream&
140 operator<<(std::ostream& os, BlockCipherAlgorithm algorithm);
141 
142 enum class CipherOperator {
143  DECRYPT,
144  ENCRYPT,
145 };
146 
147 std::ostream&
148 operator<<(std::ostream& os, CipherOperator op);
149 
150 } // namespace ndn
151 
152 #endif // NDN_CXX_SECURITY_SECURITY_COMMON_HPP
constexpr ssize_t POS_SIG_VALUE
constexpr size_t MIN_SIZE
Minimum number of name components for a Command Interest.
constexpr ssize_t POS_RANDOM_VAL
constexpr ssize_t POS_SIG_INFO
constexpr ssize_t POS_TIMESTAMP
constexpr ssize_t POS_SIG_VALUE
constexpr size_t MIN_SIZE
Minimum number of name components for an old-style Signed Interest.
constexpr ssize_t POS_SIG_INFO
Definition: data.cpp:25
KeyType
The type of a cryptographic key.
@ EC
Elliptic Curve key (e.g. for ECDSA), supports sign/verify operations.
@ RSA
RSA key, supports sign/verify and encrypt/decrypt operations.
@ AES
AES key, supports encrypt/decrypt operations.
@ NONE
Unknown or unsupported key type.
@ HMAC
HMAC key, supports sign/verify operations.
KeyIdType
The type of KeyId component in a key name.
@ RANDOM
Use a 64-bit random number as key id.
@ USER_SPECIFIED
User-specified key id.
@ SHA256
Use the SHA-256 hash of the public key as key id.
std::ostream & operator<<(std::ostream &os, const Data &data)
Definition: data.cpp:377
BlockCipherAlgorithm