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