diff options
author | Kai Engert <kaie@kuix.de> | 2013-02-28 12:44:50 +0100 |
---|---|---|
committer | Kai Engert <kaie@kuix.de> | 2013-02-28 12:44:50 +0100 |
commit | 3ecd967b2a9e23403935e2bc932597f7e03e7f24 (patch) | |
tree | 4b0f054f0354c2dbe401f86d864c04c6034c1621 /lib/freebl/rawhash.c | |
parent | f45b9ca74a609e0521d0cc4b7fc91603774992df (diff) | |
download | nss-hg-3ecd967b2a9e23403935e2bc932597f7e03e7f24.tar.gz |
Bug 845556, reorganize NSS directory layout, moving files, very large changeset! r=wtc
Diffstat (limited to 'lib/freebl/rawhash.c')
-rw-r--r-- | lib/freebl/rawhash.c | 161 |
1 files changed, 161 insertions, 0 deletions
diff --git a/lib/freebl/rawhash.c b/lib/freebl/rawhash.c new file mode 100644 index 000000000..7962b1fff --- /dev/null +++ b/lib/freebl/rawhash.c @@ -0,0 +1,161 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifdef FREEBL_NO_DEPEND +#include "stubs.h" +#endif + +#include "nspr.h" +#include "hasht.h" +#include "blapi.h" /* below the line */ +#include "secerr.h" + +static void * +null_hash_new_context(void) +{ + return NULL; +} + +static void * +null_hash_clone_context(void *v) +{ + PORT_Assert(v == NULL); + return NULL; +} + +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) +{ + *outLen = 0; +} + +static void +null_hash_destroy_context(void *v, PRBool b) +{ + PORT_Assert(v == NULL); +} + + +const SECHashObject SECRawHashObjects[] = { + { 0, + (void * (*)(void)) null_hash_new_context, + (void * (*)(void *)) null_hash_clone_context, + (void (*)(void *, PRBool)) null_hash_destroy_context, + (void (*)(void *)) null_hash_begin, + (void (*)(void *, const unsigned char *, unsigned int)) null_hash_update, + (void (*)(void *, unsigned char *, unsigned int *, + unsigned int)) null_hash_end, + 0, + HASH_AlgNULL, + (void (*)(void *, unsigned char *, unsigned int *, + unsigned int)) null_hash_end + }, + { MD2_LENGTH, + (void * (*)(void)) MD2_NewContext, + (void * (*)(void *)) null_hash_clone_context, + (void (*)(void *, PRBool)) MD2_DestroyContext, + (void (*)(void *)) MD2_Begin, + (void (*)(void *, const unsigned char *, unsigned int)) MD2_Update, + (void (*)(void *, unsigned char *, unsigned int *, unsigned int)) MD2_End, + MD2_BLOCK_LENGTH, + HASH_AlgMD2, + NULL /* end_raw */ + }, + { MD5_LENGTH, + (void * (*)(void)) MD5_NewContext, + (void * (*)(void *)) null_hash_clone_context, + (void (*)(void *, PRBool)) MD5_DestroyContext, + (void (*)(void *)) MD5_Begin, + (void (*)(void *, const unsigned char *, unsigned int)) MD5_Update, + (void (*)(void *, unsigned char *, unsigned int *, unsigned int)) MD5_End, + MD5_BLOCK_LENGTH, + HASH_AlgMD5, + (void (*)(void *, unsigned char *, unsigned int *, unsigned int)) MD5_EndRaw + }, + { SHA1_LENGTH, + (void * (*)(void)) SHA1_NewContext, + (void * (*)(void *)) null_hash_clone_context, + (void (*)(void *, PRBool)) SHA1_DestroyContext, + (void (*)(void *)) SHA1_Begin, + (void (*)(void *, const unsigned char *, unsigned int)) SHA1_Update, + (void (*)(void *, unsigned char *, unsigned int *, unsigned int)) SHA1_End, + SHA1_BLOCK_LENGTH, + HASH_AlgSHA1, + (void (*)(void *, unsigned char *, unsigned int *, unsigned int)) + SHA1_EndRaw + }, + { SHA256_LENGTH, + (void * (*)(void)) SHA256_NewContext, + (void * (*)(void *)) null_hash_clone_context, + (void (*)(void *, PRBool)) SHA256_DestroyContext, + (void (*)(void *)) SHA256_Begin, + (void (*)(void *, const unsigned char *, unsigned int)) SHA256_Update, + (void (*)(void *, unsigned char *, unsigned int *, + unsigned int)) SHA256_End, + SHA256_BLOCK_LENGTH, + HASH_AlgSHA256, + (void (*)(void *, unsigned char *, unsigned int *, + unsigned int)) SHA256_EndRaw + }, + { SHA384_LENGTH, + (void * (*)(void)) SHA384_NewContext, + (void * (*)(void *)) null_hash_clone_context, + (void (*)(void *, PRBool)) SHA384_DestroyContext, + (void (*)(void *)) SHA384_Begin, + (void (*)(void *, const unsigned char *, unsigned int)) SHA384_Update, + (void (*)(void *, unsigned char *, unsigned int *, + unsigned int)) SHA384_End, + SHA384_BLOCK_LENGTH, + HASH_AlgSHA384, + (void (*)(void *, unsigned char *, unsigned int *, + unsigned int)) SHA384_EndRaw + }, + { SHA512_LENGTH, + (void * (*)(void)) SHA512_NewContext, + (void * (*)(void *)) null_hash_clone_context, + (void (*)(void *, PRBool)) SHA512_DestroyContext, + (void (*)(void *)) SHA512_Begin, + (void (*)(void *, const unsigned char *, unsigned int)) SHA512_Update, + (void (*)(void *, unsigned char *, unsigned int *, + unsigned int)) SHA512_End, + SHA512_BLOCK_LENGTH, + HASH_AlgSHA512, + (void (*)(void *, unsigned char *, unsigned int *, + unsigned int)) SHA512_EndRaw + }, + { SHA224_LENGTH, + (void * (*)(void)) SHA224_NewContext, + (void * (*)(void *)) null_hash_clone_context, + (void (*)(void *, PRBool)) SHA224_DestroyContext, + (void (*)(void *)) SHA224_Begin, + (void (*)(void *, const unsigned char *, unsigned int)) SHA224_Update, + (void (*)(void *, unsigned char *, unsigned int *, + unsigned int)) SHA224_End, + SHA224_BLOCK_LENGTH, + HASH_AlgSHA224, + (void (*)(void *, unsigned char *, unsigned int *, + unsigned int)) SHA224_EndRaw + }, +}; + +const SECHashObject * +HASH_GetRawHashObject(HASH_HashType hashType) +{ + if (hashType < HASH_AlgNULL || hashType >= HASH_AlgTOTAL) { + PORT_SetError(SEC_ERROR_INVALID_ARGS); + return NULL; + } + return &SECRawHashObjects[hashType]; +} |