blob: 7c46355650542e3b164433e0878fd12c80cb1b09 [file] [log] [blame]
Prashanth Swaminathand5b3eae2015-07-09 15:37:05 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Alexander Afanasyev9091d832018-04-18 17:21:08 -04003 * Copyright (c) 2014-2018, Regents of the University of California
Prashanth Swaminathand5b3eae2015-07-09 15:37:05 -07004 *
Alexander Afanasyev9091d832018-04-18 17:21:08 -04005 * 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 Swaminathand5b3eae2015-07-09 15:37:05 -07007 *
Alexander Afanasyev9091d832018-04-18 17:21:08 -04008 * 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 Swaminathand5b3eae2015-07-09 15:37:05 -070011 *
Alexander Afanasyev9091d832018-04-18 17:21:08 -040012 * 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 Swaminathand5b3eae2015-07-09 15:37:05 -070015 *
16 * You should have received a copy of the GNU General Public License along with
Alexander Afanasyev9091d832018-04-18 17:21:08 -040017 * NAC, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
Prashanth Swaminathand5b3eae2015-07-09 15:37:05 -070018 */
19
20#ifndef NDN_ENCRYPTOR_HPP
21#define NDN_ENCRYPTOR_HPP
22
Yingdi Yub3c47762016-03-20 19:37:27 -070023#include "encrypt-params.hpp"
Zhiyi Zhang19a11d22018-04-12 22:58:20 -070024#include <ndn-cxx/data.hpp>
Prashanth Swaminathand5b3eae2015-07-09 15:37:05 -070025
26namespace ndn {
Alexander Afanasyev9091d832018-04-18 17:21:08 -040027namespace nac {
Prashanth Swaminathand5b3eae2015-07-09 15:37:05 -070028namespace 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 */
41void
Zhiyi Zhang19a11d22018-04-12 22:58:20 -070042encryptData(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 Swaminathand5b3eae2015-07-09 15:37:05 -070048 const EncryptParams& params);
49
50} // namespace algo
Alexander Afanasyev9091d832018-04-18 17:21:08 -040051} // namespace nac
Prashanth Swaminathand5b3eae2015-07-09 15:37:05 -070052} // namespace ndn
53
54#endif // NDN_ENCRYPTOR_HPP