blob: c2fa8f4ad05887f5d2d9dcba37d4f74ec9b5cca3 [file] [log] [blame]
Alexander Afanasyevc169a812014-05-20 20:37:29 -04001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesavento87039532017-09-16 15:15:39 -04002/*
Davide Pesaventoe80d1162018-09-08 19:23:09 -04003 * Copyright (c) 2013-2018 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
Jeff Thompson7b79eb62013-09-12 18:48:29 -070027namespace ndn {
28
Yingdi Yuae734272015-07-04 17:38:48 -070029namespace signed_interest {
Yingdi Yu0f5fb692014-06-10 12:07:28 -070030
Yingdi Yuae734272015-07-04 17:38:48 -070031const ssize_t POS_SIG_VALUE = -1;
32const ssize_t POS_SIG_INFO = -2;
Alexander Afanasyev70244f42017-01-04 12:47:12 -080033
34/** \brief minimal number of components for Signed Interest
35 * \sa https://redmine.named-data.net/projects/ndn-cxx/wiki/SignedInterest
36 */
37const size_t MIN_SIZE = 2;
38
Alexander Afanasyev70244f42017-01-04 12:47:12 -080039} // namespace signed_interest
40
41namespace command_interest {
42
43using signed_interest::POS_SIG_VALUE;
44using signed_interest::POS_SIG_INFO;
Yingdi Yuae734272015-07-04 17:38:48 -070045const ssize_t POS_RANDOM_VAL = -3;
46const ssize_t POS_TIMESTAMP = -4;
Yingdi Yu0f5fb692014-06-10 12:07:28 -070047
Junxiao Shi198c3812016-08-12 19:24:18 +000048/** \brief minimal number of components for Command Interest
49 * \sa https://redmine.named-data.net/projects/ndn-cxx/wiki/CommandInterest
50 */
Alexander Afanasyev70244f42017-01-04 12:47:12 -080051const size_t MIN_SIZE = 4;
Yingdi Yu0f5fb692014-06-10 12:07:28 -070052
Alexander Afanasyev70244f42017-01-04 12:47:12 -080053} // namespace command_interest
54
Yingdi Yuc08d7d62015-07-16 21:05:11 -070055/**
56 * @brief The type of KeyId component in a key name
57 */
58enum 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 Pesavento87039532017-09-16 15:15:39 -040076 RANDOM = 2,
Yingdi Yuc08d7d62015-07-16 21:05:11 -070077};
78
79std::ostream&
80operator<<(std::ostream& os, KeyIdType keyIdType);
81
Davide Pesavento87039532017-09-16 15:15:39 -040082/**
83 * @brief The type of a cryptographic key
84 */
Yingdi Yu99b2a002015-08-12 12:47:44 -070085enum class KeyType {
Davide Pesavento87039532017-09-16 15:15:39 -040086 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 Thompson7b79eb62013-09-12 18:48:29 -070090};
91
Yingdi Yu99b2a002015-08-12 12:47:44 -070092std::ostream&
93operator<<(std::ostream& os, KeyType keyType);
94
95enum class KeyClass {
96 NONE,
97 PUBLIC,
98 PRIVATE,
Davide Pesavento87039532017-09-16 15:15:39 -040099 SYMMETRIC,
Jeff Thompson7b79eb62013-09-12 18:48:29 -0700100};
Alexander Afanasyevb78bc4d2014-04-09 21:20:52 -0700101
Yingdi Yu99b2a002015-08-12 12:47:44 -0700102std::ostream&
103operator<<(std::ostream& os, KeyClass keyClass);
104
105enum class DigestAlgorithm {
106 NONE = 0,
Davide Pesaventodef60f12017-09-17 17:26:07 -0400107 SHA224 = 2,
Davide Pesavento87039532017-09-16 15:15:39 -0400108 SHA256 = 1,
Davide Pesaventodef60f12017-09-17 17:26:07 -0400109 SHA384 = 3,
110 SHA512 = 4,
Davide Pesavento720f3ba2017-12-29 22:06:29 -0500111 BLAKE2B_512 = 10,
112 BLAKE2S_256 = 11,
Davide Pesaventoe80d1162018-09-08 19:23:09 -0400113 SHA3_224 = 20,
114 SHA3_256 = 21,
115 SHA3_384 = 22,
116 SHA3_512 = 23,
Jeff Thompson7b79eb62013-09-12 18:48:29 -0700117};
118
Yingdi Yu99b2a002015-08-12 12:47:44 -0700119std::ostream&
120operator<<(std::ostream& os, DigestAlgorithm algorithm);
121
122enum class BlockCipherAlgorithm {
123 NONE,
Davide Pesavento87039532017-09-16 15:15:39 -0400124 AES_CBC,
Jeff Thompson7b79eb62013-09-12 18:48:29 -0700125};
126
Yingdi Yu99b2a002015-08-12 12:47:44 -0700127std::ostream&
128operator<<(std::ostream& os, BlockCipherAlgorithm algorithm);
129
Yingdi Yu87516612015-07-10 18:03:52 -0700130enum class CipherOperator {
131 DECRYPT = 0,
Davide Pesavento87039532017-09-16 15:15:39 -0400132 ENCRYPT = 1,
Yingdi Yu87516612015-07-10 18:03:52 -0700133};
134
135std::ostream&
136operator<<(std::ostream& os, CipherOperator op);
137
Yingdi Yu99b2a002015-08-12 12:47:44 -0700138enum class AclType {
139 NONE,
140 PUBLIC,
Davide Pesavento87039532017-09-16 15:15:39 -0400141 PRIVATE,
Yingdi Yu2e57a582014-02-20 23:34:43 -0800142};
143
Yingdi Yu99b2a002015-08-12 12:47:44 -0700144std::ostream&
145operator<<(std::ostream& os, AclType aclType);
146
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800147namespace security {
148namespace transform {
149class PublicKey;
150} // namespace transform
151namespace v2 {
152using transform::PublicKey;
153} // namespace v2
154} // namespace security
155
Yingdi Yu0f5fb692014-06-10 12:07:28 -0700156} // namespace ndn
Jeff Thompson7b79eb62013-09-12 18:48:29 -0700157
Yingdi Yu6ee2d362015-07-16 21:48:05 -0700158#endif // NDN_SECURITY_SECURITY_COMMON_HPP