cast.h revision 296341
1219508Snwhitehorn/* crypto/cast/cast.h */
2219508Snwhitehorn/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3219508Snwhitehorn * All rights reserved.
4219508Snwhitehorn *
5219508Snwhitehorn * This package is an SSL implementation written
6219508Snwhitehorn * by Eric Young (eay@cryptsoft.com).
7219508Snwhitehorn * The implementation was written so as to conform with Netscapes SSL.
8219508Snwhitehorn *
9219508Snwhitehorn * This library is free for commercial and non-commercial use as long as
10219508Snwhitehorn * the following conditions are aheared to.  The following conditions
11219508Snwhitehorn * apply to all code found in this distribution, be it the RC4, RSA,
12219508Snwhitehorn * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
13219508Snwhitehorn * included with this distribution is covered by the same copyright terms
14219508Snwhitehorn * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15219508Snwhitehorn *
16219508Snwhitehorn * Copyright remains Eric Young's, and as such any Copyright notices in
17219508Snwhitehorn * the code are not to be removed.
18219508Snwhitehorn * If this package is used in a product, Eric Young should be given attribution
19219508Snwhitehorn * as the author of the parts of the library used.
20219508Snwhitehorn * This can be in the form of a textual message at program startup or
21219508Snwhitehorn * in documentation (online or textual) provided with the package.
22219508Snwhitehorn *
23219508Snwhitehorn * Redistribution and use in source and binary forms, with or without
24219508Snwhitehorn * modification, are permitted provided that the following conditions
25219508Snwhitehorn * are met:
26219508Snwhitehorn * 1. Redistributions of source code must retain the copyright
27219508Snwhitehorn *    notice, this list of conditions and the following disclaimer.
28219508Snwhitehorn * 2. Redistributions in binary form must reproduce the above copyright
29219508Snwhitehorn *    notice, this list of conditions and the following disclaimer in the
30219508Snwhitehorn *    documentation and/or other materials provided with the distribution.
31219508Snwhitehorn * 3. All advertising materials mentioning features or use of this software
32219508Snwhitehorn *    must display the following acknowledgement:
33219508Snwhitehorn *    "This product includes cryptographic software written by
34219508Snwhitehorn *     Eric Young (eay@cryptsoft.com)"
35219508Snwhitehorn *    The word 'cryptographic' can be left out if the rouines from the library
36219508Snwhitehorn *    being used are not cryptographic related :-).
37219508Snwhitehorn * 4. If you include any Windows specific code (or a derivative thereof) from
38219508Snwhitehorn *    the apps directory (application code) you must include an acknowledgement:
39219508Snwhitehorn *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40219508Snwhitehorn *
41219508Snwhitehorn * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42219508Snwhitehorn * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43219508Snwhitehorn * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44219508Snwhitehorn * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45219508Snwhitehorn * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46219508Snwhitehorn * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47219508Snwhitehorn * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed.  i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef HEADER_CAST_H
60# define HEADER_CAST_H
61
62#ifdef  __cplusplus
63extern "C" {
64#endif
65
66# include <openssl/opensslconf.h>
67
68# ifdef OPENSSL_NO_CAST
69#  error CAST is disabled.
70# endif
71
72# define CAST_ENCRYPT    1
73# define CAST_DECRYPT    0
74
75# define CAST_LONG unsigned int
76
77# define CAST_BLOCK      8
78# define CAST_KEY_LENGTH 16
79
80typedef struct cast_key_st {
81    CAST_LONG data[32];
82    int short_key;              /* Use reduced rounds for short key */
83} CAST_KEY;
84
85# ifdef OPENSSL_FIPS
86void private_CAST_set_key(CAST_KEY *key, int len, const unsigned char *data);
87# endif
88void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data);
89void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out,
90                      const CAST_KEY *key, int enc);
91void CAST_encrypt(CAST_LONG *data, const CAST_KEY *key);
92void CAST_decrypt(CAST_LONG *data, const CAST_KEY *key);
93void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out,
94                      long length, const CAST_KEY *ks, unsigned char *iv,
95                      int enc);
96void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out,
97                        long length, const CAST_KEY *schedule,
98                        unsigned char *ivec, int *num, int enc);
99void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out,
100                        long length, const CAST_KEY *schedule,
101                        unsigned char *ivec, int *num);
102
103#ifdef  __cplusplus
104}
105#endif
106
107#endif
108