sha384.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright 2014 The Closure Library Authors. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS-IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. /**
  15. * @fileoverview SHA-384 cryptographic hash.
  16. *
  17. * Usage:
  18. * var sha384 = new goog.crypt.Sha384();
  19. * sha384.update(bytes);
  20. * var hash = sha384.digest();
  21. *
  22. * @author fy@google.com (Frank Yellin)
  23. */
  24. goog.provide('goog.crypt.Sha384');
  25. goog.require('goog.crypt.Sha2_64bit');
  26. /**
  27. * Constructs a SHA-384 cryptographic hash.
  28. *
  29. * @constructor
  30. * @extends {goog.crypt.Sha2_64bit}
  31. * @final
  32. * @struct
  33. */
  34. goog.crypt.Sha384 = function() {
  35. goog.crypt.Sha384.base(
  36. this, 'constructor', 6 /* numHashBlocks */,
  37. goog.crypt.Sha384.INIT_HASH_BLOCK_);
  38. };
  39. goog.inherits(goog.crypt.Sha384, goog.crypt.Sha2_64bit);
  40. /** @private {!Array<number>} */
  41. goog.crypt.Sha384.INIT_HASH_BLOCK_ = [
  42. // Section 5.3.4 of
  43. // csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf
  44. 0xcbbb9d5d, 0xc1059ed8, // H0
  45. 0x629a292a, 0x367cd507, // H1
  46. 0x9159015a, 0x3070dd17, // H2
  47. 0x152fecd8, 0xf70e5939, // H3
  48. 0x67332667, 0xffc00b31, // H4
  49. 0x8eb44a87, 0x68581511, // H5
  50. 0xdb0c2e0d, 0x64f98fa7, // H6
  51. 0x47b5481d, 0xbefa4fa4 // H7
  52. ];