Panda3D
 All Classes Functions Variables Enumerations
encryptStream.h
00001 // Filename: encryptStream.h
00002 // Created by:  drose (01Sep04)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef ENCRYPTSTREAM_H
00016 #define ENCRYPTSTREAM_H
00017 
00018 #include "dtoolbase.h"
00019 
00020 // This module is not compiled if OpenSSL is not available.
00021 #ifdef HAVE_OPENSSL
00022 
00023 #include "encryptStreamBuf.h"
00024 
00025 ////////////////////////////////////////////////////////////////////
00026 //       Class : IDecryptStream
00027 // Description : An input stream object that uses OpenSSL to decrypt
00028 //               the input from another source stream on-the-fly.
00029 //
00030 //               Attach an IDecryptStream to an existing istream that
00031 //               provides encrypted data, as generated by an
00032 //               OEncryptStream, and read the corresponding
00033 //               unencrypted data from the IDecryptStream.
00034 //
00035 //               Seeking is not supported.
00036 ////////////////////////////////////////////////////////////////////
00037 class EXPCL_DTOOLCONFIG IDecryptStream : public istream {
00038 PUBLISHED:
00039   INLINE IDecryptStream();
00040   INLINE IDecryptStream(istream *source, bool owns_source,
00041                         const string &password);
00042 
00043   INLINE IDecryptStream &open(istream *source, bool owns_source,
00044                               const string &password);
00045   INLINE IDecryptStream &close();
00046 
00047   INLINE const string &get_algorithm() const;
00048   INLINE int get_key_length() const;
00049   INLINE int get_iteration_count() const;
00050 
00051 private:
00052   EncryptStreamBuf _buf;
00053 };
00054 
00055 ////////////////////////////////////////////////////////////////////
00056 //       Class : OEncryptStream
00057 // Description : An input stream object that uses OpenSSL to encrypt
00058 //               data to another destination stream on-the-fly.
00059 //
00060 //               Attach an OEncryptStream to an existing ostream that
00061 //               will accept encrypted data, and write your
00062 //               unencrypted source data to the OEncryptStream.
00063 //
00064 //               Seeking is not supported.
00065 ////////////////////////////////////////////////////////////////////
00066 class EXPCL_DTOOLCONFIG OEncryptStream : public ostream {
00067 PUBLISHED:
00068   INLINE OEncryptStream();
00069   INLINE OEncryptStream(ostream *dest, bool owns_dest, 
00070                         const string &password);
00071 
00072   INLINE OEncryptStream &open(ostream *dest, bool owns_dest, 
00073                               const string &password);
00074   INLINE OEncryptStream &close();
00075 
00076   INLINE void set_algorithm(const string &algorithm);
00077   INLINE void set_key_length(int key_length);
00078   INLINE void set_iteration_count(int iteration_count);
00079 
00080 private:
00081   EncryptStreamBuf _buf;
00082 };
00083 
00084 #include "encryptStream.I"
00085 
00086 #endif  // HAVE_OPENSSL
00087 
00088 
00089 #endif
00090 
00091 
 All Classes Functions Variables Enumerations