blob: ad60ef4d022041b17d3990442b7835c49e581296 [file] [log] [blame]
Jeff Thompson25b4e612013-10-10 16:03:24 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
Jeff Thompson8238d002013-07-10 11:56:49 -07002/**
Jeff Thompson7687dc02013-09-13 11:54:07 -07003 * Copyright (C) 2013 Regents of the University of California.
4 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
Jeff Thompson8238d002013-07-10 11:56:49 -07005 * See COPYING for copyright and distribution information.
6 */
7
8#ifndef NDN_PUBLISHERPUBLICKEYDIGEST_HPP
Jeff Thompson2d27e2f2013-08-09 12:55:00 -07009#define NDN_PUBLISHERPUBLICKEYDIGEST_HPP
Jeff Thompson8238d002013-07-10 11:56:49 -070010
11#include <vector>
Jeff Thompson51dd5fd2013-07-10 19:27:18 -070012#include "common.hpp"
Jeff Thompson25b4e612013-10-10 16:03:24 -070013#include "util/blob.hpp"
14
15struct ndn_PublisherPublicKeyDigest;
Jeff Thompson8238d002013-07-10 11:56:49 -070016
17namespace 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 */
23class PublisherPublicKeyDigest {
24public:
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 Thompson0050abe2013-09-17 12:50:25 -070033 void
Jeff Thompson25b4e612013-10-10 16:03:24 -070034 get(struct ndn_PublisherPublicKeyDigest& publisherPublicKeyDigestStruct) const;
Jeff Thompson8238d002013-07-10 11:56:49 -070035
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
Jeff Thompson25b4e612013-10-10 16:03:24 -070041 set(const struct ndn_PublisherPublicKeyDigest& publisherPublicKeyDigestStruct);
Jeff Thompson8238d002013-07-10 11:56:49 -070042
Jeff Thompson0050abe2013-09-17 12:50:25 -070043 const Blob&
44 getPublisherPublicKeyDigest() const { return publisherPublicKeyDigest_; }
Jeff Thompson8238d002013-07-10 11:56:49 -070045
Jeff Thompson0050abe2013-09-17 12:50:25 -070046 void
Jeff Thompson10ad12a2013-09-24 16:19:11 -070047 setPublisherPublicKeyDigest(const std::vector<uint8_t>& publisherPublicKeyDigest)
Jeff Thompson0050abe2013-09-17 12:50:25 -070048 {
49 publisherPublicKeyDigest_ = publisherPublicKeyDigest;
50 }
51
52 void
Jeff Thompson97223af2013-09-24 17:01:27 -070053 setPublisherPublicKeyDigest(const uint8_t *publisherPublicKeyDigest, size_t publisherPublicKeyDigestLength)
Jeff Thompson46bd45f2013-08-08 16:46:41 -070054 {
Jeff Thompson03616c92013-09-12 14:30:01 -070055 publisherPublicKeyDigest_ = Blob(publisherPublicKeyDigest, publisherPublicKeyDigestLength);
Jeff Thompson46bd45f2013-08-08 16:46:41 -070056 }
Jeff Thompson8659fa12013-09-23 11:57:41 -070057
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 Thompson10ad12a2013-09-24 16:19:11 -070064 setPublisherPublicKeyDigest(const ptr_lib::shared_ptr<std::vector<uint8_t> > &publisherPublicKeyDigest)
Jeff Thompson8659fa12013-09-23 11:57:41 -070065 {
66 publisherPublicKeyDigest_ = publisherPublicKeyDigest;
67 }
68
69 void
Jeff Thompson10ad12a2013-09-24 16:19:11 -070070 setPublisherPublicKeyDigest(const ptr_lib::shared_ptr<const std::vector<uint8_t> > &publisherPublicKeyDigest)
Jeff Thompson8659fa12013-09-23 11:57:41 -070071 {
72 publisherPublicKeyDigest_ = publisherPublicKeyDigest;
73 }
Jeff Thompsonf4585af2013-09-11 14:56:59 -070074
75 /**
76 * Clear the publisherPublicKeyDigest.
77 */
Jeff Thompson0050abe2013-09-17 12:50:25 -070078 void
79 clear()
Jeff Thompsonf4585af2013-09-11 14:56:59 -070080 {
Jeff Thompson03616c92013-09-12 14:30:01 -070081 publisherPublicKeyDigest_.reset();
Jeff Thompsonf4585af2013-09-11 14:56:59 -070082 }
Jeff Thompson46bd45f2013-08-08 16:46:41 -070083
Jeff Thompson8238d002013-07-10 11:56:49 -070084private:
Jeff Thompson03616c92013-09-12 14:30:01 -070085 Blob publisherPublicKeyDigest_;
Jeff Thompson8238d002013-07-10 11:56:49 -070086};
87
88}
89
90#endif