Prashanth Swaminathan | c61cf19 | 2015-06-30 21:21:33 -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 | c61cf19 | 2015-06-30 21:21:33 -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 | c61cf19 | 2015-06-30 21:21:33 -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 |
Prashanth Swaminathan | c61cf19 | 2015-06-30 21:21:33 -0700 | [diff] [blame] | 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. |
| 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; |
Prashanth Swaminathan | c61cf19 | 2015-06-30 21:21:33 -0700 | [diff] [blame] | 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 | * 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 |
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 | c61cf19 | 2015-06-30 21:21:33 -0700 | [diff] [blame] | 18 | */ |
| 19 | |
Alexander Afanasyev | 9091d83 | 2018-04-18 17:21:08 -0400 | [diff] [blame^] | 20 | #ifndef NDN_NAC_ALGO_AES_HPP |
| 21 | #define NDN_NAC_ALGO_AES_HPP |
Prashanth Swaminathan | c61cf19 | 2015-06-30 21:21:33 -0700 | [diff] [blame] | 22 | |
Zhiyi Zhang | 19a11d2 | 2018-04-12 22:58:20 -0700 | [diff] [blame] | 23 | #include "common.hpp" |
Yingdi Yu | b3c4776 | 2016-03-20 19:37:27 -0700 | [diff] [blame] | 24 | #include "encrypt-params.hpp" |
| 25 | #include "../decrypt-key.hpp" |
Zhiyi Zhang | 19a11d2 | 2018-04-12 22:58:20 -0700 | [diff] [blame] | 26 | #include <ndn-cxx/security/transform/block-cipher.hpp> |
| 27 | #include <ndn-cxx/security/key-params.hpp> |
Prashanth Swaminathan | c61cf19 | 2015-06-30 21:21:33 -0700 | [diff] [blame] | 28 | |
| 29 | namespace ndn { |
Alexander Afanasyev | 9091d83 | 2018-04-18 17:21:08 -0400 | [diff] [blame^] | 30 | namespace nac { |
Prashanth Swaminathan | c61cf19 | 2015-06-30 21:21:33 -0700 | [diff] [blame] | 31 | namespace algo { |
| 32 | |
| 33 | class Aes |
| 34 | { |
| 35 | public: |
| 36 | static DecryptKey<Aes> |
Zhiyi Zhang | 19a11d2 | 2018-04-12 22:58:20 -0700 | [diff] [blame] | 37 | generateKey(AesKeyParams& params); |
Prashanth Swaminathan | c61cf19 | 2015-06-30 21:21:33 -0700 | [diff] [blame] | 38 | |
| 39 | static EncryptKey<Aes> |
| 40 | deriveEncryptKey(const Buffer& keyBits); |
| 41 | |
| 42 | static Buffer |
Prashanth Swaminathan | d5b3eae | 2015-07-09 15:37:05 -0700 | [diff] [blame] | 43 | decrypt(const uint8_t* key, size_t keyLen, |
| 44 | const uint8_t* payload, size_t payloadLen, |
| 45 | const EncryptParams& params); |
Prashanth Swaminathan | c61cf19 | 2015-06-30 21:21:33 -0700 | [diff] [blame] | 46 | |
| 47 | static Buffer |
Prashanth Swaminathan | d5b3eae | 2015-07-09 15:37:05 -0700 | [diff] [blame] | 48 | encrypt(const uint8_t* key, size_t keyLen, |
| 49 | const uint8_t* payload, size_t payloadLen, |
| 50 | const EncryptParams& params); |
Prashanth Swaminathan | c61cf19 | 2015-06-30 21:21:33 -0700 | [diff] [blame] | 51 | }; |
| 52 | |
Alexander Afanasyev | 9091d83 | 2018-04-18 17:21:08 -0400 | [diff] [blame^] | 53 | using AesEncryptKey = DecryptKey<Aes>; |
| 54 | using AesDecryptKey = EncryptKey<Aes>; |
Prashanth Swaminathan | c61cf19 | 2015-06-30 21:21:33 -0700 | [diff] [blame] | 55 | |
| 56 | } // namespace algo |
Alexander Afanasyev | 9091d83 | 2018-04-18 17:21:08 -0400 | [diff] [blame^] | 57 | } // namespace nac |
Prashanth Swaminathan | c61cf19 | 2015-06-30 21:21:33 -0700 | [diff] [blame] | 58 | } // namespace ndn |
| 59 | |
Alexander Afanasyev | 9091d83 | 2018-04-18 17:21:08 -0400 | [diff] [blame^] | 60 | #endif // NDN_NAC_ALGO_AES_HPP |