Anope IRC Services  Version 1.8
Data Structures | Macros | Functions
enc_sha1.c File Reference
#include "module.h"
#include <stdio.h>
#include <string.h>
Include dependency graph for enc_sha1.c:

Go to the source code of this file.

Data Structures

struct  SHA1_CTX
 

Macros

#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 SHA1Transform (uint32 state[5], unsigned char const buffer[64])
 
static void SHA1Init (SHA1_CTX *context)
 
static void SHA1Update (SHA1_CTX *context, unsigned char const *data, uint32 len)
 
static void SHA1Final (unsigned char digest[20], SHA1_CTX *context)
 
static int sha1_encrypt (const char *src, int len, char *dest, int size)
 
static int sha1_encrypt_check_len (int passlen, int bufsize)
 
static int sha1_decrypt (const char *src, char *dest, int size)
 
static int sha1_check_password (const char *plaintext, const char *password)
 
int AnopeInit (int argc, char **argv)
 
void AnopeFini (void)
 

Macro Definition Documentation

#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: enc_sha1.c:33

Definition at line 43 of file enc_sha1.c.

#define blk0 (   i)    block->l[i]

Definition at line 41 of file enc_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 47 of file enc_sha1.c.

Referenced by SHA1Transform().

#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 48 of file enc_sha1.c.

Referenced by SHA1Transform().

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

Definition at line 49 of file enc_sha1.c.

Referenced by SHA1Transform().

#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 50 of file enc_sha1.c.

Referenced by SHA1Transform().

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

Definition at line 51 of file enc_sha1.c.

Referenced by SHA1Transform().

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

Definition at line 33 of file enc_sha1.c.

Function Documentation

void AnopeFini ( void  )
int AnopeInit ( int  argc,
char **  argv 
)
static int sha1_check_password ( const char *  plaintext,
const char *  password 
)
static

Definition at line 221 of file enc_sha1.c.

References BUFSIZE, and sha1_encrypt().

Referenced by AnopeInit().

static int sha1_decrypt ( const char *  src,
char *  dest,
int  size 
)
static

Definition at line 215 of file enc_sha1.c.

Referenced by AnopeInit().

static int sha1_encrypt ( const char *  src,
int  len,
char *  dest,
int  size 
)
static

Definition at line 178 of file enc_sha1.c.

References alog(), binary_to_hex(), debug, SHA1Final(), SHA1Init(), and SHA1Update().

Referenced by AnopeInit(), and sha1_check_password().

static int sha1_encrypt_check_len ( int  passlen,
int  bufsize 
)
static

Definition at line 207 of file enc_sha1.c.

References fatal().

Referenced by AnopeInit().

static void SHA1Final ( unsigned char  digest[20],
SHA1_CTX context 
)
static

Definition at line 147 of file enc_sha1.c.

References SHA1_CTX::buffer, SHA1_CTX::count, SHA1Transform(), SHA1Update(), and SHA1_CTX::state.

Referenced by sha1_encrypt().

static void SHA1Init ( SHA1_CTX context)
static

Definition at line 111 of file enc_sha1.c.

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

Referenced by sha1_encrypt().

static void SHA1Transform ( uint32  state[5],
unsigned char const  buffer[64] 
)
static

Definition at line 56 of file enc_sha1.c.

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

Referenced by SHA1Final(), and SHA1Update().

static void SHA1Update ( SHA1_CTX context,
unsigned char const *  data,
uint32  len 
)
static

Definition at line 125 of file enc_sha1.c.

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

Referenced by sha1_encrypt(), and SHA1Final().