Fix warnings

This commit is contained in:
Aaro Altonen 2020-08-13 06:47:26 +03:00
parent e1a28d095a
commit b6595822cb
14 changed files with 30 additions and 12 deletions

View File

@ -139,6 +139,7 @@ namespace uvg_rtp {
namespace crc32 {
void get_crc32(uint8_t *input, size_t len, uint32_t *output);
bool verify_crc32(uint8_t *input, size_t len, uint32_t old_crc);
uint32_t calculate_crc32(uint8_t *input, size_t len);
};
};
};

View File

@ -11,7 +11,7 @@ namespace uvg_rtp {
namespace zrtp_msg {
struct zrtp_confack {
PACKED_STRUCT(zrtp_confack) {
zrtp_msg msg_start;
uint32_t crc;
};

View File

@ -13,7 +13,7 @@ namespace uvg_rtp {
namespace zrtp_msg {
struct zrtp_dh {
PACKED_STRUCT(zrtp_dh) {
zrtp_msg msg_start;
uint32_t hash[8];
uint8_t rs1_id[8];

View File

@ -249,6 +249,17 @@ void uvg_rtp::crypto::crc32::get_crc32(uint8_t *input, size_t len, uint32_t *out
crc32.TruncatedFinal((uint8_t *)output, sizeof(uint32_t));
}
uint32_t uvg_rtp::crypto::crc32::calculate_crc32(uint8_t *input, size_t len)
{
CryptoPP::CRC32 crc32;
uint32_t out;
crc32.Update(input, len);
crc32.TruncatedFinal((uint8_t *)&out, sizeof(uint32_t));
return out;
}
bool uvg_rtp::crypto::crc32::verify_crc32(uint8_t *input, size_t len, uint32_t old_crc)
{
CryptoPP::CRC32 crc32;

View File

@ -62,7 +62,7 @@ uvg_rtp::zrtp_msg::commit::commit(zrtp_session_t& session)
memcpy(&msg->mac, mac_full, sizeof(uint64_t));
/* Calculate CRC32 for the whole ZRTP packet */
uvg_rtp::crypto::crc32::get_crc32((uint8_t *)frame_, len_ - 4, &msg->crc);
msg->crc = uvg_rtp::crypto::crc32::calculate_crc32((uint8_t *)frame_, len_ - sizeof(uint32_t));
/* Finally make a copy of the message and save it for later use */
session.l_msg.commit.first = len_;

View File

@ -38,7 +38,7 @@ uvg_rtp::zrtp_msg::confack::confack(zrtp_session_t& session)
memcpy(&msg->msg_start.msgblock, ZRTP_CONFACK, 8);
/* Calculate CRC32 for the whole ZRTP packet */
uvg_rtp::crypto::crc32::get_crc32((uint8_t *)frame_, len_ - 4, &msg->crc);
msg->crc = uvg_rtp::crypto::crc32::calculate_crc32((uint8_t *)frame_, len_ - sizeof(uint32_t));
}
uvg_rtp::zrtp_msg::confack::~confack()

View File

@ -73,7 +73,7 @@ uvg_rtp::zrtp_msg::confirm::confirm(zrtp_session_t& session, int part)
memcpy(&msg->confirm_mac, mac_full, sizeof(uint64_t));
/* Calculate CRC32 for the whole ZRTP packet */
uvg_rtp::crypto::crc32::get_crc32((uint8_t *)frame_, len_ - 4, &msg->crc);
msg->crc = uvg_rtp::crypto::crc32::calculate_crc32((uint8_t *)frame_, len_ - sizeof(uint32_t));
delete hmac_sha256;
delete aes_cfb;

View File

@ -87,7 +87,7 @@ uvg_rtp::zrtp_msg::dh_key_exchange::dh_key_exchange(zrtp_session_t& session, int
memcpy(msg->mac, mac_full, 8);
/* Calculate CRC32 for the whole ZRTP packet */
uvg_rtp::crypto::crc32::get_crc32((uint8_t *)frame_, len_ - 4, &msg->crc);
msg->crc = uvg_rtp::crypto::crc32::calculate_crc32((uint8_t *)frame_, len_ - sizeof(uint32_t));
/* Finally make a copy of the message and save it for later use */
if (session.l_msg.dh.second)

View File

@ -27,7 +27,7 @@ uvg_rtp::zrtp_msg::error::error(int error_code)
msg->error = error_code;
uvg_rtp::crypto::crc32::get_crc32((uint8_t *)frame_, len_ - 4, &msg->crc);
msg->crc = uvg_rtp::crypto::crc32::calculate_crc32((uint8_t *)frame_, len_ - sizeof(uint32_t));
}
uvg_rtp::zrtp_msg::error::~error()

View File

@ -66,7 +66,7 @@ uvg_rtp::zrtp_msg::hello::hello(zrtp_session_t& session)
memcpy(&msg->mac, mac_full, sizeof(uint64_t));
/* Calculate CRC32 of the whole packet (excluding crc) */
uvg_rtp::crypto::crc32::get_crc32((uint8_t *)frame_, len_ - 4, &msg->crc);
msg->crc = uvg_rtp::crypto::crc32::calculate_crc32((uint8_t *)frame_, len_ - sizeof(uint32_t));
/* Finally make a copy of the message and save it for later use */
session.l_msg.hello.first = len_;

View File

@ -25,7 +25,7 @@ uvg_rtp::zrtp_msg::hello_ack::hello_ack()
memcpy(&msg->msg_start.msgblock, ZRTP_HELLO_ACK, 8);
uvg_rtp::crypto::crc32::get_crc32((uint8_t *)frame_, len_ - 4, &msg->crc);
msg->crc = uvg_rtp::crypto::crc32::calculate_crc32((uint8_t *)frame_, len_ - sizeof(uint32_t));
}
uvg_rtp::zrtp_msg::hello_ack::~hello_ack()

View File

@ -440,6 +440,8 @@ rtp_error_t uvg_rtp::rtcp::recv_packet_handler(void *arg, int flags, frame::rtp_
rtp_error_t uvg_rtp::rtcp::send_packet_handler_buf(void *arg, ssize_t len, void *buf)
{
(void)buf;
return ((uvg_rtp::rtcp *)arg)->update_sender_stats(len - uvg_rtp::frame::HEADER_SIZE_RTP);
}

View File

@ -209,6 +209,8 @@ rtp_error_t uvg_rtp::srtp::init_user(int type, int flags, uint8_t *key, uint8_t
rtp_error_t uvg_rtp::srtp::recv_packet_handler(void *arg, int flags, frame::rtp_frame **out)
{
(void)flags;
uvg_rtp::srtp *srtp = (uvg_rtp::srtp *)arg;
uvg_rtp::srtp_ctx_t ctx = srtp->get_ctx();
uvg_rtp::frame::rtp_frame *frame = *out;
@ -226,7 +228,7 @@ rtp_error_t uvg_rtp::srtp::recv_packet_handler(void *arg, int flags, frame::rtp_
if (seq == 0xffff)
ctx.roc++;
if (srtp->create_iv(iv, frame->header.ssrc, index, ctx.key_ctx.remote.salt_key) != RTP_OK) {
if (srtp->create_iv(iv, ssrc, index, ctx.key_ctx.remote.salt_key) != RTP_OK) {
LOG_ERROR("Failed to create IV, unable to encrypt the RTP packet!");
return RTP_INVALID_VALUE;
}
@ -247,8 +249,6 @@ rtp_error_t uvg_rtp::srtp::recv_packet_handler(void *arg, int flags, frame::rtp_
hmac_sha1.update((uint8_t *)&ctx.roc, sizeof(ctx.roc));
hmac_sha1.final((uint8_t *)&digest);
uint8_t *tmp_buffer = (uint8_t *)frame;
if (memcmp(&digest, &frame[frame->payload_len - AUTH_TAG_LENGTH], AUTH_TAG_LENGTH)) {
LOG_ERROR("Authentication tag mismatch!");
return RTP_AUTH_TAG_MISMATCH;

View File

@ -817,6 +817,8 @@ rtp_error_t uvg_rtp::zrtp::get_srtp_keys(
rtp_error_t uvg_rtp::zrtp::packet_handler(ssize_t size, void *packet, int flags, frame::rtp_frame **out)
{
(void)size, (void)flags, (void)out;
auto msg = (uvg_rtp::zrtp_msg::zrtp_msg *)packet;
/* not a ZRTP packet */
@ -856,5 +858,7 @@ rtp_error_t uvg_rtp::zrtp::packet_handler(ssize_t size, void *packet, int flags,
/* TODO: goclear & co-opeartion with srtp */
}
return RTP_OK;
}
#endif