forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencryptStream.I
More file actions
177 lines (159 loc) · 4.23 KB
/
encryptStream.I
File metadata and controls
177 lines (159 loc) · 4.23 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/**
* 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.I
* @author drose
* @date 2004-09-01
*/
/**
*
*/
INLINE IDecryptStream::
IDecryptStream() : std::istream(&_buf) {
}
/**
*
*/
INLINE IDecryptStream::
IDecryptStream(std::istream *source, bool owns_source,
const std::string &password) : std::istream(&_buf) {
open(source, owns_source, password);
}
/**
*
*/
INLINE IDecryptStream &IDecryptStream::
open(std::istream *source, bool owns_source, const std::string &password) {
clear((ios_iostate)0);
_buf.open_read(source, owns_source, password);
return *this;
}
/**
* Resets the EncryptStream to empty, but does not actually close the source
* istream unless owns_source was true.
*/
INLINE IDecryptStream &IDecryptStream::
close() {
_buf.close_read();
return *this;
}
/**
* Returns the encryption algorithm that was read from the stream.
*/
INLINE const std::string &IDecryptStream::
get_algorithm() const {
return _buf.get_algorithm();
}
/**
* Returns the encryption key length, in bits, that was read from the stream.
*/
INLINE int IDecryptStream::
get_key_length() const {
return _buf.get_key_length();
}
/**
* Returns the value that was was read from the stream.
*/
INLINE int IDecryptStream::
get_iteration_count() const {
return _buf.get_iteration_count();
}
/**
*
*/
INLINE OEncryptStream::
OEncryptStream() : std::ostream(&_buf) {
}
/**
*
*/
INLINE OEncryptStream::
OEncryptStream(std::ostream *dest, bool owns_dest, const std::string &password) :
std::ostream(&_buf)
{
open(dest, owns_dest, password);
}
/**
*
*/
INLINE OEncryptStream &OEncryptStream::
open(std::ostream *dest, bool owns_dest, const std::string &password) {
clear((ios_iostate)0);
_buf.open_write(dest, owns_dest, password);
return *this;
}
/**
* Resets the EncryptStream to empty, but does not actually close the dest
* ostream unless owns_dest was true.
*/
INLINE OEncryptStream &OEncryptStream::
close() {
_buf.close_write();
return *this;
}
/**
* Returns the encryption algorithm that was read from the stream.
*/
INLINE const std::string &OEncryptStream::
get_algorithm() const {
return _buf.get_algorithm();
}
/**
* Returns the encryption key length, in bits, that was read from the stream.
*/
INLINE int OEncryptStream::
get_key_length() const {
return _buf.get_key_length();
}
/**
* Returns the value that was was read from the stream.
*/
INLINE int OEncryptStream::
get_iteration_count() const {
return _buf.get_iteration_count();
}
/**
* Specifies the encryption algorithm that should be used for future calls to
* open(). The default is whatever is specified by the encryption-algorithm
* config variable. The complete set of available algorithms is defined by
* the current version of OpenSSL.
*
* If an invalid algorithm is specified, there is no immediate error return
* code, but open() will fail.
*/
INLINE void OEncryptStream::
set_algorithm(const std::string &algorithm) {
_buf.set_algorithm(algorithm);
}
/**
* Specifies the length of the key, in bits, that should be used to encrypt
* the stream in future calls to open(). The default is whatever is specified
* by the encryption-key-length config variable.
*
* If an invalid key_length for the chosen algorithm is specified, there is no
* immediate error return code, but open() will fail.
*/
INLINE void OEncryptStream::
set_key_length(int key_length) {
_buf.set_key_length(key_length);
}
/**
* Specifies the number of times to repeatedly hash the key before writing it
* to the stream in future calls to open(). Its purpose is to make it
* computationally more expensive for an attacker to search the key space
* exhaustively. This should be a multiple of 1,000 and should not exceed
* about 65 million; the value 0 indicates just one application of the hashing
* algorithm.
*
* The default is whatever is specified by the encryption-iteration-count
* config variable.
*/
INLINE void OEncryptStream::
set_iteration_count(int iteration_count) {
_buf.set_iteration_count(iteration_count);
}