~ubuntu-branches/ubuntu/lucid/seamonkey/lucid-security

« back to all changes in this revision

Viewing changes to security/nss-fips/lib/freebl/rawhash.c

  • Committer: Bazaar Package Importer
  • Author(s): Fabien Tassin
  • Date: 2008-07-29 21:29:02 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080729212902-spm9kpvchp9udwbw
Tags: 1.1.11+nobinonly-0ubuntu1
* New security upstream release: 1.1.11 (LP: #218534)
  Fixes USN-602-1, USN-619-1, USN-623-1 and USN-629-1
* Refresh diverged patch:
  - update debian/patches/80_security_build.patch
* Fix FTBFS with missing -lfontconfig
  - add debian/patches/11_fix_ftbfs_with_fontconfig.patch
  - update debian/patches/series
* Build with default gcc (hardy: 4.2, intrepid: 4.3)
  - update debian/rules
  - update debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ***** BEGIN LICENSE BLOCK *****
 
2
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 
3
 *
 
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/
 
8
 *
 
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
 
12
 * License.
 
13
 *
 
14
 * The Original Code is the Netscape security libraries.
 
15
 *
 
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.
 
20
 *
 
21
 * Contributor(s):
 
22
 *
 
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.
 
34
 *
 
35
 * ***** END LICENSE BLOCK ***** */
 
36
 
 
37
#include "nspr.h"
 
38
#include "sechash.h"
 
39
#include "blapi.h"      /* below the line */
 
40
#include "secerr.h"
 
41
 
 
42
static void *
 
43
null_hash_new_context(void)
 
44
{
 
45
    return NULL;
 
46
}
 
47
 
 
48
static void *
 
49
null_hash_clone_context(void *v)
 
50
{
 
51
    PORT_Assert(v == NULL);
 
52
    return NULL;
 
53
}
 
54
 
 
55
static void
 
56
null_hash_begin(void *v)
 
57
{
 
58
}
 
59
 
 
60
static void
 
61
null_hash_update(void *v, const unsigned char *input, unsigned int length)
 
62
{
 
63
}
 
64
 
 
65
static void
 
66
null_hash_end(void *v, unsigned char *output, unsigned int *outLen,
 
67
              unsigned int maxOut)
 
68
{
 
69
    *outLen = 0;
 
70
}
 
71
 
 
72
static void
 
73
null_hash_destroy_context(void *v, PRBool b)
 
74
{
 
75
    PORT_Assert(v == NULL);
 
76
}
 
77
 
 
78
 
 
79
const SECHashObject SECRawHashObjects[] = {
 
80
  { 0,
 
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,
 
88
    0,
 
89
    HASH_AlgNULL
 
90
  },
 
91
  { MD2_LENGTH,
 
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,
 
98
    MD2_BLOCK_LENGTH,
 
99
    HASH_AlgMD2
 
100
  },
 
101
  { MD5_LENGTH,
 
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,
 
108
    MD5_BLOCK_LENGTH,
 
109
    HASH_AlgMD5
 
110
  },
 
111
  { SHA1_LENGTH,
 
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,
 
118
    SHA1_BLOCK_LENGTH,
 
119
    HASH_AlgSHA1
 
120
  },
 
121
  { SHA256_LENGTH,
 
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,
 
129
    SHA256_BLOCK_LENGTH,
 
130
    HASH_AlgSHA256
 
131
  },
 
132
  { SHA384_LENGTH,
 
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,
 
140
    SHA384_BLOCK_LENGTH,
 
141
    HASH_AlgSHA384
 
142
  },
 
143
  { SHA512_LENGTH,
 
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,
 
151
    SHA512_BLOCK_LENGTH,
 
152
    HASH_AlgSHA512
 
153
  },
 
154
};
 
155
 
 
156
const SECHashObject *
 
157
HASH_GetRawHashObject(HASH_HashType hashType)
 
158
{
 
159
    if (hashType < HASH_AlgNULL || hashType >= HASH_AlgTOTAL) {
 
160
        PORT_SetError(SEC_ERROR_INVALID_ARGS);
 
161
        return NULL;
 
162
    }
 
163
    return &SECRawHashObjects[hashType];
 
164
}