Back to index

courier  0.68.2
Classes | Functions | Variables
hmac.c File Reference
#include "hmac.h"

Go to the source code of this file.

Classes

struct  hhki
struct  hhko

Functions

static void dohashkey (unsigned char *, void *)
static void docalcc (void *, void *)
void hmac_hashkey (const struct hmac_hashinfo *hh, const char *k, size_t kl, unsigned char *kxopad, unsigned char *kxipad)
static void dokeycalc (struct hhki *)
static void docalch (void *, void *)
void hmac_hashtext (const struct hmac_hashinfo *hh, const char *t, size_t tl, const unsigned char *kxopad, const unsigned char *kxipad, unsigned char *hash)

Variables

struct hmac_hashinfohmac_list [] = {HMAC_LIST}

Class Documentation

struct hhki

Definition at line 15 of file hmac.c.

Collaboration diagram for hhki:
Class Members
void * context
struct hmac_hashinfo * hh
const char * k
size_t kl
unsigned char * kxipad
unsigned char * kxopad
struct hhko

Definition at line 106 of file hmac.c.

Collaboration diagram for hhko:
Class Members
unsigned char * hash
struct hmac_hashinfo * hh
const unsigned char * kxipad
const unsigned char * kxopad
const char * t
size_t tl

Function Documentation

static void docalcc ( void *  c,
void *  v 
) [static]

Definition at line 44 of file hmac.c.

{
struct hhki *i=(struct hhki *)v;

       i->context=c;

       if (i->kl > i->hh->hh_B)
              (*i->hh->hh_allocaval)(dohashkey, (void *)i);
       else
              dokeycalc( i );
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void docalch ( void *  c,
void *  v 
) [static]

Definition at line 137 of file hmac.c.

{
struct hhko *o=(struct hhko *)v;

       (o->hh->hh_setdigest)(c, o->kxipad);
       (o->hh->hh_hash)(c, o->t, o->tl);
       (o->hh->hh_endhash)(c, o->tl+o->hh->hh_B);
       (o->hh->hh_getdigest)(c, o->hash);

       (o->hh->hh_setdigest)(c, o->kxopad);
       (o->hh->hh_hash)(c, o->hash, o->hh->hh_L);
       (o->hh->hh_endhash)(c, o->hh->hh_L + o->hh->hh_B);
       (o->hh->hh_getdigest)(c, o->hash);
}

Here is the caller graph for this function:

static void dohashkey ( unsigned char *  keybuf,
void *  v 
) [static]

Definition at line 56 of file hmac.c.

{
struct hhki *i=(struct hhki *)v;

       (*i->hh->hh_init)(i->context);
       (*i->hh->hh_hash)(i->context, i->k, i->kl);
       (*i->hh->hh_endhash)(i->context, i->kl);
       (*i->hh->hh_getdigest)(i->context, keybuf);
       i->k=(char *)keybuf;
       i->kl=i->hh->hh_L;
       dokeycalc(i);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void dokeycalc ( struct hhki i) [static]

Definition at line 69 of file hmac.c.

{
char   buf[64];      /* Random guess :-) */
unsigned n;
unsigned l;

       (*i->hh->hh_init)(i->context);
       n=0;
       for (l=0; l<i->hh->hh_B; l++)
       {
              buf[n] = ( l < i->kl ? i->k[l]:0) ^ 0x5C;
              if ( ++n >= sizeof(buf))
              {
                     (*i->hh->hh_hash)(i->context, buf, sizeof(buf));
                     n=0;
              }
       }
       if (n)
              (*i->hh->hh_hash)(i->context, buf, n);
       (*i->hh->hh_getdigest)(i->context, i->kxopad);

       (*i->hh->hh_init)(i->context);
       n=0;
       for (l=0; l<i->hh->hh_B; l++)
       {
              buf[n] = ( l < i->kl ? i->k[l]:0) ^ 0x36;
              if ( ++n >= sizeof(buf))
              {
                     (*i->hh->hh_hash)(i->context, buf, sizeof(buf));
                     n=0;
              }
       }
       if (n)
              (*i->hh->hh_hash)(i->context, buf, n);
       (*i->hh->hh_getdigest)(i->context, i->kxipad);
}

Here is the caller graph for this function:

void hmac_hashkey ( const struct hmac_hashinfo hh,
const char *  k,
size_t  kl,
unsigned char *  kxopad,
unsigned char *  kxipad 
)

Definition at line 28 of file hmac.c.

{
struct hhki i;

       i.hh=hh;
       i.k=k;
       i.kl=kl;
       i.kxopad=kxopad;
       i.kxipad=kxipad;

       (*hh->hh_allocacontext)( docalcc, (void *)&i );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void hmac_hashtext ( const struct hmac_hashinfo hh,
const char *  t,
size_t  tl,
const unsigned char *  kxopad,
const unsigned char *  kxipad,
unsigned char *  hash 
)

Definition at line 117 of file hmac.c.

{
struct hhko o;

       o.hh=hh;
       o.t=t;
       o.tl=tl;
       o.kxopad=kxopad;
       o.kxipad=kxipad;
       o.hash=hash;

       (*hh->hh_allocacontext)( docalch, (void *)&o );
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

struct hmac_hashinfo* hmac_list[] = {HMAC_LIST}

Definition at line 13 of file hmac.c.