sha1.c File Reference

Go to the source code of this file.

Macros

#define SHA1HANDSOFF   1 /* Copies data before messing with it. */
 
#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

void ldns_sha1_transform (uint32_t state[5], const unsigned char buffer[64])
 
void ldns_sha1_init (ldns_sha1_ctx *context)
 
void ldns_sha1_update (ldns_sha1_ctx *context, const unsigned char *data, unsigned int len)
 
void ldns_sha1_final (unsigned char digest[20], ldns_sha1_ctx *context)
 
unsigned char * ldns_sha1 (const unsigned char *data, unsigned int data_len, unsigned char *digest)
 Convenience function to digest a fixed block of data at once. More...
 

Macro Definition Documentation

◆ SHA1HANDSOFF

#define SHA1HANDSOFF   1 /* Copies data before messing with it. */

Definition at line 23 of file sha1.c.

◆ rol

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

Definition at line 24 of file sha1.c.

◆ blk0

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

Definition at line 29 of file sha1.c.

◆ 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))

Definition at line 34 of file sha1.c.

◆ R0

#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 38 of file sha1.c.

◆ R1

#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 39 of file sha1.c.

◆ R2

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

Definition at line 40 of file sha1.c.

◆ R3

#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 41 of file sha1.c.

◆ R4

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

Definition at line 42 of file sha1.c.

Function Documentation

◆ ldns_sha1_transform()

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

Definition at line 47 of file sha1.c.

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

◆ ldns_sha1_init()

void ldns_sha1_init ( ldns_sha1_ctx context)

Definition at line 107 of file sha1.c.

References ldns_sha1_ctx::count, and ldns_sha1_ctx::state.

◆ ldns_sha1_update()

void ldns_sha1_update ( ldns_sha1_ctx context,
const unsigned char *  data,
unsigned int  len 
)

◆ ldns_sha1_final()

void ldns_sha1_final ( unsigned char  digest[20],
ldns_sha1_ctx context 
)

◆ ldns_sha1()

unsigned char* ldns_sha1 ( const unsigned char *  data,
unsigned int  data_len,
unsigned char *  digest 
)

Convenience function to digest a fixed block of data at once.

Parameters
[in]datathe data to digest
[in]data_lenthe length of data in bytes
[out]digestthe length of data in bytes This pointer MUST have LDNS_SHA1_DIGEST_LENGTH bytes available
Returns
the SHA1 digest of the given data

Definition at line 171 of file sha1.c.

References ldns_sha1_final(), ldns_sha1_init(), and ldns_sha1_update().