Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
sechash.c File Reference
#include "sechash.h"
#include "secoidt.h"
#include "secerr.h"
#include "blapi.h"
#include "pk11func.h"

Go to the source code of this file.

Functions

static voidnull_hash_new_context (void)
static voidnull_hash_clone_context (void *v)
static void null_hash_begin (void *v)
static void null_hash_update (void *v, const unsigned char *input, unsigned int length)
static void null_hash_end (void *v, unsigned char *output, unsigned int *outLen, unsigned int maxOut)
static void null_hash_destroy_context (void *v, PRBool b)
static voidmd2_NewContext (void)
static voidmd5_NewContext (void)
static voidsha1_NewContext (void)
static voidsha256_NewContext (void)
static voidsha384_NewContext (void)
static voidsha512_NewContext (void)
const SECHashObject * HASH_GetHashObject (HASH_HashType type)
HASH_HashType HASH_GetHashTypeByOidTag (SECOidTag hashOid)
const SECHashObject * HASH_GetHashObjectByOidTag (SECOidTag hashOid)
unsigned int HASH_ResultLenByOidTag (SECOidTag hashOid)
unsigned int HASH_ResultLen (HASH_HashType type)
unsigned int HASH_ResultLenContext (HASHContext *context)
SECStatus HASH_HashBuf (HASH_HashType type, unsigned char *dest, unsigned char *src, uint32 src_len)
HASHContext * HASH_Create (HASH_HashType type)
HASHContext * HASH_Clone (HASHContext *context)
void HASH_Destroy (HASHContext *context)
void HASH_Begin (HASHContext *context)
void HASH_Update (HASHContext *context, const unsigned char *src, unsigned int len)
void HASH_End (HASHContext *context, unsigned char *result, unsigned int *result_len, unsigned int max_result_len)

Variables

const SECHashObject SECHashObjects []

Function Documentation

void HASH_Begin ( HASHContext *  context)

Definition at line 353 of file sechash.c.

{
    (* context->hashobj->begin)(context->hash_context);
    return;
}

Here is the caller graph for this function:

HASHContext* HASH_Clone ( HASHContext *  context)

Definition at line 314 of file sechash.c.

{
    void *hash_context = NULL;
    HASHContext *ret = NULL;
    
    hash_context = (* context->hashobj->clone)(context->hash_context);
    if ( hash_context == NULL ) {
       goto loser;
    }

    ret = (HASHContext *)PORT_Alloc(sizeof(HASHContext));
    if ( ret == NULL ) {
       goto loser;
    }

    ret->hash_context = hash_context;
    ret->hashobj = context->hashobj;
    
    return(ret);
    
loser:
    if ( hash_context != NULL ) {
       (* context->hashobj->destroy)(hash_context, PR_TRUE);
    }
    
    return(NULL);

}
HASHContext* HASH_Create ( HASH_HashType  type)

Definition at line 280 of file sechash.c.

{
    void *hash_context = NULL;
    HASHContext *ret = NULL;
    
    if ( ( type < HASH_AlgNULL ) || ( type >= HASH_AlgTOTAL ) ) {
       return(NULL);
    }
    
    hash_context = (* SECHashObjects[type].create)();
    if ( hash_context == NULL ) {
       goto loser;
    }

    ret = (HASHContext *)PORT_Alloc(sizeof(HASHContext));
    if ( ret == NULL ) {
       goto loser;
    }

    ret->hash_context = hash_context;
    ret->hashobj = &SECHashObjects[type];
    
    return(ret);
    
loser:
    if ( hash_context != NULL ) {
       (* SECHashObjects[type].destroy)(hash_context, PR_TRUE);
    }
    
    return(NULL);
}

Here is the caller graph for this function:

void HASH_Destroy ( HASHContext *  context)

Definition at line 344 of file sechash.c.

{
    (* context->hashobj->destroy)(context->hash_context, PR_TRUE);
    PORT_Free(context);
    return;
}

Here is the caller graph for this function:

void HASH_End ( HASHContext *  context,
unsigned char *  result,
unsigned int result_len,
unsigned int  max_result_len 
)

Definition at line 370 of file sechash.c.

{
    (* context->hashobj->end)(context->hash_context, result, result_len,
                           max_result_len);
    return;
}

Here is the caller graph for this function:

const SECHashObject* HASH_GetHashObject ( HASH_HashType  type)

Definition at line 190 of file sechash.c.

{
    return &SECHashObjects[type];
}

Here is the caller graph for this function:

const SECHashObject* HASH_GetHashObjectByOidTag ( SECOidTag  hashOid)

Definition at line 215 of file sechash.c.

{
    HASH_HashType ht = HASH_GetHashTypeByOidTag(hashOid);

    return (ht == HASH_AlgNULL) ? NULL : &SECHashObjects[ht];
}

Here is the caller graph for this function:

Definition at line 196 of file sechash.c.

{
    HASH_HashType ht = HASH_AlgNULL;

    switch(hashOid) {
    case SEC_OID_MD2:        ht = HASH_AlgMD2;    break;
    case SEC_OID_MD5:        ht = HASH_AlgMD5;    break;
    case SEC_OID_SHA1:       ht = HASH_AlgSHA1;   break;
    case SEC_OID_SHA256: ht = HASH_AlgSHA256; break;
    case SEC_OID_SHA384: ht = HASH_AlgSHA384; break;
    case SEC_OID_SHA512: ht = HASH_AlgSHA512; break;
    default:             ht = HASH_AlgNULL;   
       PORT_SetError(SEC_ERROR_INVALID_ALGORITHM);
       break;
    }
    return ht;
}

Here is the caller graph for this function:

SECStatus HASH_HashBuf ( HASH_HashType  type,
unsigned char *  dest,
unsigned char *  src,
uint32  src_len 
)

Definition at line 255 of file sechash.c.

{
    HASHContext *cx;
    unsigned int part;
    
    if ( ( type < HASH_AlgNULL ) || ( type >= HASH_AlgTOTAL ) ) {
       return(SECFailure);
    }
    
    cx = HASH_Create(type);
    if ( cx == NULL ) {
       return(SECFailure);
    }
    HASH_Begin(cx);
    HASH_Update(cx, src, src_len);
    HASH_End(cx, dest, &part, HASH_ResultLenContext(cx));
    HASH_Destroy(cx);

    return(SECSuccess);
}
unsigned int HASH_ResultLen ( HASH_HashType  type)

Definition at line 236 of file sechash.c.

Here is the caller graph for this function:

unsigned int HASH_ResultLenByOidTag ( SECOidTag  hashOid)

Definition at line 224 of file sechash.c.

{
    const SECHashObject * hashObject = HASH_GetHashObjectByOidTag(hashOid);
    unsigned int          resultLen = 0;

    if (hashObject)
       resultLen = hashObject->length;
    return resultLen;
}

Here is the caller graph for this function:

unsigned int HASH_ResultLenContext ( HASHContext *  context)

Definition at line 247 of file sechash.c.

{
    return(context->hashobj->length);
}

Here is the caller graph for this function:

void HASH_Update ( HASHContext *  context,
const unsigned char *  src,
unsigned int  len 
)

Definition at line 361 of file sechash.c.

{
    (* context->hashobj->update)(context->hash_context, src, len);
    return;
}

Here is the caller graph for this function:

static void* md2_NewContext ( void  ) [static]

Definition at line 80 of file sechash.c.

                     {
       return (void *) PK11_CreateDigestContext(SEC_OID_MD2);
}

Here is the call graph for this function:

static void* md5_NewContext ( void  ) [static]

Definition at line 85 of file sechash.c.

                     {
       return (void *) PK11_CreateDigestContext(SEC_OID_MD5);
}

Here is the call graph for this function:

static void null_hash_begin ( void v) [static]

Definition at line 56 of file sechash.c.

{
}
static void* null_hash_clone_context ( void v) [static]

Definition at line 49 of file sechash.c.

{
    PORT_Assert(v == NULL);
    return NULL;
}
static void null_hash_destroy_context ( void v,
PRBool  b 
) [static]

Definition at line 73 of file sechash.c.

{
    PORT_Assert(v == NULL);
}
static void null_hash_end ( void v,
unsigned char *  output,
unsigned int outLen,
unsigned int  maxOut 
) [static]

Definition at line 66 of file sechash.c.

{
    *outLen = 0;
}
static void* null_hash_new_context ( void  ) [static]

Definition at line 43 of file sechash.c.

{
    return NULL;
}
static void null_hash_update ( void v,
const unsigned char *  input,
unsigned int  length 
) [static]

Definition at line 61 of file sechash.c.

{
}
static void* sha1_NewContext ( void  ) [static]

Definition at line 90 of file sechash.c.

                      {
       return (void *) PK11_CreateDigestContext(SEC_OID_SHA1);
}

Here is the call graph for this function:

static void* sha256_NewContext ( void  ) [static]

Definition at line 95 of file sechash.c.

Here is the call graph for this function:

static void* sha384_NewContext ( void  ) [static]

Definition at line 100 of file sechash.c.

Here is the call graph for this function:

static void* sha512_NewContext ( void  ) [static]

Definition at line 105 of file sechash.c.

Here is the call graph for this function:


Variable Documentation

const SECHashObject SECHashObjects[]

Definition at line 109 of file sechash.c.