implemented MS_MPPE encryption

This commit is contained in:
Andreas Steffen
2012-03-13 23:26:15 +01:00
parent 5fdb849293
commit 6fd612913e
4 changed files with 148 additions and 35 deletions
+2 -1
View File
@@ -6,5 +6,6 @@ libradius_la_SOURCES = \
radius_message.h radius_message.c \
radius_socket.h radius_socket.c \
radius_client.h radius_client.c \
radius_config.h radius_config.c
radius_config.h radius_config.c \
radius_mppe.h
+45
View File
@@ -0,0 +1,45 @@
/*
* Copyright (C) 2012 Andreas Steffen
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
/**
* @defgroup libradius libradius
*
* @addtogroup libradius
* RADIUS protocol support library.
*
* @defgroup radius_msse radius_msse
* @{ @ingroup libradius
*/
#ifndef RADIUS_MSSE_H_
#define RADIUS_MSSE_H_
/**
* Microsoft specific vendor attributes
*/
#define MS_MPPE_SEND_KEY 16
#define MS_MPPE_RECV_KEY 17
typedef struct mppe_key_t mppe_key_t;
struct mppe_key_t {
u_int32_t id;
u_int8_t type;
u_int8_t length;
u_int16_t salt;
u_int8_t key[];
} __attribute__((packed));
#endif /** RADIUS_MSSE_H_ @}*/
+8 -20
View File
@@ -14,6 +14,7 @@
*/
#include "radius_socket.h"
#include "radius_mppe.h"
#include <errno.h>
#include <unistd.h>
@@ -21,12 +22,6 @@
#include <pen/pen.h>
#include <debug.h>
/**
* Microsoft specific vendor attributes
*/
#define MS_MPPE_SEND_KEY 16
#define MS_MPPE_RECV_KEY 17
typedef struct private_radius_socket_t private_radius_socket_t;
/**
@@ -286,13 +281,7 @@ METHOD(radius_socket_t, decrypt_msk, chunk_t,
private_radius_socket_t *this, radius_message_t *request,
radius_message_t *response)
{
struct {
u_int32_t id;
u_int8_t type;
u_int8_t length;
u_int16_t salt;
u_int8_t key[];
} __attribute__((packed)) *mppe_key;
mppe_key_t *mppe_key;
enumerator_t *enumerator;
chunk_t data, send = chunk_empty, recv = chunk_empty;
int type;
@@ -300,14 +289,13 @@ METHOD(radius_socket_t, decrypt_msk, chunk_t,
enumerator = response->create_enumerator(response);
while (enumerator->enumerate(enumerator, &type, &data))
{
if (type == RAT_VENDOR_SPECIFIC &&
data.len > sizeof(*mppe_key))
if (type == RAT_VENDOR_SPECIFIC && data.len > sizeof(mppe_key_t))
{
mppe_key = (void*)data.ptr;
mppe_key = (mppe_key_t*)data.ptr;
if (ntohl(mppe_key->id) == PEN_MICROSOFT &&
mppe_key->length == data.len - sizeof(mppe_key->id))
{
data = chunk_create(mppe_key->key, data.len - sizeof(*mppe_key));
data = chunk_create(mppe_key->key, data.len - sizeof(mppe_key_t));
if (mppe_key->type == MS_MPPE_SEND_KEY)
{
send = decrypt_mppe_key(this, mppe_key->salt, data, request);
@@ -365,11 +353,11 @@ radius_socket_t *radius_socket_create(char *address, u_int16_t auth_port,
.auth_fd = -1,
.acct_port = acct_port,
.acct_fd = -1,
.hasher = lib->crypto->create_hasher(lib->crypto, HASH_MD5),
.signer = lib->crypto->create_signer(lib->crypto, AUTH_HMAC_MD5_128),
.rng = lib->crypto->create_rng(lib->crypto, RNG_WEAK),
);
this->hasher = lib->crypto->create_hasher(lib->crypto, HASH_MD5);
this->signer = lib->crypto->create_signer(lib->crypto, AUTH_HMAC_MD5_128);
this->rng = lib->crypto->create_rng(lib->crypto, RNG_WEAK);
if (!this->hasher || !this->signer || !this->rng)
{
DBG1(DBG_CFG, "RADIUS initialization failed, HMAC/MD5/RNG required");