MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sctp_validate_init_auth_params

Function sctp_validate_init_auth_params

freebsd/netinet/sctp_auth.c:1771–1912  ·  view source on GitHub ↗

- * validates the AUTHentication related parameters in an INIT/INIT-ACK * Note: currently only used for INIT as INIT-ACK is handled inline * with sctp_load_addresses_from_init() */

Source from the content-addressed store, hash-verified

1769 * with sctp_load_addresses_from_init()
1770 */
1771int
1772sctp_validate_init_auth_params(struct mbuf *m, int offset, int limit)
1773{
1774 struct sctp_paramhdr *phdr, param_buf;
1775 uint16_t ptype, plen;
1776 int peer_supports_asconf = 0;
1777 int peer_supports_auth = 0;
1778 int got_random = 0, got_hmacs = 0, got_chklist = 0;
1779 uint8_t saw_asconf = 0;
1780 uint8_t saw_asconf_ack = 0;
1781
1782 /* go through each of the params. */
1783 phdr = sctp_get_next_param(m, offset, &param_buf, sizeof(param_buf));
1784 while (phdr) {
1785 ptype = ntohs(phdr->param_type);
1786 plen = ntohs(phdr->param_length);
1787
1788 if (offset + plen > limit) {
1789 break;
1790 }
1791 if (plen < sizeof(struct sctp_paramhdr)) {
1792 break;
1793 }
1794 if (ptype == SCTP_SUPPORTED_CHUNK_EXT) {
1795 /* A supported extension chunk */
1796 struct sctp_supported_chunk_types_param *pr_supported;
1797 uint8_t local_store[SCTP_SMALL_CHUNK_STORE];
1798 int num_ent, i;
1799
1800 if (plen > sizeof(local_store)) {
1801 break;
1802 }
1803 phdr = sctp_get_next_param(m, offset,
1804 (struct sctp_paramhdr *)&local_store,
1805 plen);
1806 if (phdr == NULL) {
1807 return (-1);
1808 }
1809 pr_supported = (struct sctp_supported_chunk_types_param *)phdr;
1810 num_ent = plen - sizeof(struct sctp_paramhdr);
1811 for (i = 0; i < num_ent; i++) {
1812 switch (pr_supported->chunk_types[i]) {
1813 case SCTP_ASCONF:
1814 case SCTP_ASCONF_ACK:
1815 peer_supports_asconf = 1;
1816 break;
1817 default:
1818 /* one we don't care about */
1819 break;
1820 }
1821 }
1822 } else if (ptype == SCTP_RANDOM) {
1823 /* enforce the random length */
1824 if (plen != (sizeof(struct sctp_auth_random) +
1825 SCTP_AUTH_RANDOM_SIZE_REQUIRED)) {
1826 SCTPDBG(SCTP_DEBUG_AUTH1,
1827 "SCTP: invalid RANDOM len\n");
1828 return (-1);

Callers 1

sctp_handle_initFunction · 0.85

Calls 2

sctp_get_next_paramFunction · 0.85
sctp_verify_hmac_paramFunction · 0.85

Tested by

no test coverage detected