Loading...
Searching...
No Matches
SHA
libavutil » Crypto and Hashing » Hash Functions

SHA-1 and SHA-256 (Secure Hash Algorithm) hash function implementations. More...

## Files

file | sha.h
| Public header for SHA-1 & SHA-256 hash function implementations.

## Functions

struct AVSHA * | av_sha_alloc (void)
| Allocate an AVSHA context.
int | av_sha_init (struct AVSHA *context, int bits)
| Initialize SHA-1 or SHA-2 hashing.
void | av_sha_update (struct AVSHA *ctx, const uint8_t *data, size_t len)
| Update hash value.
void | av_sha_final (struct AVSHA *context, uint8_t *digest)
| Finish hashing and output digest value.

## Variables

const int | av_sha_size

## Detailed Description

SHA-1 and SHA-256 (Secure Hash Algorithm) hash function implementations.

This module supports the following SHA hash functions:

- SHA-1: 160 bits
- SHA-224: 224 bits, as a variant of SHA-2
- SHA-256: 256 bits, as a variant of SHA-2

See also
  For SHA-384, SHA-512, and variants thereof, see SHA-512.

## Function Documentation

## av_sha_alloc()

struct AVSHA * av_sha_alloc | ( | void |  | ) |

Allocate an AVSHA context.

## av_sha_init()

int av_sha_init | ( | struct AVSHA * | context,
|  | int | bits
| ) |  |

Initialize SHA-1 or SHA-2 hashing.

Parameters

  context | pointer to the function context (of size av_sha_size)
  bits | number of bits in digest (SHA-1 - 160 bits, SHA-2 224 or 256 bits)

Returns
  zero if initialization succeeded, -1 otherwise

## av_sha_update()

void av_sha_update | ( | struct AVSHA * | ctx,
|  | const uint8_t * | data,
|  | size_t | len
| ) |  |

Update hash value.

Parameters

  ctx | hash function context
  data | input data to update hash with
  len | input data length

## av_sha_final()

void av_sha_final | ( | struct AVSHA * | context,
|  | uint8_t * | digest
| ) |  |

Finish hashing and output digest value.

Parameters

  context | hash function context
  digest | buffer where output digest value is stored

## Variable Documentation

## av_sha_size

const int av_sha_size

extern