]>
git.zerfleddert.de Git - proxmark3-svn/blob - common/mbedtls/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.
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)
36 #include MBEDTLS_CONFIG_FILE
41 #define MBEDTLS_ERR_ARC4_HW_ACCEL_FAILED -0x0019 /**< ARC4 hardware accelerator failed. */
47 #if !defined(MBEDTLS_ARC4_ALT)
48 // Regular implementation
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 */
66 #else /* MBEDTLS_ARC4_ALT */
68 #endif /* MBEDTLS_ARC4_ALT */
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
80 void mbedtls_arc4_init( mbedtls_arc4_context
*ctx
);
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
92 void mbedtls_arc4_free( mbedtls_arc4_context
*ctx
);
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
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
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
137 int mbedtls_arc4_self_test( int verbose
);