Panda3D
 All Classes Functions Variables Enumerations
encryptStream.h
1 // Filename: encryptStream.h
2 // Created by: drose (01Sep04)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef ENCRYPTSTREAM_H
16 #define ENCRYPTSTREAM_H
17 
18 #include "dtoolbase.h"
19 
20 // This module is not compiled if OpenSSL is not available.
21 #ifdef HAVE_OPENSSL
22 
23 #include "encryptStreamBuf.h"
24 
25 ////////////////////////////////////////////////////////////////////
26 // Class : IDecryptStream
27 // Description : An input stream object that uses OpenSSL to decrypt
28 // the input from another source stream on-the-fly.
29 //
30 // Attach an IDecryptStream to an existing istream that
31 // provides encrypted data, as generated by an
32 // OEncryptStream, and read the corresponding
33 // unencrypted data from the IDecryptStream.
34 //
35 // Seeking is not supported.
36 ////////////////////////////////////////////////////////////////////
37 class EXPCL_DTOOLCONFIG IDecryptStream : public istream {
38 PUBLISHED:
39  INLINE IDecryptStream();
40  INLINE IDecryptStream(istream *source, bool owns_source,
41  const string &password);
42 
43  INLINE IDecryptStream &open(istream *source, bool owns_source,
44  const string &password);
45  INLINE IDecryptStream &close();
46 
47  INLINE const string &get_algorithm() const;
48  INLINE int get_key_length() const;
49  INLINE int get_iteration_count() const;
50 
51 private:
52  EncryptStreamBuf _buf;
53 };
54 
55 ////////////////////////////////////////////////////////////////////
56 // Class : OEncryptStream
57 // Description : An input stream object that uses OpenSSL to encrypt
58 // data to another destination stream on-the-fly.
59 //
60 // Attach an OEncryptStream to an existing ostream that
61 // will accept encrypted data, and write your
62 // unencrypted source data to the OEncryptStream.
63 //
64 // Seeking is not supported.
65 ////////////////////////////////////////////////////////////////////
66 class EXPCL_DTOOLCONFIG OEncryptStream : public ostream {
67 PUBLISHED:
68  INLINE OEncryptStream();
69  INLINE OEncryptStream(ostream *dest, bool owns_dest,
70  const string &password);
71 
72  INLINE OEncryptStream &open(ostream *dest, bool owns_dest,
73  const string &password);
74  INLINE OEncryptStream &close();
75 
76  INLINE void set_algorithm(const string &algorithm);
77  INLINE void set_key_length(int key_length);
78  INLINE void set_iteration_count(int iteration_count);
79 
80 private:
81  EncryptStreamBuf _buf;
82 };
83 
84 #include "encryptStream.I"
85 
86 #endif // HAVE_OPENSSL
87 
88 
89 #endif
90 
91