blob: 2344c74af5964613f3cdda1ef01deaabd5c983b3 [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001/**
2 * \file arc4.h
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00003 *
Paul Bakker37ca75d2011-01-06 12:28:03 +00004 * \brief The ARCFOUR stream cipher
5 *
Paul Bakker84f12b72010-07-18 10:13:04 +00006 * Copyright (C) 2006-2010, Brainspark B.V.
Paul Bakkerb96f1542010-07-18 20:36:00 +00007 *
8 * This file is part of PolarSSL (http://www.polarssl.org)
Paul Bakker84f12b72010-07-18 10:13:04 +00009 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
Paul Bakkerb96f1542010-07-18 20:36:00 +000010 *
Paul Bakker77b385e2009-07-28 17:23:11 +000011 * All rights reserved.
Paul Bakkere0ccd0a2009-01-04 16:27:10 +000012 *
Paul Bakkere0ccd0a2009-01-04 16:27:10 +000013 * 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.
17 *
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.
22 *
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.
Paul Bakker5121ce52009-01-03 21:22:43 +000026 */
Paul Bakker40e46942009-01-03 21:51:57 +000027#ifndef POLARSSL_ARC4_H
28#define POLARSSL_ARC4_H
Paul Bakker5121ce52009-01-03 21:22:43 +000029
30/**
31 * \brief ARC4 context structure
32 */
33typedef struct
34{
35 int x; /*!< permutation index */
36 int y; /*!< permutation index */
37 unsigned char m[256]; /*!< permutation table */
38}
39arc4_context;
40
41#ifdef __cplusplus
42extern "C" {
43#endif
44
45/**
46 * \brief ARC4 key schedule
47 *
48 * \param ctx ARC4 context to be initialized
49 * \param key the secret key
50 * \param keylen length of the key
51 */
Paul Bakkerff60ee62010-03-16 21:09:09 +000052void arc4_setup( arc4_context *ctx, const unsigned char *key, int keylen );
Paul Bakker5121ce52009-01-03 21:22:43 +000053
54/**
55 * \brief ARC4 cipher function
56 *
57 * \param ctx ARC4 context
Paul Bakkerbaad6502010-03-21 15:42:15 +000058 * \param length length of the input data
59 * \param input buffer holding the input data
60 * \param output buffer for the output data
Paul Bakkerf3ccc682010-03-18 21:21:02 +000061 *
Paul Bakker27caa8a2010-03-21 15:43:59 +000062 * \return 0 if successful
Paul Bakker5121ce52009-01-03 21:22:43 +000063 */
Paul Bakkerbaad6502010-03-21 15:42:15 +000064int arc4_crypt( arc4_context *ctx, int length, const unsigned char *input,
65 unsigned char *output );
Paul Bakker5121ce52009-01-03 21:22:43 +000066
67/*
68 * \brief Checkup routine
69 *
70 * \return 0 if successful, or 1 if the test failed
71 */
72int arc4_self_test( int verbose );
73
74#ifdef __cplusplus
75}
76#endif
77
78#endif /* arc4.h */