Prashanth Swaminathan | d5b3eae | 2015-07-09 15:37:05 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2014-2015, Regents of the University of California |
| 4 | * |
| 5 | * This file is part of ndn-group-encrypt (Group-based Encryption Protocol for NDN). |
| 6 | * See AUTHORS.md for complete list of ndn-group-encrypt authors and contributors. |
| 7 | * |
| 8 | * ndn-group-encrypt is free software: you can redistribute it and/or modify it under |
| 9 | * the terms of the GNU General Public License as published by the Free Software |
| 10 | * Foundation, either version 3 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * ndn-group-encrypt is distributed in the hope that it will be useful, but WITHOUT |
| 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
| 14 | * A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along with |
| 17 | * ndn-group-encrypt, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | |
| 20 | #ifndef NDN_ENCRYPTOR_HPP |
| 21 | #define NDN_ENCRYPTOR_HPP |
| 22 | |
| 23 | #include <ndn-cxx/data.hpp> |
| 24 | #include "algo/encrypt-params.hpp" |
| 25 | |
| 26 | namespace ndn { |
| 27 | namespace gep { |
| 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 |
| 42 | encryptData(Data& data, const uint8_t* payload, size_t payloadLen, |
| 43 | const Name& keyName, const uint8_t* key, size_t keyLen, |
| 44 | const EncryptParams& params); |
| 45 | |
| 46 | } // namespace algo |
| 47 | } // namespace gep |
| 48 | } // namespace ndn |
| 49 | |
| 50 | #endif // NDN_ENCRYPTOR_HPP |