blob: 685ea4ba83c64a694d0401c1583d77bb753ae41f [file] [log] [blame]
Prashanth Swaminathanc61cf192015-06-30 21:21:33 -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 Swaminathanc61cf192015-06-30 21:21:33 -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 Swaminathanc61cf192015-06-30 21:21:33 -07007 *
Alexander Afanasyev9091d832018-04-18 17:21:08 -04008 * NAC is free software: you can redistribute it and/or modify it under the terms
Prashanth Swaminathanc61cf192015-06-30 21:21:33 -07009 * 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 Afanasyev9091d832018-04-18 17:21:08 -040012 * NAC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
Prashanth Swaminathanc61cf192015-06-30 21:21:33 -070013 * 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 Afanasyev9091d832018-04-18 17:21:08 -040017 * NAC, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
Prashanth Swaminathanc61cf192015-06-30 21:21:33 -070018 */
19
Alexander Afanasyev9091d832018-04-18 17:21:08 -040020#ifndef NDN_NAC_ALGO_AES_HPP
21#define NDN_NAC_ALGO_AES_HPP
Prashanth Swaminathanc61cf192015-06-30 21:21:33 -070022
Zhiyi Zhang19a11d22018-04-12 22:58:20 -070023#include "common.hpp"
Yingdi Yub3c47762016-03-20 19:37:27 -070024#include "encrypt-params.hpp"
25#include "../decrypt-key.hpp"
Zhiyi Zhang19a11d22018-04-12 22:58:20 -070026#include <ndn-cxx/security/transform/block-cipher.hpp>
27#include <ndn-cxx/security/key-params.hpp>
Prashanth Swaminathanc61cf192015-06-30 21:21:33 -070028
29namespace ndn {
Alexander Afanasyev9091d832018-04-18 17:21:08 -040030namespace nac {
Prashanth Swaminathanc61cf192015-06-30 21:21:33 -070031namespace algo {
32
33class Aes
34{
35public:
36 static DecryptKey<Aes>
Zhiyi Zhang19a11d22018-04-12 22:58:20 -070037 generateKey(AesKeyParams& params);
Prashanth Swaminathanc61cf192015-06-30 21:21:33 -070038
39 static EncryptKey<Aes>
40 deriveEncryptKey(const Buffer& keyBits);
41
42 static Buffer
Prashanth Swaminathand5b3eae2015-07-09 15:37:05 -070043 decrypt(const uint8_t* key, size_t keyLen,
44 const uint8_t* payload, size_t payloadLen,
45 const EncryptParams& params);
Prashanth Swaminathanc61cf192015-06-30 21:21:33 -070046
47 static Buffer
Prashanth Swaminathand5b3eae2015-07-09 15:37:05 -070048 encrypt(const uint8_t* key, size_t keyLen,
49 const uint8_t* payload, size_t payloadLen,
50 const EncryptParams& params);
Prashanth Swaminathanc61cf192015-06-30 21:21:33 -070051};
52
Alexander Afanasyev9091d832018-04-18 17:21:08 -040053using AesEncryptKey = DecryptKey<Aes>;
54using AesDecryptKey = EncryptKey<Aes>;
Prashanth Swaminathanc61cf192015-06-30 21:21:33 -070055
56} // namespace algo
Alexander Afanasyev9091d832018-04-18 17:21:08 -040057} // namespace nac
Prashanth Swaminathanc61cf192015-06-30 21:21:33 -070058} // namespace ndn
59
Alexander Afanasyev9091d832018-04-18 17:21:08 -040060#endif // NDN_NAC_ALGO_AES_HPP