JubeatPlus 3.9.11
Loading...
Searching...
No Matches
Md5Utilities.h File Reference

Message-digest helpers. More...

#include <stdbool.h>
import <Foundation/Foundation.h>
Include dependency graph for Md5Utilities.h:

Go to the source code of this file.

Functions

NS_ASSUME_NONNULL_BEGIN NSString * CreateMd5HexStringFromCString (const char *lpcszInput)
 Hashes a NUL-terminated C string and returns the digest as a hexadecimal string.
NSData * CreateMd5DataFromCString (const char *lpcszInput)
 Hashes a NUL-terminated C string and returns the raw 16-byte digest as data.
NSString * CreateMD5HexString (const void *pvData, unsigned int cbLength)
 Hashes an explicit-length buffer and returns the digest as a hexadecimal string.
bool VerifyMd5Digest (const void *pvData, unsigned int cbLength, const unsigned char *pbExpectedDigest)
 Hashes an explicit-length buffer with MD5 and compares it against an expected digest.
NSString * CreateSha256HexStringFromData (NSData *data, bool uppercase)
 Hashes an NSData with SHA-256 and returns the digest as a hexadecimal string.

Detailed Description

Message-digest helpers.

Reconstructed from Ghidra program Jubeat (image base 0x100000000). All

Ghidra address:
values are offsets relative to that image base.

These are among the few genuine free functions in this tree. None takes a receiver argument or belongs to a class, so the reconstruction rules' search for an owning class is exhausted and they stay free functions. Most are MD5, with one SHA-256 helper that sits beside them in the binary.

Function Documentation

◆ CreateMd5DataFromCString()

NSData * CreateMd5DataFromCString ( const char * lpcszInput)

Hashes a NUL-terminated C string and returns the raw 16-byte digest as data.

Plain CommonCrypto MD5 over strlen bytes, wrapped in +[NSData dataWithBytes:length:] . Because the input is measured with strlen an embedded NUL truncates the hashed region, so this cannot hash arbitrary binary data; use CreateMD5HexString for explicit-length input.

Parameters
lpcszInputThe string to hash, as UTF-8 bytes. Not checked for nullptr .
Returns
The raw digest, exactly 16 bytes.
Ghidra address:
0x7f0d0

◆ CreateMD5HexString()

NSString * CreateMD5HexString ( const void * pvData,
unsigned int cbLength )

Hashes an explicit-length buffer and returns the digest as a hexadecimal string.

The save-data integrity hash, used on both the encode and decode sides. Plain CommonCrypto MD5 over cbLength bytes, rendered as 32 lower-case hexadecimal characters. The binary unrolls the sixteen per-byte appends rather than looping.

Parameters
pvDataThe bytes to hash.
cbLengthThe byte count.
Returns
The digest rendered in hexadecimal, 32 characters long.
Ghidra address:
0x1c7258

◆ CreateMd5HexStringFromCString()

NS_ASSUME_NONNULL_BEGIN NSString * CreateMd5HexStringFromCString ( const char * lpcszInput)

Hashes a NUL-terminated C string and returns the digest as a hexadecimal string.

Plain CommonCrypto MD5 over strlen bytes, rendered as 32 lower-case hexadecimal characters. The binary unrolls the sixteen per-byte appends rather than looping.

Parameters
lpcszInputThe string to hash, as UTF-8 bytes.
Returns
The digest rendered in hexadecimal, 32 characters long.
Ghidra address:
0x7f168

◆ CreateSha256HexStringFromData()

NSString * CreateSha256HexStringFromData ( NSData * data,
bool uppercase )

Hashes an NSData with SHA-256 and returns the digest as a hexadecimal string.

Plain CommonCrypto SHA-256 over the data's explicit length, rendered as sixty-four hexadecimal characters. Hashes arbitrary binary data correctly, unlike the strlen -based MD5 helpers. The binary duplicates the whole thirty-two-iteration append loop rather than selecting the format string inside it; the two loops differ only in the per-byte format. This is the cluster's only SHA-256 user.

Parameters
dataThe bytes to hash.
uppercasetrue selects the upper-case "%02X" format, false the lower-case "%02x" . The binary tests only bit 0.
Returns
The digest rendered in hexadecimal, 64 characters long.
Ghidra address:
0x7f3d0

◆ VerifyMd5Digest()

bool VerifyMd5Digest ( const void * pvData,
unsigned int cbLength,
const unsigned char * pbExpectedDigest )

Hashes an explicit-length buffer with MD5 and compares it against an expected digest.

Plain CommonCrypto MD5 over cbLength bytes, whose sixteen-byte result is compared against the caller's expected digest. The comparison is byte-by-byte and short-circuits on the first mismatch, so it is not constant time: fine for detecting accidental corruption, unsuitable as an authentication check against an adversary who can time it. Unlike the strlen -based helpers above it takes an explicit length, so it hashes arbitrary binary data (including embedded NULs) correctly and is the right one for file or asset integrity checks.

Parameters
pvDataThe bytes to hash.
cbLengthThe byte count.
pbExpectedDigestThe expected digest. The caller must guarantee at least CC_MD5_DIGEST_LENGTH readable bytes; the length is implicit.
Returns
true if the computed digest matches, false otherwise.
Ghidra address:
0x7f560