Back to index

texmacs  1.0.7.15
Classes | Functions
dpxcrypt.h File Reference
#include <stdio.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  MD5_CONTEXT
struct  ARC4_KEY

Functions

void MD5_init (MD5_CONTEXT *ctx)
void MD5_write (MD5_CONTEXT *ctx, unsigned char *inbuf, unsigned long inlen)
void MD5_final (unsigned char *outbuf, MD5_CONTEXT *ctx)
void ARC4 (ARC4_KEY *ctx, unsigned long len, const unsigned char *inbuf, unsigned char *outbuf)
void ARC4_set_key (ARC4_KEY *ctx, unsigned int keylen, const unsigned char *key)

Class Documentation

struct MD5_CONTEXT

Definition at line 29 of file dpxcrypt.h.

Class Members
unsigned long A
unsigned long B
unsigned char buf
unsigned long C
int count
unsigned long D
unsigned long nblocks
struct ARC4_KEY

Definition at line 41 of file dpxcrypt.h.

Class Members
int idx_i
int idx_j
unsigned char sbox

Function Documentation

void ARC4 ( ARC4_KEY ctx,
unsigned long  len,
const unsigned char *  inbuf,
unsigned char *  outbuf 
)

Definition at line 338 of file dpxcrypt.c.

{
  do_encrypt_stream(ctx, outbuf, inbuf, len);
  _gcry_burn_stack(64);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ARC4_set_key ( ARC4_KEY ctx,
unsigned int  keylen,
const unsigned char *  key 
)

Definition at line 362 of file dpxcrypt.c.

{
  do_arcfour_setkey(ctx, key, keylen);
  _gcry_burn_stack(300);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void MD5_final ( unsigned char *  outbuf,
MD5_CONTEXT ctx 
)

Definition at line 237 of file dpxcrypt.c.

{
  unsigned long t, msb, lsb;
  unsigned char *p;

  MD5_write(hd, NULL, 0); /* flush */

  t = hd->nblocks;
  /* multiply by 64 to make a byte count */
  lsb = t << 6;
  msb = t >> 26;
  /* add the count */
  t = lsb;
  if ((lsb += hd->count) < t) msb++;
  /* multiply by 8 to make a bit count */
  t = lsb;
  lsb <<= 3;
  msb <<= 3;
  msb |= t >> 29;

  if (hd->count < 56) { /* enough room */
    hd->buf[hd->count++] = 0x80; /* pad */
    while (hd->count < 56) hd->buf[hd->count++] = 0; /* pad */
  } else { /* need one extra block */
    hd->buf[hd->count++] = 0x80; /* pad character */
    while (hd->count < 64) hd->buf[hd->count++] = 0;
    MD5_write(hd, NULL, 0); /* flush */
    memset(hd->buf, 0, 56); /* fill next block with zeroes */
  }
  /* append the 64 bit count */
  hd->buf[56] = lsb;
  hd->buf[57] = lsb >> 8;
  hd->buf[58] = lsb >> 16;
  hd->buf[59] = lsb >> 24;
  hd->buf[60] = msb;
  hd->buf[61] = msb >> 8;
  hd->buf[62] = msb >> 16;
  hd->buf[63] = msb >> 24;
  transform(hd, hd->buf);
  _gcry_burn_stack(80+6*sizeof(void*));

  p = outbuf; /* p = hd->buf; */
#ifdef WORDS_BIGENDIAN
#define X(a) do { *p++ = hd->a; *p++ = hd->a >> 8; \
                 *p++ = hd->a >> 16; *p++ = hd->a >> 24; } while (0)
#else /* little endian */
#define X(a) do { *(unsigned long *)p = (*hd).a ; p += 4; } while (0)
#endif
  X(A);
  X(B);
  X(C);
  X(D);
#undef X
}

Here is the call graph for this function:

Here is the caller graph for this function:

void MD5_init ( MD5_CONTEXT ctx)

Definition at line 69 of file dpxcrypt.c.

{
  ctx->A = 0x67452301;
  ctx->B = 0xefcdab89;
  ctx->C = 0x98badcfe;
  ctx->D = 0x10325476;

  ctx->nblocks = 0;
  ctx->count = 0;
}

Here is the caller graph for this function:

void MD5_write ( MD5_CONTEXT ctx,
unsigned char *  inbuf,
unsigned long  inlen 
)

Definition at line 204 of file dpxcrypt.c.

{
  if (hd->count == 64) { /* flush the buffer */
    transform(hd, hd->buf);
    _gcry_burn_stack(80+6*sizeof(void*));
    hd->count = 0;
    hd->nblocks++;
  }
  if (!inbuf) return;
  if (hd->count) {
    for (; inlen && hd->count < 64; inlen--)
      hd->buf[hd->count++] = *inbuf++;
    MD5_write(hd, NULL, 0);
    if (!inlen) return;
  }
  _gcry_burn_stack(80+6*sizeof(void*));

  while (inlen >= 64) {
    transform(hd, inbuf);
    hd->count = 0;
    hd->nblocks++;
    inlen -= 64;
    inbuf += 64;
  }
  for (; inlen && hd->count < 64; inlen--)
    hd->buf[hd->count++] = *inbuf++;
}

Here is the call graph for this function:

Here is the caller graph for this function: