ekg2
 All Struktury Danych Pliki Funkcje Zmienne Definicje typów Wyliczenia Wartości wyliczeń Definicje Grupay Strony
Struktury danych | Definicje | Definicje typów | Funkcje | Zmienne
Dokumentacja pliku digest.c
#include "ekg2-config.h"
#include <ekg/win32.h>
#include <ekg/debug.h>
#include <ekg/recode.h>
#include <stdint.h>
#include <ekg/stuff.h>
#include <ekg/xmalloc.h>
#include "jabber.h"
#include <stdio.h>
#include <string.h>

Struktury danych

struct  EKG2_SHA1_CTX

Definicje

#define LITTLE_ENDIAN
#define SHA1HANDSOFF
#define SHA1Init(ctx)   Init(ctx, 1)
#define SHA1Transform(state, buffer)   Transform(state, buffer, 1)
#define SHA1Update(ctx, data, len)   Update(ctx, (unsigned char *) data, len, 1)
#define SHA1Final(digest, ctx)   Final(digest, ctx, 1)
#define MD5Init(ctx)   Init(ctx, 0)
#define MD5Transform(state, buffer)   Transform(state, buffer, 0)
#define MD5Update(ctx, data, len)   Update(ctx, (unsigned char *) data, len, 0)
#define MD5Final(digest, ctx)   Final(digest, ctx, 0)
#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);
#define F(x, y, z)   (((x) & (y)) | ((~x) & (z)))
#define G(x, y, z)   (((x) & (z)) | ((y) & (~z)))
#define H(x, y, z)   ((x) ^ (y) ^ (z))
#define I(x, y, z)   ((y) ^ ((x) | (~z)))
#define FF(a, b, c, d, x, s, ac)   { (a) += F ((b), (c), (d)) + (x) + (uint32_t)(ac); (a) = rol((a), (s)); (a) += (b); }
#define GG(a, b, c, d, x, s, ac)   { (a) += G ((b), (c), (d)) + (x) + (uint32_t)(ac); (a) = rol((a), (s)); (a) += (b); }
#define HH(a, b, c, d, x, s, ac)   { (a) += H ((b), (c), (d)) + (x) + (uint32_t)(ac); (a) = rol((a), (s)); (a) += (b); }
#define II(a, b, c, d, x, s, ac)   { (a) += I ((b), (c), (d)) + (x) + (uint32_t)(ac); (a) = rol((a), (s)); (a) += (b); }
#define S11   7
#define S12   12
#define S13   17
#define S14   22
#define S21   5
#define S22   9
#define S23   14
#define S24   20
#define S31   4
#define S32   11
#define S33   16
#define S34   23
#define S41   6
#define S42   10
#define S43   15
#define S44   21

Definicje typów

typedef struct EKG2_SHA1_CTX EKG2_MD5_CTX

Funkcje

static void Init (EKG2_SHA1_CTX *context, int usesha)
static void Transform (uint32_t state[5], unsigned char buffer[64], int usesha)
static void Update (EKG2_SHA1_CTX *context, unsigned char *data, unsigned int len, int usesha)
static void Final (unsigned char digest[20], EKG2_SHA1_CTX *context, int usesha)
static void Encode (unsigned char *output, uint32_t *input, unsigned int len, int usesha)
static char * base16_encode (const unsigned char *data)
char * jabber_challange_digest (const char *sid, const char *password, const char *nonce, const char *cnonce, const char *xmpp_temp, const char *realm)
char * jabber_dcc_digest (char *sid, char *initiator, char *target)
char * jabber_digest (const char *sid, const char *password, int istlen)
char * jabber_sha1_generic (char *buf, int len)

Zmienne

char * config_console_charset

Dokumentacja definicji

#define blk (   i)
Wartość:
(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 blk0 (   i)
Wartość:
(block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
|(rol(block->l[i],8)&0x00FF00FF))
#define F (   x,
  y,
 
)    (((x) & (y)) | ((~x) & (z)))
#define FF (   a,
  b,
  c,
  d,
  x,
  s,
  ac 
)    { (a) += F ((b), (c), (d)) + (x) + (uint32_t)(ac); (a) = rol((a), (s)); (a) += (b); }
#define G (   x,
  y,
 
)    (((x) & (z)) | ((y) & (~z)))
#define GG (   a,
  b,
  c,
  d,
  x,
  s,
  ac 
)    { (a) += G ((b), (c), (d)) + (x) + (uint32_t)(ac); (a) = rol((a), (s)); (a) += (b); }
#define H (   x,
  y,
 
)    ((x) ^ (y) ^ (z))
#define HH (   a,
  b,
  c,
  d,
  x,
  s,
  ac 
)    { (a) += H ((b), (c), (d)) + (x) + (uint32_t)(ac); (a) = rol((a), (s)); (a) += (b); }
#define I (   x,
  y,
 
)    ((y) ^ ((x) | (~z)))
#define II (   a,
  b,
  c,
  d,
  x,
  s,
  ac 
)    { (a) += I ((b), (c), (d)) + (x) + (uint32_t)(ac); (a) = rol((a), (s)); (a) += (b); }
#define LITTLE_ENDIAN
#define MD5Final (   digest,
  ctx 
)    Final(digest, ctx, 0)
#define MD5Init (   ctx)    Init(ctx, 0)
#define MD5Transform (   state,
  buffer 
)    Transform(state, buffer, 0)
#define MD5Update (   ctx,
  data,
  len 
)    Update(ctx, (unsigned char *) data, len, 0)
#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);
#define rol (   value,
  bits 
)    (((value) << (bits)) | ((value) >> (32 - (bits))))
#define S11   7
#define S12   12
#define S13   17
#define S14   22
#define S21   5
#define S22   9
#define S23   14
#define S24   20
#define S31   4
#define S32   11
#define S33   16
#define S34   23
#define S41   6
#define S42   10
#define S43   15
#define S44   21
#define SHA1Final (   digest,
  ctx 
)    Final(digest, ctx, 1)
#define SHA1HANDSOFF
#define SHA1Init (   ctx)    Init(ctx, 1)
#define SHA1Transform (   state,
  buffer 
)    Transform(state, buffer, 1)
#define SHA1Update (   ctx,
  data,
  len 
)    Update(ctx, (unsigned char *) data, len, 1)

Dokumentacja definicji typów

typedef struct EKG2_SHA1_CTX EKG2_MD5_CTX

Dokumentacja funkcji

static char* base16_encode ( const unsigned char *  data)
static

base16_encode()

Return base16 hash of data

Zwraca
static with 32 digit BASE16 HASH + NUL char.
static void Encode ( unsigned char *  output,
uint32_t *  input,
unsigned int  len,
int  usesha 
)
static
static void Final ( unsigned char  digest[20],
EKG2_SHA1_CTX context,
int  usesha 
)
static
static void Init ( EKG2_SHA1_CTX context,
int  usesha 
)
static
char* jabber_challange_digest ( const char *  sid,
const char *  password,
const char *  nonce,
const char *  cnonce,
const char *  xmpp_temp,
const char *  realm 
)

jabber_challange_digest()

Return base16 encoded hash for SASL MD5 CHALLANGE

Do zrobienia:
MD5Update() on NULL params will fail. XXX, no idea what to do.
Zwraca
static buffer with 32 digit BASE16 HASH + NUL char
char* jabber_dcc_digest ( char *  sid,
char *  initiator,
char *  target 
)

[XXX] SOME TIME AGO, I had idea to connect jabber_dcc_digest() and jabber_digest() with one function, and use va_list for it... i don't know. jabber_dcc_digest()

Return SHA1 hash for SOCKS5 Bytestreams connections [DCC]
Make SHA1Update()'s on (uid, initiator and target)

Do zrobienia:
SHA1Update() on NULL params will fail. XXX, no idea what to do.
Do zrobienia:
We don't reencode params here to utf-8.
Zwraca
static buffer, with 40 digit SHA1 hash + NUL char
char* jabber_digest ( const char *  sid,
const char *  password,
int  istlen 
)

jabber_digest()

Return SHA1 hash for jabber:iq:auth
Make SHA1Update()'s on recoded to utf-8 (sid and password)

Do zrobienia:
SHA1Update() on NULL params will fail. XXX, no idea what to do.
Zwraca
static buffer, with 40 digit SHA1 hash + NUL char
char* jabber_sha1_generic ( char *  buf,
int  len 
)
static void Transform ( uint32_t  state[5],
unsigned char  buffer[64],
int  usesha 
)
static
static void Update ( EKG2_SHA1_CTX context,
unsigned char *  data,
unsigned int  len,
int  usesha 
)
static

Dokumentacja zmiennych

char* config_console_charset