FFmpeg
Loading...
Searching...
No Matches
hash.c File Reference
#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "hash.h"
#include "adler32.h"
#include "crc.h"
#include "md5.h"
#include "murmur3.h"
#include "ripemd.h"
#include "sha.h"
#include "sha512.h"
#include "avstring.h"
#include "base64.h"
#include "error.h"
#include "intreadwrite.h"
#include "mem.h"

Go to the source code of this file.

Data Structures

struct  AVHashContext
 

Macros

#define HASHES(ENTRY)
 
#define HASH_TYPE(TYPE, NAME, SIZE)
 
#define HASH_MAX_SIZE(TYPE, NAME, SIZE)
 
#define HASH_MAX_NAME_SIZE(TYPE, NAME, SIZE)
 
#define HASH_DESC(TYPE, NAME, SIZE)
 

Enumerations

enum  hashtype { NUM_HASHES }
 
enum  { MAX_HASH_SIZE }
 
enum  { MAX_HASH_NAME_SIZE }
 

Functions

const char * av_hash_names (int i)
 Get the names of available hash algorithms.
 
const char * av_hash_get_name (const AVHashContext *ctx)
 
int av_hash_get_size (const AVHashContext *ctx)
 
int av_hash_alloc (AVHashContext **ctx, const char *name)
 Allocate a hash context for the algorithm specified by name.
 
void av_hash_init (AVHashContext *ctx)
 Initialize or reset a hash context.
 
void av_hash_update (AVHashContext *ctx, const uint8_t *src, size_t len)
 Update a hash context with additional data.
 
void av_hash_final (AVHashContext *ctx, uint8_t *dst)
 Finalize a hash context and compute the actual hash value.
 
void av_hash_final_bin (struct AVHashContext *ctx, uint8_t *dst, int size)
 Finalize a hash context and store the actual hash value in a buffer.
 
void av_hash_final_hex (struct AVHashContext *ctx, uint8_t *dst, int size)
 Finalize a hash context and store the hexadecimal representation of the actual hash value as a string.
 
void av_hash_final_b64 (struct AVHashContext *ctx, uint8_t *dst, int size)
 Finalize a hash context and store the Base64 representation of the actual hash value as a string.
 
void av_hash_freep (AVHashContext **ctx)
 Free hash context and set hash context pointer to NULL.
 

Variables

struct { 
 
   const char   name [MAX_HASH_NAME_SIZE
 
   int   size 
 
hashdesc [] 
 

Macro Definition Documentation

◆ HASHES

#define HASHES ( ENTRY)
Value:
ENTRY(MD5, "MD5", 16) \
ENTRY(MURMUR3, "murmur3", 16) \
ENTRY(RIPEMD128, "RIPEMD128", 16) \
ENTRY(RIPEMD160, "RIPEMD160", 20) \
ENTRY(RIPEMD256, "RIPEMD256", 32) \
ENTRY(RIPEMD320, "RIPEMD320", 40) \
ENTRY(SHA160, "SHA160", 20) \
ENTRY(SHA224, "SHA224", 28) \
ENTRY(SHA256, "SHA256", 32) \
ENTRY(SHA512_224, "SHA512/224", 28) \
ENTRY(SHA512_256, "SHA512/256", 32) \
ENTRY(SHA384, "SHA384", 48) \
ENTRY(SHA512, "SHA512", 64) \
ENTRY(CRC32, "CRC32", 4) \
ENTRY(ADLER32, "adler32", 4) \
#define ENTRY(idx, string)

Definition at line 43 of file hash.c.

◆ HASH_TYPE

#define HASH_TYPE ( TYPE,
NAME,
SIZE )
Value:
#define TYPE
Definition ffv1dec.c:90

Definition at line 61 of file hash.c.

◆ HASH_MAX_SIZE

#define HASH_MAX_SIZE ( TYPE,
NAME,
SIZE )
Value:
HASH_MAX_SIZE_BEFORE_ ## TYPE, \
HASH_MAX_SIZE_UNTIL_ ## TYPE ## _MINUS_ONE = FFMAX(SIZE, HASH_MAX_SIZE_BEFORE_ ## TYPE) - 1,
#define SIZE
#define FFMAX(a, b)
Definition macros.h:47

Definition at line 73 of file hash.c.

◆ HASH_MAX_NAME_SIZE

#define HASH_MAX_NAME_SIZE ( TYPE,
NAME,
SIZE )
Value:
HASH_MAX_NAME_SIZE_BEFORE_ ## TYPE, \
HASH_MAX_NAME_SIZE_UNTIL_ ## TYPE ## _MINUS_ONE = FFMAX(sizeof(NAME), HASH_MAX_NAME_SIZE_BEFORE_ ## TYPE) - 1,

Definition at line 82 of file hash.c.

◆ HASH_DESC

#define HASH_DESC ( TYPE,
NAME,
SIZE )
Value:
[TYPE] = { NAME, SIZE },

Enumeration Type Documentation

◆ hashtype

enum hashtype
Enumerator
NUM_HASHES 

Definition at line 60 of file hash.c.

◆ anonymous enum

anonymous enum
Enumerator
MAX_HASH_SIZE 

Definition at line 76 of file hash.c.

◆ anonymous enum

anonymous enum
Enumerator
MAX_HASH_NAME_SIZE 

Definition at line 85 of file hash.c.

Function Documentation

◆ av_hash_get_name()

const char * av_hash_get_name ( const AVHashContext * ctx)
Examples
ffhash.c.

Definition at line 104 of file hash.c.

Referenced by avtext_print_data_hash(), check(), finish(), and main().

◆ av_hash_get_size()

int av_hash_get_size ( const AVHashContext * ctx)

Definition at line 109 of file hash.c.

Referenced by av_hash_final_b64(), av_hash_final_bin(), av_hash_final_hex(), decode(), hash_uri(), and main().

Variable Documentation

◆ name

const char name[MAX_HASH_NAME_SIZE]

Definition at line 91 of file hash.c.

◆ size

int size

Definition at line 92 of file hash.c.

◆ [struct]

const struct { ... } hashdesc[]
Initial value:
= {
#define HASH_DESC(TYPE, NAME, SIZE)
}

Referenced by av_hash_alloc(), av_hash_get_name(), av_hash_get_size(), and av_hash_names().