mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
fix: update ChanNameFilter secret size to match PUB_KEY_SIZE
This commit is contained in:
parent
4a214ae3ab
commit
5266ffcaf3
2 changed files with 5 additions and 3 deletions
|
|
@ -709,11 +709,13 @@ void MyMesh::saveBlacklist(const char* fname, const BlacklistEntry* list) {
|
|||
/* ------------------- Channel name filter helpers -------------------------- */
|
||||
|
||||
void MyMesh::deriveChanNameFilter(ChanNameFilter& entry, const char* name) {
|
||||
// Derive channel secret: first 16 bytes of sha256(name)
|
||||
// Derive channel secret: first 16 bytes of sha256(name), zero-padded to PUB_KEY_SIZE
|
||||
// to match GroupChannel.secret layout (MACThenDecrypt reads PUB_KEY_SIZE bytes)
|
||||
uint8_t full_hash[32];
|
||||
mesh::Utils::sha256(full_hash, 32, (const uint8_t*)name, strlen(name));
|
||||
memset(entry.secret, 0, sizeof(entry.secret));
|
||||
memcpy(entry.secret, full_hash, CIPHER_KEY_SIZE);
|
||||
// Derive channel hash from the secret
|
||||
// Derive channel hash from the secret (using 16-byte key length, matching addChannel)
|
||||
mesh::Utils::sha256(entry.hash, sizeof(entry.hash), entry.secret, CIPHER_KEY_SIZE);
|
||||
StrHelper::strncpy(entry.name, name, sizeof(entry.name));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ struct BlacklistEntry {
|
|||
|
||||
struct ChanNameFilter {
|
||||
uint8_t hash[PATH_HASH_SIZE];
|
||||
uint8_t secret[CIPHER_KEY_SIZE];
|
||||
uint8_t secret[PUB_KEY_SIZE];
|
||||
char name[32];
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue