2009-01-03 22:22:43 +01:00
|
|
|
/**
|
|
|
|
* \file arc4.h
|
2009-01-04 17:27:10 +01:00
|
|
|
*
|
2011-01-06 13:28:03 +01:00
|
|
|
* \brief The ARCFOUR stream cipher
|
|
|
|
*
|
2015-07-27 11:11:48 +02:00
|
|
|
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
|
2015-09-04 14:21:07 +02:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2010-07-18 22:36:00 +02:00
|
|
|
*
|
2015-09-04 14:21:07 +02: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 22:36:00 +02:00
|
|
|
*
|
2015-09-04 14:21:07 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2009-01-04 17:27:10 +01:00
|
|
|
*
|
2015-09-04 14:21:07 +02: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 17:27:10 +01:00
|
|
|
*
|
2015-09-04 14:21:07 +02:00
|
|
|
* This file is part of mbed TLS (https://tls.mbed.org)
|
2009-01-03 22:22:43 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
#ifndef MBEDTLS_ARC4_H
|
|
|
|
#define MBEDTLS_ARC4_H
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#if !defined(MBEDTLS_CONFIG_FILE)
|
2013-06-24 19:20:35 +02:00
|
|
|
#include "config.h"
|
2014-04-29 12:39:06 +02:00
|
|
|
#else
|
2015-04-08 12:49:31 +02:00
|
|
|
#include MBEDTLS_CONFIG_FILE
|
2014-04-29 12:39:06 +02:00
|
|
|
#endif
|
2013-06-24 19:20:35 +02:00
|
|
|
|
2015-02-06 14:43:58 +01:00
|
|
|
#include <stddef.h>
|
2011-04-24 10:57:21 +02:00
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#if !defined(MBEDTLS_ARC4_ALT)
|
2013-06-24 19:20:35 +02:00
|
|
|
// Regular implementation
|
|
|
|
//
|
|
|
|
|
2013-06-27 14:29:21 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2009-01-03 22:22:43 +01:00
|
|
|
/**
|
|
|
|
* \brief ARC4 context structure
|
|
|
|
*/
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int x; /*!< permutation index */
|
|
|
|
int y; /*!< permutation index */
|
|
|
|
unsigned char m[256]; /*!< permutation table */
|
|
|
|
}
|
2015-04-08 12:49:31 +02:00
|
|
|
mbedtls_arc4_context;
|
2009-01-03 22:22:43 +01:00
|
|
|
|
|
|
|
/**
|
2014-06-18 11:12:03 +02:00
|
|
|
* \brief Initialize ARC4 context
|
2009-01-03 22:22:43 +01:00
|
|
|
*
|
|
|
|
* \param ctx ARC4 context to be initialized
|
2014-06-18 11:12:03 +02:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
void mbedtls_arc4_init( mbedtls_arc4_context *ctx );
|
2014-06-18 11:12:03 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Clear ARC4 context
|
|
|
|
*
|
|
|
|
* \param ctx ARC4 context to be cleared
|
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
void mbedtls_arc4_free( mbedtls_arc4_context *ctx );
|
2014-06-18 11:12:03 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief ARC4 key schedule
|
|
|
|
*
|
|
|
|
* \param ctx ARC4 context to be setup
|
2009-01-03 22:22:43 +01:00
|
|
|
* \param key the secret key
|
2013-09-04 12:28:37 +02:00
|
|
|
* \param keylen length of the key, in bytes
|
2009-01-03 22:22:43 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
void mbedtls_arc4_setup( mbedtls_arc4_context *ctx, const unsigned char *key,
|
2014-05-01 14:18:25 +02:00
|
|
|
unsigned int keylen );
|
2009-01-03 22:22:43 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief ARC4 cipher function
|
|
|
|
*
|
|
|
|
* \param ctx ARC4 context
|
2010-03-21 16:42:15 +01: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 22:21:02 +01:00
|
|
|
*
|
2010-03-21 16:43:59 +01:00
|
|
|
* \return 0 if successful
|
2009-01-03 22:22:43 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_arc4_crypt( mbedtls_arc4_context *ctx, size_t length, const unsigned char *input,
|
2010-03-21 16:42:15 +01:00
|
|
|
unsigned char *output );
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2013-06-24 19:20:35 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#else /* MBEDTLS_ARC4_ALT */
|
2013-06-24 19:20:35 +02:00
|
|
|
#include "arc4_alt.h"
|
2015-04-08 12:49:31 +02:00
|
|
|
#endif /* MBEDTLS_ARC4_ALT */
|
2013-06-24 19:20:35 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2012-11-14 13:39:52 +01:00
|
|
|
/**
|
2009-01-03 22:22:43 +01:00
|
|
|
* \brief Checkup routine
|
|
|
|
*
|
|
|
|
* \return 0 if successful, or 1 if the test failed
|
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_arc4_self_test( int verbose );
|
2009-01-03 22:22:43 +01:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* arc4.h */
|