YAZ 5.37.0
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)
#define blk0(i)
#define blk(i)
#define R0(v, w, x, y, z, i)
#define R1(v, w, x, y, z, i)
#define R2(v, w, x, y, z, i)
#define R3(v, w, x, y, z, i)
#define R4(v, w, x, y, z, i)

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
int wrbuf_sha1_puts (WRBUF b, const char *cp, int hexit)
 writes SHA1 text to WRBUF

Detailed Description

Implements SHA1 creation over WRBUF.

Definition in file wrbuf_sha1.c.

Macro Definition Documentation

◆ blk

#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.

◆ blk0

#define blk0 ( i)
Value:
(block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
|(rol(block->l[i],8)&0x00FF00FF))

Definition at line 51 of file wrbuf_sha1.c.

◆ R0

#define R0 ( v,
w,
x,
y,
z,
i )
Value:
z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
unsigned y
#define blk0(i)
Definition wrbuf_sha1.c:51

Definition at line 58 of file wrbuf_sha1.c.

Referenced by SHA1Transform().

◆ R1

#define R1 ( v,
w,
x,
y,
z,
i )
Value:
z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
#define blk(i)
Definition wrbuf_sha1.c:54

Definition at line 59 of file wrbuf_sha1.c.

Referenced by SHA1Transform().

◆ R2

#define R2 ( v,
w,
x,
y,
z,
i )
Value:
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().

◆ R3

#define R3 ( v,
w,
x,
y,
z,
i )
Value:
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().

◆ R4

#define R4 ( v,
w,
x,
y,
z,
i )
Value:
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().

◆ rol

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

Definition at line 44 of file wrbuf_sha1.c.

◆ SHA1HANDSOFF

#define SHA1HANDSOFF

Definition at line 29 of file wrbuf_sha1.c.

Function Documentation

◆ SHA1Final()

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().

◆ SHA1Init()

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().

◆ SHA1Transform()

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().

◆ SHA1Update()

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().

◆ wrbuf_sha1_puts()

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().

◆ wrbuf_sha1_write()

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().