Loading...
Searching...
No Matches
md5.c File Reference
`#include <stdbool.h>`
`#include <stdio.h>`
`#include <string.h>`
`#include "decls.h"`
`#include "md5.h"`

Go to the source code of this file.

## Macros

#define | AARU_RESTRICT
#define | LIKELY(x)
#define | UNLIKELY(x)
#define | HOT
#define | MD5_MAX_UNROLL 4
#define | MD5_PREFETCH_DISTANCE_BLOCKS 8
#define | MD5_ENABLE_PREFETCH 1
#define | MD5_UNROLL8_THRESHOLD 8192UL
#define | MD5_UNROLL4_THRESHOLD 2048UL
#define | MD5_UNROLL2_THRESHOLD 512UL
#define | F(x, y, z)
#define | G(x, y, z)
#define | H(x, y, z)
#define | H2(x, y, z)
#define | I(x, y, z)
#define | ROTL32(x, s)
#define | STEP(f, a, b, c, d, x, t, s)
#define | SET(n)
#define | GET(n)
#define | OUT(dst, src)

## Functions

FORCE_INLINE void | md5_process_block_loaded (uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, const unsigned char *ptr)
static const void * | body (md5_ctx *ctx, const void *data, unsigned long size)
void | aaruf_md5_init (md5_ctx *ctx)
void | aaruf_md5_update (md5_ctx *ctx, const void *data, unsigned long size)
void | aaruf_md5_final (md5_ctx *ctx, unsigned char *result)
void | aaruf_md5_buffer (const void *data, unsigned long size, unsigned char *result)

## Macro Definition Documentation

## AARU_RESTRICT

#define AARU_RESTRICT

Definition at line 49 of file md5.c.

Referenced by aaruf_md5_update(), body(), and md5_process_block_loaded().

## F

#define F | ( |  | x,
|  |  | y,
|  |  | z )

Value:
((z) ^ ((x) & ((y) ^ (z))))

Definition at line 105 of file md5.c.

Referenced by body(), and md5_process_block_loaded().

## G

#define G | ( |  | x,
|  |  | y,
|  |  | z )

Value:
((y) ^ ((z) & ((x) ^ (y))))

Definition at line 106 of file md5.c.

Referenced by body(), and md5_process_block_loaded().

## GET

#define GET | ( |  | n | ) |

Value:
(ctx->block[(n)])

Definition at line 155 of file md5.c.

Referenced by body().

## H

#define H | ( |  | x,
|  |  | y,
|  |  | z )

Value:
(((x) ^ (y)) ^ (z))

Definition at line 107 of file md5.c.

Referenced by body(), and md5_process_block_loaded().

## H2

#define H2 | ( |  | x,
|  |  | y,
|  |  | z )

Value:
((x) ^ ((y) ^ (z)))

Definition at line 108 of file md5.c.

Referenced by body(), and md5_process_block_loaded().

## HOT

#define HOT

Definition at line 65 of file md5.c.

Referenced by body(), and md5_process_block_loaded().

## I

#define I | ( |  | x,
|  |  | y,
|  |  | z )

Value:
((y) ^ ((x) | ~(z)))

Definition at line 109 of file md5.c.

Referenced by body(), and md5_process_block_loaded().

## LIKELY

#define LIKELY | ( |  | x | ) |

Value:
(x)

Definition at line 57 of file md5.c.

Referenced by aaruf_md5_update().

## MD5_ENABLE_PREFETCH

#define MD5_ENABLE_PREFETCH 1

Definition at line 75 of file md5.c.

## MD5_MAX_UNROLL

#define MD5_MAX_UNROLL 4

Definition at line 69 of file md5.c.

## MD5_PREFETCH_DISTANCE_BLOCKS

#define MD5_PREFETCH_DISTANCE_BLOCKS 8

Definition at line 72 of file md5.c.

Referenced by body().

## MD5_UNROLL2_THRESHOLD

#define MD5_UNROLL2_THRESHOLD 512UL

Definition at line 84 of file md5.c.

Referenced by body().

## MD5_UNROLL4_THRESHOLD

#define MD5_UNROLL4_THRESHOLD 2048UL

Definition at line 81 of file md5.c.

Referenced by body().

## MD5_UNROLL8_THRESHOLD

#define MD5_UNROLL8_THRESHOLD 8192UL

Definition at line 78 of file md5.c.

Referenced by body().

## OUT

#define OUT | ( |  | dst,
|  |  | src )

Value:
(dst)[0] = (unsigned char)(src); \
(dst)[1] = (unsigned char)((src) >> 8); \
(dst)[2] = (unsigned char)((src) >> 16); \
(dst)[3] = (unsigned char)((src) >> 24);

Definition at line 479 of file md5.c.

Referenced by aaruf_md5_final().

## ROTL32

#define ROTL32 | ( |  | x,
|  |  | s )

Value:
(((uint32_t)(x) << (s)) | ((uint32_t)(x) >> (32 - (s))))

Definition at line 122 of file md5.c.

## SET

#define SET | ( |  | n | ) |

Value:
(ctx->block[(n)] = (uint32_t)ptr[(n) * 4] | ((uint32_t)ptr[(n) * 4 + 1] << 8) | \
((uint32_t)ptr[(n) * 4 + 2] << 16) | ((uint32_t)ptr[(n) * 4 + 3] << 24))

Definition at line 152 of file md5.c.

Referenced by body().

## STEP

#define STEP | ( |  | f,
|  |  | a,
|  |  | b,
|  |  | c,
|  |  | d,
|  |  | x,
|  |  | t,
|  |  | s )

Value:
(a) += f((b), (c), (d)) + (x) + (uint32_t)(t); \
(a) = ROTL32((a), (s)); \
(a) += (b);
ROTL32
#define ROTL32(x, s)
Definition md5.c:122

Definition at line 128 of file md5.c.

Referenced by body(), and md5_process_block_loaded().

## UNLIKELY

#define UNLIKELY | ( |  | x | ) |

Value:
(x)

Definition at line 58 of file md5.c.

Referenced by aaruf_md5_update().

## Function Documentation

## aaruf_md5_buffer()

void aaruf_md5_buffer | ( | const void * | data,
|  | unsigned long | size,
|  | unsigned char * | result )

Definition at line 518 of file md5.c.

References AARU_CALL, AARU_EXPORT, aaruf_md5_final(), aaruf_md5_init(), and aaruf_md5_update().

## aaruf_md5_final()

void aaruf_md5_final | ( | md5_ctx * | ctx,
|  | unsigned char * | result )

Definition at line 485 of file md5.c.

References md5_ctx::a, AARU_CALL, AARU_EXPORT, md5_ctx::b, body(), md5_ctx::buffer, md5_ctx::c, md5_ctx::d, md5_ctx::hi, md5_ctx::lo, and OUT.

Referenced by aaruf_md5_buffer(), and write_checksum_block().

## aaruf_md5_init()

void aaruf_md5_init | ( | md5_ctx * | ctx | ) |

Definition at line 436 of file md5.c.

References md5_ctx::a, AARU_CALL, AARU_EXPORT, md5_ctx::b, md5_ctx::c, md5_ctx::d, md5_ctx::hi, and md5_ctx::lo.

Referenced by aaruf_create(), and aaruf_md5_buffer().

## aaruf_md5_update()

void aaruf_md5_update | ( | md5_ctx * | ctx,
|  | const void * | data,
|  | unsigned long | size )

Definition at line 447 of file md5.c.

References AARU_CALL, AARU_EXPORT, AARU_RESTRICT, body(), md5_ctx::buffer, md5_ctx::hi, LIKELY, md5_ctx::lo, and UNLIKELY.

Referenced by aaruf_md5_buffer(), aaruf_write_sector(), and aaruf_write_sector_long().

## body()

const void * body | ( | md5_ctx * | ctx,
|  | const void * | data,
|  | unsigned long | size )

static

Definition at line 268 of file md5.c.

References md5_ctx::a, AARU_RESTRICT, md5_ctx::b, md5_ctx::c, md5_ctx::d, F, G, GET, H, H2, HOT, I, MD5_PREFETCH_DISTANCE_BLOCKS, md5_process_block_loaded(), MD5_UNROLL2_THRESHOLD, MD5_UNROLL4_THRESHOLD, MD5_UNROLL8_THRESHOLD, SET, and STEP.

Referenced by aaruf_md5_final(), and aaruf_md5_update().

## md5_process_block_loaded()

FORCE_INLINE void md5_process_block_loaded | ( | uint32_t * | a,
|  | uint32_t * | b,
|  | uint32_t * | c,
|  | uint32_t * | d,
|  | const unsigned char * | ptr )

Definition at line 162 of file md5.c.

References AARU_RESTRICT, F, FORCE_INLINE, G, H, H2, HOT, I, and STEP.

Referenced by body().