blob: df2da0bb255923ae89fd3925fdb06617d6a68775 [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 Thompson1656e6a2013-08-29 18:01:48 -070030 void get(struct ndn_PublisherPublicKeyDigest& publisherPublicKeyDigestStruct) const
Jeff Thompson8238d002013-07-10 11:56:49 -070031 {
32 publisherPublicKeyDigestStruct.publisherPublicKeyDigestLength = publisherPublicKeyDigest_.size();
33 if (publisherPublicKeyDigest_.size() > 0)
Jeff Thompson03616c92013-09-12 14:30:01 -070034 publisherPublicKeyDigestStruct.publisherPublicKeyDigest = (unsigned char *)publisherPublicKeyDigest_.buf();
Jeff Thompson8238d002013-07-10 11:56:49 -070035 else
36 publisherPublicKeyDigestStruct.publisherPublicKeyDigest = 0;
37 }
38
39 /**
40 * Clear this PublisherPublicKeyDigest, and copy from the ndn_PublisherPublicKeyDigest struct.
41 * @param excludeStruct a C ndn_Exclude struct
42 */
Jeff Thompson1656e6a2013-08-29 18:01:48 -070043 void set(const struct ndn_PublisherPublicKeyDigest& publisherPublicKeyDigestStruct)
Jeff Thompson8238d002013-07-10 11:56:49 -070044 {
Jeff Thompson03616c92013-09-12 14:30:01 -070045 publisherPublicKeyDigest_ =
46 Blob(publisherPublicKeyDigestStruct.publisherPublicKeyDigest, publisherPublicKeyDigestStruct.publisherPublicKeyDigestLength);
Jeff Thompson8238d002013-07-10 11:56:49 -070047 }
48
Jeff Thompson03616c92013-09-12 14:30:01 -070049 const Blob& getPublisherPublicKeyDigest() const { return publisherPublicKeyDigest_; }
Jeff Thompson8238d002013-07-10 11:56:49 -070050
Jeff Thompson1656e6a2013-08-29 18:01:48 -070051 void setPublisherPublicKeyDigest(const std::vector<unsigned char>& publisherPublicKeyDigest) { publisherPublicKeyDigest_ = publisherPublicKeyDigest; }
Jeff Thompson46bd45f2013-08-08 16:46:41 -070052 void setPublisherPublicKeyDigest(const unsigned char *publisherPublicKeyDigest, unsigned int publisherPublicKeyDigestLength)
53 {
Jeff Thompson03616c92013-09-12 14:30:01 -070054 publisherPublicKeyDigest_ = Blob(publisherPublicKeyDigest, publisherPublicKeyDigestLength);
Jeff Thompson46bd45f2013-08-08 16:46:41 -070055 }
Jeff Thompsonf4585af2013-09-11 14:56:59 -070056
57 /**
58 * Clear the publisherPublicKeyDigest.
59 */
60 void clear()
61 {
Jeff Thompson03616c92013-09-12 14:30:01 -070062 publisherPublicKeyDigest_.reset();
Jeff Thompsonf4585af2013-09-11 14:56:59 -070063 }
Jeff Thompson46bd45f2013-08-08 16:46:41 -070064
Jeff Thompson8238d002013-07-10 11:56:49 -070065private:
Jeff Thompson03616c92013-09-12 14:30:01 -070066 Blob publisherPublicKeyDigest_;
Jeff Thompson8238d002013-07-10 11:56:49 -070067};
68
69}
70
71#endif