00001 #ifndef ICE_KEY_CLASS
00002 #define ICE_KEY_CLASS
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "crypto_dll.h"
00020
00021 #include <basis/object_base.h>
00022
00023
00024 class ice_subkey;
00025
00027
00032 class CRYPTO_CLASS_STYLE ice_key : public virtual object_base
00033 {
00034 public:
00035 ice_key(int blocks, bool randomize = true);
00037
00043 virtual ~ice_key();
00044
00045 IMPLEMENT_CLASS_NAME("ice_key");
00046
00047 bool set(const byte_array &key);
00049
00053 bool encrypt(const byte_array &plain_text, byte_array &cipher_text) const;
00055
00058 bool decrypt(const byte_array &cipher_text, byte_array &plain_text) const;
00060
00063 int key_size() const { return _size * 8; }
00065 int blocks() const { return _size; }
00067 int block_size() const { return 8; }
00069
00070 private:
00071 int _size;
00072 int _rounds;
00073 ice_subkey *_keysched;
00074 bool _key_set;
00075 chaos *_randomizer;
00076 bool _randomize;
00077
00078 typedef byte code_granule[8];
00079
00080 byte_array int_to_bytes(u_int to_encode) const;
00082
00083 u_int bytes_to_int(const byte_array &to_decode) const;
00085
00086 void encrypt_eight(const code_granule &plain_text,
00087 code_granule &cipher_text) const;
00089
00090 void decrypt_eight(const code_granule &cipher_text,
00091 code_granule &plain_text) const;
00093
00094 void schedule_build(unsigned short *k, int n, const int *keyrot);
00096
00097 static void initialize_ice_sboxes();
00099
00100
00101 ice_key(const ice_key &);
00102 ice_key &operator =(const ice_key &);
00103 };
00104
00105 #endif
00106