JubeatPlus 3.9.11
Loading...
Searching...
No Matches
BFCodec Class Reference

A Blowfish cipher that works in place on an NSMutableData. More...

#include <BFCodec.h>

Inheritance diagram for BFCodec:
Collaboration diagram for BFCodec:

Instance Methods

(instancetype) - init
 Builds a codec with a zeroed chaining vector and a fresh key schedule.
(void) - cipherInit:length:
 Sets the key from a raw buffer, and resets the chaining vector to its fixed value.
(void) - cipherInit:
 Sets the key from a data buffer.
(unsigned int) - encipher:
 Encrypts a buffer in place, growing it to hold the padding and a length trailer.
(BOOL) - decipher:
 Decrypts a buffer in place.
(void) - dealloc
 Wipes the chaining vector and releases the key schedule.

Detailed Description

A Blowfish cipher that works in place on an NSMutableData.

Method Documentation

◆ cipherInit:

- (void) cipherInit: (nullable NSData *) key

Sets the key from a data buffer.

Callers pass a 16-byte MD5 digest. A nil key returns without touching anything, so the codec keeps whatever key it had.

Parameters
keyThe key material.
Ghidra address:
0x94a58

◆ cipherInit:length:

- (void) cipherInit: (const char *) key
length: (int) length 

Sets the key from a raw buffer, and resets the chaining vector to its fixed value.

The vector is not derived from the key or from anything else — it is eight bytes written literally into the ivar. See TYPES_PENDING.md.

Parameters
keyThe key material.
lengthThe key's length in bytes.
Ghidra address:
0x949e0
Ghidra address:
0x949e0

◆ dealloc

- (void) dealloc

Wipes the chaining vector and releases the key schedule.

Ghidra address:
0x9510c

◆ decipher:

- (BOOL) decipher: (nullable NSMutableData *) data

Decrypts a buffer in place.

Both of the trailer's words are checked before anything is decrypted, and the buffer is truncated back to the plaintext afterwards. The return type is BOOL rather than the void this header previously claimed, from the metadata encoding B24@0:8@16 .

Parameters
dataThe buffer to decrypt, modified in place.
Returns
NO when the trailer does not describe the buffer, YES otherwise.
Ghidra address:
0x94e20

◆ encipher:

- (unsigned int) encipher: (nullable NSMutableData *) data

Encrypts a buffer in place, growing it to hold the padding and a length trailer.

The buffer is resized to (length + 15) & ~7 : the plaintext rounded up to a block boundary, plus one more block holding the original length. Chaining is CBC from the fixed vector.

Parameters
dataThe buffer to encrypt, modified in place.
Returns
The buffer's new length.
Ghidra address:
0x94aec

◆ init

- (instancetype) init

Builds a codec with a zeroed chaining vector and a fresh key schedule.

Returns
The initialised codec.
Ghidra address:
0x94978
Ghidra address:
0x94978

The documentation for this class was generated from the following files: