summaryrefslogtreecommitdiffstats
path: root/src/protocols/ec25519_fhmqvc/handshake.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-10-30 22:41:20 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-10-30 22:41:20 +0100
commit601efec8e944bfc6ecb8afbfdfa1393030f36b06 (patch)
tree0826e35d9f69c2c36c89946e8955d097add7b0e3 /src/protocols/ec25519_fhmqvc/handshake.c
parent658c83870a254340a777f8ebca48c87dd98c73d6 (diff)
downloadfastd-601efec8e944bfc6ecb8afbfdfa1393030f36b06.tar
fastd-601efec8e944bfc6ecb8afbfdfa1393030f36b06.zip
Add fastd_handshake_add_zero function
Diffstat (limited to 'src/protocols/ec25519_fhmqvc/handshake.c')
-rw-r--r--src/protocols/ec25519_fhmqvc/handshake.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/protocols/ec25519_fhmqvc/handshake.c b/src/protocols/ec25519_fhmqvc/handshake.c
index d1592d6..742e310 100644
--- a/src/protocols/ec25519_fhmqvc/handshake.c
+++ b/src/protocols/ec25519_fhmqvc/handshake.c
@@ -160,10 +160,9 @@ static void respond_handshake(fastd_context_t *ctx, const fastd_socket_t *sock,
fastd_handshake_add(ctx, &buffer, RECORD_T, HASHBYTES, hmacbuf.b);
}
- memset(&hmacbuf, 0, sizeof(hmacbuf));
- fastd_handshake_add(ctx, &buffer, RECORD_TLV_MAC, HASHBYTES, hmacbuf.b);
+ uint8_t *hmac = fastd_handshake_add_zero(ctx, &buffer, RECORD_TLV_MAC, HASHBYTES);
fastd_hmacsha256(&hmacbuf, peer->protocol_state->shared_handshake_key.w, fastd_handshake_tlv_data(&buffer), fastd_handshake_tlv_len(&buffer));
- memcpy(buffer.data+buffer.len-HASHBYTES, hmacbuf.b, HASHBYTES);
+ memcpy(hmac, hmacbuf.b, HASHBYTES);
fastd_send_handshake(ctx, sock, local_addr, remote_addr, peer, buffer);
}
@@ -328,10 +327,9 @@ static void finish_handshake(fastd_context_t *ctx, fastd_socket_t *sock, const f
fastd_handshake_add(ctx, &buffer, RECORD_T, HASHBYTES, hmacbuf.b);
}
- memset(&hmacbuf, 0, sizeof(hmacbuf));
- fastd_handshake_add(ctx, &buffer, RECORD_TLV_MAC, HASHBYTES, hmacbuf.b);
+ uint8_t *hmac = fastd_handshake_add_zero(ctx, &buffer, RECORD_TLV_MAC, HASHBYTES);
fastd_hmacsha256(&hmacbuf, shared_handshake_key.w, fastd_handshake_tlv_data(&buffer), fastd_handshake_tlv_len(&buffer));
- memcpy(buffer.data+buffer.len-HASHBYTES, hmacbuf.b, HASHBYTES);
+ memcpy(hmac, hmacbuf.b, HASHBYTES);
fastd_send_handshake(ctx, sock, local_addr, remote_addr, peer, buffer);
}