You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

29 lines
779 B

#include "Destination.h"
#include "Utils.h"
#include <string.h>
namespace mesh {
Destination::Destination(const Identity& identity, const char* name) {
uint8_t name_hash[MAX_HASH_SIZE];
Utils::sha256(name_hash, MAX_HASH_SIZE, (const uint8_t *)name, strlen(name));
Utils::sha256(hash, MAX_HASH_SIZE, name_hash, MAX_HASH_SIZE, identity.pub_key, PUB_KEY_SIZE);
}
Destination::Destination(const char* name) {
uint8_t name_hash[MAX_HASH_SIZE];
Utils::sha256(name_hash, MAX_HASH_SIZE, (const uint8_t *)name, strlen(name));
Utils::sha256(hash, MAX_HASH_SIZE, name_hash, MAX_HASH_SIZE);
}
Destination::Destination() {
memset(hash, 0, MAX_HASH_SIZE);
}
bool Destination::matches(const uint8_t* other_hash) {
return memcmp(hash, other_hash, MAX_HASH_SIZE) == 0;
}
}