Panda3D

Loading...
Searching...
No Matches
encryptStream.I
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file encryptStream.I
10 * @author drose
11 * @date 2004-09-01
12 */
13
14/**
15 *
16 */
17INLINE IDecryptStream::
18IDecryptStream() : std::istream(&_buf) {
19}
20
21/**
22 *
23 */
24INLINE IDecryptStream::
25IDecryptStream(std::istream *source, bool owns_source,
26 const std::string &password) : std::istream(&_buf) {
27 open(source, owns_source, password);
28}
29
30/**
31 *
32 */
33INLINE IDecryptStream &IDecryptStream::
34open(std::istream *source, bool owns_source, const std::string &password) {
35 clear((ios_iostate)0);
36 _buf.open_read(source, owns_source, password);
37 return *this;
38}
39
40/**
41 * Resets the EncryptStream to empty, but does not actually close the source
42 * istream unless owns_source was true.
43 */
44INLINE IDecryptStream &IDecryptStream::
45close() {
46 _buf.close_read();
47 return *this;
48}
49
50/**
51 * Returns the encryption algorithm that was read from the stream.
52 */
53INLINE const std::string &IDecryptStream::
54get_algorithm() const {
55 return _buf.get_algorithm();
56}
57
58/**
59 * Returns the encryption key length, in bits, that was read from the stream.
60 */
61INLINE int IDecryptStream::
62get_key_length() const {
63 return _buf.get_key_length();
64}
65
66/**
67 * Returns the value that was was read from the stream.
68 */
69INLINE int IDecryptStream::
70get_iteration_count() const {
71 return _buf.get_iteration_count();
72}
73
74
75/**
76 *
77 */
78INLINE OEncryptStream::
79OEncryptStream() : std::ostream(&_buf) {
80}
81
82/**
83 *
84 */
85INLINE OEncryptStream::
86OEncryptStream(std::ostream *dest, bool owns_dest, const std::string &password) :
87 std::ostream(&_buf)
88{
89 open(dest, owns_dest, password);
90}
91
92/**
93 *
94 */
95INLINE OEncryptStream &OEncryptStream::
96open(std::ostream *dest, bool owns_dest, const std::string &password) {
97 clear((ios_iostate)0);
98 _buf.open_write(dest, owns_dest, password);
99 return *this;
100}
101
102/**
103 * Resets the EncryptStream to empty, but does not actually close the dest
104 * ostream unless owns_dest was true.
105 */
106INLINE OEncryptStream &OEncryptStream::
107close() {
108 _buf.close_write();
109 return *this;
110}
111
112/**
113 * Returns the encryption algorithm that was read from the stream.
114 */
115INLINE const std::string &OEncryptStream::
116get_algorithm() const {
117 return _buf.get_algorithm();
118}
119
120/**
121 * Returns the encryption key length, in bits, that was read from the stream.
122 */
123INLINE int OEncryptStream::
124get_key_length() const {
125 return _buf.get_key_length();
126}
127
128/**
129 * Returns the value that was was read from the stream.
130 */
131INLINE int OEncryptStream::
132get_iteration_count() const {
133 return _buf.get_iteration_count();
134}
135
136/**
137 * Specifies the encryption algorithm that should be used for future calls to
138 * open(). The default is whatever is specified by the encryption-algorithm
139 * config variable. The complete set of available algorithms is defined by
140 * the current version of OpenSSL.
141 *
142 * If an invalid algorithm is specified, there is no immediate error return
143 * code, but open() will fail.
144 */
145INLINE void OEncryptStream::
146set_algorithm(const std::string &algorithm) {
147 _buf.set_algorithm(algorithm);
148}
149
150/**
151 * Specifies the length of the key, in bits, that should be used to encrypt
152 * the stream in future calls to open(). The default is whatever is specified
153 * by the encryption-key-length config variable.
154 *
155 * If an invalid key_length for the chosen algorithm is specified, there is no
156 * immediate error return code, but open() will fail.
157 */
158INLINE void OEncryptStream::
159set_key_length(int key_length) {
160 _buf.set_key_length(key_length);
161}
162
163/**
164 * Specifies the number of times to repeatedly hash the key before writing it
165 * to the stream in future calls to open(). Its purpose is to make it
166 * computationally more expensive for an attacker to search the key space
167 * exhaustively. This should be a multiple of 1,000 and should not exceed
168 * about 65 million; the value 0 indicates just one application of the hashing
169 * algorithm.
170 *
171 * The default is whatever is specified by the encryption-iteration-count
172 * config variable.
173 */
174INLINE void OEncryptStream::
175set_iteration_count(int iteration_count) {
176 _buf.set_iteration_count(iteration_count);
177}
istream
STL class.
ostream
STL class.
std
STL namespace.