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-2022 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 
26 #include "ndn-cxx/util/span.hpp"
27 
28 #include <vector>
29 
30 namespace ndn {
31 
32 namespace signed_interest {
33 
34 const ssize_t POS_SIG_VALUE = -1;
35 const ssize_t POS_SIG_INFO = -2;
36 
40 const size_t MIN_SIZE = 2;
41 
42 } // namespace signed_interest
43 
44 namespace command_interest {
45 
48 const ssize_t POS_RANDOM_VAL = -3;
49 const ssize_t POS_TIMESTAMP = -4;
50 
54 const size_t MIN_SIZE = 4;
55 
56 } // namespace command_interest
57 
58 #ifndef DOXYGEN
59 using InputBuffers = std::vector<span<const uint8_t>>;
60 #else
62 class InputBuffers;
63 #endif
64 
68 enum class KeyIdType {
74  USER_SPECIFIED = 0,
80  SHA256 = 1,
86  RANDOM = 2,
87 };
88 
89 std::ostream&
90 operator<<(std::ostream& os, KeyIdType keyIdType);
91 
95 enum class KeyType {
96  NONE = 0,
97  RSA,
98  EC,
99  AES,
100  HMAC,
101 };
102 
103 std::ostream&
104 operator<<(std::ostream& os, KeyType keyType);
105 
106 enum class DigestAlgorithm {
107  NONE = 0,
108  SHA224,
109  SHA256,
110  SHA384,
111  SHA512,
112  BLAKE2B_512,
113  BLAKE2S_256,
114  SHA3_224,
115  SHA3_256,
116  SHA3_384,
117  SHA3_512,
118 };
119 
120 std::ostream&
121 operator<<(std::ostream& os, DigestAlgorithm algorithm);
122 
124  NONE,
125  AES_CBC,
126 };
127 
128 std::ostream&
129 operator<<(std::ostream& os, BlockCipherAlgorithm algorithm);
130 
131 enum class CipherOperator {
132  DECRYPT,
133  ENCRYPT,
134 };
135 
136 std::ostream&
137 operator<<(std::ostream& os, CipherOperator op);
138 
139 } // namespace ndn
140 
141 #endif // NDN_CXX_SECURITY_SECURITY_COMMON_HPP
Common includes and macros used throughout the library.
const ssize_t POS_RANDOM_VAL
const size_t MIN_SIZE
Minimum number of name components for a Command Interest.
const ssize_t POS_TIMESTAMP
const ssize_t POS_SIG_VALUE
const size_t MIN_SIZE
Minimum number of name components for an old-style Signed Interest.
const 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:374
BlockCipherAlgorithm