2 * Microsoft Point-to-Point Encryption Protocol (MPPE)
4 * Copyright (C) 2010, Broadcom Corporation
7 * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
8 * the contents of this file may not be disclosed to third parties, copied
9 * or duplicated in any form, in whole or in part, without the prior
10 * written permission of Broadcom Corporation.
12 * $Id: mppe.c 241388 2011-02-18 03:33:22Z stakita $
17 #include <bcmcrypto/md5.h>
21 #define bcopy(src, dst, len) memcpy((dst), (src), (len))
22 #define bzero(b, len) memset((b), '\0', (len))
24 /* Encrypt or decrypt a MPPE message in place */
26 mppe_crypt(unsigned char salt
[2], /* 2 bytes Salt */
27 unsigned char *text
, int text_len
, /* Multiple of 16 bytes String */
28 unsigned char *key
, int key_len
, /* Shared secret */
29 unsigned char vector
[16], /* 16 bytes Request Authenticator vector */
30 int encrypt
) /* Encrypt if 1 */
32 unsigned char b
[16], c
[16], *p
;
36 /* Initial cipher block is Request Authenticator vector */
38 for (p
= text
; &p
[15] < &text
[text_len
]; p
+= 16) {
40 /* Add shared secret */
41 MD5Update(&md5
, key
, key_len
);
42 /* Add last cipher block */
43 MD5Update(&md5
, c
, 16);
46 MD5Update(&md5
, salt
, 2);
49 for (i
= 0; i
< 16; i
++) {
54 for (i
= 0; i
< 16; i
++) {