Back to index

courier  0.68.2
Defines | Typedefs | Functions
sha1.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define SHA1_DIGEST_SIZE   20
#define SHA1_BLOCK_SIZE   64
#define SHA256_DIGEST_SIZE   32
#define SHA256_BLOCK_SIZE   64
#define SHA512_DIGEST_SIZE   64
#define SHA512_BLOCK_SIZE   128

Typedefs

typedef SHA1_WORD SHA256_WORD
typedef unsigned char SHA1_DIGEST [20]
typedef unsigned char SHA256_DIGEST [32]
typedef unsigned char SHA512_DIGEST [64]
typedef unsigned char SSHA_RAND [4]

Functions

void sha1_digest (const void *, unsigned, SHA1_DIGEST)
const char * sha1_hash (const char *)
const char * ssha_hash (const char *, SSHA_RAND)
void sha256_digest (const void *, unsigned, SHA256_DIGEST)
const char * sha256_hash (const char *)
void sha512_digest (const void *, unsigned, SHA512_DIGEST)
const char * sha512_hash (const char *)

Define Documentation

#define SHA1_BLOCK_SIZE   64

Definition at line 19 of file sha1.h.

#define SHA1_DIGEST_SIZE   20

Definition at line 18 of file sha1.h.

#define SHA256_BLOCK_SIZE   64

Definition at line 22 of file sha1.h.

#define SHA256_DIGEST_SIZE   32

Definition at line 21 of file sha1.h.

#define SHA512_BLOCK_SIZE   128

Definition at line 25 of file sha1.h.

#define SHA512_DIGEST_SIZE   64

Definition at line 24 of file sha1.h.


Typedef Documentation

typedef unsigned char SHA1_DIGEST[20]

Definition at line 33 of file sha1.h.

typedef unsigned char SHA256_DIGEST[32]

Definition at line 34 of file sha1.h.

typedef SHA1_WORD SHA256_WORD

Definition at line 27 of file sha1.h.

typedef unsigned char SHA512_DIGEST[64]

Definition at line 35 of file sha1.h.

typedef unsigned char SSHA_RAND[4]

Definition at line 94 of file sha1.h.


Function Documentation

void sha1_digest ( const void *  ,
unsigned  ,
SHA1_DIGEST   
)

Definition at line 184 of file sha1.c.

{
struct SHA1_CONTEXT c;

       sha1_context_init( &c );
       sha1_context_hashstream(&c, msg, len);
       sha1_context_endstream(&c, len);
       sha1_context_digest( &c, d );
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* sha1_hash ( const char *  )

Definition at line 13 of file sha1_hash.c.

{
SHA1_DIGEST sha1buf;
static char hash_buffer[1+(sizeof(sha1buf)+2)/3*4];
int    a=0,b=0,c=0;
int    i, j;
int    d, e, f, g;

       sha1_digest(passw, strlen(passw), sha1buf);

       j=0;

       for (i=0; i<sizeof(sha1buf); i += 3)
       {
              a=sha1buf[i];
              b= i+1 < sizeof(sha1buf) ? sha1buf[i+1]:0;
              c= i+2 < sizeof(sha1buf) ? sha1buf[i+2]:0;

              d=base64tab[ a >> 2 ];
              e=base64tab[ ((a & 3 ) << 4) | (b >> 4)];
              f=base64tab[ ((b & 15) << 2) | (c >> 6)];
              g=base64tab[ c & 63 ];
              if (i + 1 >= sizeof(sha1buf))      f='=';
              if (i + 2 >= sizeof(sha1buf)) g='=';
              hash_buffer[j++]=d;
              hash_buffer[j++]=e;
              hash_buffer[j++]=f;
              hash_buffer[j++]=g;
       }

       hash_buffer[j]=0;
       return (hash_buffer);
}

Here is the call graph for this function:

void sha256_digest ( const void *  ,
unsigned  ,
SHA256_DIGEST   
)

Definition at line 197 of file sha256.c.

{
       struct SHA256_CONTEXT c;

       sha256_context_init( &c );
       sha256_context_hashstream(&c, msg, len);
       sha256_context_endstream(&c, len);
       sha256_context_digest( &c, d );
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* sha256_hash ( const char *  )

Definition at line 13 of file sha256_hash.c.

{
SHA256_DIGEST sha256buf;
static char hash_buffer[1+(sizeof(sha256buf)+2)/3*4];
int    a=0,b=0,c=0;
int    i, j;
int    d, e, f, g;

       sha256_digest(passw, strlen(passw), sha256buf);

       j=0;

       for (i=0; i<sizeof(sha256buf); i += 3)
       {
              a=sha256buf[i];
              b= i+1 < sizeof(sha256buf) ? sha256buf[i+1]:0;
              c= i+2 < sizeof(sha256buf) ? sha256buf[i+2]:0;

              d=base64tab[ a >> 2 ];
              e=base64tab[ ((a & 3 ) << 4) | (b >> 4)];
              f=base64tab[ ((b & 15) << 2) | (c >> 6)];
              g=base64tab[ c & 63 ];
              if (i + 1 >= sizeof(sha256buf))    f='=';
              if (i + 2 >= sizeof(sha256buf)) g='=';
              hash_buffer[j++]=d;
              hash_buffer[j++]=e;
              hash_buffer[j++]=f;
              hash_buffer[j++]=g;
       }

       hash_buffer[j]=0;
       return (hash_buffer);
}

Here is the call graph for this function:

void sha512_digest ( const void *  ,
unsigned  ,
SHA512_DIGEST   
)

Definition at line 224 of file sha512.c.

{
       struct SHA512_CONTEXT c;

       sha512_context_init( &c );
       sha512_context_hashstream(&c, msg, len);
       sha512_context_endstream(&c, len);
       sha512_context_digest( &c, d );
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* sha512_hash ( const char *  )

Definition at line 13 of file sha512_hash.c.

{
SHA512_DIGEST sha512buf;
static char hash_buffer[1+(sizeof(sha512buf)+2)/3*4];
int    a=0,b=0,c=0;
int    i, j;
int    d, e, f, g;

       sha512_digest(passw, strlen(passw), sha512buf);

       j=0;

       for (i=0; i<sizeof(sha512buf); i += 3)
       {
              a=sha512buf[i];
              b= i+1 < sizeof(sha512buf) ? sha512buf[i+1]:0;
              c= i+2 < sizeof(sha512buf) ? sha512buf[i+2]:0;

              d=base64tab[ a >> 2 ];
              e=base64tab[ ((a & 3 ) << 4) | (b >> 4)];
              f=base64tab[ ((b & 15) << 2) | (c >> 6)];
              g=base64tab[ c & 63 ];
              if (i + 1 >= sizeof(sha512buf))    f='=';
              if (i + 2 >= sizeof(sha512buf)) g='=';
              hash_buffer[j++]=d;
              hash_buffer[j++]=e;
              hash_buffer[j++]=f;
              hash_buffer[j++]=g;
       }

       hash_buffer[j]=0;
       return (hash_buffer);
}

Here is the call graph for this function:

const char* ssha_hash ( const char *  ,
SSHA_RAND   
)

Definition at line 47 of file sha1_hash.c.

{
       unsigned char sha1buf[sizeof(SHA1_DIGEST)+sizeof(SSHA_RAND)];

       static char hash_buffer[1+(sizeof(sha1buf)+2)/3*4];
       int    a=0,b=0,c=0;
       int    i, j;
       int    d, e, f, g;
       struct SHA1_CONTEXT ctx;

       sha1_context_init( &ctx );
       sha1_context_hashstream(&ctx, passw, strlen(passw));
       sha1_context_hashstream(&ctx, seed, sizeof(SSHA_RAND));
       sha1_context_endstream(&ctx, strlen(passw)+sizeof(SSHA_RAND));
       sha1_context_digest( &ctx, sha1buf );

       for(i=0; i<sizeof(SSHA_RAND); i++)
       {
              sha1buf[sizeof(SHA1_DIGEST)+i] = seed[i];
       }

       j=0;

       for (i=0; i<sizeof(sha1buf); i += 3)
       {
              a=sha1buf[i];
              b= i+1 < sizeof(sha1buf) ? sha1buf[i+1]:0;
              c= i+2 < sizeof(sha1buf) ? sha1buf[i+2]:0;

              d=base64tab[ a >> 2 ];
              e=base64tab[ ((a & 3 ) << 4) | (b >> 4)];
              f=base64tab[ ((b & 15) << 2) | (c >> 6)];
              g=base64tab[ c & 63 ];
              if (i + 1 >= sizeof(sha1buf))      f='=';
              if (i + 2 >= sizeof(sha1buf)) g='=';
              hash_buffer[j++]=d;
              hash_buffer[j++]=e;
              hash_buffer[j++]=f;
              hash_buffer[j++]=g;
       }

       hash_buffer[j]=0;
       return (hash_buffer);
}

Here is the call graph for this function: