forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencryptStream.h
More file actions
109 lines (87 loc) · 3.06 KB
/
encryptStream.h
File metadata and controls
109 lines (87 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file encryptStream.h
* @author drose
* @date 2004-09-01
*/
#ifndef ENCRYPTSTREAM_H
#define ENCRYPTSTREAM_H
#include "dtoolbase.h"
// This module is not compiled if OpenSSL is not available.
#ifdef HAVE_OPENSSL
#include "encryptStreamBuf.h"
/**
* An input stream object that uses OpenSSL to decrypt the input from another
* source stream on-the-fly.
*
* Attach an IDecryptStream to an existing istream that provides encrypted
* data, as generated by an OEncryptStream, and read the corresponding
* unencrypted data from the IDecryptStream.
*
* Seeking is not supported.
*/
class EXPCL_DTOOL_PRC IDecryptStream : public std::istream {
PUBLISHED:
INLINE IDecryptStream();
INLINE explicit IDecryptStream(std::istream *source, bool owns_source,
const std::string &password);
#if _MSC_VER >= 1800
INLINE IDecryptStream(const IDecryptStream ©) = delete;
#endif
INLINE IDecryptStream &open(std::istream *source, bool owns_source,
const std::string &password);
INLINE IDecryptStream &close();
INLINE const std::string &get_algorithm() const;
INLINE int get_key_length() const;
INLINE int get_iteration_count() const;
MAKE_PROPERTY(algorithm, get_algorithm);
MAKE_PROPERTY(key_length, get_key_length);
MAKE_PROPERTY(iteration_count, get_iteration_count);
public:
bool read_magic(const char *magic, size_t size);
private:
EncryptStreamBuf _buf;
};
/**
* An input stream object that uses OpenSSL to encrypt data to another
* destination stream on-the-fly.
*
* Attach an OEncryptStream to an existing ostream that will accept encrypted
* data, and write your unencrypted source data to the OEncryptStream.
*
* Seeking is not supported.
*/
class EXPCL_DTOOL_PRC OEncryptStream : public std::ostream {
PUBLISHED:
INLINE OEncryptStream();
INLINE explicit OEncryptStream(std::ostream *dest, bool owns_dest,
const std::string &password);
#if _MSC_VER >= 1800
INLINE OEncryptStream(const OEncryptStream ©) = delete;
#endif
INLINE OEncryptStream &open(std::ostream *dest, bool owns_dest,
const std::string &password);
INLINE OEncryptStream &close();
public:
INLINE const std::string &get_algorithm() const;
INLINE int get_key_length() const;
INLINE int get_iteration_count() const;
PUBLISHED:
INLINE void set_algorithm(const std::string &algorithm);
INLINE void set_key_length(int key_length);
INLINE void set_iteration_count(int iteration_count);
MAKE_PROPERTY(algorithm, get_algorithm, set_algorithm);
MAKE_PROPERTY(key_length, get_key_length, set_key_length);
MAKE_PROPERTY(iteration_count, get_iteration_count, set_iteration_count);
private:
EncryptStreamBuf _buf;
};
#include "encryptStream.I"
#endif // HAVE_OPENSSL
#endif