summaryrefslogtreecommitdiff
path: root/node/Identity.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2013-08-03 10:29:56 -0400
committerAdam Ierymenko <adam.ierymenko@gmail.com>2013-08-03 10:29:56 -0400
commit63fa4a684d15409e185422e7641e7c4680d19ec3 (patch)
treef24b0535aed69c5eccd415c344675836d6349772 /node/Identity.cpp
parent3635a940f921a10f229d67a30fde1be650d3a28e (diff)
parent80d8b7d0ae56f1dce8b5b25ab7930df436755daf (diff)
downloadinfinitytier-63fa4a684d15409e185422e7641e7c4680d19ec3.tar.gz
infinitytier-63fa4a684d15409e185422e7641e7c4680d19ec3.zip
Merge my adamierymenko-dev into the new master that incorporates Raspberry Pi build changes in order to keep everything in sync.
Diffstat (limited to 'node/Identity.cpp')
-rw-r--r--node/Identity.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/node/Identity.cpp b/node/Identity.cpp
index f16947a0..e9cbef3d 100644
--- a/node/Identity.cpp
+++ b/node/Identity.cpp
@@ -57,11 +57,13 @@ void Identity::generate()
// the address of an identity will be detected as its signature will be
// invalid. Of course, deep verification of address/key relationship is
// required to cover the more elaborate address claim jump attempt case.
+ unsigned char atmp[ZT_ADDRESS_LENGTH];
+ _address.copyTo(atmp,ZT_ADDRESS_LENGTH);
SHA256_CTX sha;
unsigned char dig[32];
unsigned char idtype = IDENTITY_TYPE_NIST_P_521,zero = 0;
SHA256_Init(&sha);
- SHA256_Update(&sha,_address.data(),ZT_ADDRESS_LENGTH);
+ SHA256_Update(&sha,atmp,ZT_ADDRESS_LENGTH);
SHA256_Update(&sha,&zero,1);
SHA256_Update(&sha,&idtype,1);
SHA256_Update(&sha,&zero,1);
@@ -73,11 +75,13 @@ void Identity::generate()
bool Identity::locallyValidate(bool doAddressDerivationCheck) const
{
+ unsigned char atmp[ZT_ADDRESS_LENGTH];
+ _address.copyTo(atmp,ZT_ADDRESS_LENGTH);
SHA256_CTX sha;
unsigned char dig[32];
unsigned char idtype = IDENTITY_TYPE_NIST_P_521,zero = 0;
SHA256_Init(&sha);
- SHA256_Update(&sha,_address.data(),ZT_ADDRESS_LENGTH);
+ SHA256_Update(&sha,atmp,ZT_ADDRESS_LENGTH);
SHA256_Update(&sha,&zero,1);
SHA256_Update(&sha,&idtype,1);
SHA256_Update(&sha,&zero,1);
@@ -119,7 +123,7 @@ bool Identity::fromString(const char *str)
std::string b(Utils::unhex(fields[0]));
if (b.length() != ZT_ADDRESS_LENGTH)
return false;
- _address = b.data();
+ _address.setTo(b.data(),ZT_ADDRESS_LENGTH);
b = Utils::base64Decode(fields[2]);
if ((!b.length())||(b.length() > ZT_EC_MAX_BYTES))
@@ -218,7 +222,7 @@ Address Identity::deriveAddress(const void *keyBytes,unsigned int keyLen)
delete [] ram;
- return Address(dig); // first 5 bytes of dig[]
+ return Address(dig,ZT_ADDRESS_LENGTH); // first 5 bytes of dig[]
}
std::string Identity::encrypt(const Identity &to,const void *data,unsigned int len) const