blob: 4c610997709fdc3e23f5a1e6ffd21efbf8632f51 [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
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 Swaminathanc61cf192015-06-30 21:21:33 -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 Swaminathanc61cf192015-06-30 21:21:33 -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 Swaminathanc61cf192015-06-30 21:21:33 -070018 */
19
Alexander Afanasyev9091d832018-04-18 17:21:08 -040020#ifndef NDN_NAC_DECRYPT_KEY_HPP
21#define NDN_NAC_DECRYPT_KEY_HPP
Prashanth Swaminathanc61cf192015-06-30 21:21:33 -070022
23#include "encrypt-key.hpp"
24
25namespace ndn {
Alexander Afanasyev9091d832018-04-18 17:21:08 -040026namespace nac {
Prashanth Swaminathanc61cf192015-06-30 21:21:33 -070027
28template<class Algorithm>
29class DecryptKey
30{
31public:
32 DecryptKey(Buffer&& keyBits)
33 : m_keyBits(keyBits)
34 {
35 }
36
37 EncryptKey<Algorithm>
38 deriveEncryptKey()
39 {
40 return Algorithm::deriveEncryptKey(m_keyBits);
41 }
42
43 Buffer
44 decrypt(const Buffer& encryptedData)
45 {
46 return Algorithm::decrypt(m_keyBits, encryptedData);
47 }
48
49 const Buffer&
Zhiyi Zhang3ac0d8d2015-10-28 14:07:09 +080050 getKeyBits() const
Prashanth Swaminathanc61cf192015-06-30 21:21:33 -070051 {
52 return m_keyBits;
53 }
54
55private:
56 Buffer m_keyBits;
57};
58
Alexander Afanasyev9091d832018-04-18 17:21:08 -040059} // namespace nac
Prashanth Swaminathanc61cf192015-06-30 21:21:33 -070060} // namespace ndn
61
Alexander Afanasyev9091d832018-04-18 17:21:08 -040062#endif // NDN_NAC_DECRYPT_KEY_HPP