1rc4(n)                         RC4 Stream Cipher                        rc4(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       rc4 - Impementation of the RC4 stream cipher
9

SYNOPSIS

11       package require Tcl  8.2
12
13       package require rc4  ?1.1.0?
14
15       ::rc4::rc4  ?-hex?  -key  keyvalue  ?-command lst? ?-out channel? [ -in
16       channel | -infile filename | string ]
17
18       ::rc4::RC4Init keydata
19
20       ::rc4::RC4 Key data
21
22       ::rc4::RC4Final Key
23
24_________________________________________________________________
25

DESCRIPTION

27       This package is an implementation in  Tcl  of  the  RC4  stream  cipher
28       developed  by  Ron  Rivest  of  RSA Data Security Inc. The cipher was a
29       trade secret of RSA but was reverse-engineered  and  published  to  the
30       internet  in  1994.  It  is  used  in a number of network protocols for
31       securing communications. To evade trademark restrictions this cipher is
32       sometimes known as ARCFOUR.
33

COMMANDS

35       ::rc4::rc4  ?-hex?  -key  keyvalue  ?-command lst? ?-out channel? [ -in
36       channel | -infile filename | string ]
37              Perform the RC4 algorithm on either the  data  provided  by  the
38              argument  or  on  the data read from the -in channel. If an -out
39              channel is given then the result will be written to  this  chan‐
40              nel.   Giving  the -hex option will return a hexadecimal encoded
41              version of the result if not using an -out channel.
42
43              The data to be processes can be specified  either  as  a  string
44              argument  to  the  rc4 command, or as a filename or a pre-opened
45              channel. If the -infile argument  is  given  then  the  file  is
46              opened,  the  data read and processed and the file is closed. If
47              the -in argument is given then data is  read  from  the  channel
48              until  the  end  of file. The channel is not closed. If the -out
49              argument is given then the processing result is written to  this
50              channel.
51
52              If  -command  is  provided  then the rc4 command does not return
53              anything. Instead the command provided is called  with  the  rc4
54              result data appended as the final parameter. This is most useful
55              when reading from Tcl channels as a fileevent is  setup  on  the
56              channel and the data processed in chunks
57
58              Only one of -infile, -in or string should be given.
59

PROGRAMMING INTERFACE

61       ::rc4::RC4Init keydata
62              Initialize  a  new  RC4 key. The keydata is any amount of binary
63              data and is used to initialize the cipher internal state.
64
65       ::rc4::RC4 Key data
66              Encrypt or decrypt the input data  using  the  key  obtained  by
67              calling RC4Init.
68
69       ::rc4::RC4Final Key
70              This should be called to clean up resources associated with Key.
71              Once this function has been called the key is destroyed.
72

EXAMPLES

74       % set keydata [binary format H* 0123456789abcdef]
75       % rc4::rc4 -hex -key $keydata HelloWorld
76       3cf1ae8b7f1c670b612f
77       % rc4::rc4 -hex -key $keydata [binary format H* 3cf1ae8b7f1c670b612f]
78       HelloWorld
79
80
81        set Key [rc4::RC4Init "key data"]
82        append ciphertext [rc4::RC4 $Key $plaintext]
83        append ciphertext [rc4::RC4 $Key $additional_plaintext]
84        rc4::RC4Final $Key
85
86
87        proc ::Finish {myState data} {
88            DoStuffWith $myState $data
89        }
90        rc4::rc4 -in $socket -command [list ::Finish $ApplicationState]
91
92

AUTHORS

94       Pat Thoyts
95

SEE ALSO

97       aes(n), blowfish(n), des(n)
98

KEYWORDS

100       arcfour,, data integrity, encryption, rc4, security, stream cipher
101
103       Copyright (c) 2003, Pat Thoyts <patthoyts@users.sourceforge.net>
104
105
106
107
108rc4                                  1.1.0                              rc4(n)
Impressum