blob: 20f142a567d539b0a7e01d5a798a6d7ca4feca2a [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001/**
2 * \file arc4.h
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00003 *
Paul Bakker77b385e2009-07-28 17:23:11 +00004 * Copyright (C) 2006-2009, Paul Bakker <polarssl_maintainer at polarssl.org>
5 * All rights reserved.
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00006 *
Paul Bakker77b385e2009-07-28 17:23:11 +00007 * Joined copyright on original XySSL code with: Christophe Devine
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00008 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Paul Bakker5121ce52009-01-03 21:22:43 +000022 */
Paul Bakker40e46942009-01-03 21:51:57 +000023#ifndef POLARSSL_ARC4_H
24#define POLARSSL_ARC4_H
Paul Bakker5121ce52009-01-03 21:22:43 +000025
26/**
27 * \brief ARC4 context structure
28 */
29typedef struct
30{
31 int x; /*!< permutation index */
32 int y; /*!< permutation index */
33 unsigned char m[256]; /*!< permutation table */
34}
35arc4_context;
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41/**
42 * \brief ARC4 key schedule
43 *
44 * \param ctx ARC4 context to be initialized
45 * \param key the secret key
46 * \param keylen length of the key
47 */
Paul Bakkerff60ee62010-03-16 21:09:09 +000048void arc4_setup( arc4_context *ctx, const unsigned char *key, int keylen );
Paul Bakker5121ce52009-01-03 21:22:43 +000049
50/**
51 * \brief ARC4 cipher function
52 *
53 * \param ctx ARC4 context
54 * \param buf buffer to be processed
55 * \param buflen amount of data in buf
56 */
57void arc4_crypt( arc4_context *ctx, unsigned char *buf, int buflen );
58
59/*
60 * \brief Checkup routine
61 *
62 * \return 0 if successful, or 1 if the test failed
63 */
64int arc4_self_test( int verbose );
65
66#ifdef __cplusplus
67}
68#endif
69
70#endif /* arc4.h */