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

Side by Side Diff: nss/lib/freebl/sha512.c

Issue 16132005: Allow NSS to be built with NO_NSPR_10_SUPPORT. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/nss/
Patch Set: Created 7 years, 6 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 | « nss/lib/freebl/rsa.c ('k') | nss/lib/freebl/sha_fast.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * sha512.c - implementation of SHA224, SHA256, SHA384 and SHA512 2 * sha512.c - implementation of SHA224, SHA256, SHA384 and SHA512
3 * 3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public 4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 7
8 #ifdef FREEBL_NO_DEPEND 8 #ifdef FREEBL_NO_DEPEND
9 #include "stubs.h" 9 #include "stubs.h"
10 #endif 10 #endif
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 #endif 485 #endif
486 486
487 len = PR_MIN(SHA256_LENGTH, maxDigestLen); 487 len = PR_MIN(SHA256_LENGTH, maxDigestLen);
488 memcpy(digest, h, len); 488 memcpy(digest, h, len);
489 if (digestLen) 489 if (digestLen)
490 *digestLen = len; 490 *digestLen = len;
491 } 491 }
492 492
493 SECStatus 493 SECStatus
494 SHA256_HashBuf(unsigned char *dest, const unsigned char *src, 494 SHA256_HashBuf(unsigned char *dest, const unsigned char *src,
495 uint32 src_length) 495 PRUint32 src_length)
496 { 496 {
497 SHA256Context ctx; 497 SHA256Context ctx;
498 unsigned int outLen; 498 unsigned int outLen;
499 499
500 SHA256_Begin(&ctx); 500 SHA256_Begin(&ctx);
501 SHA256_Update(&ctx, src, src_length); 501 SHA256_Update(&ctx, src, src_length);
502 SHA256_End(&ctx, dest, &outLen, SHA256_LENGTH); 502 SHA256_End(&ctx, dest, &outLen, SHA256_LENGTH);
503 memset(&ctx, 0, sizeof ctx); 503 memset(&ctx, 0, sizeof ctx);
504 504
505 return SECSuccess; 505 return SECSuccess;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 void 587 void
588 SHA224_EndRaw(SHA256Context *ctx, unsigned char *digest, 588 SHA224_EndRaw(SHA256Context *ctx, unsigned char *digest,
589 unsigned int *digestLen, unsigned int maxDigestLen) 589 unsigned int *digestLen, unsigned int maxDigestLen)
590 { 590 {
591 unsigned int maxLen = SHA_MIN(maxDigestLen, SHA224_LENGTH); 591 unsigned int maxLen = SHA_MIN(maxDigestLen, SHA224_LENGTH);
592 SHA256_EndRaw(ctx, digest, digestLen, maxLen); 592 SHA256_EndRaw(ctx, digest, digestLen, maxLen);
593 } 593 }
594 594
595 SECStatus 595 SECStatus
596 SHA224_HashBuf(unsigned char *dest, const unsigned char *src, 596 SHA224_HashBuf(unsigned char *dest, const unsigned char *src,
597 uint32 src_length) 597 PRUint32 src_length)
598 { 598 {
599 SHA256Context ctx; 599 SHA256Context ctx;
600 unsigned int outLen; 600 unsigned int outLen;
601 601
602 SHA224_Begin(&ctx); 602 SHA224_Begin(&ctx);
603 SHA256_Update(&ctx, src, src_length); 603 SHA256_Update(&ctx, src, src_length);
604 SHA256_End(&ctx, dest, &outLen, SHA224_LENGTH); 604 SHA256_End(&ctx, dest, &outLen, SHA224_LENGTH);
605 memset(&ctx, 0, sizeof ctx); 605 memset(&ctx, 0, sizeof ctx);
606 606
607 return SECSuccess; 607 return SECSuccess;
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 BYTESWAP8(h[7]); 1289 BYTESWAP8(h[7]);
1290 #endif 1290 #endif
1291 len = PR_MIN(SHA512_LENGTH, maxDigestLen); 1291 len = PR_MIN(SHA512_LENGTH, maxDigestLen);
1292 memcpy(digest, h, len); 1292 memcpy(digest, h, len);
1293 if (digestLen) 1293 if (digestLen)
1294 *digestLen = len; 1294 *digestLen = len;
1295 } 1295 }
1296 1296
1297 SECStatus 1297 SECStatus
1298 SHA512_HashBuf(unsigned char *dest, const unsigned char *src, 1298 SHA512_HashBuf(unsigned char *dest, const unsigned char *src,
1299 uint32 src_length) 1299 PRUint32 src_length)
1300 { 1300 {
1301 SHA512Context ctx; 1301 SHA512Context ctx;
1302 unsigned int outLen; 1302 unsigned int outLen;
1303 1303
1304 SHA512_Begin(&ctx); 1304 SHA512_Begin(&ctx);
1305 SHA512_Update(&ctx, src, src_length); 1305 SHA512_Update(&ctx, src, src_length);
1306 SHA512_End(&ctx, dest, &outLen, SHA512_LENGTH); 1306 SHA512_End(&ctx, dest, &outLen, SHA512_LENGTH);
1307 memset(&ctx, 0, sizeof ctx); 1307 memset(&ctx, 0, sizeof ctx);
1308 1308
1309 return SECSuccess; 1309 return SECSuccess;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1405 void 1405 void
1406 SHA384_EndRaw(SHA384Context *ctx, unsigned char *digest, 1406 SHA384_EndRaw(SHA384Context *ctx, unsigned char *digest,
1407 unsigned int *digestLen, unsigned int maxDigestLen) 1407 unsigned int *digestLen, unsigned int maxDigestLen)
1408 { 1408 {
1409 unsigned int maxLen = SHA_MIN(maxDigestLen, SHA384_LENGTH); 1409 unsigned int maxLen = SHA_MIN(maxDigestLen, SHA384_LENGTH);
1410 SHA512_EndRaw(ctx, digest, digestLen, maxLen); 1410 SHA512_EndRaw(ctx, digest, digestLen, maxLen);
1411 } 1411 }
1412 1412
1413 SECStatus 1413 SECStatus
1414 SHA384_HashBuf(unsigned char *dest, const unsigned char *src, 1414 SHA384_HashBuf(unsigned char *dest, const unsigned char *src,
1415 » » » uint32 src_length) 1415 » PRUint32 src_length)
1416 { 1416 {
1417 SHA512Context ctx; 1417 SHA512Context ctx;
1418 unsigned int outLen; 1418 unsigned int outLen;
1419 1419
1420 SHA384_Begin(&ctx); 1420 SHA384_Begin(&ctx);
1421 SHA512_Update(&ctx, src, src_length); 1421 SHA512_Update(&ctx, src, src_length);
1422 SHA512_End(&ctx, dest, &outLen, SHA384_LENGTH); 1422 SHA512_End(&ctx, dest, &outLen, SHA384_LENGTH);
1423 memset(&ctx, 0, sizeof ctx); 1423 memset(&ctx, 0, sizeof ctx);
1424 1424
1425 return SECSuccess; 1425 return SECSuccess;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1589 } 1589 }
1590 printf("done\n"); 1590 printf("done\n");
1591 } 1591 }
1592 return 0; 1592 return 0;
1593 } 1593 }
1594 1594
1595 void *PORT_Alloc(size_t len) { return malloc(len); } 1595 void *PORT_Alloc(size_t len) { return malloc(len); }
1596 void PORT_Free(void *ptr) { free(ptr); } 1596 void PORT_Free(void *ptr) { free(ptr); }
1597 void PORT_ZFree(void *ptr, size_t len) { memset(ptr, 0, len); free(ptr); } 1597 void PORT_ZFree(void *ptr, size_t len) { memset(ptr, 0, len); free(ptr); }
1598 #endif 1598 #endif
OLDNEW
« no previous file with comments | « nss/lib/freebl/rsa.c ('k') | nss/lib/freebl/sha_fast.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698