Native API¶
This page is generated from the native declarations and JavaDoc in the Pawn includes. Choose one naming include per script; aliases bind to the same Rust native and work with either server. Read the operation guides for execution, lifetime and error semantics.
Constants¶
| Constant | Value |
|---|---|
CRYPTO_VERSION |
Generated from Cargo.toml at build time. |
CRYPTO_SHA224_LENGTH |
56 |
CRYPTO_SHA256_LENGTH |
64 |
CRYPTO_SHA384_LENGTH |
96 |
CRYPTO_SHA512_LENGTH |
128 |
CRYPTO_HMAC_SHA256_LENGTH |
CRYPTO_SHA256_LENGTH |
CRYPTO_HMAC_SHA512_LENGTH |
CRYPTO_SHA512_LENGTH |
CRYPTO_ARGON2ID_HASH_SIZE |
128 |
CRYPTO_PASSWORD_OK |
0 |
CRYPTO_PASSWORD_INVALID_HASH |
1 |
CRYPTO_PASSWORD_FAILED |
2 |
Digest/tag length constants exclude the null terminator. Add one cell for
their output arrays. CRYPTO_ARGON2ID_HASH_SIZE is a buffer capacity and
already includes the terminator. Password status meanings are described in
errors.
SHA-2¶
crypto_sha224¶
Hashes a Pawn string with SHA-224; uses original bytes up to the first null. Packed and unpacked strings are supported. This call is synchronous.
crypto.inc
crypto_omp.inc
| Parameter | Meaning |
|---|---|
input |
Null-terminated string to hash. |
output |
Destination for the 56-character lowercase hexadecimal digest. |
size |
Output capacity in cells; at least CRYPTO_SHA224_LENGTH + 1. |
Returns: true on success; false if size is too small, leaving output unchanged.
crypto_sha256¶
Hashes a Pawn string with SHA-256 and writes lowercase hexadecimal output. Input bytes are used directly, without text encoding conversion. Packed and unpacked strings are supported; input ends at the first null byte. This is a synchronous hash for data, not a password hashing function.
crypto.inc
crypto_omp.inc
| Parameter | Meaning |
|---|---|
input |
Null-terminated string to hash. |
output |
Destination for the 64-character lowercase hexadecimal digest. |
size |
Output capacity in cells; at least CRYPTO_SHA256_LENGTH + 1. |
Returns: true on success; false if size is too small, leaving output unchanged.
crypto_sha384¶
Hashes a Pawn string with SHA-384; uses original bytes up to the first null. Packed and unpacked strings are supported. This call is synchronous.
crypto.inc
crypto_omp.inc
| Parameter | Meaning |
|---|---|
input |
Null-terminated string to hash. |
output |
Destination for the 96-character lowercase hexadecimal digest. |
size |
Output capacity in cells; at least CRYPTO_SHA384_LENGTH + 1. |
Returns: true on success; false if size is too small, leaving output unchanged.
crypto_sha512¶
Hashes a Pawn string with SHA-512; uses original bytes up to the first null. Packed and unpacked strings are supported. This call is synchronous.
crypto.inc
crypto_omp.inc
| Parameter | Meaning |
|---|---|
input |
Null-terminated string to hash. |
output |
Destination for the 128-character lowercase hexadecimal digest. |
size |
Output capacity in cells; at least CRYPTO_SHA512_LENGTH + 1. |
Returns: true on success; false if size is too small, leaving output unchanged.
HMAC¶
crypto_hmac_sha256¶
Generates a full HMAC-SHA-256 tag in lowercase hexadecimal.
crypto.inc
crypto_omp.inc
native bool:Crypto_HmacSha256(const input[], const key[], output[], size = sizeof(output)) = crypto_hmac_sha256;
| Parameter | Meaning |
|---|---|
input |
Null-terminated message to authenticate. |
key |
Null-terminated secret key; its bytes are used without decoding. |
output |
Destination for the 64-character hexadecimal tag. |
size |
Output capacity in cells; at least CRYPTO_HMAC_SHA256_LENGTH + 1. |
Returns: true on success; false on failure, leaving output unchanged.
crypto_hmac_sha256_verify¶
Verifies a full HMAC-SHA-256 tag using a constant-time byte comparison. Hexadecimal input may use either case. Truncated tags are not accepted.
crypto.inc
crypto_omp.inc
native bool:Crypto_HmacSha256Verify(const input[], const key[], const expected[]) = crypto_hmac_sha256_verify;
| Parameter | Meaning |
|---|---|
input |
Null-terminated message to authenticate. |
key |
Null-terminated secret key, in its original byte encoding. |
expected |
Full 64-character hexadecimal tag to verify. |
Returns: true for a valid tag; false for a mismatch or malformed tag.
crypto_hmac_sha512¶
Generates a full HMAC-SHA-512 tag in lowercase hexadecimal.
crypto.inc
crypto_omp.inc
native bool:Crypto_HmacSha512(const input[], const key[], output[], size = sizeof(output)) = crypto_hmac_sha512;
| Parameter | Meaning |
|---|---|
input |
Null-terminated message to authenticate. |
key |
Null-terminated secret key; its bytes are used without decoding. |
output |
Destination for the 128-character hexadecimal tag. |
size |
Output capacity in cells; at least CRYPTO_HMAC_SHA512_LENGTH + 1. |
Returns: true on success; false on failure, leaving output unchanged.
crypto_hmac_sha512_verify¶
Verifies a full HMAC-SHA-512 tag using a constant-time byte comparison. Hexadecimal input may use either case. Truncated tags are not accepted.
crypto.inc
crypto_omp.inc
native bool:Crypto_HmacSha512Verify(const input[], const key[], const expected[]) = crypto_hmac_sha512_verify;
| Parameter | Meaning |
|---|---|
input |
Null-terminated message to authenticate. |
key |
Null-terminated secret key, in its original byte encoding. |
expected |
Full 128-character hexadecimal tag to verify. |
Returns: true for a valid tag; false for a mismatch or malformed tag.
Argon2id¶
crypto_argon2id_hash¶
Generates an Argon2id v19 PHC string with a fresh OS-random salt. Defaults: m=19456 KiB, t=2, p=1; 16-byte salt and 32-byte output. Callback signature: public Callback(status, const hash[], context). On failure, status is CRYPTO_PASSWORD_FAILED and hash is empty.
crypto.inc
crypto_omp.inc
native bool:Crypto_Argon2idHash(const password[], const callback[], context = 0) = crypto_argon2id_hash;
| Parameter | Meaning |
|---|---|
password |
Password string, never decoded or logged by this plugin. |
callback |
Name of an existing public in the calling script. |
context |
Integer passed unchanged to the callback. |
Returns: true if queued; false for invalid input, missing callback or full queue.
crypto_argon2id_verify¶
Verifies a password against an Argon2id v19 PHC string on a worker. Callback signature: public Callback(status, bool:matches, context). A wrong password returns CRYPTO_PASSWORD_OK with matches=false. Malformed, unsupported or excessive-cost hashes return CRYPTO_PASSWORD_INVALID_HASH with matches=false. Accepted maximums: m=65536 KiB, t=10, p=4. Other worker failures use CRYPTO_PASSWORD_FAILED.
crypto.inc
crypto_omp.inc
native bool:Crypto_Argon2idVerify(const password[], const hash[], const callback[], context = 0) = crypto_argon2id_verify;
| Parameter | Meaning |
|---|---|
password |
Password string in its original byte encoding. |
hash |
Complete stored PHC string, including its salt and parameters. |
callback |
Name of an existing public in the calling script. |
context |
Integer passed unchanged to the callback. |
Returns: true if queued; false for invalid input, missing callback or full queue.