PostgreSQL Source Code  git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
sha1_int.h File Reference
#include "common/sha1.h"
Include dependency graph for sha1_int.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  pg_sha1_ctx
 

Functions

void pg_sha1_init (pg_sha1_ctx *ctx)
 
void pg_sha1_update (pg_sha1_ctx *ctx, const uint8 *data, size_t len)
 
void pg_sha1_final (pg_sha1_ctx *ctx, uint8 *dest)
 

Function Documentation

◆ pg_sha1_final()

void pg_sha1_final ( pg_sha1_ctx ctx,
uint8 dest 
)

Definition at line 365 of file sha1.c.

366 {
367  sha1_pad(ctx);
368  sha1_result(dest, ctx);
369 }
static void sha1_result(uint8 *digest0, pg_sha1_ctx *ctx)
Definition: sha1.c:276
static void sha1_pad(pg_sha1_ctx *ctx)
Definition: sha1.c:233

References generate_unaccent_rules::dest, sha1_pad(), and sha1_result().

Referenced by pg_cryptohash_final().

◆ pg_sha1_init()

void pg_sha1_init ( pg_sha1_ctx ctx)

Definition at line 316 of file sha1.c.

317 {
318  memset(ctx, 0, sizeof(pg_sha1_ctx));
319  H(0) = 0x67452301;
320  H(1) = 0xefcdab89;
321  H(2) = 0x98badcfe;
322  H(3) = 0x10325476;
323  H(4) = 0xc3d2e1f0;
324 }
#define H(n)
Definition: sha1.c:75

References H.

Referenced by pg_cryptohash_init().

◆ pg_sha1_update()

void pg_sha1_update ( pg_sha1_ctx ctx,
const uint8 data,
size_t  len 
)

Definition at line 332 of file sha1.c.

333 {
334  const uint8 *input;
335  size_t gaplen;
336  size_t gapstart;
337  size_t off;
338  size_t copysiz;
339 
340  input = (const uint8 *) data;
341  off = 0;
342 
343  while (off < len)
344  {
345  gapstart = COUNT % 64;
346  gaplen = 64 - gapstart;
347 
348  copysiz = (gaplen < len - off) ? gaplen : len - off;
349  memmove(&ctx->m.b8[gapstart], &input[off], copysiz);
350  COUNT += copysiz;
351  COUNT %= 64;
352  ctx->c.b64[0] += copysiz * 8;
353  if (COUNT % 64 == 0)
354  sha1_step(ctx);
355  off += copysiz;
356  }
357 }
unsigned char uint8
Definition: c.h:516
FILE * input
const void size_t len
const void * data
static void sha1_step(pg_sha1_ctx *ctx)
Definition: sha1.c:90
#define COUNT
Definition: sha1.c:76
uint8 b8[20]
Definition: sha1_int.h:60
union pg_sha1_ctx::@42 c
union pg_sha1_ctx::@43 m
uint64 b64[1]
Definition: sha1_int.h:66

References pg_sha1_ctx::b64, pg_sha1_ctx::b8, pg_sha1_ctx::c, COUNT, data, input, len, pg_sha1_ctx::m, and sha1_step().

Referenced by pg_cryptohash_update().