Jeff Thompson | 25b4e61 | 2013-10-10 16:03:24 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
Jeff Thompson | 8238d00 | 2013-07-10 11:56:49 -0700 | [diff] [blame] | 2 | /** |
Jeff Thompson | 7687dc0 | 2013-09-13 11:54:07 -0700 | [diff] [blame] | 3 | * Copyright (C) 2013 Regents of the University of California. |
| 4 | * @author: Jeff Thompson <jefft0@remap.ucla.edu> |
Jeff Thompson | 8238d00 | 2013-07-10 11:56:49 -0700 | [diff] [blame] | 5 | * See COPYING for copyright and distribution information. |
| 6 | */ |
| 7 | |
| 8 | #ifndef NDN_PUBLISHERPUBLICKEYDIGEST_HPP |
Jeff Thompson | 2d27e2f | 2013-08-09 12:55:00 -0700 | [diff] [blame] | 9 | #define NDN_PUBLISHERPUBLICKEYDIGEST_HPP |
Jeff Thompson | 8238d00 | 2013-07-10 11:56:49 -0700 | [diff] [blame] | 10 | |
| 11 | #include <vector> |
Jeff Thompson | 51dd5fd | 2013-07-10 19:27:18 -0700 | [diff] [blame] | 12 | #include "common.hpp" |
Jeff Thompson | 25b4e61 | 2013-10-10 16:03:24 -0700 | [diff] [blame] | 13 | #include "util/blob.hpp" |
| 14 | |
| 15 | struct ndn_PublisherPublicKeyDigest; |
Jeff Thompson | 8238d00 | 2013-07-10 11:56:49 -0700 | [diff] [blame] | 16 | |
| 17 | namespace ndn { |
| 18 | |
| 19 | /** |
| 20 | * A PublisherPublicKeyDigest holds the publisher public key digest value, if any. |
| 21 | * We make a separate class since this is used by multiple other classes. |
| 22 | */ |
| 23 | class PublisherPublicKeyDigest { |
| 24 | public: |
| 25 | PublisherPublicKeyDigest() { |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * Set the publisherPublicKeyDigestStruct to point to the entries in this PublisherPublicKeyDigest, without copying any memory. |
| 30 | * WARNING: The resulting pointers in publisherPublicKeyDigestStruct are invalid after a further use of this object which could reallocate memory. |
| 31 | * @param publisherPublicKeyDigestStruct a C ndn_PublisherPublicKeyDigest struct to receive the pointer |
| 32 | */ |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 33 | void |
Jeff Thompson | 25b4e61 | 2013-10-10 16:03:24 -0700 | [diff] [blame] | 34 | get(struct ndn_PublisherPublicKeyDigest& publisherPublicKeyDigestStruct) const; |
Jeff Thompson | 8238d00 | 2013-07-10 11:56:49 -0700 | [diff] [blame] | 35 | |
| 36 | /** |
| 37 | * Clear this PublisherPublicKeyDigest, and copy from the ndn_PublisherPublicKeyDigest struct. |
| 38 | * @param excludeStruct a C ndn_Exclude struct |
| 39 | */ |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 40 | void |
Jeff Thompson | 25b4e61 | 2013-10-10 16:03:24 -0700 | [diff] [blame] | 41 | set(const struct ndn_PublisherPublicKeyDigest& publisherPublicKeyDigestStruct); |
Jeff Thompson | 8238d00 | 2013-07-10 11:56:49 -0700 | [diff] [blame] | 42 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 43 | const Blob& |
| 44 | getPublisherPublicKeyDigest() const { return publisherPublicKeyDigest_; } |
Jeff Thompson | 8238d00 | 2013-07-10 11:56:49 -0700 | [diff] [blame] | 45 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 46 | void |
Jeff Thompson | 10ad12a | 2013-09-24 16:19:11 -0700 | [diff] [blame] | 47 | setPublisherPublicKeyDigest(const std::vector<uint8_t>& publisherPublicKeyDigest) |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 48 | { |
| 49 | publisherPublicKeyDigest_ = publisherPublicKeyDigest; |
| 50 | } |
| 51 | |
| 52 | void |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 53 | setPublisherPublicKeyDigest(const uint8_t *publisherPublicKeyDigest, size_t publisherPublicKeyDigestLength) |
Jeff Thompson | 46bd45f | 2013-08-08 16:46:41 -0700 | [diff] [blame] | 54 | { |
Jeff Thompson | 03616c9 | 2013-09-12 14:30:01 -0700 | [diff] [blame] | 55 | publisherPublicKeyDigest_ = Blob(publisherPublicKeyDigest, publisherPublicKeyDigestLength); |
Jeff Thompson | 46bd45f | 2013-08-08 16:46:41 -0700 | [diff] [blame] | 56 | } |
Jeff Thompson | 8659fa1 | 2013-09-23 11:57:41 -0700 | [diff] [blame] | 57 | |
| 58 | /** |
| 59 | * Set the publisher public key digest to point to an existing byte array. IMPORTANT: After calling this, |
| 60 | * if you keep a pointer to the array then you must treat the array as immutable and promise not to change it. |
| 61 | * @param signature A pointer to a vector with the byte array. This takes another reference and does not copy the bytes. |
| 62 | */ |
| 63 | void |
Jeff Thompson | 10ad12a | 2013-09-24 16:19:11 -0700 | [diff] [blame] | 64 | setPublisherPublicKeyDigest(const ptr_lib::shared_ptr<std::vector<uint8_t> > &publisherPublicKeyDigest) |
Jeff Thompson | 8659fa1 | 2013-09-23 11:57:41 -0700 | [diff] [blame] | 65 | { |
| 66 | publisherPublicKeyDigest_ = publisherPublicKeyDigest; |
| 67 | } |
| 68 | |
| 69 | void |
Jeff Thompson | 10ad12a | 2013-09-24 16:19:11 -0700 | [diff] [blame] | 70 | setPublisherPublicKeyDigest(const ptr_lib::shared_ptr<const std::vector<uint8_t> > &publisherPublicKeyDigest) |
Jeff Thompson | 8659fa1 | 2013-09-23 11:57:41 -0700 | [diff] [blame] | 71 | { |
| 72 | publisherPublicKeyDigest_ = publisherPublicKeyDigest; |
| 73 | } |
Jeff Thompson | f4585af | 2013-09-11 14:56:59 -0700 | [diff] [blame] | 74 | |
| 75 | /** |
| 76 | * Clear the publisherPublicKeyDigest. |
| 77 | */ |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 78 | void |
| 79 | clear() |
Jeff Thompson | f4585af | 2013-09-11 14:56:59 -0700 | [diff] [blame] | 80 | { |
Jeff Thompson | 03616c9 | 2013-09-12 14:30:01 -0700 | [diff] [blame] | 81 | publisherPublicKeyDigest_.reset(); |
Jeff Thompson | f4585af | 2013-09-11 14:56:59 -0700 | [diff] [blame] | 82 | } |
Jeff Thompson | 46bd45f | 2013-08-08 16:46:41 -0700 | [diff] [blame] | 83 | |
Jeff Thompson | 8238d00 | 2013-07-10 11:56:49 -0700 | [diff] [blame] | 84 | private: |
Jeff Thompson | 03616c9 | 2013-09-12 14:30:01 -0700 | [diff] [blame] | 85 | Blob publisherPublicKeyDigest_; |
Jeff Thompson | 8238d00 | 2013-07-10 11:56:49 -0700 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | } |
| 89 | |
| 90 | #endif |