blob: a24e94b70df57eb0043966ec1c18ef881b2f4bd6 [file] [log] [blame]
Alexander Afanasyevfa13f8e2014-01-03 15:19:07 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/**
3 * Copyright (C) 2013 Regents of the University of California.
4 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
5 * See COPYING for copyright and distribution information.
6 */
7
8#ifndef NDN_SIGNATURE_SHA256_WITH_RSA_HPP
9#define NDN_SIGNATURE_SHA256_WITH_RSA_HPP
10
11#include "../../data.hpp"
12
13namespace ndn {
14
15/**
16 * Representing of SHA256-with-RSA signature in a data packet.
17 */
18class SignatureSha256WithRsa : public Signature {
19public:
20 SignatureSha256WithRsa()
21 {
22 info_ = Block(Tlv::SignatureInfo);
23
24 type_ = Signature::Sha256WithRsa;
25 info_.push_back(nonNegativeIntegerBlock(Tlv::SignatureType, Tlv::SignatureSha256WithRsa));
26 }
27
28 SignatureSha256WithRsa(const Signature &signature)
29 : Signature(signature)
30 {
31 if (getType() != Signature::Sha256WithRsa)
32 throw Signature::Error("Incorrect signature type");
33
34 info_.parse();
35 Block::element_iterator i = info_.find(Tlv::KeyLocator);
36 if (i != info_.getAll().end())
37 {
38 keyLocator_.wireDecode(*i);
39 }
40 }
41
42 const KeyLocator&
43 getKeyLocator() const
44 {
45 return keyLocator_;
46 }
47
48 void
49 setKeyLocator(const KeyLocator& keyLocator)
50 {
51 keyLocator_ = keyLocator;
52
53 /// @todo Ensure that keylocator does not exist
54 info_.push_back(keyLocator_.wireEncode());
55 }
56
57private:
58 KeyLocator keyLocator_;
59};
60
61} // namespace ndn
62
63#endif