camellia: fix camellia_self_test failure on compilers where char is unsigned by default
[tropicssl.git] / include / tropicssl / arc4.h
blob2f360a05d8a58c94edb5d374e21654874a1b9c5c
1 /**
2 * \file arc4.h
4 * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
6 * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
8 * All rights reserved.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * * Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * * Neither the names of PolarSSL or XySSL nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #ifndef TROPICSSL_ARC4_H
36 #define TROPICSSL_ARC4_H
38 /**
39 * \brief ARC4 context structure
41 typedef struct {
42 int x; /*!< permutation index */
43 int y; /*!< permutation index */
44 unsigned char m[256]; /*!< permutation table */
45 } arc4_context;
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
51 /**
52 * \brief ARC4 key schedule
54 * \param ctx ARC4 context to be initialized
55 * \param key the secret key
56 * \param keylen length of the key
58 void arc4_setup(arc4_context * ctx, const unsigned char *key, int keylen);
60 /**
61 * \brief ARC4 cipher function
63 * \param ctx ARC4 context
64 * \param buf buffer to be processed
65 * \param buflen amount of data in buf
67 void arc4_crypt(arc4_context * ctx, int buflen,
68 const unsigned char *input,
69 unsigned char *output);
72 * \brief Checkup routine
74 * \return 0 if successful, or 1 if the test failed
76 int arc4_self_test(int verbose);
78 #ifdef __cplusplus
80 #endif
81 #endif /* arc4.h */