sha1.h
mbedtls/config.h
stddef.h
stdint.h
crypto_builtin_primitives.h
mbedtls/check_config.h
mbedtls/config.h
sha1.h
limits.h
stddef.h
stdint.h
sha1.h
crypto.h
crypto_builtin_primitives.h
crypto_driver_contexts_primitives.h
crypto_struct.h
mbedtls_sha1_context
MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED
-0x0035

SHA-1 hardware accelerator failed

MBEDTLS_ERR_SHA1_BAD_INPUT_DATA
-0x0073

SHA-1 input data was malformed.

MBEDTLS_DEPRECATED
__attribute__((deprecated))
MBEDTLS_DEPRECATED
__attribute__((deprecated))
struct mbedtls_sha1_context typedef struct mbedtls_sha1_context mbedtls_sha1_context mbedtls_sha1_context

The SHA-1 context structure.

SHA-1 is considered a weak message digest and its use constitutes a security risk. We recommend considering stronger message digests instead.

void void mbedtls_sha1_init (mbedtls_sha1_context *ctx) mbedtls_sha1_init mbedtls_sha1_context * ctx

This function initializes a SHA-1 context.

SHA-1 is considered a weak message digest and its use constitutes a security risk. We recommend considering stronger message digests instead.

ctx

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

void void mbedtls_sha1_free (mbedtls_sha1_context *ctx) mbedtls_sha1_free mbedtls_sha1_context * ctx

This function clears a SHA-1 context.

SHA-1 is considered a weak message digest and its use constitutes a security risk. We recommend considering stronger message digests instead.

ctx

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

void void mbedtls_sha1_clone (mbedtls_sha1_context *dst, const mbedtls_sha1_context *src) mbedtls_sha1_clone mbedtls_sha1_context * dst const mbedtls_sha1_context * src

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

SHA-1 is considered a weak message digest and its use constitutes a security risk. We recommend considering stronger message digests instead.

dst

The SHA-1 context to clone to. This must be initialized.

src

The SHA-1 context to clone from. This must be initialized.

int int mbedtls_sha1_starts_ret (mbedtls_sha1_context *ctx) mbedtls_sha1_starts_ret mbedtls_sha1_context * ctx

This function starts a SHA-1 checksum calculation.

SHA-1 is considered a weak message digest and its use constitutes a security risk. We recommend considering stronger message digests instead.

ctx

The SHA-1 context to initialize. This must be initialized.

`0` on success.

A negative error code on failure.

int int mbedtls_sha1_update_ret (mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen) mbedtls_sha1_update_ret mbedtls_sha1_context * ctx const unsigned char * input size_t ilen

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

SHA-1 is considered a weak message digest and its use constitutes a security risk. We recommend considering stronger message digests instead.

ctx

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

input

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

ilen

The length of the input data `input` in Bytes.

`0` on success.

A negative error code on failure.

int int mbedtls_sha1_finish_ret (mbedtls_sha1_context *ctx, unsigned char output[20]) mbedtls_sha1_finish_ret mbedtls_sha1_context * ctx unsigned char output [20]

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

SHA-1 is considered a weak message digest and its use constitutes a security risk. We recommend considering stronger message digests instead.

ctx

The SHA-1 context to use. This must be initialized and have a hash operation started.

output

The SHA-1 checksum result. This must be a writable buffer of length `20` Bytes.

`0` on success.

A negative error code on failure.

int int mbedtls_internal_sha1_process (mbedtls_sha1_context *ctx, const unsigned char data[64]) mbedtls_internal_sha1_process mbedtls_sha1_context * ctx const unsigned char data [64]

SHA-1 process data block (internal use only).

SHA-1 is considered a weak message digest and its use constitutes a security risk. We recommend considering stronger message digests instead.

ctx

The SHA-1 context to use. This must be initialized.

data

The data block being processed. This must be a readable buffer of length `64` Bytes.

`0` on success.

A negative error code on failure.

MBEDTLS_DEPRECATED void MBEDTLS_DEPRECATED void mbedtls_sha1_starts (mbedtls_sha1_context *ctx) mbedtls_sha1_starts mbedtls_sha1_context * ctx

This function starts a SHA-1 checksum calculation.

SHA-1 is considered a weak message digest and its use constitutes a security risk. We recommend considering stronger message digests instead.

Deprecated

Superseded by mbedtls_sha1_starts_ret() in 2.7.0.

ctx

The SHA-1 context to initialize. This must be initialized.

MBEDTLS_DEPRECATED void MBEDTLS_DEPRECATED void mbedtls_sha1_update (mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen) mbedtls_sha1_update mbedtls_sha1_context * ctx const unsigned char * input size_t ilen

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

SHA-1 is considered a weak message digest and its use constitutes a security risk. We recommend considering stronger message digests instead.

Deprecated

Superseded by mbedtls_sha1_update_ret() in 2.7.0.

ctx

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

input

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

ilen

The length of the input data `input` in Bytes.

MBEDTLS_DEPRECATED void MBEDTLS_DEPRECATED void mbedtls_sha1_finish (mbedtls_sha1_context *ctx, unsigned char output[20]) mbedtls_sha1_finish mbedtls_sha1_context * ctx unsigned char output [20]

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

SHA-1 is considered a weak message digest and its use constitutes a security risk. We recommend considering stronger message digests instead.

Deprecated

Superseded by mbedtls_sha1_finish_ret() in 2.7.0.

ctx

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

output

The SHA-1 checksum result. This must be a writable buffer of length `20` Bytes.

MBEDTLS_DEPRECATED void MBEDTLS_DEPRECATED void mbedtls_sha1_process (mbedtls_sha1_context *ctx, const unsigned char data[64]) mbedtls_sha1_process mbedtls_sha1_context * ctx const unsigned char data [64]

SHA-1 process data block (internal use only).

SHA-1 is considered a weak message digest and its use constitutes a security risk. We recommend considering stronger message digests instead.

Deprecated

Superseded by mbedtls_internal_sha1_process() in 2.7.0.

ctx

The SHA-1 context. This must be initialized.

data

The data block being processed. This must be a readable buffer of length `64` bytes.

int int mbedtls_sha1_ret (const unsigned char *input, size_t ilen, unsigned char output[20]) mbedtls_sha1_ret const unsigned char * input size_t ilen unsigned char output [20]

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

The function allocates the context, performs the calculation, and frees the context. The SHA-1 result is calculated as output = SHA-1(input buffer).

SHA-1 is considered a weak message digest and its use constitutes a security risk. We recommend considering stronger message digests instead.

input

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

ilen

The length of the input data `input` in Bytes.

output

The SHA-1 checksum result. This must be a writable buffer of length `20` Bytes.

`0` on success.

A negative error code on failure.

MBEDTLS_DEPRECATED void MBEDTLS_DEPRECATED void mbedtls_sha1 (const unsigned char *input, size_t ilen, unsigned char output[20]) mbedtls_sha1 const unsigned char * input size_t ilen unsigned char output [20]

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

The function allocates the context, performs the calculation, and frees the context. The SHA-1 result is calculated as output = SHA-1(input buffer).

SHA-1 is considered a weak message digest and its use constitutes a security risk. We recommend considering stronger message digests instead.

Deprecated

Superseded by mbedtls_sha1_ret() in 2.7.0

input

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

ilen

The length of the input data `input` in Bytes.

output

The SHA-1 checksum result. This must be a writable buffer of size `20` Bytes.

int int mbedtls_sha1_self_test (int verbose) mbedtls_sha1_self_test int verbose

The SHA-1 checkup routine.

SHA-1 is considered a weak message digest and its use constitutes a security risk. We recommend considering stronger message digests instead.

`0` on success.

`1` on failure.

This file contains SHA-1 definitions and functions.

The Secure Hash Algorithm 1 (SHA-1) cryptographic hash function is defined in FIPS 180-4: Secure Hash Standard (SHS).

SHA-1 is considered a weak message digest and its use constitutes a security risk. We recommend considering stronger message digests instead.

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

    #if!defined(MBEDTLS_CONFIG_FILE)
    #include"mbedtls/config.h"
    #else
    #includeMBEDTLS_CONFIG_FILE
    #endif

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

    /*MBEDTLS_ERR_SHA1_HW_ACCEL_FAILEDisdeprecatedandshouldnotbeused.*/
    #defineMBEDTLS_ERR_SHA1_HW_ACCEL_FAILED-0x0035
    #defineMBEDTLS_ERR_SHA1_BAD_INPUT_DATA-0x0073

    #ifdef__cplusplus
    extern"C"{
    #endif

    #if!defined(MBEDTLS_SHA1_ALT)
    //Regularimplementation
    //

    typedefstructmbedtls_sha1_context{
    uint32_ttotal[2];
    uint32_tstate[5];
    unsignedcharbuffer[64];
    }
    mbedtls_sha1_context;

    #else/*MBEDTLS_SHA1_ALT*/
    #include"sha1_alt.h"
    #endif/*MBEDTLS_SHA1_ALT*/

    voidmbedtls_sha1_init(mbedtls_sha1_context*ctx);

    voidmbedtls_sha1_free(mbedtls_sha1_context*ctx);

    voidmbedtls_sha1_clone(mbedtls_sha1_context*dst,
    constmbedtls_sha1_context*src);

    intmbedtls_sha1_starts_ret(mbedtls_sha1_context*ctx);

    intmbedtls_sha1_update_ret(mbedtls_sha1_context*ctx,
    constunsignedchar*input,
    size_tilen);

    intmbedtls_sha1_finish_ret(mbedtls_sha1_context*ctx,
    unsignedcharoutput[20]);

    intmbedtls_internal_sha1_process(mbedtls_sha1_context*ctx,
    constunsignedchardata[64]);

    #if!defined(MBEDTLS_DEPRECATED_REMOVED)
    #ifdefined(MBEDTLS_DEPRECATED_WARNING)
    #defineMBEDTLS_DEPRECATED__attribute__((deprecated))
    #else
    #defineMBEDTLS_DEPRECATED
    #endif
    MBEDTLS_DEPRECATEDvoidmbedtls_sha1_starts(mbedtls_sha1_context*ctx);

    MBEDTLS_DEPRECATEDvoidmbedtls_sha1_update(mbedtls_sha1_context*ctx,
    constunsignedchar*input,
    size_tilen);

    MBEDTLS_DEPRECATEDvoidmbedtls_sha1_finish(mbedtls_sha1_context*ctx,
    unsignedcharoutput[20]);

    MBEDTLS_DEPRECATEDvoidmbedtls_sha1_process(mbedtls_sha1_context*ctx,
    constunsignedchardata[64]);

    #undefMBEDTLS_DEPRECATED
    #endif/*!MBEDTLS_DEPRECATED_REMOVED*/

    intmbedtls_sha1_ret(constunsignedchar*input,
    size_tilen,
    unsignedcharoutput[20]);

    #if!defined(MBEDTLS_DEPRECATED_REMOVED)
    #ifdefined(MBEDTLS_DEPRECATED_WARNING)
    #defineMBEDTLS_DEPRECATED__attribute__((deprecated))
    #else
    #defineMBEDTLS_DEPRECATED
    #endif
    MBEDTLS_DEPRECATEDvoidmbedtls_sha1(constunsignedchar*input,
    size_tilen,
    unsignedcharoutput[20]);

    #undefMBEDTLS_DEPRECATED
    #endif/*!MBEDTLS_DEPRECATED_REMOVED*/

    #ifdefined(MBEDTLS_SELF_TEST)

    intmbedtls_sha1_self_test(intverbose);

    #endif/*MBEDTLS_SELF_TEST*/

    #ifdef__cplusplus
    }
    #endif

    #endif/*mbedtls_sha1.h*/