(srtp_test): Make sure that the packet passed to srtp_unprotect() in replay check really is identical to previous packet.
diff --git a/test/srtp_driver.c b/test/srtp_driver.c
index d9f3faa..bfb04dc 100644
--- a/test/srtp_driver.c
+++ b/test/srtp_driver.c
@@ -552,8 +552,9 @@
srtp_t srtp_rcvr;
err_status_t status = err_status_ok;
srtp_hdr_t *hdr, *hdr2;
+ uint8_t hdr_enc[64];
uint8_t *pkt_end;
- int msg_len_octets;
+ int msg_len_octets, msg_len_enc;
int len;
int tag_length = policy->rtp.auth_tag_len;
uint32_t ssrc;
@@ -603,6 +604,10 @@
octet_string_hex_string((uint8_t *)hdr, len));
#endif
+ /* save protected message and length */
+ memcpy(hdr_enc, hdr, len);
+ msg_len_enc = len;
+
/*
* check for overrun of the srtp_protect() function
*
@@ -689,8 +694,11 @@
printf("testing for false positives in replay check...");
+ /* set message length */
+ len = msg_len_enc;
+
/* unprotect a second time - should fail with a replay error */
- status = srtp_unprotect(srtp_rcvr, hdr, &len);
+ status = srtp_unprotect(srtp_rcvr, hdr_enc, &len);
if (status != err_status_replay_fail) {
printf("failed with error code %d\n", status);
free(hdr);
@@ -705,6 +713,9 @@
/* increment sequence number in header */
hdr->seq++;
+ /* set message length */
+ len = msg_len_octets;
+
/* apply protection */
err_check(srtp_protect(srtp_sender, hdr, &len));