23 #ifndef NDN_CONSUMER_HPP
24 #define NDN_CONSUMER_HPP
27 #include "../data.hpp"
28 #include "../face.hpp"
29 #include "../security/key-chain.hpp"
30 #include "encrypt-error.hpp"
31 #include "encrypted-content.hpp"
32 #include "consumer-db.hpp"
35 class TestConsumer_DecryptContent_Test;
62 const Name& consumerName,
const ptr_lib::shared_ptr<ConsumerDb>& database)
63 : impl_(
new Impl(face, keyChain, groupName, consumerName, database))
67 typedef func_lib::function<void
68 (
const ptr_lib::shared_ptr<Data>& contentData,
69 const Blob& result)> OnConsumeComplete;
88 (
const Name& contentName,
const OnConsumeComplete& onConsumeComplete,
91 impl_->consume(contentName, onConsumeComplete, onError);
113 impl_->addDecryptionKey(keyName, keyBlob);
118 friend TestConsumer_DecryptContent_Test;
124 class Impl :
public ptr_lib::enable_shared_from_this<Impl> {
132 const Name& consumerName,
const ptr_lib::shared_ptr<ConsumerDb>& database);
136 (
const Name& contentName,
const OnConsumeComplete& onConsumeComplete,
140 setGroup(
const Name& groupName) { groupName_ = groupName; }
147 friend TestConsumer_DecryptContent_Test;
149 typedef func_lib::function<void(const Blob& decryptedBlob)> OnPlainText;
161 (
const Blob& encryptedBlob,
const Blob& keyBits,
173 decryptEncryptedContent
174 (
const EncryptedContent& encryptedContent,
const Blob& keyBits,
186 (
const Data& data,
const OnPlainText& onPlainText,
198 (
const Data& cKeyData,
const OnPlainText& onPlainText,
210 (
const Data& dKeyData,
const OnPlainText& onPlainText,
222 getDecryptionKey(
const Name& decryptionKeyName)
224 return database_->getKey(decryptionKeyName);
233 (
const ptr_lib::shared_ptr<Data>& data,
const std::string& reason,
242 (
const ptr_lib::shared_ptr<const Interest>& interest,
245 ptr_lib::shared_ptr<ConsumerDb> database_;
251 std::map<Name, Blob> cKeyMap_;
253 std::map<Name, Blob> dKeyMap_;
256 ptr_lib::shared_ptr<Impl> impl_;
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:36
Consumer(Face *face, KeyChain *keyChain, const Name &groupName, const Name &consumerName, const ptr_lib::shared_ptr< ConsumerDb > &database)
Create a Consumer to use the given ConsumerDb, Face and other values.
Definition: consumer.hpp:61
The Face class provides the main methods for NDN communication.
Definition: face.hpp:86
func_lib::function< void(ErrorCode errorCode, const std::string &message)> OnError
A method calls onError(errorCode, message) for an error.
Definition: encrypt-error.hpp:49
KeyChain is the main class of the security library.
Definition: key-chain.hpp:45
A Consumer manages fetched group keys used to decrypt a data packet in the group-based encryption pro...
Definition: consumer.hpp:44
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:40
A Blob holds a pointer to an immutable byte array implemented as const std::vector.
Definition: blob.hpp:42
void consume(const Name &contentName, const OnConsumeComplete &onConsumeComplete, const EncryptError::OnError &onError)
Express an Interest to fetch the content packet with contentName, and decrypt it, fetching keys as ne...
Definition: consumer.hpp:88
void setGroup(const Name &groupName)
Set the group name.
Definition: consumer.hpp:100
void addDecryptionKey(const Name &keyName, const Blob &keyBlob)
Add a new decryption key with keyName and keyBlob to the database.
Definition: consumer.hpp:111