aboutsummaryrefslogtreecommitdiffstats
path: root/libtransport/includes/hicn/transport/auth/verifier.h
diff options
context:
space:
mode:
Diffstat (limited to 'libtransport/includes/hicn/transport/auth/verifier.h')
-rw-r--r--libtransport/includes/hicn/transport/auth/verifier.h58
1 files changed, 35 insertions, 23 deletions
diff --git a/libtransport/includes/hicn/transport/auth/verifier.h b/libtransport/includes/hicn/transport/auth/verifier.h
index 6321d4ed5..2e086df4f 100644
--- a/libtransport/includes/hicn/transport/auth/verifier.h
+++ b/libtransport/includes/hicn/transport/auth/verifier.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2021 Cisco and/or its affiliates.
+ * Copyright (c) 2021 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -40,9 +40,9 @@ class Verifier {
// The VerificationFailedCallback will be called by the transport if a
// data packet (either a manifest or a content object) was not validated.
// The application decides what to do then by returning a
- // VerificationPolicy object.
+ // new VerificationPolicy.
using VerificationFailedCallback = std::function<auth::VerificationPolicy(
- const core::ContentObject &content_object, std::error_code ec)>;
+ Suffix suffix, VerificationPolicy policy)>;
// The list of VerificationPolicy that will trigger the
// VerificationFailedCallback.
@@ -54,12 +54,15 @@ class Verifier {
// Verify a single packet or buffer.
virtual bool verifyPacket(PacketPtr packet);
+ virtual bool verifyBuffer(const uint8_t *buffer, std::size_t len,
+ const utils::MemBuf::Ptr &signature,
+ CryptoSuite suite) = 0;
virtual bool verifyBuffer(const std::vector<uint8_t> &buffer,
- const std::vector<uint8_t> &signature,
- CryptoHashType hash_type) = 0;
+ const utils::MemBuf::Ptr &signature,
+ CryptoSuite suite) = 0;
virtual bool verifyBuffer(const utils::MemBuf *buffer,
- const std::vector<uint8_t> &signature,
- CryptoHashType hash_type) = 0;
+ const utils::MemBuf::Ptr &signature,
+ CryptoSuite suite) = 0;
// Verify a batch of packets. Return a mapping from packet suffixes to their
// VerificationPolicy.
@@ -96,13 +99,13 @@ class Verifier {
void getVerificationFailedCallback(
VerificationFailedCallback **verification_failed_cb);
+ // Call VerificationFailedCallback if it is set and update the packet policy.
+ void callVerificationFailedCallback(Suffix suffix,
+ VerificationPolicy &policy);
+
protected:
VerificationFailedCallback verification_failed_cb_;
std::vector<VerificationPolicy> failed_policies_;
-
- // Call VerificationFailedCallback if it is set and update the packet policy.
- void callVerificationFailedCallback(PacketPtr packet,
- VerificationPolicy &policy);
};
class VoidVerifier : public Verifier {
@@ -110,12 +113,15 @@ class VoidVerifier : public Verifier {
// and always returns true.
public:
bool verifyPacket(PacketPtr packet) override;
+ bool verifyBuffer(const uint8_t *buffer, std::size_t len,
+ const utils::MemBuf::Ptr &signature,
+ CryptoSuite suite) override;
bool verifyBuffer(const std::vector<uint8_t> &buffer,
- const std::vector<uint8_t> &signature,
- CryptoHashType hash_type) override;
+ const utils::MemBuf::Ptr &signature,
+ CryptoSuite suite) override;
bool verifyBuffer(const utils::MemBuf *buffer,
- const std::vector<uint8_t> &signature,
- CryptoHashType hash_type) override;
+ const utils::MemBuf::Ptr &signature,
+ CryptoSuite suite) override;
PolicyMap verifyPackets(const std::vector<PacketPtr> &packets) override;
@@ -143,12 +149,15 @@ class AsymmetricVerifier : public Verifier {
void useCertificate(const std::string &cert_path);
void useCertificate(std::shared_ptr<X509> cert);
+ bool verifyBuffer(const uint8_t *buffer, std::size_t len,
+ const utils::MemBuf::Ptr &signature,
+ CryptoSuite suite) override;
bool verifyBuffer(const std::vector<uint8_t> &buffer,
- const std::vector<uint8_t> &signature,
- CryptoHashType hash_type) override;
+ const utils::MemBuf::Ptr &signature,
+ CryptoSuite suite) override;
bool verifyBuffer(const utils::MemBuf *buffer,
- const std::vector<uint8_t> &signature,
- CryptoHashType hash_type) override;
+ const utils::MemBuf::Ptr &signature,
+ CryptoSuite suite) override;
private:
std::shared_ptr<EVP_PKEY> key_;
@@ -166,12 +175,15 @@ class SymmetricVerifier : public Verifier {
// Create and set a symmetric key from a passphrase.
void setPassphrase(const std::string &passphrase);
+ bool verifyBuffer(const uint8_t *buffer, std::size_t len,
+ const utils::MemBuf::Ptr &signature,
+ CryptoSuite suite) override;
bool verifyBuffer(const std::vector<uint8_t> &buffer,
- const std::vector<uint8_t> &signature,
- CryptoHashType hash_type) override;
+ const utils::MemBuf::Ptr &signature,
+ CryptoSuite suite) override;
bool verifyBuffer(const utils::MemBuf *buffer,
- const std::vector<uint8_t> &signature,
- CryptoHashType hash_type) override;
+ const utils::MemBuf::Ptr &signature,
+ CryptoSuite suite) override;
protected:
std::shared_ptr<EVP_PKEY> key_;