Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
arc4.h
00001 /** 00002 * \file arc4.h 00003 * 00004 * \brief The ARCFOUR stream cipher 00005 * 00006 * \warning ARC4 is considered a weak cipher and its use constitutes a 00007 * security risk. We recommend considering stronger ciphers instead. 00008 */ 00009 /* 00010 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved 00011 * SPDX-License-Identifier: Apache-2.0 00012 * 00013 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00014 * not use this file except in compliance with the License. 00015 * You may obtain a copy of the License at 00016 * 00017 * http://www.apache.org/licenses/LICENSE-2.0 00018 * 00019 * Unless required by applicable law or agreed to in writing, software 00020 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00021 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00022 * See the License for the specific language governing permissions and 00023 * limitations under the License. 00024 * 00025 * This file is part of mbed TLS (https://tls.mbed.org) 00026 * 00027 */ 00028 #ifndef MBEDTLS_ARC4_H 00029 #define MBEDTLS_ARC4_H 00030 00031 #if !defined(MBEDTLS_CONFIG_FILE) 00032 #include "config.h" 00033 #else 00034 #include MBEDTLS_CONFIG_FILE 00035 #endif 00036 00037 #include <stddef.h> 00038 00039 #define MBEDTLS_ERR_ARC4_HW_ACCEL_FAILED -0x0019 /**< ARC4 hardware accelerator failed. */ 00040 00041 #ifdef __cplusplus 00042 extern "C" { 00043 #endif 00044 00045 #if !defined(MBEDTLS_ARC4_ALT) 00046 // Regular implementation 00047 // 00048 00049 /** 00050 * \brief ARC4 context structure 00051 * 00052 * \warning ARC4 is considered a weak cipher and its use constitutes a 00053 * security risk. We recommend considering stronger ciphers instead. 00054 * 00055 */ 00056 typedef struct mbedtls_arc4_context 00057 { 00058 int x ; /*!< permutation index */ 00059 int y ; /*!< permutation index */ 00060 unsigned char m [256]; /*!< permutation table */ 00061 } 00062 mbedtls_arc4_context; 00063 00064 #else /* MBEDTLS_ARC4_ALT */ 00065 #include "arc4_alt.h" 00066 #endif /* MBEDTLS_ARC4_ALT */ 00067 00068 /** 00069 * \brief Initialize ARC4 context 00070 * 00071 * \param ctx ARC4 context to be initialized 00072 * 00073 * \warning ARC4 is considered a weak cipher and its use constitutes a 00074 * security risk. We recommend considering stronger ciphers 00075 * instead. 00076 * 00077 */ 00078 void mbedtls_arc4_init( mbedtls_arc4_context *ctx ); 00079 00080 /** 00081 * \brief Clear ARC4 context 00082 * 00083 * \param ctx ARC4 context to be cleared 00084 * 00085 * \warning ARC4 is considered a weak cipher and its use constitutes a 00086 * security risk. We recommend considering stronger ciphers 00087 * instead. 00088 * 00089 */ 00090 void mbedtls_arc4_free( mbedtls_arc4_context *ctx ); 00091 00092 /** 00093 * \brief ARC4 key schedule 00094 * 00095 * \param ctx ARC4 context to be setup 00096 * \param key the secret key 00097 * \param keylen length of the key, in bytes 00098 * 00099 * \warning ARC4 is considered a weak cipher and its use constitutes a 00100 * security risk. We recommend considering stronger ciphers 00101 * instead. 00102 * 00103 */ 00104 void mbedtls_arc4_setup( mbedtls_arc4_context *ctx, const unsigned char *key, 00105 unsigned int keylen ); 00106 00107 /** 00108 * \brief ARC4 cipher function 00109 * 00110 * \param ctx ARC4 context 00111 * \param length length of the input data 00112 * \param input buffer holding the input data 00113 * \param output buffer for the output data 00114 * 00115 * \return 0 if successful 00116 * 00117 * \warning ARC4 is considered a weak cipher and its use constitutes a 00118 * security risk. We recommend considering stronger ciphers 00119 * instead. 00120 * 00121 */ 00122 int mbedtls_arc4_crypt( mbedtls_arc4_context *ctx, size_t length, const unsigned char *input, 00123 unsigned char *output ); 00124 00125 /** 00126 * \brief Checkup routine 00127 * 00128 * \return 0 if successful, or 1 if the test failed 00129 * 00130 * \warning ARC4 is considered a weak cipher and its use constitutes a 00131 * security risk. We recommend considering stronger ciphers 00132 * instead. 00133 * 00134 */ 00135 int mbedtls_arc4_self_test( int verbose ); 00136 00137 #ifdef __cplusplus 00138 } 00139 #endif 00140 00141 #endif /* arc4.h */
Generated on Tue Jul 12 2022 13:52:56 by
