4 * \brief The ARCFOUR stream cipher
6 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
7 * SPDX-License-Identifier: Apache-2.0
9 * Licensed under the Apache License, Version 2.0 (the "License"); you may
10 * not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * This file is part of mbed TLS (https://tls.mbed.org)
23 #ifndef MBEDTLS_ARC4_H
24 #define MBEDTLS_ARC4_H
26 #if !defined(MBEDTLS_CONFIG_FILE)
29 #include MBEDTLS_CONFIG_FILE
34 #if !defined(MBEDTLS_ARC4_ALT)
35 // Regular implementation
43 * \brief ARC4 context structure
47 int x
; /*!< permutation index */
48 int y
; /*!< permutation index */
49 unsigned char m
[256]; /*!< permutation table */
54 * \brief Initialize ARC4 context
56 * \param ctx ARC4 context to be initialized
58 void mbedtls_arc4_init( mbedtls_arc4_context
*ctx
);
61 * \brief Clear ARC4 context
63 * \param ctx ARC4 context to be cleared
65 void mbedtls_arc4_free( mbedtls_arc4_context
*ctx
);
68 * \brief ARC4 key schedule
70 * \param ctx ARC4 context to be setup
71 * \param key the secret key
72 * \param keylen length of the key, in bytes
74 void mbedtls_arc4_setup( mbedtls_arc4_context
*ctx
, const unsigned char *key
,
75 unsigned int keylen
);
78 * \brief ARC4 cipher function
80 * \param ctx ARC4 context
81 * \param length length of the input data
82 * \param input buffer holding the input data
83 * \param output buffer for the output data
85 * \return 0 if successful
87 int mbedtls_arc4_crypt( mbedtls_arc4_context
*ctx
, size_t length
, const unsigned char *input
,
88 unsigned char *output
);
94 #else /* MBEDTLS_ARC4_ALT */
96 #endif /* MBEDTLS_ARC4_ALT */
103 * \brief Checkup routine
105 * \return 0 if successful, or 1 if the test failed
107 int mbedtls_arc4_self_test( int verbose
);