33 #include "../data.hpp" 34 #include "../interest.hpp" 35 #include "../encoding/buffer-stream.hpp" 41 verifySignature(
const uint8_t* blob,
size_t blobLen,
const uint8_t* sig,
size_t sigLen,
42 const v2::PublicKey& pKey)
57 verifySignature(
const uint8_t* data,
size_t dataLen,
const uint8_t* sig,
size_t sigLen,
58 const uint8_t* key,
size_t keyLen)
62 pKey.loadPkcs8(key, keyLen);
71 static std::tuple<bool, const uint8_t*, size_t, const uint8_t*, size_t>
75 return std::make_tuple(
true,
82 return std::make_tuple(
false,
nullptr, 0,
nullptr, 0);
86 static std::tuple<bool, const uint8_t*, size_t, const uint8_t*, size_t>
92 return std::make_tuple(
false,
nullptr, 0,
nullptr, 0);
97 return std::make_tuple(
true,
103 return std::make_tuple(
false,
nullptr, 0,
nullptr, 0);
108 verifySignature(
const std::tuple<bool, const uint8_t*, size_t, const uint8_t*, size_t>& params,
109 const v2::PublicKey& pKey)
111 bool isParsable =
false;
112 const uint8_t* buf =
nullptr;
114 const uint8_t* sig =
nullptr;
117 std::tie(isParsable, buf, bufLen, sig, sigLen) = params;
126 verifySignature(
const std::tuple<bool, const uint8_t*, size_t, const uint8_t*, size_t>& params,
127 const uint8_t* key,
size_t keyLen)
129 bool isParsable =
false;
130 const uint8_t* buf =
nullptr;
132 const uint8_t* sig =
nullptr;
135 std::tie(isParsable, buf, bufLen, sig, sigLen) = params;
194 verifyDigest(
const uint8_t* blob,
size_t blobLen,
const uint8_t* digest,
size_t digestLen,
208 if (result->size() != digestLen)
212 return CRYPTO_memcmp(result->data(), digest, digestLen) == 0;
218 bool isParsable =
false;
219 const uint8_t* buf =
nullptr;
221 const uint8_t* sig =
nullptr;
224 std::tie(isParsable, buf, bufLen, sig, sigLen) =
parse(data);
227 return verifyDigest(buf, bufLen, sig, sigLen, algorithm);
237 bool isParsable =
false;
238 const uint8_t* buf =
nullptr;
240 const uint8_t* sig =
nullptr;
243 std::tie(isParsable, buf, bufLen, sig, sigLen) =
parse(interest);
246 return verifyDigest(buf, bufLen, sig, sigLen, algorithm);
const Name & getName() const
Copyright (c) 2011-2015 Regents of the University of California.
The certificate following the certificate format naming convention.
const Signature & getSignature() const
Get Signature.
const size_t MIN_SIZE
minimal number of components for Signed Interest
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Fast encoding or block size estimation.
Represents a TLV element of NDN packet format.
represents an Interest packet
const Block & getValue() const
Get SignatureValue.
Catch-all error for security policy errors that don't fit in other categories.
size_t size() const
Get size of encoded wire, including Type-Length-Value.
bool verifyDigest(const uint8_t *blob, size_t blobLen, const uint8_t *digest, size_t digestLen, DigestAlgorithm algorithm)
Verify blob against digest using algorithm.
size_t wireEncode(EncodingImpl< TAG > &encoder, bool wantUnsignedPortionOnly=false) const
Fast encoding or block size estimation.
A frontend handle of a key instance.
size_t size() const
Get number of components.
Use the SHA256 hash of the public key as the key id.
Represents an absolute name.
size_t value_size() const
Get size of TLV-VALUE aka TLV-LENGTH.
const ssize_t POS_SIG_VALUE
const Buffer & getPublicKey() const
Get public key bits.
bool verifySignature(const uint8_t *blob, size_t blobLen, const uint8_t *sig, size_t sigLen, const v2::PublicKey &pKey)
Verify blob using key against sig.
shared_ptr< Buffer > buf()
Flush written data to the stream and return shared pointer to the underlying buffer.
const Block & getContent() const
Get Content.
static std::tuple< bool, const uint8_t *, size_t, const uint8_t *, size_t > parse(const Data &data)
const uint8_t * value() const
Get pointer to TLV-VALUE.
implements an output stream that constructs ndn::Buffer
Represents a Data packet.
represents an error in TLV encoding or decoding
shared_ptr< const Buffer > ConstBufferPtr