1
/* ***** BEGIN LICENSE BLOCK *****
2
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
* The contents of this file are subject to the Mozilla Public License Version
5
* 1.1 (the "License"); you may not use this file except in compliance with
6
* the License. You may obtain a copy of the License at
7
* http://www.mozilla.org/MPL/
9
* Software distributed under the License is distributed on an "AS IS" basis,
10
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
* for the specific language governing rights and limitations under the
14
* The Original Code is the Netscape security libraries.
16
* The Initial Developer of the Original Code is
17
* Netscape Communications Corporation.
18
* Portions created by the Initial Developer are Copyright (C) 1994-2000
19
* the Initial Developer. All Rights Reserved.
23
* Alternatively, the contents of this file may be used under the terms of
24
* either the GNU General Public License Version 2 or later (the "GPL"), or
25
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26
* in which case the provisions of the GPL or the LGPL are applicable instead
27
* of those above. If you wish to allow use of your version of this file only
28
* under the terms of either the GPL or the LGPL, and not to allow others to
29
* use your version of this file under the terms of the MPL, indicate your
30
* decision by deleting the provisions above and replace them with the notice
31
* and other provisions required by the GPL or the LGPL. If you do not delete
32
* the provisions above, a recipient may use your version of this file under
33
* the terms of any one of the MPL, the GPL or the LGPL.
35
* ***** END LICENSE BLOCK ***** */
39
#include "blapi.h" /* below the line */
43
null_hash_new_context(void)
49
null_hash_clone_context(void *v)
51
PORT_Assert(v == NULL);
56
null_hash_begin(void *v)
61
null_hash_update(void *v, const unsigned char *input, unsigned int length)
66
null_hash_end(void *v, unsigned char *output, unsigned int *outLen,
73
null_hash_destroy_context(void *v, PRBool b)
75
PORT_Assert(v == NULL);
79
const SECHashObject SECRawHashObjects[] = {
81
(void * (*)(void)) null_hash_new_context,
82
(void * (*)(void *)) null_hash_clone_context,
83
(void (*)(void *, PRBool)) null_hash_destroy_context,
84
(void (*)(void *)) null_hash_begin,
85
(void (*)(void *, const unsigned char *, unsigned int)) null_hash_update,
86
(void (*)(void *, unsigned char *, unsigned int *,
87
unsigned int)) null_hash_end,
92
(void * (*)(void)) MD2_NewContext,
93
(void * (*)(void *)) null_hash_clone_context,
94
(void (*)(void *, PRBool)) MD2_DestroyContext,
95
(void (*)(void *)) MD2_Begin,
96
(void (*)(void *, const unsigned char *, unsigned int)) MD2_Update,
97
(void (*)(void *, unsigned char *, unsigned int *, unsigned int)) MD2_End,
102
(void * (*)(void)) MD5_NewContext,
103
(void * (*)(void *)) null_hash_clone_context,
104
(void (*)(void *, PRBool)) MD5_DestroyContext,
105
(void (*)(void *)) MD5_Begin,
106
(void (*)(void *, const unsigned char *, unsigned int)) MD5_Update,
107
(void (*)(void *, unsigned char *, unsigned int *, unsigned int)) MD5_End,
112
(void * (*)(void)) SHA1_NewContext,
113
(void * (*)(void *)) null_hash_clone_context,
114
(void (*)(void *, PRBool)) SHA1_DestroyContext,
115
(void (*)(void *)) SHA1_Begin,
116
(void (*)(void *, const unsigned char *, unsigned int)) SHA1_Update,
117
(void (*)(void *, unsigned char *, unsigned int *, unsigned int)) SHA1_End,
122
(void * (*)(void)) SHA256_NewContext,
123
(void * (*)(void *)) null_hash_clone_context,
124
(void (*)(void *, PRBool)) SHA256_DestroyContext,
125
(void (*)(void *)) SHA256_Begin,
126
(void (*)(void *, const unsigned char *, unsigned int)) SHA256_Update,
127
(void (*)(void *, unsigned char *, unsigned int *,
128
unsigned int)) SHA256_End,
133
(void * (*)(void)) SHA384_NewContext,
134
(void * (*)(void *)) null_hash_clone_context,
135
(void (*)(void *, PRBool)) SHA384_DestroyContext,
136
(void (*)(void *)) SHA384_Begin,
137
(void (*)(void *, const unsigned char *, unsigned int)) SHA384_Update,
138
(void (*)(void *, unsigned char *, unsigned int *,
139
unsigned int)) SHA384_End,
144
(void * (*)(void)) SHA512_NewContext,
145
(void * (*)(void *)) null_hash_clone_context,
146
(void (*)(void *, PRBool)) SHA512_DestroyContext,
147
(void (*)(void *)) SHA512_Begin,
148
(void (*)(void *, const unsigned char *, unsigned int)) SHA512_Update,
149
(void (*)(void *, unsigned char *, unsigned int *,
150
unsigned int)) SHA512_End,
156
const SECHashObject *
157
HASH_GetRawHashObject(HASH_HashType hashType)
159
if (hashType < HASH_AlgNULL || hashType >= HASH_AlgTOTAL) {
160
PORT_SetError(SEC_ERROR_INVALID_ARGS);
163
return &SECRawHashObjects[hashType];