fcad-core-dragon 2.0.0-beta.1 → 2.0.0-beta.3
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 +33 -33
- package/.eslintignore +29 -29
- package/{.eslintrc.js → .eslintrc.cjs} +81 -86
- package/CHANGELOG +364 -364
- package/README.md +71 -71
- package/bk.scss +117 -0
- package/package.json +61 -63
- package/src/$locales/en.json +143 -179
- package/src/$locales/fr.json +105 -181
- package/src/assets/data/onboardingMessages.json +47 -47
- package/src/components/AppBase.vue +1054 -614
- package/src/components/AppBaseButton.vue +87 -63
- package/src/components/AppBaseErrorDisplay.vue +438 -420
- package/src/components/AppBaseFlipCard.vue +84 -83
- package/src/components/AppBaseModule.vue +1673 -1842
- package/src/components/AppBasePage.vue +779 -312
- package/src/components/AppBasePopover.vue +41 -0
- package/src/components/AppCompAudio.vue +234 -0
- package/src/components/AppCompBranchButtons.vue +552 -582
- package/src/components/AppCompButtonProgress.vue +126 -147
- package/src/components/AppCompCarousel.vue +298 -192
- package/src/components/AppCompInputCheckBoxNext.vue +195 -0
- package/src/components/AppCompInputDropdownNext.vue +159 -0
- package/src/components/AppCompInputRadioNext.vue +152 -0
- package/src/components/{AppCompInputTextBox.vue → AppCompInputTextNext.vue} +106 -91
- package/src/components/AppCompInputTextTableNext.vue +141 -0
- package/src/components/AppCompInputTextToFillDropdownNext.vue +230 -0
- package/src/components/{AppCompInputTextToFillText.vue → AppCompInputTextToFillNext.vue} +171 -164
- package/src/components/AppCompJauge.vue +74 -55
- package/src/components/AppCompMenu.vue +413 -209
- package/src/components/AppCompMenuItem.vue +228 -174
- package/src/components/AppCompNavigation.vue +960 -949
- package/src/components/AppCompNoteCall.vue +133 -126
- package/src/components/AppCompNoteCredit.vue +292 -164
- package/src/components/AppCompPlayBar.vue +1218 -1319
- package/src/components/AppCompPlayBarNext.vue +2052 -0
- package/src/components/AppCompPlayBarProgress.vue +82 -0
- package/src/components/AppCompPopUpNext.vue +503 -0
- package/src/components/{AppCompQuiz.vue → AppCompQuizNext.vue} +2904 -2989
- package/src/components/AppCompQuizRecall.vue +276 -250
- package/src/components/AppCompSVGNext.vue +347 -0
- package/src/components/AppCompSettingsMenu.vue +172 -171
- package/src/components/AppCompTableOfContent.vue +387 -264
- package/src/components/AppCompTranscript.vue +24 -19
- package/src/components/AppCompVideoPlayer.vue +368 -336
- package/src/components/AppCompViewDisplay.vue +6 -6
- package/src/components/BaseModule.vue +72 -67
- package/src/composables/useQuiz.js +206 -0
- package/src/externalComps/ModuleView.vue +22 -0
- package/src/externalComps/SummaryView.vue +91 -0
- package/src/main.js +272 -227
- package/src/mixins/$mediaMixins.js +819 -0
- package/src/mixins/timerMixin.js +155 -156
- package/src/module/stores/appStore.js +893 -0
- package/src/module/xapi/ADL.js +376 -339
- 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 -319
- 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/launch.js +157 -157
- package/src/module/xapi/utils.js +167 -167
- package/src/module/xapi/verbs.js +294 -294
- package/src/module/xapi/wrapper.js +1963 -1890
- package/src/module/xapi/xapiStatement.js +444 -444
- package/src/plugins/bus.js +8 -3
- package/src/plugins/gsap.js +14 -17
- package/src/plugins/helper.js +308 -295
- package/src/plugins/i18n.js +44 -31
- package/src/plugins/idb.js +219 -212
- 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 -21
- package/src/router/index.js +43 -41
- package/src/router/routes.js +312 -337
- package/src/shared/generalfuncs.js +210 -188
- package/src/shared/validators.js +1069 -249
- package/vite.config.js +27 -0
- package/.prettierrc.js +0 -5
- package/babel.config.js +0 -3
- package/src/components/AppBaseDragChoice.vue +0 -91
- package/src/components/AppBaseDropZone.vue +0 -112
- package/src/components/AppCompBif.vue +0 -120
- package/src/components/AppCompDragAndDrop.vue +0 -339
- package/src/components/AppCompInputAssociation.vue +0 -332
- package/src/components/AppCompInputCheckBox.vue +0 -227
- package/src/components/AppCompInputDropdown.vue +0 -184
- package/src/components/AppCompInputRadio.vue +0 -169
- package/src/components/AppCompInputTextTable.vue +0 -155
- package/src/components/AppCompInputTextToFillDropdown.vue +0 -255
- package/src/components/AppCompMediaPlayer.vue +0 -397
- package/src/components/AppCompPopUp.vue +0 -522
- package/src/components/AppCompPopover.vue +0 -27
- package/src/components/AppCompSVG.vue +0 -309
- package/src/mixins/$pageMixins.js +0 -459
- package/src/mixins/$quizMixins.js +0 -456
- package/src/module/store.js +0 -895
- package/src/plugins/timeManager.js +0 -77
- package/src/routes_bckp.js +0 -313
- package/src/routes_static.js +0 -344
- package/vue.config.js +0 -83
|
@@ -1,319 +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,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
let
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
let
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
let
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (i <
|
|
51
|
-
t += ((b & c) | (
|
|
52
|
-
}
|
|
53
|
-
t += (b ^ c ^ d)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
H[
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
let
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
dataWords[nBitsLeft
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
//
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
key.
|
|
137
|
-
|
|
138
|
-
//
|
|
139
|
-
let
|
|
140
|
-
let
|
|
141
|
-
|
|
142
|
-
//
|
|
143
|
-
let
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
let
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
let
|
|
224
|
-
let
|
|
225
|
-
let
|
|
226
|
-
let
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
let
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
(
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
let
|
|
256
|
-
((
|
|
257
|
-
((
|
|
258
|
-
((
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
H[
|
|
279
|
-
H[
|
|
280
|
-
H[
|
|
281
|
-
H[
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
let
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
dataWords[nBitsLeft
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
}
|
|
317
|
-
})
|
|
318
|
-
}
|
|
319
|
-
}
|
|
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
|
+
}
|