Yingdi Yu | 2115716 | 2014-02-28 13:02:34 -0800 | [diff] [blame] | 1 | /* -*- 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 | |
| 13 | namespace ndn { |
| 14 | |
| 15 | /** |
| 16 | * Representing of SHA256 signature in a data packet. |
| 17 | */ |
| 18 | class SignatureSha256 : public Signature { |
| 19 | public: |
| 20 | SignatureSha256() |
| 21 | { |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 22 | m_info = Block(Tlv::SignatureInfo); |
| 23 | |
| 24 | m_type = Signature::Sha256; |
| 25 | m_info.push_back(nonNegativeIntegerBlock(Tlv::SignatureType, Tlv::DigestSha256)); |
Yingdi Yu | 2115716 | 2014-02-28 13:02:34 -0800 | [diff] [blame] | 26 | } |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 27 | |
Yingdi Yu | 2115716 | 2014-02-28 13:02:34 -0800 | [diff] [blame] | 28 | SignatureSha256(const Signature &signature) |
| 29 | : 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 |