blob: fdccea706b10dd7c2d18fb70cbceab874ab5753f [file] [log] [blame]
Prashanth Swaminathanc61cf192015-06-30 21:21:33 -07001/* -*- 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_GEP_DECRYPT_KEY_HPP
21#define NDN_GEP_DECRYPT_KEY_HPP
22
23#include "encrypt-key.hpp"
24
25namespace ndn {
26namespace gep {
27
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&
50 getKeyBits()
51 {
52 return m_keyBits;
53 }
54
55private:
56 Buffer m_keyBits;
57};
58
59} // namespace gep
60} // namespace ndn
61
62#endif // NDN_GEP_DECRYPT_KEY_HPP