Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Side by Side Diff: mozilla/security/nss/lib/freebl/sha_fast.c

Issue 12207073: Update to NSS 3.14.3 Beta 1 for the TLS CBC constant-time (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/nss/
Patch Set: Remove unrelated WIN64 changes from nss.gyp Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « mozilla/security/nss/lib/freebl/sha_fast.h ('k') | mozilla/security/nss/lib/nss/nss.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* This Source Code Form is subject to the terms of the Mozilla Public 1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 4
5 #ifdef FREEBL_NO_DEPEND 5 #ifdef FREEBL_NO_DEPEND
6 #include "stubs.h" 6 #include "stubs.h"
7 #endif 7 #endif
8 8
9 #include <memory.h> 9 #include <memory.h>
10 #include "blapi.h" 10 #include "blapi.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 141
142 /* 142 /*
143 * SHA: Generate hash value from context 143 * SHA: Generate hash value from context
144 */ 144 */
145 void 145 void
146 SHA1_End(SHA1Context *ctx, unsigned char *hashout, 146 SHA1_End(SHA1Context *ctx, unsigned char *hashout,
147 unsigned int *pDigestLen, unsigned int maxDigestLen) 147 unsigned int *pDigestLen, unsigned int maxDigestLen)
148 { 148 {
149 register PRUint64 size; 149 register PRUint64 size;
150 register PRUint32 lenB; 150 register PRUint32 lenB;
151 PRUint32 tmpbuf[5];
151 152
152 static const unsigned char bulk_pad[64] = { 0x80,0,0,0,0,0,0,0,0,0, 153 static const unsigned char bulk_pad[64] = { 0x80,0,0,0,0,0,0,0,0,0,
153 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 154 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
154 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; 155 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
155 #define tmp lenB 156 #define tmp lenB
156 157
157 PORT_Assert (maxDigestLen >= SHA1_LENGTH); 158 PORT_Assert (maxDigestLen >= SHA1_LENGTH);
158 159
159 /* 160 /*
160 * Pad with a binary 1 (e.g. 0x80), then zeroes, then length in bits 161 * Pad with a binary 1 (e.g. 0x80), then zeroes, then length in bits
161 */ 162 */
162 size = ctx->size; 163 size = ctx->size;
163 164
164 lenB = (PRUint32)size & 63; 165 lenB = (PRUint32)size & 63;
165 SHA1_Update(ctx, bulk_pad, (((55+64) - lenB) & 63) + 1); 166 SHA1_Update(ctx, bulk_pad, (((55+64) - lenB) & 63) + 1);
166 PORT_Assert(((PRUint32)ctx->size & 63) == 56); 167 PORT_Assert(((PRUint32)ctx->size & 63) == 56);
167 /* Convert size from bytes to bits. */ 168 /* Convert size from bytes to bits. */
168 size <<= 3; 169 size <<= 3;
169 ctx->W[14] = SHA_HTONL((PRUint32)(size >> 32)); 170 ctx->W[14] = SHA_HTONL((PRUint32)(size >> 32));
170 ctx->W[15] = SHA_HTONL((PRUint32)size); 171 ctx->W[15] = SHA_HTONL((PRUint32)size);
171 shaCompress(&ctx->H[H2X], ctx->W); 172 shaCompress(&ctx->H[H2X], ctx->W);
172 173
173 /* 174 /*
174 * Output hash 175 * Output hash
175 */ 176 */
176 SHA_STORE_RESULT; 177 SHA_STORE_RESULT;
177 *pDigestLen = SHA1_LENGTH; 178 if (pDigestLen) {
179 *pDigestLen = SHA1_LENGTH;
180 }
181 #undef tmp
182 }
178 183
184 void
185 SHA1_EndRaw(SHA1Context *ctx, unsigned char *hashout,
186 unsigned int *pDigestLen, unsigned int maxDigestLen)
187 {
188 #if defined(SHA_NEED_TMP_VARIABLE)
189 register PRUint32 tmp;
190 #endif
191 PRUint32 tmpbuf[5];
192 PORT_Assert (maxDigestLen >= SHA1_LENGTH);
193
194 SHA_STORE_RESULT;
195 if (pDigestLen)
196 *pDigestLen = SHA1_LENGTH;
179 } 197 }
180 198
181 #undef B 199 #undef B
182 #undef tmp
183 /* 200 /*
184 * SHA: Compression function, unrolled. 201 * SHA: Compression function, unrolled.
185 * 202 *
186 * Some operations in shaCompress are done as 5 groups of 16 operations. 203 * Some operations in shaCompress are done as 5 groups of 16 operations.
187 * Others are done as 4 groups of 20 operations. 204 * Others are done as 4 groups of 20 operations.
188 * The code below shows that structure. 205 * The code below shows that structure.
189 * 206 *
190 * The functions that compute the new values of the 5 state variables 207 * The functions that compute the new values of the 5 state variables
191 * A-E are done in 4 groups of 20 operations (or you may also think 208 * A-E are done in 4 groups of 20 operations (or you may also think
192 * of them as being done in 16 groups of 5 operations). They are 209 * of them as being done in 16 groups of 5 operations). They are
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 void SHA1_Clone(SHA1Context *dest, SHA1Context *src) 454 void SHA1_Clone(SHA1Context *dest, SHA1Context *src)
438 { 455 {
439 memcpy(dest, src, sizeof *dest); 456 memcpy(dest, src, sizeof *dest);
440 } 457 }
441 458
442 void 459 void
443 SHA1_TraceState(SHA1Context *ctx) 460 SHA1_TraceState(SHA1Context *ctx)
444 { 461 {
445 PORT_SetError(PR_NOT_IMPLEMENTED_ERROR); 462 PORT_SetError(PR_NOT_IMPLEMENTED_ERROR);
446 } 463 }
OLDNEW
« no previous file with comments | « mozilla/security/nss/lib/freebl/sha_fast.h ('k') | mozilla/security/nss/lib/nss/nss.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698