rc2.h revision 55714
14Srgrimes/* crypto/rc2/rc2.h */
24Srgrimes/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
34Srgrimes * All rights reserved.
44Srgrimes *
54Srgrimes * This package is an SSL implementation written
64Srgrimes * by Eric Young (eay@cryptsoft.com).
74Srgrimes * The implementation was written so as to conform with Netscapes SSL.
84Srgrimes *
94Srgrimes * This library is free for commercial and non-commercial use as long as
104Srgrimes * the following conditions are aheared to.  The following conditions
114Srgrimes * apply to all code found in this distribution, be it the RC4, RSA,
124Srgrimes * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
134Srgrimes * included with this distribution is covered by the same copyright terms
144Srgrimes * except that the holder is Tim Hudson (tjh@cryptsoft.com).
154Srgrimes *
164Srgrimes * Copyright remains Eric Young's, and as such any Copyright notices in
174Srgrimes * the code are not to be removed.
184Srgrimes * If this package is used in a product, Eric Young should be given attribution
194Srgrimes * as the author of the parts of the library used.
204Srgrimes * This can be in the form of a textual message at program startup or
214Srgrimes * in documentation (online or textual) provided with the package.
224Srgrimes *
234Srgrimes * Redistribution and use in source and binary forms, with or without
244Srgrimes * modification, are permitted provided that the following conditions
254Srgrimes * are met:
264Srgrimes * 1. Redistributions of source code must retain the copyright
274Srgrimes *    notice, this list of conditions and the following disclaimer.
284Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
294Srgrimes *    notice, this list of conditions and the following disclaimer in the
304Srgrimes *    documentation and/or other materials provided with the distribution.
314Srgrimes * 3. All advertising materials mentioning features or use of this software
324Srgrimes *    must display the following acknowledgement:
334Srgrimes *    "This product includes cryptographic software written by
344Srgrimes *     Eric Young (eay@cryptsoft.com)"
354Srgrimes *    The word 'cryptographic' can be left out if the rouines from the library
36556Srgrimes *    being used are not cryptographic related :-).
3750477Speter * 4. If you include any Windows specific code (or a derivative thereof) from
3815392Sphk *    the apps directory (application code) you must include an acknowledgement:
39757Sdg *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40757Sdg *
41757Sdg * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
4215392Sphk * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4315392Sphk * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
444Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
454Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4632358Seivind * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4790132Sbde * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4837272Sjmg * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4914835Sbde * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5014835Sbde * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
515908Sbde * SUCH DAMAGE.
524Srgrimes *
5314835Sbde * The licence and distribution terms for any publically available version or
5414835Sbde * derivative of this code cannot be changed.  i.e. this code cannot simply be
5514835Sbde * copied and put under another distribution licence
5615543Sphk * [including the GNU Public Licence.]
5714835Sbde */
5814835Sbde
5914835Sbde#ifndef HEADER_RC2_H
6014835Sbde#define HEADER_RC2_H
6173017Speter
6273017Speter#ifdef  __cplusplus
6373017Speterextern "C" {
6473017Speter#endif
6573017Speter
6673017Speter#ifdef NO_RC2
674Srgrimes#error RC2 is disabled.
68757Sdg#endif
69757Sdg
704Srgrimes#define RC2_ENCRYPT	1
714Srgrimes#define RC2_DECRYPT	0
724Srgrimes
734Srgrimes#include <openssl/opensslconf.h> /* RC2_INT */
744Srgrimes#define RC2_BLOCK	8
75200Sdg#define RC2_KEY_LENGTH	16
764Srgrimes
774Srgrimestypedef struct rc2_key_st
7882307Sjulian	{
7982307Sjulian	RC2_INT data[64];
8082307Sjulian	} RC2_KEY;
8182308Speter
8282394Speter
8382307Sjulianvoid RC2_set_key(RC2_KEY *key, int len, unsigned char *data,int bits);
844Srgrimesvoid RC2_ecb_encrypt(unsigned char *in,unsigned char *out,RC2_KEY *key,
8573011Sjake	int enc);
8673011Sjakevoid RC2_encrypt(unsigned long *data,RC2_KEY *key);
8773011Sjakevoid RC2_decrypt(unsigned long *data,RC2_KEY *key);
8873011Sjakevoid RC2_cbc_encrypt(unsigned char *in, unsigned char *out, long length,
89592Srgrimes	RC2_KEY *ks, unsigned char *iv, int enc);
903861Sbdevoid RC2_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
914Srgrimes	RC2_KEY *schedule, unsigned char *ivec, int *num, int enc);
924Srgrimesvoid RC2_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
9382307Sjulian	RC2_KEY *schedule, unsigned char *ivec, int *num);
944Srgrimes
9573011Sjake#ifdef  __cplusplus
9673011Sjake}
9773011Sjake#endif
9873011Sjake
994Srgrimes#endif
10070928Sjake