2 |
- |
1 |
/* Copyright (C) 2001 Artifex Software, Inc. All rights reserved.
|
|
|
2 |
|
|
|
3 |
This software is provided AS-IS with no warranty, either express or
|
|
|
4 |
implied.
|
|
|
5 |
|
|
|
6 |
This software is distributed under license and may not be copied,
|
|
|
7 |
modified or distributed except as expressly authorized under the terms
|
|
|
8 |
of the license contained in the file LICENSE in this distribution.
|
|
|
9 |
|
|
|
10 |
For more information about licensing, please refer to
|
|
|
11 |
http://www.ghostscript.com/licensing/. For information on
|
|
|
12 |
commercial licensing, go to http://www.artifex.com/licensing/ or
|
|
|
13 |
contact Artifex Software, Inc., 101 Lucas Valley Road #110,
|
|
|
14 |
San Rafael, CA 94903, U.S.A., +1(415)492-9861.
|
|
|
15 |
*/
|
|
|
16 |
|
|
|
17 |
/* $Id: sarc4.h,v 1.6 2004/01/14 13:45:56 igor Exp $ */
|
|
|
18 |
/* Definitions for Arcfour cipher and filter */
|
|
|
19 |
/* Requires scommon.h; strimpl.h if any templates are referenced */
|
|
|
20 |
|
|
|
21 |
#ifndef sarc4_INCLUDED
|
|
|
22 |
# define sarc4_INCLUDED
|
|
|
23 |
|
|
|
24 |
#include "scommon.h"
|
|
|
25 |
|
|
|
26 |
/* Arcfour is a symmetric cipher whose state is maintained
|
|
|
27 |
* in two indices into an accompanying 8x8 S box. this will
|
|
|
28 |
* typically be allocated on the stack, and so has no memory
|
|
|
29 |
* management associated.
|
|
|
30 |
*/
|
|
|
31 |
struct stream_arcfour_state_s
|
|
|
32 |
{
|
|
|
33 |
stream_state_common; /* a define from scommon.h */
|
|
|
34 |
unsigned int x, y;
|
|
|
35 |
unsigned char S[256];
|
|
|
36 |
};
|
|
|
37 |
|
|
|
38 |
#ifndef stream_arcfour_state_DEFINED
|
|
|
39 |
#define stream_arcfour_state_DEFINED
|
|
|
40 |
typedef struct stream_arcfour_state_s stream_arcfour_state;
|
|
|
41 |
#endif
|
|
|
42 |
|
|
|
43 |
int s_arcfour_set_key(stream_arcfour_state * state, const unsigned char *key,
|
|
|
44 |
int keylength);
|
|
|
45 |
|
|
|
46 |
#define private_st_arcfour_state() /* used in sarc4.c */\
|
|
|
47 |
gs_private_st_simple(st_arcfour_state, stream_arcfour_state,\
|
|
|
48 |
"Arcfour filter state")
|
|
|
49 |
extern const stream_template s_arcfour_template;
|
|
|
50 |
|
|
|
51 |
/* (de)crypt a section of text in a buffer -- the procedure is the same
|
|
|
52 |
* in each direction. see strimpl.h for return codes.
|
|
|
53 |
*/
|
|
|
54 |
int s_arcfour_process_buffer(stream_arcfour_state *ss, byte *buf, int buf_size);
|
|
|
55 |
|
|
|
56 |
#endif /* sarc4_INCLUDED */
|