diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-10-14 14:12:12 -0700 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-10-14 14:12:12 -0700 |
| commit | 619e1137480de4682bb46eabaee3ce750c5be3e8 (patch) | |
| tree | fff48f9b16d0410b09e0831088f0386a3c9bb4f3 /node/Identity.hpp | |
| parent | c312ae221f0aa339cce56c411d59d9cc9e34abc5 (diff) | |
| download | infinitytier-619e1137480de4682bb46eabaee3ce750c5be3e8.tar.gz infinitytier-619e1137480de4682bb46eabaee3ce750c5be3e8.zip | |
Work in progress on Cluster for new root infrastructure, multi-homing.
Diffstat (limited to 'node/Identity.hpp')
| -rw-r--r-- | node/Identity.hpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/node/Identity.hpp b/node/Identity.hpp index 19bb2e1f..6c33e74f 100644 --- a/node/Identity.hpp +++ b/node/Identity.hpp @@ -38,6 +38,7 @@ #include "Address.hpp" #include "C25519.hpp" #include "Buffer.hpp" +#include "SHA512.hpp" namespace ZeroTier { @@ -91,8 +92,7 @@ public: } template<unsigned int C> - Identity(const Buffer<C> &b,unsigned int startAt = 0) - throw(std::out_of_range,std::invalid_argument) : + Identity(const Buffer<C> &b,unsigned int startAt = 0) : _privateKey((C25519::Private *)0) { deserialize(b,startAt); @@ -138,6 +138,21 @@ public: inline bool hasPrivate() const throw() { return (_privateKey != (C25519::Private *)0); } /** + * Compute the SHA512 hash of our private key (if we have one) + * + * @param sha Buffer to receive SHA512 (MUST be ZT_SHA512_DIGEST_LEN (64) bytes in length) + * @return True on success, false if no private key + */ + inline bool sha512PrivateKey(void *sha) const + { + if (_privateKey) { + SHA512::hash(sha,_privateKey->data,ZT_C25519_PRIVATE_KEY_LEN); + return true; + } + return false; + } + + /** * Sign a message with this identity (private key required) * * @param data Data to sign |
