util_sha512h
Behaviour
Section titled “Behaviour”- Compute an
SHA512hash over the data pointed to byread_ptr - Write the first half of the hash to
write_ptr
- Compute an
SHA512hash over the data pointed to bydata - Return the first half of the hash
Definition
Section titled “Definition”int64_t util_sha512h ( uint32_t write_ptr, uint32_t write_len, uint32_t read_ptr, uint32_t read_len);function util_sha512h(data: ByteArray | HexString): ErrorCode | ByteArrayExample
Section titled “Example”C
uint8_t hash_out[32];if (util_sha512h(hash_out, 32, data_in_ptr, data_in_len) < 0) rollback("Could not generate Hash", 23, 1);if (util_sha512h(data) < 0) rollback("Could not generate Hash", 1)Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| write_ptr | uint32_t | Pointer to a buffer the hash will be written to |
| write_len | uint32_t | Length of output buffer, should be at least 32. |
| read_ptr | uint32_t | Pointer to the buffer data will be read from (to compute the hash over) |
| read_len | uint32_t | Length of input data |
| Name | Type | Description |
|---|---|---|
| data | ByteArray or HexString | The data to compute the hash over, can be provided as an array of numbers or a string. |
Return Code
Section titled “Return Code”| Type | Description |
|---|---|
| int64_t | The number of bytes written, should always be 32. If negative, an error: OUT_OF_BOUNDS- pointers/lengths specified outside of hook memory. TOO_SMALL- Output buffer isn’t large enough |
| Type | Description |
|---|---|
| ByteArray | ErrorCode if there is an error in computing the hash, otherwise returns the SHA512-half hash as an array of numbers. |