Jeff Thompson | 8238d00 | 2013-07-10 11:56:49 -0700 | [diff] [blame] | 1 | /** |
| 2 | * @author: Jeff Thompson |
| 3 | * See COPYING for copyright and distribution information. |
| 4 | */ |
| 5 | |
| 6 | #ifndef NDN_PUBLISHERPUBLICKEYDIGEST_HPP |
Jeff Thompson | 2d27e2f | 2013-08-09 12:55:00 -0700 | [diff] [blame] | 7 | #define NDN_PUBLISHERPUBLICKEYDIGEST_HPP |
Jeff Thompson | 8238d00 | 2013-07-10 11:56:49 -0700 | [diff] [blame] | 8 | |
| 9 | #include <vector> |
Jeff Thompson | 51dd5fd | 2013-07-10 19:27:18 -0700 | [diff] [blame] | 10 | #include "common.hpp" |
Jeff Thompson | 5341219 | 2013-08-06 13:35:50 -0700 | [diff] [blame] | 11 | #include "c/publisher-public-key-digest.h" |
Jeff Thompson | 8238d00 | 2013-07-10 11:56:49 -0700 | [diff] [blame] | 12 | |
| 13 | namespace ndn { |
| 14 | |
| 15 | /** |
| 16 | * A PublisherPublicKeyDigest holds the publisher public key digest value, if any. |
| 17 | * We make a separate class since this is used by multiple other classes. |
| 18 | */ |
| 19 | class PublisherPublicKeyDigest { |
| 20 | public: |
| 21 | PublisherPublicKeyDigest() { |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Set the publisherPublicKeyDigestStruct to point to the entries in this PublisherPublicKeyDigest, without copying any memory. |
| 26 | * WARNING: The resulting pointers in publisherPublicKeyDigestStruct are invalid after a further use of this object which could reallocate memory. |
| 27 | * @param publisherPublicKeyDigestStruct a C ndn_PublisherPublicKeyDigest struct to receive the pointer |
| 28 | */ |
Jeff Thompson | 1656e6a | 2013-08-29 18:01:48 -0700 | [diff] [blame] | 29 | void get(struct ndn_PublisherPublicKeyDigest& publisherPublicKeyDigestStruct) const |
Jeff Thompson | 8238d00 | 2013-07-10 11:56:49 -0700 | [diff] [blame] | 30 | { |
| 31 | publisherPublicKeyDigestStruct.publisherPublicKeyDigestLength = publisherPublicKeyDigest_.size(); |
| 32 | if (publisherPublicKeyDigest_.size() > 0) |
Jeff Thompson | 03616c9 | 2013-09-12 14:30:01 -0700 | [diff] [blame^] | 33 | publisherPublicKeyDigestStruct.publisherPublicKeyDigest = (unsigned char *)publisherPublicKeyDigest_.buf(); |
Jeff Thompson | 8238d00 | 2013-07-10 11:56:49 -0700 | [diff] [blame] | 34 | else |
| 35 | publisherPublicKeyDigestStruct.publisherPublicKeyDigest = 0; |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Clear this PublisherPublicKeyDigest, and copy from the ndn_PublisherPublicKeyDigest struct. |
| 40 | * @param excludeStruct a C ndn_Exclude struct |
| 41 | */ |
Jeff Thompson | 1656e6a | 2013-08-29 18:01:48 -0700 | [diff] [blame] | 42 | void set(const struct ndn_PublisherPublicKeyDigest& publisherPublicKeyDigestStruct) |
Jeff Thompson | 8238d00 | 2013-07-10 11:56:49 -0700 | [diff] [blame] | 43 | { |
Jeff Thompson | 03616c9 | 2013-09-12 14:30:01 -0700 | [diff] [blame^] | 44 | publisherPublicKeyDigest_ = |
| 45 | Blob(publisherPublicKeyDigestStruct.publisherPublicKeyDigest, publisherPublicKeyDigestStruct.publisherPublicKeyDigestLength); |
Jeff Thompson | 8238d00 | 2013-07-10 11:56:49 -0700 | [diff] [blame] | 46 | } |
| 47 | |
Jeff Thompson | 03616c9 | 2013-09-12 14:30:01 -0700 | [diff] [blame^] | 48 | const Blob& getPublisherPublicKeyDigest() const { return publisherPublicKeyDigest_; } |
Jeff Thompson | 8238d00 | 2013-07-10 11:56:49 -0700 | [diff] [blame] | 49 | |
Jeff Thompson | 1656e6a | 2013-08-29 18:01:48 -0700 | [diff] [blame] | 50 | void setPublisherPublicKeyDigest(const std::vector<unsigned char>& publisherPublicKeyDigest) { publisherPublicKeyDigest_ = publisherPublicKeyDigest; } |
Jeff Thompson | 46bd45f | 2013-08-08 16:46:41 -0700 | [diff] [blame] | 51 | void setPublisherPublicKeyDigest(const unsigned char *publisherPublicKeyDigest, unsigned int publisherPublicKeyDigestLength) |
| 52 | { |
Jeff Thompson | 03616c9 | 2013-09-12 14:30:01 -0700 | [diff] [blame^] | 53 | publisherPublicKeyDigest_ = Blob(publisherPublicKeyDigest, publisherPublicKeyDigestLength); |
Jeff Thompson | 46bd45f | 2013-08-08 16:46:41 -0700 | [diff] [blame] | 54 | } |
Jeff Thompson | f4585af | 2013-09-11 14:56:59 -0700 | [diff] [blame] | 55 | |
| 56 | /** |
| 57 | * Clear the publisherPublicKeyDigest. |
| 58 | */ |
| 59 | void clear() |
| 60 | { |
Jeff Thompson | 03616c9 | 2013-09-12 14:30:01 -0700 | [diff] [blame^] | 61 | publisherPublicKeyDigest_.reset(); |
Jeff Thompson | f4585af | 2013-09-11 14:56:59 -0700 | [diff] [blame] | 62 | } |
Jeff Thompson | 46bd45f | 2013-08-08 16:46:41 -0700 | [diff] [blame] | 63 | |
Jeff Thompson | 8238d00 | 2013-07-10 11:56:49 -0700 | [diff] [blame] | 64 | private: |
Jeff Thompson | 03616c9 | 2013-09-12 14:30:01 -0700 | [diff] [blame^] | 65 | Blob publisherPublicKeyDigest_; |
Jeff Thompson | 8238d00 | 2013-07-10 11:56:49 -0700 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | } |
| 69 | |
| 70 | #endif |