YAZ  5.23.1
Data Structures | Macros | Functions
wrbuf_sha1.c File Reference

Implements SHA1 creation over WRBUF. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <yaz/wrbuf.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  SHA1_CTX
 

Macros

#define SHA1HANDSOFF
 
#define rol(value, bits)   (((value) << (bits)) | ((value) >> (32 - (bits))))
 
#define blk0(i)
 
#define blk(i)
 
#define R0(v, w, x, y, z, i)   z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
 
#define R1(v, w, x, y, z, i)   z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
 
#define R2(v, w, x, y, z, i)   z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
 
#define R3(v, w, x, y, z, i)   z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
 
#define R4(v, w, x, y, z, i)   z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
 

Functions

static void SHA1Transform (uint32_t state[5], const unsigned char buffer[64])
 
static void SHA1Init (SHA1_CTX *context)
 
static void SHA1Update (SHA1_CTX *context, const unsigned char *data, uint32_t len)
 
static void SHA1Final (unsigned char digest[20], SHA1_CTX *context)
 
int wrbuf_sha1_write (WRBUF b, const char *cp, size_t sz, int hexit)
 writes SHA1 text to WRBUF More...
 
int wrbuf_sha1_puts (WRBUF b, const char *cp, int hexit)
 writes SHA1 text to WRBUF More...
 

Detailed Description

Implements SHA1 creation over WRBUF.

Definition in file wrbuf_sha1.c.

Macro Definition Documentation

#define blk (   i)
Value:
(block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
^block->l[(i+2)&15]^block->l[i&15],1))
#define rol(value, bits)
Definition: wrbuf_sha1.c:44

Definition at line 54 of file wrbuf_sha1.c.

#define blk0 (   i)
Value:
(block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
|(rol(block->l[i],8)&0x00FF00FF))
#define rol(value, bits)
Definition: wrbuf_sha1.c:44

Definition at line 51 of file wrbuf_sha1.c.

#define R0 (   v,
  w,
  x,
  y,
  z,
 
)    z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);

Definition at line 58 of file wrbuf_sha1.c.

Referenced by SHA1Transform().

#define R1 (   v,
  w,
  x,
  y,
  z,
 
)    z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);

Definition at line 59 of file wrbuf_sha1.c.

Referenced by SHA1Transform().

#define R2 (   v,
  w,
  x,
  y,
  z,
 
)    z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);

Definition at line 60 of file wrbuf_sha1.c.

Referenced by SHA1Transform().

#define R3 (   v,
  w,
  x,
  y,
  z,
 
)    z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);

Definition at line 61 of file wrbuf_sha1.c.

Referenced by SHA1Transform().

#define R4 (   v,
  w,
  x,
  y,
  z,
 
)    z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);

Definition at line 62 of file wrbuf_sha1.c.

Referenced by SHA1Transform().

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

Definition at line 44 of file wrbuf_sha1.c.

#define SHA1HANDSOFF

Definition at line 29 of file wrbuf_sha1.c.

Function Documentation

static void SHA1Final ( unsigned char  digest[20],
SHA1_CTX context 
)
static

Definition at line 167 of file wrbuf_sha1.c.

References SHA1_CTX::count, SHA1Update(), and SHA1_CTX::state.

Referenced by wrbuf_sha1_write().

static void SHA1Init ( SHA1_CTX context)
static

Definition at line 128 of file wrbuf_sha1.c.

References SHA1_CTX::count, and SHA1_CTX::state.

Referenced by wrbuf_sha1_write().

static void SHA1Transform ( uint32_t  state[5],
const unsigned char  buffer[64] 
)
static

Definition at line 67 of file wrbuf_sha1.c.

References R0, R1, R2, R3, and R4.

Referenced by SHA1Update().

static void SHA1Update ( SHA1_CTX context,
const unsigned char *  data,
uint32_t  len 
)
static

Definition at line 142 of file wrbuf_sha1.c.

References SHA1_CTX::buffer, SHA1_CTX::count, SHA1Transform(), and SHA1_CTX::state.

Referenced by SHA1Final(), and wrbuf_sha1_write().

int wrbuf_sha1_puts ( WRBUF  b,
const char *  cp,
int  hexit 
)

writes SHA1 text to WRBUF

Parameters
bresult
cpC-string
hexit1=hex mode; 0=binary
Returns
0 if successful
-1 on error

Definition at line 214 of file wrbuf_sha1.c.

References wrbuf_sha1_write().

Referenced by wrbuf_vary_puts(), and ZOOM_memcached_resultset().

int wrbuf_sha1_write ( WRBUF  b,
const char *  cp,
size_t  sz,
int  hexit 
)

writes SHA1 text to WRBUF

Parameters
bresult
cpchar buffer
szsize of char buffer
hexit1=hex mode; 0=binary
Returns
0 if successful
-1 on error

Definition at line 194 of file wrbuf_sha1.c.

References SHA1Final(), SHA1Init(), SHA1Update(), wrbuf_printf(), and wrbuf_write().

Referenced by wrbuf_sha1_puts(), and ZOOM_memcached_add().