ice_key.h

Go to the documentation of this file.
00001 #ifndef ICE_KEY_CLASS
00002 #define ICE_KEY_CLASS
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : ice_key                                                           *
00007 *  Author : Matthew Kwan  (http://www.cs.mu.oz.au/~mkwan/ice)                 *
00008 *  Mods   : Chris Koeritz                                                     *
00009 *                                                                             *
00010 *******************************************************************************
00011 * Copyright (c) 1996-$now By Author.  This program is free software; you can  *
00012 * redistribute it and/or modify it under the terms of the GNU General Public  *
00013 * License as published by the Free Software Foundation; either version 2 of   *
00014 * the License or (at your option) any later version.  This is online at:      *
00015 *     http://www.fsf.org/copyleft/gpl.html                                    *
00016 * Please send any updates to: fred@gruntose.com                               *
00017 \*****************************************************************************/
00018 
00019 #include "crypto_dll.h"
00020 
00021 #include <basis/object_base.h>
00022 
00023 // forward.
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   // not permitted.
00101   ice_key(const ice_key &);
00102   ice_key &operator =(const ice_key &);
00103 };
00104 
00105 #endif
00106 

Generated on Fri Nov 21 04:29:40 2008 for HOOPLE Libraries by  doxygen 1.5.1