Cleanup armsrc/string.c and string.h (#964)
[legacy-proxmark3.git] / common / mbedtls / arc4.h
blob0355fb8b535b550e1a912791a197db996ae0a70b
1 /**
2 * \file arc4.h
4 * \brief The ARCFOUR stream cipher
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: GPL-2.0
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 * This file is part of mbed TLS (https://tls.mbed.org)
30 #ifndef MBEDTLS_ARC4_H
31 #define MBEDTLS_ARC4_H
33 #if !defined(MBEDTLS_CONFIG_FILE)
34 #include "config.h"
35 #else
36 #include MBEDTLS_CONFIG_FILE
37 #endif
39 #include <stddef.h>
41 #define MBEDTLS_ERR_ARC4_HW_ACCEL_FAILED -0x0019 /**< ARC4 hardware accelerator failed. */
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
47 #if !defined(MBEDTLS_ARC4_ALT)
48 // Regular implementation
51 /**
52 * \brief ARC4 context structure
54 * \warning ARC4 is considered a weak cipher and its use constitutes a
55 * security risk. We recommend considering stronger ciphers instead.
58 typedef struct mbedtls_arc4_context
60 int x; /*!< permutation index */
61 int y; /*!< permutation index */
62 unsigned char m[256]; /*!< permutation table */
64 mbedtls_arc4_context;
66 #else /* MBEDTLS_ARC4_ALT */
67 #include "arc4_alt.h"
68 #endif /* MBEDTLS_ARC4_ALT */
70 /**
71 * \brief Initialize ARC4 context
73 * \param ctx ARC4 context to be initialized
75 * \warning ARC4 is considered a weak cipher and its use constitutes a
76 * security risk. We recommend considering stronger ciphers
77 * instead.
80 void mbedtls_arc4_init( mbedtls_arc4_context *ctx );
82 /**
83 * \brief Clear ARC4 context
85 * \param ctx ARC4 context to be cleared
87 * \warning ARC4 is considered a weak cipher and its use constitutes a
88 * security risk. We recommend considering stronger ciphers
89 * instead.
92 void mbedtls_arc4_free( mbedtls_arc4_context *ctx );
94 /**
95 * \brief ARC4 key schedule
97 * \param ctx ARC4 context to be setup
98 * \param key the secret key
99 * \param keylen length of the key, in bytes
101 * \warning ARC4 is considered a weak cipher and its use constitutes a
102 * security risk. We recommend considering stronger ciphers
103 * instead.
106 void mbedtls_arc4_setup( mbedtls_arc4_context *ctx, const unsigned char *key,
107 unsigned int keylen );
110 * \brief ARC4 cipher function
112 * \param ctx ARC4 context
113 * \param length length of the input data
114 * \param input buffer holding the input data
115 * \param output buffer for the output data
117 * \return 0 if successful
119 * \warning ARC4 is considered a weak cipher and its use constitutes a
120 * security risk. We recommend considering stronger ciphers
121 * instead.
124 int mbedtls_arc4_crypt( mbedtls_arc4_context *ctx, size_t length, const unsigned char *input,
125 unsigned char *output );
128 * \brief Checkup routine
130 * \return 0 if successful, or 1 if the test failed
132 * \warning ARC4 is considered a weak cipher and its use constitutes a
133 * security risk. We recommend considering stronger ciphers
134 * instead.
137 int mbedtls_arc4_self_test( int verbose );
139 #ifdef __cplusplus
141 #endif
143 #endif /* arc4.h */