Mbed OS Reference
Loading...
Searching...
No Matches
pppcrypt.h
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 "ppp_opts.h"
34#if PPP_SUPPORT /* don't build if not configured for use in ppp_opts.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#ifdef __cplusplus
42extern "C" {
43#endif
44
45/*
46 * Map hashes and ciphers functions to PolarSSL
47 */
48#if !PPP_USE_EXTERNAL_MBEDTLS
49
50#include "polarssl/md4.h"
51#define MD4_context md4_context
52#define MD4_init(context)
53#define MD4_starts md4_starts
54#define MD4_update md4_update
55#define MD4_finish md4_finish
56#define MD4_free(context)
57
58#include "polarssl/md5.h"
59#define MD5_context md5_context
60#define MD5_init(context)
61#define MD5_starts md5_starts
62#define MD5_update md5_update
63#define MD5_finish md5_finish
64#define MD5_free(context)
65
66#include "polarssl/sha1.h"
67#define SHA1_context sha1_context
68#define SHA1_init(context)
69#define SHA1_starts sha1_starts
70#define SHA1_update sha1_update
71#define SHA1_finish sha1_finish
72#define SHA1_free(context)
73
74#include "polarssl/des.h"
75#define Des_context des_context
76#define Des_init(context)
77#define Des_setkey_enc des_setkey_enc
78#define Des_crypt_ecb des_crypt_ecb
79#define Des_free(context)
80
81#include "polarssl/arc4.h"
82#define ARC4_context arc4_context
83#define ARC4_init(context)
84#define ARC4_setup arc4_setup
85#define ARC4_crypt arc4_crypt
86#define ARC4_free(context)
87
88#endif /* !PPP_USE_EXTERNAL_MBEDTLS */
89
90/*
91 * Map hashes and ciphers functions to mbed TLS
92 */
93#if PPP_USE_EXTERNAL_MBEDTLS
94
95#include "mbedtls/md5.h"
96
97#define MD4_context mbedtls_md4_context
98#define MD4_init mbedtls_md4_init
99#define MD4_starts mbedtls_md4_starts
100#define MD4_update mbedtls_md4_update
101#define MD4_finish mbedtls_md4_finish
102#define MD4_free mbedtls_md4_free
103
104#define MD5_context mbedtls_md5_context
105#define MD5_init mbedtls_md5_init
106#define MD5_starts mbedtls_md5_starts
107#define MD5_update mbedtls_md5_update
108#define MD5_finish mbedtls_md5_finish
109#define MD5_free mbedtls_md5_free
110
111#define SHA1_context mbedtls_sha1_context
112#define SHA1_init mbedtls_sha1_init
113#define SHA1_starts mbedtls_sha1_starts
114#define SHA1_update mbedtls_sha1_update
115#define SHA1_finish mbedtls_sha1_finish
116#define SHA1_free mbedtls_sha1_free
117
118#define Des_context mbedtls_des_context
119#define Des_init mbedtls_des_init
120#define Des_setkey_enc mbedtls_des_setkey_enc
121#define Des_crypt_ecb mbedtls_des_crypt_ecb
122#define Des_free mbedtls_des_free
123
124#define ARC4_context mbedtls_arc4_context
125#define ARC4_init mbedtls_arc4_init
126#define ARC4_setup mbedtls_arc4_setup
127#define ARC4_crypt(context, buffer, length) mbedtls_arc4_crypt(context, length, buffer, buffer)
128#define ARC4_free mbedtls_arc4_free
129
130#endif /* PPP_USE_EXTERNAL_MBEDTLS */
131
132void pppcrypt_56_to_64_bit_key(u_char *key, u_char *des_key);
133
134#ifdef __cplusplus
135}
136#endif
137
138#endif /* PPPCRYPT_H */
139
140#endif /* PPP_SUPPORT */
MD5 message digest algorithm (hash function)