first check-in of feisty meow codebase. many things broken still due to recent
[feisty_meow.git] / core / library / crypto / ssl_init.h
1 #ifndef SSL_INIT_CLASS
2 #define SSL_INIT_CLASS
3
4 /*****************************************************************************\
5 *                                                                             *
6 *  Name   : SSL initialization helper                                         *
7 *  Author : Chris Koeritz                                                     *
8 *                                                                             *
9 *******************************************************************************
10 * Copyright (c) 2005-$now By Author.  This program is free software; you can  *
11 * redistribute it and/or modify it under the terms of the GNU General Public  *
12 * License as published by the Free Software Foundation; either version 2 of   *
13 * the License or (at your option) any later version.  This is online at:      *
14 *     http://www.fsf.org/copyleft/gpl.html                                    *
15 * Please send any updates to: fred@gruntose.com                               *
16 \*****************************************************************************/
17
18 #include <basis/byte_array.h>
19 #include <mathematics/chaos.h>
20
21 namespace crypto {
22
23 //! provides some initialization for the RSA and blowfish crypto.
24 /*!
25   This class does the SSL initialization needed before any functions can
26   be used.  It also sets up the random seed for SSL.  NOTE: you should never
27   need to use this class directly; just use the accessor function at the
28   very bottom and it will be managed globally for the entire program.
29 */
30
31 class ssl_init : public virtual basis::nameable
32 {
33 public:
34   ssl_init();
35   ~ssl_init();
36
37   DEFINE_CLASS_NAME("ssl_init");
38
39   basis::byte_array random_bytes(int length) const;
40     //!< can be used to generate a random array of "length" bytes.
41
42   const mathematics::chaos &randomizer() const;
43     //!< provides a random number generator for any encryption routines.
44
45 private:
46   mathematics::chaos c_rando;  //!< used for generating random numbers.
47 };
48
49 extern const ssl_init &static_ssl_initializer();
50   //!< the main method for accessing the SSL initialization support.
51
52 } //namespace.
53
54 #endif
55