Verify IKEv1 nonce size, send 32 byte nonces

This commit is contained in:
Martin Willi
2012-03-20 17:30:44 +01:00
parent 6c2b7d4ed9
commit 31fc14e394
2 changed files with 22 additions and 7 deletions
@@ -19,6 +19,7 @@
#include "nonce_payload.h"
#include <daemon.h>
#include <encoding/payloads/encodings.h>
typedef struct private_nonce_payload_t private_nonce_payload_t;
@@ -103,8 +104,26 @@ static encoding_rule_t encodings[] = {
METHOD(payload_t, verify, status_t,
private_nonce_payload_t *this)
{
if (this->nonce.len < 16 || this->nonce.len > 256)
bool bad_length = FALSE;
if (this->nonce.len > 256)
{
bad_length = TRUE;
}
if (this->type == NONCE &&
this->nonce.len < 16)
{
bad_length = TRUE;
}
if (this->type == NONCE_V1 &&
this->nonce.len < 8)
{
bad_length = TRUE;
}
if (bad_length)
{
DBG1(DBG_ENC, "%N payload has invalid length (%d bytes)",
payload_type_names, this->type, this->nonce.len);
return FAILED;
}
return SUCCESS;