Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers arc4.h Source File

arc4.h

00001 /**
00002  * /@code
00003  *
00004  * \file arc4.h
00005  *
00006  *  Based on XySSL: Copyright (C) 2006-2008  Christophe Devine
00007  *
00008  *  Copyright (C) 2009  Paul Bakker <polarssl_maintainer at polarssl dot org>
00009  *
00010  *  All rights reserved.
00011  *
00012  *  Redistribution and use in source and binary forms, with or without
00013  *  modification, are permitted provided that the following conditions
00014  *  are met:
00015  *  
00016  *    * Redistributions of source code must retain the above copyright
00017  *      notice, this list of conditions and the following disclaimer.
00018  *    * Redistributions in binary form must reproduce the above copyright
00019  *      notice, this list of conditions and the following disclaimer in the
00020  *      documentation and/or other materials provided with the distribution.
00021  *    * Neither the names of PolarSSL or XySSL nor the names of its contributors
00022  *      may be used to endorse or promote products derived from this software
00023  *      without specific prior written permission.
00024  *  
00025  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00026  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00027  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00028  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00029  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00030  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
00031  *  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032  *  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033  *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034  *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035  *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036  *
00037  *  /@endcode
00038  */
00039 
00040 #include "ppp_opts.h"
00041 #if PPP_INCLUDED_POLARSSL_ARC4
00042 
00043 #ifndef PPP_INCLUDED_POLARSSL_ARC4_H
00044 #define PPP_INCLUDED_POLARSSL_ARC4_H
00045 
00046 /**
00047  * \brief          ARC4 context structure
00048  */
00049 typedef struct
00050 {
00051     int x ;                      /*!< permutation index */
00052     int y ;                      /*!< permutation index */
00053     unsigned char m[256];       /*!< permutation table */
00054 }
00055 arc4_context;
00056 
00057 #ifdef __cplusplus
00058 extern "C" {
00059 #endif
00060 
00061 /**
00062  * \brief          ARC4 key schedule
00063  *
00064  * \param ctx      ARC4 context to be initialized
00065  * \param key      the secret key
00066  * \param keylen   length of the key
00067  */
00068 void arc4_setup( arc4_context *ctx, unsigned char *key, int keylen );
00069 
00070 /**
00071  * \brief          ARC4 cipher function
00072  *
00073  * \param ctx      ARC4 context
00074  * \param buf      buffer to be processed
00075  * \param buflen   amount of data in buf
00076  */
00077 void arc4_crypt( arc4_context *ctx, unsigned char *buf, int buflen );
00078 
00079 #ifdef __cplusplus
00080 }
00081 #endif
00082 
00083 #endif /* PPP_INCLUDED_POLARSSL_ARC4_H */
00084 
00085 #endif /* PPP_INCLUDED_POLARSSL_ARC4 */