mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-14 10:46:51 -07:00
Fix MAC for Messages
This commit is contained in:
parent
8c158815e7
commit
77c11cadbc
3 changed files with 5 additions and 1 deletions
|
@ -189,6 +189,7 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_gkcrypt_gmac(ChiakiGKCrypt *gkcrypt, size_t
|
|||
uint8_t *gmac_key = gkcrypt->key_gmac_current;
|
||||
uint8_t gmac_key_tmp[CHIAKI_GKCRYPT_BLOCK_SIZE];
|
||||
uint64_t key_index = key_pos / CHIAKI_GKCRYPT_GMAC_KEY_REFRESH_KEY_POS;
|
||||
// TODO: what to do if (key_pos / CHIAKI_GKCRYPT_GMAC_KEY_REFRESH_KEY_POS) != ((key_pos + buf_size) / CHIAKI_GKCRYPT_GMAC_KEY_REFRESH_KEY_POS)?
|
||||
if(key_index > gkcrypt->key_gmac_index_current)
|
||||
{
|
||||
chiaki_gkcrypt_gen_new_gmac_key(gkcrypt, key_index);
|
||||
|
|
|
@ -401,6 +401,9 @@ static ChiakiErrorCode takion_handle_packet_mac(ChiakiTakion *takion, uint8_t ba
|
|||
}
|
||||
|
||||
uint32_t key_pos = ntohl(*((uint32_t *)(buf + key_pos_offset)));
|
||||
if(base_type == TAKION_PACKET_TYPE_MESSAGE)
|
||||
memset(buf + key_pos_offset, 0, sizeof(uint32_t));
|
||||
|
||||
uint8_t mac[CHIAKI_GKCRYPT_GMAC_SIZE];
|
||||
memcpy(mac, buf + mac_offset, sizeof(mac));
|
||||
memset(buf + mac_offset, 0, sizeof(mac));
|
||||
|
|
|
@ -184,7 +184,7 @@ static MunitResult test_gmac(const MunitParameter params[], void *user)
|
|||
memcpy(gkcrypt.iv, gkcrypt_iv, sizeof(gkcrypt.iv));
|
||||
gkcrypt.key_buf = NULL;
|
||||
gkcrypt.key_buf_size = 0;
|
||||
gkcrypt.key_gmac_index_next = 1;
|
||||
gkcrypt.key_gmac_index_current = 0;
|
||||
|
||||
uint8_t gmac[CHIAKI_GKCRYPT_GMAC_SIZE];
|
||||
ChiakiErrorCode err = chiaki_gkcrypt_gmac(&gkcrypt, key_pos, buf, sizeof(buf), gmac);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue