Panda3D

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