blob: 4d0282185d7fbd8b649c22ea4afa8fddff337e7d [file] [log] [blame]
Jeff Thompson8238d002013-07-10 11:56:49 -07001/**
2 * @author: Jeff Thompson
3 * See COPYING for copyright and distribution information.
4 */
5
6#ifndef NDN_PUBLISHERPUBLICKEYDIGEST_HPP
Jeff Thompson2d27e2f2013-08-09 12:55:00 -07007#define NDN_PUBLISHERPUBLICKEYDIGEST_HPP
Jeff Thompson8238d002013-07-10 11:56:49 -07008
9#include <vector>
Jeff Thompson51dd5fd2013-07-10 19:27:18 -070010#include "common.hpp"
Jeff Thompson53412192013-08-06 13:35:50 -070011#include "c/publisher-public-key-digest.h"
Jeff Thompson8238d002013-07-10 11:56:49 -070012
13namespace 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 */
19class PublisherPublicKeyDigest {
20public:
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 Thompson1656e6a2013-08-29 18:01:48 -070029 void get(struct ndn_PublisherPublicKeyDigest& publisherPublicKeyDigestStruct) const
Jeff Thompson8238d002013-07-10 11:56:49 -070030 {
31 publisherPublicKeyDigestStruct.publisherPublicKeyDigestLength = publisherPublicKeyDigest_.size();
32 if (publisherPublicKeyDigest_.size() > 0)
Jeff Thompson03616c92013-09-12 14:30:01 -070033 publisherPublicKeyDigestStruct.publisherPublicKeyDigest = (unsigned char *)publisherPublicKeyDigest_.buf();
Jeff Thompson8238d002013-07-10 11:56:49 -070034 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 Thompson1656e6a2013-08-29 18:01:48 -070042 void set(const struct ndn_PublisherPublicKeyDigest& publisherPublicKeyDigestStruct)
Jeff Thompson8238d002013-07-10 11:56:49 -070043 {
Jeff Thompson03616c92013-09-12 14:30:01 -070044 publisherPublicKeyDigest_ =
45 Blob(publisherPublicKeyDigestStruct.publisherPublicKeyDigest, publisherPublicKeyDigestStruct.publisherPublicKeyDigestLength);
Jeff Thompson8238d002013-07-10 11:56:49 -070046 }
47
Jeff Thompson03616c92013-09-12 14:30:01 -070048 const Blob& getPublisherPublicKeyDigest() const { return publisherPublicKeyDigest_; }
Jeff Thompson8238d002013-07-10 11:56:49 -070049
Jeff Thompson1656e6a2013-08-29 18:01:48 -070050 void setPublisherPublicKeyDigest(const std::vector<unsigned char>& publisherPublicKeyDigest) { publisherPublicKeyDigest_ = publisherPublicKeyDigest; }
Jeff Thompson46bd45f2013-08-08 16:46:41 -070051 void setPublisherPublicKeyDigest(const unsigned char *publisherPublicKeyDigest, unsigned int publisherPublicKeyDigestLength)
52 {
Jeff Thompson03616c92013-09-12 14:30:01 -070053 publisherPublicKeyDigest_ = Blob(publisherPublicKeyDigest, publisherPublicKeyDigestLength);
Jeff Thompson46bd45f2013-08-08 16:46:41 -070054 }
Jeff Thompsonf4585af2013-09-11 14:56:59 -070055
56 /**
57 * Clear the publisherPublicKeyDigest.
58 */
59 void clear()
60 {
Jeff Thompson03616c92013-09-12 14:30:01 -070061 publisherPublicKeyDigest_.reset();
Jeff Thompsonf4585af2013-09-11 14:56:59 -070062 }
Jeff Thompson46bd45f2013-08-08 16:46:41 -070063
Jeff Thompson8238d002013-07-10 11:56:49 -070064private:
Jeff Thompson03616c92013-09-12 14:30:01 -070065 Blob publisherPublicKeyDigest_;
Jeff Thompson8238d002013-07-10 11:56:49 -070066};
67
68}
69
70#endif