ConOpSys V2970  P004.07
ANVILEX control operating system
pppcrypt.h
Go to the documentation of this file.
1 /*
2  * pppcrypt.c - PPP/DES linkage for MS-CHAP and EAP SRP-SHA1
3  *
4  * Extracted from chap_ms.c by James Carlson.
5  *
6  * Copyright (c) 1995 Eric Rosenquist. All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The name(s) of the authors of this software must not be used to
21  * endorse or promote products derived from this software without
22  * prior written permission.
23  *
24  * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
25  * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
26  * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
27  * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
28  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
29  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
30  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
31  */
32 
33 #include "netif/ppp/ppp_opts.h"
34 #if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
35 
36 /* This header file is included in all PPP modules needing hashes and/or ciphers */
37 
38 #ifndef PPPCRYPT_H
39 #define PPPCRYPT_H
40 
41 /*
42  * If included PolarSSL copy is not used, user is expected to include
43  * external libraries in arch/cc.h (which is included by lwip/arch.h).
44  */
45 #include "lwip/arch.h"
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
51 /*
52  * Map hashes and ciphers functions to PolarSSL
53  */
54 #if !LWIP_USE_EXTERNAL_MBEDTLS
55 
56 #include "netif/ppp/polarssl/md4.h"
57 #define lwip_md4_context md4_context
58 #define lwip_md4_init(context)
59 #define lwip_md4_starts md4_starts
60 #define lwip_md4_update md4_update
61 #define lwip_md4_finish md4_finish
62 #define lwip_md4_free(context)
63 
64 #include "netif/ppp/polarssl/md5.h"
65 #define lwip_md5_context md5_context
66 #define lwip_md5_init(context)
67 #define lwip_md5_starts md5_starts
68 #define lwip_md5_update md5_update
69 #define lwip_md5_finish md5_finish
70 #define lwip_md5_free(context)
71 
72 #include "netif/ppp/polarssl/sha1.h"
73 #define lwip_sha1_context sha1_context
74 #define lwip_sha1_init(context)
75 #define lwip_sha1_starts sha1_starts
76 #define lwip_sha1_update sha1_update
77 #define lwip_sha1_finish sha1_finish
78 #define lwip_sha1_free(context)
79 
80 #include "netif/ppp/polarssl/des.h"
81 #define lwip_des_context des_context
82 #define lwip_des_init(context)
83 #define lwip_des_setkey_enc des_setkey_enc
84 #define lwip_des_crypt_ecb des_crypt_ecb
85 #define lwip_des_free(context)
86 
87 #include "netif/ppp/polarssl/arc4.h"
88 #define lwip_arc4_context arc4_context
89 #define lwip_arc4_init(context)
90 #define lwip_arc4_setup arc4_setup
91 #define lwip_arc4_crypt arc4_crypt
92 #define lwip_arc4_free(context)
93 
94 #endif /* !LWIP_USE_EXTERNAL_MBEDTLS */
95 
96 /*
97  * Map hashes and ciphers functions to mbed TLS
98  */
99 #if LWIP_USE_EXTERNAL_MBEDTLS
100 
101 #define lwip_md4_context mbedtls_md4_context
102 #define lwip_md4_init mbedtls_md4_init
103 #define lwip_md4_starts mbedtls_md4_starts
104 #define lwip_md4_update mbedtls_md4_update
105 #define lwip_md4_finish mbedtls_md4_finish
106 #define lwip_md4_free mbedtls_md4_free
107 
108 #define lwip_md5_context mbedtls_md5_context
109 #define lwip_md5_init mbedtls_md5_init
110 #define lwip_md5_starts mbedtls_md5_starts
111 #define lwip_md5_update mbedtls_md5_update
112 #define lwip_md5_finish mbedtls_md5_finish
113 #define lwip_md5_free mbedtls_md5_free
114 
115 #define lwip_sha1_context mbedtls_sha1_context
116 #define lwip_sha1_init mbedtls_sha1_init
117 #define lwip_sha1_starts mbedtls_sha1_starts
118 #define lwip_sha1_update mbedtls_sha1_update
119 #define lwip_sha1_finish mbedtls_sha1_finish
120 #define lwip_sha1_free mbedtls_sha1_free
121 
122 #define lwip_des_context mbedtls_des_context
123 #define lwip_des_init mbedtls_des_init
124 #define lwip_des_setkey_enc mbedtls_des_setkey_enc
125 #define lwip_des_crypt_ecb mbedtls_des_crypt_ecb
126 #define lwip_des_free mbedtls_des_free
127 
128 #define lwip_arc4_context mbedtls_arc4_context
129 #define lwip_arc4_init mbedtls_arc4_init
130 #define lwip_arc4_setup mbedtls_arc4_setup
131 #define lwip_arc4_crypt(context, buffer, length) mbedtls_arc4_crypt(context, length, buffer, buffer)
132 #define lwip_arc4_free mbedtls_arc4_free
133 
134 #endif /* LWIP_USE_EXTERNAL_MBEDTLS */
135 
136 void pppcrypt_56_to_64_bit_key(u_char *key, u_char *des_key);
137 
138 #ifdef __cplusplus
139 }
140 #endif
141 
142 #endif /* PPPCRYPT_H */
143 
144 #endif /* PPP_SUPPORT */