sha.min.js 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252
  1. !(function (n, e) {
  2. 'object' == typeof exports && 'undefined' != typeof module
  3. ? (module.exports = e())
  4. : 'function' == typeof define && define.amd
  5. ? define(e)
  6. : ((n = 'undefined' != typeof globalThis ? globalThis : n || self).jsSHA = e())
  7. })(this, function () {
  8. 'use strict'
  9. var A = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
  10. e = 'ARRAYBUFFER not supported by this environment',
  11. t = 'UINT8ARRAY not supported by this environment'
  12. function i(n, e, t, r) {
  13. for (
  14. var i, o, u = e || [0], s = (t = t || 0) >>> 3, h = -1 === r ? 3 : 0, a = 0;
  15. a < n.length;
  16. a += 1
  17. )
  18. (i = (o = a + s) >>> 2), u.length <= i && u.push(0), (u[i] |= n[a] << (8 * (h + r * (o % 4))))
  19. return { value: u, binLen: 8 * n.length + t }
  20. }
  21. function o(n, M, I) {
  22. switch (M) {
  23. case 'UTF8':
  24. case 'UTF16BE':
  25. case 'UTF16LE':
  26. break
  27. default:
  28. throw new Error('encoding must be UTF8, UTF16BE, or UTF16LE')
  29. }
  30. switch (n) {
  31. case 'HEX':
  32. return function (n, e, t) {
  33. var r,
  34. i,
  35. o,
  36. u = n,
  37. n = e,
  38. e = t,
  39. s = I
  40. if (0 != u.length % 2) throw new Error('String of HEX type must be in byte increments')
  41. for (
  42. var h = n || [0], a = (e = e || 0) >>> 3, w = -1 === s ? 3 : 0, f = 0;
  43. f < u.length;
  44. f += 2
  45. ) {
  46. if (((r = parseInt(u.substr(f, 2), 16)), isNaN(r)))
  47. throw new Error('String of HEX type contains invalid characters')
  48. for (i = (o = (f >>> 1) + a) >>> 2; h.length <= i; ) h.push(0)
  49. h[i] |= r << (8 * (w + s * (o % 4)))
  50. }
  51. return { value: h, binLen: 4 * u.length + e }
  52. }
  53. case 'TEXT':
  54. return function (n, e, t) {
  55. var r,
  56. i,
  57. o,
  58. u,
  59. s,
  60. h,
  61. a,
  62. w,
  63. f = n,
  64. n = M,
  65. c = 0,
  66. l = I,
  67. p = 0,
  68. v = e || [0],
  69. A = (c = t || 0) >>> 3
  70. if ('UTF8' === n)
  71. for (a = -1 === l ? 3 : 0, o = 0; o < f.length; o += 1)
  72. for (
  73. i = [],
  74. (r = f.charCodeAt(o)) < 128
  75. ? i.push(r)
  76. : r < 2048
  77. ? (i.push(192 | (r >>> 6)), i.push(128 | (63 & r)))
  78. : r < 55296 || 57344 <= r
  79. ? i.push(224 | (r >>> 12), 128 | ((r >>> 6) & 63), 128 | (63 & r))
  80. : ((r = 65536 + (((1023 & r) << 10) | (1023 & f.charCodeAt((o += 1))))),
  81. i.push(
  82. 240 | (r >>> 18),
  83. 128 | ((r >>> 12) & 63),
  84. 128 | ((r >>> 6) & 63),
  85. 128 | (63 & r),
  86. )),
  87. u = 0;
  88. u < i.length;
  89. u += 1
  90. ) {
  91. for (s = (h = p + A) >>> 2; v.length <= s; ) v.push(0)
  92. ;(v[s] |= i[u] << (8 * (a + l * (h % 4)))), (p += 1)
  93. }
  94. else
  95. for (
  96. a = -1 === l ? 2 : 0,
  97. w = ('UTF16LE' === n && 1 !== l) || ('UTF16LE' !== n && 1 === l),
  98. o = 0;
  99. o < f.length;
  100. o += 1
  101. ) {
  102. for (
  103. r = f.charCodeAt(o),
  104. !0 == w && (r = ((u = 255 & r) << 8) | (r >>> 8)),
  105. s = (h = p + A) >>> 2;
  106. v.length <= s;
  107. )
  108. v.push(0)
  109. ;(v[s] |= r << (8 * (a + l * (h % 4)))), (p += 2)
  110. }
  111. return { value: v, binLen: 8 * p + c }
  112. }
  113. case 'B64':
  114. return function (n, e, t) {
  115. var r,
  116. i,
  117. o,
  118. u,
  119. s,
  120. h,
  121. a = n,
  122. n = 0,
  123. w = I,
  124. f = 0,
  125. c = e || [0],
  126. l = (n = t || 0) >>> 3,
  127. p = -1 === w ? 3 : 0,
  128. e = a.indexOf('=')
  129. if (-1 === a.search(/^[a-zA-Z0-9=+/]+$/))
  130. throw new Error('Invalid character in base-64 string')
  131. if (((a = a.replace(/=/g, '')), -1 !== e && e < a.length))
  132. throw new Error("Invalid '=' found in base-64 string")
  133. for (r = 0; r < a.length; r += 4) {
  134. for (u = a.substr(r, 4), i = o = 0; i < u.length; i += 1)
  135. o |= A.indexOf(u.charAt(i)) << (18 - 6 * i)
  136. for (i = 0; i < u.length - 1; i += 1) {
  137. for (s = (h = f + l) >>> 2; c.length <= s; ) c.push(0)
  138. ;(c[s] |= ((o >>> (16 - 8 * i)) & 255) << (8 * (p + w * (h % 4)))), (f += 1)
  139. }
  140. }
  141. return { value: c, binLen: 8 * f + n }
  142. }
  143. case 'BYTES':
  144. return function (n, e, t) {
  145. for (
  146. var r,
  147. i,
  148. o,
  149. u = n,
  150. n = 0,
  151. s = I,
  152. h = e || [0],
  153. a = (n = t || 0) >>> 3,
  154. w = -1 === s ? 3 : 0,
  155. f = 0;
  156. f < u.length;
  157. f += 1
  158. )
  159. (r = u.charCodeAt(f)),
  160. (i = (o = f + a) >>> 2),
  161. h.length <= i && h.push(0),
  162. (h[i] |= r << (8 * (w + s * (o % 4))))
  163. return { value: h, binLen: 8 * u.length + n }
  164. }
  165. case 'ARRAYBUFFER':
  166. try {
  167. new ArrayBuffer(0)
  168. } catch (n) {
  169. throw new Error(e)
  170. }
  171. return function (n, e, t) {
  172. return (e = e), (t = t), (r = I), i(new Uint8Array(n), e, t, r)
  173. }
  174. case 'UINT8ARRAY':
  175. try {
  176. new Uint8Array(0)
  177. } catch (n) {
  178. throw new Error(t)
  179. }
  180. return function (n, e, t) {
  181. return i(n, e, t, I)
  182. }
  183. default:
  184. throw new Error('format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY')
  185. }
  186. }
  187. function u(n, l, p, v) {
  188. switch (n) {
  189. case 'HEX':
  190. return function (n) {
  191. for (
  192. var e,
  193. t = n,
  194. r = p,
  195. n = v,
  196. i = '0123456789abcdef',
  197. o = '',
  198. u = l / 8,
  199. s = -1 === r ? 3 : 0,
  200. h = 0;
  201. h < u;
  202. h += 1
  203. )
  204. (e = t[h >>> 2] >>> (8 * (s + r * (h % 4)))),
  205. (o += i.charAt((e >>> 4) & 15) + i.charAt(15 & e))
  206. return n.outputUpper ? o.toUpperCase() : o
  207. }
  208. case 'B64':
  209. return function (n) {
  210. for (
  211. var e,
  212. t,
  213. r,
  214. i,
  215. o = n,
  216. u = l,
  217. s = p,
  218. h = v,
  219. a = '',
  220. w = u / 8,
  221. f = -1 === s ? 3 : 0,
  222. c = 0;
  223. c < w;
  224. c += 3
  225. )
  226. for (
  227. r = c + 1 < w ? o[(c + 1) >>> 2] : 0,
  228. i = c + 2 < w ? o[(c + 2) >>> 2] : 0,
  229. t =
  230. (((o[c >>> 2] >>> (8 * (f + s * (c % 4)))) & 255) << 16) |
  231. (((r >>> (8 * (f + s * ((c + 1) % 4)))) & 255) << 8) |
  232. ((i >>> (8 * (f + s * ((c + 2) % 4)))) & 255),
  233. e = 0;
  234. e < 4;
  235. e += 1
  236. )
  237. a += 8 * c + 6 * e <= u ? A.charAt((t >>> (6 * (3 - e))) & 63) : h.b64Pad
  238. return a
  239. }
  240. case 'BYTES':
  241. return function (n) {
  242. for (var e, t = n, r = p, i = '', o = l / 8, u = -1 === r ? 3 : 0, s = 0; s < o; s += 1)
  243. (e = (t[s >>> 2] >>> (8 * (u + r * (s % 4)))) & 255), (i += String.fromCharCode(e))
  244. return i
  245. }
  246. case 'ARRAYBUFFER':
  247. try {
  248. new ArrayBuffer(0)
  249. } catch (n) {
  250. throw new Error(e)
  251. }
  252. return function (n) {
  253. for (
  254. var e = n,
  255. t = p,
  256. r = l / 8,
  257. n = new ArrayBuffer(r),
  258. i = new Uint8Array(n),
  259. o = -1 === t ? 3 : 0,
  260. u = 0;
  261. u < r;
  262. u += 1
  263. )
  264. i[u] = (e[u >>> 2] >>> (8 * (o + t * (u % 4)))) & 255
  265. return n
  266. }
  267. case 'UINT8ARRAY':
  268. try {
  269. new Uint8Array(0)
  270. } catch (n) {
  271. throw new Error(t)
  272. }
  273. return function (n) {
  274. for (
  275. var e = n, t = p, r = l / 8, i = -1 === t ? 3 : 0, o = new Uint8Array(r), u = 0;
  276. u < r;
  277. u += 1
  278. )
  279. o[u] = (e[u >>> 2] >>> (8 * (i + t * (u % 4)))) & 255
  280. return o
  281. }
  282. default:
  283. throw new Error('format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY')
  284. }
  285. }
  286. var a = 4294967296,
  287. M = [
  288. 1116352408, 1899447441, 3049323471, 3921009573, 961987163, 1508970993, 2453635748, 2870763221,
  289. 3624381080, 310598401, 607225278, 1426881987, 1925078388, 2162078206, 2614888103, 3248222580,
  290. 3835390401, 4022224774, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986,
  291. 2554220882, 2821834349, 2952996808, 3210313671, 3336571891, 3584528711, 113926993, 338241895,
  292. 666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, 2177026350, 2456956037,
  293. 2730485921, 2820302411, 3259730800, 3345764771, 3516065817, 3600352804, 4094571909, 275423344,
  294. 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779,
  295. 1955562222, 2024104815, 2227730452, 2361852424, 2428436474, 2756734187, 3204031479,
  296. 3329325298,
  297. ],
  298. r = [
  299. 3238371032, 914150663, 812702999, 4144912697, 4290775857, 1750603025, 1694076839, 3204075428,
  300. ],
  301. s = [
  302. 1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225,
  303. ],
  304. w = 'Chosen SHA variant is not supported',
  305. h = 'Cannot set numRounds with MAC'
  306. function f(n, e) {
  307. var t,
  308. r,
  309. i = n.binLen >>> 3,
  310. o = e.binLen >>> 3,
  311. u = i << 3,
  312. s = (4 - i) << 3
  313. if (i % 4 == 0) return { value: n.value.concat(e.value), binLen: n.binLen + e.binLen }
  314. for (t = 0; t < o; t += 4)
  315. (n.value[(r = (i + t) >>> 2)] |= e.value[t >>> 2] << u),
  316. n.value.push(0),
  317. (n.value[1 + r] |= e.value[t >>> 2] >>> s)
  318. return (
  319. (n.value.length << 2) - 4 >= o + i && n.value.pop(),
  320. { value: n.value, binLen: n.binLen + e.binLen }
  321. )
  322. }
  323. function c(n) {
  324. var e = { outputUpper: !1, b64Pad: '=', outputLen: -1 },
  325. n = n || {},
  326. t = 'Output length must be a multiple of 8'
  327. if (((e.outputUpper = n.outputUpper || !1), n.b64Pad && (e.b64Pad = n.b64Pad), n.outputLen)) {
  328. if (n.outputLen % 8 != 0) throw new Error(t)
  329. e.outputLen = n.outputLen
  330. } else if (n.shakeLen) {
  331. if (n.shakeLen % 8 != 0) throw new Error(t)
  332. e.outputLen = n.shakeLen
  333. }
  334. if ('boolean' != typeof e.outputUpper) throw new Error('Invalid outputUpper formatting option')
  335. if ('string' != typeof e.b64Pad) throw new Error('Invalid b64Pad formatting option')
  336. return e
  337. }
  338. function l(n, e, t, r) {
  339. n += ' must include a value and format'
  340. if (!e) {
  341. if (r) return r
  342. throw new Error(n)
  343. }
  344. if (void 0 !== e.value && e.format) return o(e.format, e.encoding || 'UTF8', t)(e.value)
  345. throw new Error(n)
  346. }
  347. ;(v.prototype.update = function (n) {
  348. for (
  349. var e = 0,
  350. t = this.p >>> 5,
  351. n = this.m(n, this.u, this.h),
  352. r = n.binLen,
  353. i = n.value,
  354. o = r >>> 5,
  355. u = 0;
  356. u < o;
  357. u += t
  358. )
  359. e + this.p <= r && ((this.U = this.R(i.slice(u, u + t), this.U)), (e += this.p))
  360. return (this.A += e), (this.u = i.slice(e >>> 5)), (this.h = r % this.p), (this.v = !0), this
  361. }),
  362. (v.prototype.getHash = function (n, e) {
  363. var t,
  364. r,
  365. i = this.T,
  366. e = c(e)
  367. if (this.C) {
  368. if (-1 === e.outputLen) throw new Error('Output length must be specified in options')
  369. i = e.outputLen
  370. }
  371. n = u(n, i, this.F, e)
  372. if (this.l && this.K) return n(this.K(e))
  373. for (
  374. r = this.g(this.u.slice(), this.h, this.A, this.L(this.U), i), t = 1;
  375. t < this.numRounds;
  376. t += 1
  377. )
  378. this.C && i % 32 != 0 && (r[r.length - 1] &= 16777215 >>> (24 - (i % 32))),
  379. (r = this.g(r, i, 0, this.B(this.o), i))
  380. return n(r)
  381. }),
  382. (v.prototype.setHMACKey = function (n, e, t) {
  383. if (!this.k) throw new Error('Variant does not support HMAC')
  384. if (this.v) throw new Error('Cannot set MAC key after calling update')
  385. e = o(e, (t || {}).encoding || 'UTF8', this.F)
  386. this.Y(e(n))
  387. }),
  388. (v.prototype.Y = function (n) {
  389. var e,
  390. t = this.p >>> 3,
  391. r = t / 4 - 1
  392. if (1 !== this.numRounds) throw new Error(h)
  393. if (this.l) throw new Error('MAC key already set')
  394. for (
  395. t < n.binLen / 8 && (n.value = this.g(n.value, n.binLen, 0, this.B(this.o), this.T));
  396. n.value.length <= r;
  397. )
  398. n.value.push(0)
  399. for (e = 0; e <= r; e += 1)
  400. (this.S[e] = 909522486 ^ n.value[e]), (this.H[e] = 1549556828 ^ n.value[e])
  401. ;(this.U = this.R(this.S, this.U)), (this.A = this.p), (this.l = !0)
  402. }),
  403. (v.prototype.getHMAC = function (n, e) {
  404. e = c(e)
  405. return u(n, this.T, this.F, e)(this.N())
  406. }),
  407. (v.prototype.N = function () {
  408. if (!this.l) throw new Error('Cannot call getHMAC without first setting MAC key')
  409. var n = this.g(this.u.slice(), this.h, this.A, this.L(this.U), this.T),
  410. e = this.R(this.H, this.B(this.o))
  411. return this.g(n, this.T, this.p, e, this.T)
  412. })
  413. var n = v,
  414. p = function (n, e) {
  415. return (p =
  416. Object.setPrototypeOf ||
  417. ({ __proto__: [] } instanceof Array &&
  418. function (n, e) {
  419. n.__proto__ = e
  420. }) ||
  421. function (n, e) {
  422. for (var t in e) Object.prototype.hasOwnProperty.call(e, t) && (n[t] = e[t])
  423. })(n, e)
  424. }
  425. function v(n, e, t) {
  426. t = t || {}
  427. if (
  428. ((this.t = e),
  429. (this.i = t.encoding || 'UTF8'),
  430. (this.numRounds = t.numRounds || 1),
  431. isNaN(this.numRounds) ||
  432. this.numRounds !== parseInt(this.numRounds, 10) ||
  433. this.numRounds < 1)
  434. )
  435. throw new Error('numRounds must a integer >= 1')
  436. ;(this.o = n),
  437. (this.u = []),
  438. (this.h = 0),
  439. (this.v = !1),
  440. (this.A = 0),
  441. (this.l = !1),
  442. (this.S = []),
  443. (this.H = [])
  444. }
  445. function I(n, e) {
  446. if ('function' != typeof e && null !== e)
  447. throw new TypeError('Class extends value ' + String(e) + ' is not a constructor or null')
  448. function t() {
  449. this.constructor = n
  450. }
  451. p(n, e), (n.prototype = null === e ? Object.create(e) : ((t.prototype = e.prototype), new t()))
  452. }
  453. function g(n, e) {
  454. return (n << e) | (n >>> (32 - e))
  455. }
  456. function m(n, e) {
  457. return (n >>> e) | (n << (32 - e))
  458. }
  459. function d(n, e, t) {
  460. return (n & e) ^ (~n & t)
  461. }
  462. function y(n, e, t) {
  463. return (n & e) ^ (n & t) ^ (e & t)
  464. }
  465. function b(n, e) {
  466. var t = (65535 & n) + (65535 & e)
  467. return ((65535 & ((n >>> 16) + (e >>> 16) + (t >>> 16))) << 16) | (65535 & t)
  468. }
  469. function E(n, e, t, r, i) {
  470. var o = (65535 & n) + (65535 & e) + (65535 & t) + (65535 & r) + (65535 & i)
  471. return (
  472. ((65535 & ((n >>> 16) + (e >>> 16) + (t >>> 16) + (r >>> 16) + (i >>> 16) + (o >>> 16))) <<
  473. 16) |
  474. (65535 & o)
  475. )
  476. }
  477. function B(n) {
  478. return [1732584193, 4023233417, 2562383102, 271733878, 3285377520]
  479. }
  480. function H(n, e) {
  481. for (var t, r = [], i = e[0], o = e[1], u = e[2], s = e[3], h = e[4], a = 0; a < 80; a += 1)
  482. (r[a] = a < 16 ? n[a] : g(r[a - 3] ^ r[a - 8] ^ r[a - 14] ^ r[a - 16], 1)),
  483. (t =
  484. a < 20
  485. ? E(g(i, 5), d(o, u, s), h, 1518500249, r[a])
  486. : a < 40
  487. ? E(g(i, 5), o ^ u ^ s, h, 1859775393, r[a])
  488. : a < 60
  489. ? E(g(i, 5), y(o, u, s), h, 2400959708, r[a])
  490. : E(g(i, 5), o ^ u ^ s, h, 3395469782, r[a])),
  491. (h = s),
  492. (s = u),
  493. (u = g(o, 30)),
  494. (o = i),
  495. (i = t)
  496. return (
  497. (e[0] = b(i, e[0])),
  498. (e[1] = b(o, e[1])),
  499. (e[2] = b(u, e[2])),
  500. (e[3] = b(s, e[3])),
  501. (e[4] = b(h, e[4])),
  502. e
  503. )
  504. }
  505. function Y(n, e, t, r) {
  506. for (var i, o = 15 + (((e + 65) >>> 9) << 4), t = e + t; n.length <= o; ) n.push(0)
  507. for (
  508. n[e >>> 5] |= 128 << (24 - (e % 32)), n[o] = 4294967295 & t, n[o - 1] = (t / a) | 0, i = 0;
  509. i < n.length;
  510. i += 16
  511. )
  512. r = H(n.slice(i, i + 16), r)
  513. return r
  514. }
  515. I(O, (K = n))
  516. var K,
  517. _ = O
  518. function O(n, e, t) {
  519. var r = this
  520. if ('SHA-1' !== n) throw new Error(w)
  521. var i = t || {}
  522. return (
  523. ((r = K.call(this, n, e, t) || this).k = !0),
  524. (r.K = r.N),
  525. (r.F = -1),
  526. (r.m = o(r.t, r.i, r.F)),
  527. (r.R = H),
  528. (r.L = function (n) {
  529. return n.slice()
  530. }),
  531. (r.B = B),
  532. (r.g = Y),
  533. (r.U = [1732584193, 4023233417, 2562383102, 271733878, 3285377520]),
  534. (r.p = 512),
  535. (r.T = 160),
  536. (r.C = !1),
  537. i.hmacKey && r.Y(l('hmacKey', i.hmacKey, r.F)),
  538. r
  539. )
  540. }
  541. function X(n) {
  542. return ('SHA-224' == n ? r : s).slice()
  543. }
  544. function j(n, e) {
  545. for (
  546. var t,
  547. r,
  548. i,
  549. o,
  550. u,
  551. s = [],
  552. h = e[0],
  553. a = e[1],
  554. w = e[2],
  555. f = e[3],
  556. c = e[4],
  557. l = e[5],
  558. p = e[6],
  559. v = e[7],
  560. A = 0;
  561. A < 64;
  562. A += 1
  563. )
  564. (s[A] =
  565. A < 16
  566. ? n[A]
  567. : ((t = m((t = s[A - 2]), 17) ^ m(t, 19) ^ (t >>> 10)),
  568. (r = s[A - 7]),
  569. (u = s[A - 15]),
  570. (u = m(u, 7) ^ m(u, 18) ^ (u >>> 3)),
  571. (i = s[A - 16]),
  572. (o = void 0),
  573. ((65535 &
  574. ((t >>> 16) +
  575. (r >>> 16) +
  576. (u >>> 16) +
  577. (i >>> 16) +
  578. ((o = (65535 & t) + (65535 & r) + (65535 & u) + (65535 & i)) >>> 16))) <<
  579. 16) |
  580. (65535 & o))),
  581. (t = E(v, m(c, 6) ^ m(c, 11) ^ m(c, 25), d(c, l, p), M[A], s[A])),
  582. (r = b(m(h, 2) ^ m(h, 13) ^ m(h, 22), y(h, a, w))),
  583. (v = p),
  584. (p = l),
  585. (l = c),
  586. (c = b(f, t)),
  587. (f = w),
  588. (w = a),
  589. (a = h),
  590. (h = b(t, r))
  591. return (
  592. (e[0] = b(h, e[0])),
  593. (e[1] = b(a, e[1])),
  594. (e[2] = b(w, e[2])),
  595. (e[3] = b(f, e[3])),
  596. (e[4] = b(c, e[4])),
  597. (e[5] = b(l, e[5])),
  598. (e[6] = b(p, e[6])),
  599. (e[7] = b(v, e[7])),
  600. e
  601. )
  602. }
  603. I(x, (z = n))
  604. var z,
  605. P = x,
  606. L = function (n, e) {
  607. ;(this.I = n), (this.M = e)
  608. }
  609. function x(h, n, e) {
  610. var t = this
  611. if ('SHA-224' !== h && 'SHA-256' !== h) throw new Error(w)
  612. var r = e || {}
  613. return (
  614. ((t = z.call(this, h, n, e) || this).K = t.N),
  615. (t.k = !0),
  616. (t.F = -1),
  617. (t.m = o(t.t, t.i, t.F)),
  618. (t.R = j),
  619. (t.L = function (n) {
  620. return n.slice()
  621. }),
  622. (t.B = X),
  623. (t.g = function (n, e, t, r) {
  624. for (
  625. var i, o = n, n = e, u = r, e = h, s = 15 + (((n + 65) >>> 9) << 4), r = n + t;
  626. o.length <= s;
  627. )
  628. o.push(0)
  629. for (
  630. o[n >>> 5] |= 128 << (24 - (n % 32)),
  631. o[s] = 4294967295 & r,
  632. o[s - 1] = (r / a) | 0,
  633. i = 0;
  634. i < o.length;
  635. i += 16
  636. )
  637. u = j(o.slice(i, i + 16), u)
  638. return 'SHA-224' === e ? [u[0], u[1], u[2], u[3], u[4], u[5], u[6]] : u
  639. }),
  640. (t.U = X(h)),
  641. (t.p = 512),
  642. (t.T = 'SHA-224' === h ? 224 : 256),
  643. (t.C = !1),
  644. r.hmacKey && t.Y(l('hmacKey', r.hmacKey, t.F)),
  645. t
  646. )
  647. }
  648. function V(n, e) {
  649. var t
  650. return 32 < e
  651. ? new L((n.M << e) | (n.I >>> (t = 64 - e)), (n.I << e) | (n.M >>> t))
  652. : 0 !== e
  653. ? new L((n.I << e) | (n.M >>> (t = 32 - e)), (n.M << e) | (n.I >>> t))
  654. : n
  655. }
  656. function C(n, e) {
  657. var t
  658. return e < 32
  659. ? new L((n.I >>> e) | (n.M << (t = 32 - e)), (n.M >>> e) | (n.I << t))
  660. : new L((n.M >>> e) | (n.I << (t = 64 - e)), (n.I >>> e) | (n.M << t))
  661. }
  662. function Z(n, e) {
  663. return new L(n.I >>> e, (n.M >>> e) | (n.I << (32 - e)))
  664. }
  665. function U(n, e) {
  666. var t,
  667. r = (65535 & n.M) + (65535 & e.M),
  668. i = ((65535 & (t = (n.M >>> 16) + (e.M >>> 16) + (r >>> 16))) << 16) | (65535 & r)
  669. return (
  670. (r = (65535 & n.I) + (65535 & e.I) + (t >>> 16)),
  671. (t = (n.I >>> 16) + (e.I >>> 16) + (r >>> 16)),
  672. new L(((65535 & t) << 16) | (65535 & r), i)
  673. )
  674. }
  675. function S(n, e) {
  676. return new L(n.I ^ e.I, n.M ^ e.M)
  677. }
  678. var q = [
  679. new L(M[0], 3609767458),
  680. new L(M[1], 602891725),
  681. new L(M[2], 3964484399),
  682. new L(M[3], 2173295548),
  683. new L(M[4], 4081628472),
  684. new L(M[5], 3053834265),
  685. new L(M[6], 2937671579),
  686. new L(M[7], 3664609560),
  687. new L(M[8], 2734883394),
  688. new L(M[9], 1164996542),
  689. new L(M[10], 1323610764),
  690. new L(M[11], 3590304994),
  691. new L(M[12], 4068182383),
  692. new L(M[13], 991336113),
  693. new L(M[14], 633803317),
  694. new L(M[15], 3479774868),
  695. new L(M[16], 2666613458),
  696. new L(M[17], 944711139),
  697. new L(M[18], 2341262773),
  698. new L(M[19], 2007800933),
  699. new L(M[20], 1495990901),
  700. new L(M[21], 1856431235),
  701. new L(M[22], 3175218132),
  702. new L(M[23], 2198950837),
  703. new L(M[24], 3999719339),
  704. new L(M[25], 766784016),
  705. new L(M[26], 2566594879),
  706. new L(M[27], 3203337956),
  707. new L(M[28], 1034457026),
  708. new L(M[29], 2466948901),
  709. new L(M[30], 3758326383),
  710. new L(M[31], 168717936),
  711. new L(M[32], 1188179964),
  712. new L(M[33], 1546045734),
  713. new L(M[34], 1522805485),
  714. new L(M[35], 2643833823),
  715. new L(M[36], 2343527390),
  716. new L(M[37], 1014477480),
  717. new L(M[38], 1206759142),
  718. new L(M[39], 344077627),
  719. new L(M[40], 1290863460),
  720. new L(M[41], 3158454273),
  721. new L(M[42], 3505952657),
  722. new L(M[43], 106217008),
  723. new L(M[44], 3606008344),
  724. new L(M[45], 1432725776),
  725. new L(M[46], 1467031594),
  726. new L(M[47], 851169720),
  727. new L(M[48], 3100823752),
  728. new L(M[49], 1363258195),
  729. new L(M[50], 3750685593),
  730. new L(M[51], 3785050280),
  731. new L(M[52], 3318307427),
  732. new L(M[53], 3812723403),
  733. new L(M[54], 2003034995),
  734. new L(M[55], 3602036899),
  735. new L(M[56], 1575990012),
  736. new L(M[57], 1125592928),
  737. new L(M[58], 2716904306),
  738. new L(M[59], 442776044),
  739. new L(M[60], 593698344),
  740. new L(M[61], 3733110249),
  741. new L(M[62], 2999351573),
  742. new L(M[63], 3815920427),
  743. new L(3391569614, 3928383900),
  744. new L(3515267271, 566280711),
  745. new L(3940187606, 3454069534),
  746. new L(4118630271, 4000239992),
  747. new L(116418474, 1914138554),
  748. new L(174292421, 2731055270),
  749. new L(289380356, 3203993006),
  750. new L(460393269, 320620315),
  751. new L(685471733, 587496836),
  752. new L(852142971, 1086792851),
  753. new L(1017036298, 365543100),
  754. new L(1126000580, 2618297676),
  755. new L(1288033470, 3409855158),
  756. new L(1501505948, 4234509866),
  757. new L(1607167915, 987167468),
  758. new L(1816402316, 1246189591),
  759. ]
  760. function D(n) {
  761. return 'SHA-384' === n
  762. ? [
  763. new L(3418070365, r[0]),
  764. new L(1654270250, r[1]),
  765. new L(2438529370, r[2]),
  766. new L(355462360, r[3]),
  767. new L(1731405415, r[4]),
  768. new L(41048885895, r[5]),
  769. new L(3675008525, r[6]),
  770. new L(1203062813, r[7]),
  771. ]
  772. : [
  773. new L(s[0], 4089235720),
  774. new L(s[1], 2227873595),
  775. new L(s[2], 4271175723),
  776. new L(s[3], 1595750129),
  777. new L(s[4], 2917565137),
  778. new L(s[5], 725511199),
  779. new L(s[6], 4215389547),
  780. new L(s[7], 327033209),
  781. ]
  782. }
  783. function G(n, e) {
  784. for (
  785. var t,
  786. r,
  787. i,
  788. o,
  789. u,
  790. s,
  791. h,
  792. a,
  793. w,
  794. f,
  795. c,
  796. l,
  797. p,
  798. v,
  799. A = [],
  800. M = e[0],
  801. I = e[1],
  802. g = e[2],
  803. m = e[3],
  804. d = e[4],
  805. y = e[5],
  806. b = e[6],
  807. E = e[7],
  808. H = 0;
  809. H < 80;
  810. H += 1
  811. )
  812. H < 16
  813. ? (A[H] = new L(n[(t = 2 * H)], n[1 + t]))
  814. : (A[H] =
  815. (0,
  816. (a = C((t = A[H - 2]), 19)),
  817. (w = C(t, 61)),
  818. (l = Z(t, 6)),
  819. (a = new L(a.I ^ w.I ^ l.I, a.M ^ w.M ^ l.M)),
  820. (w = A[H - 7]),
  821. (l = A[H - 15]),
  822. (v = p = void 0),
  823. (p = C(l, 1)),
  824. (v = C(l, 8)),
  825. (l = Z(l, 7)),
  826. (p = new L(p.I ^ v.I ^ l.I, p.M ^ v.M ^ l.M)),
  827. (v = A[H - 16]),
  828. (c = f = l = void 0),
  829. (f = (65535 & a.M) + (65535 & w.M) + (65535 & p.M) + (65535 & v.M)),
  830. (c =
  831. ((65535 &
  832. (l = (a.M >>> 16) + (w.M >>> 16) + (p.M >>> 16) + (v.M >>> 16) + (f >>> 16))) <<
  833. 16) |
  834. (65535 & f)),
  835. (f = (65535 & a.I) + (65535 & w.I) + (65535 & p.I) + (65535 & v.I) + (l >>> 16)),
  836. (l = (a.I >>> 16) + (w.I >>> 16) + (p.I >>> 16) + (v.I >>> 16) + (f >>> 16)),
  837. new L(((65535 & l) << 16) | (65535 & f), c))),
  838. (a = E),
  839. (p = w = void 0),
  840. (w = C((v = d), 14)),
  841. (p = C(v, 18)),
  842. (v = C(v, 41)),
  843. (l = new L(w.I ^ p.I ^ v.I, w.M ^ p.M ^ v.M)),
  844. (f = y),
  845. (c = b),
  846. (h = new L(((h = d).I & f.I) ^ (~h.I & c.I), (h.M & f.M) ^ (~h.M & c.M))),
  847. (r = q[H]),
  848. (i = A[H]),
  849. (s = u = o = void 0),
  850. (u = (65535 & a.M) + (65535 & l.M) + (65535 & h.M) + (65535 & r.M) + (65535 & i.M)),
  851. (s =
  852. ((65535 &
  853. (o =
  854. (a.M >>> 16) +
  855. (l.M >>> 16) +
  856. (h.M >>> 16) +
  857. (r.M >>> 16) +
  858. (i.M >>> 16) +
  859. (u >>> 16))) <<
  860. 16) |
  861. (65535 & u)),
  862. (u =
  863. (65535 & a.I) +
  864. (65535 & l.I) +
  865. (65535 & h.I) +
  866. (65535 & r.I) +
  867. (65535 & i.I) +
  868. (o >>> 16)),
  869. (o = (a.I >>> 16) + (l.I >>> 16) + (h.I >>> 16) + (r.I >>> 16) + (i.I >>> 16) + (u >>> 16)),
  870. (h = new L(((65535 & o) << 16) | (65535 & u), s)),
  871. (i = U(
  872. ((i = r = void 0),
  873. (r = C((o = M), 28)),
  874. (i = C(o, 34)),
  875. (o = C(o, 39)),
  876. new L(r.I ^ i.I ^ o.I, r.M ^ i.M ^ o.M)),
  877. ((u = I),
  878. (s = g),
  879. new L(
  880. ((r = M).I & u.I) ^ (r.I & s.I) ^ (u.I & s.I),
  881. (r.M & u.M) ^ (r.M & s.M) ^ (u.M & s.M),
  882. )),
  883. )),
  884. (E = b),
  885. (b = y),
  886. (y = d),
  887. (d = U(m, h)),
  888. (m = g),
  889. (g = I),
  890. (I = M),
  891. (M = U(h, i))
  892. return (
  893. (e[0] = U(M, e[0])),
  894. (e[1] = U(I, e[1])),
  895. (e[2] = U(g, e[2])),
  896. (e[3] = U(m, e[3])),
  897. (e[4] = U(d, e[4])),
  898. (e[5] = U(y, e[5])),
  899. (e[6] = U(b, e[6])),
  900. (e[7] = U(E, e[7])),
  901. e
  902. )
  903. }
  904. I(nn, (J = n))
  905. var J,
  906. Q = nn,
  907. W = [
  908. new L(0, 1),
  909. new L(0, 32898),
  910. new L(2147483648, 32906),
  911. new L(2147483648, 2147516416),
  912. new L(0, 32907),
  913. new L(0, 2147483649),
  914. new L(2147483648, 2147516545),
  915. new L(2147483648, 32777),
  916. new L(0, 138),
  917. new L(0, 136),
  918. new L(0, 2147516425),
  919. new L(0, 2147483658),
  920. new L(0, 2147516555),
  921. new L(2147483648, 139),
  922. new L(2147483648, 32905),
  923. new L(2147483648, 32771),
  924. new L(2147483648, 32770),
  925. new L(2147483648, 128),
  926. new L(0, 32778),
  927. new L(2147483648, 2147483658),
  928. new L(2147483648, 2147516545),
  929. new L(2147483648, 32896),
  930. new L(0, 2147483649),
  931. new L(2147483648, 2147516424),
  932. ],
  933. $ = [
  934. [0, 36, 3, 41, 18],
  935. [1, 44, 10, 45, 2],
  936. [62, 6, 43, 15, 61],
  937. [28, 55, 25, 21, 56],
  938. [27, 20, 39, 8, 14],
  939. ]
  940. function nn(h, n, e) {
  941. var t = this
  942. if ('SHA-384' !== h && 'SHA-512' !== h) throw new Error(w)
  943. var r = e || {}
  944. return (
  945. ((t = J.call(this, h, n, e) || this).K = t.N),
  946. (t.k = !0),
  947. (t.F = -1),
  948. (t.m = o(t.t, t.i, t.F)),
  949. (t.R = G),
  950. (t.L = function (n) {
  951. return n.slice()
  952. }),
  953. (t.B = D),
  954. (t.g = function (n, e, t, r) {
  955. for (
  956. var i, o = n, n = e, u = r, e = h, s = 31 + (((n + 129) >>> 10) << 5), r = n + t;
  957. o.length <= s;
  958. )
  959. o.push(0)
  960. for (
  961. o[n >>> 5] |= 128 << (24 - (n % 32)),
  962. o[s] = 4294967295 & r,
  963. o[s - 1] = (r / a) | 0,
  964. i = 0;
  965. i < o.length;
  966. i += 32
  967. )
  968. u = G(o.slice(i, i + 32), u)
  969. return 'SHA-384' === e
  970. ? [
  971. u[0].I,
  972. u[0].M,
  973. u[1].I,
  974. u[1].M,
  975. u[2].I,
  976. u[2].M,
  977. u[3].I,
  978. u[3].M,
  979. u[4].I,
  980. u[4].M,
  981. u[5].I,
  982. u[5].M,
  983. ]
  984. : [
  985. u[0].I,
  986. u[0].M,
  987. u[1].I,
  988. u[1].M,
  989. u[2].I,
  990. u[2].M,
  991. u[3].I,
  992. u[3].M,
  993. u[4].I,
  994. u[4].M,
  995. u[5].I,
  996. u[5].M,
  997. u[6].I,
  998. u[6].M,
  999. u[7].I,
  1000. u[7].M,
  1001. ]
  1002. }),
  1003. (t.U = D(h)),
  1004. (t.p = 1024),
  1005. (t.T = 'SHA-384' === h ? 384 : 512),
  1006. (t.C = !1),
  1007. r.hmacKey && t.Y(l('hmacKey', r.hmacKey, t.F)),
  1008. t
  1009. )
  1010. }
  1011. function T(n) {
  1012. for (var e = [], t = 0; t < 5; t += 1)
  1013. e[t] = [new L(0, 0), new L(0, 0), new L(0, 0), new L(0, 0), new L(0, 0)]
  1014. return e
  1015. }
  1016. function en(n) {
  1017. for (var e = [], t = 0; t < 5; t += 1) e[t] = n[t].slice()
  1018. return e
  1019. }
  1020. function R(n, e) {
  1021. var t,
  1022. r,
  1023. i,
  1024. o,
  1025. u,
  1026. s,
  1027. h,
  1028. a,
  1029. w,
  1030. f = [],
  1031. c = []
  1032. if (null !== n)
  1033. for (r = 0; r < n.length; r += 2)
  1034. e[(r >>> 1) % 5][((r >>> 1) / 5) | 0] = S(
  1035. e[(r >>> 1) % 5][((r >>> 1) / 5) | 0],
  1036. new L(n[r + 1], n[r]),
  1037. )
  1038. for (t = 0; t < 24; t += 1) {
  1039. for (o = T(), r = 0; r < 5; r += 1)
  1040. f[r] =
  1041. ((u = e[r][0]),
  1042. (s = e[r][1]),
  1043. (h = e[r][2]),
  1044. (a = e[r][3]),
  1045. (w = e[r][4]),
  1046. new L(u.I ^ s.I ^ h.I ^ a.I ^ w.I, u.M ^ s.M ^ h.M ^ a.M ^ w.M))
  1047. for (r = 0; r < 5; r += 1) c[r] = S(f[(r + 4) % 5], V(f[(r + 1) % 5], 1))
  1048. for (r = 0; r < 5; r += 1) for (i = 0; i < 5; i += 1) e[r][i] = S(e[r][i], c[r])
  1049. for (r = 0; r < 5; r += 1)
  1050. for (i = 0; i < 5; i += 1) o[i][(2 * r + 3 * i) % 5] = V(e[r][i], $[r][i])
  1051. for (r = 0; r < 5; r += 1)
  1052. for (i = 0; i < 5; i += 1)
  1053. e[r][i] = S(
  1054. o[r][i],
  1055. new L(
  1056. ~o[(r + 1) % 5][i].I & o[(r + 2) % 5][i].I,
  1057. ~o[(r + 1) % 5][i].M & o[(r + 2) % 5][i].M,
  1058. ),
  1059. )
  1060. e[0][0] = S(e[0][0], W[t])
  1061. }
  1062. return e
  1063. }
  1064. function tn(n) {
  1065. for (var e, t = 0, r = [0, 0], i = [4294967295 & n, (n / a) & 2097151], o = 6; 0 <= o; o--)
  1066. (0 == (e = (i[o >> 2] >>> (8 * o)) & 255) && 0 === t) ||
  1067. ((r[(t + 1) >> 2] |= e << (8 * (t + 1))), (t += 1))
  1068. return (r[0] |= t = 0 !== t ? t : 1), { value: 4 < t + 1 ? r : [r[0]], binLen: 8 + 8 * t }
  1069. }
  1070. function F(n) {
  1071. return f(tn(n.binLen), n)
  1072. }
  1073. function rn(n, e) {
  1074. for (
  1075. var t = tn(e), e = e >>> 2, r = (e - ((t = f(t, n)).value.length % e)) % e, i = 0;
  1076. i < r;
  1077. i++
  1078. )
  1079. t.value.push(0)
  1080. return t.value
  1081. }
  1082. I(k, (on = n)),
  1083. (k.prototype.j = function (n, e) {
  1084. ;(n = {
  1085. funcName: l('funcName', (n = n || {} || {}).funcName, 1, { value: [], binLen: 0 }),
  1086. customization: l('Customization', n.customization, 1, { value: [], binLen: 0 }),
  1087. }),
  1088. e && (n.funcName = e),
  1089. (e = f(F(n.funcName), F(n.customization)))
  1090. if (0 === n.customization.binLen && 0 === n.funcName.binLen) return 31
  1091. for (var t = rn(e, this.p >>> 3), r = 0; r < t.length; r += this.p >>> 5)
  1092. (this.U = this.R(t.slice(r, r + (this.p >>> 5)), this.U)), (this.A += this.p)
  1093. return 4
  1094. }),
  1095. (k.prototype.X = function (n) {
  1096. var e = {
  1097. kmacKey: l('kmacKey', (e = n || {} || {}).kmacKey, 1),
  1098. funcName: { value: [1128353099], binLen: 32 },
  1099. customization: l('Customization', e.customization, 1, { value: [], binLen: 0 }),
  1100. }
  1101. this.j(n, e.funcName)
  1102. for (var t = rn(F(e.kmacKey), this.p >>> 3), r = 0; r < t.length; r += this.p >>> 5)
  1103. (this.U = this.R(t.slice(r, r + (this.p >>> 5)), this.U)), (this.A += this.p)
  1104. this.l = !0
  1105. }),
  1106. (k.prototype.O = function (n) {
  1107. var e = f(
  1108. { value: this.u.slice(), binLen: this.h },
  1109. (function (n) {
  1110. for (
  1111. var e, t = 0, r = [0, 0], i = [4294967295 & n, (n / a) & 2097151], o = 6;
  1112. 0 <= o;
  1113. o--
  1114. )
  1115. (0 == (e = (i[o >> 2] >>> (8 * o)) & 255) && 0 === t) ||
  1116. ((r[t >> 2] |= e << (8 * t)), (t += 1))
  1117. return (
  1118. (r[(t = 0 !== t ? t : 1) >> 2] |= t << (8 * t)),
  1119. { value: 4 < t + 1 ? r : [r[0]], binLen: 8 + 8 * t }
  1120. )
  1121. })(n.outputLen),
  1122. )
  1123. return this.g(e.value, e.binLen, this.A, this.L(this.U), n.outputLen)
  1124. })
  1125. var on,
  1126. un = k
  1127. function k(n, e, t) {
  1128. var r = this,
  1129. A = 6,
  1130. M = 0,
  1131. i = t || {}
  1132. if (1 !== (r = on.call(this, n, e, t) || this).numRounds) {
  1133. if (i.kmacKey || i.hmacKey) throw new Error(h)
  1134. if ('CSHAKE128' === r.o || 'CSHAKE256' === r.o)
  1135. throw new Error('Cannot set numRounds for CSHAKE variants')
  1136. }
  1137. switch (
  1138. ((r.F = 1),
  1139. (r.m = o(r.t, r.i, r.F)),
  1140. (r.R = R),
  1141. (r.L = en),
  1142. (r.B = T),
  1143. (r.U = T()),
  1144. (r.C = !1),
  1145. n)
  1146. ) {
  1147. case 'SHA3-224':
  1148. ;(r.p = M = 1152), (r.T = 224), (r.k = !0), (r.K = r.N)
  1149. break
  1150. case 'SHA3-256':
  1151. ;(r.p = M = 1088), (r.T = 256), (r.k = !0), (r.K = r.N)
  1152. break
  1153. case 'SHA3-384':
  1154. ;(r.p = M = 832), (r.T = 384), (r.k = !0), (r.K = r.N)
  1155. break
  1156. case 'SHA3-512':
  1157. ;(r.p = M = 576), (r.T = 512), (r.k = !0), (r.K = r.N)
  1158. break
  1159. case 'SHAKE128':
  1160. ;(A = 31), (r.p = M = 1344), (r.T = -1), (r.C = !0), (r.k = !1), (r.K = null)
  1161. break
  1162. case 'SHAKE256':
  1163. ;(A = 31), (r.p = M = 1088), (r.T = -1), (r.C = !0), (r.k = !1), (r.K = null)
  1164. break
  1165. case 'KMAC128':
  1166. ;(A = 4), (r.p = M = 1344), r.X(t), (r.T = -1), (r.C = !0), (r.k = !1), (r.K = r.O)
  1167. break
  1168. case 'KMAC256':
  1169. ;(A = 4), (r.p = M = 1088), r.X(t), (r.T = -1), (r.C = !0), (r.k = !1), (r.K = r.O)
  1170. break
  1171. case 'CSHAKE128':
  1172. ;(r.p = M = 1344), (A = r.j(t)), (r.T = -1), (r.C = !0), (r.k = !1), (r.K = null)
  1173. break
  1174. case 'CSHAKE256':
  1175. ;(r.p = M = 1088), (A = r.j(t)), (r.T = -1), (r.C = !0), (r.k = !1), (r.K = null)
  1176. break
  1177. default:
  1178. throw new Error(w)
  1179. }
  1180. return (
  1181. (r.g = function (n, e, t, r, i) {
  1182. for (
  1183. var o,
  1184. u = n,
  1185. s = e,
  1186. h = r,
  1187. a = M,
  1188. n = A,
  1189. w = i,
  1190. f = 0,
  1191. c = [],
  1192. l = a >>> 5,
  1193. p = s >>> 5,
  1194. v = 0;
  1195. v < p && a <= s;
  1196. v += l
  1197. )
  1198. (h = R(u.slice(v, v + l), h)), (s -= a)
  1199. for (u = u.slice(v), s %= a; u.length < l; ) u.push(0)
  1200. for (
  1201. u[(v = s >>> 3) >> 2] ^= n << ((v % 4) * 8), u[l - 1] ^= 2147483648, h = R(u, h);
  1202. 32 * c.length < w && ((o = h[f % 5][(f / 5) | 0]), c.push(o.M), !(32 * c.length >= w));
  1203. )
  1204. c.push(o.I), 0 == (64 * (f += 1)) % a && (R(null, h), (f = 0))
  1205. return c
  1206. }),
  1207. i.hmacKey && r.Y(l('hmacKey', i.hmacKey, r.F)),
  1208. r
  1209. )
  1210. }
  1211. return (
  1212. (N.prototype.update = function (n) {
  1213. return this._.update(n), this
  1214. }),
  1215. (N.prototype.getHash = function (n, e) {
  1216. return this._.getHash(n, e)
  1217. }),
  1218. (N.prototype.setHMACKey = function (n, e, t) {
  1219. this._.setHMACKey(n, e, t)
  1220. }),
  1221. (N.prototype.getHMAC = function (n, e) {
  1222. return this._.getHMAC(n, e)
  1223. }),
  1224. N
  1225. )
  1226. function N(n, e, t) {
  1227. if ('SHA-1' == n) this._ = new _(n, e, t)
  1228. else if ('SHA-224' == n || 'SHA-256' == n) this._ = new P(n, e, t)
  1229. else if ('SHA-384' == n || 'SHA-512' == n) this._ = new Q(n, e, t)
  1230. else {
  1231. if (
  1232. 'SHA3-224' != n &&
  1233. 'SHA3-256' != n &&
  1234. 'SHA3-384' != n &&
  1235. 'SHA3-512' != n &&
  1236. 'SHAKE128' != n &&
  1237. 'SHAKE256' != n &&
  1238. 'CSHAKE128' != n &&
  1239. 'CSHAKE256' != n &&
  1240. 'KMAC128' != n &&
  1241. 'KMAC256' != n
  1242. )
  1243. throw new Error(w)
  1244. this._ = new un(n, e, t)
  1245. }
  1246. }
  1247. })