eap_attr::create_ms_mppe_key() method for MS-MPPE-Send-Key and MS-MPPE-Recv-Key generation added

This commit is contained in:
Simon Rozman 2016-08-12 21:09:38 +02:00
parent dc27115903
commit 84e544c2f6
2 changed files with 49 additions and 0 deletions

View File

@ -151,6 +151,18 @@ namespace winstd
} }
return *this; return *this;
} }
///
/// Creates MS-MPPE-Send-Key or MS-MPPE-Recv-Key
///
/// \sa [RADIUS Vendor-Specific](https://tools.ietf.org/html/rfc2865#section-5.26)
/// \sa [MS-MPPE-Send-Key](https://tools.ietf.org/html/rfc2548#section-2.4.2)
/// \sa [MS-MPPE-Recv-Key](https://tools.ietf.org/html/rfc2548#section-2.4.3)
///
void create_ms_mppe_key(_In_ BYTE bVendorType, _In_count_(nKeySize) LPCBYTE pbKey, _In_ BYTE nKeySize);
public:
static const EAP_ATTRIBUTE blank;
}; };

View File

@ -32,6 +32,43 @@ winstd::eap_attr::~eap_attr()
} }
void winstd::eap_attr::create_ms_mppe_key(_In_ BYTE bVendorType, _In_count_(nKeySize) LPCBYTE pbKey, _In_ BYTE nKeySize)
{
BYTE nPaddingLength = (BYTE)((16 - (1 + nKeySize)) % 16);
DWORD dwLengthNew =
4 + // Vendor-Id
1 + // Vendor type
1 + // Vendor length
2 + // Salt
1 + // Key-Length
nKeySize + // Key
nPaddingLength; // Padding
LPBYTE p = new BYTE[dwLengthNew];
p[0] = 0x00; // Vendor-Id (0x137 = 311 = Microsoft)
p[1] = 0x00; // --|
p[2] = 0x01; // --|
p[3] = 0x37; // --^
p[4] = bVendorType; // Vendor type
p[5] = (BYTE)(dwLengthNew - 4); // Vendor length
p[6] = 0x00; // Salt
p[7] = 0x00; // --^
p[8] = nKeySize; // Key-Length
memcpy(p + 9, pbKey, nKeySize); // Key
memset(p + 9 + nKeySize, 0, nPaddingLength); // Padding
if (pValue)
delete [] pValue;
eaType = eatVendorSpecific;
dwLength = dwLengthNew;
pValue = p;
}
const EAP_ATTRIBUTE winstd::eap_attr::blank = {};
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// winstd::eap_packet // winstd::eap_packet
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////