#include <blowfish.h>
|
| static constexpr size_type | getOutputLength (size_type length) |
| | Get length of required output buffer. More...
|
| |
| static std::string | to_hex (const uint8_t *bytes, size_type length) |
| | Translate some bytes into their hexadecimal representation. More...
|
| |
| static std::string | to_hex (const std::string &input) |
| | Convert a string to its hexadecimal representation. More...
|
| |
| static std::string | from_hex (const std::string &digits) |
| | Translate hexadecimal into a string. More...
|
| |
◆ PArray
◆ SBoxes
◆ size_type
◆ Action
| Enumerator |
|---|
| Encrypt | |
| Decrypt | |
◆ BlowFish() [1/2]
| BlowFish::BlowFish |
( |
const uint8_t * |
key, |
|
|
size_type |
key_length |
|
) |
| |
Initialize BlowFish cipher.
- Parameters
-
| key | The cipher encryption/decryption key. |
| key_length | The length of the key, in bytes. |
◆ BlowFish() [2/2]
| BlowFish::BlowFish |
( |
const std::string & |
key | ) |
|
Initialize the BlowFish cipher.
- Parameters
-
| key | The key. The entire string is used, regardless of whitespace and nulls. |
◆ decipher()
| void BlowFish::decipher |
( |
uint32_t * |
left_32, |
|
|
uint32_t * |
right_32 |
|
) |
| const |
|
private |
Decipher a 64-bit block.
- Parameters
-
| left_32 | First 32 bits, in host byte (mathy) order. |
| right_32 | Second 32 bits, in host byte (mathy) order. |
◆ decrypt() [1/2]
| std::string BlowFish::decrypt |
( |
const std::string & |
input | ) |
const |
Decipher ciphertext encrypted with Blowfish ECD.
- Parameters
-
| input | The ciphertext to decipher. |
- Returns
- The deciphered message. Any nulls added during encryption to pad the message to the necessary 64-bit/8-byte boundary are included.
- Warning
- There is no error checking. If you have the wrong key, you'll get junk out. There is no inherent error detection or validation.
◆ decrypt() [2/2]
| void BlowFish::decrypt |
( |
const uint8_t * |
input, |
|
|
size_type |
input_length, |
|
|
uint8_t * |
output, |
|
|
size_type |
output_size |
|
) |
| const |
|
inline |
Decipher a BlowFish ECD message.
- Parameters
-
| input | The ciphertext. |
| input_length | The length of the message. This should be a multiple of 8, as all enciphered messages end up a multiple of 8 bytes. Truncated messages will decipher incorrectly. |
| output | A buffer for the resulting message. This may be the same as the input to encrypt in place. |
| output_size | The size of the output. This must be large enough to accommodate any added padding. |
◆ decryptFromHex()
| std::string BlowFish::decryptFromHex |
( |
const std::string & |
input, |
|
|
bool |
trim_nulls = true |
|
) |
| const |
Decrypt hex-encoded ciphertext and return it, optionally removing null padding that was added.
Whitespace or punctuation in the input are skipped.
- Parameters
-
| input | The ciphertext. |
| trim_nulls | If true, any trailing nulls are removed. |
- Returns
- If the key is correct, the deciphered message. If not, junk.
- Exceptions
-
| invalid_argument | If the ciphertext has non-hex letters in it. |
◆ encipher()
| void BlowFish::encipher |
( |
uint32_t * |
left_32, |
|
|
uint32_t * |
right_32 |
|
) |
| const |
|
private |
Encipher a 64-bit block.
- Parameters
-
| left_32 | First 32 bits, in host byte (mathy) order. |
| right_32 | Second 32 bits, in host byte (mathy) order. |
◆ encrypt() [1/2]
| std::string BlowFish::encrypt |
( |
const std::string & |
input | ) |
const |
Encipher a message with Blowfish ECD.
- Warning
- Don't use this cipher for new stuff. And don't use ECD.
- Parameters
-
| input | The message to encrypt. |
- Returns
- The encrypted message. This will not be ASCII.
◆ encrypt() [2/2]
| void BlowFish::encrypt |
( |
const uint8_t * |
input, |
|
|
size_type |
input_length, |
|
|
uint8_t * |
output, |
|
|
size_type |
output_size |
|
) |
| const |
|
inline |
Encipher a BlowFish ECD message.
- Warning
- Don't use this cipher for new stuff. And don't use ECD.
- Parameters
-
| input | The message to encrypt. |
| input_length | The length of the message. |
| output | A buffer for the resulting message. This may be the same as the input to encrypt in place. |
| output_size | The size of the output. This must be large enough to accommodate any added padding. |
◆ encrypt_or_decrypt()
| void BlowFish::encrypt_or_decrypt |
( |
Action |
action, |
|
|
const uint8_t * |
input, |
|
|
size_type |
input_length, |
|
|
uint8_t * |
output, |
|
|
size_type |
output_size |
|
) |
| const |
|
private |
Encipher or decipher a series of bytes.
Result is produced in 64-bit (8-byte) chunks; if the input is not an even length, it is padded on the tail end with nulls. Once encrypted, these are part of the ciphertext; if the message is truncated to its original length, it won't decrypt.
- Parameters
-
| action | Selects encryption or decryption. |
| input | The input message. |
| input_length | The length of the input message. |
| output | Buffer for the encrypted message. |
| output_size | The size of the buffer. Must be the required size (input length ceilinged to %8==0). |
◆ encryptToHex()
| std::string BlowFish::encryptToHex |
( |
const std::string & |
input | ) |
const |
Encrypt a string and return it has hex digits.
- Parameters
-
| input | The message to encipher. |
- Returns
- A hex representation of the ciphertext.
◆ fFunction()
| uint32_t BlowFish::fFunction |
( |
uint32_t |
in | ) |
const |
|
private |
The cipher's "F function", used by ciphering/deciphering.
◆ from_hex()
| std::string BlowFish::from_hex |
( |
const std::string & |
digits | ) |
|
|
static |
Translate hexadecimal into a string.
Whitespace, punctuation and other junk is ignored.
- Parameters
-
| digits | The digits to translate. |
- Returns
- The unhexed string.
- Exceptions
-
| invalid_argument | upon bad input:
- An odd number of digits.
- Letters that are not hex digits.
|
◆ getOutputLength()
Get length of required output buffer.
- Parameters
-
| length | The length of the input message. |
- Returns
- The length the output buffer must be to accommodate the message.
◆ to_hex() [1/2]
| static std::string BlowFish::to_hex |
( |
const std::string & |
input | ) |
|
|
inlinestatic |
Convert a string to its hexadecimal representation.
◆ to_hex() [2/2]
| std::string BlowFish::to_hex |
( |
const uint8_t * |
bytes, |
|
|
size_type |
length |
|
) |
| |
|
static |
Translate some bytes into their hexadecimal representation.
- Parameters
-
| bytes | The beginning of the byte stream. |
| length | The number of bytes to hex encode. |
- Returns
- A string containing each byte encoded as 2 hex digits.
◆ InitialPArray
Initial value:= {
0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, 0x452821e6,
0x38d01377, 0xbe5466cf, 0x34e90c6c, 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, 0x9216d5d9, 0x8979fb1b,
}
◆ InitialSBoxes
◆ MaximumKeyBytes
| constexpr int BlowFish::MaximumKeyBytes = 56 |
|
staticconstexprprivate |
◆ NumberOfPasses
| constexpr int BlowFish::NumberOfPasses = 16 |
|
staticconstexprprivate |
◆ parray
◆ sboxes
The documentation for this class was generated from the following files: