PPP: add a function map for hashes and ciphers to prepare for mbed TLS support

Unfortunately, all functions were renamed when PolarSSL was renamed to
mbed TLS, breaking the API. In order to continue supporting our embedded
PolarSSL copy while allowing our users to use mbed TLS, we need a function
map to deal with the API break.

This commit add a function map for all hashes and ciphers we are currently
using.
This commit is contained in:
Sylvain Rochet
2016-05-08 19:26:08 +02:00
parent 1dcd5d31d7
commit 3417a02b25
9 changed files with 163 additions and 180 deletions

View File

@@ -39,11 +39,7 @@
#ifndef MPPE_H
#define MPPE_H
#if LWIP_INCLUDED_POLARSSL_ARC4
#include "netif/ppp/polarssl/arc4.h"
#else
#include "polarssl/arc4.h"
#endif
#include "netif/ppp/pppcrypt.h"
#define MPPE_PAD 4 /* MPPE growth per frame */
#define MPPE_MAX_KEY_LEN 16 /* largest key length (128-bit) */
@@ -152,7 +148,7 @@ static const u8_t mppe_sha1_pad2[SHA1_PAD_SIZE] = {
* State for an MPPE (de)compressor.
*/
typedef struct ppp_mppe_state {
arc4_context arc4;
lwip_arc4_context arc4;
u8_t master_key[MPPE_MAX_KEY_LEN];
u8_t session_key[MPPE_MAX_KEY_LEN];
u8_t keylen; /* key length in bytes */

View File

@@ -331,6 +331,7 @@
* LWIP_INCLUDED_POLARSSL_MD5 ; Use lwIP internal PolarSSL for MD5
* LWIP_INCLUDED_POLARSSL_SHA1 ; Use lwIP internal PolarSSL for SHA1
* LWIP_INCLUDED_POLARSSL_DES ; Use lwIP internal PolarSSL for DES
* LWIP_INCLUDED_POLARSSL_ARC4 ; Use lwIP internal PolarSSL for ARC4
*
* If set (=1), the default if required by another enabled PPP feature unless
* explicitly set to 0, using included lwIP PolarSSL.
@@ -344,7 +345,7 @@
/* CHAP, EAP, L2TP AUTH and MD5 Random require MD5 support */
#if CHAP_SUPPORT || EAP_SUPPORT || PPPOL2TP_AUTH_SUPPORT || PPP_MD5_RANDM
#ifndef LWIP_INCLUDED_POLARSSL_MD5
#define LWIP_INCLUDED_POLARSSL_MD5 1
#define LWIP_INCLUDED_POLARSSL_MD5 1
#endif /* LWIP_INCLUDED_POLARSSL_MD5 */
#endif /* CHAP_SUPPORT || EAP_SUPPORT || PPPOL2TP_AUTH_SUPPORT || PPP_MD5_RANDM */

View File

@@ -33,9 +33,48 @@
#include "netif/ppp/ppp_opts.h"
#if PPP_SUPPORT && MSCHAP_SUPPORT /* don't build if not configured for use in lwipopts.h */
/* This header file is included in all PPP modules needing hashes and/or ciphers */
#ifndef PPPCRYPT_H
#define PPPCRYPT_H
/*
* If included PolarSSL copy is not used, user is expected to include
* external libraries in arch/cc.h (which is included by lwip/arch.h).
*/
#include "lwip/arch.h"
/*
* Map hashes and ciphers functions to PolarSSL
*/
#include "netif/ppp/polarssl/md4.h"
#define lwip_md4_context md4_context
#define lwip_md4_starts md4_starts
#define lwip_md4_update md4_update
#define lwip_md4_finish md4_finish
#include "netif/ppp/polarssl/md5.h"
#define lwip_md5_context md5_context
#define lwip_md5_starts md5_starts
#define lwip_md5_update md5_update
#define lwip_md5_finish md5_finish
#include "netif/ppp/polarssl/sha1.h"
#define lwip_sha1_context sha1_context
#define lwip_sha1_starts sha1_starts
#define lwip_sha1_update sha1_update
#define lwip_sha1_finish sha1_finish
#include "netif/ppp/polarssl/des.h"
#define lwip_des_context des_context
#define lwip_des_setkey_enc des_setkey_enc
#define lwip_des_crypt_ecb des_crypt_ecb
#include "netif/ppp/polarssl/arc4.h"
#define lwip_arc4_context arc4_context
#define lwip_arc4_setup arc4_setup
#define lwip_arc4_crypt arc4_crypt
void pppcrypt_56_to_64_bit_key(u_char *key, u_char *des_key);
#endif /* PPPCRYPT_H */