UNPKG

2.26 kBJavaScriptView Raw
1;(function (root, factory, undef) {
2 if (typeof exports === "object") {
3 // CommonJS
4 module.exports = exports = factory(require("./core"), require("./x64-core"), require("./sha512"));
5 }
6 else if (typeof define === "function" && define.amd) {
7 // AMD
8 define(["./core", "./x64-core", "./sha512"], factory);
9 }
10 else {
11 // Global (browser)
12 factory(root.CryptoJS);
13 }
14}(this, function (CryptoJS) {
15
16 (function () {
17 // Shortcuts
18 var C = CryptoJS;
19 var C_x64 = C.x64;
20 var X64Word = C_x64.Word;
21 var X64WordArray = C_x64.WordArray;
22 var C_algo = C.algo;
23 var SHA512 = C_algo.SHA512;
24
25 /**
26 * SHA-384 hash algorithm.
27 */
28 var SHA384 = C_algo.SHA384 = SHA512.extend({
29 _doReset: function () {
30 this._hash = new X64WordArray.init([
31 new X64Word.init(0xcbbb9d5d, 0xc1059ed8), new X64Word.init(0x629a292a, 0x367cd507),
32 new X64Word.init(0x9159015a, 0x3070dd17), new X64Word.init(0x152fecd8, 0xf70e5939),
33 new X64Word.init(0x67332667, 0xffc00b31), new X64Word.init(0x8eb44a87, 0x68581511),
34 new X64Word.init(0xdb0c2e0d, 0x64f98fa7), new X64Word.init(0x47b5481d, 0xbefa4fa4)
35 ]);
36 },
37
38 _doFinalize: function () {
39 var hash = SHA512._doFinalize.call(this);
40
41 hash.sigBytes -= 16;
42
43 return hash;
44 }
45 });
46
47 /**
48 * Shortcut function to the hasher's object interface.
49 *
50 * @param {WordArray|string} message The message to hash.
51 *
52 * @return {WordArray} The hash.
53 *
54 * @static
55 *
56 * @example
57 *
58 * var hash = CryptoJS.SHA384('message');
59 * var hash = CryptoJS.SHA384(wordArray);
60 */
61 C.SHA384 = SHA512._createHelper(SHA384);
62
63 /**
64 * Shortcut function to the HMAC's object interface.
65 *
66 * @param {WordArray|string} message The message to hash.
67 * @param {WordArray|string} key The secret key.
68 *
69 * @return {WordArray} The HMAC.
70 *
71 * @static
72 *
73 * @example
74 *
75 * var hmac = CryptoJS.HmacSHA384(message, key);
76 */
77 C.HmacSHA384 = SHA512._createHmacHelper(SHA384);
78 }());
79
80
81 return CryptoJS.SHA384;
82
83}));
\No newline at end of file