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-2020 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_SECURITY_SECURITY_COMMON_HPP
23 #define NDN_SECURITY_SECURITY_COMMON_HPP
24 
26 
27 #include <vector>
28 
29 namespace ndn {
30 
31 namespace signed_interest {
32 
33 const ssize_t POS_SIG_VALUE = -1;
34 const ssize_t POS_SIG_INFO = -2;
35 
39 const size_t MIN_SIZE = 2;
40 
41 } // namespace signed_interest
42 
43 namespace command_interest {
44 
47 const ssize_t POS_RANDOM_VAL = -3;
48 const ssize_t POS_TIMESTAMP = -4;
49 
53 const size_t MIN_SIZE = 4;
54 
55 } // namespace command_interest
56 
57 #ifndef DOXYGEN
58 using InputBuffers = std::vector<std::pair<const uint8_t*, size_t>>;
59 #else
60 class InputBuffers;
62 #endif
63 
67 enum class KeyIdType {
73  USER_SPECIFIED = 0,
79  SHA256 = 1,
85  RANDOM = 2,
86 };
87 
88 std::ostream&
89 operator<<(std::ostream& os, KeyIdType keyIdType);
90 
94 enum class KeyType {
95  NONE = 0,
96  RSA,
97  EC,
98  AES,
99  HMAC,
100 };
101 
102 std::ostream&
103 operator<<(std::ostream& os, KeyType keyType);
104 
105 enum class DigestAlgorithm {
106  NONE = 0,
107  SHA224,
108  SHA256,
109  SHA384,
110  SHA512,
111  BLAKE2B_512,
112  BLAKE2S_256,
113  SHA3_224,
114  SHA3_256,
115  SHA3_384,
116  SHA3_512,
117 };
118 
119 std::ostream&
120 operator<<(std::ostream& os, DigestAlgorithm algorithm);
121 
123  NONE,
124  AES_CBC,
125 };
126 
127 std::ostream&
128 operator<<(std::ostream& os, BlockCipherAlgorithm algorithm);
129 
130 enum class CipherOperator {
131  DECRYPT,
132  ENCRYPT,
133 };
134 
135 std::ostream&
136 operator<<(std::ostream& os, CipherOperator op);
137 
138 } // namespace ndn
139 
140 #endif // NDN_SECURITY_SECURITY_COMMON_HPP
const ssize_t POS_RANDOM_VAL
Definition: data.cpp:26
KeyIdType
The type of KeyId component in a key name.
BlockCipherAlgorithm
std::ostream & operator<<(std::ostream &os, const Data &data)
Definition: data.cpp:383
RSA key, supports sign/verify and encrypt/decrypt operations.
const size_t MIN_SIZE
minimal number of components for Signed Interest
HMAC key, supports sign/verify operations.
KeyType
The type of a cryptographic key.
Common includes and macros used throughout the library.
Elliptic Curve key (e.g. for ECDSA), supports sign/verify operations.
Use the SHA-256 hash of the public key as key id.
const ssize_t POS_SIG_VALUE
const ssize_t POS_TIMESTAMP
const ssize_t POS_SIG_INFO
Use a 64-bit random number as key id.
User-specified key id.
AES key, supports encrypt/decrypt operations.