external/ppp
Revision | bbbb1872c15fb497a20f13f75f320653e5d67248 (tree) |
---|---|
Time | 2009-04-30 04:09:52 |
Author | Chung-yih Wang <cywang@goog...> |
Commiter | The Android Open Source Project |
am e7f221f: This change is for enabling the pppd for vpn authentication
Merge commit 'e7f221f12403dcb4081d08e28c54d3b2a1ab05ee'
* commit 'e7f221f12403dcb4081d08e28c54d3b2a1ab05ee':
@@ -11,28 +11,28 @@ LOCAL_SRC_FILES:= \ | ||
11 | 11 | ipcp.c \ |
12 | 12 | upap.c \ |
13 | 13 | chap-new.c \ |
14 | - md5.c \ | |
15 | 14 | ccp.c \ |
16 | 15 | ecp.c \ |
17 | 16 | ipxcp.c \ |
18 | 17 | auth.c \ |
19 | 18 | options.c \ |
20 | 19 | sys-linux.c \ |
21 | - md4.c \ | |
22 | 20 | chap_ms.c \ |
23 | 21 | demand.c \ |
24 | 22 | utils.c \ |
25 | 23 | tty.c \ |
26 | 24 | eap.c \ |
27 | - chap-md5.c | |
25 | + chap-md5.c \ | |
26 | + pppcrypt.c \ | |
27 | + openssl-hash.c | |
28 | 28 | |
29 | 29 | LOCAL_SHARED_LIBRARIES := \ |
30 | - libcutils | |
30 | + libcutils libcrypto libssl | |
31 | 31 | |
32 | 32 | LOCAL_C_INCLUDES := \ |
33 | 33 | $(LOCAL_PATH)/include |
34 | 34 | |
35 | -LOCAL_CFLAGS := -DANDROID_CHANGES | |
35 | +LOCAL_CFLAGS := -DANDROID_CHANGES -DCHAPMS=1 -Iexternal/openssl/include | |
36 | 36 | |
37 | 37 | LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) |
38 | 38 | LOCAL_MODULE_TAGS := eng |
@@ -35,6 +35,9 @@ | ||
35 | 35 | #include "pppd.h" |
36 | 36 | #include "chap-new.h" |
37 | 37 | #include "chap-md5.h" |
38 | +#ifdef ANDROID_CHANGES | |
39 | +#include "openssl-hash.h" | |
40 | +#endif | |
38 | 41 | |
39 | 42 | #ifdef CHAPMS |
40 | 43 | #include "chap_ms.h" |
@@ -141,6 +144,9 @@ chap_init(int unit) | ||
141 | 144 | memset(&client, 0, sizeof(client)); |
142 | 145 | memset(&server, 0, sizeof(server)); |
143 | 146 | |
147 | +#ifdef ANDROID_CHANGES | |
148 | + openssl_hash_init(); | |
149 | +#endif | |
144 | 150 | chap_md5_init(); |
145 | 151 | #ifdef CHAPMS |
146 | 152 | chapms_init(); |
@@ -89,8 +89,12 @@ | ||
89 | 89 | #include "pppd.h" |
90 | 90 | #include "chap-new.h" |
91 | 91 | #include "chap_ms.h" |
92 | +#ifdef ANDROID_CHANGES | |
93 | +#include "openssl-hash.h" | |
94 | +#else | |
92 | 95 | #include "md4.h" |
93 | 96 | #include "sha1.h" |
97 | +#endif | |
94 | 98 | #include "pppcrypt.h" |
95 | 99 | #include "magic.h" |
96 | 100 |
@@ -514,12 +518,17 @@ ascii2unicode(char ascii[], int ascii_len, u_char unicode[]) | ||
514 | 518 | static void |
515 | 519 | NTPasswordHash(char *secret, int secret_len, u_char hash[MD4_SIGNATURE_SIZE]) |
516 | 520 | { |
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 | |
517 | 525 | #ifdef __NetBSD__ |
518 | 526 | /* NetBSD uses the libc md4 routines which take bytes instead of bits */ |
519 | 527 | int mdlen = secret_len; |
520 | 528 | #else |
521 | 529 | int mdlen = secret_len * 8; |
522 | 530 | #endif |
531 | +#endif | |
523 | 532 | MD4_CTX md4Context; |
524 | 533 | |
525 | 534 | MD4Init(&md4Context); |
@@ -55,6 +55,9 @@ | ||
55 | 55 | #include <sys/socket.h> |
56 | 56 | #include <netinet/in.h> |
57 | 57 | #include <arpa/inet.h> |
58 | +#ifdef ANDROID_CHANGES | |
59 | +#include <paths.h> | |
60 | +#endif | |
58 | 61 | |
59 | 62 | #include "pppd.h" |
60 | 63 | #include "fsm.h" |
@@ -1712,6 +1715,9 @@ ipcp_up(f) | ||
1712 | 1715 | } |
1713 | 1716 | script_setenv("IPLOCAL", ip_ntoa(go->ouraddr), 0); |
1714 | 1717 | 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 | |
1715 | 1721 | |
1716 | 1722 | if (go->dnsaddr[0]) |
1717 | 1723 | script_setenv("DNS1", ip_ntoa(go->dnsaddr[0]), 0); |
@@ -1978,6 +1984,13 @@ ipcp_script(script) | ||
1978 | 1984 | slprintf(strlocal, sizeof(strlocal), "%I", ipcp_gotoptions[0].ouraddr); |
1979 | 1985 | slprintf(strremote, sizeof(strremote), "%I", ipcp_hisoptions[0].hisaddr); |
1980 | 1986 | |
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 | |
1981 | 1994 | argv[0] = script; |
1982 | 1995 | argv[1] = ifname; |
1983 | 1996 | argv[2] = devnam; |
@@ -1987,6 +2000,7 @@ ipcp_script(script) | ||
1987 | 2000 | argv[6] = ipparam; |
1988 | 2001 | argv[7] = NULL; |
1989 | 2002 | ipcp_script_pid = run_program(script, argv, 0, ipcp_script_done, NULL); |
2003 | +#endif | |
1990 | 2004 | } |
1991 | 2005 | |
1992 | 2006 | /* |
@@ -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 | +} |
@@ -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 |
@@ -171,7 +171,7 @@ u_char *key; | ||
171 | 171 | } |
172 | 172 | |
173 | 173 | bool |
174 | -DesEncrypt(clear, key, cipher) | |
174 | +DesEncrypt(clear, cipher) | |
175 | 175 | u_char *clear; /* IN 8 octets */ |
176 | 176 | u_char *cipher; /* OUT 8 octets */ |
177 | 177 | { |
@@ -38,8 +38,12 @@ | ||
38 | 38 | #endif |
39 | 39 | |
40 | 40 | #ifndef USE_CRYPT |
41 | +#ifdef ANDROID_CHANGES | |
42 | +#include <openssl/des.h> | |
43 | +#else | |
41 | 44 | #include <des.h> |
42 | 45 | #endif |
46 | +#endif | |
43 | 47 | |
44 | 48 | extern bool DesSetkey __P((u_char *)); |
45 | 49 | extern bool DesEncrypt __P((u_char *, u_char *)); |