Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / mbedtls / repo / include / mbedtls / arc4.h
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 (C) 2006-2015, ARM Limited, All Rights Reserved
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  *  This file is part of mbed TLS (https://tls.mbed.org)
26  *
27  */
28 #ifndef MBEDTLS_ARC4_H
29 #define MBEDTLS_ARC4_H
30
31 #if !defined(MBEDTLS_CONFIG_FILE)
32 #include "config.h"
33 #else
34 #include MBEDTLS_CONFIG_FILE
35 #endif
36
37 #include <stddef.h>
38
39 /* MBEDTLS_ERR_ARC4_HW_ACCEL_FAILED is deprecated and should not be used. */
40 #define MBEDTLS_ERR_ARC4_HW_ACCEL_FAILED                  -0x0019  /**< ARC4 hardware accelerator failed. */
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46 #if !defined(MBEDTLS_ARC4_ALT)
47 // Regular implementation
48 //
49
50 /**
51  * \brief     ARC4 context structure
52  *
53  * \warning   ARC4 is considered a weak cipher and its use constitutes a
54  *            security risk. We recommend considering stronger ciphers instead.
55  *
56  */
57 typedef struct mbedtls_arc4_context
58 {
59     int x;                      /*!< permutation index */
60     int y;                      /*!< permutation index */
61     unsigned char m[256];       /*!< permutation table */
62 }
63 mbedtls_arc4_context;
64
65 #else  /* MBEDTLS_ARC4_ALT */
66 #include "arc4_alt.h"
67 #endif /* MBEDTLS_ARC4_ALT */
68
69 /**
70  * \brief          Initialize ARC4 context
71  *
72  * \param ctx      ARC4 context to be initialized
73  *
74  * \warning        ARC4 is considered a weak cipher and its use constitutes a
75  *                 security risk. We recommend considering stronger ciphers
76  *                 instead.
77  *
78  */
79 void mbedtls_arc4_init( mbedtls_arc4_context *ctx );
80
81 /**
82  * \brief          Clear ARC4 context
83  *
84  * \param ctx      ARC4 context to be cleared
85  *
86  * \warning        ARC4 is considered a weak cipher and its use constitutes a
87  *                 security risk. We recommend considering stronger ciphers
88  *                 instead.
89  *
90  */
91 void mbedtls_arc4_free( mbedtls_arc4_context *ctx );
92
93 /**
94  * \brief          ARC4 key schedule
95  *
96  * \param ctx      ARC4 context to be setup
97  * \param key      the secret key
98  * \param keylen   length of the key, in bytes
99  *
100  * \warning        ARC4 is considered a weak cipher and its use constitutes a
101  *                 security risk. We recommend considering stronger ciphers
102  *                 instead.
103  *
104  */
105 void mbedtls_arc4_setup( mbedtls_arc4_context *ctx, const unsigned char *key,
106                  unsigned int keylen );
107
108 /**
109  * \brief          ARC4 cipher function
110  *
111  * \param ctx      ARC4 context
112  * \param length   length of the input data
113  * \param input    buffer holding the input data
114  * \param output   buffer for the output data
115  *
116  * \return         0 if successful
117  *
118  * \warning        ARC4 is considered a weak cipher and its use constitutes a
119  *                 security risk. We recommend considering stronger ciphers
120  *                 instead.
121  *
122  */
123 int mbedtls_arc4_crypt( mbedtls_arc4_context *ctx, size_t length, const unsigned char *input,
124                 unsigned char *output );
125
126 #if defined(MBEDTLS_SELF_TEST)
127
128 /**
129  * \brief          Checkup routine
130  *
131  * \return         0 if successful, or 1 if the test failed
132  *
133  * \warning        ARC4 is considered a weak cipher and its use constitutes a
134  *                 security risk. We recommend considering stronger ciphers
135  *                 instead.
136  *
137  */
138 int mbedtls_arc4_self_test( int verbose );
139
140 #endif /* MBEDTLS_SELF_TEST */
141
142 #ifdef __cplusplus
143 }
144 #endif
145
146 #endif /* arc4.h */