sha384.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. CryptoJS v3.1.2
  3. code.google.com/p/crypto-js
  4. (c) 2009-2013 by Jeff Mott. All rights reserved.
  5. code.google.com/p/crypto-js/wiki/License
  6. */
  7. (function () {
  8. // Shortcuts
  9. var C = CryptoJS;
  10. var C_x64 = C.x64;
  11. var X64Word = C_x64.Word;
  12. var X64WordArray = C_x64.WordArray;
  13. var C_algo = C.algo;
  14. var SHA512 = C_algo.SHA512;
  15. /**
  16. * SHA-384 hash algorithm.
  17. */
  18. var SHA384 = C_algo.SHA384 = SHA512.extend({
  19. _doReset: function () {
  20. this._hash = new X64WordArray.init([
  21. new X64Word.init(0xcbbb9d5d, 0xc1059ed8), new X64Word.init(0x629a292a, 0x367cd507),
  22. new X64Word.init(0x9159015a, 0x3070dd17), new X64Word.init(0x152fecd8, 0xf70e5939),
  23. new X64Word.init(0x67332667, 0xffc00b31), new X64Word.init(0x8eb44a87, 0x68581511),
  24. new X64Word.init(0xdb0c2e0d, 0x64f98fa7), new X64Word.init(0x47b5481d, 0xbefa4fa4)
  25. ]);
  26. },
  27. _doFinalize: function () {
  28. var hash = SHA512._doFinalize.call(this);
  29. hash.sigBytes -= 16;
  30. return hash;
  31. }
  32. });
  33. /**
  34. * Shortcut function to the hasher's object interface.
  35. *
  36. * @param {WordArray|string} message The message to hash.
  37. *
  38. * @return {WordArray} The hash.
  39. *
  40. * @static
  41. *
  42. * @example
  43. *
  44. * var hash = CryptoJS.SHA384('message');
  45. * var hash = CryptoJS.SHA384(wordArray);
  46. */
  47. C.SHA384 = SHA512._createHelper(SHA384);
  48. /**
  49. * Shortcut function to the HMAC's object interface.
  50. *
  51. * @param {WordArray|string} message The message to hash.
  52. * @param {WordArray|string} key The secret key.
  53. *
  54. * @return {WordArray} The HMAC.
  55. *
  56. * @static
  57. *
  58. * @example
  59. *
  60. * var hmac = CryptoJS.HmacSHA384(message, key);
  61. */
  62. C.HmacSHA384 = SHA512._createHmacHelper(SHA384);
  63. }());