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

Function sctp_auth_get_cookie_params

freebsd/netinet/sctp_auth.c:1361–1496  ·  view source on GitHub ↗

* get local authentication parameters from cookie (from INIT-ACK) */

Source from the content-addressed store, hash-verified

1359 * get local authentication parameters from cookie (from INIT-ACK)
1360 */
1361void
1362sctp_auth_get_cookie_params(struct sctp_tcb *stcb, struct mbuf *m,
1363 uint32_t offset, uint32_t length)
1364{
1365 struct sctp_paramhdr *phdr, tmp_param;
1366 uint16_t plen, ptype;
1367 uint8_t random_store[SCTP_PARAM_BUFFER_SIZE];
1368 struct sctp_auth_random *p_random = NULL;
1369 uint16_t random_len = 0;
1370 uint8_t hmacs_store[SCTP_PARAM_BUFFER_SIZE];
1371 struct sctp_auth_hmac_algo *hmacs = NULL;
1372 uint16_t hmacs_len = 0;
1373 uint8_t chunks_store[SCTP_PARAM_BUFFER_SIZE];
1374 struct sctp_auth_chunk_list *chunks = NULL;
1375 uint16_t num_chunks = 0;
1376 sctp_key_t *new_key;
1377 uint32_t keylen;
1378
1379 /* convert to upper bound */
1380 length += offset;
1381
1382 phdr = (struct sctp_paramhdr *)sctp_m_getptr(m, offset,
1383 sizeof(struct sctp_paramhdr), (uint8_t *)&tmp_param);
1384 while (phdr != NULL) {
1385 ptype = ntohs(phdr->param_type);
1386 plen = ntohs(phdr->param_length);
1387
1388 if ((plen < sizeof(struct sctp_paramhdr)) ||
1389 (offset + plen > length))
1390 break;
1391
1392 if (ptype == SCTP_RANDOM) {
1393 if (plen > sizeof(random_store))
1394 break;
1395 phdr = sctp_get_next_param(m, offset,
1396 (struct sctp_paramhdr *)random_store, plen);
1397 if (phdr == NULL)
1398 return;
1399 /* save the random and length for the key */
1400 p_random = (struct sctp_auth_random *)phdr;
1401 random_len = plen - sizeof(*p_random);
1402 } else if (ptype == SCTP_HMAC_LIST) {
1403 uint16_t num_hmacs;
1404 uint16_t i;
1405
1406 if (plen > sizeof(hmacs_store))
1407 break;
1408 phdr = sctp_get_next_param(m, offset,
1409 (struct sctp_paramhdr *)hmacs_store, plen);
1410 if (phdr == NULL)
1411 return;
1412 /* save the hmacs list and num for the key */
1413 hmacs = (struct sctp_auth_hmac_algo *)phdr;
1414 hmacs_len = plen - sizeof(*hmacs);
1415 num_hmacs = hmacs_len / sizeof(hmacs->hmac_ids[0]);
1416 if (stcb->asoc.local_hmacs != NULL)
1417 sctp_free_hmaclist(stcb->asoc.local_hmacs);
1418 stcb->asoc.local_hmacs = sctp_alloc_hmaclist(num_hmacs);

Callers 1

sctp_process_cookie_newFunction · 0.85

Calls 14

sctp_m_getptrFunction · 0.85
sctp_get_next_paramFunction · 0.85
sctp_free_hmaclistFunction · 0.85
sctp_alloc_hmaclistFunction · 0.85
sctp_auth_add_hmacidFunction · 0.85
sctp_clear_chunklistFunction · 0.85
sctp_alloc_chunklistFunction · 0.85
sctp_auth_add_chunkFunction · 0.85
sctp_alloc_keyFunction · 0.85
sctp_free_keyFunction · 0.85
sctp_clear_cachedkeysFunction · 0.85
sctp_negotiate_hmacidFunction · 0.85

Tested by

no test coverage detected