blob: 8ef37a856e6be1f2ad4135e0171f9ce917ced53f [file] [log] [blame]
Yingdi Yu21157162014-02-28 13:02:34 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/**
3 * Copyright (C) 2013 Regents of the University of California.
4 * See COPYING for copyright and distribution information.
5 */
6
7#ifndef NDN_SECURITY_SIGNATURE_SHA256_HPP
8#define NDN_SECURITY_SIGNATURE_SHA256_HPP
9
10#include "../data.hpp"
11#include "../encoding/tlv.hpp"
12
13namespace ndn {
14
15/**
16 * Representing of SHA256 signature in a data packet.
17 */
18class SignatureSha256 : public Signature {
19public:
20 SignatureSha256()
21 {
Alexander Afanasyevff2d08f2014-04-07 18:28:25 -070022 m_info = Block(Tlv::SignatureInfo);
23
24 m_type = Signature::Sha256;
25 m_info.push_back(nonNegativeIntegerBlock(Tlv::SignatureType, Tlv::DigestSha256));
Yingdi Yu21157162014-02-28 13:02:34 -080026 }
Alexander Afanasyevff2d08f2014-04-07 18:28:25 -070027
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070028 SignatureSha256(const Signature& signature)
Yingdi Yu21157162014-02-28 13:02:34 -080029 : Signature(signature)
30 {
31 if (getType() != Signature::Sha256)
32 throw Signature::Error("Incorrect signature type");
33 }
34};
35
36} // namespace ndn
37
38#endif //NDN_SECURITY_SIGNATURE_SHA256_HPP