summaryrefslogtreecommitdiff
path: root/net/ppp-mppe/patches/patch-bu
blob: 4a245bd09045a1e7214399a064a077a614bb3980 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
$NetBSD: patch-bu,v 1.1.1.1 1999/10/08 04:34:43 dbj Exp $

--- /dev/null	Sat Sep 25 16:45:44 1999
+++ netbsd-1.4/getkey.c	Sat Sep 25 17:06:23 1999
@@ -0,0 +1,51 @@
+/*
+ * Microsoft's Get_Key() per mppe draft by mag <mag@bunuel.tii.matav.hu>
+ */
+#include <sys/param.h>
+#include <sys/systm.h>
+#include "sha.h"
+
+   /*
+    * Pads used in key derivation
+    */
+static unsigned char  SHAPad1[40] =
+        {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+static unsigned char  SHAPad2[40] =
+        {0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2,
+         0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2,
+         0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2,
+         0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2};
+
+   /*
+    * SHAInit(), SHAUpdate() and SHAFinal() functions are an
+    * implementation of Secure Hash Algorithm (SHA-1) [7]. These are
+    * available in public domain or can be licensed from
+    * RSA Data Security, Inc.
+    *
+    * 1) H is 8 bytes long for 40 bit session keys.
+    * 2) H is 16 bytes long for 128 bit session keys.
+    * 3) H' is same as H when this routine is called for the first time
+    *    for the session.
+    * 4) The generated key is returned in H'. This is the "current" key.
+    */
+void
+GetNewKeyFromSHA(StartKey, SessionKey, SessionKeyLength, InterimKey)
+    unsigned char *StartKey;
+    unsigned char *SessionKey;
+    unsigned long SessionKeyLength;
+    unsigned char *InterimKey;
+{
+    SHA_CTX Context;
+    unsigned char Digest[SHA_DIGEST_LENGTH];
+
+    SHA1_Init(&Context);
+    SHA1_Update(&Context, StartKey, SessionKeyLength);
+    SHA1_Update(&Context, SHAPad1, 40);
+    SHA1_Update(&Context, SessionKey, SessionKeyLength);
+    SHA1_Update(&Context, SHAPad2, 40);
+    SHA1_Final(Digest,&Context);
+    memcpy(InterimKey, Digest, SessionKeyLength);
+}