28 #include "ndn-cxx/security/impl/openssl.hpp"
46 ParseResult() =
default;
58 span<const uint8_t>
sig;
68 using namespace transform;
94 parse(
const Data& data)
99 {data.getSignatureValue().value(), data.getSignatureValue().value_size()});
101 catch (
const tlv::Error&) {
102 return ParseResult();
110 interest.wireEncode();
112 if (interest.getSignatureInfo() && interest.getSignatureValue().isValid()) {
114 Block sigValue = interest.getSignatureValue();
115 return ParseResult(*interest.getSignatureInfo(),
116 interest.extractSignedRanges(),
117 {sigValue.value(), sigValue.value_size()});
121 const Name& interestName = interest.getName();
123 return ParseResult();
126 const Block& nameBlock = interestName.wireEncode();
129 return ParseResult(
info,
133 sigValue.value_size()});
136 catch (
const tlv::Error&) {
137 return ParseResult();
142 verifySignature(
const ParseResult& params,
const transform::PublicKey& key)
144 return !params.bufs.empty() &&
verifySignature(params.bufs, params.sig, key);
150 return !params.bufs.empty() &&
verifySignature(params.bufs, params.sig, key);
157 return !params.bufs.empty() && bool(tpm.verify(params.bufs, params.sig, keyName, digestAlgorithm));
163 if (params.bufs.empty()) {
169 using namespace transform;
172 catch (
const transform::Error&) {
175 auto result = os.buf();
177 if (result->size() != params.sig.size()) {
182 return CRYPTO_memcmp(result->data(), params.sig.data(), params.sig.size()) == 0;
224 auto parsed = parse(data);
226 return verifySignature(parsed, {cert->getContent().value(), cert->getContent().value_size()});
240 auto parsed = parse(interest);
242 return verifySignature(parsed, {cert->getContent().value(), cert->getContent().value_size()});
264 return verifySignature(parse(interest), tpm, keyName, digestAlgorithm);
Represents a Data packet.
InputBuffers extractSignedRanges() const
Extract ranges of Data covered by the signature.
const SignatureInfo & getSignatureInfo() const noexcept
Get SignatureInfo.
Represents an Interest packet.
Represents an absolute name.
A frontend handle of a key instance.
span< const uint8_t > getPublicKey() const
Get public key bits.
bool verifySignature(const InputBuffers &blobs, span< const uint8_t > sig, const transform::PublicKey &key)
Verify blobs using key against sig.
const ssize_t POS_SIG_VALUE
const size_t MIN_SIZE
minimal number of components for Signed Interest
const ssize_t POS_SIG_INFO
span< const uint8_t > sig