sha1.c File Reference

#include <stdio.h>
#include <string.h>
#include <endian.h>
#include "sha1.h"

Go to the source code of this file.

Defines

#define rol(value, bits)   (((value) << (bits)) | ((value) >> (32 - (bits))))
#define blk0(i)   block.l[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 SHA1_Transform (uint32_t state[5], const uint8_t buffer[64])
void sat_SHA1_Init (SHA1_CTX *context)
void sat_SHA1_Update (SHA1_CTX *context, const uint8_t *data, const size_t len)
void sat_SHA1_Final (SHA1_CTX *context, uint8_t digest[SHA1_DIGEST_SIZE])


Define Documentation

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

Definition at line 87 of file sha1.c.

#define blk0 (  )     block.l[i]

Definition at line 93 of file sha1.c.

#define blk (  ) 

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 98 of file 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 102 of file sha1.c.

Referenced by SHA1_Transform().

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

Referenced by SHA1_Transform().

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

Definition at line 104 of file sha1.c.

Referenced by SHA1_Transform().

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

Referenced by SHA1_Transform().

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

Definition at line 106 of file sha1.c.

Referenced by SHA1_Transform().


Function Documentation

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

Definition at line 110 of file sha1.c.

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

Referenced by sat_SHA1_Update().

void sat_SHA1_Init ( SHA1_CTX context  ) 

Definition at line 163 of file sha1.c.

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

Referenced by sat_chksum_create().

void sat_SHA1_Update ( SHA1_CTX context,
const uint8_t *  data,
const size_t  len 
)

Definition at line 176 of file sha1.c.

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

Referenced by sat_chksum_add(), and sat_SHA1_Final().

void sat_SHA1_Final ( SHA1_CTX context,
uint8_t  digest[SHA1_DIGEST_SIZE] 
)

Definition at line 205 of file sha1.c.

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

Referenced by sat_chksum_get().


doxygen