• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

external/ppp


Commit MetaInfo

Revisionbbbb1872c15fb497a20f13f75f320653e5d67248 (tree)
Time2009-04-30 04:09:52
AuthorChung-yih Wang <cywang@goog...>
CommiterThe Android Open Source Project

Log Message

am e7f221f: This change is for enabling the pppd for vpn authentication

Merge commit 'e7f221f12403dcb4081d08e28c54d3b2a1ab05ee'

* commit 'e7f221f12403dcb4081d08e28c54d3b2a1ab05ee':

This change is for enabling the pppd for vpn authentication and setup.

Change Summary

Incremental Difference

--- a/pppd/Android.mk
+++ b/pppd/Android.mk
@@ -11,28 +11,28 @@ LOCAL_SRC_FILES:= \
1111 ipcp.c \
1212 upap.c \
1313 chap-new.c \
14- md5.c \
1514 ccp.c \
1615 ecp.c \
1716 ipxcp.c \
1817 auth.c \
1918 options.c \
2019 sys-linux.c \
21- md4.c \
2220 chap_ms.c \
2321 demand.c \
2422 utils.c \
2523 tty.c \
2624 eap.c \
27- chap-md5.c
25+ chap-md5.c \
26+ pppcrypt.c \
27+ openssl-hash.c
2828
2929 LOCAL_SHARED_LIBRARIES := \
30- libcutils
30+ libcutils libcrypto libssl
3131
3232 LOCAL_C_INCLUDES := \
3333 $(LOCAL_PATH)/include
3434
35-LOCAL_CFLAGS := -DANDROID_CHANGES
35+LOCAL_CFLAGS := -DANDROID_CHANGES -DCHAPMS=1 -Iexternal/openssl/include
3636
3737 LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
3838 LOCAL_MODULE_TAGS := eng
--- a/pppd/chap-new.c
+++ b/pppd/chap-new.c
@@ -35,6 +35,9 @@
3535 #include "pppd.h"
3636 #include "chap-new.h"
3737 #include "chap-md5.h"
38+#ifdef ANDROID_CHANGES
39+#include "openssl-hash.h"
40+#endif
3841
3942 #ifdef CHAPMS
4043 #include "chap_ms.h"
@@ -141,6 +144,9 @@ chap_init(int unit)
141144 memset(&client, 0, sizeof(client));
142145 memset(&server, 0, sizeof(server));
143146
147+#ifdef ANDROID_CHANGES
148+ openssl_hash_init();
149+#endif
144150 chap_md5_init();
145151 #ifdef CHAPMS
146152 chapms_init();
--- a/pppd/chap_ms.c
+++ b/pppd/chap_ms.c
@@ -89,8 +89,12 @@
8989 #include "pppd.h"
9090 #include "chap-new.h"
9191 #include "chap_ms.h"
92+#ifdef ANDROID_CHANGES
93+#include "openssl-hash.h"
94+#else
9295 #include "md4.h"
9396 #include "sha1.h"
97+#endif
9498 #include "pppcrypt.h"
9599 #include "magic.h"
96100
@@ -514,12 +518,17 @@ ascii2unicode(char ascii[], int ascii_len, u_char unicode[])
514518 static void
515519 NTPasswordHash(char *secret, int secret_len, u_char hash[MD4_SIGNATURE_SIZE])
516520 {
521+#ifdef ANDROID_CHANGES
522+ /* We link with MD4 routines in openssl, we have to take bytes instead */
523+ int mdlen = secret_len;
524+#else
517525 #ifdef __NetBSD__
518526 /* NetBSD uses the libc md4 routines which take bytes instead of bits */
519527 int mdlen = secret_len;
520528 #else
521529 int mdlen = secret_len * 8;
522530 #endif
531+#endif
523532 MD4_CTX md4Context;
524533
525534 MD4Init(&md4Context);
--- a/pppd/ipcp.c
+++ b/pppd/ipcp.c
@@ -55,6 +55,9 @@
5555 #include <sys/socket.h>
5656 #include <netinet/in.h>
5757 #include <arpa/inet.h>
58+#ifdef ANDROID_CHANGES
59+#include <paths.h>
60+#endif
5861
5962 #include "pppd.h"
6063 #include "fsm.h"
@@ -1712,6 +1715,9 @@ ipcp_up(f)
17121715 }
17131716 script_setenv("IPLOCAL", ip_ntoa(go->ouraddr), 0);
17141717 script_setenv("IPREMOTE", ip_ntoa(ho->hisaddr), 1);
1718+#ifdef ANDROID_CHANGES
1719+ script_setenv("PATH","/sbin:/system/sbin:/system/bin:/system/xbin", 0);
1720+#endif
17151721
17161722 if (go->dnsaddr[0])
17171723 script_setenv("DNS1", ip_ntoa(go->dnsaddr[0]), 0);
@@ -1978,6 +1984,13 @@ ipcp_script(script)
19781984 slprintf(strlocal, sizeof(strlocal), "%I", ipcp_gotoptions[0].ouraddr);
19791985 slprintf(strremote, sizeof(strremote), "%I", ipcp_hisoptions[0].hisaddr);
19801986
1987+#ifdef ANDROID_CHANGES
1988+ argv[0] = "sh";
1989+ argv[1] = "-c";
1990+ argv[2] = script;
1991+ argv[3] = NULL;
1992+ ipcp_script_pid = run_program(_PATH_BSHELL, argv, 0, ipcp_script_done, NULL);
1993+#else
19811994 argv[0] = script;
19821995 argv[1] = ifname;
19831996 argv[2] = devnam;
@@ -1987,6 +2000,7 @@ ipcp_script(script)
19872000 argv[6] = ipparam;
19882001 argv[7] = NULL;
19892002 ipcp_script_pid = run_program(script, argv, 0, ipcp_script_done, NULL);
2003+#endif
19902004 }
19912005
19922006 /*
--- /dev/null
+++ b/pppd/openssl-hash.c
@@ -0,0 +1,41 @@
1+/*
2+ * Copyright (C) 2009 The Android Open Source Project
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+#include <openssl/evp.h>
18+
19+const EVP_MD *sha1_md;
20+const EVP_MD *md4_md;
21+const EVP_MD *md5_md;
22+
23+void openssl_hash_init() {
24+ /* Use the SHA1 functions in openssl to save the flash space.*/
25+ OpenSSL_add_all_digests();
26+ sha1_md = EVP_get_digestbyname("sha1");
27+ if (!sha1_md) {
28+ dbglog("Error Unknown message digest SHA1\n");
29+ exit(1);
30+ }
31+ md4_md = EVP_get_digestbyname("md4");
32+ if (!md4_md) {
33+ dbglog("Error Unknown message digest MD4\n");
34+ exit(1);
35+ }
36+ md5_md = EVP_get_digestbyname("md5");
37+ if (!md5_md) {
38+ dbglog("Error Unknown message digest MD5\n");
39+ exit(1);
40+ }
41+}
--- /dev/null
+++ b/pppd/openssl-hash.h
@@ -0,0 +1,55 @@
1+/*
2+ * Copyright (C) 2009 The Android Open Source Project
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+#ifndef __OPENSSL_HASH__
18+#define __OPENSSL_HASH__
19+
20+#include <openssl/evp.h>
21+
22+extern const EVP_MD *sha1_md;
23+#define SHA1_SIGNATURE_SIZE 20
24+#define SHA1_CTX EVP_MD_CTX
25+#define SHA1_Init(ctx) { \
26+ EVP_MD_CTX_init(ctx); \
27+ EVP_DigestInit_ex(ctx, sha1_md, NULL); \
28+}
29+#define SHA1_Update EVP_DigestUpdate
30+#define SHA1_Final(digest, ctx) { \
31+ int md_len; \
32+ EVP_DigestFinal_ex(ctx, digest, &md_len); \
33+}
34+
35+extern const EVP_MD *md4_md;
36+#define MD4_CTX EVP_MD_CTX
37+#define MD4Init(ctx) { \
38+ EVP_MD_CTX_init(ctx); \
39+ EVP_DigestInit_ex(ctx, md4_md, NULL); \
40+}
41+#define MD4Update EVP_DigestUpdate
42+#define MD4Final SHA1_Final
43+
44+extern const EVP_MD *md5_md;
45+#define MD5_CTX EVP_MD_CTX
46+#define MD5_Init(ctx) { \
47+ EVP_MD_CTX_init(ctx); \
48+ EVP_DigestInit_ex(ctx, md5_md, NULL); \
49+}
50+#define MD5_Update EVP_DigestUpdate
51+#define MD5_Final SHA1_Final
52+
53+extern void openssl_hash_init();
54+
55+#endif
--- a/pppd/pppcrypt.c
+++ b/pppd/pppcrypt.c
@@ -171,7 +171,7 @@ u_char *key;
171171 }
172172
173173 bool
174-DesEncrypt(clear, key, cipher)
174+DesEncrypt(clear, cipher)
175175 u_char *clear; /* IN 8 octets */
176176 u_char *cipher; /* OUT 8 octets */
177177 {
--- a/pppd/pppcrypt.h
+++ b/pppd/pppcrypt.h
@@ -38,8 +38,12 @@
3838 #endif
3939
4040 #ifndef USE_CRYPT
41+#ifdef ANDROID_CHANGES
42+#include <openssl/des.h>
43+#else
4144 #include <des.h>
4245 #endif
46+#endif
4347
4448 extern bool DesSetkey __P((u_char *));
4549 extern bool DesEncrypt __P((u_char *, u_char *));