00001 #ifndef BLOWFISH_CRYPTO_CLASS 00002 #define BLOWFISH_CRYPTO_CLASS 00003 00004 /*****************************************************************************\ 00005 * * 00006 * Name : blowfish encryption * 00007 * Author : Chris Koeritz * 00008 * * 00009 ******************************************************************************* 00010 * Copyright (c) 2005-$now By Author. This program is free software; you can * 00011 * redistribute it and/or modify it under the terms of the GNU General Public * 00012 * License as published by the Free Software Foundation; either version 2 of * 00013 * the License or (at your option) any later version. This is online at: * 00014 * http://www.fsf.org/copyleft/gpl.html * 00015 * Please send any updates to: fred@gruntose.com * 00016 \*****************************************************************************/ 00017 00018 #include "crypto_dll.h" 00019 00020 #include <basis/object_base.h> 00021 00023 00024 class CRYPTO_CLASS_STYLE blowfish_crypto : public virtual object_base 00025 { 00026 public: 00027 blowfish_crypto(int key_size); 00029 00037 blowfish_crypto(const byte_array &key, int key_size); 00039 00040 blowfish_crypto(const blowfish_crypto &to_copy); 00041 00042 virtual ~blowfish_crypto(); 00043 00044 blowfish_crypto &operator = (const blowfish_crypto &to_copy); 00045 00046 IMPLEMENT_CLASS_NAME("blowfish_crypto"); 00047 00048 int key_size() const; // returns the size of our key, in bits. 00049 00050 static int minimum_key_size(); 00052 static int maximum_key_size(); 00054 00055 const byte_array &get_key() const; 00056 00057 bool set_key(const byte_array &new_key, int key_size); 00059 00060 static void generate_key(int size, byte_array &new_key); 00062 00063 bool encrypt(const byte_array &source, byte_array &target) const; 00065 00066 bool decrypt(const byte_array &source, byte_array &target) const; 00068 00069 // seldom-needed methods... 00070 00071 static const byte_array &init_vector(); 00073 00081 private: 00082 int _key_size; 00083 byte_array *_key; 00084 }; 00085 00086 #endif 00087
1.5.1