response = radius_message_create(code);
response->set_identifier(response, request->get_identifier(request));
response->sign(response, request->get_authenticator(request),
- this->secret, this->hasher, this->signer, NULL);
+ this->secret, this->hasher, this->signer, NULL, FALSE);
send_message(this, response, client);
save_retransmit(this, response, client);
}
response->set_identifier(response, request->get_identifier(request));
response->sign(response, request->get_authenticator(request),
- this->secret, this->hasher, this->signer, NULL);
+ this->secret, this->hasher, this->signer, NULL, TRUE);
DBG1(DBG_CFG, "sending RADIUS %N to client '%H'", radius_message_code_names,
code, client);
METHOD(radius_message_t, sign, void,
private_radius_message_t *this, u_int8_t *req_auth, chunk_t secret,
- hasher_t *hasher, signer_t *signer, rng_t *rng)
+ hasher_t *hasher, signer_t *signer, rng_t *rng, bool msg_auth)
{
if (rng)
{
}
else
{
- /* build Response-Authenticator */
+ /* prepare build of Response-Authenticator */
if (req_auth)
{
memcpy(this->msg->authenticator, req_auth, HASH_SIZE_MD5);
}
}
- if (rng || this->msg->code == RMC_ACCESS_CHALLENGE
- || this->msg->code == RMC_ACCESS_ACCEPT
- || this->msg->code == RMC_ACCESS_REJECT)
+ if (msg_auth)
{
char buf[HASH_SIZE_MD5];
{
chunk_t msg;
+ /* build Response-Authenticator */
msg = chunk_create((u_char*)this->msg, ntohs(this->msg->length));
hasher->get_hash(hasher, msg, NULL);
hasher->get_hash(hasher, secret, this->msg->authenticator);
* @param secret shared RADIUS secret
* @param signer HMAC-MD5 signer with secret set
* @param hasher MD5 hasher
- * @param rng RNG to create Message-Authenticator, NULL to omit
+ * @param rng RNG to create Request-Authenticator, NULL to omit
+ * @param msg_auth calculate and add Message-Authenticator
*/
void (*sign)(radius_message_t *this, u_int8_t *req_auth, chunk_t secret,
- hasher_t *hasher, signer_t *signer, rng_t *rng);
+ hasher_t *hasher, signer_t *signer, rng_t *rng, bool msg_auth);
/**
* Verify the integrity of a received RADIUS message.
/* set Message Identifier */
request->set_identifier(request, this->identifier++);
/* sign the request */
- request->sign(request, NULL, this->secret, this->hasher, this->signer, rng);
+ request->sign(request, NULL, this->secret, this->hasher, this->signer,
+ rng, rng != NULL);
if (!check_connection(this, fd, port))
{