Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers pppcrypt.h Source File

pppcrypt.h

00001 /*
00002  * pppcrypt.c - PPP/DES linkage for MS-CHAP and EAP SRP-SHA1
00003  *
00004  * Extracted from chap_ms.c by James Carlson.
00005  *
00006  * Copyright (c) 1995 Eric Rosenquist.  All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions
00010  * are met:
00011  *
00012  * 1. Redistributions of source code must retain the above copyright
00013  *    notice, this list of conditions and the following disclaimer.
00014  *
00015  * 2. Redistributions in binary form must reproduce the above copyright
00016  *    notice, this list of conditions and the following disclaimer in
00017  *    the documentation and/or other materials provided with the
00018  *    distribution.
00019  *
00020  * 3. The name(s) of the authors of this software must not be used to
00021  *    endorse or promote products derived from this software without
00022  *    prior written permission.
00023  *
00024  * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
00025  * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
00026  * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
00027  * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
00028  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
00029  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
00030  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00031  */
00032 
00033 #include "ppp_opts.h"
00034 #if PPP_SUPPORT /* don't build if not configured for use in ppp_opts.h */
00035 
00036 /* This header file is included in all PPP modules needing hashes and/or ciphers */
00037 
00038 #ifndef PPPCRYPT_H
00039 #define PPPCRYPT_H
00040 
00041 #ifdef __cplusplus
00042 extern "C" {
00043 #endif
00044 
00045 /*
00046  * Map hashes and ciphers functions to PolarSSL
00047  */
00048 #if !PPP_USE_EXTERNAL_MBEDTLS
00049 
00050 #include "polarssl/md4.h"
00051 #define MD4_context md4_context
00052 #define MD4_init(context)
00053 #define MD4_starts md4_starts
00054 #define MD4_update md4_update
00055 #define MD4_finish md4_finish
00056 #define MD4_free(context)
00057 
00058 #include "polarssl/md5.h"
00059 #define MD5_context md5_context
00060 #define MD5_init(context)
00061 #define MD5_starts md5_starts
00062 #define MD5_update md5_update
00063 #define MD5_finish md5_finish
00064 #define MD5_free(context)
00065 
00066 #include "polarssl/sha1.h"
00067 #define SHA1_context sha1_context
00068 #define SHA1_init(context)
00069 #define SHA1_starts sha1_starts
00070 #define SHA1_update sha1_update
00071 #define SHA1_finish sha1_finish
00072 #define SHA1_free(context)
00073 
00074 #include "polarssl/des.h"
00075 #define Des_context des_context
00076 #define Des_init(context)
00077 #define Des_setkey_enc des_setkey_enc
00078 #define Des_crypt_ecb des_crypt_ecb
00079 #define Des_free(context)
00080 
00081 #include "polarssl/arc4.h"
00082 #define ARC4_context arc4_context
00083 #define ARC4_init(context)
00084 #define ARC4_setup arc4_setup
00085 #define ARC4_crypt arc4_crypt
00086 #define ARC4_free(context)
00087 
00088 #endif /* !PPP_USE_EXTERNAL_MBEDTLS */
00089 
00090 /*
00091  * Map hashes and ciphers functions to mbed TLS
00092  */
00093 #if PPP_USE_EXTERNAL_MBEDTLS
00094 
00095 #include "mbedtls/md5.h"
00096 
00097 #define MD4_context mbedtls_md4_context
00098 #define MD4_init mbedtls_md4_init
00099 #define MD4_starts mbedtls_md4_starts
00100 #define MD4_update mbedtls_md4_update
00101 #define MD4_finish mbedtls_md4_finish
00102 #define MD4_free mbedtls_md4_free
00103 
00104 #define MD5_context mbedtls_md5_context
00105 #define MD5_init mbedtls_md5_init
00106 #define MD5_starts mbedtls_md5_starts
00107 #define MD5_update mbedtls_md5_update
00108 #define MD5_finish mbedtls_md5_finish
00109 #define MD5_free mbedtls_md5_free
00110 
00111 #define SHA1_context mbedtls_sha1_context
00112 #define SHA1_init mbedtls_sha1_init
00113 #define SHA1_starts mbedtls_sha1_starts
00114 #define SHA1_update mbedtls_sha1_update
00115 #define SHA1_finish mbedtls_sha1_finish
00116 #define SHA1_free mbedtls_sha1_free
00117 
00118 #define Des_context mbedtls_des_context
00119 #define Des_init mbedtls_des_init
00120 #define Des_setkey_enc mbedtls_des_setkey_enc
00121 #define Des_crypt_ecb mbedtls_des_crypt_ecb
00122 #define Des_free mbedtls_des_free
00123 
00124 #define ARC4_context mbedtls_arc4_context
00125 #define ARC4_init mbedtls_arc4_init
00126 #define ARC4_setup mbedtls_arc4_setup
00127 #define ARC4_crypt(context, buffer, length) mbedtls_arc4_crypt(context, length, buffer, buffer)
00128 #define ARC4_free mbedtls_arc4_free
00129 
00130 #endif /* PPP_USE_EXTERNAL_MBEDTLS */
00131 
00132 void pppcrypt_56_to_64_bit_key(u_char *key, u_char *des_key);
00133 
00134 #ifdef __cplusplus
00135 }
00136 #endif
00137 
00138 #endif /* PPPCRYPT_H */
00139 
00140 #endif /* PPP_SUPPORT */