Deleted Added
full compact
ng_mppc.c (87599) ng_mppc.c (87971)
1
2/*
3 * ng_mppc.c
4 *
5 * Copyright (c) 1996-2000 Whistle Communications, Inc.
6 * All rights reserved.
7 *
8 * Subject to the following obligations and disclaimer of warranty, use and

--- 23 unchanged lines hidden (view full) ---

32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
35 * OF SUCH DAMAGE.
36 *
37 * Author: Archie Cobbs <archie@freebsd.org>
38 *
39 * $Whistle: ng_mppc.c,v 1.4 1999/11/25 00:10:12 archie Exp $
1
2/*
3 * ng_mppc.c
4 *
5 * Copyright (c) 1996-2000 Whistle Communications, Inc.
6 * All rights reserved.
7 *
8 * Subject to the following obligations and disclaimer of warranty, use and

--- 23 unchanged lines hidden (view full) ---

32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
35 * OF SUCH DAMAGE.
36 *
37 * Author: Archie Cobbs <archie@freebsd.org>
38 *
39 * $Whistle: ng_mppc.c,v 1.4 1999/11/25 00:10:12 archie Exp $
40 * $FreeBSD: head/sys/netgraph/ng_mppc.c 87599 2001-12-10 08:09:49Z obrien $
40 * $FreeBSD: head/sys/netgraph/ng_mppc.c 87971 2001-12-15 02:07:32Z archie $
41 */
42
43/*
44 * Microsoft PPP compression (MPPC) and encryption (MPPE) netgraph node type.
45 *
46 * You must define one or both of the NETGRAPH_MPPC_COMPRESSION and/or
47 * NETGRAPH_MPPC_ENCRYPTION options for this node type to be useful.
48 */

--- 110 unchanged lines hidden (view full) ---

159 NULL,
160 NULL,
161 ng_mppc_rcvdata,
162 ng_mppc_disconnect,
163 NULL
164};
165NETGRAPH_INIT(mppc, &ng_mppc_typestruct);
166
41 */
42
43/*
44 * Microsoft PPP compression (MPPC) and encryption (MPPE) netgraph node type.
45 *
46 * You must define one or both of the NETGRAPH_MPPC_COMPRESSION and/or
47 * NETGRAPH_MPPC_ENCRYPTION options for this node type to be useful.
48 */

--- 110 unchanged lines hidden (view full) ---

159 NULL,
160 NULL,
161 ng_mppc_rcvdata,
162 ng_mppc_disconnect,
163 NULL
164};
165NETGRAPH_INIT(mppc, &ng_mppc_typestruct);
166
167/* Fixed bit pattern to weaken keysize down to 40 bits */
167/* Fixed bit pattern to weaken keysize down to 40 or 56 bits */
168static const u_char ng_mppe_weakenkey[3] = { 0xd1, 0x26, 0x9e };
169
170#define ERROUT(x) do { error = (x); goto done; } while (0)
171
172/************************************************************************
173 NETGRAPH NODE STUFF
174 ************************************************************************/
175

--- 114 unchanged lines hidden (view full) ---

290
291#ifdef NETGRAPH_MPPC_ENCRYPTION
292 /* Generate initial session keys for encryption */
293 if ((cfg->bits & MPPE_BITS) != 0) {
294 const int keylen = KEYLEN(cfg->bits);
295
296 bcopy(cfg->startkey, d->key, keylen);
297 ng_mppc_getkey(cfg->startkey, d->key, keylen);
168static const u_char ng_mppe_weakenkey[3] = { 0xd1, 0x26, 0x9e };
169
170#define ERROUT(x) do { error = (x); goto done; } while (0)
171
172/************************************************************************
173 NETGRAPH NODE STUFF
174 ************************************************************************/
175

--- 114 unchanged lines hidden (view full) ---

290
291#ifdef NETGRAPH_MPPC_ENCRYPTION
292 /* Generate initial session keys for encryption */
293 if ((cfg->bits & MPPE_BITS) != 0) {
294 const int keylen = KEYLEN(cfg->bits);
295
296 bcopy(cfg->startkey, d->key, keylen);
297 ng_mppc_getkey(cfg->startkey, d->key, keylen);
298 if ((cfg->bits & MPPE_128) == 0) {
299 bcopy(&ng_mppe_weakenkey, d->key,
300 sizeof(ng_mppe_weakenkey));
301 }
298 if ((cfg->bits & MPPE_40) != 0)
299 bcopy(&ng_mppe_weakenkey, d->key, 3);
300 else if ((cfg->bits & MPPE_56) != 0)
301 bcopy(&ng_mppe_weakenkey, d->key, 1);
302 rc4_init(&d->rc4, d->key, keylen);
303 }
304#endif
305
306 /* Initialize other state */
307 d->cc = 0;
308 d->flushed = 0;
309 break;

--- 464 unchanged lines hidden (view full) ---

774ng_mppc_updatekey(u_int32_t bits,
775 u_char *key0, u_char *key, struct rc4_state *rc4)
776{
777 const int keylen = KEYLEN(bits);
778
779 ng_mppc_getkey(key0, key, keylen);
780 rc4_init(rc4, key, keylen);
781 rc4_crypt(rc4, key, key, keylen);
302 rc4_init(&d->rc4, d->key, keylen);
303 }
304#endif
305
306 /* Initialize other state */
307 d->cc = 0;
308 d->flushed = 0;
309 break;

--- 464 unchanged lines hidden (view full) ---

774ng_mppc_updatekey(u_int32_t bits,
775 u_char *key0, u_char *key, struct rc4_state *rc4)
776{
777 const int keylen = KEYLEN(bits);
778
779 ng_mppc_getkey(key0, key, keylen);
780 rc4_init(rc4, key, keylen);
781 rc4_crypt(rc4, key, key, keylen);
782 if ((bits & MPPE_128) == 0)
783 bcopy(&ng_mppe_weakenkey, key, sizeof(ng_mppe_weakenkey));
782 if ((bits & MPPE_40) != 0)
783 bcopy(&ng_mppe_weakenkey, key, 3);
784 else if ((bits & MPPE_56) != 0)
785 bcopy(&ng_mppe_weakenkey, key, 1);
784 rc4_init(rc4, key, keylen);
785}
786
786 rc4_init(rc4, key, keylen);
787}
788