blob: dd2afcf4ccd4c1e31c364bcf7bac5a8611687ac9 [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
Yingdi Yub3c47762016-03-20 19:37:27 -070020#include "../random-number-generator.hpp"
Prashanth Swaminathanc61cf192015-06-30 21:21:33 -070021#include "encrypt-params.hpp"
22
23namespace ndn {
24namespace gep {
25namespace algo {
26
Prashanth Swaminathand5b3eae2015-07-09 15:37:05 -070027EncryptParams::EncryptParams(tlv::AlgorithmTypeValue algorithm, uint8_t ivLength)
28 : m_algo(algorithm)
Prashanth Swaminathanc61cf192015-06-30 21:21:33 -070029{
30 if (ivLength != 0){
31 RandomNumberGenerator rng;
32 m_iv.resize(ivLength);
33 rng.GenerateBlock(m_iv.buf(), m_iv.size());
34 }
35}
36
37void
Prashanth Swaminathand5b3eae2015-07-09 15:37:05 -070038EncryptParams::setIV(const uint8_t* iv, size_t ivLen)
Prashanth Swaminathanc61cf192015-06-30 21:21:33 -070039{
Prashanth Swaminathand5b3eae2015-07-09 15:37:05 -070040 m_iv = Buffer(iv, ivLen);
Prashanth Swaminathanc61cf192015-06-30 21:21:33 -070041}
42
43void
Prashanth Swaminathand5b3eae2015-07-09 15:37:05 -070044EncryptParams::setAlgorithmType(tlv::AlgorithmTypeValue algorithm)
Prashanth Swaminathanc61cf192015-06-30 21:21:33 -070045{
Prashanth Swaminathand5b3eae2015-07-09 15:37:05 -070046 m_algo = algorithm;
Prashanth Swaminathanc61cf192015-06-30 21:21:33 -070047}
48
49Buffer
50EncryptParams::getIV() const
51{
52 return m_iv;
53}
54
Prashanth Swaminathand5b3eae2015-07-09 15:37:05 -070055tlv::AlgorithmTypeValue
56EncryptParams::getAlgorithmType() const
Prashanth Swaminathanc61cf192015-06-30 21:21:33 -070057{
Prashanth Swaminathand5b3eae2015-07-09 15:37:05 -070058 return m_algo;
Prashanth Swaminathanc61cf192015-06-30 21:21:33 -070059}
60
61} // namespace algo
62} // namespace gep
Prashanth Swaminathand5b3eae2015-07-09 15:37:05 -070063} // namespace ndn