OLD | NEW |
1 /* | 1 /* |
2 * srtp.c | 2 * srtp.c |
3 * | 3 * |
4 * the secure real-time transport protocol | 4 * the secure real-time transport protocol |
5 * | 5 * |
6 * David A. McGrew | 6 * David A. McGrew |
7 * Cisco Systems, Inc. | 7 * Cisco Systems, Inc. |
8 */ | 8 */ |
9 /* | 9 /* |
10 * | 10 * |
(...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1070 * find starting point for decryption and length of data to be | 1070 * find starting point for decryption and length of data to be |
1071 * decrypted - the encrypted portion starts after the rtp header | 1071 * decrypted - the encrypted portion starts after the rtp header |
1072 * extension, if present; otherwise, it starts after the last csrc, | 1072 * extension, if present; otherwise, it starts after the last csrc, |
1073 * if any are present | 1073 * if any are present |
1074 */ | 1074 */ |
1075 enc_start = (uint32_t*)hdr + uint32s_in_rtp_header + hdr->cc; | 1075 enc_start = (uint32_t*)hdr + uint32s_in_rtp_header + hdr->cc; |
1076 if (hdr->x == 1) { | 1076 if (hdr->x == 1) { |
1077 srtp_hdr_xtnd_t *xtn_hdr = (srtp_hdr_xtnd_t*)enc_start; | 1077 srtp_hdr_xtnd_t *xtn_hdr = (srtp_hdr_xtnd_t*)enc_start; |
1078 enc_start += (ntohs(xtn_hdr->length) + 1); | 1078 enc_start += (ntohs(xtn_hdr->length) + 1); |
1079 } | 1079 } |
1080 if (!((uint8_t*)enc_start < (uint8_t*)hdr + *pkt_octet_len)) | 1080 if (!((uint8_t*)enc_start < (uint8_t*)hdr + (*pkt_octet_len - tag_len))) |
1081 return err_status_parse_err; | 1081 return err_status_parse_err; |
1082 /* | 1082 /* |
1083 * We pass the tag down to the cipher when doing GCM mode | 1083 * We pass the tag down to the cipher when doing GCM mode |
1084 */ | 1084 */ |
1085 enc_octet_len = (unsigned int)(*pkt_octet_len - | 1085 enc_octet_len = (unsigned int)(*pkt_octet_len - |
1086 ((uint8_t*)enc_start - (uint8_t*)hdr)); | 1086 ((uint8_t*)enc_start - (uint8_t*)hdr)); |
1087 | 1087 |
1088 /* | 1088 /* |
1089 * Sanity check the encrypted payload length against | 1089 * Sanity check the encrypted payload length against |
1090 * the tag size. It must always be at least as large | 1090 * the tag size. It must always be at least as large |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1300 * extension, if present; otherwise, it starts after the last csrc, | 1300 * extension, if present; otherwise, it starts after the last csrc, |
1301 * if any are present | 1301 * if any are present |
1302 * | 1302 * |
1303 * if we're not providing confidentiality, set enc_start to NULL | 1303 * if we're not providing confidentiality, set enc_start to NULL |
1304 */ | 1304 */ |
1305 if (stream->rtp_services & sec_serv_conf) { | 1305 if (stream->rtp_services & sec_serv_conf) { |
1306 enc_start = (uint32_t *)hdr + uint32s_in_rtp_header + hdr->cc; | 1306 enc_start = (uint32_t *)hdr + uint32s_in_rtp_header + hdr->cc; |
1307 if (hdr->x == 1) { | 1307 if (hdr->x == 1) { |
1308 srtp_hdr_xtnd_t *xtn_hdr = (srtp_hdr_xtnd_t *)enc_start; | 1308 srtp_hdr_xtnd_t *xtn_hdr = (srtp_hdr_xtnd_t *)enc_start; |
1309 enc_start += (ntohs(xtn_hdr->length) + 1); | 1309 enc_start += (ntohs(xtn_hdr->length) + 1); |
1310 if (!((uint8_t*)enc_start < (uint8_t*)hdr + *pkt_octet_len)) | |
1311 return err_status_parse_err; | |
1312 } | 1310 } |
| 1311 if (!((uint8_t*)enc_start < (uint8_t*)hdr + *pkt_octet_len)) |
| 1312 return err_status_parse_err; |
1313 enc_octet_len = (unsigned int)(*pkt_octet_len - | 1313 enc_octet_len = (unsigned int)(*pkt_octet_len - |
1314 ((uint8_t*)enc_start - (uint8_t*)hdr)); | 1314 ((uint8_t*)enc_start - (uint8_t*)hdr)); |
1315 } else { | 1315 } else { |
1316 enc_start = NULL; | 1316 enc_start = NULL; |
1317 } | 1317 } |
1318 | 1318 |
1319 /* | 1319 /* |
1320 * if we're providing authentication, set the auth_start and auth_tag | 1320 * if we're providing authentication, set the auth_start and auth_tag |
1321 * pointers to the proper locations; otherwise, set auth_start to NULL | 1321 * pointers to the proper locations; otherwise, set auth_start to NULL |
1322 * to indicate that no authentication is needed | 1322 * to indicate that no authentication is needed |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1588 * if any are present | 1588 * if any are present |
1589 * | 1589 * |
1590 * if we're not providing confidentiality, set enc_start to NULL | 1590 * if we're not providing confidentiality, set enc_start to NULL |
1591 */ | 1591 */ |
1592 if (stream->rtp_services & sec_serv_conf) { | 1592 if (stream->rtp_services & sec_serv_conf) { |
1593 enc_start = (uint32_t *)hdr + uint32s_in_rtp_header + hdr->cc; | 1593 enc_start = (uint32_t *)hdr + uint32s_in_rtp_header + hdr->cc; |
1594 if (hdr->x == 1) { | 1594 if (hdr->x == 1) { |
1595 srtp_hdr_xtnd_t *xtn_hdr = (srtp_hdr_xtnd_t *)enc_start; | 1595 srtp_hdr_xtnd_t *xtn_hdr = (srtp_hdr_xtnd_t *)enc_start; |
1596 enc_start += (ntohs(xtn_hdr->length) + 1); | 1596 enc_start += (ntohs(xtn_hdr->length) + 1); |
1597 } | 1597 } |
1598 if (!((uint8_t*)enc_start < (uint8_t*)hdr + *pkt_octet_len)) | 1598 if (!((uint8_t*)enc_start < (uint8_t*)hdr + (*pkt_octet_len - tag_len))) |
1599 return err_status_parse_err; | 1599 return err_status_parse_err; |
1600 enc_octet_len = (uint32_t)(*pkt_octet_len - tag_len - | 1600 enc_octet_len = (uint32_t)(*pkt_octet_len - tag_len - |
1601 ((uint8_t*)enc_start - (uint8_t*)hdr)); | 1601 ((uint8_t*)enc_start - (uint8_t*)hdr)); |
1602 } else { | 1602 } else { |
1603 enc_start = NULL; | 1603 enc_start = NULL; |
1604 } | 1604 } |
1605 | 1605 |
1606 /* | 1606 /* |
1607 * if we're providing authentication, set the auth_start and auth_tag | 1607 * if we're providing authentication, set the auth_start and auth_tag |
1608 * pointers to the proper locations; otherwise, set auth_start to NULL | 1608 * pointers to the proper locations; otherwise, set auth_start to NULL |
(...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3216 break; | 3216 break; |
3217 case srtp_profile_aes256_cm_sha1_32: | 3217 case srtp_profile_aes256_cm_sha1_32: |
3218 return 14; | 3218 return 14; |
3219 break; | 3219 break; |
3220 /* the following profiles are not (yet) supported */ | 3220 /* the following profiles are not (yet) supported */ |
3221 case srtp_profile_null_sha1_32: | 3221 case srtp_profile_null_sha1_32: |
3222 default: | 3222 default: |
3223 return 0; /* indicate error by returning a zero */ | 3223 return 0; /* indicate error by returning a zero */ |
3224 } | 3224 } |
3225 } | 3225 } |
OLD | NEW |