blob: b609d97701b01a41f8f3e31b5db656c1212eb817 [file] [log] [blame]
Jeff Thompson5cae5e52013-07-10 19:41:20 -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 Thompson5cae5e52013-07-10 19:41:20 -07004 * See COPYING for copyright and distribution information.
5 */
6
Jeff Thompson98ec85a2013-12-17 11:57:56 -08007#ifndef NDN_KEY_LOCATOR_H
8#define NDN_KEY_LOCATOR_H
Jeff Thompson5cae5e52013-07-10 19:41:20 -07009
Jeff Thompson25b4e612013-10-10 16:03:24 -070010#include <ndn-cpp/c/key-types.h>
Jeff Thompson7329a132013-08-16 15:57:37 -070011#include "name.h"
12
Jeff Thompson2d27e2f2013-08-09 12:55:00 -070013#ifdef __cplusplus
Jeff Thompson5cae5e52013-07-10 19:41:20 -070014extern "C" {
15#endif
16
Jeff Thompson7329a132013-08-16 15:57:37 -070017/**
18 * An ndn_KeyLocator holds the type of key locator and related data.
19 */
Jeff Thompson5cae5e52013-07-10 19:41:20 -070020struct ndn_KeyLocator {
Jeff Thompson7329a132013-08-16 15:57:37 -070021 ndn_KeyLocatorType type; /**< -1 for none */
Jeff Thompson93034532013-10-08 11:52:43 -070022 struct ndn_Blob keyData; /**< A Blob whose value is a pointer to a pre-allocated buffer for the key data as follows:
Jeff Thompson7329a132013-08-16 15:57:37 -070023 * If type is ndn_KeyLocatorType_KEY, the key data.
24 * If type is ndn_KeyLocatorType_CERTIFICATE, the certificate data.
25 * If type is ndn_KeyLocatorType_KEYNAME and keyNameType is ndn_KeyNameType_PUBLISHER_PUBLIC_KEY_DIGEST, the publisher public key digest.
26 * If type is ndn_KeyLocatorType_KEYNAME and keyNameType is ndn_KeyNameType_PUBLISHER_CERTIFICATE_DIGEST, the publisher certificate digest.
27 * If type is ndn_KeyLocatorType_KEYNAME and keyNameType is ndn_KeyNameType_PUBLISHER_ISSUER_KEY_DIGEST, the publisher issuer key digest.
28 * If type is ndn_KeyLocatorType_KEYNAME and keyNameType is ndn_KeyNameType_PUBLISHER_ISSUER_CERTIFICATE_DIGEST, the publisher issuer certificate digest.
29 */
Jeff Thompson7329a132013-08-16 15:57:37 -070030 struct ndn_Name keyName; /**< The key name (only used if type is ndn_KeyLocatorType_KEYNAME.) */
Jeff Thompson1cf72e92013-08-23 20:38:39 -070031 ndn_KeyNameType keyNameType; /**< The type of data for keyName, -1 for none. (only used if type is ndn_KeyLocatorType_KEYNAME.) */
Jeff Thompson5cae5e52013-07-10 19:41:20 -070032};
33
Jeff Thompson7329a132013-08-16 15:57:37 -070034/**
35 * Initialize an ndn_KeyLocator struct with the pre-allocated nameComponents, and defaults for all the values.
36 * @param self A pointer to the ndn_KeyLocator struct.
37 * @param keyNameComponents The pre-allocated array of ndn_NameComponent.
38 * @param maxKeyNameComponents The number of elements in the allocated keyNameComponents array.
39 */
Jeff Thompsond1427fb2013-08-29 17:20:32 -070040static inline void ndn_KeyLocator_initialize
Jeff Thompson97223af2013-09-24 17:01:27 -070041 (struct ndn_KeyLocator *self, struct ndn_NameComponent *keyNameComponents, size_t maxKeyNameComponents) {
Jeff Thompson5cae5e52013-07-10 19:41:20 -070042 self->type = (ndn_KeyLocatorType)-1;
Jeff Thompson93034532013-10-08 11:52:43 -070043 ndn_Blob_initialize(&self->keyData, 0, 0);
Jeff Thompsond1427fb2013-08-29 17:20:32 -070044 ndn_Name_initialize(&self->keyName, keyNameComponents, maxKeyNameComponents);
Jeff Thompson7329a132013-08-16 15:57:37 -070045 self->keyNameType = (ndn_KeyNameType)-1;
Jeff Thompson5cae5e52013-07-10 19:41:20 -070046}
47
Jeff Thompson2d27e2f2013-08-09 12:55:00 -070048#ifdef __cplusplus
Jeff Thompson5cae5e52013-07-10 19:41:20 -070049}
50#endif
51
52#endif