gsasl  1.10.0
About: GNU SASL is an implementation of the Simple Authentication and Security Layer (SASL). Development version.
  Fossies Dox: gsasl-1.10.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

sha1.c File Reference
#include <config.h>
#include "sha1.h"
#include <stdalign.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <byteswap.h>
Include dependency graph for sha1.c:

Go to the source code of this file.

Macros

#define SWAP(n)   bswap_32 (n)
 
#define BLOCKSIZE   32768
 
#define UNALIGNED_P(p)   ((uintptr_t) (p) % alignof (uint32_t) != 0)
 
#define K1   0x5a827999
 
#define K2   0x6ed9eba1
 
#define K3   0x8f1bbcdc
 
#define K4   0xca62c1d6
 
#define F1(B, C, D)   ( D ^ ( B & ( C ^ D ) ) )
 
#define F2(B, C, D)   (B ^ C ^ D)
 
#define F3(B, C, D)   ( ( B & C ) | ( D & ( B | C ) ) )
 
#define F4(B, C, D)   (B ^ C ^ D)
 
#define rol(x, n)   (((x) << (n)) | ((uint32_t) (x) >> (32 - (n))))
 
#define M(I)
 
#define R(A, B, C, D, E, F, K, M)
 

Functions

void sha1_init_ctx (struct sha1_ctx *ctx)
 
static void set_uint32 (char *cp, unsigned int v)
 
void * sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf)
 
void * sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf)
 
void * sha1_buffer (const char *buffer, size_t len, void *resblock)
 
void sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx)
 
void sha1_process_block (const void *buffer, size_t len, struct sha1_ctx *ctx)
 

Variables

static const unsigned char fillbuf [64] = { 0x80, 0 }
 

Macro Definition Documentation

◆ BLOCKSIZE

#define BLOCKSIZE   32768

Definition at line 47 of file sha1.c.

◆ F1

#define F1 (   B,
  C,
 
)    ( D ^ ( B & ( C ^ D ) ) )

Definition at line 307 of file sha1.c.

◆ F2

#define F2 (   B,
  C,
 
)    (B ^ C ^ D)

Definition at line 308 of file sha1.c.

◆ F3

#define F3 (   B,
  C,
 
)    ( ( B & C ) | ( D & ( B | C ) ) )

Definition at line 309 of file sha1.c.

◆ F4

#define F4 (   B,
  C,
 
)    (B ^ C ^ D)

Definition at line 310 of file sha1.c.

◆ K1

#define K1   0x5a827999

Definition at line 301 of file sha1.c.

◆ K2

#define K2   0x6ed9eba1

Definition at line 302 of file sha1.c.

◆ K3

#define K3   0x8f1bbcdc

Definition at line 303 of file sha1.c.

◆ K4

#define K4   0xca62c1d6

Definition at line 304 of file sha1.c.

◆ M

#define M (   I)
Value:
( tm = x[I&0x0f] ^ x[(I-14)&0x0f] \
^ x[(I-8)&0x0f] ^ x[(I-3)&0x0f] \
, (x[I&0x0f] = rol(tm, 1)) )
#define rol(x, n)

◆ R

#define R (   A,
  B,
  C,
  D,
  E,
  F,
  K,
  M 
)
Value:
do { E += rol( A, 5 ) \
+ F( B, C, D ) \
+ K \
+ M; \
B = rol( B, 30 ); \
} while(0)
#define M(I)
#define K(I)
Definition: sha256.c:380

◆ rol

#define rol (   x,
 
)    (((x) << (n)) | ((uint32_t) (x) >> (32 - (n))))

◆ SWAP

#define SWAP (   n)    bswap_32 (n)

Definition at line 44 of file sha1.c.

◆ UNALIGNED_P

#define UNALIGNED_P (   p)    ((uintptr_t) (p) % alignof (uint32_t) != 0)

Function Documentation

◆ set_uint32()

static void set_uint32 ( char *  cp,
unsigned int  v 
)
static

Definition at line 78 of file sha1.c.

Referenced by sha1_read_ctx().

◆ sha1_buffer()

void* sha1_buffer ( const char *  buffer,
size_t  len,
void *  resblock 
)

Definition at line 215 of file sha1.c.

References sha1_ctx::buffer, sha1_finish_ctx(), sha1_init_ctx(), and sha1_process_bytes().

Referenced by gc_hash_buffer(), and gc_sha1().

◆ sha1_finish_ctx()

void* sha1_finish_ctx ( struct sha1_ctx ctx,
void *  resbuf 
)

◆ sha1_init_ctx()

void sha1_init_ctx ( struct sha1_ctx ctx)

Definition at line 62 of file sha1.c.

References sha1_ctx::A, sha1_ctx::B, sha1_ctx::buflen, sha1_ctx::C, sha1_ctx::D, sha1_ctx::E, and sha1_ctx::total.

Referenced by gc_hash_open(), and sha1_buffer().

◆ sha1_process_block()

void sha1_process_block ( const void *  buffer,
size_t  len,
struct sha1_ctx ctx 
)

◆ sha1_process_bytes()

void sha1_process_bytes ( const void *  buffer,
size_t  len,
struct sha1_ctx ctx 
)

Definition at line 230 of file sha1.c.

References sha1_ctx::buffer, sha1_ctx::buflen, sha1_process_block(), and UNALIGNED_P.

Referenced by gc_hash_write(), and sha1_buffer().

◆ sha1_read_ctx()

void* sha1_read_ctx ( const struct sha1_ctx ctx,
void *  resbuf 
)

Definition at line 86 of file sha1.c.

References sha1_ctx::A, sha1_ctx::B, sha1_ctx::C, sha1_ctx::D, sha1_ctx::E, set_uint32(), and SWAP.

Referenced by sha1_finish_ctx().

Variable Documentation

◆ fillbuf

const unsigned char fillbuf[64] = { 0x80, 0 }
static

Definition at line 55 of file sha1.c.

Referenced by sha1_finish_ctx().