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

Function sctp_handle_auth

freebsd/netinet/sctp_auth.c:1589–1704  ·  view source on GitHub ↗

- * process the incoming Authentication chunk * return codes: * -1 on any authentication error * 0 on authentication verification */

Source from the content-addressed store, hash-verified

1587 * 0 on authentication verification
1588 */
1589int
1590sctp_handle_auth(struct sctp_tcb *stcb, struct sctp_auth_chunk *auth,
1591 struct mbuf *m, uint32_t offset)
1592{
1593 uint16_t chunklen;
1594 uint16_t shared_key_id;
1595 uint16_t hmac_id;
1596 sctp_sharedkey_t *skey;
1597 uint32_t digestlen;
1598 uint8_t digest[SCTP_AUTH_DIGEST_LEN_MAX];
1599 uint8_t computed_digest[SCTP_AUTH_DIGEST_LEN_MAX];
1600
1601 /* auth is checked for NULL by caller */
1602 chunklen = ntohs(auth->ch.chunk_length);
1603 if (chunklen < sizeof(*auth)) {
1604 SCTP_STAT_INCR(sctps_recvauthfailed);
1605 return (-1);
1606 }
1607 SCTP_STAT_INCR(sctps_recvauth);
1608
1609 /* get the auth params */
1610 shared_key_id = ntohs(auth->shared_key_id);
1611 hmac_id = ntohs(auth->hmac_id);
1612 SCTPDBG(SCTP_DEBUG_AUTH1,
1613 "SCTP AUTH Chunk: shared key %u, HMAC id %u\n",
1614 shared_key_id, hmac_id);
1615
1616 /* is the indicated HMAC supported? */
1617 if (!sctp_auth_is_supported_hmac(stcb->asoc.local_hmacs, hmac_id)) {
1618 struct mbuf *op_err;
1619 struct sctp_error_auth_invalid_hmac *cause;
1620
1621 SCTP_STAT_INCR(sctps_recvivalhmacid);
1622 SCTPDBG(SCTP_DEBUG_AUTH1,
1623 "SCTP Auth: unsupported HMAC id %u\n",
1624 hmac_id);
1625 /*
1626 * report this in an Error Chunk: Unsupported HMAC
1627 * Identifier
1628 */
1629 op_err = sctp_get_mbuf_for_msg(sizeof(struct sctp_error_auth_invalid_hmac),
1630 0, M_NOWAIT, 1, MT_HEADER);
1631 if (op_err != NULL) {
1632 /* pre-reserve some space */
1633 SCTP_BUF_RESV_UF(op_err, sizeof(struct sctp_chunkhdr));
1634 /* fill in the error */
1635 cause = mtod(op_err, struct sctp_error_auth_invalid_hmac *);
1636 cause->cause.code = htons(SCTP_CAUSE_UNSUPPORTED_HMACID);
1637 cause->cause.length = htons(sizeof(struct sctp_error_auth_invalid_hmac));
1638 cause->hmac_id = ntohs(hmac_id);
1639 SCTP_BUF_LEN(op_err) = sizeof(struct sctp_error_auth_invalid_hmac);
1640 /* queue it */
1641 sctp_queue_op_err(stcb, op_err);
1642 }
1643 return (-1);
1644 }
1645 /* get the indicated shared key, if available */
1646 if ((stcb->asoc.authinfo.recv_key == NULL) ||

Callers 2

sctp_process_cookie_newFunction · 0.85
sctp_process_controlFunction · 0.85

Calls 13

sctp_get_mbuf_for_msgFunction · 0.85
sctp_queue_op_errFunction · 0.85
sctp_find_sharedkeyFunction · 0.85
sctp_free_keyFunction · 0.85
sctp_compute_hashkeyFunction · 0.85
sctp_print_keyFunction · 0.85
sctp_get_hmac_digest_lenFunction · 0.85
sctp_zero_mFunction · 0.85
sctp_compute_hmac_mFunction · 0.85
timingsafe_bcmpFunction · 0.85

Tested by

no test coverage detected