#include "sha1.h"
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
Defines | |
#define | SWAP(n) (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24)) |
#define | BLOCKSIZE 32768 |
#define | alignof(type) offsetof (struct { char c; type x; }, x) |
#define | UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0) |
#define | K1 0x5a827999 |
#define | K2 0x6ed9eba1 |
#define | K3 0x8f1bbcdc |
#define | K4 0xca62c1d6 |
#define | F1(B, C, D) ( D ^ ( B & ( C ^ D ) ) ) |
#define | F2(B, C, D) (B ^ C ^ D) |
#define | F3(B, C, D) ( ( B & C ) | ( D & ( B | C ) ) ) |
#define | F4(B, C, D) (B ^ C ^ D) |
#define | rol(x, n) (((x) << (n)) | ((uint32_t) (x) >> (32 - (n)))) |
#define | M(I) |
#define | R(A, B, C, D, E, F, K, M) |
Functions | |
void | sha1_init_ctx (struct sha1_ctx *ctx) |
static void | set_uint32 (char *cp, uint32_t v) |
void * | sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf) |
void * | sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf) |
int | sha1_stream (FILE *stream, void *resblock) |
void * | sha1_buffer (const char *buffer, size_t len, void *resblock) |
void | sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx) |
void | sha1_process_block (const void *buffer, size_t len, struct sha1_ctx *ctx) |
Variables | |
static const unsigned char | fillbuf [64] = { 0x80, 0 } |
#define BLOCKSIZE 32768 |
Referenced by sha1_stream().
#define F1 | ( | B, | ||
C, | ||||
D | ||||
) | ( D ^ ( B & ( C ^ D ) ) ) |
Referenced by sha1_process_block().
#define F2 | ( | B, | ||
C, | ||||
D | ||||
) | (B ^ C ^ D) |
Referenced by sha1_process_block().
#define F3 | ( | B, | ||
C, | ||||
D | ||||
) | ( ( B & C ) | ( D & ( B | C ) ) ) |
Referenced by sha1_process_block().
#define F4 | ( | B, | ||
C, | ||||
D | ||||
) | (B ^ C ^ D) |
Referenced by sha1_process_block().
#define K1 0x5a827999 |
Referenced by sha1_process_block().
#define K2 0x6ed9eba1 |
Referenced by sha1_process_block().
#define K3 0x8f1bbcdc |
Referenced by sha1_process_block().
#define K4 0xca62c1d6 |
Referenced by sha1_process_block().
#define M | ( | I | ) |
#define R | ( | A, | ||
B, | ||||
C, | ||||
D, | ||||
E, | ||||
F, | ||||
K, | ||||
M | ||||
) |
Referenced by sha1_process_block().
#define SWAP | ( | n | ) | (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24)) |
Referenced by sha1_finish_ctx(), sha1_process_block(), and sha1_read_ctx().
#define UNALIGNED_P | ( | p | ) | (((size_t) p) % alignof (uint32_t) != 0) |
Referenced by sha1_process_bytes().
static void set_uint32 | ( | char * | cp, | |
uint32_t | v | |||
) | [inline, static] |
Referenced by sha1_read_ctx().
void* sha1_buffer | ( | const char * | buffer, | |
size_t | len, | |||
void * | resblock | |||
) |
References sha1_finish_ctx(), sha1_init_ctx(), and sha1_process_bytes().
Referenced by ODc_Crypto::performDecrypt().
void* sha1_finish_ctx | ( | struct sha1_ctx * | ctx, | |
void * | resbuf | |||
) |
References sha1_ctx::buffer, sha1_ctx::buflen, fillbuf, sha1_process_block(), sha1_read_ctx(), size, SWAP, and sha1_ctx::total.
Referenced by hmac_sha1(), sha1_buffer(), and sha1_stream().
void sha1_init_ctx | ( | struct sha1_ctx * | ctx | ) |
References sha1_ctx::A, sha1_ctx::B, sha1_ctx::buflen, sha1_ctx::C, sha1_ctx::D, sha1_ctx::E, and sha1_ctx::total.
Referenced by hmac_sha1(), sha1_buffer(), and sha1_stream().
void sha1_process_block | ( | const void * | buffer, | |
size_t | len, | |||
struct sha1_ctx * | ctx | |||
) |
References sha1_ctx::A, sha1_ctx::B, sha1_ctx::C, sha1_ctx::D, d, sha1_ctx::E, F1, F2, F3, F4, K1, K2, K3, K4, M, R, SWAP, and sha1_ctx::total.
Referenced by hmac_sha1(), sha1_finish_ctx(), sha1_process_bytes(), and sha1_stream().
void sha1_process_bytes | ( | const void * | buffer, | |
size_t | len, | |||
struct sha1_ctx * | ctx | |||
) |
References sha1_ctx::buffer, sha1_ctx::buflen, sha1_process_block(), and UNALIGNED_P.
Referenced by hmac_sha1(), sha1_buffer(), and sha1_stream().
void* sha1_read_ctx | ( | const struct sha1_ctx * | ctx, | |
void * | resbuf | |||
) |
References sha1_ctx::A, sha1_ctx::B, sha1_ctx::C, sha1_ctx::D, sha1_ctx::E, set_uint32(), and SWAP.
Referenced by sha1_finish_ctx().
int sha1_stream | ( | FILE * | stream, | |
void * | resblock | |||
) |
References BLOCKSIZE, sha1_finish_ctx(), sha1_init_ctx(), sha1_process_block(), and sha1_process_bytes().
const unsigned char fillbuf[64] = { 0x80, 0 } [static] |
Referenced by sha1_finish_ctx().