mbuf version */
| 1089 | |
| 1090 | /* mbuf version */ |
| 1091 | uint32_t |
| 1092 | sctp_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 | |
| 1123 | int |
| 1124 | sctp_auth_is_supported_hmac(sctp_hmaclist_t *list, uint16_t id) |
no test coverage detected