Jeff Thompson | 5cae5e5 | 2013-07-10 19:41:20 -0700 | [diff] [blame] | 1 | /** |
| 2 | * @author: Jeff Thompson |
| 3 | * See COPYING for copyright and distribution information. |
| 4 | */ |
| 5 | |
| 6 | #ifndef NDN_KEY_HPP |
Jeff Thompson | 2d27e2f | 2013-08-09 12:55:00 -0700 | [diff] [blame] | 7 | #define NDN_KEY_HPP |
Jeff Thompson | 5cae5e5 | 2013-07-10 19:41:20 -0700 | [diff] [blame] | 8 | |
| 9 | #include <vector> |
Jeff Thompson | 5341219 | 2013-08-06 13:35:50 -0700 | [diff] [blame] | 10 | #include "c/key.h" |
Jeff Thompson | 5cae5e5 | 2013-07-10 19:41:20 -0700 | [diff] [blame] | 11 | |
| 12 | namespace ndn { |
| 13 | |
| 14 | class KeyLocator { |
| 15 | public: |
| 16 | KeyLocator() |
| 17 | { |
| 18 | type_ = (ndn_KeyLocatorType)-1; |
| 19 | } |
| 20 | |
| 21 | /** |
| 22 | * Set the keyLocatorStruct to point to the values in this key locator, without copying any memory. |
| 23 | * WARNING: The resulting pointers in keyLocatorStruct are invalid after a further use of this object which could reallocate memory. |
| 24 | * @param keyLocatorStruct a C ndn_KeyLocator struct where the name components array is already allocated. |
| 25 | */ |
| 26 | void get(struct ndn_KeyLocator &keyLocatorStruct) const; |
| 27 | |
| 28 | /** |
| 29 | * Clear this key locator, and set the values by copying from the ndn_KeyLocator struct. |
| 30 | * @param keyLocatorStruct a C ndn_KeyLocator struct |
| 31 | */ |
| 32 | void set(const struct ndn_KeyLocator &keyLocatorStruct); |
| 33 | |
| 34 | ndn_KeyLocatorType getType() const { return type_; } |
| 35 | |
| 36 | const std::vector<unsigned char> getKeyOrCertificate() const { return keyOrCertificate_; } |
| 37 | |
Jeff Thompson | 46bd45f | 2013-08-08 16:46:41 -0700 | [diff] [blame] | 38 | // TODO: Implement getKeyName. |
| 39 | |
| 40 | void setType(ndn_KeyLocatorType type) { type_ = type; } |
| 41 | |
| 42 | void setKeyOrCertificate(const std::vector<unsigned char> &keyOrCertificate) { keyOrCertificate_ = keyOrCertificate; } |
| 43 | void setKeyOrCertificate(const unsigned char *keyOrCertificate, unsigned int keyOrCertificateLength) |
| 44 | { |
| 45 | setVector(keyOrCertificate_, keyOrCertificate, keyOrCertificateLength); |
| 46 | } |
| 47 | |
| 48 | // TODO: Implement setKeyName. |
Jeff Thompson | 5cae5e5 | 2013-07-10 19:41:20 -0700 | [diff] [blame] | 49 | |
| 50 | private: |
| 51 | ndn_KeyLocatorType type_; |
| 52 | std::vector<unsigned char> keyOrCertificate_; /**< used if type_ is ndn_KeyLocatorType_KEY or ndn_KeyLocatorType_CERTIFICATE */ |
| 53 | // TODO: Implement keyName. |
| 54 | }; |
| 55 | |
| 56 | } |
| 57 | |
| 58 | #endif |