blob: 8069fa020fa8f462de3db1dc2dad555b935a7e94 [file] [log] [blame]
Jeff Thompson8238d002013-07-10 11:56:49 -07001/**
Jeff Thompson7687dc02013-09-13 11:54:07 -07002 * Copyright (C) 2013 Regents of the University of California.
3 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
Jeff Thompson8238d002013-07-10 11:56:49 -07004 * See COPYING for copyright and distribution information.
5 */
6
7#ifndef NDN_PUBLISHERPUBLICKEYDIGEST_HPP
Jeff Thompson2d27e2f2013-08-09 12:55:00 -07008#define NDN_PUBLISHERPUBLICKEYDIGEST_HPP
Jeff Thompson8238d002013-07-10 11:56:49 -07009
10#include <vector>
Jeff Thompson51dd5fd2013-07-10 19:27:18 -070011#include "common.hpp"
Jeff Thompson53412192013-08-06 13:35:50 -070012#include "c/publisher-public-key-digest.h"
Jeff Thompson8238d002013-07-10 11:56:49 -070013
14namespace 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 */
20class PublisherPublicKeyDigest {
21public:
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 Thompson0050abe2013-09-17 12:50:25 -070030 void
31 get(struct ndn_PublisherPublicKeyDigest& publisherPublicKeyDigestStruct) const
Jeff Thompson8238d002013-07-10 11:56:49 -070032 {
Jeff Thompson93034532013-10-08 11:52:43 -070033 publisherPublicKeyDigest_.get(publisherPublicKeyDigestStruct.publisherPublicKeyDigest);
Jeff Thompson8238d002013-07-10 11:56:49 -070034 }
35
36 /**
37 * Clear this PublisherPublicKeyDigest, and copy from the ndn_PublisherPublicKeyDigest struct.
38 * @param excludeStruct a C ndn_Exclude struct
39 */
Jeff Thompson0050abe2013-09-17 12:50:25 -070040 void
41 set(const struct ndn_PublisherPublicKeyDigest& publisherPublicKeyDigestStruct)
Jeff Thompson8238d002013-07-10 11:56:49 -070042 {
Jeff Thompson93034532013-10-08 11:52:43 -070043 publisherPublicKeyDigest_ = Blob(publisherPublicKeyDigestStruct.publisherPublicKeyDigest);
Jeff Thompson8238d002013-07-10 11:56:49 -070044 }
45
Jeff Thompson0050abe2013-09-17 12:50:25 -070046 const Blob&
47 getPublisherPublicKeyDigest() const { return publisherPublicKeyDigest_; }
Jeff Thompson8238d002013-07-10 11:56:49 -070048
Jeff Thompson0050abe2013-09-17 12:50:25 -070049 void
Jeff Thompson10ad12a2013-09-24 16:19:11 -070050 setPublisherPublicKeyDigest(const std::vector<uint8_t>& publisherPublicKeyDigest)
Jeff Thompson0050abe2013-09-17 12:50:25 -070051 {
52 publisherPublicKeyDigest_ = publisherPublicKeyDigest;
53 }
54
55 void
Jeff Thompson97223af2013-09-24 17:01:27 -070056 setPublisherPublicKeyDigest(const uint8_t *publisherPublicKeyDigest, size_t publisherPublicKeyDigestLength)
Jeff Thompson46bd45f2013-08-08 16:46:41 -070057 {
Jeff Thompson03616c92013-09-12 14:30:01 -070058 publisherPublicKeyDigest_ = Blob(publisherPublicKeyDigest, publisherPublicKeyDigestLength);
Jeff Thompson46bd45f2013-08-08 16:46:41 -070059 }
Jeff Thompson8659fa12013-09-23 11:57:41 -070060
61 /**
62 * Set the publisher public key digest to point to an existing byte array. IMPORTANT: After calling this,
63 * if you keep a pointer to the array then you must treat the array as immutable and promise not to change it.
64 * @param signature A pointer to a vector with the byte array. This takes another reference and does not copy the bytes.
65 */
66 void
Jeff Thompson10ad12a2013-09-24 16:19:11 -070067 setPublisherPublicKeyDigest(const ptr_lib::shared_ptr<std::vector<uint8_t> > &publisherPublicKeyDigest)
Jeff Thompson8659fa12013-09-23 11:57:41 -070068 {
69 publisherPublicKeyDigest_ = publisherPublicKeyDigest;
70 }
71
72 void
Jeff Thompson10ad12a2013-09-24 16:19:11 -070073 setPublisherPublicKeyDigest(const ptr_lib::shared_ptr<const std::vector<uint8_t> > &publisherPublicKeyDigest)
Jeff Thompson8659fa12013-09-23 11:57:41 -070074 {
75 publisherPublicKeyDigest_ = publisherPublicKeyDigest;
76 }
Jeff Thompsonf4585af2013-09-11 14:56:59 -070077
78 /**
79 * Clear the publisherPublicKeyDigest.
80 */
Jeff Thompson0050abe2013-09-17 12:50:25 -070081 void
82 clear()
Jeff Thompsonf4585af2013-09-11 14:56:59 -070083 {
Jeff Thompson03616c92013-09-12 14:30:01 -070084 publisherPublicKeyDigest_.reset();
Jeff Thompsonf4585af2013-09-11 14:56:59 -070085 }
Jeff Thompson46bd45f2013-08-08 16:46:41 -070086
Jeff Thompson8238d002013-07-10 11:56:49 -070087private:
Jeff Thompson03616c92013-09-12 14:30:01 -070088 Blob publisherPublicKeyDigest_;
Jeff Thompson8238d002013-07-10 11:56:49 -070089};
90
91}
92
93#endif