]> git.cryptolib.org Git - avr-crypto-lib.git/blob - arcfour/arcfour.h
fixing E-Mail-Address & Copyright
[avr-crypto-lib.git] / arcfour / arcfour.h
1 /* arcfour.h */
2 /*
3  This file is part of the AVR-Crypto-Lib.
4  Copyright (C) 2006-2015 Daniel Otte (bg@nerilex.org)
5
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU General Public License for more details.
15
16  You should have received a copy of the GNU General Public License
17  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 /*
20  * File:        arcfour.h
21  * Author:      Daniel Otte
22  * Date:        2006-06-07
23  * License: GPLv3+
24  * Description: Implementation of the ARCFOUR (RC4 compatible) stream cipher algorithm.
25  */
26
27 /**
28  * \file        arcfour.h
29  * \author      Daniel Otte
30  * \date        2006-06-07
31  * \license GPLv3+
32  * \brief Implementation of the ARCFOUR (RC4 compatible) stream cipher algorithm.
33  *
34  * This header file defines the interface of the ARCFOUR cipher implementation.
35  *
36  * This implementation aims to be compatible with the ARCFOUR description
37  * available at
38  * http://www.mozilla.org/projects/security/pki/nss/draft-kaukonen-cipher-arcfour-03.txt
39  */
40
41 #ifndef ARCFOUR_H_
42 #define ARCFOUR_H_
43
44 #include <stdint.h>
45
46 /** \typedef arcfour_ctx_t
47  * \brief type for arcfour context
48  *
49  * A variable of this type may contain a complete ARCFOUR context.
50  * The context is used to store the state of the cipher and gets
51  * created by the arcfour_init(arcfour_ctx_t *c, uint8_t *key, uint8_t length_B)
52  * function. The context is of the fixed size of 258 bytes
53  */
54
55 /** \struct arcfour_ctx_st
56  * \brief base for ::arcfour_ctx_t
57  *
58  * The struct holds the two indices and the S-Box
59  */
60 typedef struct arcfour_ctx_st {
61     uint8_t i, j;
62     uint8_t s[256];
63 } arcfour_ctx_t;
64
65 /** \fn void arcfour_init(const void *key, uint8_t length_B, arcfour_ctx_t *ctx)
66  * \brief setup a context with a key
67  *
68  * This function sets up a ::arcfour_ctx_t context using
69  * the supplied key of the given length.
70  * \param ctx pointer to the context
71  * \param key pointer to the key
72  * \param length_b length of the key in bits (between 8 and 2048)
73  */
74
75 void arcfour_init(const void *key, uint16_t length_b, arcfour_ctx_t *ctx);
76
77 /** \fn uint8_t arcfour_gen(arcfour_ctx_t *ctx)
78  * \brief generates a byte of keystream
79  *
80  * This function generates the next byte of keystream
81  * from the supplied ::arcfour_ctx_t context which is updated accordingly
82  *
83  * \param ctx pointer to the context
84  * \return byte of keystream
85  */
86
87 uint8_t arcfour_gen(arcfour_ctx_t *ctx);
88
89 #endif