2009-01-03 21:22:43 +00:00
|
|
|
/**
|
|
|
|
* \file arc4.h
|
2009-01-04 16:27:10 +00:00
|
|
|
*
|
2011-01-06 12:28:03 +00:00
|
|
|
* \brief The ARCFOUR stream cipher
|
2017-09-25 13:53:51 +00:00
|
|
|
*
|
|
|
|
* \warning ARC4 is considered a weak cipher and its use constitutes a
|
|
|
|
* security risk. We recommend considering stronger ciphers instead.
|
2018-01-05 15:33:17 +00:00
|
|
|
*/
|
|
|
|
/*
|
2020-08-07 11:07:28 +00:00
|
|
|
* Copyright The Mbed TLS Contributors
|
2015-09-04 12:21:07 +00:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2010-07-18 20:36:00 +00:00
|
|
|
*
|
2015-09-04 12:21:07 +00:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
* not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2010-07-18 20:36:00 +00:00
|
|
|
*
|
2015-09-04 12:21:07 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2009-01-04 16:27:10 +00:00
|
|
|
*
|
2015-09-04 12:21:07 +00:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2009-01-04 16:27:10 +00:00
|
|
|
*
|
2009-01-03 21:22:43 +00:00
|
|
|
*/
|
2015-04-08 10:49:31 +00:00
|
|
|
#ifndef MBEDTLS_ARC4_H
|
|
|
|
#define MBEDTLS_ARC4_H
|
2009-01-03 21:22:43 +00:00
|
|
|
|
2015-04-08 10:49:31 +00:00
|
|
|
#if !defined(MBEDTLS_CONFIG_FILE)
|
2019-07-04 19:01:14 +00:00
|
|
|
#include "mbedtls/config.h"
|
2014-04-29 10:39:06 +00:00
|
|
|
#else
|
2015-04-08 10:49:31 +00:00
|
|
|
#include MBEDTLS_CONFIG_FILE
|
2014-04-29 10:39:06 +00:00
|
|
|
#endif
|
2013-06-24 17:20:35 +00:00
|
|
|
|
2015-02-06 13:43:58 +00:00
|
|
|
#include <stddef.h>
|
2011-04-24 08:57:21 +00:00
|
|
|
|
2018-10-04 07:59:13 +00:00
|
|
|
/* MBEDTLS_ERR_ARC4_HW_ACCEL_FAILED is deprecated and should not be used. */
|
2018-01-26 16:56:38 +00:00
|
|
|
#define MBEDTLS_ERR_ARC4_HW_ACCEL_FAILED -0x0019 /**< ARC4 hardware accelerator failed. */
|
|
|
|
|
2013-06-27 12:29:21 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2017-05-18 13:53:08 +00:00
|
|
|
#if !defined(MBEDTLS_ARC4_ALT)
|
|
|
|
// Regular implementation
|
|
|
|
//
|
|
|
|
|
2009-01-03 21:22:43 +00:00
|
|
|
/**
|
2017-09-25 13:53:51 +00:00
|
|
|
* \brief ARC4 context structure
|
|
|
|
*
|
|
|
|
* \warning ARC4 is considered a weak cipher and its use constitutes a
|
|
|
|
* security risk. We recommend considering stronger ciphers instead.
|
|
|
|
*
|
2009-01-03 21:22:43 +00:00
|
|
|
*/
|
2018-07-24 08:02:47 +00:00
|
|
|
typedef struct mbedtls_arc4_context
|
2009-01-03 21:22:43 +00:00
|
|
|
{
|
|
|
|
int x; /*!< permutation index */
|
|
|
|
int y; /*!< permutation index */
|
|
|
|
unsigned char m[256]; /*!< permutation table */
|
|
|
|
}
|
2015-04-08 10:49:31 +00:00
|
|
|
mbedtls_arc4_context;
|
2009-01-03 21:22:43 +00:00
|
|
|
|
2017-05-18 13:53:08 +00:00
|
|
|
#else /* MBEDTLS_ARC4_ALT */
|
|
|
|
#include "arc4_alt.h"
|
|
|
|
#endif /* MBEDTLS_ARC4_ALT */
|
|
|
|
|
2009-01-03 21:22:43 +00:00
|
|
|
/**
|
2014-06-18 09:12:03 +00:00
|
|
|
* \brief Initialize ARC4 context
|
2009-01-03 21:22:43 +00:00
|
|
|
*
|
|
|
|
* \param ctx ARC4 context to be initialized
|
2017-09-25 13:53:51 +00:00
|
|
|
*
|
|
|
|
* \warning ARC4 is considered a weak cipher and its use constitutes a
|
|
|
|
* security risk. We recommend considering stronger ciphers
|
|
|
|
* instead.
|
|
|
|
*
|
2014-06-18 09:12:03 +00:00
|
|
|
*/
|
2015-04-08 10:49:31 +00:00
|
|
|
void mbedtls_arc4_init( mbedtls_arc4_context *ctx );
|
2014-06-18 09:12:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Clear ARC4 context
|
|
|
|
*
|
|
|
|
* \param ctx ARC4 context to be cleared
|
2017-09-25 13:53:51 +00:00
|
|
|
*
|
|
|
|
* \warning ARC4 is considered a weak cipher and its use constitutes a
|
|
|
|
* security risk. We recommend considering stronger ciphers
|
|
|
|
* instead.
|
|
|
|
*
|
2014-06-18 09:12:03 +00:00
|
|
|
*/
|
2015-04-08 10:49:31 +00:00
|
|
|
void mbedtls_arc4_free( mbedtls_arc4_context *ctx );
|
2014-06-18 09:12:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief ARC4 key schedule
|
|
|
|
*
|
|
|
|
* \param ctx ARC4 context to be setup
|
2009-01-03 21:22:43 +00:00
|
|
|
* \param key the secret key
|
2013-09-04 10:28:37 +00:00
|
|
|
* \param keylen length of the key, in bytes
|
2017-09-25 13:53:51 +00:00
|
|
|
*
|
|
|
|
* \warning ARC4 is considered a weak cipher and its use constitutes a
|
|
|
|
* security risk. We recommend considering stronger ciphers
|
|
|
|
* instead.
|
|
|
|
*
|
2009-01-03 21:22:43 +00:00
|
|
|
*/
|
2015-04-08 10:49:31 +00:00
|
|
|
void mbedtls_arc4_setup( mbedtls_arc4_context *ctx, const unsigned char *key,
|
2014-05-01 12:18:25 +00:00
|
|
|
unsigned int keylen );
|
2009-01-03 21:22:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief ARC4 cipher function
|
|
|
|
*
|
|
|
|
* \param ctx ARC4 context
|
2010-03-21 15:42:15 +00:00
|
|
|
* \param length length of the input data
|
|
|
|
* \param input buffer holding the input data
|
|
|
|
* \param output buffer for the output data
|
2010-03-18 21:21:02 +00:00
|
|
|
*
|
2010-03-21 15:43:59 +00:00
|
|
|
* \return 0 if successful
|
2017-09-25 13:53:51 +00:00
|
|
|
*
|
|
|
|
* \warning ARC4 is considered a weak cipher and its use constitutes a
|
|
|
|
* security risk. We recommend considering stronger ciphers
|
|
|
|
* instead.
|
|
|
|
*
|
2009-01-03 21:22:43 +00:00
|
|
|
*/
|
2015-04-08 10:49:31 +00:00
|
|
|
int mbedtls_arc4_crypt( mbedtls_arc4_context *ctx, size_t length, const unsigned char *input,
|
2010-03-21 15:42:15 +00:00
|
|
|
unsigned char *output );
|
2009-01-03 21:22:43 +00:00
|
|
|
|
2019-01-31 13:20:20 +00:00
|
|
|
#if defined(MBEDTLS_SELF_TEST)
|
|
|
|
|
2012-11-14 12:39:52 +00:00
|
|
|
/**
|
2009-01-03 21:22:43 +00:00
|
|
|
* \brief Checkup routine
|
|
|
|
*
|
|
|
|
* \return 0 if successful, or 1 if the test failed
|
2017-09-25 13:53:51 +00:00
|
|
|
*
|
|
|
|
* \warning ARC4 is considered a weak cipher and its use constitutes a
|
|
|
|
* security risk. We recommend considering stronger ciphers
|
|
|
|
* instead.
|
|
|
|
*
|
2009-01-03 21:22:43 +00:00
|
|
|
*/
|
2015-04-08 10:49:31 +00:00
|
|
|
int mbedtls_arc4_self_test( int verbose );
|
2009-01-03 21:22:43 +00:00
|
|
|
|
2019-01-31 13:20:20 +00:00
|
|
|
#endif /* MBEDTLS_SELF_TEST */
|
|
|
|
|
2009-01-03 21:22:43 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* arc4.h */
|