Panda3D
encryptStreamBuf.I
1 // Filename: encryptStreamBuf.I
2 // Created by: drose (09Dec04)
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 
16 ////////////////////////////////////////////////////////////////////
17 // Function: EncryptStreamBuf::set_algorithm
18 // Access: Public
19 // Description: Specifies the encryption algorithm that should be
20 // used for future calls to open_write(). The default
21 // is whatever is specified by the encryption-algorithm
22 // config variable. The complete set of available
23 // algorithms is defined by the current version of
24 // OpenSSL.
25 //
26 // If an invalid algorithm is specified, there is no
27 // immediate error return code, but open_write() will
28 // fail.
29 ////////////////////////////////////////////////////////////////////
30 INLINE void EncryptStreamBuf::
31 set_algorithm(const string &algorithm) {
32  _algorithm = algorithm;
33 }
34 
35 ////////////////////////////////////////////////////////////////////
36 // Function: EncryptStreamBuf::get_algorithm
37 // Access: Public
38 // Description: Returns the encryption algorithm that was specified
39 // by set_algorithm(), or was read from the stream by
40 // the last successful open_read().
41 ////////////////////////////////////////////////////////////////////
42 INLINE const string &EncryptStreamBuf::
43 get_algorithm() const {
44  return _algorithm;
45 }
46 
47 ////////////////////////////////////////////////////////////////////
48 // Function: EncryptStreamBuf::set_key_length
49 // Access: Public
50 // Description: Specifies the length of the key, in bits, that should
51 // be used to encrypt the stream in future calls to
52 // open_write(). The default is whatever is specified
53 // by the encryption-key-length config variable.
54 //
55 // If an invalid key_length for the chosen algorithm is
56 // specified, there is no immediate error return code,
57 // but open_write() will fail.
58 ////////////////////////////////////////////////////////////////////
59 INLINE void EncryptStreamBuf::
60 set_key_length(int key_length) {
61  _key_length = key_length;
62 }
63 
64 ////////////////////////////////////////////////////////////////////
65 // Function: EncryptStreamBuf::get_key_length
66 // Access: Public
67 // Description: Returns the encryption key length, in bits, that was
68 // specified by set_key_length(), or was read from the
69 // stream by the last successful open_read().
70 ////////////////////////////////////////////////////////////////////
71 INLINE int EncryptStreamBuf::
72 get_key_length() const {
73  return _key_length;
74 }
75 
76 ////////////////////////////////////////////////////////////////////
77 // Function: EncryptStreamBuf::set_iteration_count
78 // Access: Public
79 // Description: Specifies the number of times to repeatedly hash the
80 // key before writing it to the stream in future calls
81 // to open_write(). Its purpose is to make it
82 // computationally more expensive for an attacker to
83 // search the key space exhaustively. This should be a
84 // multiple of 1,000 and should not exceed about 65
85 // million; the value 0 indicates just one application
86 // of the hashing algorithm.
87 //
88 // The default is whatever is specified by the
89 // encryption-iteration-count config variable.
90 ////////////////////////////////////////////////////////////////////
91 INLINE void EncryptStreamBuf::
92 set_iteration_count(int iteration_count) {
93  _iteration_count = iteration_count;
94 }
95 
96 ////////////////////////////////////////////////////////////////////
97 // Function: EncryptStreamBuf::get_iteration_count
98 // Access: Public
99 // Description: Returns the value that was specified by
100 // set_iteration_count(), or was read from the stream by
101 // the last successful open_read().
102 ////////////////////////////////////////////////////////////////////
103 INLINE int EncryptStreamBuf::
104 get_iteration_count() const {
105  return _iteration_count;
106 }