NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
sha256.hpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2013-2018 Regents of the University of California.
4
*
5
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6
*
7
* ndn-cxx library is free software: you can redistribute it and/or modify it under the
8
* terms of the GNU Lesser General Public License as published by the Free Software
9
* Foundation, either version 3 of the License, or (at your option) any later version.
10
*
11
* ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14
*
15
* You should have received copies of the GNU General Public License and GNU Lesser
16
* General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17
* <http://www.gnu.org/licenses/>.
18
*
19
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20
*/
21
22
#ifndef NDN_UTIL_SHA256_HPP
23
#define NDN_UTIL_SHA256_HPP
24
25
#include "
ndn-cxx/encoding/block.hpp
"
26
#include "
ndn-cxx/encoding/buffer-stream.hpp
"
27
#include "
ndn-cxx/security/transform/step-source.hpp
"
28
29
namespace
ndn
{
30
namespace
util {
31
44
class
Sha256
45
{
46
public
:
47
class
Error
:
public
std::runtime_error
48
{
49
public
:
50
using
std::runtime_error::runtime_error;
51
};
52
56
static
const
size_t
DIGEST_SIZE
= 32;
57
61
Sha256
();
62
66
explicit
67
Sha256
(std::istream& is);
68
74
bool
75
empty
()
const
76
{
77
return
m_isEmpty;
78
}
79
83
void
84
reset
();
85
89
ConstBufferPtr
90
computeDigest
();
91
96
bool
97
operator==
(
Sha256
& digest);
98
103
bool
104
operator!=
(
Sha256
& digest)
105
{
106
return
!(*
this
== digest);
107
}
108
118
Sha256
&
119
operator<<
(
Sha256
& src);
120
125
Sha256
&
126
operator<<
(
const
std::string& str);
127
132
Sha256
&
133
operator<<
(
const
Block
& block);
134
139
Sha256
&
140
operator<<
(uint64_t value);
141
148
void
149
update
(
const
uint8_t* buffer,
size_t
size);
150
155
std::string
156
toString
();
157
164
static
ConstBufferPtr
165
computeDigest
(
const
uint8_t* buffer,
size_t
size);
166
167
private
:
168
unique_ptr<security::transform::StepSource> m_input;
169
unique_ptr<OBufferStream> m_output;
170
bool
m_isEmpty;
171
bool
m_isFinalized;
172
};
173
174
std::ostream&
175
operator<<
(std::ostream& os, Sha256& digest);
176
177
}
// namespace util
178
}
// namespace ndn
179
180
#endif // NDN_UTIL_SHA256_HPP
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndn::util::Sha256
Provides stateful SHA-256 digest calculation.
Definition:
sha256.hpp:44
ndn::util::Sha256::DIGEST_SIZE
static const size_t DIGEST_SIZE
Length in bytes of a SHA-256 digest.
Definition:
sha256.hpp:56
ndn::util::operator<<
std::ostream & operator<<(std::ostream &os, LogLevel level)
Output LogLevel as a string.
Definition:
logger.cpp:29
ndn::util::Sha256::operator==
bool operator==(Sha256 &digest)
Check if the supplied digest is equal to this digest.
Definition:
sha256.cpp:75
ndn::Block
Represents a TLV element of NDN packet format.
Definition:
block.hpp:42
ndn::util::Sha256::toString
std::string toString()
Convert digest to std::string.
Definition:
sha256.cpp:129
ndn::util::Sha256::Sha256
Sha256()
Create an empty SHA-256 digest.
Definition:
sha256.cpp:34
ndn::util::Sha256::update
void update(const uint8_t *buffer, size_t size)
Add a raw buffer to the digest calculation.
Definition:
sha256.cpp:118
ndn::util::Sha256::operator!=
bool operator!=(Sha256 &digest)
Check if the supplied digest is not equal to this digest.
Definition:
sha256.hpp:104
ndn::util::Sha256::reset
void reset()
Discard the current state and start a new digest calculation.
Definition:
sha256.cpp:50
ndn::util::Sha256::Error
Definition:
sha256.hpp:47
block.hpp
step-source.hpp
ndn::util::Sha256::computeDigest
ConstBufferPtr computeDigest()
Finalize and return the digest based on all previously supplied inputs.
Definition:
sha256.cpp:63
ndn::util::Sha256::operator<<
Sha256 & operator<<(Sha256 &src)
Add existing digest to the digest calculation.
Definition:
sha256.cpp:89
buffer-stream.hpp
ndn::util::Sha256::empty
bool empty() const
Check if digest is empty.
Definition:
sha256.hpp:75
ndn::ConstBufferPtr
shared_ptr< const Buffer > ConstBufferPtr
Definition:
buffer.hpp:126
ndnSIM
ndn-cxx
ndn-cxx
util
sha256.hpp
Generated on Sun Feb 24 2019 22:16:07 for ndnSIM by
1.8.15