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

Function sctp_compute_hmac_m

freebsd/netinet/sctp_auth.c:1091–1121  ·  view source on GitHub ↗

mbuf version */

Source from the content-addressed store, hash-verified

1089
1090/* mbuf version */
1091uint32_t
1092sctp_compute_hmac_m(uint16_t hmac_algo, sctp_key_t *key, struct mbuf *m,
1093 uint32_t m_offset, uint8_t *digest)
1094{
1095 uint32_t digestlen;
1096 uint32_t blocklen;
1097 sctp_hash_context_t ctx;
1098 uint8_t temp[SCTP_AUTH_DIGEST_LEN_MAX];
1099
1100 /* sanity check */
1101 if ((key == NULL) || (m == NULL) || (digest == NULL)) {
1102 /* can't do HMAC with empty key or text or digest store */
1103 return (0);
1104 }
1105 /* validate the hmac algo and get the digest length */
1106 digestlen = sctp_get_hmac_digest_len(hmac_algo);
1107 if (digestlen == 0)
1108 return (0);
1109
1110 /* hash the key if it is longer than the hash block size */
1111 blocklen = sctp_get_hmac_block_len(hmac_algo);
1112 if (key->keylen > blocklen) {
1113 sctp_hmac_init(hmac_algo, &ctx);
1114 sctp_hmac_update(hmac_algo, &ctx, key->key, key->keylen);
1115 sctp_hmac_final(hmac_algo, &ctx, temp);
1116 /* save the hashed key as the new key */
1117 key->keylen = digestlen;
1118 memcpy(key->key, temp, key->keylen);
1119 }
1120 return (sctp_hmac_m(hmac_algo, key->key, key->keylen, m, m_offset, digest, 0));
1121}
1122
1123int
1124sctp_auth_is_supported_hmac(sctp_hmaclist_t *list, uint16_t id)

Callers 2

sctp_fill_hmac_digest_mFunction · 0.85
sctp_handle_authFunction · 0.85

Calls 7

sctp_get_hmac_digest_lenFunction · 0.85
sctp_get_hmac_block_lenFunction · 0.85
sctp_hmac_initFunction · 0.85
sctp_hmac_updateFunction · 0.85
sctp_hmac_finalFunction · 0.85
sctp_hmac_mFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected