blob: 296cb2224bb498947f1af5b9945345d072709dfd [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 gep (Group-based Encryption Protocol for NDN).
6 * See AUTHORS.md for complete list of gep authors and contributors.
7 *
8 * gep 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.
11 *
12 * gep 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.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * gep, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "random-number-generator.hpp"
21#include "encrypt-params.hpp"
22
23namespace ndn {
24namespace gep {
25namespace algo {
26
27EncryptParams::EncryptParams(EncryptionMode encryptMode, PaddingScheme paddingScheme, uint8_t ivLength = 0)
28 : m_encryptMode(encryptMode)
29 , m_paddingScheme(paddingScheme)
30{
31 if (ivLength != 0){
32 RandomNumberGenerator rng;
33 m_iv.resize(ivLength);
34 rng.GenerateBlock(m_iv.buf(), m_iv.size());
35 }
36}
37
38void
39EncryptParams::setIV(const Buffer& iv)
40{
41 m_iv = iv;
42}
43
44void
45EncryptParams::setEncryptMode(const EncryptionMode& encryptMode)
46{
47 m_encryptMode = encryptMode;
48}
49
50void
51EncryptParams::setPaddingScheme(const PaddingScheme& paddingScheme)
52{
53 m_paddingScheme = paddingScheme;
54}
55
56Buffer
57EncryptParams::getIV() const
58{
59 return m_iv;
60}
61
62EncryptionMode
63EncryptParams::getEncryptMode() const
64{
65 return m_encryptMode;
66}
67
68PaddingScheme
69EncryptParams::getPaddingScheme() const
70{
71 return m_paddingScheme;
72}
73
74} // namespace algo
75} // namespace gep
76} // namespace ndn