sha3.h
mbedtls/private_access.h
mbedtls/build_info.h
stddef.h
stdint.h
crypto_builtin_primitives.h
mbedtls/build_info.h
mbedtls/check_config.h
mbedtls/config_adjust_legacy_crypto.h
mbedtls/config_adjust_psa_from_legacy.h
mbedtls/config_adjust_psa_superset_legacy.h
mbedtls/config_adjust_ssl.h
mbedtls/config_adjust_x509.h
mbedtls/config_psa.h
mbedtls/mbedtls_config.h
mbedtls/private_access.h
sha3.h
psa/crypto_adjust_auto_enabled.h
psa/crypto_adjust_config_dependencies.h
psa/crypto_adjust_config_key_pair_types.h
psa/crypto_adjust_config_synonyms.h
psa/crypto_legacy.h
limits.h
stddef.h
stdint.h
debug.h
net_sockets.h
oid.h
pk.h
pkcs7.h
psa_util.h
sha3.h
ssl.h
ssl_cache.h
ssl_ciphersuites.h
ssl_cookie.h
ssl_ticket.h
x509.h
x509_crl.h
x509_crt.h
x509_csr.h
crypto.h
crypto_builtin_primitives.h
crypto_driver_contexts_primitives.h
crypto_struct.h
mbedtls_sha3_context
MBEDTLS_ERR_SHA3_BAD_INPUT_DATA
-0x0076

SHA-3 input data was malformed.

mbedtls_sha3_id
MBEDTLS_SHA3_NONE
= 0

Operation not defined.

MBEDTLS_SHA3_224

SHA3-224

MBEDTLS_SHA3_256

SHA3-256

MBEDTLS_SHA3_384

SHA3-384

MBEDTLS_SHA3_512

SHA3-512

SHA-3 family id.

It identifies the family (SHA3-256, SHA3-512, etc.)

void void mbedtls_sha3_init (mbedtls_sha3_context *ctx) mbedtls_sha3_init mbedtls_sha3_context * ctx

This function initializes a SHA-3 context.

ctx

The SHA-3 context to initialize. This must not be `NULL`.

void void mbedtls_sha3_free (mbedtls_sha3_context *ctx) mbedtls_sha3_free mbedtls_sha3_context * ctx

This function clears a SHA-3 context.

ctx

The SHA-3 context to clear. This may be `NULL`, in which case this function returns immediately. If it is not `NULL`, it must point to an initialized SHA-3 context.

void void mbedtls_sha3_clone (mbedtls_sha3_context *dst, const mbedtls_sha3_context *src) mbedtls_sha3_clone mbedtls_sha3_context * dst const mbedtls_sha3_context * src

This function clones the state of a SHA-3 context.

dst

The destination context. This must be initialized.

src

The context to clone. This must be initialized.

int int mbedtls_sha3_starts (mbedtls_sha3_context *ctx, mbedtls_sha3_id id) mbedtls_sha3_starts mbedtls_sha3_context * ctx mbedtls_sha3_id id

This function starts a SHA-3 checksum calculation.

ctx

The context to use. This must be initialized.

id

The id of the SHA-3 family.

`0` on success.

A negative error code on failure.

int int mbedtls_sha3_update (mbedtls_sha3_context *ctx, const uint8_t *input, size_t ilen) mbedtls_sha3_update mbedtls_sha3_context * ctx const uint8_t * input size_t ilen

This function feeds an input buffer into an ongoing SHA-3 checksum calculation.

ctx

The SHA-3 context. This must be initialized and have a hash operation started.

input

The buffer holding the data. This must be a readable buffer of length `ilen` Bytes.

ilen

The length of the input data in Bytes.

`0` on success.

A negative error code on failure.

int int mbedtls_sha3_finish (mbedtls_sha3_context *ctx, uint8_t *output, size_t olen) mbedtls_sha3_finish mbedtls_sha3_context * ctx uint8_t * output size_t olen

This function finishes the SHA-3 operation, and writes the result to the output buffer.

ctx

The SHA-3 context. This must be initialized and have a hash operation started.

output

The SHA-3 checksum result. This must be a writable buffer of length `olen` bytes.

olen

Defines the length of output buffer (in bytes). For SHA-3 224, SHA-3 256, SHA-3 384 and SHA-3 512 `olen` must equal to 28, 32, 48 and 64, respectively.

`0` on success.

A negative error code on failure.

int int mbedtls_sha3 (mbedtls_sha3_id id, const uint8_t *input, size_t ilen, uint8_t *output, size_t olen) mbedtls_sha3 mbedtls_sha3_id id const uint8_t * input size_t ilen uint8_t * output size_t olen

This function calculates the SHA-3 checksum of a buffer.

The function allocates the context, performs the calculation, and frees the context.

The SHA-3 result is calculated as output = SHA-3(id, input buffer, d).

id

The id of the SHA-3 family.

input

The buffer holding the data. This must be a readable buffer of length `ilen` Bytes.

ilen

The length of the input data in Bytes.

output

The SHA-3 checksum result. This must be a writable buffer of length `olen` bytes.

olen

Defines the length of output buffer (in bytes). For SHA-3 224, SHA-3 256, SHA-3 384 and SHA-3 512 `olen` must equal to 28, 32, 48 and 64, respectively.

`0` on success.

A negative error code on failure.

int int mbedtls_sha3_self_test (int verbose) mbedtls_sha3_self_test int verbose

Checkup routine for the algorithms implemented by this module: SHA3-224, SHA3-256, SHA3-384, SHA3-512.

0 if successful, or 1 if the test failed.

This file contains SHA-3 definitions and functions.

The Secure Hash Algorithms cryptographic hash functions are defined in FIPS 202: SHA-3 Standard: Permutation-Based Hash and Extendable-Output Functions .

    /*
    *CopyrightTheMbedTLSContributors
    *SPDX-License-Identifier:Apache-2.0ORGPL-2.0-or-later
    */

    #ifndefMBEDTLS_SHA3_H
    #defineMBEDTLS_SHA3_H
    #include"mbedtls/private_access.h"

    #include"mbedtls/build_info.h"

    #include<stddef.h>
    #include<stdint.h>

    #ifdef__cplusplus
    extern"C"{
    #endif

    #defineMBEDTLS_ERR_SHA3_BAD_INPUT_DATA-0x0076

    typedefenum{
    MBEDTLS_SHA3_NONE=0,
    MBEDTLS_SHA3_224,
    MBEDTLS_SHA3_256,
    MBEDTLS_SHA3_384,
    MBEDTLS_SHA3_512,
    }mbedtls_sha3_id;

    typedefstruct{
    uint64_tMBEDTLS_PRIVATE(state[25]);
    uint32_tMBEDTLS_PRIVATE(index);
    uint16_tMBEDTLS_PRIVATE(olen);
    uint16_tMBEDTLS_PRIVATE(max_block_size);
    }
    mbedtls_sha3_context;

    voidmbedtls_sha3_init(mbedtls_sha3_context*ctx);

    voidmbedtls_sha3_free(mbedtls_sha3_context*ctx);

    voidmbedtls_sha3_clone(mbedtls_sha3_context*dst,
    constmbedtls_sha3_context*src);

    intmbedtls_sha3_starts(mbedtls_sha3_context*ctx,mbedtls_sha3_idid);

    intmbedtls_sha3_update(mbedtls_sha3_context*ctx,
    constuint8_t*input,
    size_tilen);

    intmbedtls_sha3_finish(mbedtls_sha3_context*ctx,
    uint8_t*output,size_tolen);

    intmbedtls_sha3(mbedtls_sha3_idid,constuint8_t*input,
    size_tilen,
    uint8_t*output,
    size_tolen);

    #ifdefined(MBEDTLS_SELF_TEST)
    intmbedtls_sha3_self_test(intverbose);
    #endif/*MBEDTLS_SELF_TEST*/

    #ifdef__cplusplus
    }
    #endif

    #endif/*mbedtls_sha3.h*/