idea.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley/* crypto/idea/idea.h */
70e5a7403f0e0a3bd292b8287c5fed5772c15270Automatic Updater/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * All rights reserved.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence *
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater * This package is an SSL implementation written
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley * by Eric Young (eay@cryptsoft.com).
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley * The implementation was written so as to conform with Netscapes SSL.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence *
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * This library is free for commercial and non-commercial use as long as
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * the following conditions are aheared to. The following conditions
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * apply to all code found in this distribution, be it the RC4, RSA,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * lhash, DES, etc., code; not just the SSL code. The SSL documentation
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * included with this distribution is covered by the same copyright terms
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * except that the holder is Tim Hudson (tjh@cryptsoft.com).
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews *
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley * Copyright remains Eric Young's, and as such any Copyright notices in
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley * the code are not to be removed.
70e5a7403f0e0a3bd292b8287c5fed5772c15270Automatic Updater * If this package is used in a product, Eric Young should be given attribution
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence * as the author of the parts of the library used.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein * This can be in the form of a textual message at program startup or
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein * in documentation (online or textual) provided with the package.
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley *
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley * Redistribution and use in source and binary forms, with or without
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley * modification, are permitted provided that the following conditions
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley * are met:
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley * 1. Redistributions of source code must retain the copyright
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley * notice, this list of conditions and the following disclaimer.
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley * 2. Redistributions in binary form must reproduce the above copyright
d95e6b2631a1cb164480c5bce91b2d4e2aee4689Michael Graff * notice, this list of conditions and the following disclaimer in the
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley * documentation and/or other materials provided with the distribution.
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence * 3. All advertising materials mentioning features or use of this software
d95e6b2631a1cb164480c5bce91b2d4e2aee4689Michael Graff * must display the following acknowledgement:
d95e6b2631a1cb164480c5bce91b2d4e2aee4689Michael Graff * "This product includes cryptographic software written by
d95e6b2631a1cb164480c5bce91b2d4e2aee4689Michael Graff * Eric Young (eay@cryptsoft.com)"
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley * The word 'cryptographic' can be left out if the rouines from the library
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley * being used are not cryptographic related :-).
d95e6b2631a1cb164480c5bce91b2d4e2aee4689Michael Graff * 4. If you include any Windows specific code (or a derivative thereof) from
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley * the apps directory (application code) you must include an acknowledgement:
558ab0f6a8046499bfe3e39ea4789036313b72b3Michael Graff * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
d95e6b2631a1cb164480c5bce91b2d4e2aee4689Michael Graff *
de4ef688d73a449d4c1218adbb35a4f70a71e672Brian Wellington * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
d95e6b2631a1cb164480c5bce91b2d4e2aee4689Michael Graff * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37392bc121176d7f5ae6ae44769642bd66d52d0eBob Halley * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37392bc121176d7f5ae6ae44769642bd66d52d0eBob Halley * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley * SUCH DAMAGE.
e44487bfc23599b6b240e09d83d1c862fecfcc82Michael Graff *
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley * The licence and distribution terms for any publically available version or
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley * derivative of this code cannot be changed. i.e. this code cannot simply be
95b41befcb9e75df2b451ceeb9f8812ccedcc25fAndreas Gustafsson * copied and put under another distribution licence
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley * [including the GNU Public Licence.]
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley */
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley#ifndef HEADER_IDEA_H
37392bc121176d7f5ae6ae44769642bd66d52d0eBob Halley#define HEADER_IDEA_H
37392bc121176d7f5ae6ae44769642bd66d52d0eBob Halley
37392bc121176d7f5ae6ae44769642bd66d52d0eBob Halley#ifdef OPENSSL_NO_IDEA
37392bc121176d7f5ae6ae44769642bd66d52d0eBob Halley#error IDEA is disabled.
e605e98f3e4be079f545b26bb53ba02a6d04b0b6Andreas Gustafsson#endif
bd75e751a718e3dc17b288fa288700ee574c8dc4Andreas Gustafsson
bd75e751a718e3dc17b288fa288700ee574c8dc4Andreas Gustafsson#define IDEA_ENCRYPT 1
37392bc121176d7f5ae6ae44769642bd66d52d0eBob Halley#define IDEA_DECRYPT 0
37392bc121176d7f5ae6ae44769642bd66d52d0eBob Halley
37392bc121176d7f5ae6ae44769642bd66d52d0eBob Halley#include <openssl/opensslconf.h> /* IDEA_INT */
e44487bfc23599b6b240e09d83d1c862fecfcc82Michael Graff#define IDEA_BLOCK 8
37392bc121176d7f5ae6ae44769642bd66d52d0eBob Halley#define IDEA_KEY_LENGTH 16
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley#ifdef __cplusplus
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halleyextern "C" {
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley#endif
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halleytypedef struct idea_key_st
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley {
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley IDEA_INT data[9][6];
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley } IDEA_KEY_SCHEDULE;
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halleyconst char *idea_options(void);
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halleyvoid idea_ecb_encrypt(const unsigned char *in, unsigned char *out,
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley IDEA_KEY_SCHEDULE *ks);
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halleyvoid idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks);
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halleyvoid idea_set_decrypt_key(IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk);
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halleyvoid idea_cbc_encrypt(const unsigned char *in, unsigned char *out,
558ab0f6a8046499bfe3e39ea4789036313b72b3Michael Graff long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,int enc);
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halleyvoid idea_cfb64_encrypt(const unsigned char *in, unsigned char *out,
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley int *num,int enc);
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halleyvoid idea_ofb64_encrypt(const unsigned char *in, unsigned char *out,
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, int *num);
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halleyvoid idea_encrypt(unsigned long *in, IDEA_KEY_SCHEDULE *ks);
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley#ifdef __cplusplus
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley}
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley#endif
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley#endif
d42634d8a376d5e51330451d22e35d5cfb262ec3Bob Halley