NCBI C++ ToolKit
Classes | Macros | Typedefs | Functions
sha1.h File Reference

This file contains SHA-1 definitions and functions. More...

#include "mbedtls/config.h"
#include <stddef.h>
#include <stdint.h>
+ Include dependency graph for sha1.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Go to the SVN repository for this file.

Classes

struct  mbedtls_sha1_context
 The SHA-1 context structure. More...
 

Macros

#define MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED   -0x0035
 SHA-1 hardware accelerator failed. More...
 
#define MBEDTLS_ERR_SHA1_BAD_INPUT_DATA   -0x0073
 SHA-1 input data was malformed. More...
 
#define MBEDTLS_DEPRECATED
 
#define MBEDTLS_DEPRECATED
 

Typedefs

typedef struct mbedtls_sha1_context mbedtls_sha1_context
 The SHA-1 context structure. More...
 

Functions

void mbedtls_sha1_init (mbedtls_sha1_context *ctx)
 This function initializes a SHA-1 context. More...
 
void mbedtls_sha1_free (mbedtls_sha1_context *ctx)
 This function clears a SHA-1 context. More...
 
void mbedtls_sha1_clone (mbedtls_sha1_context *dst, const mbedtls_sha1_context *src)
 This function clones the state of a SHA-1 context. More...
 
int mbedtls_sha1_starts_ret (mbedtls_sha1_context *ctx)
 This function starts a SHA-1 checksum calculation. More...
 
int 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. More...
 
int 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. More...
 
int mbedtls_internal_sha1_process (mbedtls_sha1_context *ctx, const unsigned char data[64])
 SHA-1 process data block (internal use only). More...
 
void mbedtls_sha1_starts (mbedtls_sha1_context *ctx)
 This function starts a SHA-1 checksum calculation. More...
 
void 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. More...
 
void 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. More...
 
void mbedtls_sha1_process (mbedtls_sha1_context *ctx, const unsigned char data[64])
 SHA-1 process data block (internal use only). More...
 
int mbedtls_sha1_ret (const unsigned char *input, size_t ilen, unsigned char output[20])
 This function calculates the SHA-1 checksum of a buffer. More...
 
void mbedtls_sha1 (const unsigned char *input, size_t ilen, unsigned char output[20])
 This function calculates the SHA-1 checksum of a buffer. More...
 

Detailed Description

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).

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

Definition in file sha1.h.

Macro Definition Documentation

◆ MBEDTLS_DEPRECATED [1/2]

#define MBEDTLS_DEPRECATED

Definition at line 299 of file sha1.h.

◆ MBEDTLS_DEPRECATED [2/2]

#define MBEDTLS_DEPRECATED

Definition at line 299 of file sha1.h.

◆ MBEDTLS_ERR_SHA1_BAD_INPUT_DATA

#define MBEDTLS_ERR_SHA1_BAD_INPUT_DATA   -0x0073

SHA-1 input data was malformed.

Definition at line 45 of file sha1.h.

◆ MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED

#define MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED   -0x0035

SHA-1 hardware accelerator failed.

Definition at line 43 of file sha1.h.

Typedef Documentation

◆ mbedtls_sha1_context

The SHA-1 context structure.

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

Function Documentation

◆ mbedtls_internal_sha1_process()

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

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

Warning
SHA-1 is considered a weak message digest and its use constitutes a security risk. We recommend considering stronger message digests instead.
Parameters
ctxThe SHA-1 context to use. This must be initialized.
dataThe data block being processed. This must be a readable buffer of length 64 Bytes.
Returns
0 on success.
A negative error code on failure.

Referenced by mbedtls_md_process_ncbicxx_2_28_3(), mbedtls_sha1_finish_ret_ncbicxx_2_28_3(), mbedtls_sha1_process_ncbicxx_2_28_3(), and mbedtls_sha1_update_ret_ncbicxx_2_28_3().

◆ mbedtls_sha1()

void 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).

Warning
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
Parameters
inputThe buffer holding the input data. This must be a readable buffer of length ilen Bytes.
ilenThe length of the input data input in Bytes.
outputThe SHA-1 checksum result. This must be a writable buffer of size 20 Bytes.

Referenced by mbedtls_ssl_get_key_exchange_md_ssl_tls_ncbicxx_2_28_3().

◆ mbedtls_sha1_clone()

void mbedtls_sha1_clone ( mbedtls_sha1_context dst,
const mbedtls_sha1_context src 
)

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

Warning
SHA-1 is considered a weak message digest and its use constitutes a security risk. We recommend considering stronger message digests instead.
Parameters
dstThe SHA-1 context to clone to. This must be initialized.
srcThe SHA-1 context to clone from. This must be initialized.

Referenced by mbedtls_md_clone_ncbicxx_2_28_3(), ssl_calc_finished_tls(), and ssl_calc_verify_tls().

◆ mbedtls_sha1_finish()

void 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.

Warning
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.
Parameters
ctxThe SHA-1 context. This must be initialized and have a hash operation started.
outputThe SHA-1 checksum result. This must be a writable buffer of length 20 Bytes.

◆ mbedtls_sha1_finish_ret()

int 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.

Warning
SHA-1 is considered a weak message digest and its use constitutes a security risk. We recommend considering stronger message digests instead.
Parameters
ctxThe SHA-1 context to use. This must be initialized and have a hash operation started.
outputThe SHA-1 checksum result. This must be a writable buffer of length 20 Bytes.
Returns
0 on success.
A negative error code on failure.

Referenced by mbedtls_md_finish_ncbicxx_2_28_3(), mbedtls_sha1_finish_ncbicxx_2_28_3(), mbedtls_sha1_ret_ncbicxx_2_28_3(), mbedtls_ssl_get_key_exchange_md_ssl_tls_ncbicxx_2_28_3(), ssl_calc_finished_tls(), and ssl_calc_verify_tls().

◆ mbedtls_sha1_free()

void mbedtls_sha1_free ( mbedtls_sha1_context ctx)

This function clears a SHA-1 context.

Warning
SHA-1 is considered a weak message digest and its use constitutes a security risk. We recommend considering stronger message digests instead.
Parameters
ctxThe 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.

Referenced by mbedtls_md_free_ncbicxx_2_28_3(), mbedtls_sha1_ret_ncbicxx_2_28_3(), mbedtls_ssl_get_key_exchange_md_ssl_tls_ncbicxx_2_28_3(), mbedtls_ssl_handshake_free_ncbicxx_2_28_3(), ssl_calc_finished_tls(), and ssl_calc_verify_tls().

◆ mbedtls_sha1_init()

void mbedtls_sha1_init ( mbedtls_sha1_context ctx)

This function initializes a SHA-1 context.

Warning
SHA-1 is considered a weak message digest and its use constitutes a security risk. We recommend considering stronger message digests instead.
Parameters
ctxThe SHA-1 context to initialize. This must not be NULL.

Referenced by mbedtls_sha1_ret_ncbicxx_2_28_3(), mbedtls_ssl_get_key_exchange_md_ssl_tls_ncbicxx_2_28_3(), ssl_calc_finished_tls(), ssl_calc_verify_tls(), and ssl_handshake_params_init().

◆ mbedtls_sha1_process()

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

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

Warning
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.
Parameters
ctxThe SHA-1 context. This must be initialized.
dataThe data block being processed. This must be a readable buffer of length 64 bytes.

◆ mbedtls_sha1_ret()

int 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).

Warning
SHA-1 is considered a weak message digest and its use constitutes a security risk. We recommend considering stronger message digests instead.
Parameters
inputThe buffer holding the input data. This must be a readable buffer of length ilen Bytes.
ilenThe length of the input data input in Bytes.
outputThe SHA-1 checksum result. This must be a writable buffer of length 20 Bytes.
Returns
0 on success.
A negative error code on failure.

Referenced by mbedtls_md_ncbicxx_2_28_3(), mbedtls_sha1_ncbicxx_2_28_3(), mbedtls_x509write_crt_set_authority_key_identifier_ncbicxx_2_28_3(), and mbedtls_x509write_crt_set_subject_key_identifier_ncbicxx_2_28_3().

◆ mbedtls_sha1_starts()

void mbedtls_sha1_starts ( mbedtls_sha1_context ctx)

This function starts a SHA-1 checksum calculation.

Warning
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.
Parameters
ctxThe SHA-1 context to initialize. This must be initialized.

◆ mbedtls_sha1_starts_ret()

int mbedtls_sha1_starts_ret ( mbedtls_sha1_context ctx)

This function starts a SHA-1 checksum calculation.

Warning
SHA-1 is considered a weak message digest and its use constitutes a security risk. We recommend considering stronger message digests instead.
Parameters
ctxThe SHA-1 context to initialize. This must be initialized.
Returns
0 on success.
A negative error code on failure.

Referenced by mbedtls_md_starts_ncbicxx_2_28_3(), mbedtls_sha1_ret_ncbicxx_2_28_3(), mbedtls_sha1_starts_ncbicxx_2_28_3(), mbedtls_ssl_get_key_exchange_md_ssl_tls_ncbicxx_2_28_3(), mbedtls_ssl_reset_checksum_ncbicxx_2_28_3(), and ssl_handshake_params_init().

◆ mbedtls_sha1_update()

void 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.

Warning
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.
Parameters
ctxThe SHA-1 context. This must be initialized and have a hash operation started.
inputThe buffer holding the input data. This must be a readable buffer of length ilen Bytes.
ilenThe length of the input data input in Bytes.

◆ mbedtls_sha1_update_ret()

int 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.

Warning
SHA-1 is considered a weak message digest and its use constitutes a security risk. We recommend considering stronger message digests instead.
Parameters
ctxThe SHA-1 context. This must be initialized and have a hash operation started.
inputThe buffer holding the input data. This must be a readable buffer of length ilen Bytes.
ilenThe length of the input data input in Bytes.
Returns
0 on success.
A negative error code on failure.

Referenced by mbedtls_md_update_ncbicxx_2_28_3(), mbedtls_sha1_ret_ncbicxx_2_28_3(), mbedtls_sha1_update_ncbicxx_2_28_3(), mbedtls_ssl_get_key_exchange_md_ssl_tls_ncbicxx_2_28_3(), ssl_update_checksum_md5sha1(), and ssl_update_checksum_start().

Modified on Thu Feb 22 17:06:05 2024 by modify_doxy.py rev. 669887