uint16_t total_length;
int len;
VALUE_PAIR const *reply;
+ bool seen_ma = false;
/*
* A 4K packet, aligned on 64-bits.
* memcpy.
*/
+ /*
+ * Always add Message-Authenticator for replies to
+ * Access-Request packets.
+ *
+ * It must be the FIRST attribute in the packet.
+ */
+ if (!packet->tls && original && (original->code == PW_CODE_ACCESS_REQUEST)) {
+ seen_ma = true;
+
+ packet->offset = RADIUS_HDR_LEN;
+
+ ptr[0] = PW_MESSAGE_AUTHENTICATOR;
+ ptr[1] = 18;
+ memset(ptr + 2, 0, 16);
+
+ ptr += 18;
+ total_length += 18;
+ }
+
/*
* Loop over the reply attributes for the packet.
*/
* length and initial value.
*/
if (!reply->da->vendor && (reply->da->attr == PW_MESSAGE_AUTHENTICATOR)) {
+ /*
+ * We have already encoded the Message-Authenticator, don't do it again.
+ */
+ if (seen_ma) {
+ reply = reply->next;
+ continue;
+ }
+
if (room < 18) break;
/*