HDK
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
UT_Blowfish.h
Go to the documentation of this file.
1
/*
2
* PROPRIETARY INFORMATION. This software is proprietary to
3
* Side Effects Software Inc., and is not to be reproduced,
4
* transmitted, or disclosed in any way without written permission.
5
*
6
* NAME: UT_Blowfish.h ( Library, C++)
7
*
8
* COMMENTS:
9
* Based on a free source code from:
10
* http://www.schneier.com/blowfish.html
11
* http://www.schneier.com/blowfish-download.html
12
*
13
* blowfish.h interface file for blowfish.cpp
14
* _THE BLOWFISH ENCRYPTION ALGORITHM_
15
* by Bruce Schneier
16
* Revised code--3/20/94
17
* Converted to C++ class 5/96, Jim Conger
18
*/
19
20
#ifndef __UT_Blowfish__
21
#define __UT_Blowfish__
22
23
#include "
UT_API.h
"
24
#include <
SYS/SYS_Types.h
>
25
26
27
// the size of the s-box used by the blofish:
28
#define UT_BLOWFISH_SBOX_SIZE 256
29
30
31
class
UT_API
UT_Blowfish
32
{
33
public
:
34
// Construct an encryptor/decryptor object with a given secret key.
35
UT_Blowfish
(
const
uint8
key[],
int
key_size );
36
~
UT_Blowfish
();
37
38
UT_Blowfish
(
const
UT_Blowfish
&) =
delete
;
39
UT_Blowfish
&
operator=
(
const
UT_Blowfish
&) =
delete
;
40
41
// Get the amount of memory owned by this UT_Blowfish object
42
int64
getMemoryUsage(
bool
inclusive)
const
;
43
44
// Get output cipher length given the input message length. The output
45
// cipher length must be divisible by 8 because it consists of 64-bit blocks
46
// (8 bytes x 8 bits = 64 bit block).
47
static
int
getEncryptionOutputSize(
int
input_size );
48
49
// Gets the maximum data chunk size on which the algorithm can work and that
50
// is no larger than the specifies 'max_buffer_size'. This is a convenience
51
// method that returns the size that is the multiple of the block size.
52
static
int
getCryptBufferSize(
int
max_buffer_size );
53
54
// Gets the block size. The alogrithm will work on sizes that are multiples
55
// of the block size.
56
static
int
getBlockSize();
57
58
// Eencrypt input into output. Input length is input_size. Returned value
59
// is length of output (which will be divisible by 8 bytes).
60
// Input and output buffers can be the same, but be sure buffer length
61
// is divisible by 8, so that it can contain the output cipher.
62
int
encrypt(
const
uint8
* input,
uint8
* output,
63
int
input_size );
64
65
// Decrypt input into output. Input length in input_size (and is divisible
66
// by 8, since it contains a number of 64-bit (8-byte) blocks).
67
// Input and output buffer can be the same. The length of output buffer must
68
// be the same as (or larger than) the input buffer. The amount of data
69
// in the output buffer is the same as 'input_size'.
70
// Returns true if all is OK; false if errors occured
71
bool
decrypt(
const
uint8
* input,
uint8
* output,
72
int
input_size );
73
74
75
private
:
76
// Constructs the enctryption sieve using the secret key.
77
void
initialize
(
const
uint8
key[],
int
key_size );
78
79
// Encrypts the 64-bit block that has been split into left and right 32-bit
80
// halves. The encrypted cipher replaces the original data in the block.
81
void
encipherBlock(
uint32
*xl,
uint32
*xr );
82
83
// Decrypts the 64-bit block that has been split into left and right 32-bit
84
// halves. The decrypted text replaces the original cipher in the block.
85
void
decipherBlock(
uint32
*xl,
uint32
*xr );
86
87
// Encrypts the 64-bit block from the input source into the destination
88
// output. The source and destination can be the same. The pointers
89
// point to an 8-byte (64-bit) memory chunk.
90
void
encipherBlock(
const
uint8
*input,
uint8
*output );
91
92
// Decrypts the 64-bit block from the input source into the destination
93
// output. The source and destination can be the same. The pointers
94
// point to an 8-byte (64-bit) memory chunk.
95
void
decipherBlock(
const
uint8
*input,
uint8
*output );
96
97
// Array (p-array) containing the subkeys used for xor'ing block's xL half.
98
uint32
*myPArray;
99
100
// Lookup tables (S-boxes) that implement non-reversible function F.
101
uint32
(*mySBoxes)[
UT_BLOWFISH_SBOX_SIZE
];
102
};
103
104
#endif // __UT_Blowfish__
105
106
107
UT_API.h
UT_API
#define UT_API
Definition:
UT_API.h:14
uint8
unsigned char uint8
Definition:
SYS_Types.h:36
SYS_Types.h
UT_Blowfish
Definition:
UT_Blowfish.h:31
int64
long long int64
Definition:
SYS_Types.h:116
openvdb::OPENVDB_VERSION_NAME::initialize
OPENVDB_API void initialize()
Global registration of native Grid, Transform, Metadata and Point attribute types. Also initializes blosc (if enabled).
Definition:
logging.h:294
nanovdb::operator=
LeafData & operator=(const LeafData &)=delete
UT_BLOWFISH_SBOX_SIZE
#define UT_BLOWFISH_SBOX_SIZE
Definition:
UT_Blowfish.h:28
uint32
unsigned int uint32
Definition:
SYS_Types.h:40
UT
UT_Blowfish.h
Generated on Sun Nov 17 2024 03:03:40 for HDK by
1.8.6