Mbed OS Reference
Loading...
Searching...
No Matches
mbedtls/include/mbedtls/arc4.h
Go to the documentation of this file.
1/**
2 * \file arc4.h
3 *
4 * \brief The ARCFOUR stream cipher
5 *
6 * \warning ARC4 is considered a weak cipher and its use constitutes a
7 * security risk. We recommend considering stronger ciphers instead.
8 */
9/*
10 * Copyright The Mbed TLS Contributors
11 * SPDX-License-Identifier: Apache-2.0
12 *
13 * Licensed under the Apache License, Version 2.0 (the "License"); you may
14 * not use this file except in compliance with the License.
15 * You may obtain a copy of the License at
16 *
17 * http://www.apache.org/licenses/LICENSE-2.0
18 *
19 * Unless required by applicable law or agreed to in writing, software
20 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
21 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 * See the License for the specific language governing permissions and
23 * limitations under the License.
24 *
25 */
26#ifndef MBEDTLS_ARC4_H
27#define MBEDTLS_ARC4_H
28
29#if !defined(MBEDTLS_CONFIG_FILE)
30#include "mbedtls/config.h"
31#else
32#include MBEDTLS_CONFIG_FILE
33#endif
34
35#include <stddef.h>
36
37/**
38 * \addtogroup mbedtls
39 * \{
40 * \defgroup mbedtls_arc4_module ARC4
41 * \{
42 */
43
44/* MBEDTLS_ERR_ARC4_HW_ACCEL_FAILED is deprecated and should not be used. */
45#define MBEDTLS_ERR_ARC4_HW_ACCEL_FAILED -0x0019 /**< ARC4 hardware accelerator failed. */
46
47#ifdef __cplusplus
48extern "C" {
49#endif
50
51#if !defined(MBEDTLS_ARC4_ALT)
52// Regular implementation
53//
54
55/**
56 * \brief ARC4 context structure
57 *
58 * \warning ARC4 is considered a weak cipher and its use constitutes a
59 * security risk. We recommend considering stronger ciphers instead.
60 *
61 */
63{
64 int x; /*!< permutation index */
65 int y; /*!< permutation index */
66 unsigned char m[256]; /*!< permutation table */
67}
69
70#else /* MBEDTLS_ARC4_ALT */
71#include "arc4_alt.h"
72#endif /* MBEDTLS_ARC4_ALT */
73
74/**
75 * \brief Initialize ARC4 context
76 *
77 * \param ctx ARC4 context to be initialized
78 *
79 * \warning ARC4 is considered a weak cipher and its use constitutes a
80 * security risk. We recommend considering stronger ciphers
81 * instead.
82 *
83 */
85
86/**
87 * \brief Clear ARC4 context
88 *
89 * \param ctx ARC4 context to be cleared
90 *
91 * \warning ARC4 is considered a weak cipher and its use constitutes a
92 * security risk. We recommend considering stronger ciphers
93 * instead.
94 *
95 */
97
98/**
99 * \brief ARC4 key schedule
100 *
101 * \param ctx ARC4 context to be setup
102 * \param key the secret key
103 * \param keylen length of the key, in bytes
104 *
105 * \warning ARC4 is considered a weak cipher and its use constitutes a
106 * security risk. We recommend considering stronger ciphers
107 * instead.
108 *
109 */
110void mbedtls_arc4_setup( mbedtls_arc4_context *ctx, const unsigned char *key,
111 unsigned int keylen );
112
113/**
114 * \brief ARC4 cipher function
115 *
116 * \param ctx ARC4 context
117 * \param length length of the input data
118 * \param input buffer holding the input data
119 * \param output buffer for the output data
120 *
121 * \return 0 if successful
122 *
123 * \warning ARC4 is considered a weak cipher and its use constitutes a
124 * security risk. We recommend considering stronger ciphers
125 * instead.
126 *
127 */
128int mbedtls_arc4_crypt( mbedtls_arc4_context *ctx, size_t length, const unsigned char *input,
129 unsigned char *output );
130
131/// \}
132/// \}
133
134#if defined(MBEDTLS_SELF_TEST)
135
136/**
137 * \brief Checkup routine
138 *
139 * \return 0 if successful, or 1 if the test failed
140 *
141 * \warning ARC4 is considered a weak cipher and its use constitutes a
142 * security risk. We recommend considering stronger ciphers
143 * instead.
144 *
145 */
146int mbedtls_arc4_self_test( int verbose );
147
148#endif /* MBEDTLS_SELF_TEST */
149
150#ifdef __cplusplus
151}
152#endif
153
154#endif /* arc4.h */
Configuration options (set of defines)
int mbedtls_arc4_crypt(mbedtls_arc4_context *ctx, size_t length, const unsigned char *input, unsigned char *output)
ARC4 cipher function.
void mbedtls_arc4_setup(mbedtls_arc4_context *ctx, const unsigned char *key, unsigned int keylen)
ARC4 key schedule.
void mbedtls_arc4_init(mbedtls_arc4_context *ctx)
Initialize ARC4 context.
void mbedtls_arc4_free(mbedtls_arc4_context *ctx)
Clear ARC4 context.