feisty meow concerns codebase 2.140
twofish_crypto.cpp
Go to the documentation of this file.
1/*
2* Name : twofish encryption
3* Author : Chris Koeritz
4*****
5* Copyright (c) 2005-$now By Author. This program is free software; you can
6* redistribute it and/or modify it under the terms of the GNU General Public
7* License as published by the Free Software Foundation; either version 2 of
8* the License or (at your option) any later version. This is online at:
9* http://www.fsf.org/copyleft/gpl.html
10* Please send any updates to: fred@gruntose.com
11*/
12
13#include "twofish_crypto.h"
14#include "ssl_init.h"
15
16#include <basis/astring.h>
17#include <basis/functions.h>
18#include <basis/mutex.h>
21#include <mathematics/chaos.h>
23
24#include <openssl/err.h>
25#include <openssl/evp.h>
26
27using namespace basis;
28using namespace loggers;
29using namespace mathematics;
30using namespace structures;
31
32/*
33 Q: is twofish truly requiring 128/192/256 key sizes only?
34 A: no, schneier says any key size up to 256 bits.
35 Q: can twofish really support *any* key length up to 256?
36 A: well, not in openssl. we are getting invalid key length complaints
37 with keys below 92 bits. this was calculated by testing for quite
38 a while with only those size keys, and 92 seems reliable as a minimum.
39*/
40
41namespace crypto {
42
43//#define DEBUG_TWOFISH
44 // uncomment for noisier version.
45#undef ALWAYS_LOG
46#define ALWAYS_LOG(t) CLASS_EMERGENCY_LOG(program_wide_logger::get(), t)
47#ifdef DEBUG_TWOFISH
48 #undef LOG
49 #define LOG(t) CLASS_EMERGENCY_LOG(program_wide_logger::get(), t)
50#else
51 #undef LOG
52 #define LOG(t)
53#endif
54
56: cryptical_envelopment(EVP_aes_256_cbc())
57{
59}
60
62: cryptical_envelopment(EVP_aes_256_cbc())
63{
64 set_key(key, key_size);
65}
66
68: root_object(),
70{
71}
72
76
78{
79 if (this == &to_copy) return *this;
80 *((cryptical_envelopment *)this) = *((cryptical_envelopment *)&to_copy);
81//hmmm: is that the best way to do this?
82 return *this;
83}
84
85} //namespace.
86
A very common template for a dynamic array of bytes.
Definition byte_array.h:36
bool set_key(int key_size)
this will create a new random key of the "key_size", in bits.
twofish_crypto(int key_size)
this will create a new random key of the "key_size", in bits.
twofish_crypto & operator=(const twofish_crypto &to_copy)
The guards collection helps in testing preconditions and reporting errors.
Definition array.h:30
A logger that sends to the console screen using the standard output device.
An extension to floating point primitives providing approximate equality.
Definition averager.h:21
A dynamic container class that holds any kind of object via pointers.
Definition amorph.h:55