Back to index

lightning-sunbird  0.9+nobinonly
Functions
sechash.h File Reference
#include "seccomon.h"
#include "hasht.h"
#include "secoidt.h"

Go to the source code of this file.

Functions

SEC_BEGIN_PROTOS unsigned int HASH_ResultLen (HASH_HashType type)
unsigned int HASH_ResultLenContext (HASHContext *context)
unsigned int HASH_ResultLenByOidTag (SECOidTag hashOid)
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)
const SECHashObject * HASH_GetHashObject (HASH_HashType type)
const SECHashObject * HASH_GetHashObjectByOidTag (SECOidTag hashOid)
HASH_HashType HASH_GetHashTypeByOidTag (SECOidTag hashOid)

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);

}

Here is the call graph for this function:

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 call graph for this function:

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 call graph for this function:

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 call graph for this function:

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 call graph for this function:

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);
}

Here is the call graph for this function:

Definition at line 236 of file sechash.c.

Here is the call graph for this function:

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 call graph for this function:

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: