mirror of https://github.com/meshcore-dev/MeshCore
4 changed files with 4 additions and 58 deletions
@ -1,29 +0,0 @@ |
|||||
#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; |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
@ -1,25 +0,0 @@ |
|||||
#pragma once |
|
||||
|
|
||||
#include <MeshCore.h> |
|
||||
#include <Identity.h> |
|
||||
|
|
||||
namespace mesh { |
|
||||
|
|
||||
/**
|
|
||||
* \brief Represents an end-point in the mesh, identified by a truncated SHA256 hash. (of DEST_HASH_SIZE) |
|
||||
* The hash is either from just a 'name' (C-string), and these can be thought of as 'broadcast' addresses, |
|
||||
* or can be the hash of name + Identity.public_key |
|
||||
*/ |
|
||||
class Destination { |
|
||||
public: |
|
||||
uint8_t hash[MAX_HASH_SIZE]; |
|
||||
|
|
||||
Destination(const Identity& identity, const char* name); |
|
||||
Destination(const char* name); |
|
||||
Destination(const uint8_t desthash[]) { memcpy(hash, desthash, MAX_HASH_SIZE); } |
|
||||
Destination(); |
|
||||
|
|
||||
bool matches(const uint8_t* other_hash); |
|
||||
}; |
|
||||
|
|
||||
} |
|
||||
Loading…
Reference in new issue