Ruby  2.5.0dev(2017-10-22revision60238)
Data Structures | Macros | Functions
sha1.c File Reference
#include "sha1.h"
#include <assert.h>
#include <string.h>

Go to the source code of this file.

Data Structures

union  CHAR64LONG16
 

Macros

#define SHA1HANDSOFF   /* Copies data before messing with it. */
 
#define _DIAGASSERT(cond)   assert(cond)
 
#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 SHA1_Transform (uint32_t state[5], const uint8_t buffer[64])
 
int SHA1_Init (SHA1_CTX *context)
 
void SHA1_Update (SHA1_CTX *context, const uint8_t *data, size_t len)
 
int SHA1_Finish (SHA1_CTX *context, uint8_t digest[20])
 

Macro Definition Documentation

◆ _DIAGASSERT

#define _DIAGASSERT (   cond)    assert(cond)

Definition at line 35 of file sha1.c.

Referenced by SHA1_Finish(), SHA1_Init(), SHA1_Transform(), and SHA1_Update().

◆ 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: sha1.c:46

Definition at line 58 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:46

Definition at line 53 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 64 of file sha1.c.

Referenced by SHA1_Transform().

◆ 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 65 of file sha1.c.

Referenced by SHA1_Transform().

◆ 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 66 of file sha1.c.

Referenced by SHA1_Transform().

◆ 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 67 of file sha1.c.

Referenced by SHA1_Transform().

◆ 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 68 of file sha1.c.

Referenced by SHA1_Transform().

◆ rol

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

Definition at line 46 of file sha1.c.

◆ SHA1HANDSOFF

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

Definition at line 22 of file sha1.c.

Function Documentation

◆ SHA1_Finish()

int SHA1_Finish ( SHA1_CTX context,
uint8_t  digest[20] 
)

Definition at line 248 of file sha1.c.

References _DIAGASSERT, SHA1_CTX::count, SHA1_Update(), and SHA1_CTX::state.

◆ SHA1_Init()

int SHA1_Init ( SHA1_CTX context)

Definition at line 202 of file sha1.c.

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

◆ SHA1_Transform()

void SHA1_Transform ( uint32_t  state[5],
const uint8_t  buffer[64] 
)

Definition at line 132 of file sha1.c.

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

Referenced by SHA1_Update().

◆ SHA1_Update()

void SHA1_Update ( SHA1_CTX context,
const uint8_t data,
size_t  len 
)

Definition at line 221 of file sha1.c.

References _DIAGASSERT, SHA1_CTX::buffer, SHA1_CTX::count, len, SHA1_Transform(), and SHA1_CTX::state.

Referenced by SHA1_Finish().