NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
digest.hpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22
#ifndef NDN_UTIL_DIGEST_HPP
23
#define NDN_UTIL_DIGEST_HPP
24
25
#include "../encoding/buffer.hpp"
26
#include "../encoding/block.hpp"
27
#include "../security/cryptopp.hpp"
28
#include "
concepts.hpp
"
29
30
namespace
ndn
{
31
namespace
util {
32
46
template
<
typename
Hash>
47
class
Digest
48
{
49
public
:
50
BOOST_CONCEPT_ASSERT((
Hashable<Hash>
));
51
52
typedef
Hash
HashFunction
;
53
54
class
Error
:
public
std::runtime_error
55
{
56
public
:
57
explicit
58
Error
(
const
std::string& what)
59
:
std
::runtime_error(what)
60
{
61
}
62
};
63
64
Digest
();
65
70
explicit
71
Digest
(std::istream& is);
72
76
void
77
reset
();
78
84
bool
85
empty
()
const
86
{
87
return
!m_isInProcess;
88
}
89
95
ConstBufferPtr
96
computeDigest
();
97
107
bool
108
operator==
(
Digest<Hash>
& digest);
109
119
bool
120
operator!=
(
Digest<Hash>
& digest)
121
{
122
return
!(*
this
== digest);
123
}
124
133
Digest<Hash>
&
134
operator<<(Digest<Hash>& src);
135
140
Digest<Hash>
&
141
operator<<
(
const
std::string& str);
142
147
Digest<Hash>
&
148
operator<<
(
const
Block
& block);
149
154
Digest<Hash>
&
155
operator<<
(uint64_t value);
156
167
void
168
update
(
const
uint8_t* buffer,
size_t
size);
169
176
static
ConstBufferPtr
177
computeDigest
(
const
uint8_t* buffer,
size_t
size);
178
185
std::string
186
toString
();
187
188
private
:
194
void
195
finalize();
196
197
private
:
198
Hash m_hash;
199
BufferPtr
m_buffer;
200
bool
m_isInProcess;
201
bool
m_isFinalized;
202
};
203
204
template
<
typename
Hash>
205
std::ostream&
206
operator<<(std::ostream& os, Digest<Hash>& digest);
207
211
typedef
Digest<CryptoPP::SHA256>
Sha256
;
212
213
}
// namespace util
214
}
// namespace ndn
215
216
#endif // NDN_UTIL_DIGEST_HPP
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndn::util::Digest::reset
void reset()
Discard the current state and start a new digest.
Definition:
digest.cpp:50
ndn::BufferPtr
shared_ptr< Buffer > BufferPtr
Definition:
buffer.hpp:35
ndn::util::Digest::Error
Definition:
digest.hpp:54
std
STL namespace.
ndn::util::Digest::operator!=
bool operator!=(Digest< Hash > &digest)
Check if supplied digest is not equal to this digest.
Definition:
digest.hpp:120
ndn::Block
Class representing a wire element of NDN-TLV packet format.
Definition:
block.hpp:43
ndn::util::Digest
provides a digest calculation
Definition:
digest.hpp:47
ndn::util::Digest::empty
bool empty() const
Check if digest is empty.
Definition:
digest.hpp:85
ndn::util::Digest::operator<<
Digest< Hash > & operator<<(Digest< Hash > &src)
Add existing digest to digest calculation.
Definition:
digest.cpp:88
ndn::util::Digest::HashFunction
Hash HashFunction
Definition:
digest.hpp:52
ndn::util::Sha256
Digest< CryptoPP::SHA256 > Sha256
A digest using SHA256 as the hash function.
Definition:
digest.hpp:211
ndn::util::Digest::Error::Error
Error(const std::string &what)
Definition:
digest.hpp:58
ndn::util::Digest::update
void update(const uint8_t *buffer, size_t size)
Add a buffer to digest calculation.
Definition:
digest.cpp:125
concepts.hpp
ndn::util::Digest::computeDigest
ConstBufferPtr computeDigest()
Obtain the digest.
Definition:
digest.cpp:73
ndn::util::Digest::operator==
bool operator==(Digest< Hash > &digest)
Check if supplied digest equal to this digest.
Definition:
digest.cpp:81
ndn::ConstBufferPtr
shared_ptr< const Buffer > ConstBufferPtr
Definition:
buffer.hpp:33
ndn::util::Digest::Digest
Digest()
Definition:
digest.cpp:30
ndn::util::Digest::toString
std::string toString()
Convert digest to std::string.
Definition:
digest.cpp:150
ndn::Hashable
a concept check for CryptoPP hash algorithm
Definition:
concepts.hpp:84
ndnSIM
ndn-cxx
src
util
digest.hpp
Generated on Tue Feb 23 2016 22:18:44 for ndnSIM by
1.8.11