34 static Name digestSha256Identity(
"/localhost/identity/digest-sha256");
35 return digestSha256Identity;
41 static Name hmacIdentity(
"/localhost/identity/hmac");
46 const Name& signerName,
51 , m_info(signatureInfo)
72 if (signingStr.empty()) {
76 auto pos = signingStr.find(
':');
77 if (pos == std::string_view::npos) {
78 NDN_THROW(std::invalid_argument(
"Invalid signing string cannot represent SigningInfo"));
81 auto scheme = signingStr.substr(0, pos);
82 auto nameArg = signingStr.substr(pos + 1);
92 else if (scheme ==
"key") {
95 else if (scheme ==
"cert") {
98 else if (scheme ==
"hmac-sha256") {
103 NDN_THROW(std::invalid_argument(
"Invalid signing string scheme"));
129 m_name = certificateName;
142 m_hmacKey = make_shared<transform::PrivateKey>();
165 m_identity = identity;
181 m_info = signatureInfo;
210 return os <<
"Signed Interest v0.3";
212 return os <<
"Signed Interest v0.2";
214 return os <<
"Unknown signed Interest format " <<
to_underlying(format);
Represents an absolute name.
void clear()
Remove all components.
Name & append(const Component &component)
Append a name component.
An output stream that writes to a Buffer.
std::shared_ptr< Buffer > buf()
Return a shared pointer to the underlying buffer.
Represents a SignatureInfo or InterestSignatureInfo TLV element.
Represents a name component.
Signing parameters passed to KeyChain.
SigningInfo(SignerType signerType=SIGNER_TYPE_NULL, const Name &signerName=Name(), const SignatureInfo &signatureInfo=SignatureInfo())
Constructor.
SigningInfo & setPibIdentity(const Identity &identity)
Set signer as a PIB identity handle identity.
const Name & getSignerName() const
SigningInfo & setSigningIdentity(const Name &identity)
Set signer as an identity with name identity.
static const Name & getDigestSha256Identity()
A localhost identity to indicate that the signature is generated using SHA-256.
SigningInfo & setSha256Signing()
Set SHA-256 as the signing method.
SigningInfo & setSigningCertName(const Name &certificateName)
Set signer as a certificate with name certificateName.
static const Name & getHmacIdentity()
A localhost identity to indicate that the signature is generated using an HMAC key.
SigningInfo & setSignatureInfo(const SignatureInfo &signatureInfo)
Set a semi-prepared SignatureInfo.
SignerType getSignerType() const
Return the signer type.
SigningInfo & setSigningHmacKey(std::string_view hmacKey)
Set signer to a base64-encoded HMAC key.
@ SIGNER_TYPE_CERT
Signer is a certificate, use it directly.
@ SIGNER_TYPE_SHA256
Use a SHA-256 digest only, no signer needs to be specified.
@ SIGNER_TYPE_HMAC
Signer is a HMAC key.
@ SIGNER_TYPE_NULL
No signer is specified, use default setting or follow the trust schema.
@ SIGNER_TYPE_ID
Signer is an identity, use its default key and default certificate.
@ SIGNER_TYPE_KEY
Signer is a key, use its default certificate.
SigningInfo & setDigestAlgorithm(const DigestAlgorithm &algorithm)
Set the digest algorithm for signing operations.
SigningInfo & setSigningKeyName(const Name &keyName)
Set signer as a key with name keyName.
SigningInfo & setPibKey(const Key &key)
Set signer as a PIB key handle key.
Frontend handle for an identity in the PIB.
const Name & getName() const
Return the name of the identity.
Frontend handle for a key in the PIB.
const Name & getName() const
Return the name of the key.
Contains the ndn-cxx security framework.
std::ostream & operator<<(std::ostream &os, const AdditionalDescription &desc)
@ V03
Sign Interest using Packet Specification v0.3 semantics.
@ V02
Sign Interest using Packet Specification v0.2 semantics.
@ HMAC
HMAC key, supports sign/verify operations.
@ SHA256
Use the SHA-256 hash of the public key as key id.
constexpr std::underlying_type_t< T > to_underlying(T val) noexcept