/* Puts HMAC-SHA2 digest of packet data (except for the bytes where this digest will be stored) into that packet. */
static int rtmp_handshake_imprint_with_digest(uint8_t *buf)
/* Puts HMAC-SHA2 digest of packet data (except for the bytes where this digest will be stored) into that packet. */
static int rtmp_handshake_imprint_with_digest(uint8_t *buf)
{
    int i, digest_pos = 0;
    for (i = 8; i < 12; i++)
        digest_pos += buf[i];
    digest_pos = (digest_pos % 728) + 12;
    rtmp_calc_digest(buf, RTMP_HANDSHAKE_PACKET_SIZE, digest_pos,
                     rtmp_player_key, PLAYER_KEY_OPEN_PART_LEN,
                     buf + digest_pos);
    return digest_pos;
}