From 0bfe435c4ff600a8c026929300bacf1c6284ab4c Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Sat, 28 Mar 2015 23:58:59 +0100 Subject: [PATCH] PPP, MPPE, updated polarssl ARC4 for lwIP --- src/include/lwip/opt.h | 16 ++++++ src/include/netif/ppp/polarssl/arc4.h | 19 +++---- src/include/netif/ppp/ppp.h | 4 -- src/netif/ppp/polarssl/arc4.c | 80 ++------------------------- 4 files changed, 29 insertions(+), 90 deletions(-) diff --git a/src/include/lwip/opt.h b/src/include/lwip/opt.h index 2af84e4b..9bf53edd 100644 --- a/src/include/lwip/opt.h +++ b/src/include/lwip/opt.h @@ -2036,6 +2036,13 @@ #define CCP_SUPPORT 0 #endif +/** + * MPPE_SUPPORT==1: Support MPPE. CURRENTLY NOT SUPPORTED! DO NOT SET! + */ +#ifndef MPPE_SUPPORT +#define MPPE_SUPPORT 0 +#endif + /** * ECP_SUPPORT==1: Support ECP. CURRENTLY NOT SUPPORTED! DO NOT SET! */ @@ -2140,6 +2147,12 @@ #ifndef LWIP_INCLUDED_POLARSSL_DES #define LWIP_INCLUDED_POLARSSL_DES 1 /* MSCHAP require DES support */ #endif /* LWIP_INCLUDED_POLARSSL_DES */ +/* MS-CHAP support is required for MPPE */ +#if MPPE_SUPPORT +#ifndef LWIP_INCLUDED_POLARSSL_ARC4 +#define LWIP_INCLUDED_POLARSSL_ARC4 1 /* MPPE require ARC4 support */ +#endif /* LWIP_INCLUDED_POLARSSL_ARC4*/ +#endif /* MPPE_SUPPORT */ #endif /* MSCHAP_SUPPORT */ /* Default value if unset */ @@ -2155,6 +2168,9 @@ #ifndef LWIP_INCLUDED_POLARSSL_DES #define LWIP_INCLUDED_POLARSSL_DES 0 #endif /* LWIP_INCLUDED_POLARSSL_DES */ +#ifndef LWIP_INCLUDED_POLARSSL_ARC4 +#define LWIP_INCLUDED_POLARSSL_ARC4 0 +#endif /* LWIP_INCLUDED_POLARSSL_ARC4 */ /* * Timeouts diff --git a/src/include/netif/ppp/polarssl/arc4.h b/src/include/netif/ppp/polarssl/arc4.h index a8439cd1..95d9b34a 100644 --- a/src/include/netif/ppp/polarssl/arc4.h +++ b/src/include/netif/ppp/polarssl/arc4.h @@ -32,8 +32,12 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef POLARSSL_ARC4_H -#define POLARSSL_ARC4_H + +#include "lwip/opt.h" +#if LWIP_INCLUDED_POLARSSL_ARC4 + +#ifndef LWIP_INCLUDED_POLARSSL_ARC4_H +#define LWIP_INCLUDED_POLARSSL_ARC4_H /** * \brief ARC4 context structure @@ -68,15 +72,10 @@ void arc4_setup( arc4_context *ctx, unsigned char *key, int keylen ); */ void arc4_crypt( arc4_context *ctx, unsigned char *buf, int buflen ); -/* - * \brief Checkup routine - * - * \return 0 if successful, or 1 if the test failed - */ -int arc4_self_test( int verbose ); - #ifdef __cplusplus } #endif -#endif /* arc4.h */ +#endif /* LWIP_INCLUDED_POLARSSL_ARC4_H */ + +#endif /* LWIP_INCLUDED_POLARSSL_ARC4 */ diff --git a/src/include/netif/ppp/ppp.h b/src/include/netif/ppp/ppp.h index 2661034a..c08781ee 100644 --- a/src/include/netif/ppp/ppp.h +++ b/src/include/netif/ppp/ppp.h @@ -85,10 +85,6 @@ #define PPP_STATS_SUPPORT 0 #endif -#ifndef MPPE_SUPPORT -#define MPPE_SUPPORT 0 -#endif - /************************* *** PUBLIC DEFINITIONS *** diff --git a/src/netif/ppp/polarssl/arc4.c b/src/netif/ppp/polarssl/arc4.c index 140dc6bc..ca5000e7 100644 --- a/src/netif/ppp/polarssl/arc4.c +++ b/src/netif/ppp/polarssl/arc4.c @@ -38,12 +38,10 @@ * http://groups.google.com/group/sci.crypt/msg/10a300c9d21afca0 */ -#include "polarssl/config.h" - -#if defined(POLARSSL_ARC4_C) - -#include "polarssl/arc4.h" +#include "lwip/opt.h" +#if PPP_SUPPORT && LWIP_INCLUDED_POLARSSL_ARC4 +#include "netif/ppp/polarssl/arc4.h" /* * ARC4 key schedule */ @@ -100,74 +98,4 @@ void arc4_crypt( arc4_context *ctx, unsigned char *buf, int buflen ) ctx->y = y; } -#if defined(POLARSSL_SELF_TEST) - -#include -#include - -/* - * ARC4 tests vectors as posted by Eric Rescorla in sep. 1994: - * - * http://groups.google.com/group/comp.security.misc/msg/10a300c9d21afca0 - */ -static const unsigned char arc4_test_key[3][8] = -{ - { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF }, - { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } -}; - -static const unsigned char arc4_test_pt[3][8] = -{ - { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } -}; - -static const unsigned char arc4_test_ct[3][8] = -{ - { 0x75, 0xB7, 0x87, 0x80, 0x99, 0xE0, 0xC5, 0x96 }, - { 0x74, 0x94, 0xC2, 0xE7, 0x10, 0x4B, 0x08, 0x79 }, - { 0xDE, 0x18, 0x89, 0x41, 0xA3, 0x37, 0x5D, 0x3A } -}; - -/* - * Checkup routine - */ -int arc4_self_test( int verbose ) -{ - int i; - unsigned char buf[8]; - arc4_context ctx; - - for( i = 0; i < 3; i++ ) - { - if( verbose != 0 ) - printf( " ARC4 test #%d: ", i + 1 ); - - memcpy( buf, arc4_test_pt[i], 8 ); - - arc4_setup( &ctx, (unsigned char *) arc4_test_key[i], 8 ); - arc4_crypt( &ctx, buf, 8 ); - - if( memcmp( buf, arc4_test_ct[i], 8 ) != 0 ) - { - if( verbose != 0 ) - printf( "failed\n" ); - - return( 1 ); - } - - if( verbose != 0 ) - printf( "passed\n" ); - } - - if( verbose != 0 ) - printf( "\n" ); - - return( 0 ); -} - -#endif - -#endif +#endif /* PPP_SUPPORT && LWIP_INCLUDED_POLARSSL_DES */