NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
crypto.cpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22
#include "
crypto.hpp
"
23
#include "../encoding/buffer-stream.hpp"
24
25
#include "../security/v1/cryptopp.hpp"
26
27
namespace
ndn
{
28
namespace
crypto {
29
30
ConstBufferPtr
31
computeSha256Digest
(
const
uint8_t* data,
size_t
dataLength)
32
{
33
try
{
34
CryptoPP::SHA256
hash;
35
OBufferStream
os;
36
CryptoPP::StringSource(data, dataLength,
true
,
37
new
CryptoPP::HashFilter(hash,
new
CryptoPP::FileSink(os)));
38
return
os.
buf
();
39
}
40
catch
(CryptoPP::Exception& e) {
41
return
ConstBufferPtr
();
42
}
43
}
44
45
}
// namespace crypto
46
}
// namespace ndn
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
crypto.hpp
ndn::OBufferStream::buf
shared_ptr< Buffer > buf()
Flush written data to the stream and return shared pointer to the underlying buffer.
Definition:
buffer-stream.cpp:54
ndn::crypto::computeSha256Digest
ConstBufferPtr computeSha256Digest(const uint8_t *data, size_t dataLength)
Compute the sha-256 digest of data.
Definition:
crypto.cpp:31
ndn::DigestAlgorithm::SHA256
ndn::OBufferStream
implements an output stream that constructs ndn::Buffer
Definition:
buffer-stream.hpp:70
ndn::ConstBufferPtr
shared_ptr< const Buffer > ConstBufferPtr
Definition:
buffer.hpp:33
ndnSIM
ndn-cxx
src
util
crypto.cpp
Generated on Wed Jan 11 2017 18:17:14 for ndnSIM by
1.8.13