Prashanth Swaminathan | d5b3eae | 2015-07-09 15:37:05 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Alexander Afanasyev | 9091d83 | 2018-04-18 17:21:08 -0400 | [diff] [blame^] | 3 | * Copyright (c) 2014-2018, Regents of the University of California |
Prashanth Swaminathan | d5b3eae | 2015-07-09 15:37:05 -0700 | [diff] [blame] | 4 | * |
Alexander Afanasyev | 9091d83 | 2018-04-18 17:21:08 -0400 | [diff] [blame^] | 5 | * This file is part of NAC (Name-Based Access Control for NDN). |
| 6 | * See AUTHORS.md for complete list of NAC authors and contributors. |
Prashanth Swaminathan | d5b3eae | 2015-07-09 15:37:05 -0700 | [diff] [blame] | 7 | * |
Alexander Afanasyev | 9091d83 | 2018-04-18 17:21:08 -0400 | [diff] [blame^] | 8 | * NAC is free software: you can redistribute it and/or modify it under the terms |
| 9 | * of the GNU General Public License as published by the Free Software Foundation, |
| 10 | * either version 3 of the License, or (at your option) any later version. |
Prashanth Swaminathan | d5b3eae | 2015-07-09 15:37:05 -0700 | [diff] [blame] | 11 | * |
Alexander Afanasyev | 9091d83 | 2018-04-18 17:21:08 -0400 | [diff] [blame^] | 12 | * NAC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 | * PURPOSE. See the GNU General Public License for more details. |
Prashanth Swaminathan | d5b3eae | 2015-07-09 15:37:05 -0700 | [diff] [blame] | 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along with |
Alexander Afanasyev | 9091d83 | 2018-04-18 17:21:08 -0400 | [diff] [blame^] | 17 | * NAC, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
Prashanth Swaminathan | d5b3eae | 2015-07-09 15:37:05 -0700 | [diff] [blame] | 18 | */ |
| 19 | |
| 20 | #ifndef NDN_ENCRYPTOR_HPP |
| 21 | #define NDN_ENCRYPTOR_HPP |
| 22 | |
Yingdi Yu | b3c4776 | 2016-03-20 19:37:27 -0700 | [diff] [blame] | 23 | #include "encrypt-params.hpp" |
Zhiyi Zhang | 19a11d2 | 2018-04-12 22:58:20 -0700 | [diff] [blame] | 24 | #include <ndn-cxx/data.hpp> |
Prashanth Swaminathan | d5b3eae | 2015-07-09 15:37:05 -0700 | [diff] [blame] | 25 | |
| 26 | namespace ndn { |
Alexander Afanasyev | 9091d83 | 2018-04-18 17:21:08 -0400 | [diff] [blame^] | 27 | namespace nac { |
Prashanth Swaminathan | d5b3eae | 2015-07-09 15:37:05 -0700 | [diff] [blame] | 28 | namespace algo { |
| 29 | |
| 30 | /** |
| 31 | * @brief Prepare an encrypted data packet. |
| 32 | * |
| 33 | * This method will encrypt @p payload using @p key according to @p params. |
| 34 | * In addition, it will prepare the EncryptedContent TLVs with the encryption |
| 35 | * result with @p keyName and @p params. The TLV will be set as the content of |
| 36 | * @p data. If @p params defines an asymmetric encryption and the payload is |
| 37 | * larger than the max plaintext size, this method will encrypt the payload |
| 38 | * with a symmetric key that will be asymmetrically encrypted and provided as |
| 39 | * a nonce in the content of @p data. |
| 40 | */ |
| 41 | void |
Zhiyi Zhang | 19a11d2 | 2018-04-12 22:58:20 -0700 | [diff] [blame] | 42 | encryptData(Data& data, |
| 43 | const uint8_t* payload, |
| 44 | size_t payloadLen, |
| 45 | const Name& keyName, |
| 46 | const uint8_t* key, |
| 47 | size_t keyLen, |
Prashanth Swaminathan | d5b3eae | 2015-07-09 15:37:05 -0700 | [diff] [blame] | 48 | const EncryptParams& params); |
| 49 | |
| 50 | } // namespace algo |
Alexander Afanasyev | 9091d83 | 2018-04-18 17:21:08 -0400 | [diff] [blame^] | 51 | } // namespace nac |
Prashanth Swaminathan | d5b3eae | 2015-07-09 15:37:05 -0700 | [diff] [blame] | 52 | } // namespace ndn |
| 53 | |
| 54 | #endif // NDN_ENCRYPTOR_HPP |