blob: e04ef7801a786bb7605a0fdc71334901c1584038 [file] [log] [blame]
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
/**
* Copyright (C) 2013 Regents of the University of California.
* See COPYING for copyright and distribution information.
*/
#ifndef NDN_SECURITY_SIGNATURE_SHA256_WITH_RSA_HPP
#define NDN_SECURITY_SIGNATURE_SHA256_WITH_RSA_HPP
#include "../data.hpp"
#include "../encoding/tlv.hpp"
namespace ndn {
/**
* Representing of SHA256-with-RSA signature in a data packet.
*/
class SignatureSha256WithRsa : public Signature {
public:
SignatureSha256WithRsa()
{
info_ = Block(Tlv::SignatureInfo);
type_ = Signature::Sha256WithRsa;
info_.push_back(nonNegativeIntegerBlock(Tlv::SignatureType, Tlv::SignatureSha256WithRsa));
info_.push_back(keyLocator_.wireEncode());
}
SignatureSha256WithRsa(const Signature &signature)
: Signature(signature)
{
if (getType() != Signature::Sha256WithRsa)
throw Signature::Error("Incorrect signature type");
info_.parse();
Block::element_const_iterator i = info_.find(Tlv::KeyLocator);
if (i != info_.elements_end())
{
keyLocator_.wireDecode(*i);
}
}
const KeyLocator&
getKeyLocator() const
{
return keyLocator_;
}
void
setKeyLocator(const KeyLocator& keyLocator)
{
keyLocator_ = keyLocator;
info_.remove(ndn::Tlv::KeyLocator);
info_.push_back(keyLocator_.wireEncode());
}
private:
KeyLocator keyLocator_;
};
} // namespace ndn
#endif //NDN_SECURITY_SIGNATURE_SHA256_WITH_RSA_HPP