FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
ripemd.c File Reference
#include <string.h>
#include "attributes.h"
#include "avutil.h"
#include "bswap.h"
#include "intreadwrite.h"
#include "ripemd.h"
#include "mem.h"

Go to the source code of this file.

Data Structures

struct  AVRIPEMD
 hash context More...
 

Macros

#define rol(value, bits)   ((value << bits) | (value >> (32 - bits)))
 
#define SWAP(a, b)   if (ext) { int t = a; a = b; b = t; }
 
#define ROUND128_0_TO_15(a, b, c, d, e, f, g, h)
 
#define ROUND128_16_TO_31(a, b, c, d, e, f, g, h)
 
#define ROUND128_32_TO_47(a, b, c, d, e, f, g, h)
 
#define ROUND128_48_TO_63(a, b, c, d, e, f, g, h)
 
#define ROTATE(x, y)
 
#define ROUND160_0_TO_15(a, b, c, d, e, f, g, h, i, j)
 
#define ROUND160_16_TO_31(a, b, c, d, e, f, g, h, i, j)
 
#define ROUND160_32_TO_47(a, b, c, d, e, f, g, h, i, j)
 
#define ROUND160_48_TO_63(a, b, c, d, e, f, g, h, i, j)
 
#define ROUND160_64_TO_79(a, b, c, d, e, f, g, h, i, j)
 

Functions

struct AVRIPEMDav_ripemd_alloc (void)
 Allocate an AVRIPEMD context.
 
static void ripemd128_transform (uint32_t *state, const uint8_t buffer[64], int ext)
 
static void ripemd160_transform (uint32_t *state, const uint8_t buffer[64], int ext)
 
av_cold int av_ripemd_init (AVRIPEMD *ctx, int bits)
 Initialize RIPEMD hashing.
 
void av_ripemd_update (AVRIPEMD *ctx, const uint8_t *data, unsigned int len)
 Update hash value.
 
void av_ripemd_final (AVRIPEMD *ctx, uint8_t *digest)
 Finish hashing and output digest value.
 

Variables

const int av_ripemd_size = sizeof(AVRIPEMD)
 
static const uint32_t KA [4]
 
static const uint32_t KB [4]
 
static const int ROTA [80]
 
static const int ROTB [80]
 
static const int WA [80]
 
static const int WB [80]
 

Macro Definition Documentation

#define rol (   value,
  bits 
)    ((value << bits) | (value >> (32 - bits)))

Definition at line 89 of file ripemd.c.

#define SWAP (   a,
  b 
)    if (ext) { int t = a; a = b; b = t; }

Definition at line 91 of file ripemd.c.

Referenced by ripemd128_transform(), and ripemd160_transform().

#define ROUND128_0_TO_15 (   a,
  b,
  c,
  d,
  e,
  f,
  g,
 
)
Value:
a = rol(a + (( b ^ c ^ d) + block[WA[n]]), ROTA[n]); \
e = rol(e + ((((f ^ g) & h) ^ g) + block[WB[n]] + KB[0]), ROTB[n]); \
n++

Definition at line 93 of file ripemd.c.

Referenced by ripemd128_transform().

#define ROUND128_16_TO_31 (   a,
  b,
  c,
  d,
  e,
  f,
  g,
 
)
Value:
a = rol(a + ((((c ^ d) & b) ^ d) + block[WA[n]] + KA[0]), ROTA[n]); \
e = rol(e + (((~g | f) ^ h) + block[WB[n]] + KB[1]), ROTB[n]); \
n++

Definition at line 98 of file ripemd.c.

Referenced by ripemd128_transform().

#define ROUND128_32_TO_47 (   a,
  b,
  c,
  d,
  e,
  f,
  g,
 
)
Value:
a = rol(a + (((~c | b) ^ d) + block[WA[n]] + KA[1]), ROTA[n]); \
e = rol(e + ((((g ^ h) & f) ^ h) + block[WB[n]] + KB[2]), ROTB[n]); \
n++

Definition at line 103 of file ripemd.c.

Referenced by ripemd128_transform().

#define ROUND128_48_TO_63 (   a,
  b,
  c,
  d,
  e,
  f,
  g,
 
)
Value:
a = rol(a + ((((b ^ c) & d) ^ c) + block[WA[n]] + KA[2]), ROTA[n]); \
e = rol(e + (( f ^ g ^ h) + block[WB[n]]), ROTB[n]); \
n++

Definition at line 108 of file ripemd.c.

Referenced by ripemd128_transform().

#define ROTATE (   x,
  y 
)
Value:
x = rol(x, 10); \
y = rol(y, 10); \
n++

Definition at line 176 of file ripemd.c.

#define ROUND160_0_TO_15 (   a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  i,
 
)
Value:
a = rol(a + (( b ^ c ^ d) + block[WA[n]]), ROTA[n]) + e; \
f = rol(f + (((~i | h) ^ g) + block[WB[n]] + KB[0]), ROTB[n]) + j; \
ROTATE(c,h)

Definition at line 181 of file ripemd.c.

Referenced by ripemd160_transform().

#define ROUND160_16_TO_31 (   a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  i,
 
)
Value:
a = rol(a + ((((c ^ d) & b) ^ d) + block[WA[n]] + KA[0]), ROTA[n]) + e; \
f = rol(f + ((((g ^ h) & i) ^ h) + block[WB[n]] + KB[1]), ROTB[n]) + j; \
ROTATE(c,h)

Definition at line 186 of file ripemd.c.

Referenced by ripemd160_transform().

#define ROUND160_32_TO_47 (   a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  i,
 
)
Value:
a = rol(a + (((~c | b) ^ d) + block[WA[n]] + KA[1]), ROTA[n]) + e; \
f = rol(f + (((~h | g) ^ i) + block[WB[n]] + KB[2]), ROTB[n]) + j; \
ROTATE(c,h)

Definition at line 191 of file ripemd.c.

Referenced by ripemd160_transform().

#define ROUND160_48_TO_63 (   a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  i,
 
)
Value:
a = rol(a + ((((b ^ c) & d) ^ c) + block[WA[n]] + KA[2]), ROTA[n]) + e; \
f = rol(f + ((((h ^ i) & g) ^ i) + block[WB[n]] + KB[3]), ROTB[n]) + j; \
ROTATE(c,h)

Definition at line 196 of file ripemd.c.

Referenced by ripemd160_transform().

#define ROUND160_64_TO_79 (   a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  i,
 
)
Value:
a = rol(a + (((~d | c) ^ b) + block[WA[n]] + KA[3]), ROTA[n]) + e; \
f = rol(f + (( g ^ h ^ i) + block[WB[n]]), ROTB[n]) + j; \
ROTATE(c,h)

Definition at line 201 of file ripemd.c.

Referenced by ripemd160_transform().

Function Documentation

static void ripemd128_transform ( uint32_t *  state,
const uint8_t  buffer[64],
int  ext 
)
static

Definition at line 113 of file ripemd.c.

Referenced by av_ripemd_init().

static void ripemd160_transform ( uint32_t *  state,
const uint8_t  buffer[64],
int  ext 
)
static

Definition at line 206 of file ripemd.c.

Referenced by av_ripemd_init().

Variable Documentation

const uint32_t KA[4]
static
Initial value:
= {
0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xa953fd4e
}

Definition at line 49 of file ripemd.c.

const uint32_t KB[4]
static
Initial value:
= {
0x50a28be6, 0x5c4dd124, 0x6d703ef3, 0x7a6d76e9
}

Definition at line 53 of file ripemd.c.

const int ROTA[80]
static
Initial value:
= {
11, 14, 15, 12, 5, 8, 7 , 9, 11, 13, 14, 15, 6, 7, 9, 8,
7 , 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
}

Definition at line 57 of file ripemd.c.

const int ROTB[80]
static
Initial value:
= {
8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
}

Definition at line 65 of file ripemd.c.

const int WA[80]
static
Initial value:
= {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
}

Definition at line 73 of file ripemd.c.

const int WB[80]
static
Initial value:
= {
5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
}

Definition at line 81 of file ripemd.c.