fcad-core-dragon 2.1.0-beta.4 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +8 -33
- package/.prettierrc +11 -0
- package/.vscode/extensions.json +8 -0
- package/.vscode/settings.json +16 -0
- package/CHANGELOG +20 -0
- package/eslint.config.js +60 -0
- package/package.json +9 -9
- package/src/$locales/en.json +3 -3
- package/src/$locales/fr.json +3 -3
- package/src/assets/data/onboardingMessages.json +47 -47
- package/src/components/AppBase.vue +5 -6
- package/src/components/AppBaseErrorDisplay.vue +438 -438
- package/src/components/AppBaseFlipCard.vue +84 -84
- package/src/components/AppBaseModule.vue +15 -17
- package/src/components/AppBasePage.vue +91 -8
- package/src/components/AppBasePopover.vue +41 -41
- package/src/components/AppBaseSkeleton.vue +24 -3
- package/src/components/AppCompAudio.vue +12 -2
- package/src/components/AppCompInputCheckBoxNx.vue +1 -2
- package/src/components/AppCompInputRadioNx.vue +8 -2
- package/src/components/AppCompInputTextToFillDropdownNx.vue +45 -0
- package/src/components/AppCompMenu.vue +423 -423
- package/src/components/AppCompNavigation.vue +2 -2
- package/src/components/AppCompPlayBarNext.vue +123 -94
- package/src/components/AppCompPopUpNext.vue +2 -2
- package/src/components/AppCompQuizNext.vue +12 -2
- package/src/components/AppCompQuizRecall.vue +10 -4
- package/src/components/AppCompSettingsMenu.vue +172 -172
- package/src/components/AppCompTableOfContent.vue +1 -4
- package/src/components/AppCompVideoPlayer.vue +7 -0
- package/src/components/AppCompViewDisplay.vue +6 -6
- package/src/composables/useTimer.js +17 -20
- package/src/externalComps/ModuleView.vue +22 -22
- package/src/externalComps/SummaryView.vue +91 -91
- package/src/main.js +5 -5
- package/src/module/stores/appStore.js +0 -1
- package/src/module/xapi/Crypto/Hasher.js +241 -241
- package/src/module/xapi/Crypto/WordArray.js +278 -278
- package/src/module/xapi/Crypto/algorithms/BufferedBlockAlgorithm.js +103 -103
- package/src/module/xapi/Crypto/algorithms/C_algo.js +315 -315
- package/src/module/xapi/Crypto/algorithms/HMAC.js +9 -9
- package/src/module/xapi/Crypto/algorithms/SHA1.js +9 -9
- package/src/module/xapi/Crypto/encoders/Base.js +105 -105
- package/src/module/xapi/Crypto/encoders/Base64.js +99 -99
- package/src/module/xapi/Crypto/encoders/Hex.js +61 -61
- package/src/module/xapi/Crypto/encoders/Latin1.js +61 -61
- package/src/module/xapi/Crypto/encoders/Utf8.js +45 -45
- package/src/module/xapi/Crypto/index.js +53 -53
- package/src/module/xapi/Statement/activity.js +47 -47
- package/src/module/xapi/Statement/agent.js +55 -55
- package/src/module/xapi/Statement/group.js +26 -26
- package/src/module/xapi/Statement/index.js +259 -259
- package/src/module/xapi/Statement/statement.js +253 -253
- package/src/module/xapi/Statement/statementRef.js +23 -23
- package/src/module/xapi/Statement/substatement.js +22 -22
- package/src/module/xapi/Statement/verb.js +36 -36
- package/src/module/xapi/activitytypes.js +17 -17
- package/src/module/xapi/utils.js +167 -167
- package/src/module/xapi/verbs.js +294 -294
- package/src/module/xapi/xapiStatement.js +444 -444
- package/src/plugins/analytics.js +4 -4
- package/src/plugins/bus.js +8 -8
- package/src/plugins/gsap.js +4 -2
- package/src/plugins/helper.js +8 -4
- package/src/plugins/save.js +37 -37
- package/src/plugins/scorm.js +287 -287
- package/src/plugins/xapi.js +11 -11
- package/src/public/index.html +33 -33
- package/src/router/index.js +1 -1
- package/src/shared/validators.js +22 -6
- package/.eslintignore +0 -29
- package/.eslintrc.cjs +0 -81
- package/bk.scss +0 -117
|
@@ -1,315 +1,315 @@
|
|
|
1
|
-
import { WordArray } from '../WordArray'
|
|
2
|
-
import { Hasher } from '../Hasher'
|
|
3
|
-
import { Base } from '../encoders/Base'
|
|
4
|
-
import { Utf8 } from '../encoders/Utf8'
|
|
5
|
-
/**
|
|
6
|
-
* Algorithm namespace.
|
|
7
|
-
*/
|
|
8
|
-
export const C_algo = function () {
|
|
9
|
-
// Reusable Variables
|
|
10
|
-
let W = [],
|
|
11
|
-
K = [],
|
|
12
|
-
H = []
|
|
13
|
-
|
|
14
|
-
return {
|
|
15
|
-
/**
|
|
16
|
-
* SHA-1 hash algorithm.
|
|
17
|
-
*/
|
|
18
|
-
SHA1: Hasher.extend({
|
|
19
|
-
_doReset: function () {
|
|
20
|
-
this._hash = new WordArray.init([
|
|
21
|
-
0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0
|
|
22
|
-
])
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
_doProcessBlock: function (M, offset) {
|
|
26
|
-
// Shortcut
|
|
27
|
-
let H = this._hash.words
|
|
28
|
-
|
|
29
|
-
// Working let iables
|
|
30
|
-
let a = H[0]
|
|
31
|
-
let b = H[1]
|
|
32
|
-
let c = H[2]
|
|
33
|
-
let d = H[3]
|
|
34
|
-
let e = H[4]
|
|
35
|
-
|
|
36
|
-
// Computation
|
|
37
|
-
for (let i = 0; i < 80; i++) {
|
|
38
|
-
if (i < 16) {
|
|
39
|
-
W[i] = M[offset + i] | 0
|
|
40
|
-
} else {
|
|
41
|
-
let n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]
|
|
42
|
-
W[i] = (n << 1) | (n >>> 31)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
let t = ((a << 5) | (a >>> 27)) + e + W[i]
|
|
46
|
-
if (i < 20) {
|
|
47
|
-
t += ((b & c) | (~b & d)) + 0x5a827999
|
|
48
|
-
} else if (i < 40) {
|
|
49
|
-
t += (b ^ c ^ d) + 0x6ed9eba1
|
|
50
|
-
} else if (i < 60) {
|
|
51
|
-
t += ((b & c) | (b & d) | (c & d)) - 0x70e44324
|
|
52
|
-
} /* if (i < 80) */ else {
|
|
53
|
-
t += (b ^ c ^ d) - 0x359d3e2a
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
e = d
|
|
57
|
-
d = c
|
|
58
|
-
c = (b << 30) | (b >>> 2)
|
|
59
|
-
b = a
|
|
60
|
-
a = t
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Intermediate hash value
|
|
64
|
-
H[0] = (H[0] + a) | 0
|
|
65
|
-
H[1] = (H[1] + b) | 0
|
|
66
|
-
H[2] = (H[2] + c) | 0
|
|
67
|
-
H[3] = (H[3] + d) | 0
|
|
68
|
-
H[4] = (H[4] + e) | 0
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
_doFinalize: function () {
|
|
72
|
-
// Shortcuts
|
|
73
|
-
let data = this._data
|
|
74
|
-
let dataWords = data.words
|
|
75
|
-
|
|
76
|
-
let nBitsTotal = this._nDataBytes * 8
|
|
77
|
-
let nBitsLeft = data.sigBytes * 8
|
|
78
|
-
|
|
79
|
-
// Add padding
|
|
80
|
-
dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - (nBitsLeft % 32))
|
|
81
|
-
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(
|
|
82
|
-
nBitsTotal / 0x100000000
|
|
83
|
-
)
|
|
84
|
-
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal
|
|
85
|
-
data.sigBytes = dataWords.length * 4
|
|
86
|
-
|
|
87
|
-
// Hash final blocks
|
|
88
|
-
this._process()
|
|
89
|
-
|
|
90
|
-
// Return final computed hash
|
|
91
|
-
return this._hash
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
clone: function () {
|
|
95
|
-
let clone = Hasher.clone.call(this)
|
|
96
|
-
clone._hash = this._hash.clone()
|
|
97
|
-
|
|
98
|
-
return clone
|
|
99
|
-
}
|
|
100
|
-
}),
|
|
101
|
-
/**
|
|
102
|
-
* HMAC algorithm.
|
|
103
|
-
*/
|
|
104
|
-
HMAC: Base.extend({
|
|
105
|
-
/**
|
|
106
|
-
* Initializes a newly created HMAC.
|
|
107
|
-
*
|
|
108
|
-
* @param {Hasher} hasher The hash algorithm to use.
|
|
109
|
-
* @param {WordArray|string} key The secret key.
|
|
110
|
-
* @example
|
|
111
|
-
* let hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
|
|
112
|
-
*/
|
|
113
|
-
init: function (hasher, key) {
|
|
114
|
-
// Init hasher
|
|
115
|
-
hasher = this._hasher = new hasher.init()
|
|
116
|
-
|
|
117
|
-
// Convert string to WordArray, else assume WordArray already
|
|
118
|
-
if (typeof key == 'string') {
|
|
119
|
-
key = Utf8.parse(key)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// Shortcuts
|
|
123
|
-
let hasherBlockSize = hasher.blockSize
|
|
124
|
-
let hasherBlockSizeBytes = hasherBlockSize * 4
|
|
125
|
-
|
|
126
|
-
// Allow arbitrary length keys
|
|
127
|
-
if (key.sigBytes > hasherBlockSizeBytes) {
|
|
128
|
-
key = hasher.finalize(key)
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// Clamp excess bits
|
|
132
|
-
key.clamp()
|
|
133
|
-
|
|
134
|
-
// Clone key for inner and outer pads
|
|
135
|
-
let oKey = (this._oKey = key.clone())
|
|
136
|
-
let iKey = (this._iKey = key.clone())
|
|
137
|
-
|
|
138
|
-
// Shortcuts
|
|
139
|
-
let oKeyWords = oKey.words
|
|
140
|
-
let iKeyWords = iKey.words
|
|
141
|
-
|
|
142
|
-
// XOR keys with pad constants
|
|
143
|
-
for (let i = 0; i < hasherBlockSize; i++) {
|
|
144
|
-
oKeyWords[i] ^= 0x5c5c5c5c
|
|
145
|
-
iKeyWords[i] ^= 0x36363636
|
|
146
|
-
}
|
|
147
|
-
oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes
|
|
148
|
-
|
|
149
|
-
// Set initial values
|
|
150
|
-
this.reset()
|
|
151
|
-
},
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Resets this HMAC to its initial state.
|
|
155
|
-
* @example
|
|
156
|
-
* hmacHasher.reset();
|
|
157
|
-
*/
|
|
158
|
-
reset: function () {
|
|
159
|
-
// Shortcut
|
|
160
|
-
let hasher = this._hasher
|
|
161
|
-
|
|
162
|
-
// Reset
|
|
163
|
-
hasher.reset()
|
|
164
|
-
hasher.update(this._iKey)
|
|
165
|
-
},
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Updates this HMAC with a message.
|
|
169
|
-
* @param {WordArray|string} messageUpdate The message to append.
|
|
170
|
-
* @return {HMAC} This HMAC instance.
|
|
171
|
-
* @example
|
|
172
|
-
* hmacHasher.update('message');
|
|
173
|
-
* hmacHasher.update(wordArray);
|
|
174
|
-
*/
|
|
175
|
-
update: function (messageUpdate) {
|
|
176
|
-
this._hasher.update(messageUpdate)
|
|
177
|
-
|
|
178
|
-
// Chainable
|
|
179
|
-
return this
|
|
180
|
-
},
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Finalizes the HMAC computation.
|
|
184
|
-
* Note that the finalize operation is effectively a destructive, read-once operation.
|
|
185
|
-
*
|
|
186
|
-
* @param {WordArray|string} messageUpdate (Optional) A final message update.
|
|
187
|
-
* @return {WordArray} The HMAC.
|
|
188
|
-
* @example
|
|
189
|
-
* let hmac = hmacHasher.finalize();
|
|
190
|
-
* let hmac = hmacHasher.finalize('message');
|
|
191
|
-
* let hmac = hmacHasher.finalize(wordArray);
|
|
192
|
-
*/
|
|
193
|
-
finalize: function (messageUpdate) {
|
|
194
|
-
// Shortcut
|
|
195
|
-
let hasher = this._hasher
|
|
196
|
-
|
|
197
|
-
// Compute HMAC
|
|
198
|
-
let innerHash = hasher.finalize(messageUpdate)
|
|
199
|
-
hasher.reset()
|
|
200
|
-
let hmac = hasher.finalize(this._oKey.clone().concat(innerHash))
|
|
201
|
-
|
|
202
|
-
return hmac
|
|
203
|
-
}
|
|
204
|
-
}),
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* SHA-256 hash algorithm.
|
|
208
|
-
*/
|
|
209
|
-
SHA256: Hasher.extend({
|
|
210
|
-
_doReset: function () {
|
|
211
|
-
this._hash = new WordArray.init(H.slice(0))
|
|
212
|
-
},
|
|
213
|
-
|
|
214
|
-
_doProcessBlock: function (M, offset) {
|
|
215
|
-
// Shortcut
|
|
216
|
-
let H = this._hash.words
|
|
217
|
-
|
|
218
|
-
// Working variables
|
|
219
|
-
let a = H[0]
|
|
220
|
-
let b = H[1]
|
|
221
|
-
let c = H[2]
|
|
222
|
-
let d = H[3]
|
|
223
|
-
let e = H[4]
|
|
224
|
-
let f = H[5]
|
|
225
|
-
let g = H[6]
|
|
226
|
-
let h = H[7]
|
|
227
|
-
|
|
228
|
-
// Computation
|
|
229
|
-
for (let i = 0; i < 64; i++) {
|
|
230
|
-
if (i < 16) {
|
|
231
|
-
W[i] = M[offset + i] | 0
|
|
232
|
-
} else {
|
|
233
|
-
let gamma0x = W[i - 15]
|
|
234
|
-
let gamma0 =
|
|
235
|
-
((gamma0x << 25) | (gamma0x >>> 7)) ^
|
|
236
|
-
((gamma0x << 14) | (gamma0x >>> 18)) ^
|
|
237
|
-
(gamma0x >>> 3)
|
|
238
|
-
|
|
239
|
-
let gamma1x = W[i - 2]
|
|
240
|
-
let gamma1 =
|
|
241
|
-
((gamma1x << 15) | (gamma1x >>> 17)) ^
|
|
242
|
-
((gamma1x << 13) | (gamma1x >>> 19)) ^
|
|
243
|
-
(gamma1x >>> 10)
|
|
244
|
-
|
|
245
|
-
W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
let ch = (e & f) ^ (~e & g)
|
|
249
|
-
let maj = (a & b) ^ (a & c) ^ (b & c)
|
|
250
|
-
|
|
251
|
-
let sigma0 =
|
|
252
|
-
((a << 30) | (a >>> 2)) ^
|
|
253
|
-
((a << 19) | (a >>> 13)) ^
|
|
254
|
-
((a << 10) | (a >>> 22))
|
|
255
|
-
let sigma1 =
|
|
256
|
-
((e << 26) | (e >>> 6)) ^
|
|
257
|
-
((e << 21) | (e >>> 11)) ^
|
|
258
|
-
((e << 7) | (e >>> 25))
|
|
259
|
-
|
|
260
|
-
let t1 = h + sigma1 + ch + K[i] + W[i]
|
|
261
|
-
let t2 = sigma0 + maj
|
|
262
|
-
|
|
263
|
-
h = g
|
|
264
|
-
g = f
|
|
265
|
-
f = e
|
|
266
|
-
e = (d + t1) | 0
|
|
267
|
-
d = c
|
|
268
|
-
c = b
|
|
269
|
-
b = a
|
|
270
|
-
a = (t1 + t2) | 0
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
// Intermediate hash value
|
|
274
|
-
H[0] = (H[0] + a) | 0
|
|
275
|
-
H[1] = (H[1] + b) | 0
|
|
276
|
-
H[2] = (H[2] + c) | 0
|
|
277
|
-
H[3] = (H[3] + d) | 0
|
|
278
|
-
H[4] = (H[4] + e) | 0
|
|
279
|
-
H[5] = (H[5] + f) | 0
|
|
280
|
-
H[6] = (H[6] + g) | 0
|
|
281
|
-
H[7] = (H[7] + h) | 0
|
|
282
|
-
},
|
|
283
|
-
|
|
284
|
-
_doFinalize: function () {
|
|
285
|
-
// Shortcuts
|
|
286
|
-
let data = this._data
|
|
287
|
-
let dataWords = data.words
|
|
288
|
-
|
|
289
|
-
let nBitsTotal = this._nDataBytes * 8
|
|
290
|
-
let nBitsLeft = data.sigBytes * 8
|
|
291
|
-
|
|
292
|
-
// Add padding
|
|
293
|
-
dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - (nBitsLeft % 32))
|
|
294
|
-
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(
|
|
295
|
-
nBitsTotal / 0x100000000
|
|
296
|
-
)
|
|
297
|
-
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal
|
|
298
|
-
data.sigBytes = dataWords.length * 4
|
|
299
|
-
|
|
300
|
-
// Hash final blocks
|
|
301
|
-
this._process()
|
|
302
|
-
|
|
303
|
-
// Return final computed hash
|
|
304
|
-
return this._hash
|
|
305
|
-
},
|
|
306
|
-
|
|
307
|
-
clone: function () {
|
|
308
|
-
let clone = Hasher.clone.call(this)
|
|
309
|
-
clone._hash = this._hash.clone()
|
|
310
|
-
|
|
311
|
-
return clone
|
|
312
|
-
}
|
|
313
|
-
})
|
|
314
|
-
}
|
|
315
|
-
}
|
|
1
|
+
import { WordArray } from '../WordArray'
|
|
2
|
+
import { Hasher } from '../Hasher'
|
|
3
|
+
import { Base } from '../encoders/Base'
|
|
4
|
+
import { Utf8 } from '../encoders/Utf8'
|
|
5
|
+
/**
|
|
6
|
+
* Algorithm namespace.
|
|
7
|
+
*/
|
|
8
|
+
export const C_algo = function () {
|
|
9
|
+
// Reusable Variables
|
|
10
|
+
let W = [],
|
|
11
|
+
K = [],
|
|
12
|
+
H = []
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
/**
|
|
16
|
+
* SHA-1 hash algorithm.
|
|
17
|
+
*/
|
|
18
|
+
SHA1: Hasher.extend({
|
|
19
|
+
_doReset: function () {
|
|
20
|
+
this._hash = new WordArray.init([
|
|
21
|
+
0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0
|
|
22
|
+
])
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
_doProcessBlock: function (M, offset) {
|
|
26
|
+
// Shortcut
|
|
27
|
+
let H = this._hash.words
|
|
28
|
+
|
|
29
|
+
// Working let iables
|
|
30
|
+
let a = H[0]
|
|
31
|
+
let b = H[1]
|
|
32
|
+
let c = H[2]
|
|
33
|
+
let d = H[3]
|
|
34
|
+
let e = H[4]
|
|
35
|
+
|
|
36
|
+
// Computation
|
|
37
|
+
for (let i = 0; i < 80; i++) {
|
|
38
|
+
if (i < 16) {
|
|
39
|
+
W[i] = M[offset + i] | 0
|
|
40
|
+
} else {
|
|
41
|
+
let n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]
|
|
42
|
+
W[i] = (n << 1) | (n >>> 31)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
let t = ((a << 5) | (a >>> 27)) + e + W[i]
|
|
46
|
+
if (i < 20) {
|
|
47
|
+
t += ((b & c) | (~b & d)) + 0x5a827999
|
|
48
|
+
} else if (i < 40) {
|
|
49
|
+
t += (b ^ c ^ d) + 0x6ed9eba1
|
|
50
|
+
} else if (i < 60) {
|
|
51
|
+
t += ((b & c) | (b & d) | (c & d)) - 0x70e44324
|
|
52
|
+
} /* if (i < 80) */ else {
|
|
53
|
+
t += (b ^ c ^ d) - 0x359d3e2a
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
e = d
|
|
57
|
+
d = c
|
|
58
|
+
c = (b << 30) | (b >>> 2)
|
|
59
|
+
b = a
|
|
60
|
+
a = t
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Intermediate hash value
|
|
64
|
+
H[0] = (H[0] + a) | 0
|
|
65
|
+
H[1] = (H[1] + b) | 0
|
|
66
|
+
H[2] = (H[2] + c) | 0
|
|
67
|
+
H[3] = (H[3] + d) | 0
|
|
68
|
+
H[4] = (H[4] + e) | 0
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
_doFinalize: function () {
|
|
72
|
+
// Shortcuts
|
|
73
|
+
let data = this._data
|
|
74
|
+
let dataWords = data.words
|
|
75
|
+
|
|
76
|
+
let nBitsTotal = this._nDataBytes * 8
|
|
77
|
+
let nBitsLeft = data.sigBytes * 8
|
|
78
|
+
|
|
79
|
+
// Add padding
|
|
80
|
+
dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - (nBitsLeft % 32))
|
|
81
|
+
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(
|
|
82
|
+
nBitsTotal / 0x100000000
|
|
83
|
+
)
|
|
84
|
+
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal
|
|
85
|
+
data.sigBytes = dataWords.length * 4
|
|
86
|
+
|
|
87
|
+
// Hash final blocks
|
|
88
|
+
this._process()
|
|
89
|
+
|
|
90
|
+
// Return final computed hash
|
|
91
|
+
return this._hash
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
clone: function () {
|
|
95
|
+
let clone = Hasher.clone.call(this)
|
|
96
|
+
clone._hash = this._hash.clone()
|
|
97
|
+
|
|
98
|
+
return clone
|
|
99
|
+
}
|
|
100
|
+
}),
|
|
101
|
+
/**
|
|
102
|
+
* HMAC algorithm.
|
|
103
|
+
*/
|
|
104
|
+
HMAC: Base.extend({
|
|
105
|
+
/**
|
|
106
|
+
* Initializes a newly created HMAC.
|
|
107
|
+
*
|
|
108
|
+
* @param {Hasher} hasher The hash algorithm to use.
|
|
109
|
+
* @param {WordArray|string} key The secret key.
|
|
110
|
+
* @example
|
|
111
|
+
* let hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
|
|
112
|
+
*/
|
|
113
|
+
init: function (hasher, key) {
|
|
114
|
+
// Init hasher
|
|
115
|
+
hasher = this._hasher = new hasher.init()
|
|
116
|
+
|
|
117
|
+
// Convert string to WordArray, else assume WordArray already
|
|
118
|
+
if (typeof key == 'string') {
|
|
119
|
+
key = Utf8.parse(key)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Shortcuts
|
|
123
|
+
let hasherBlockSize = hasher.blockSize
|
|
124
|
+
let hasherBlockSizeBytes = hasherBlockSize * 4
|
|
125
|
+
|
|
126
|
+
// Allow arbitrary length keys
|
|
127
|
+
if (key.sigBytes > hasherBlockSizeBytes) {
|
|
128
|
+
key = hasher.finalize(key)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Clamp excess bits
|
|
132
|
+
key.clamp()
|
|
133
|
+
|
|
134
|
+
// Clone key for inner and outer pads
|
|
135
|
+
let oKey = (this._oKey = key.clone())
|
|
136
|
+
let iKey = (this._iKey = key.clone())
|
|
137
|
+
|
|
138
|
+
// Shortcuts
|
|
139
|
+
let oKeyWords = oKey.words
|
|
140
|
+
let iKeyWords = iKey.words
|
|
141
|
+
|
|
142
|
+
// XOR keys with pad constants
|
|
143
|
+
for (let i = 0; i < hasherBlockSize; i++) {
|
|
144
|
+
oKeyWords[i] ^= 0x5c5c5c5c
|
|
145
|
+
iKeyWords[i] ^= 0x36363636
|
|
146
|
+
}
|
|
147
|
+
oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes
|
|
148
|
+
|
|
149
|
+
// Set initial values
|
|
150
|
+
this.reset()
|
|
151
|
+
},
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Resets this HMAC to its initial state.
|
|
155
|
+
* @example
|
|
156
|
+
* hmacHasher.reset();
|
|
157
|
+
*/
|
|
158
|
+
reset: function () {
|
|
159
|
+
// Shortcut
|
|
160
|
+
let hasher = this._hasher
|
|
161
|
+
|
|
162
|
+
// Reset
|
|
163
|
+
hasher.reset()
|
|
164
|
+
hasher.update(this._iKey)
|
|
165
|
+
},
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Updates this HMAC with a message.
|
|
169
|
+
* @param {WordArray|string} messageUpdate The message to append.
|
|
170
|
+
* @return {HMAC} This HMAC instance.
|
|
171
|
+
* @example
|
|
172
|
+
* hmacHasher.update('message');
|
|
173
|
+
* hmacHasher.update(wordArray);
|
|
174
|
+
*/
|
|
175
|
+
update: function (messageUpdate) {
|
|
176
|
+
this._hasher.update(messageUpdate)
|
|
177
|
+
|
|
178
|
+
// Chainable
|
|
179
|
+
return this
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Finalizes the HMAC computation.
|
|
184
|
+
* Note that the finalize operation is effectively a destructive, read-once operation.
|
|
185
|
+
*
|
|
186
|
+
* @param {WordArray|string} messageUpdate (Optional) A final message update.
|
|
187
|
+
* @return {WordArray} The HMAC.
|
|
188
|
+
* @example
|
|
189
|
+
* let hmac = hmacHasher.finalize();
|
|
190
|
+
* let hmac = hmacHasher.finalize('message');
|
|
191
|
+
* let hmac = hmacHasher.finalize(wordArray);
|
|
192
|
+
*/
|
|
193
|
+
finalize: function (messageUpdate) {
|
|
194
|
+
// Shortcut
|
|
195
|
+
let hasher = this._hasher
|
|
196
|
+
|
|
197
|
+
// Compute HMAC
|
|
198
|
+
let innerHash = hasher.finalize(messageUpdate)
|
|
199
|
+
hasher.reset()
|
|
200
|
+
let hmac = hasher.finalize(this._oKey.clone().concat(innerHash))
|
|
201
|
+
|
|
202
|
+
return hmac
|
|
203
|
+
}
|
|
204
|
+
}),
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* SHA-256 hash algorithm.
|
|
208
|
+
*/
|
|
209
|
+
SHA256: Hasher.extend({
|
|
210
|
+
_doReset: function () {
|
|
211
|
+
this._hash = new WordArray.init(H.slice(0))
|
|
212
|
+
},
|
|
213
|
+
|
|
214
|
+
_doProcessBlock: function (M, offset) {
|
|
215
|
+
// Shortcut
|
|
216
|
+
let H = this._hash.words
|
|
217
|
+
|
|
218
|
+
// Working variables
|
|
219
|
+
let a = H[0]
|
|
220
|
+
let b = H[1]
|
|
221
|
+
let c = H[2]
|
|
222
|
+
let d = H[3]
|
|
223
|
+
let e = H[4]
|
|
224
|
+
let f = H[5]
|
|
225
|
+
let g = H[6]
|
|
226
|
+
let h = H[7]
|
|
227
|
+
|
|
228
|
+
// Computation
|
|
229
|
+
for (let i = 0; i < 64; i++) {
|
|
230
|
+
if (i < 16) {
|
|
231
|
+
W[i] = M[offset + i] | 0
|
|
232
|
+
} else {
|
|
233
|
+
let gamma0x = W[i - 15]
|
|
234
|
+
let gamma0 =
|
|
235
|
+
((gamma0x << 25) | (gamma0x >>> 7)) ^
|
|
236
|
+
((gamma0x << 14) | (gamma0x >>> 18)) ^
|
|
237
|
+
(gamma0x >>> 3)
|
|
238
|
+
|
|
239
|
+
let gamma1x = W[i - 2]
|
|
240
|
+
let gamma1 =
|
|
241
|
+
((gamma1x << 15) | (gamma1x >>> 17)) ^
|
|
242
|
+
((gamma1x << 13) | (gamma1x >>> 19)) ^
|
|
243
|
+
(gamma1x >>> 10)
|
|
244
|
+
|
|
245
|
+
W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
let ch = (e & f) ^ (~e & g)
|
|
249
|
+
let maj = (a & b) ^ (a & c) ^ (b & c)
|
|
250
|
+
|
|
251
|
+
let sigma0 =
|
|
252
|
+
((a << 30) | (a >>> 2)) ^
|
|
253
|
+
((a << 19) | (a >>> 13)) ^
|
|
254
|
+
((a << 10) | (a >>> 22))
|
|
255
|
+
let sigma1 =
|
|
256
|
+
((e << 26) | (e >>> 6)) ^
|
|
257
|
+
((e << 21) | (e >>> 11)) ^
|
|
258
|
+
((e << 7) | (e >>> 25))
|
|
259
|
+
|
|
260
|
+
let t1 = h + sigma1 + ch + K[i] + W[i]
|
|
261
|
+
let t2 = sigma0 + maj
|
|
262
|
+
|
|
263
|
+
h = g
|
|
264
|
+
g = f
|
|
265
|
+
f = e
|
|
266
|
+
e = (d + t1) | 0
|
|
267
|
+
d = c
|
|
268
|
+
c = b
|
|
269
|
+
b = a
|
|
270
|
+
a = (t1 + t2) | 0
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// Intermediate hash value
|
|
274
|
+
H[0] = (H[0] + a) | 0
|
|
275
|
+
H[1] = (H[1] + b) | 0
|
|
276
|
+
H[2] = (H[2] + c) | 0
|
|
277
|
+
H[3] = (H[3] + d) | 0
|
|
278
|
+
H[4] = (H[4] + e) | 0
|
|
279
|
+
H[5] = (H[5] + f) | 0
|
|
280
|
+
H[6] = (H[6] + g) | 0
|
|
281
|
+
H[7] = (H[7] + h) | 0
|
|
282
|
+
},
|
|
283
|
+
|
|
284
|
+
_doFinalize: function () {
|
|
285
|
+
// Shortcuts
|
|
286
|
+
let data = this._data
|
|
287
|
+
let dataWords = data.words
|
|
288
|
+
|
|
289
|
+
let nBitsTotal = this._nDataBytes * 8
|
|
290
|
+
let nBitsLeft = data.sigBytes * 8
|
|
291
|
+
|
|
292
|
+
// Add padding
|
|
293
|
+
dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - (nBitsLeft % 32))
|
|
294
|
+
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(
|
|
295
|
+
nBitsTotal / 0x100000000
|
|
296
|
+
)
|
|
297
|
+
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal
|
|
298
|
+
data.sigBytes = dataWords.length * 4
|
|
299
|
+
|
|
300
|
+
// Hash final blocks
|
|
301
|
+
this._process()
|
|
302
|
+
|
|
303
|
+
// Return final computed hash
|
|
304
|
+
return this._hash
|
|
305
|
+
},
|
|
306
|
+
|
|
307
|
+
clone: function () {
|
|
308
|
+
let clone = Hasher.clone.call(this)
|
|
309
|
+
clone._hash = this._hash.clone()
|
|
310
|
+
|
|
311
|
+
return clone
|
|
312
|
+
}
|
|
313
|
+
})
|
|
314
|
+
}
|
|
315
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
//import { WordArray } from './WordArray'
|
|
2
|
-
import { C_algo } from './C_algo'
|
|
3
|
-
/**
|
|
4
|
-
* SHA-1 hash algorithm.
|
|
5
|
-
*/
|
|
6
|
-
export const SHA1 = function () {
|
|
7
|
-
let sha1 = C_algo().SHA1
|
|
8
|
-
return sha1
|
|
9
|
-
}
|
|
1
|
+
//import { WordArray } from './WordArray'
|
|
2
|
+
import { C_algo } from './C_algo'
|
|
3
|
+
/**
|
|
4
|
+
* SHA-1 hash algorithm.
|
|
5
|
+
*/
|
|
6
|
+
export const SHA1 = function () {
|
|
7
|
+
let sha1 = C_algo().SHA1
|
|
8
|
+
return sha1
|
|
9
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
//import { WordArray } from './WordArray'
|
|
2
|
-
import { C_algo } from './C_algo'
|
|
3
|
-
/**
|
|
4
|
-
* SHA-1 hash algorithm.
|
|
5
|
-
*/
|
|
6
|
-
export const SHA1 = function () {
|
|
7
|
-
let sha1 = C_algo().SHA1
|
|
8
|
-
return sha1
|
|
9
|
-
}
|
|
1
|
+
//import { WordArray } from './WordArray'
|
|
2
|
+
import { C_algo } from './C_algo'
|
|
3
|
+
/**
|
|
4
|
+
* SHA-1 hash algorithm.
|
|
5
|
+
*/
|
|
6
|
+
export const SHA1 = function () {
|
|
7
|
+
let sha1 = C_algo().SHA1
|
|
8
|
+
return sha1
|
|
9
|
+
}
|