提交 f5318d5632ca6179808206ab9f10af9628d2ebbe
Merge branch 'master' of http://gitlab.ctune.cn/weijunh/DMapManager
正在显示
331 个修改的文件
包含
11154 行增加
和
28 行删除
| ... | ... | @@ -4,7 +4,7 @@ from unittest import result |
| 4 | 4 | from flasgger import swag_from |
| 5 | 5 | from app.util import BlueprintApi |
| 6 | 6 | from app.util import BlueprintApi |
| 7 | -from flask import Blueprint, render_template, redirect, request, session, jsonify | |
| 7 | +from flask import Blueprint, render_template, redirect, request, session, jsonify, flash | |
| 8 | 8 | from .models import * |
| 9 | 9 | from .oauth2 import authorization, generate_user_info, require_oauth |
| 10 | 10 | from authlib.oauth2 import OAuth2Error |
| ... | ... | @@ -48,7 +48,7 @@ class DataManager(BlueprintApi): |
| 48 | 48 | return jsonify(dict(error.get_body())) |
| 49 | 49 | if not user: |
| 50 | 50 | # 生成验证码 |
| 51 | - | |
| 51 | + | |
| 52 | 52 | return render_template("auth/authorize.html", |
| 53 | 53 | user=user, |
| 54 | 54 | grant=grant) |
| ... | ... | @@ -62,24 +62,34 @@ class DataManager(BlueprintApi): |
| 62 | 62 | error = "密码不可为空" |
| 63 | 63 | else: |
| 64 | 64 | username = request.form.get("username") |
| 65 | - # password = SM3.encode(request.form.get("password")) | |
| 66 | - password = request.form.get("password") | |
| 65 | + crypt_pwd = request.form.get("password") | |
| 66 | + # password = SM3.encode(crypt_pwd) | |
| 67 | + password = SM3.encode(AESHelper.decode(crypt_pwd)) | |
| 67 | 68 | user = User.query.filter_by( |
| 68 | 69 | username=username, password=password).first() |
| 69 | 70 | if not user: |
| 70 | 71 | error = "账号或密码不正确" |
| 72 | + flash(error) | |
| 73 | + # return render_template("auth/authorize.html", | |
| 74 | + # grant_user=None,error=error) | |
| 71 | 75 | |
| 76 | + flash(error) | |
| 72 | 77 | if user: |
| 73 | 78 | session["id"] = user.id |
| 74 | 79 | grant_user = user |
| 75 | 80 | return authorization.create_authorization_response(request=request, grant_user=grant_user) |
| 76 | 81 | |
| 82 | + # try: | |
| 83 | + # grant = authorization.validate_consent_request(end_user=user) | |
| 84 | + # except OAuth2Error as error: | |
| 85 | + # return jsonify(dict(error.get_body())) | |
| 86 | + # return render_template("auth/authorize.html", user=user, grant=grant, error=error) | |
| 77 | 87 | try: |
| 78 | 88 | grant = authorization.validate_consent_request(end_user=user) |
| 79 | 89 | except OAuth2Error as error: |
| 80 | 90 | return jsonify(dict(error.get_body())) |
| 81 | - # return render_template("auth/authorize.html", user=user, grant=grant, error=error) | |
| 82 | - return authorization.create_authorization_response(grant_user=None) | |
| 91 | + return render_template("auth/authorize.html", | |
| 92 | + grant_user=None, error=error) | |
| 83 | 93 | |
| 84 | 94 | @staticmethod |
| 85 | 95 | @bp.route("/token", methods=["POST"]) |
| ... | ... | @@ -98,21 +108,19 @@ class DataManager(BlueprintApi): |
| 98 | 108 | @staticmethod |
| 99 | 109 | @bp.route("/logout", methods=["GET"]) |
| 100 | 110 | def logout(): |
| 101 | - url = '' | |
| 102 | 111 | try: |
| 103 | - user = current_user() | |
| 104 | - grant = authorization.validate_consent_request(end_user=user) | |
| 112 | + request2 = authorization.create_oauth2_request(request) | |
| 113 | + grant1 = authorization.get_authorization_grant(request=request2) | |
| 114 | + redirect_uri = grant1.validate_authorization_request() | |
| 105 | 115 | access_token = request.args.get("accesstoken") |
| 106 | 116 | accesstoken = OAuth2Token.query.filter_by( |
| 107 | 117 | access_token=access_token).first() |
| 108 | 118 | accesstoken.revoked = True |
| 109 | 119 | db.session.commit() |
| 110 | 120 | remove_user() |
| 111 | - if accesstoken: | |
| 112 | - url = grant.client.client_uri | |
| 113 | 121 | except OAuth2Error as error: |
| 114 | 122 | return jsonify(dict(error.get_body())) |
| 115 | - return redirect(url) | |
| 123 | + return redirect(redirect_uri) | |
| 116 | 124 | |
| 117 | 125 | """接口""" |
| 118 | 126 | @staticmethod | ... | ... |
| ... | ... | @@ -5,16 +5,40 @@ dmap.login = { |
| 5 | 5 | let username = $("#username").val(); |
| 6 | 6 | let password = $("#password").val(); |
| 7 | 7 | |
| 8 | - if (username.length <= 0 || password.length <= 0) { | |
| 9 | - tips.notify("用户名或密码不能为空", "danger", 1e3); | |
| 10 | - return false; | |
| 11 | - } | |
| 8 | + // if (username.length <= 0 || password.length <= 0) { | |
| 9 | + // tips.notify("用户名或密码不能为空", "danger", 1e3); | |
| 10 | + // return false; | |
| 11 | + // } | |
| 12 | 12 | |
| 13 | - $.post("authorize", { username: username, password: password }, function(data) { | |
| 14 | - if (!data.result) { | |
| 15 | - tips.notify("账号或密码错误", "danger", 1e3); | |
| 16 | - } | |
| 17 | - }) | |
| 13 | + let aesKey = JsCrypto.Utf8.parse('w03MyIgc3zMHM5Qe'), | |
| 14 | + iv = JsCrypto.Utf8.parse('8765432187654321'), | |
| 15 | + instr = JsCrypto.Utf8.parse(password); | |
| 16 | + let encryptData = JsCrypto.AES.encrypt(instr, aesKey, { | |
| 17 | + iv: iv, | |
| 18 | + mode: JsCrypto.mode.CBC, | |
| 19 | + padding: JsCrypto.pad.Pkcs7 | |
| 20 | + }); | |
| 21 | + let crypt_pwd = encryptData.cipherText.toString(); | |
| 22 | + let form = document.createElement('form'); | |
| 23 | + form.method = 'post'; | |
| 24 | + createElement(form, { username: username, password: crypt_pwd }); | |
| 25 | + form.style.display = "contents"; | |
| 26 | + document.body.appendChild(form); | |
| 27 | + form.submit(); | |
| 18 | 28 | }); |
| 29 | + | |
| 30 | + | |
| 31 | + function createElement(form, params) { | |
| 32 | + for (const key in params) { | |
| 33 | + if (params.hasOwnProperty(key)) { | |
| 34 | + const hiddenField = document.createElement('input'); | |
| 35 | + hiddenField.type = 'hidden'; | |
| 36 | + hiddenField.name = key; | |
| 37 | + hiddenField.value = params[key]; | |
| 38 | + | |
| 39 | + form.appendChild(hiddenField); | |
| 40 | + } | |
| 41 | + } | |
| 42 | + } | |
| 19 | 43 | } |
| 20 | 44 | }; |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/AES.d.ts
0 → 100644
| 1 | +import { CipherProps, PropsWithKey } from "./lib/algorithm/cipher/Cipher"; | |
| 2 | +import type { Word32Array } from "./lib/Word32Array"; | |
| 3 | +import { BlockCipher, BlockCipherProps } from "./lib/algorithm/cipher/BlockCipher"; | |
| 4 | +import type { CipherParams } from "./lib/algorithm/cipher/CipherParams"; | |
| 5 | +export interface AESProps extends BlockCipherProps { | |
| 6 | +} | |
| 7 | +export declare class AES extends BlockCipher { | |
| 8 | + static readonly keySize: number; | |
| 9 | + protected _props: PropsWithKey<AESProps>; | |
| 10 | + protected _nRounds: number; | |
| 11 | + protected _keyPriorReset: Word32Array | undefined; | |
| 12 | + protected _keySchedule: number[]; | |
| 13 | + protected _invKeySchedule: number[]; | |
| 14 | + constructor(props: PropsWithKey<AESProps>); | |
| 15 | + protected _doReset(): void; | |
| 16 | + encryptBlock(words: number[], offset: number): void; | |
| 17 | + decryptBlock(words: number[], offset: number): void; | |
| 18 | + protected _doCryptBlock(words: number[], offset: number, keySchedule: number[], subMix0: number[], subMix1: number[], subMix2: number[], subMix3: number[], sBox: number[]): void; | |
| 19 | + /** | |
| 20 | + * Creates this cipher in encryption mode. | |
| 21 | + * | |
| 22 | + * @param {Word32Array} key The key. | |
| 23 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 24 | + * @return {Cipher} A cipher instance. | |
| 25 | + * @example | |
| 26 | + * var cipher = AES.createEncryptor(keyWordArray, { iv: ivWordArray }); | |
| 27 | + */ | |
| 28 | + static createEncryptor(key: Word32Array, props?: Partial<CipherProps>): AES; | |
| 29 | + /** | |
| 30 | + * Creates this cipher in decryption mode. | |
| 31 | + * | |
| 32 | + * @param {Word32Array} key The key. | |
| 33 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 34 | + * @return {Cipher} A cipher instance. | |
| 35 | + * @example | |
| 36 | + * var cipher = AES.createDecryptor(keyWordArray, { iv: ivWordArray }); | |
| 37 | + */ | |
| 38 | + static createDecryptor(key: Word32Array, props?: Partial<CipherProps>): AES; | |
| 39 | + /** | |
| 40 | + * Encrypt a message with key | |
| 41 | + * | |
| 42 | + * @param {Word32Array|string} message | |
| 43 | + * @param {Word32Array|string} key | |
| 44 | + * @param {Partial<AESProps>?} props | |
| 45 | + * @example | |
| 46 | + * var encryptedMessage = AES.encrypt("test", "pass"); | |
| 47 | + */ | |
| 48 | + static encrypt(message: Word32Array | string, key: Word32Array | string, props?: Partial<AESProps>): CipherParams; | |
| 49 | + /** | |
| 50 | + * Encrypt a encrypted message with key | |
| 51 | + * | |
| 52 | + * @param {CipherParams|string} cipherParams | |
| 53 | + * @param {Word32Array|string} key | |
| 54 | + * @param {Partial<AESProps>?} props | |
| 55 | + * @example | |
| 56 | + * var encryptedMessage = AES.decrypt(cipherProps, "pass"); | |
| 57 | + */ | |
| 58 | + static decrypt(cipherParams: CipherParams | string, key: Word32Array | string, props?: Partial<AESProps>): Word32Array; | |
| 59 | +} | ... | ... |
app/static/content/jscrypto/AES.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var r=t();for(var i in n.JsCrypto=n.JsCrypto||{},r)n.JsCrypto[i]=r[i]}}(this,(function(){return function(){"use strict";var n={6367:function(n,t,r){r.d(t,{Hmac:function(){return e}});var i=r(4768),e=function(){function n(n,t){this.i=n,"string"==typeof t&&(t=i.d.parse(t));var r=n.blockSize,e=4*r;t.nSigBytes>e&&(t=n.finalize(t)),t.clamp();for(var o=this.u=t.clone(),u=this.h=t.clone(),f=o.words,c=u.words,s=0;s<r;s++)f[s]^=1549556828,c[s]^=909522486;u.nSigBytes=e,o.nSigBytes=e,this.reset()}return n.prototype.reset=function(){this.i.reset(),this.i.update(this.h)},n.prototype.update=function(n){return this.i.update(n),this},n.prototype.finalize=function(n){var t=this.i.finalize(n);return this.i.reset(),this.i.finalize(this.u.clone().concat(t))},n}()},5561:function(n,t,r){r.d(t,{SHA256:function(){return v}});var i,e=r(1868),o=r(3354),u=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),f=[],c=[];function s(n){for(var t=Math.sqrt(n),r=2;r<=t;r++)if(!(n%r))return!1;return!0}function a(n){return 4294967296*(n-(0|n))|0}!function(){for(var n=2,t=0;t<64;)s(n)&&(t<8&&(f[t]=a(Math.pow(n,.5))),c[t]=a(Math.pow(n,1/3)),t++),n++}();var h=[],v=function(n){function t(t){var r=n.call(this,t)||this;return r.v=new o.e(f.slice(0)),r.j=t,t&&void 0!==t.hash&&(r.v=t.hash.clone()),r}return u(t,n),t.prototype.O=function(){this.v=new o.e(f.slice(0))},t.prototype.A=function(n,t){for(var r=this.v.words,i=r[0],e=r[1],o=r[2],u=r[3],f=r[4],s=r[5],a=r[6],v=r[7],w=0;w<64;w++){if(w<16)h[w]=0|n[t+w];else{var d=h[w-15],l=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,b=h[w-2],y=(b<<15|b>>>17)^(b<<13|b>>>19)^b>>>10;h[w]=l+h[w-7]+y+h[w-16]}var p=i&e^i&o^e&o,m=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),j=v+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(f&s^~f&a)+c[w]+h[w];v=a,a=s,s=f,f=u+j|0,u=o,o=e,e=i,i=j+(m+p)|0}r[0]=r[0]+i|0,r[1]=r[1]+e|0,r[2]=r[2]+o|0,r[3]=r[3]+u|0,r[4]=r[4]+f|0,r[5]=r[5]+s|0,r[6]=r[6]+a|0,r[7]=r[7]+v|0},t.prototype.N=function(){var n=this.k.words,t=8*this.I,r=8*this.k.nSigBytes;return n[r>>>5]|=128<<24-r%32,n[14+(r+64>>>9<<4)]=Math.floor(t/4294967296),n[15+(r+64>>>9<<4)]=t,this.k.nSigBytes=4*n.length,this.S(),this.v},t.prototype.clone=function(){return new t({hash:this.v,blockSize:this.U,data:this.k,nBytes:this.I})},t.hash=function(n,r){return new t(r).finalize(n)},t}(e.P)},3354:function(n,t,r){r.d(t,{e:function(){return o}});var i=r(5720),e=r(9054),o=function(){function n(t,r){if(Array.isArray(t)||!t)return this.F=Array.isArray(t)?t:[],void(this.H="number"==typeof r?r:4*this.F.length);if(t instanceof n)return this.F=t.words.slice(),void(this.H=t.nSigBytes);var i;try{t instanceof ArrayBuffer?i=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!i)throw new Error("Invalid argument");for(var e=i.byteLength,o=[],u=0;u<e;u++)o[u>>>2]|=i[u]<<24-u%4*8;this.F=o,this.H=e}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.H},set:function(n){this.H=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.F},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):i.p.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this.F,t=this.H,r=new Uint8Array(t),i=0;i<t;i++)r[i]=n[i>>>2]>>>24-i%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.H%4)for(var i=0;i<r;i++){var e=t[i>>>2]>>>24-i%4*8&255;this.F[this.H+i>>>2]|=e<<24-(this.H+i)%4*8}else for(i=0;i<r;i+=4)this.F[this.H+i>>>2]=t[i>>>2];return this.H+=r,this},n.prototype.clamp=function(){var n=this.H;this.F[n>>>2]&=4294967295<<32-n%4*8,this.F.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.F.slice(),this.H)},n.random=function(t){for(var r=[],i=0;i<t;i+=4)r.push((0,e.M)());return new n(r,t)},n}()},7211:function(n,t,r){r.d(t,{C:function(){return o}});var i=r(3354),e=r(4768),o=function(){function n(n){this.B=0,this.U=0,this.j=n,this.k=n&&void 0!==n.data?n.data.clone():new i.e,this.I=n&&"number"==typeof n.nBytes?n.nBytes:0}return Object.defineProperty(n.prototype,"blockSize",{get:function(){return this.U},enumerable:!1,configurable:!0}),n.prototype.reset=function(n,t){this.k=void 0!==n?n.clone():new i.e,this.I="number"==typeof t?t:0},n.prototype.K=function(n){var t="string"==typeof n?e.d.parse(n):n;this.k.concat(t),this.I+=t.nSigBytes},n.prototype.S=function(n){var t,r=this.k.words,e=this.k.nSigBytes,o=this.U,u=e/(4*this.U),f=(u=n?Math.ceil(u):Math.max((0|u)-this.B,0))*o,c=Math.min(4*f,e);if(f){for(var s=0;s<f;s+=o)this.A(r,s);t=r.splice(0,f),this.k.nSigBytes-=c}return new i.e(t,c)},n.prototype.A=function(n,t){throw new Error("Not implemented")},n}()},1868:function(n,t,r){r.d(t,{P:function(){return u}});var i,e=r(7211),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.U=16,r.j=t,t&&"number"==typeof t.blockSize&&(r.U=t.blockSize),r.reset(t?t.data:void 0,t?t.nBytes:void 0),r}return o(t,n),Object.defineProperty(t.prototype,"blockSize",{get:function(){return this.U},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.O()},t.prototype.update=function(n){return this.K(n),this.S(),this},t.prototype.finalize=function(n){return n&&this.K(n),this.N()},t.prototype.O=function(){throw new Error("Not implemented")},t.prototype.N=function(){throw new Error("Not implemented")},t}(e.C)},787:function(n,t,r){r.d(t,{G:function(){return s}});var i,e=r(9456),o=r(4344),u=r(7919),f=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),c=function(){return(c=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},s=function(n){function t(t){var r=n.call(this,t)||this;return r.U=4,r.R=o.n,r.q=u.l,r.j=t,r.R=void 0!==t.mode?t.mode:r.R,r.q=void 0!==t.padding?t.padding:r.q,r.reset(null==t?void 0:t.data,null==t?void 0:t.nBytes),r}return f(t,n),Object.defineProperty(t.prototype,"mode",{get:function(){return this.J},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"padding",{get:function(){return this.q},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){var i;n.prototype.reset.call(this,t,r),this.L===e.t.ENC_TRANSFORM_MODE?i=this.R.createEncryptor:(i=this.R.createDecryptor,this.B=1),this.R&&this.V===i?this.J=new this.R({cipher:this,iv:this.X}):(this.J=i.call(this.R,{cipher:this,iv:this.X}),this.V=i)},t.prototype.A=function(n,t){var r;null===(r=this.J)||void 0===r||r.processBlock(n,t)},t.prototype.N=function(){var n,t=this.q;return this.L===e.t.ENC_TRANSFORM_MODE?(t.pad(this.k,this.blockSize),n=this.S(!0)):(n=this.S(!0),t.unpad(n)),n},t.prototype.encryptBlock=function(n,t){throw new Error("Not implemented")},t.prototype.decryptBlock=function(n,t){throw new Error("Not implemented")},t.createEncryptor=function(n,r){return new t(c(c({},r=void 0===r?{}:r),{key:n,transformMode:e.t.ENC_TRANSFORM_MODE}))},t.createDecryptor=function(n,r){return new t(c(c({},r=void 0===r?{}:r),{key:n,transformMode:e.t.DEC_TRANSFORM_MODE}))},t}(e.t)},9456:function(n,t,r){r.d(t,{t:function(){return f}});var i,e=r(7211),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(){return(u=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},f=function(n){function t(t){var r=n.call(this,t)||this;return r.L=1,r.j=t,r.Y=t.key,r.X=void 0!==t.iv?t.iv:r.X,r.L=void 0!==t.transformMode?t.transformMode:r.L,r}return o(t,n),Object.defineProperty(t.prototype,"iv",{get:function(){return this.X},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.O()},t.prototype.process=function(n){return this.K(n),this.S()},t.prototype.finalize=function(n){return n&&this.K(n),this.N()},t.prototype.O=function(){throw new Error("Not implemented")},t.prototype.A=function(n,t){throw new Error("Not implemented")},t.prototype.N=function(){throw new Error("Not implemented")},t.createEncryptor=function(n,r){return new t(u(u({},r=void 0===r?{}:r),{key:n,transformMode:t.ENC_TRANSFORM_MODE}))},t.createDecryptor=function(n,r){return new t(u(u({},r=void 0===r?{}:r),{key:n,transformMode:t.DEC_TRANSFORM_MODE}))},t.ENC_TRANSFORM_MODE=1,t.DEC_TRANSFORM_MODE=2,t.keySize=4,t.ivSize=4,t}(e.C)},2505:function(n,t,r){r.d(t,{Q:function(){return e}});var i=r(1232),e=function(){function n(n){this.formatter=i.w,n&&(this.cipherText=n.cipherText,this.key=n.key,this.iv=n.iv,this.salt=n.salt,this.Algorithm=n.Algorithm,this.mode=n.mode,this.padding=n.padding,this.blockSize=n.blockSize,this.formatter=n.formatter||i.w)}return n.prototype.toString=function(n){return(n||this.formatter).stringify(this)},n}()},5693:function(n,t,r){r.d(t,{E:function(){return c}});var i=r(9109),e=r(2214),o=r(2505),u=r(1232),f=function(){return(f=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},c={encrypt:function(n,t,r,u){var c=u?f({},u):{},s=u&&u.KDF?u.KDF:e.s,a={};u&&u.kdfHasher&&(a.kdfHasher=u.kdfHasher),u&&u.kdfIterations&&(a.kdfIterations=u.kdfIterations),u&&u.kdfModule&&(a.kdfModule=u.kdfModule);var h=s.execute(r,n.keySize,n.ivSize,c.kdfSalt,a);c.iv=h.iv;var v=i.D.encrypt(n,t,h.key,c);return new o.Q(f(f({},v),{key:h.key,iv:h.iv,salt:h.salt}))},decrypt:function(n,t,r,o){var c=o?f({},o):{},s=c.KDF?c.KDF:e.s,a=c.formatter?c.formatter:u.w,h=(0,i.W)(t,a),v={};o&&o.kdfHasher&&(v.kdfHasher=o.kdfHasher),o&&o.kdfIterations&&(v.kdfIterations=o.kdfIterations),o&&o.kdfModule&&(v.kdfModule=o.kdfModule);var w=s.execute(r,n.keySize,n.ivSize,h.salt,v);return c.iv=w.iv,i.D.decrypt(n,h,w.key,c)}}},9109:function(n,t,r){r.d(t,{W:function(){return o},D:function(){return u}});var i=r(1232),e=r(2505);function o(n,t){return"string"==typeof n?t.parse(n):n}var u={encrypt:function(n,t,r,o){var u=n.createEncryptor(r,o),f=u.finalize(t);return new e.Q({cipherText:f,key:r,iv:u.iv,Algorithm:n,mode:u.mode,padding:u.padding,blockSize:u.blockSize,formatter:(null==o?void 0:o.formatter)||i.w})},decrypt:function(n,t,r,e){var u=n.createDecryptor(r,e),f=o(t,(null==e?void 0:e.formatter)||i.w);return u.finalize(f.cipherText||"")}}},1232:function(n,t,r){r.d(t,{w:function(){return u}});var i=r(2505),e=r(3354),o=r(1773),u={stringify:function(n){var t=n.cipherText,r=n.salt;return t?r?new e.e([1398893684,1701076831]).concat(r).concat(t).toString(o.D):t.toString(o.D):""},parse:function(n){var t,r=o.D.parse(n),u=r.words;return 1398893684===u[0]&&1701076831===u[1]&&(t=new e.e(u.slice(2,4)),u.splice(0,4),r.nSigBytes-=16),new i.Q({cipherText:r,salt:t})}}},2214:function(n,t,r){r.d(t,{s:function(){return f}});var i=r(3354),e=r(2505),o=r(7008),u=function(){return(u=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},f={execute:function(n,t,r,f,c){f||(f=i.e.random(8));var s=c&&c.kdfModule||o.E,a=c?{Hasher:c.kdfHasher,iterations:c.kdfIterations}:{},h=s.getKey(n,f,u(u({},a),{keySize:t+r})),v=new i.e(h.words.slice(t),4*r);return h.nSigBytes=4*t,new e.Q({key:h,iv:v,salt:f})}}},7008:function(n,t,r){r.d(t,{E:function(){return s}});var i,e=r(5561),o=r(6367),u=r(3354),f=r(9541),c=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),s=function(n){function t(t){var r=n.call(this,t)||this;return r.Z=4,r.$=e.SHA256,r.nn=1e4,t&&(r.Z=void 0!==t.keySize?t.keySize:r.Z,r.$=void 0!==t.Hasher?t.Hasher:r.$,r.nn=void 0!==t.iterations?t.iterations:r.nn),r}return c(t,n),t.prototype.compute=function(n,t){for(var r=new o.Hmac(new this.$,n),i=new u.e,e=new u.e([1]),f=i.words,c=e.words,s=this.Z,a=this.nn;f.length<s;){var h=r.update(t).finalize(e);r.reset();for(var v=h.words,w=v.length,d=h,l=1;l<a;l++){d=r.finalize(d),r.reset();for(var b=d.words,y=0;y<w;y++)v[y]^=b[y]}i.concat(h),c[0]++}return i.nSigBytes=4*s,i},t.getKey=function(n,r,i){return new t(i).compute(n,r)},t}(f._)},9541:function(n,t,r){r.d(t,{_:function(){return i}});var i=function(){function n(n){this.j=n}return n.prototype.compute=function(n,t){throw new Error("Not implemented")},n.getKey=function(n,t,r){throw new Error("Not implemented")},n}()},1863:function(n,t,r){r.d(t,{T:function(){return i}});var i=function(){function n(n){this.j=n,this.tn=n.cipher,this.X=n.iv}return n.prototype.processBlock=function(n,t){},n.createEncryptor=function(n){throw new Error("Not implemented yet")},n.createDecryptor=function(n){throw new Error("Not implemented yet")},n}()},4344:function(n,t,r){r.d(t,{n:function(){return u}});var i,e=r(1863),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.rn=[],r}return o(t,n),t.prototype.xorBlock=function(n,t,r){var i,e=this.X;e?(i=e.words,this.X=void 0):i=this.rn;for(var o=0;o<r;o++)n[t+o]^=i[o]},t.createEncryptor=function(n){return new t.Encryptor(n)},t.createDecryptor=function(n){return new t.Decryptor(n)},t.Encryptor=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return o(t,n),t.prototype.processBlock=function(n,t){var r=this.tn,i=r.blockSize;this.xorBlock(n,t,i),r.encryptBlock(n,t),this.rn=n.slice(t,t+i)},t}(t),t.Decryptor=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return o(t,n),t.prototype.processBlock=function(n,t){var r=this.tn,i=r.blockSize,e=n.slice(t,t+i);r.decryptBlock(n,t),this.xorBlock(n,t,i),this.rn=e},t}(t),t}(e.T)},7919:function(n,t,r){r.d(t,{l:function(){return e}});var i=r(3354);var e={pad:function(n,t){for(var r=4*t,e=r-n.nSigBytes%r,o=e<<24|e<<16|e<<8|e,u=[],f=0;f<e;f+=4)u.push(o);var c=new i.e(u,e);n.concat(c)},unpad:function(n){var t=255&n.words[n.nSigBytes-1>>>2];n.nSigBytes-=t}}},1756:function(n,t,r){r.d(t,{w:function(){return u}});var i,e="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(i=parseInt((/msie (\d+)/.exec(e)||[])[1],10),isNaN(i)?(i=parseInt((/trident\/.*; rv:(\d+)/.exec(e)||[])[1],10),!isNaN(i)&&i):i);function u(n,t){return!1!==o&&(!t||("<"===n?o<t:"<="===n?o<=t:">"===n?o>t:">="===n?o>=t:o===t))}},1773:function(n,t,r){r.d(t,{D:function(){return f}});for(var i=r(3354),e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=[],u=0;u<e.length;u++)o[e.charCodeAt(u)]=u;var f={stringify:function(n){var t=n.words,r=n.nSigBytes;n.clamp();for(var i=[],o=0;o<r;o+=3)for(var u=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,f=0;f<4&&o+.75*f<r;f++)i.push(e.charAt(u>>>6*(3-f)&63));var c=e.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(n){var t=n.length,r=e.charAt(64);if(r){var u=n.indexOf(r);-1!==u&&(t=u)}for(var f=[],c=0,s=0;s<t;s++)if(s%4){var a=o[n.charCodeAt(s-1)]<<s%4*2|o[n.charCodeAt(s)]>>>6-s%4*2;f[c>>>2]|=a<<24-c%4*8,c++}return new i.e(f,c)}}},5720:function(n,t,r){r.d(t,{p:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var r=[],e=0;e<t;e+=2)r[e>>>3]|=parseInt(n.substr(e,2),16)<<24-e%8*4;return new i.e(r,t/2)}}},8702:function(n,t,r){r.d(t,{m:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push(String.fromCharCode(o))}return i.join("")},parse:function(n){for(var t=n.length,r=[],e=0;e<t;e++)r[e>>>2]|=(255&n.charCodeAt(e))<<24-e%4*8;return new i.e(r,t)}}},4768:function(n,t,r){r.d(t,{d:function(){return e}});var i=r(8702),e={stringify:function(n){try{return decodeURIComponent(escape(i.m.stringify(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return i.m.parse(unescape(encodeURIComponent(n)))}}},9054:function(n,t,r){r.d(t,{M:function(){return e}});var i=r(1756);var e=function(){if("undefined"!=typeof window){var n=window.crypto||window.msCrypto;if(!n){if((0,i.w)("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return n.getRandomValues(new Uint32Array(1))[0]}}return void 0!==r.g&&r.g.crypto?function(){return r.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}()}},t={};function r(i){var e=t[i];if(void 0!==e)return e.exports;var o=t[i]={exports:{}};return n[i](o,o.exports,r),o.exports}r.d=function(n,t){for(var i in t)r.o(t,i)&&!r.o(n,i)&&Object.defineProperty(n,i,{enumerable:!0,get:t[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"en",{value:!0})};var i={};return function(){r.r(i),r.d(i,{AES:function(){return j}});var n,t=r(9456),e=r(787),o=r(5693),u=r(9109),f=(n=function(t,r){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(t,r)},function(t,r){function i(){this.constructor=t}n(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}),c=function(){return(c=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},s=[],a=[],h=[],v=[],w=[],d=[],l=[],b=[],y=[],p=[];!function(){for(var n=[],t=0;t<256;t++)n[t]=t<128?t<<1:t<<1^283;var r=0,i=0;for(t=0;t<256;t++){var e=i^i<<1^i<<2^i<<3^i<<4;e=e>>>8^255&e^99,s[r]=e,a[e]=r;var o=n[r],u=n[o],f=n[u],c=257*n[e]^16843008*e;h[r]=c<<24|c>>>8,v[r]=c<<16|c>>>16,w[r]=c<<8|c>>>24,d[r]=c,c=16843009*f^65537*u^257*o^16843008*r,l[e]=c<<24|c>>>8,b[e]=c<<16|c>>>16,y[e]=c<<8|c>>>24,p[e]=c,r?(r=o^n[n[n[f^o]]],i^=n[n[i]]):r=i=1}}();var m=[0,1,2,4,8,16,32,64,128,27,54],j=function(n){function r(t){var r=n.call(this,t)||this;return r.on=0,r.un=[],r.fn=[],r.j=t,r.O(),r}return f(r,n),r.prototype.O=function(){var n;if(!this.on||this.cn!==this.Y){for(var t=this.cn=this.Y,r=t.words,i=t.nSigBytes/4,e=4*((this.on=i+6)+1),o=this.un=[],u=0;u<e;u++)u<i?o[u]=r[u]:(n=o[u-1],u%i?i>6&&u%i==4&&(n=s[n>>>24]<<24|s[n>>>16&255]<<16|s[n>>>8&255]<<8|s[255&n]):(n=s[(n=n<<8|n>>>24)>>>24]<<24|s[n>>>16&255]<<16|s[n>>>8&255]<<8|s[255&n],n^=m[u/i|0]<<24),o[u]=o[u-i]^n);this.fn=[];for(var f=0;f<e;f++){u=e-f;n=f%4?o[u]:o[u-4],this.fn[f]=f<4||u<=4?n:l[s[n>>>24]]^b[s[n>>>16&255]]^y[s[n>>>8&255]]^p[s[255&n]]}}},r.prototype.encryptBlock=function(n,t){this.sn(n,t,this.un,h,v,w,d,s)},r.prototype.decryptBlock=function(n,t){var r=n[t+1];n[t+1]=n[t+3],n[t+3]=r,this.sn(n,t,this.fn,l,b,y,p,a),r=n[t+1],n[t+1]=n[t+3],n[t+3]=r},r.prototype.sn=function(n,t,r,i,e,o,u,f){for(var c=this.on,s=n[t]^r[0],a=n[t+1]^r[1],h=n[t+2]^r[2],v=n[t+3]^r[3],w=4,d=1;d<c;d++){var l=i[s>>>24]^e[a>>>16&255]^o[h>>>8&255]^u[255&v]^r[w++],b=i[a>>>24]^e[h>>>16&255]^o[v>>>8&255]^u[255&s]^r[w++],y=i[h>>>24]^e[v>>>16&255]^o[s>>>8&255]^u[255&a]^r[w++],p=i[v>>>24]^e[s>>>16&255]^o[a>>>8&255]^u[255&h]^r[w++];s=l,a=b,h=y,v=p}var m=(f[s>>>24]<<24|f[a>>>16&255]<<16|f[h>>>8&255]<<8|f[255&v])^r[w++],j=(f[a>>>24]<<24|f[h>>>16&255]<<16|f[v>>>8&255]<<8|f[255&s])^r[w++],O=(f[h>>>24]<<24|f[v>>>16&255]<<16|f[s>>>8&255]<<8|f[255&a])^r[w++],g=(f[v>>>24]<<24|f[s>>>16&255]<<16|f[a>>>8&255]<<8|f[255&h])^r[w++];n[t]=m,n[t+1]=j,n[t+2]=O,n[t+3]=g},r.createEncryptor=function(n,i){return new r(c(c({},i=void 0===i?{}:i),{key:n,transformMode:t.t.ENC_TRANSFORM_MODE}))},r.createDecryptor=function(n,i){return new r(c(c({},i=void 0===i?{}:i),{key:n,transformMode:t.t.DEC_TRANSFORM_MODE}))},r.encrypt=function(n,t,i){if("string"==typeof t)return o.E.encrypt(r,n,t,i);if(t.nSigBytes%4!=0)throw new Error("Key size must be multiple of 32bit/4byte/1word");return u.D.encrypt(r,n,t,i)},r.decrypt=function(n,t,i){if("string"==typeof t)return o.E.decrypt(r,n,t,i);if(t.nSigBytes%4!=0)throw new Error("Key size must be multiple of 32bit/4byte/1word");return u.D.decrypt(r,n,t,i)},r.keySize=8,r}(e.G)}(),i}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/API.md
0 → 100644
| 1 | +## API | |
| 2 | +`jscrypto` supports crypto modules as well as `cryptojs`. | |
| 3 | + | |
| 4 | +### *Popular* | |
| 5 | +**Hash** [`MD5`][MD5], [`SHA1`][SHA1], [`SHA3`][SHA3], [`SHA224`][SHA224], [`SHA256`][SHA256], [`SHA384`][SHA384], [`SHA512`][SHA512], [`RIPEMD160`][RIPEMD160], | |
| 6 | +**Message/Key Hash** [`HMAC-MD5`][HMAC-MD5], [`HMAC-SHA224`][HMAC-SHA224], [`HMAC-SHA256`][HMAC-SHA256], [`HMAC-SHA384`][HMAC-SHA384], [`HMAC-SHA512`][HMAC-SHA512], [`GMAC`][GMAC], [`CBC-MAC`][CBC-MAC] | |
| 7 | +**Block Cipher** [`AES`][AES], [`DES`][DES], [`Triple-DES`][Triple-DES] | |
| 8 | + | |
| 9 | +### *Basic structure* | |
| 10 | +**Word** [`Word32Array`][Word32Array], [`Word64Array`][Word64Array] | |
| 11 | +**Encoder** [`Base64`][Base64], [`Hex`][Hex], [`Latin1`][Latin1], [`Utf8`][Utf8], [`Utf16`][Utf16] | |
| 12 | + | |
| 13 | +### *Misc* | |
| 14 | +**Stream Cipher** [`Rabbits`][Rabbits], [`RC4`][RC4], [`RC4Drop`][RC4Drop] | |
| 15 | +**Key Derive Function** [`OpenSSLKDF`][OpenSSLKDF], [`EvpKDF`][EvpKDF], [`PBKDF2`][PBKDF2] | |
| 16 | +**Block Cipher mode** [`CBC`][CBC], [`CFB`][CFB], [`CTR`][CTR], [`ECB`][ECB], [`OFB`][OFB], [`GCM`][GCM], [`CCM`][CCM] | |
| 17 | +**Block Padding** [`AnsiX923`][AnsiX923], [`ISO10126`][ISO10126], [`ISO97971`][ISO97971], [`NoPadding`][NoPadding], [`Pkcs7`][Pkcs7], [`Zero`][Zero] | |
| 18 | +**Formatter** [`OpenSSLFormatter`][OpenSSLFormatter] | |
| 19 | + | |
| 20 | +--- | |
| 21 | + | |
| 22 | +### Hash | |
| 23 | +#### General | |
| 24 | +Hash module can take both string/binary word as a hashing target. | |
| 25 | +```js | |
| 26 | +JsCrypto.SHA256.hash("string"); | |
| 27 | +// or | |
| 28 | +var w = new Word32Array([0x61626364]); // Binary representation of "abcd" | |
| 29 | +JsCrypt.SHA256.hash(w); | |
| 30 | +// or | |
| 31 | +// Byte array can be hashed. | |
| 32 | +// ArrayBuffer | Uint8Array | Int8Array | Uint8ClampedArray | Int16Array | Uint16Array | |
| 33 | +// Int32Array | Uint32Array | Float32Array | Float64Array | |
| 34 | +var w = new Word32Array(typedArray); | |
| 35 | +JsCrypt.SHA256.hash(w); | |
| 36 | +``` | |
| 37 | + | |
| 38 | +<h4 id='md5'>MD5</h4> | |
| 39 | + | |
| 40 | +```js | |
| 41 | +// MD.hash(string) | |
| 42 | +// Return value of 'hash' is Word32Array | |
| 43 | +var hashedWord = JsCrypto.MD5.hash("abc"); | |
| 44 | +hashedWord.toString(); // "900150983cd24fb0d6963f7d28e17f72" | |
| 45 | +hashedWord.toString(JsCrypto.Hex); // "900150983cd24fb0d6963f7d28e17f72" | |
| 46 | +hashedWord.toString(JsCrypto.Base64); // "kAFQmDzST7DWlj99KOF/cg==" | |
| 47 | + | |
| 48 | +// Binary words can be hashed as well. | |
| 49 | +// binary representation of "abc" | |
| 50 | +var w = new JsCrypto.Word32Array([0x61626300], 3); | |
| 51 | +var hashedWord = JsCrypto.MD5.hash(w); | |
| 52 | +hashedWord.toString(); // "900150983cd24fb0d6963f7d28e17f72" | |
| 53 | + | |
| 54 | +// binary representation of "abcd" | |
| 55 | +var w2 = new JsCrypto.Word32Array([0x61626364]); | |
| 56 | +var hashedWord = JsCrypto.MD5.hash(w2); | |
| 57 | +hashedWord.toString(); // "e2fc714c4727ee9395f324cd2e7f331f" | |
| 58 | + | |
| 59 | +// You can do gradual update | |
| 60 | +var md5 = new JsCrypto.MD5(""); | |
| 61 | +md5.update("a"); | |
| 62 | +md5.update("b"); | |
| 63 | +md5.update("c"); | |
| 64 | +var hashedWord = md5.finalize(); | |
| 65 | +hashedWord.toString(); // The same as Jscrypto.MD5.hash("abc").toString(); "900150983cd24fb0d6963f7d28e17f72" | |
| 66 | +``` | |
| 67 | + | |
| 68 | +<h4 id='sha1'>SHA1</h4> | |
| 69 | + | |
| 70 | +```js | |
| 71 | +// SHA1.hash(string) | |
| 72 | +var hashedWord = JsCrypto.SHA1.hash("abc"); // Return value of 'hash' is Word32Array | |
| 73 | +hashedWord.toString(); // "a9993e364706816aba3e25717850c26c9cd0d89d" | |
| 74 | +hashedWord.toString(JsCrypto.Hex); // "a9993e364706816aba3e25717850c26c9cd0d89d" | |
| 75 | +hashedWord.toString(JsCrypto.Base64); // "qZk+NkcGgWq6PiVxeFDCbJzQ2J0=" | |
| 76 | + | |
| 77 | +// Binary words can be hashed as well as MD5. See MD5 example above. | |
| 78 | +// You can do gradual update as well as MD5. See MD5 example above. | |
| 79 | +``` | |
| 80 | + | |
| 81 | +<h4 id='sha3'>SHA3</h4> | |
| 82 | + | |
| 83 | +```js | |
| 84 | +// SHA3.hash(string) | |
| 85 | +var hashedWord = JsCrypto.SHA3.hash("abc"); // Return value of 'hash' is Word32Array | |
| 86 | +hashedWord.toString(); // "18587dc2ea10...7aa511a9d00bb96" | |
| 87 | +hashedWord.toString(JsCrypto.Hex); // "18587dc2ea10...7aa511a9d00bb96" | |
| 88 | +hashedWord.toString(JsCrypto.Base64); // "GFh9wuoQa5oVY...plsZ13qlEanQC7lg==" | |
| 89 | + | |
| 90 | +// Binary words can be hashed as well as MD5. See MD5 example above. | |
| 91 | +// You can do gradual update as well as MD5. See MD5 example above. | |
| 92 | +``` | |
| 93 | + | |
| 94 | +<h4 id='sha224'>SHA224</h4> | |
| 95 | + | |
| 96 | +```js | |
| 97 | +// SHA224.hash(string) | |
| 98 | +var hashedWord = JsCrypto.SHA224.hash("abc"); // Return value of 'hash' is Word32Array | |
| 99 | +hashedWord.toString(); // "23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7" | |
| 100 | +hashedWord.toString(JsCrypto.Hex); // "23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7" | |
| 101 | +hashedWord.toString(JsCrypto.Base64); // "Iwl9IjQF2CKGQqR3vaJVsyqtvOS9oLP342ydpw==" | |
| 102 | + | |
| 103 | +// Binary words can be hashed as well as MD5. See MD5 example above. | |
| 104 | +// You can do gradual update as well as MD5. See MD5 example above. | |
| 105 | +``` | |
| 106 | + | |
| 107 | +<h4 id='sha256'>SHA256</h4> | |
| 108 | + | |
| 109 | +```js | |
| 110 | +// SHA256.hash(string) | |
| 111 | +var hashedWord = JsCrypto.SHA256.hash("abc"); // Return value of 'hash' is Word32Array | |
| 112 | +hashedWord.toString(); // "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" | |
| 113 | +hashedWord.toString(JsCrypto.Hex); // "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" | |
| 114 | +hashedWord.toString(JsCrypto.Base64); // "ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0=" | |
| 115 | + | |
| 116 | +// Binary words can be hashed as well as MD5. See MD5 example above. | |
| 117 | +// You can do gradual update as well as MD5. See MD5 example above. | |
| 118 | +``` | |
| 119 | + | |
| 120 | +<h4 id='sha384'>SHA384</h4> | |
| 121 | + | |
| 122 | +```js | |
| 123 | +// SHA384.hash(string) | |
| 124 | +var hashedWord = JsCrypto.SHA384.hash("abc"); // Return value of 'hash' is Word32Array | |
| 125 | +hashedWord.toString(); // "cb00753f45a35...2358baeca134c825a7" | |
| 126 | +hashedWord.toString(JsCrypto.Hex); // "cb00753f45a35...2358baeca134c825a7" | |
| 127 | +hashedWord.toString(JsCrypto.Base64); // "ywB1P0WjXou1oD1pm...croefMI1i67KE0yCWn" | |
| 128 | + | |
| 129 | +// Binary words can be hashed as well as MD5. See MD5 example above. | |
| 130 | +// You can do gradual update as well as MD5. See MD5 example above. | |
| 131 | +``` | |
| 132 | + | |
| 133 | +<h4 id='sha512'>SHA512</h4> | |
| 134 | + | |
| 135 | +```js | |
| 136 | +// SHA512.hash(string) | |
| 137 | +var hashedWord = JsCrypto.SHA512.hash("abc"); // Return value of 'hash' is Word32Array | |
| 138 | +hashedWord.toString(); // "ddaf35a19361...2a9ac94fa54ca49f" | |
| 139 | +hashedWord.toString(JsCrypto.Hex); // "ddaf35a19361...2a9ac94fa54ca49f" | |
| 140 | +hashedWord.toString(JsCrypto.Base64); // "3a81oZNherrMQXNJ...2Q86A4qmslPpUyknw==" | |
| 141 | + | |
| 142 | +// Binary words can be hashed as well as MD5. See MD5 example above. | |
| 143 | +// You can do gradual update as well as MD5. See MD5 example above. | |
| 144 | +``` | |
| 145 | + | |
| 146 | +<h4 id='ripemd160'>RIPEMD160</h4> | |
| 147 | + | |
| 148 | +```js | |
| 149 | +// RIPEMD160.hash(string) | |
| 150 | +var hashedWord = JsCrypto.RIPEMD160.hash("abc"); // Return value of 'hash' is Word32Array | |
| 151 | +hashedWord.toString(); // "8eb208f7e05d987a9b044a8e98c6b087f15a0bfc" | |
| 152 | +hashedWord.toString(JsCrypto.Hex); // "8eb208f7e05d987a9b044a8e98c6b087f15a0bfc" | |
| 153 | +hashedWord.toString(JsCrypto.Base64); // "jrII9+BdmHqbBEqOmMawh/FaC/w=" | |
| 154 | + | |
| 155 | +// Binary words can be hashed as well as MD5. See MD5 example above. | |
| 156 | +// You can do gradual update as well as MD5. See MD5 example above. | |
| 157 | +``` | |
| 158 | + | |
| 159 | +### Message/Key Hash | |
| 160 | +#### General | |
| 161 | +HMAC function can be generated from hash function as below. | |
| 162 | +```js | |
| 163 | +var hmacMD5 = new JsCrypto.Hmac(new JsCrypto.MD5(), "key"); | |
| 164 | +var words = hmacMD5.finalize("message"); | |
| 165 | +words.toString(); // "4e4748e62b463521f6775fbf921234b5" | |
| 166 | +// or | |
| 167 | +var hmacSHA1 = new JsCrypto.Hmac(new JsCrypto.SHA1(), "key"); | |
| 168 | +var words = hmacSHA1.finalize("message"); | |
| 169 | +words.toString(); // "2088df74d5f2146b48146caf4965377e9d0be3a4" | |
| 170 | +// or simply | |
| 171 | +JsCrypto.HmacSHA256("message", "key").toString(); // "6e9ef29b75fffc5b7ab...76917343065f58ed4a" | |
| 172 | + | |
| 173 | +``` | |
| 174 | + | |
| 175 | +<h4 id='hmac-md5'>HMAC-MD5</h4> | |
| 176 | + | |
| 177 | +```js | |
| 178 | +var hashedWord = JsCrypto.HmacMD5("message", "key"); | |
| 179 | +hashedWord.toString(); // "4e4748e62b463521f6775fbf921234b5" | |
| 180 | +hashedWord.toString(JsCrypto.Base64); // "TkdI5itGNSH2d1+/khI0tQ==" | |
| 181 | + | |
| 182 | +// Binary message can be hashed. | |
| 183 | +// Binary representation of "message" | |
| 184 | +var message = new JsCrypto.Word32Array([0x6d657373, 0x61676500], 7); | |
| 185 | +var hashedWord = JsCrypto.HmacMD5(message, "key"); | |
| 186 | +hashedWord.toString(); // "4e4748e62b463521f6775fbf921234b5" | |
| 187 | + | |
| 188 | +// Key also can be a binary | |
| 189 | +// Binary representation of "message" | |
| 190 | +var message = new JsCrypto.Word32Array([0x6d657373, 0x61676500], 7); | |
| 191 | +// Binary representation of "key" | |
| 192 | +var key = new JsCrypto.Word32Array([0x6b657900], 3); | |
| 193 | +var hashedWord = JsCrypto.HmacMD5(message, key); | |
| 194 | +hashedWord.toString(); // "4e4748e62b463521f6775fbf921234b5" | |
| 195 | + | |
| 196 | +// Gradual update | |
| 197 | +var hmacMD5 = new JsCrypto.Hmac(new JsCrypto.MD5(), "key"); | |
| 198 | +hmacMD5.update("me"); | |
| 199 | +hmacMD5.update("ss"); | |
| 200 | +hmacMD5.update("ag"); | |
| 201 | +var w = hmacMD5.finalize("e"); | |
| 202 | +w.toString(); // "4e4748e62b463521f6775fbf921234b5" | |
| 203 | +``` | |
| 204 | + | |
| 205 | +<h4 id='hmac-sha224'>HMAC-SHA224</h4> | |
| 206 | + | |
| 207 | +```js | |
| 208 | +var hashedWord = JsCrypto.HmacSHA224("message", "key"); | |
| 209 | +hashedWord.toString(); // "a0b5eecae3f74f0561a8da6f389f78f1a3895c8c183c31c1756d7925" | |
| 210 | +hashedWord.toString(JsCrypto.Base64); // "oLXuyuP3TwVhqNpvOJ948aOJXIwYPDHBdW15JQ==" | |
| 211 | + | |
| 212 | +// Binary message can be hashed as well as HMAC-MD5. See HMAC-MD5 example above. | |
| 213 | +// Key also can be a binary as well as HMAC-MD5. See HMAC-MD5 example above. | |
| 214 | +// Can Gradual update as well as HMAC-MD5. See HMAC-MD5 example above. | |
| 215 | +``` | |
| 216 | + | |
| 217 | +<h4 id='hmac-sha256'>HMAC-SHA256</h4> | |
| 218 | + | |
| 219 | +```js | |
| 220 | +var hashedWord = JsCrypto.HmacSHA256("message", "key"); | |
| 221 | +hashedWord.toString(); // "6e9ef29b75fffc5b7abae527d58fdadb2fe42e7219011976917343065f58ed4a" | |
| 222 | +hashedWord.toString(JsCrypto.Base64); // "bp7ym3X//Ft6uuUn1Y/a2y/kLnIZARl2kXNDBl9Y7Uo=" | |
| 223 | + | |
| 224 | +// Binary message can be hashed as well as HMAC-MD5. See HMAC-MD5 example above. | |
| 225 | +// Key also can be a binary as well as HMAC-MD5. See HMAC-MD5 example above. | |
| 226 | +// Can Gradual update as well as HMAC-MD5. See HMAC-MD5 example above. | |
| 227 | +``` | |
| 228 | + | |
| 229 | +<h4 id='hmac-sha384'>HMAC-SHA384</h4> | |
| 230 | + | |
| 231 | +```js | |
| 232 | +var hashedWord = JsCrypto.HmacSHA384("message", "key"); | |
| 233 | +hashedWord.toString(); // "0fd3ae3237be98c64a075...544b9062c773b2d86f" | |
| 234 | +hashedWord.toString(JsCrypto.Base64); // "D9OuMje+m...EuQYsdzsthv" | |
| 235 | + | |
| 236 | +// Binary message can be hashed as well as HMAC-MD5. See HMAC-MD5 example above. | |
| 237 | +// Key also can be a binary as well as HMAC-MD5. See HMAC-MD5 example above. | |
| 238 | +// Can Gradual update as well as HMAC-MD5. See HMAC-MD5 example above. | |
| 239 | +``` | |
| 240 | + | |
| 241 | +<h4 id='hmac-sha512'>HMAC-SHA512</h4> | |
| 242 | + | |
| 243 | +```js | |
| 244 | +var hashedWord = JsCrypto.HmacSHA512("message", "key"); | |
| 245 | +hashedWord.toString(); // ""e477384d7ca2...16810fa367e98" | |
| 246 | +hashedWord.toString(JsCrypto.Base64); // "5Hc4TXyiKd0UJuZ...xp9NdbQ0IWgQ+jZ+mA==" | |
| 247 | + | |
| 248 | +// Binary message can be hashed as well as HMAC-MD5. See HMAC-MD5 example above. | |
| 249 | +// Key also can be a binary as well as HMAC-MD5. See HMAC-MD5 example above. | |
| 250 | +// Can Gradual update as well as HMAC-MD5. See HMAC-MD5 example above. | |
| 251 | +``` | |
| 252 | + | |
| 253 | +<h4 id='gmac'>GMAC</h4> | |
| 254 | + | |
| 255 | +Default Cipher: `AES`. | |
| 256 | +If you do not supply `iv` to GMAC, `iv` is initialized to 0^128. (128bit 0s) | |
| 257 | +```js | |
| 258 | +var message = JsCrypto.Hex.parse("1063509E5A672C092CAD0B1DC6CE009A61AAAAAAAAAAAA"); | |
| 259 | +var key = JsCrypto.Hex.parse("55804F3AEB4E914DC91255944A1F565A"); | |
| 260 | +var iv = JsCrypto.Hex.parse("BBBBBBBBBBBBBBBBBBBBBBBB"); // 96bit(12byte) iv is recommended. | |
| 261 | +var tagLength = 8; // 8byte. Optional. If omitted, tagLength will be set to 16(byte). | |
| 262 | + | |
| 263 | +var authTagWord = JsCrypto.GMAC(message, key, iv, tagLength); | |
| 264 | +authTagWord.toString(); // 44c955d637994285 | |
| 265 | +authTagWord.toString(JsCrypto.Base64); // "RMlV1jeZQoU=" | |
| 266 | +``` | |
| 267 | + | |
| 268 | +<h4 id='cbc-mac'>CBC-MAC</h4> | |
| 269 | + | |
| 270 | +Default Cipher: `AES`. | |
| 271 | +If you set `Nonce` below to falsy value like `null|undefined|0`, Nonce will be reset to `new Word32Array([0, 0], 8);` (64bit/8byte 0s). | |
| 272 | + | |
| 273 | +Please note that there are many implementations of CBC-MAC in the world. Some implementation says CBC-MAC is just | |
| 274 | +the final processed block of CBC with iv=0. | |
| 275 | +So you need to take extra care what implementation is used if you are just told to "Go get Message-Authentication-Code with CBC-MAC". | |
| 276 | +For `jscrypto`, it implements `CBC-MAC` so that it satisfies [NIST 800-38C specification and its test vectors](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38c.pdf). | |
| 277 | + | |
| 278 | +For additional description, [please read this](#note-for-ccm-implementation). | |
| 279 | + | |
| 280 | +```js | |
| 281 | +var Plaintext = JsCrypto.Hex.parse("20212223"); | |
| 282 | +var Message = JsCrypto.Hex.parse("0001020304050607"); | |
| 283 | +var Key = JsCrypto.Hex.parse("404142434445464748494a4b4c4d4e4f"); | |
| 284 | +var Nonce = undefined; // Nonce/iv shouldn't be used. Always set to be `undefined` or `new Word32Array([0,0], 8)` | |
| 285 | +var tagLength = 32/8; // 32bit = 4byte | |
| 286 | + | |
| 287 | +var authTagWord = JsCrypto.CBCMAC(Plaintext, Message, Key, Nonce, tagLength); | |
| 288 | +authTagWord.toString(); // "9bd4029e" | |
| 289 | +``` | |
| 290 | + | |
| 291 | +### Block Cipher | |
| 292 | + | |
| 293 | +<h4 id="aes">AES</h4> | |
| 294 | + | |
| 295 | +Default block cipher mode: `CBC` | |
| 296 | +Default padding: `Pkcs7` | |
| 297 | + | |
| 298 | +```js | |
| 299 | +//////////////////////////////////////////////////////////////////////////////////////// | |
| 300 | +// Encrypt/Decrypt string without specifying salt. (Salt is randomly chosen at runtime) | |
| 301 | +// *Salt is used to convert string password to binary key. | |
| 302 | +//////////////////////////////////////////////////////////////////////////////////////// | |
| 303 | +// Default block cipher mode is CBC, pad is Pkcs7. | |
| 304 | +// Random base64 string which contains encrypted message and 'random' salt for kdf. | |
| 305 | +var encryptedData = JsCrypto.AES.encrypt("message", "key").toString(); | |
| 306 | +// Binary data is returned as Word32Array. | |
| 307 | +var decryptedData = JsCrypto.AES.decrypt(encryptedData, "key"); | |
| 308 | +decryptedData.toString(JsCrypto.Utf8); // "message" | |
| 309 | + | |
| 310 | +//////////////////////////////////////////////////////////////////////////////////////// | |
| 311 | +// Encrypt/Decrypt string with pre-defined kdf salt. | |
| 312 | +//////////////////////////////////////////////////////////////////////////////////////// | |
| 313 | +var kdfSalt = new JsCrypto.Word32Array([0x00112233, 0x44556677]); // Or JsCrypto.Hex.parse("0011223344556677") | |
| 314 | +// Always "U2FsdGVkX18AESIzRFVmd1MuEw84PQjNhlcGD3AQzJg=" because salt for kdf is fixed. | |
| 315 | +var encryptedData = JsCrypto.AES.encrypt("message", "key", {kdfSalt: kdfSalt}).toString(); | |
| 316 | +// Binary data is returned as Word32Array. | |
| 317 | +var decryptedData = JsCrypto.AES.decrypt(encryptedData, "key"); | |
| 318 | +decryptedData.toString(JsCrypto.Utf8); // "message" | |
| 319 | + | |
| 320 | +//////////////////////////////////////////////////////////////////////////////////////// | |
| 321 | +// Encrypt/Decrypt string with binary key. | |
| 322 | +//////////////////////////////////////////////////////////////////////////////////////// | |
| 323 | +// key lenght must be multiple of 32bit=4byte=1word. (32/64/96/128/160/192/224/256bit key supported for AES) | |
| 324 | +var key = JsCrypto.Hex.parse("00112233445566778899aabbccddeeff"); // 16byte = 128bit key | |
| 325 | +// Always "dwhN2ILLN9QJD+BQr0kcsw==" because of a fixed key. | |
| 326 | +var encryptedData = JsCrypto.AES.encrypt("message", key).toString(); | |
| 327 | +// Binary data is returned as Word32Array. | |
| 328 | +var decryptedData = JsCrypto.AES.decrypt(encryptedData, key); | |
| 329 | +decryptedData.toString(JsCrypto.Utf8); // "message" | |
| 330 | + | |
| 331 | +//////////////////////////////////////////////////////////////////////////////////////// | |
| 332 | +// When you want to store/copy encrypted data somewhere, be sure to have 'stringified' data. | |
| 333 | +// Don't save 'encryptedDataObj' below, because this contains encryption key itself. | |
| 334 | +//////////////////////////////////////////////////////////////////////////////////////// | |
| 335 | +// Always 'stringify' this 'encryptedDataObj' then port it anywhere. | |
| 336 | +var encryptedDataObj = JsCrypto.AES.encrypt("message", "key"); | |
| 337 | +// Return value of 'toString()' is a Base64 string containing only encrypted data and kdf salt | |
| 338 | +var encryptedData = encryptedDataObj.toString(); | |
| 339 | + | |
| 340 | +//////////////////////////////////////////////////////////////////////////////////////// | |
| 341 | +// Encrypt not only a string but also binary data(ArrayBuffer, Uint8Array, etc) | |
| 342 | +//////////////////////////////////////////////////////////////////////////////////////// | |
| 343 | +const fileElement = document.querySelector("input[type='file']"); | |
| 344 | +const file = fileElement.files[0]; | |
| 345 | +const reader = new FileReader(); | |
| 346 | +reader.onload = function(e){ | |
| 347 | + const arrayBuffer = reader.result; | |
| 348 | + const binaryWord = new JsCrypto.Word32Array(arrayBuffer); | |
| 349 | + const encryptedData = JsCrypto.AES.encrypt(binaryWord, "password").toString(); | |
| 350 | + | |
| 351 | + // Store it to localStorage, etc. | |
| 352 | + localStorage.setItem("secretFile", encryptedData); | |
| 353 | + | |
| 354 | + // You can decrypt it like below | |
| 355 | + // Returned value is Word32Array | |
| 356 | + const decryptedData = JsCrypto.AES.decrypt(encryptedData, "password"); | |
| 357 | + // Word32Array can be turned to Uint8Array. | |
| 358 | + const decryptedFile = decryptedData.toUint8Array(); | |
| 359 | + // You can then convert it to ArrayBuffer; | |
| 360 | + const decryptedFileArrayBuffer = decryptedFile.buffer; | |
| 361 | +}; | |
| 362 | +reader.readAsArrayBuffer(file); | |
| 363 | + | |
| 364 | +//////////////////////////////////////////////////////////////////////////////////////// | |
| 365 | +// Options for block cipher like AES. | |
| 366 | +//////////////////////////////////////////////////////////////////////////////////////// | |
| 367 | +// CBC/ECB/CTR/OFB/CFB is the options. CBC is the default. | |
| 368 | +var mode = JsCrypto.mode.CBC; | |
| 369 | +// AnsiX923/ISO10126/ISO97971/Pkcs7/NoPadding/Zero is the options. Pkcs7 is the default. | |
| 370 | +var padding = JsCrypto.pad.Pkcs7; | |
| 371 | +// PBKDF2/EvpKDF is the options. PBKDF2 is the default. | |
| 372 | +var kdfModule = JsCrypto.PBKDF2; | |
| 373 | +// MD5/SHA1/SHA3/SHA224/SHA256/SHA384/SHA512/RIPEMD160 is the options. SHA256 is the default | |
| 374 | +var kdfHasher = JsCrypto.SHA256; | |
| 375 | +// 10000 is the default value. | |
| 376 | +var kdfIterations = 10000; | |
| 377 | +// Salt used in key derivation. If omitted, salt is randomly chosen. Random generation is strongly recommended. | |
| 378 | +var kdfSalt = JsCrypto.Hex.parse("daefe2565e3c4680"); | |
| 379 | +var aesProps = {mode, padding, kdfModule, kdfSalt, kdfHasher, kdfIterations}; | |
| 380 | + | |
| 381 | +var cipherParams = JsCrypto.AES.encrypt("message", "password", aesProps); | |
| 382 | +// Gets "U2FsdGVkX1/a7+JWXjxGgCXR5T2J97jwBZAKtZNXZI4=". OpenSSL compatible format. See detail in OpenSSLFormatter section. | |
| 383 | +var encryptedData = cipherParams.toString(); | |
| 384 | + | |
| 385 | +var decrypted = JsCrypto.AES.decrypt(encryptedData, "password", aesProps); | |
| 386 | +decrypted.toString(JsCrypto.Utf8); // "message" | |
| 387 | +``` | |
| 388 | + | |
| 389 | +When you supply encryption key as a string password, it automatically generates 256bit key for encryption. (AES-256). | |
| 390 | + | |
| 391 | +<h4 id="des">DES</h4> | |
| 392 | + | |
| 393 | + | |
| 394 | +Default block cipher mode: `CBC` | |
| 395 | +Default padding: `Pkcs7` | |
| 396 | + | |
| 397 | +```js | |
| 398 | +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 399 | +// Encrypt/Decrypt string without specifying salt. (Salt is randomly chosen at runtime) | |
| 400 | +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 401 | +// Default block cipher mode is CBC, pad is Pkcs7. | |
| 402 | +// Random base64 string which contains encrypted message and 'random' salt. | |
| 403 | +var encryptedData = JsCrypto.DES.encrypt("message", "key").toString(); | |
| 404 | +// Binary data is returned as Word32Array. | |
| 405 | +var decryptedData = JsCrypto.DES.decrypt(encryptedData, "key"); | |
| 406 | +// Specify encoding and you get "message" | |
| 407 | +decryptedData.toString(JsCrypto.Utf8); | |
| 408 | + | |
| 409 | +// For additinal feature, please see AES example and replace 'AES' to 'DES'. | |
| 410 | +``` | |
| 411 | + | |
| 412 | +<h4 id="des3">Triple-DES</h4> | |
| 413 | + | |
| 414 | + | |
| 415 | +Default block cipher mode: `CBC` | |
| 416 | +Default padding: `Pkcs7` | |
| 417 | + | |
| 418 | +Triple-DES requires the key length to be 64, 128, 192 or >192bit. | |
| 419 | +If string key is provided, it is automaically converted to 192bit key by key derivation function. | |
| 420 | + | |
| 421 | +```js | |
| 422 | +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 423 | +// Encrypt/Decrypt string without specifying salt. (Salt is randomly chosen at runtime) | |
| 424 | +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 425 | +// Default block cipher mode is CBC, pad is Pkcs7. | |
| 426 | +// Random base64 string which contains encrypted message and 'random' salt. | |
| 427 | +var encryptedData = JsCrypto.DES3.encrypt("message", "key").toString(); | |
| 428 | +// Binary data is returned as Word32Array. | |
| 429 | +var decryptedData = JsCrypto.DES3.decrypt(encryptedData, "key"); | |
| 430 | +// Specify encoding and you get "message" | |
| 431 | +decryptedData.toString(JsCrypto.Utf8); | |
| 432 | + | |
| 433 | +// For additinal feature, please see AES example and replace 'AES' to 'DES3'. | |
| 434 | +``` | |
| 435 | + | |
| 436 | +### Word | |
| 437 | +The basic instance holding binary value. | |
| 438 | +<h4 id='word32array'>Word32Array</h4> | |
| 439 | + | |
| 440 | +```js | |
| 441 | +// Example of Word32Array constructor. | |
| 442 | +// Given 'new Word32Array(A, B)', A: array of 32bit word, B: the number of significant bytes. | |
| 443 | + | |
| 444 | +// Binary representation of "abcdefgh" | |
| 445 | +var abcdefgh = new JsCrypto.Word32Array([0x61626364, 0x65666768]); | |
| 446 | +// Binary representation of "abcdefg" | |
| 447 | +var abcdefg = new JsCrypto.Word32Array([0x61626364, 0x65666768], 7); | |
| 448 | +// Binary representation of "abcdef" | |
| 449 | +var abcdef = new JsCrypto.Word32Array([0x61626364, 0x65666768], 6); | |
| 450 | +// Binary representation of "abcd" | |
| 451 | +var abcd = new JsCrypto.Word32Array([0x61626364, 0x65666768], 4); | |
| 452 | +// This also represents "abcd" | |
| 453 | +var abcd2 = new JsCrypto.Word32Array([0x61626364]); | |
| 454 | + | |
| 455 | +// Example of stringify | |
| 456 | +var w = new JsCrypto.Word32Array([0x1234567, 0x89abcdef]); | |
| 457 | +// Word32Array.toString(encoder?: IEncoder) | |
| 458 | +w.toString(); // "0123456789abcdef" | |
| 459 | +w.toString(JsCrypto.Hex); // "0123456789abcdef" | |
| 460 | +w.toString(JsCrypto.Base64); // "ASNFZ4mrze8=" | |
| 461 | + | |
| 462 | +// Word32Array can be genereated from parser. | |
| 463 | +// The same as 'new Word32Array([0x01234567, 0x89abcdef])' | |
| 464 | +JsCrypto.Hex.parse("0123456789abcdef"); | |
| 465 | +// The same as 'new Word32Array([0x01234567, 0x89abcdef])' | |
| 466 | +JsCrypto.Base64.parse("ASNFZ4mrze8="); | |
| 467 | +// The same as 'new Word32Array([0x61626364])' | |
| 468 | +JsCrypto.Utf8.parse("abcd"); | |
| 469 | +``` | |
| 470 | + | |
| 471 | +<h4 id='word64array'>Word64Array</h4> | |
| 472 | + | |
| 473 | +```js | |
| 474 | +var w1 = new Word64Array([new Word64(0x00010203, 0x04050607)]); | |
| 475 | +w1.toString(); // "0001020304050607" | |
| 476 | +w1.nSigBytes; // 8 | |
| 477 | + | |
| 478 | +var w2 = w1.to32(); | |
| 479 | +w2.toString(); // "0001020304050607" | |
| 480 | +w2.nSigBytes; // 8 | |
| 481 | +``` | |
| 482 | + | |
| 483 | +### Encoder | |
| 484 | +<h4 id='base64'>Base64</h4> | |
| 485 | + | |
| 486 | +```js | |
| 487 | + var w = new JsCrypto.Word32Array([0x00000000]); | |
| 488 | + | |
| 489 | +// Base64.stringify | |
| 490 | +JsCrypto.Base64.stringify(w); // "AAAAAA==" | |
| 491 | +// or | |
| 492 | +w.toString(JsCrypto.Base64); // "AAAAAA==" | |
| 493 | + | |
| 494 | +// Base64.parse | |
| 495 | +JsCrypto.Base64.parse("AAAAAA=="); // Word32Array. 0x00000000 | |
| 496 | +JsCrypto.Base64.parse("AAAAAA==").toString(); // "00000000" | |
| 497 | +``` | |
| 498 | + | |
| 499 | +<h4 id='hex'>Hex</h4> | |
| 500 | + | |
| 501 | +```js | |
| 502 | + var w = new JsCrypto.Word32Array([0x00102030]); | |
| 503 | + | |
| 504 | +// Hex.stringify | |
| 505 | +JsCrypto.Hex.stringify(w); // "00102030" | |
| 506 | +// or | |
| 507 | +w.toString(JsCrypto.Hex); // "00102030" | |
| 508 | + | |
| 509 | +// Hex.parse | |
| 510 | +JsCrypto.Hex.parse("00102030"); // Word32Array. 0x00102030 | |
| 511 | +JsCrypto.Hex.parse("00102030").toString(); // "00102030" | |
| 512 | +``` | |
| 513 | + | |
| 514 | +<h4 id='latin1'>Latin1</h4> | |
| 515 | + | |
| 516 | +```js | |
| 517 | + var w = new JsCrypto.Word32Array([0x616263ff]); | |
| 518 | + | |
| 519 | +// Latin1.stringify | |
| 520 | +JsCrypto.Latin1.stringify(w); // "abcÿ" | |
| 521 | +// or | |
| 522 | +w.toString(JsCrypto.Latin1); // "abcÿ" | |
| 523 | + | |
| 524 | +// Latin1.parse | |
| 525 | +JsCrypto.Latin1.parse("abcÿ"); // Word32Array. 0x616263ff | |
| 526 | +JsCrypto.Latin1.parse("abcÿ").toString(); // "616263ff" | |
| 527 | +``` | |
| 528 | + | |
| 529 | +<h4 id='utf8'>UTF-8</h4> | |
| 530 | + | |
| 531 | +```js | |
| 532 | + var w = new JsCrypto.Word32Array([0xe3818200 | 0x00000061]); // e3-81-82 -> あ, 61 -> a | |
| 533 | + | |
| 534 | +// Utf8.stringify | |
| 535 | +JsCrypto.Utf8.stringify(w); // "あa" | |
| 536 | +// or | |
| 537 | +w.toString(JsCrypto.Utf8); // "あa" | |
| 538 | + | |
| 539 | +// Outside utf-8 code space cannot be stringified | |
| 540 | +JsCrypto.Utf8.stringify(new JsCrypto.Word32Array([0x00aabbcc])); // Uncaught Error: Malformed UTF-8 data | |
| 541 | + | |
| 542 | +// Utf8.parse | |
| 543 | +JsCrypto.Utf8.parse("あa"); // Word32Array. 0xe3818261 | |
| 544 | +JsCrypto.Utf8.parse("あa").toString(); // "e3818261" | |
| 545 | +``` | |
| 546 | + | |
| 547 | +<h4 id='utf16'>UTF-16</h4> | |
| 548 | + | |
| 549 | +```js | |
| 550 | +var w = new JsCrypto.Word32Array([0x30423044]); // 0x3042 = あ, 0x3044 = い in UTF-16 | |
| 551 | + | |
| 552 | +// Utf16.stringify | |
| 553 | +JsCrypto.Utf16.stringify(w); // "あい" | |
| 554 | +// or | |
| 555 | +w.toString(JsCrypto.Utf16); // "あい" | |
| 556 | + | |
| 557 | +// Utf16.parse | |
| 558 | +JsCrypto.Utf16.parse("あい"); // Word32Array. 0x30423044 | |
| 559 | +JsCrypto.Utf16.parse("あい").toString(); // "30423044" | |
| 560 | +``` | |
| 561 | + | |
| 562 | +### Stream Cipher | |
| 563 | +<h4 id='rabbits'>Rabbits</h4> | |
| 564 | + | |
| 565 | +```js | |
| 566 | +// Encrypt | |
| 567 | +var message = JsCrypto.Hex.parse("00000000000000000000000000000000"); | |
| 568 | +var key = JsCrypto.Hex.parse("00000000000000000000000000000000"); | |
| 569 | +var encrypted = JsCrypto.Rabbit.encrypt(message, key).toString(); // "AvdKHCZFa/Xs1qU28FRXsQ==" | |
| 570 | +// Decrypt | |
| 571 | +var word = JsCrypto.Rabbit.decrypt(encrypted, key); | |
| 572 | +word.toString(); // "00000000000000000000000000000000" | |
| 573 | +``` | |
| 574 | + | |
| 575 | +<h4 id='rc4'>RC4</h4> | |
| 576 | + | |
| 577 | +```js | |
| 578 | +// Encrypt | |
| 579 | +var message = JsCrypto.Hex.parse("0000000000000000"); // word32array | |
| 580 | +var key = JsCrypto.Hex.parse("0123456789abcdef"); // word32array | |
| 581 | +var encrypted = JsCrypto.RC4.encrypt(message, key).toString(); // "AvdKHCZFa/Xs1qU28FRXsQ==" | |
| 582 | +// Decrypt | |
| 583 | +var word = JsCrypto.RC4.decrypt(encrypted, key); | |
| 584 | +word.toString(); // "0000000000000000" | |
| 585 | +``` | |
| 586 | + | |
| 587 | +<h4 id='rc4drop'>RC4Drop</h4> | |
| 588 | + | |
| 589 | +```js | |
| 590 | +// Encrypt | |
| 591 | +var encrypted = JsCrypto.RC4Drop.encrypt("Message", "Secret Passphrase", { drop: 3072/4 }); | |
| 592 | +// Decrypt | |
| 593 | +var decrypted = JsCrypto.RC4Drop.decrypt(encrypted, "Secret Passphrase", { drop: 3072/4 }); | |
| 594 | +decrypted.toString(JsCrypto.Utf8); // "Message" | |
| 595 | +``` | |
| 596 | + | |
| 597 | +### Key Derivation Function | |
| 598 | +<h4 id='opensslkdf'>OpenSSLKDF</h4> | |
| 599 | + | |
| 600 | +String password cannot be used to crypto modules as it is. | |
| 601 | +It is automatically converted to a byte array in a crypto module by key derivation function. | |
| 602 | +You can generate binary key with Key Derivation Function by yourself, as described here. | |
| 603 | + | |
| 604 | +```js | |
| 605 | +// OpenSSLKDF returns both key/iv. | |
| 606 | +var keySize = 256/32; // 256bit -> 32byte -> 8words | |
| 607 | +var ivSize = 128/32; // 128bit -> 16byte -> 4words | |
| 608 | +var salt = JsCrypto.Hex.parse("0a9d8620cf7219f1"); | |
| 609 | +var derivedParams = JsCrypto.OpenSSLKDF.execute("password", keySize, ivSize, salt); | |
| 610 | + | |
| 611 | +// "50f32e0ec9408e02ff42364a52aac95c3694fc027256c6f488bf84b8e60effcd"; | |
| 612 | +derivedParams.key.toString(); | |
| 613 | +// "81381e39b94fd692dff7e2239a298cb6"; | |
| 614 | +derivedParams.iv.toString(); | |
| 615 | +// "0a9d8620cf7219f1" | |
| 616 | +derivedParams.salt.toString(); | |
| 617 | +``` | |
| 618 | + | |
| 619 | +<h4 id='evpkdf'>EvpKDF</h4> | |
| 620 | + | |
| 621 | +```js | |
| 622 | +// Generate 192bit key | |
| 623 | +// https://www.openssl.org/docs/man1.1.1/man3/EVP_BytesToKey.html | |
| 624 | +// Return value is Word32Array. | |
| 625 | +var keySize = 192/32; // 192bit -> 6 words | |
| 626 | +var key = EvpKDF.getKey("password", "saltsalt", {keySize: keySize}); | |
| 627 | +``` | |
| 628 | + | |
| 629 | +<h4 id='pbkdf2'>PBKDF2</h4> | |
| 630 | + | |
| 631 | +```js | |
| 632 | +// Generate 256bit key with 1200 iterations. | |
| 633 | +// Password-Based Key Derivation Function 2 algorithm. | |
| 634 | +// Return value is Word32Array. | |
| 635 | +var key = PBKDF2.getKey("password", "saltsalt", {keySize: 256/32, iterations: 1200}); | |
| 636 | +``` | |
| 637 | + | |
| 638 | + | |
| 639 | +### Block Cipher mode | |
| 640 | +<h4 id='cbc'>CBC</h4> | |
| 641 | + | |
| 642 | +[Cipher Block Chaining](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Cipher_block_chaining_(CBC)) | |
| 643 | +**\*CBC requires encrypting data size to be padded to multiple of block size.** (Default block size is 128bits = 16bytes = 4words). | |
| 644 | +This is the default Block cipher mode for AES/DES/Triple-DES. | |
| 645 | +```js | |
| 646 | +var message = JsCrypto.Utf8.parse("message"); // 7bytes. Padding is required. | |
| 647 | +var key = new JsCrypto.Word32Array([0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f]); | |
| 648 | +var iv = new JsCrypto.Word32Array([0x30313233, 0x34353637, 0x38393a3b, 0x3c3d3e3f]); | |
| 649 | + | |
| 650 | +var CBC = JsCrypto.mode.CBC; | |
| 651 | +var Pkcs7 = JsCrypto.pad.Pkcs7; // Don't use 'JsCrypto.NoPadding' unless message size is multiple of 4 words. | |
| 652 | +var encrypted = JsCrypto.AES.encrypt(message, key, { iv: iv, mode: CBC, padding: Pkcs7 }); | |
| 653 | +var decrypted = JsCrypto.AES.decrypt(encrypted, key, { iv: iv, mode: CBC, padding: Pkcs7 }); | |
| 654 | +decrypted.toString(JsCrypto.Utf8); // "message" | |
| 655 | + | |
| 656 | +// If encrypting data is multiple of 16bytes, padding is not required. | |
| 657 | +var message = JsCrypto.Utf8.parse("encrypt--message"); // 16bytes. NoPadding is allowed. | |
| 658 | +var key = new JsCrypto.Word32Array([0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f]); | |
| 659 | +var iv = new JsCrypto.Word32Array([0x30313233, 0x34353637, 0x38393a3b, 0x3c3d3e3f]); | |
| 660 | + | |
| 661 | +var CBC = JsCrypto.mode.CBC; | |
| 662 | +var NoPadding = JsCrypto.pad.NoPadding; | |
| 663 | +var encrypted = JsCrypto.AES.encrypt(message, key, { iv: iv, mode: CBC, padding: NoPadding }); | |
| 664 | +var decrypted = JsCrypto.AES.decrypt(encrypted, key, { iv: iv, mode: CBC, padding: NoPadding }); | |
| 665 | +decrypted.toString(JsCrypto.Utf8); // "encrypt--message" | |
| 666 | +``` | |
| 667 | + | |
| 668 | +<h4 id='cfb'>CFB</h4> | |
| 669 | + | |
| 670 | +[Cipher Feedback](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Cipher_feedback_(CFB)) | |
| 671 | +Unlike CBC, padding is not required. | |
| 672 | +```js | |
| 673 | +var message = JsCrypto.Utf8.parse("message"); // 7bytes. | |
| 674 | +var key = new JsCrypto.Word32Array([0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f]); | |
| 675 | +var iv = new JsCrypto.Word32Array([0x30313233, 0x34353637, 0x38393a3b, 0x3c3d3e3f]); | |
| 676 | + | |
| 677 | +var CFB = JsCrypto.mode.CFB; | |
| 678 | +var NoPadding = JsCrypto.pad.NoPadding; | |
| 679 | +var encrypted = JsCrypto.AES.encrypt(message, key, { iv: iv, mode: CFB, padding: NoPadding }); | |
| 680 | +var decrypted = JsCrypto.AES.decrypt(encrypted, key, { iv: iv, mode: CFB, padding: NoPadding }); | |
| 681 | +decrypted.toString(JsCrypto.Utf8); // "message" | |
| 682 | +``` | |
| 683 | + | |
| 684 | +<h4 id='ctr'>CTR</h4> | |
| 685 | + | |
| 686 | +[Counter](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Counter_(CTR)) | |
| 687 | +This CTR mode does not require data to be padded. | |
| 688 | +```js | |
| 689 | +var message = JsCrypto.Utf8.parse("message"); // 7bytes. | |
| 690 | +var key = new JsCrypto.Word32Array([0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f]); | |
| 691 | +var iv = new JsCrypto.Word32Array([0x30313233, 0x34353637, 0x38393a3b, 0x3c3d3e3f]); | |
| 692 | + | |
| 693 | +var CTR = JsCrypto.mode.CTR; | |
| 694 | +var NoPadding = JsCrypto.pad.NoPadding; | |
| 695 | +var encrypted = JsCrypto.AES.encrypt(message, key, { iv: iv, mode: CTR, padding: NoPadding }); | |
| 696 | +var decrypted = JsCrypto.AES.decrypt(encrypted, key, { iv: iv, mode: CTR, padding: NoPadding }); | |
| 697 | +decrypted.toString(JsCrypto.Utf8); // "message" | |
| 698 | +``` | |
| 699 | + | |
| 700 | +<h4 id='ecb'>ECB</h4> | |
| 701 | + | |
| 702 | +[Electronic Code Block](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Electronic_codebook_(ECB)) | |
| 703 | +The simplest of the encryption modes. **Padding is required as well as CBC** | |
| 704 | +Because ECB encrypts identical plaintext blocks into identical ciphertext blocks, it does not hide data patterns well. | |
| 705 | +ECB is not recommended for use in cryptographic protocols | |
| 706 | +```js | |
| 707 | +var message = JsCrypto.Utf8.parse("message"); // 7bytes. Padding is required. | |
| 708 | +var key = new JsCrypto.Word32Array([0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f]); | |
| 709 | +var iv = new JsCrypto.Word32Array([0x30313233, 0x34353637, 0x38393a3b, 0x3c3d3e3f]); | |
| 710 | + | |
| 711 | +var ECB = JsCrypto.mode.ECB; | |
| 712 | +var Pkcs7 = JsCrypto.pad.Pkcs7; // Don't use 'JsCrypto.NoPadding' unless message size is multiple of 4 words. | |
| 713 | +var encrypted = JsCrypto.AES.encrypt(message, key, { iv: iv, mode: ECB, padding: Pkcs7 }); | |
| 714 | +var decrypted = JsCrypto.AES.decrypt(encrypted, key, { iv: iv, mode: ECB, padding: Pkcs7 }); | |
| 715 | +decrypted.toString(JsCrypto.Utf8); // "message" | |
| 716 | +``` | |
| 717 | + | |
| 718 | +<h4 id='ofb'>OFB</h4> | |
| 719 | + | |
| 720 | +[Output Feedback](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Output_feedback_(OFB)) | |
| 721 | +OFB does not require encrypting data to be padded. | |
| 722 | +```js | |
| 723 | +var message = JsCrypto.Utf8.parse("message"); // 7bytes. | |
| 724 | +var key = new JsCrypto.Word32Array([0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f]); | |
| 725 | +var iv = new JsCrypto.Word32Array([0x30313233, 0x34353637, 0x38393a3b, 0x3c3d3e3f]); | |
| 726 | + | |
| 727 | +var OFB = JsCrypto.mode.OFB; | |
| 728 | +var NoPadding = JsCrypto.pad.NoPadding; | |
| 729 | +var encrypted = JsCrypto.AES.encrypt(message, key, { iv: iv, mode: OFB, padding: NoPadding }); | |
| 730 | +var decrypted = JsCrypto.AES.decrypt(encrypted, key, { iv: iv, mode: OFB, padding: NoPadding }); | |
| 731 | +decrypted.toString(JsCrypto.Utf8); // "message" | |
| 732 | +``` | |
| 733 | + | |
| 734 | +<h4 id="gcm">GCM</h4> | |
| 735 | + | |
| 736 | +[Galois Counter Mode](https://en.wikipedia.org/wiki/Galois/Counter_Mode) for authenticated encryption. | |
| 737 | + | |
| 738 | +GCM does not require encrypting data to be padded. | |
| 739 | +Changing Block padding has no effect. | |
| 740 | + | |
| 741 | +For detailed specification, please read official NIST publication. | |
| 742 | +https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf | |
| 743 | + | |
| 744 | +```js | |
| 745 | +//////////////////////////////////////////////////////////////////////////////////////// | |
| 746 | +// Authenticated encryption by AES-GCM | |
| 747 | +//////////////////////////////////////////////////////////////////////////////////////// | |
| 748 | +var key = JsCrypto.Hex.parse("0123456789ABCDEF11113333555577770123456789ABCDEF1111333355557777"); | |
| 749 | +var msg = JsCrypto.Hex.parse("00000000000000000000000000000000"); | |
| 750 | +var iv = JsCrypto.Hex.parse("000000000000000000000000"); // 96bit(12byte) iv is recommended. | |
| 751 | +var authData = JsCrypto.Utf8.parse("some plain text data for authentication. This will not be encrypted."); | |
| 752 | + | |
| 753 | +var encryptedData = JsCrypto.AES.encrypt(msg, key, {iv, mode: JsCrypto.mode.GCM}); | |
| 754 | + | |
| 755 | +// Encrypted message | |
| 756 | +var cipherText = encryptedData.cipherText; | |
| 757 | +// Authentication Tag | |
| 758 | +// 16byte. Output tag length in byte. If you omit this option, default value 16 is used. | |
| 759 | +var tagLength = 16; | |
| 760 | +var authTag = JsCrypto.mode.GCM.mac(JsCrypto.AES, key, iv, authData, cipherText, tagLength); | |
| 761 | + | |
| 762 | +// Base64 encoded encrypted data which can be safely shared in public. | |
| 763 | +// DO NOT share original `encryptedData` itself without calling `toString()`. | |
| 764 | +// Original encrypteData object contains key data, so if you share encryptedData variable in public, | |
| 765 | +// it turns to be just a plain text. | |
| 766 | +var encryptedPayload = encryptedData.toString(); | |
| 767 | + | |
| 768 | +//////////////////////////////////////////////////////////////////////////////////////// | |
| 769 | +// Authenticated decryption by AES-GCM | |
| 770 | +//////////////////////////////////////////////////////////////////////////////////////// | |
| 771 | +// Decrypting entity receives encryptedPayload, iv, authData. key should be share previously. | |
| 772 | +var decryptedData = JsCrypto.AES.decrypt(encryptedPayload, key, {iv, mode: JsCrypto.mode.GCM}); | |
| 773 | + | |
| 774 | +// Encrypt/Decrypt as usual | |
| 775 | +decryptedData.toString() === msg.toString(); // true | |
| 776 | + | |
| 777 | +// Verify authentication code as well as HMAC | |
| 778 | +var cipherText = JsCrypto.formatter.OpenSSLFormatter.parse(encryptedPayload).cipherText; | |
| 779 | +// authTag, iv, authData, cipherText(encryptedPayload) may be shared in public. | |
| 780 | +// key should be pre-shared in private. | |
| 781 | +authTag.toString() === JsCrypto.mode.GCM.mac(JsCrypto.AES, key, iv, authData, cipherText).toString(); // true | |
| 782 | +``` | |
| 783 | + | |
| 784 | +<h4 id="ccm">CCM</h4> | |
| 785 | + | |
| 786 | +[CCM Mode](https://en.wikipedia.org/wiki/CCM_mode) for authenticated encryption. | |
| 787 | + | |
| 788 | +For detailed specification, please read official NIST publication. | |
| 789 | +https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38c.pdf | |
| 790 | + | |
| 791 | +```js | |
| 792 | +// Example test vectors | |
| 793 | +// See page 17 at https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38c.pdf | |
| 794 | +// Klen=128bit, Tlen=32bit, Nlen=56bit, Alen=64bit, Plen=32bit | |
| 795 | +var K = JsCrypto.Hex.parse("404142434445464748494a4b4c4d4e4f"); // key | |
| 796 | +var N = JsCrypto.Hex.parse("10111213141516"); // Nonce/iv | |
| 797 | +var A = JsCrypto.Hex.parse("0001020304050607"); // Associated Data | |
| 798 | +var P = JsCrypto.Hex.parse("20212223"); // Payload/Plaintext | |
| 799 | +var t = 32/8; // 4byte. tag length byte. | |
| 800 | + | |
| 801 | +// Generate CBC-MAC | |
| 802 | +var cbcMac = JsCrypto.mode.CCM.mac(JsCrypto.AES, K, N, A, P, t); | |
| 803 | +cbcMac.toString(); // "4dac255d" | |
| 804 | + | |
| 805 | +// Encryption | |
| 806 | +var encrypted = JsCrypto.AES.encrypt(P, K, { iv: N, mode: JsCrypto.mode.CCM, padding: JsCrypto.pad.NoPadding }); | |
| 807 | +var cipherText = encrypted.cipherText; | |
| 808 | +cipherText.toString(); // "7162015b" | |
| 809 | + | |
| 810 | +// Combine encrypted block and MAC to be compatible with cipher output at Steps 8 in chapter 6.1, NIST-800-38C. | |
| 811 | +// See page 9 through page 10 at https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38c.pdf | |
| 812 | +var nist80038cStyleCiphertext = JsCrypto.mode.CCM.combineCipherTextAndAuthTag(cipherText, cbcMac); | |
| 813 | +nist80038cStyleCiphertext.toString(); // "7162015b4dac255d" | |
| 814 | + | |
| 815 | +// Decryption | |
| 816 | +// Assuming you receive nist 800-38c style ciphertext and N, A, P, t from encrypting entity. | |
| 817 | +// K(key) should be pre-shared privately. | |
| 818 | +var cipherTextAndAuthTag = JsCrypto.mode.CCM.splitCipherTextAndAuthTag(nist80038cStyleCiphertext, t); | |
| 819 | +var cipherText = cipherTextAndAuthTag.cipherText; | |
| 820 | +var authTag = cipherTextAndAuthTag.authTag; | |
| 821 | +var cp = new JsCrypto.CipherParams({cipherText}); | |
| 822 | +// Finally decrypt here | |
| 823 | +var decrypted = JsCrypto.AES.decrypt(cp, K, {iv: N, mode: JsCrypto.mode.CCM, padding: JsCrypto.pad.NoPadding}); | |
| 824 | +decrypted.toString() === P.toString(); // true | |
| 825 | +authTag.toString() === cbcMac.toString(); // true | |
| 826 | +``` | |
| 827 | + | |
| 828 | +<h5 id="note-for-ccm-implementation">Note for CCM implementation</h5> | |
| 829 | + | |
| 830 | +Since there are many CCM implementations out in the world, interoperability among those implementations can't be expected. | |
| 831 | +I can only say that CCM implementation of `jscrypto` follows NIST 800-38C style ciphertext. | |
| 832 | + | |
| 833 | +However, since I put an emphasis on coherence on this library, | |
| 834 | +jscrypto requires you to take additional steps to reproduce exact the same cipher output as NIST 800-38C style ciphertext. | |
| 835 | + | |
| 836 | +- JsCrypto's CCM independently outputs ciphertext and authTag(mac). | |
| 837 | + Each operation(encryption/generating mac) does not care opponent's internal state at all. | |
| 838 | +- If you want to generate NIST 800-38C style ciphertext, you need to take steps as below. | |
| 839 | + 1. encrypt plain text | |
| 840 | + 2. generate CBC-MAC | |
| 841 | + 3. combine outputs from above operations. | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | +<h5 id="reason-why-it-takes-extra-steps-in-ccm">The reason why it takes extra steps</h5> | |
| 846 | + | |
| 847 | +You may notice that in NIST 800-38C style ciphertext, sizes of input plaintext and output ciphertext does not match | |
| 848 | +because 800-38C's ciphertext is followed by MAC of input data(a.k.a. authTag). So size of output ciphertext is size of plaintext plus size of MAC(authTag). | |
| 849 | + | |
| 850 | +In `jscrypto`, block cipher takes fixed size block and produces the same size block and repeats it | |
| 851 | +until all blocks which compose of input plaintext are consumed. | |
| 852 | +Even CCM is not an exception. CCM takes fixed size block and produce the same size encrypted block. | |
| 853 | +So if you want NIST 800-38C style ciphertext, you need to combine encrypted plaintext and MAC. | |
| 854 | + | |
| 855 | +### Block Padding | |
| 856 | +<h4 id='ansix923'>AnsiX923</h4> | |
| 857 | + | |
| 858 | +Add 0 and number of bytes added. | |
| 859 | + | |
| 860 | +```js | |
| 861 | +var data = new JsCrypto.Word32Array([0xaabbcc00], 3); // 3bytes | |
| 862 | +// pad(data, blockSizeInWords) | |
| 863 | +JsCrypto.pad.AnsiX923.pad(data, 2); // Padding to 2words * 4bytes/words = 8bytes | |
| 864 | + | |
| 865 | +// true | |
| 866 | +data.toString(); // aabbcc0000000005 | |
| 867 | + | |
| 868 | +// new JsCrypto.Word32Array([0xaabbcc00, 0x00000005]) | |
| 869 | +// ^^ ^^^^^^^^ | |
| 870 | +// ^: Bytes added by padding. Last byte represents number of bytes added. | |
| 871 | +// | |
| 872 | +// AnsiX923 requires padding value to be zero. (https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography.paddingmode?view=net-5.0) | |
| 873 | +// Note that IBM said padding value is to be random. (https://www.ibm.com/support/knowledgecenter/en/linuxonibm/com.ibm.linux.z.wskc.doc/wskc_c_l0wskc58.html) | |
| 874 | + | |
| 875 | +JsCrypto.pad.AnsiX923.unpad(data); | |
| 876 | +// true | |
| 877 | +data.toString(); // aabbcc | |
| 878 | +``` | |
| 879 | + | |
| 880 | +<h4 id='iso10126'>ISO10126</h4> | |
| 881 | + | |
| 882 | +Add random bytes and number of bytes added. | |
| 883 | + | |
| 884 | +```js | |
| 885 | +var data = new JsCrypto.Word32Array([0xaabbcc00], 3); | |
| 886 | +// pad(data, blockSizeInWords) | |
| 887 | +JsCrypto.pad.ISO10126.pad(data, 2); | |
| 888 | +// Padding strategy is almost the same with ANSIX9.23. The difference is padded value. | |
| 889 | +// Padded values in AnsiX9.23 is 0 while ISO10126 is random. | |
| 890 | + | |
| 891 | +data.toString(); // aabbccf6b9304505, where f6b9304505 is added. Last byte(5) means 5 bytes have been added. Other padded values are random. | |
| 892 | + | |
| 893 | +JsCrypto.pad.ISO10126.unpad(data); | |
| 894 | +// true | |
| 895 | +data.toString(); // aabbcc | |
| 896 | +``` | |
| 897 | + | |
| 898 | +<h4 id='iso97971'>ISO97971</h4> | |
| 899 | + | |
| 900 | +Add 0x80 and 0s. | |
| 901 | + | |
| 902 | +```js | |
| 903 | +var data = new JsCrypto.Word32Array([0xaabbccdd, 0xee000000], 5); | |
| 904 | +// pad(data, blockSizeInWords) | |
| 905 | +JsCrypto.pad.ISO97971.pad(data, 2); | |
| 906 | + | |
| 907 | +data.toString(); // aabbccddee800000, where 800000 is added. Always add 0x80 and following 0 until last byte. | |
| 908 | + | |
| 909 | +JsCrypto.pad.ISO97971.unpad(data); | |
| 910 | +// true | |
| 911 | +data.toString(); // aabbccddee | |
| 912 | + | |
| 913 | +``` | |
| 914 | + | |
| 915 | +<h4 id='nopadding'>NoPadding</h4> | |
| 916 | + | |
| 917 | +As name says, it pretends to pad. | |
| 918 | +```js | |
| 919 | +var data = new JsCrypto.Word32Array([0xaabbccdd, 0xee000000], 5); | |
| 920 | +// pad(data, blockSizeInWords) | |
| 921 | +JsCrypto.pad.NoPadding.pad(data, 2); | |
| 922 | + | |
| 923 | +data.toString(); // aabbccddee. Not padding at all. | |
| 924 | + | |
| 925 | +JsCrypto.pad.NoPadding.unpad(data); | |
| 926 | +// true | |
| 927 | +data.toString(); // aabbccddee | |
| 928 | +``` | |
| 929 | + | |
| 930 | +<h4 id='pkcs7'>Pkcs7</h4> | |
| 931 | + | |
| 932 | +The value of each added byte is the number of bytes that are added | |
| 933 | +```js | |
| 934 | +var data = new JsCrypto.Word32Array([0xaabbccdd, 0xee000000], 5); | |
| 935 | +// pad(data, blockSizeInWords) | |
| 936 | +JsCrypto.pad.Pkcs7.pad(data, 2); | |
| 937 | + | |
| 938 | +data.toString(); // aabbccddee030303 | |
| 939 | + | |
| 940 | +JsCrypto.pad.Pkcs7.unpad(data); | |
| 941 | +// true | |
| 942 | +data.toString(); // aabbccddee | |
| 943 | +``` | |
| 944 | + | |
| 945 | +<h4 id='zero'>Zero</h4> | |
| 946 | + | |
| 947 | +The value of each added byte is 0. | |
| 948 | +Note Zero padding may not be reversible if the original file ends with one or more zero bytes. | |
| 949 | +```js | |
| 950 | +var data = new JsCrypto.Word32Array([0xaabbccdd, 0xee000000], 5); | |
| 951 | +// pad(data, blockSizeInWords) | |
| 952 | +JsCrypto.pad.Zero.pad(data, 2); | |
| 953 | + | |
| 954 | +data.toString(); // aabbccddee000000 | |
| 955 | + | |
| 956 | +JsCrypto.pad.Zero.unpad(data); | |
| 957 | +// true | |
| 958 | +data.toString(); // aabbccddee | |
| 959 | +``` | |
| 960 | + | |
| 961 | +### Formatter | |
| 962 | +<h4 id='opensslformatter'>OpenSSLFormatter</h4> | |
| 963 | + | |
| 964 | +Converts a cipher params object to an OpenSSL-compatible string which contains encrypted data and kdf salt. | |
| 965 | + | |
| 966 | +Encrypt by JsCrypto | |
| 967 | +```js | |
| 968 | +// CBC/ECB/CTR/OFB/CFB is the options | |
| 969 | +var mode = JsCrypto.mode.CBC; | |
| 970 | +// AnsiX923/ISO10126/ISO97971/Pkcs7/NoPadding/Zero is the options | |
| 971 | +var padding = JsCrypto.pad.Pkcs7; | |
| 972 | +// AnsiX923/ISO10126/ISO97971/Pkcs7/NoPadding/Zero is the options | |
| 973 | +var kdfModule = JsCrypto.PBKDF2; | |
| 974 | +// MD5/SHA1/SHA3/SHA225/SHA256/SHA384/SHA512/RIPEMD160 is the options | |
| 975 | +var kdfHasher = JsCrypto.SHA256; | |
| 976 | +// 10000 is the default value. You can omit this. | |
| 977 | +var kdfIterations = 10000; | |
| 978 | +// For testing purpose only. DO NOT USE salt unless you need it. | |
| 979 | +var kdfSalt = JsCrypto.Hex.parse("daefe2565e3c4680"); | |
| 980 | +var aesProps = {mode, padding, kdfModule, kdfSalt, kdfHasher, kdfIterations}; | |
| 981 | + | |
| 982 | +var cipherParams = JsCrypto.AES.encrypt("message", "password", aesProps); | |
| 983 | +// Gets "U2FsdGVkX1/a7+JWXjxGgCXR5T2J97jwBZAKtZNXZI4=". OpenSSL compatible format. | |
| 984 | +JsCrypto.formatter.OpenSSLFormatter.stringify(cipherParams); | |
| 985 | +// Or | |
| 986 | +cipherParams.toString(); | |
| 987 | + | |
| 988 | +// You can omit default parameters. | |
| 989 | +var cipherParams = JsCrypto.AES.encrypt("message", "password", {kdfSalt: JsCrypto.Hex.parse("daefe2565e3c4680")}); | |
| 990 | +// "U2FsdGVkX1/a7+JWXjxGgCXR5T2J97jwBZAKtZNXZI4=". OpenSSL compatible format. | |
| 991 | +cipherParams.toString(); | |
| 992 | +// Above options are all default values except for kdfSalt so you can omit them if you want to use default values. | |
| 993 | +// Warning: DO NOT specify kdfSalt unless you need to do it. | |
| 994 | +``` | |
| 995 | + | |
| 996 | +Equivalent in OpenSSL (OpenSSL 1.1.1f) | |
| 997 | +```shell | |
| 998 | +echo -n "message" | openssl enc -e -aes-256-cbc -pass pass:password -base64 -pbkdf2 -S daefe2565e3c4680 -iter 10000 | |
| 999 | +# Output: U2FsdGVkX1/a7+JWXjxGgCXR5T2J97jwBZAKtZNXZI4= | |
| 1000 | + | |
| 1001 | +# or simply | |
| 1002 | +echo -n "message" | openssl enc -e -aes-256-cbc -pass pass:password -base64 -S daefe2565e3c4680 | |
| 1003 | +# pbkdf2 and iterations:10000 is the default value in OpenSSL 1.1.1f | |
| 1004 | +``` | |
| 1005 | + | |
| 1006 | +Decrypt by JsCrypto | |
| 1007 | +```js | |
| 1008 | +var mode = JsCrypto.mode.CBC; | |
| 1009 | +var padding = JsCrypto.pad.Pkcs7; | |
| 1010 | +var kdfModule = JsCrypto.PBKDF2; | |
| 1011 | +var kdfHasher = JsCrypto.SHA256; | |
| 1012 | +var kdfIterations = 10000; | |
| 1013 | +var kdfSalt = JsCrypto.Hex.parse("daefe2565e3c4680"); | |
| 1014 | +var aesProps = {mode, padding, kdfModule, kdfSalt, kdfHasher, kdfIterations}; | |
| 1015 | + | |
| 1016 | +var encryptedData = "U2FsdGVkX1/a7+JWXjxGgCXR5T2J97jwBZAKtZNXZI4="; | |
| 1017 | +var decrypted = JsCrypto.AES.decrypt(encryptedData, "password", aesProps); | |
| 1018 | +decrypted.toString(JsCrypto.Utf8); // "message" | |
| 1019 | +``` | |
| 1020 | + | |
| 1021 | +In OpenSSL | |
| 1022 | +```shell | |
| 1023 | +echo "U2FsdGVkX1/a7+JWXjxGgCXR5T2J97jwBZAKtZNXZI4=" | openssl enc -d -aes-256-cbc -pass pass:password -base64 -pbkdf2 -S daefe2565e3c4680 -iter 10000 | |
| 1024 | +# Output: message (Without newline) | |
| 1025 | +``` | |
| 1026 | + | |
| 1027 | +[MD5]: #md5 | |
| 1028 | +[SHA1]: #sha1 | |
| 1029 | +[SHA3]: #sha3 | |
| 1030 | +[SHA224]: #sha224 | |
| 1031 | +[SHA256]: #sha256 | |
| 1032 | +[SHA384]: #sha384 | |
| 1033 | +[SHA512]: #sha512 | |
| 1034 | +[RIPEMD160]: #ripemd160 | |
| 1035 | +[HMAC-MD5]: #hmac-md5 | |
| 1036 | +[HMAC-SHA224]: #hmac-sha224 | |
| 1037 | +[HMAC-SHA256]: #hmac-sha256 | |
| 1038 | +[HMAC-SHA384]: #hmac-sha384 | |
| 1039 | +[HMAC-SHA512]: #hmac-sha512 | |
| 1040 | +[GMAC]: #gmac | |
| 1041 | +[CBC-MAC]: #cbc-mac | |
| 1042 | +[AES]: #aes | |
| 1043 | +[DES]: #des | |
| 1044 | +[Triple-DES]: #des3 | |
| 1045 | +[Word32Array]: #word32array | |
| 1046 | +[Word64Array]: #mword64Array | |
| 1047 | +[Base64]: #base64 | |
| 1048 | +[Hex]: #hex | |
| 1049 | +[Latin1]: #latin1 | |
| 1050 | +[Utf8]: #utf8 | |
| 1051 | +[Utf16]: #utf16 | |
| 1052 | +[Rabbits]: #rabbits | |
| 1053 | +[RC4]: #rc4 | |
| 1054 | +[RC4Drop]: #rc4drop | |
| 1055 | +[OpenSSLKDF]: #opensslkdf | |
| 1056 | +[EvpKDF]: #evpkdf | |
| 1057 | +[PBKDF2]: #pbkdf2 | |
| 1058 | +[CBC]: #cbc | |
| 1059 | +[CFB]: #cfb | |
| 1060 | +[CTR]: #ctr | |
| 1061 | +[ECB]: #ecb | |
| 1062 | +[OFB]: #ofb | |
| 1063 | +[GCM]: #gcm | |
| 1064 | +[CCM]: #ccm | |
| 1065 | +[AnsiX923]: #ansix923 | |
| 1066 | +[ISO10126]: #iso10126 | |
| 1067 | +[ISO97971]: #iso97971 | |
| 1068 | +[NoPadding]: #nopadding | |
| 1069 | +[Pkcs7]: #pkcs7 | |
| 1070 | +[Zero]: #zero | |
| 1071 | +[OpenSSLFormatter]: #opensslformatter | ... | ... |
app/static/content/jscrypto/Base64.d.ts
0 → 100644
| 1 | +export { Base64 } from "./lib/encoder/Base64"; | ... | ... |
app/static/content/jscrypto/Base64.js
0 → 100644
| 1 | +!function(r,n){if("object"==typeof exports&&"object"==typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else if("object"==typeof exports)exports.JsCrypto=n();else{var t=n();for(var e in r.JsCrypto=r.JsCrypto||{},t)r.JsCrypto[e]=t[e]}}(this,(function(){return function(){"use strict";var r={d:function(n,t){for(var e in t)r.o(t,e)&&!r.o(n,e)&&Object.defineProperty(n,e,{enumerable:!0,get:t[e]})}};r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(r){if("object"==typeof window)return window}}(),r.o=function(r,n){return Object.prototype.hasOwnProperty.call(r,n)},r.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"t",{value:!0})};var n={};r.r(n),r.d(n,{Base64:function(){return h}});var t,e=function(r){for(var n=r.nSigBytes,t=r.words,e=[],i=0;i<n;i++){var o=t[i>>>2]>>>24-i%4*8&255;e.push((o>>>4).toString(16)),e.push((15&o).toString(16))}return e.join("")},i="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(t=parseInt((/msie (\d+)/.exec(i)||[])[1],10),isNaN(t)?(t=parseInt((/trident\/.*; rv:(\d+)/.exec(i)||[])[1],10),!isNaN(t)&&t):t);for(var a=function(){if("undefined"!=typeof window){var n=window.crypto||window.msCrypto;if(!n){if(function(r,n){return!1!==o&&(!n||("<"===r?o<n:"<="===r?o<=n:">"===r?o>n:">="===r?o>=n:o===n))}("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return n.getRandomValues(new Uint32Array(1))[0]}}return void 0!==r.g&&r.g.crypto?function(){return r.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}(),f=function(){function r(n,t){if(Array.isArray(n)||!n)return this.i=Array.isArray(n)?n:[],void(this.u="number"==typeof t?t:4*this.i.length);if(n instanceof r)return this.i=n.words.slice(),void(this.u=n.nSigBytes);var e;try{n instanceof ArrayBuffer?e=new Uint8Array(n):(n instanceof Uint8Array||n instanceof Int8Array||n instanceof Uint8ClampedArray||n instanceof Int16Array||n instanceof Uint16Array||n instanceof Int32Array||n instanceof Uint32Array||n instanceof Float32Array||n instanceof Float64Array)&&(e=new Uint8Array(n.buffer,n.byteOffset,n.byteLength))}catch(r){throw new Error("Invalid argument")}if(!e)throw new Error("Invalid argument");for(var i=e.byteLength,o=[],a=0;a<i;a++)o[a>>>2]|=e[a]<<24-a%4*8;this.i=o,this.u=i}return Object.defineProperty(r.prototype,"nSigBytes",{get:function(){return this.u},set:function(r){this.u=r},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"words",{get:function(){return this.i},enumerable:!1,configurable:!0}),r.prototype.toString=function(r){return r?r.stringify(this):e(this)},r.prototype.toUint8Array=function(){for(var r=this.i,n=this.u,t=new Uint8Array(n),e=0;e<n;e++)t[e]=r[e>>>2]>>>24-e%4*8&255;return t},r.prototype.concat=function(r){var n=r.words.slice(),t=r.nSigBytes;if(this.clamp(),this.u%4)for(var e=0;e<t;e++){var i=n[e>>>2]>>>24-e%4*8&255;this.i[this.u+e>>>2]|=i<<24-(this.u+e)%4*8}else for(e=0;e<t;e+=4)this.i[this.u+e>>>2]=n[e>>>2];return this.u+=t,this},r.prototype.clamp=function(){var r=this.u;this.i[r>>>2]&=4294967295<<32-r%4*8,this.i.length=Math.ceil(r/4)},r.prototype.clone=function(){return new r(this.i.slice(),this.u)},r.random=function(n){for(var t=[],e=0;e<n;e+=4)t.push(a());return new r(t,n)},r}(),u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",s=[],c=0;c<u.length;c++)s[u.charCodeAt(c)]=c;var h={stringify:function(r){var n=r.words,t=r.nSigBytes;r.clamp();for(var e=[],i=0;i<t;i+=3)for(var o=(n[i>>>2]>>>24-i%4*8&255)<<16|(n[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|n[i+2>>>2]>>>24-(i+2)%4*8&255,a=0;a<4&&i+.75*a<t;a++)e.push(u.charAt(o>>>6*(3-a)&63));var f=u.charAt(64);if(f)for(;e.length%4;)e.push(f);return e.join("")},parse:function(r){var n=r.length,t=u.charAt(64);if(t){var e=r.indexOf(t);-1!==e&&(n=e)}for(var i=[],o=0,a=0;a<n;a++)if(a%4){var c=s[r.charCodeAt(a-1)]<<a%4*2|s[r.charCodeAt(a)]>>>6-a%4*2;i[o>>>2]|=c<<24-o%4*8,o++}return new f(i,o)}};return n}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/CBCMAC.d.ts
0 → 100644
| 1 | +import { Word32Array } from "./lib/Word32Array"; | |
| 2 | +import { BlockCipher } from "./lib/algorithm/cipher/BlockCipher"; | |
| 3 | +export declare type CBCMACProps = { | |
| 4 | + Cipher: typeof BlockCipher; | |
| 5 | +}; | |
| 6 | +export declare function CBCMAC(plainText: Word32Array | string, associatedData: Word32Array | string, key: Word32Array | string, iv: Word32Array | null, tagLength?: number, props?: Partial<CBCMACProps>): Word32Array; | ... | ... |
app/static/content/jscrypto/CBCMAC.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var r=t();for(var i in n.JsCrypto=n.JsCrypto||{},r)n.JsCrypto[i]=r[i]}}(this,(function(){return function(){"use strict";var n={9691:function(n,t,r){r.d(t,{AES:function(){return g}});var i,e=r(9456),o=r(787),u=r(5693),f=r(9109),c=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),s=function(){return(s=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},a=[],h=[],v=[],w=[],l=[],d=[],b=[],y=[],p=[],m=[];!function(){for(var n=[],t=0;t<256;t++)n[t]=t<128?t<<1:t<<1^283;var r=0,i=0;for(t=0;t<256;t++){var e=i^i<<1^i<<2^i<<3^i<<4;e=e>>>8^255&e^99,a[r]=e,h[e]=r;var o=n[r],u=n[o],f=n[u],c=257*n[e]^16843008*e;v[r]=c<<24|c>>>8,w[r]=c<<16|c>>>16,l[r]=c<<8|c>>>24,d[r]=c,c=16843009*f^65537*u^257*o^16843008*r,b[e]=c<<24|c>>>8,y[e]=c<<16|c>>>16,p[e]=c<<8|c>>>24,m[e]=c,r?(r=o^n[n[n[f^o]]],i^=n[n[i]]):r=i=1}}();var j=[0,1,2,4,8,16,32,64,128,27,54],g=function(n){function t(t){var r=n.call(this,t)||this;return r.i=0,r.u=[],r.h=[],r.v=t,r.j(),r}return c(t,n),t.prototype.j=function(){var n;if(!this.i||this.O!==this.A){for(var t=this.O=this.A,r=t.words,i=t.nSigBytes/4,e=4*((this.i=i+6)+1),o=this.u=[],u=0;u<e;u++)u<i?o[u]=r[u]:(n=o[u-1],u%i?i>6&&u%i==4&&(n=a[n>>>24]<<24|a[n>>>16&255]<<16|a[n>>>8&255]<<8|a[255&n]):(n=a[(n=n<<8|n>>>24)>>>24]<<24|a[n>>>16&255]<<16|a[n>>>8&255]<<8|a[255&n],n^=j[u/i|0]<<24),o[u]=o[u-i]^n);this.h=[];for(var f=0;f<e;f++){u=e-f;n=f%4?o[u]:o[u-4],this.h[f]=f<4||u<=4?n:b[a[n>>>24]]^y[a[n>>>16&255]]^p[a[n>>>8&255]]^m[a[255&n]]}}},t.prototype.encryptBlock=function(n,t){this.N(n,t,this.u,v,w,l,d,a)},t.prototype.decryptBlock=function(n,t){var r=n[t+1];n[t+1]=n[t+3],n[t+3]=r,this.N(n,t,this.h,b,y,p,m,h),r=n[t+1],n[t+1]=n[t+3],n[t+3]=r},t.prototype.N=function(n,t,r,i,e,o,u,f){for(var c=this.i,s=n[t]^r[0],a=n[t+1]^r[1],h=n[t+2]^r[2],v=n[t+3]^r[3],w=4,l=1;l<c;l++){var d=i[s>>>24]^e[a>>>16&255]^o[h>>>8&255]^u[255&v]^r[w++],b=i[a>>>24]^e[h>>>16&255]^o[v>>>8&255]^u[255&s]^r[w++],y=i[h>>>24]^e[v>>>16&255]^o[s>>>8&255]^u[255&a]^r[w++],p=i[v>>>24]^e[s>>>16&255]^o[a>>>8&255]^u[255&h]^r[w++];s=d,a=b,h=y,v=p}var m=(f[s>>>24]<<24|f[a>>>16&255]<<16|f[h>>>8&255]<<8|f[255&v])^r[w++],j=(f[a>>>24]<<24|f[h>>>16&255]<<16|f[v>>>8&255]<<8|f[255&s])^r[w++],g=(f[h>>>24]<<24|f[v>>>16&255]<<16|f[s>>>8&255]<<8|f[255&a])^r[w++],O=(f[v>>>24]<<24|f[s>>>16&255]<<16|f[a>>>8&255]<<8|f[255&h])^r[w++];n[t]=m,n[t+1]=j,n[t+2]=g,n[t+3]=O},t.createEncryptor=function(n,r){return new t(s(s({},r=void 0===r?{}:r),{key:n,transformMode:e.t.ENC_TRANSFORM_MODE}))},t.createDecryptor=function(n,r){return new t(s(s({},r=void 0===r?{}:r),{key:n,transformMode:e.t.DEC_TRANSFORM_MODE}))},t.encrypt=function(n,r,i){if("string"==typeof r)return u.E.encrypt(t,n,r,i);if(r.nSigBytes%4!=0)throw new Error("Key size must be multiple of 32bit/4byte/1word");return f.D.encrypt(t,n,r,i)},t.decrypt=function(n,r,i){if("string"==typeof r)return u.E.decrypt(t,n,r,i);if(r.nSigBytes%4!=0)throw new Error("Key size must be multiple of 32bit/4byte/1word");return f.D.decrypt(t,n,r,i)},t.keySize=8,t}(o.G)},6367:function(n,t,r){r.d(t,{Hmac:function(){return e}});var i=r(4768),e=function(){function n(n,t){this.k=n,"string"==typeof t&&(t=i.d.parse(t));var r=n.blockSize,e=4*r;t.nSigBytes>e&&(t=n.finalize(t)),t.clamp();for(var o=this.I=t.clone(),u=this.S=t.clone(),f=o.words,c=u.words,s=0;s<r;s++)f[s]^=1549556828,c[s]^=909522486;u.nSigBytes=e,o.nSigBytes=e,this.reset()}return n.prototype.reset=function(){this.k.reset(),this.k.update(this.S)},n.prototype.update=function(n){return this.k.update(n),this},n.prototype.finalize=function(n){var t=this.k.finalize(n);return this.k.reset(),this.k.finalize(this.I.clone().concat(t))},n}()},5561:function(n,t,r){r.d(t,{SHA256:function(){return v}});var i,e=r(1868),o=r(3354),u=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),f=[],c=[];function s(n){for(var t=Math.sqrt(n),r=2;r<=t;r++)if(!(n%r))return!1;return!0}function a(n){return 4294967296*(n-(0|n))|0}!function(){for(var n=2,t=0;t<64;)s(n)&&(t<8&&(f[t]=a(Math.pow(n,.5))),c[t]=a(Math.pow(n,1/3)),t++),n++}();var h=[],v=function(n){function t(t){var r=n.call(this,t)||this;return r.U=new o.e(f.slice(0)),r.v=t,t&&void 0!==t.hash&&(r.U=t.hash.clone()),r}return u(t,n),t.prototype.j=function(){this.U=new o.e(f.slice(0))},t.prototype.B=function(n,t){for(var r=this.U.words,i=r[0],e=r[1],o=r[2],u=r[3],f=r[4],s=r[5],a=r[6],v=r[7],w=0;w<64;w++){if(w<16)h[w]=0|n[t+w];else{var l=h[w-15],d=(l<<25|l>>>7)^(l<<14|l>>>18)^l>>>3,b=h[w-2],y=(b<<15|b>>>17)^(b<<13|b>>>19)^b>>>10;h[w]=d+h[w-7]+y+h[w-16]}var p=i&e^i&o^e&o,m=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),j=v+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(f&s^~f&a)+c[w]+h[w];v=a,a=s,s=f,f=u+j|0,u=o,o=e,e=i,i=j+(m+p)|0}r[0]=r[0]+i|0,r[1]=r[1]+e|0,r[2]=r[2]+o|0,r[3]=r[3]+u|0,r[4]=r[4]+f|0,r[5]=r[5]+s|0,r[6]=r[6]+a|0,r[7]=r[7]+v|0},t.prototype.F=function(){var n=this.H.words,t=8*this.L,r=8*this.H.nSigBytes;return n[r>>>5]|=128<<24-r%32,n[14+(r+64>>>9<<4)]=Math.floor(t/4294967296),n[15+(r+64>>>9<<4)]=t,this.H.nSigBytes=4*n.length,this.R(),this.U},t.prototype.clone=function(){return new t({hash:this.U,blockSize:this.q,data:this.H,nBytes:this.L})},t.hash=function(n,r){return new t(r).finalize(n)},t}(e.P)},3354:function(n,t,r){r.d(t,{e:function(){return o}});var i=r(5720),e=r(9054),o=function(){function n(t,r){if(Array.isArray(t)||!t)return this.J=Array.isArray(t)?t:[],void(this.V="number"==typeof r?r:4*this.J.length);if(t instanceof n)return this.J=t.words.slice(),void(this.V=t.nSigBytes);var i;try{t instanceof ArrayBuffer?i=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!i)throw new Error("Invalid argument");for(var e=i.byteLength,o=[],u=0;u<e;u++)o[u>>>2]|=i[u]<<24-u%4*8;this.J=o,this.V=e}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.V},set:function(n){this.V=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.J},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):i.p.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this.J,t=this.V,r=new Uint8Array(t),i=0;i<t;i++)r[i]=n[i>>>2]>>>24-i%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.V%4)for(var i=0;i<r;i++){var e=t[i>>>2]>>>24-i%4*8&255;this.J[this.V+i>>>2]|=e<<24-(this.V+i)%4*8}else for(i=0;i<r;i+=4)this.J[this.V+i>>>2]=t[i>>>2];return this.V+=r,this},n.prototype.clamp=function(){var n=this.V;this.J[n>>>2]&=4294967295<<32-n%4*8,this.J.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.J.slice(),this.V)},n.random=function(t){for(var r=[],i=0;i<t;i+=4)r.push((0,e.M)());return new n(r,t)},n}()},7211:function(n,t,r){r.d(t,{C:function(){return o}});var i=r(3354),e=r(4768),o=function(){function n(n){this.X=0,this.q=0,this.v=n,this.H=n&&void 0!==n.data?n.data.clone():new i.e,this.L=n&&"number"==typeof n.nBytes?n.nBytes:0}return Object.defineProperty(n.prototype,"blockSize",{get:function(){return this.q},enumerable:!1,configurable:!0}),n.prototype.reset=function(n,t){this.H=void 0!==n?n.clone():new i.e,this.L="number"==typeof t?t:0},n.prototype.Y=function(n){var t="string"==typeof n?e.d.parse(n):n;this.H.concat(t),this.L+=t.nSigBytes},n.prototype.R=function(n){var t,r=this.H.words,e=this.H.nSigBytes,o=this.q,u=e/(4*this.q),f=(u=n?Math.ceil(u):Math.max((0|u)-this.X,0))*o,c=Math.min(4*f,e);if(f){for(var s=0;s<f;s+=o)this.B(r,s);t=r.splice(0,f),this.H.nSigBytes-=c}return new i.e(t,c)},n.prototype.B=function(n,t){throw new Error("Not implemented")},n}()},1868:function(n,t,r){r.d(t,{P:function(){return u}});var i,e=r(7211),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.q=16,r.v=t,t&&"number"==typeof t.blockSize&&(r.q=t.blockSize),r.reset(t?t.data:void 0,t?t.nBytes:void 0),r}return o(t,n),Object.defineProperty(t.prototype,"blockSize",{get:function(){return this.q},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.j()},t.prototype.update=function(n){return this.Y(n),this.R(),this},t.prototype.finalize=function(n){return n&&this.Y(n),this.F()},t.prototype.j=function(){throw new Error("Not implemented")},t.prototype.F=function(){throw new Error("Not implemented")},t}(e.C)},787:function(n,t,r){r.d(t,{G:function(){return s}});var i,e=r(9456),o=r(4344),u=r(7919),f=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),c=function(){return(c=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},s=function(n){function t(t){var r=n.call(this,t)||this;return r.q=4,r.Z=o.n,r.$=u.l,r.v=t,r.Z=void 0!==t.mode?t.mode:r.Z,r.$=void 0!==t.padding?t.padding:r.$,r.reset(null==t?void 0:t.data,null==t?void 0:t.nBytes),r}return f(t,n),Object.defineProperty(t.prototype,"mode",{get:function(){return this.nn},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"padding",{get:function(){return this.$},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){var i;n.prototype.reset.call(this,t,r),this.tn===e.t.ENC_TRANSFORM_MODE?i=this.Z.createEncryptor:(i=this.Z.createDecryptor,this.X=1),this.Z&&this.rn===i?this.nn=new this.Z({cipher:this,iv:this.en}):(this.nn=i.call(this.Z,{cipher:this,iv:this.en}),this.rn=i)},t.prototype.B=function(n,t){var r;null===(r=this.nn)||void 0===r||r.processBlock(n,t)},t.prototype.F=function(){var n,t=this.$;return this.tn===e.t.ENC_TRANSFORM_MODE?(t.pad(this.H,this.blockSize),n=this.R(!0)):(n=this.R(!0),t.unpad(n)),n},t.prototype.encryptBlock=function(n,t){throw new Error("Not implemented")},t.prototype.decryptBlock=function(n,t){throw new Error("Not implemented")},t.createEncryptor=function(n,r){return new t(c(c({},r=void 0===r?{}:r),{key:n,transformMode:e.t.ENC_TRANSFORM_MODE}))},t.createDecryptor=function(n,r){return new t(c(c({},r=void 0===r?{}:r),{key:n,transformMode:e.t.DEC_TRANSFORM_MODE}))},t}(e.t)},9456:function(n,t,r){r.d(t,{t:function(){return f}});var i,e=r(7211),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(){return(u=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},f=function(n){function t(t){var r=n.call(this,t)||this;return r.tn=1,r.v=t,r.A=t.key,r.en=void 0!==t.iv?t.iv:r.en,r.tn=void 0!==t.transformMode?t.transformMode:r.tn,r}return o(t,n),Object.defineProperty(t.prototype,"iv",{get:function(){return this.en},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.j()},t.prototype.process=function(n){return this.Y(n),this.R()},t.prototype.finalize=function(n){return n&&this.Y(n),this.F()},t.prototype.j=function(){throw new Error("Not implemented")},t.prototype.B=function(n,t){throw new Error("Not implemented")},t.prototype.F=function(){throw new Error("Not implemented")},t.createEncryptor=function(n,r){return new t(u(u({},r=void 0===r?{}:r),{key:n,transformMode:t.ENC_TRANSFORM_MODE}))},t.createDecryptor=function(n,r){return new t(u(u({},r=void 0===r?{}:r),{key:n,transformMode:t.DEC_TRANSFORM_MODE}))},t.ENC_TRANSFORM_MODE=1,t.DEC_TRANSFORM_MODE=2,t.keySize=4,t.ivSize=4,t}(e.C)},2505:function(n,t,r){r.d(t,{Q:function(){return e}});var i=r(1232),e=function(){function n(n){this.formatter=i.w,n&&(this.cipherText=n.cipherText,this.key=n.key,this.iv=n.iv,this.salt=n.salt,this.Algorithm=n.Algorithm,this.mode=n.mode,this.padding=n.padding,this.blockSize=n.blockSize,this.formatter=n.formatter||i.w)}return n.prototype.toString=function(n){return(n||this.formatter).stringify(this)},n}()},5693:function(n,t,r){r.d(t,{E:function(){return c}});var i=r(9109),e=r(2214),o=r(2505),u=r(1232),f=function(){return(f=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},c={encrypt:function(n,t,r,u){var c=u?f({},u):{},s=u&&u.KDF?u.KDF:e.s,a={};u&&u.kdfHasher&&(a.kdfHasher=u.kdfHasher),u&&u.kdfIterations&&(a.kdfIterations=u.kdfIterations),u&&u.kdfModule&&(a.kdfModule=u.kdfModule);var h=s.execute(r,n.keySize,n.ivSize,c.kdfSalt,a);c.iv=h.iv;var v=i.D.encrypt(n,t,h.key,c);return new o.Q(f(f({},v),{key:h.key,iv:h.iv,salt:h.salt}))},decrypt:function(n,t,r,o){var c=o?f({},o):{},s=c.KDF?c.KDF:e.s,a=c.formatter?c.formatter:u.w,h=(0,i.W)(t,a),v={};o&&o.kdfHasher&&(v.kdfHasher=o.kdfHasher),o&&o.kdfIterations&&(v.kdfIterations=o.kdfIterations),o&&o.kdfModule&&(v.kdfModule=o.kdfModule);var w=s.execute(r,n.keySize,n.ivSize,h.salt,v);return c.iv=w.iv,i.D.decrypt(n,h,w.key,c)}}},9109:function(n,t,r){r.d(t,{W:function(){return o},D:function(){return u}});var i=r(1232),e=r(2505);function o(n,t){return"string"==typeof n?t.parse(n):n}var u={encrypt:function(n,t,r,o){var u=n.createEncryptor(r,o),f=u.finalize(t);return new e.Q({cipherText:f,key:r,iv:u.iv,Algorithm:n,mode:u.mode,padding:u.padding,blockSize:u.blockSize,formatter:(null==o?void 0:o.formatter)||i.w})},decrypt:function(n,t,r,e){var u=n.createDecryptor(r,e),f=o(t,(null==e?void 0:e.formatter)||i.w);return u.finalize(f.cipherText||"")}}},1232:function(n,t,r){r.d(t,{w:function(){return u}});var i=r(2505),e=r(3354),o=r(1773),u={stringify:function(n){var t=n.cipherText,r=n.salt;return t?r?new e.e([1398893684,1701076831]).concat(r).concat(t).toString(o.D):t.toString(o.D):""},parse:function(n){var t,r=o.D.parse(n),u=r.words;return 1398893684===u[0]&&1701076831===u[1]&&(t=new e.e(u.slice(2,4)),u.splice(0,4),r.nSigBytes-=16),new i.Q({cipherText:r,salt:t})}}},2214:function(n,t,r){r.d(t,{s:function(){return f}});var i=r(3354),e=r(2505),o=r(7008),u=function(){return(u=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},f={execute:function(n,t,r,f,c){f||(f=i.e.random(8));var s=c&&c.kdfModule||o.E,a=c?{Hasher:c.kdfHasher,iterations:c.kdfIterations}:{},h=s.getKey(n,f,u(u({},a),{keySize:t+r})),v=new i.e(h.words.slice(t),4*r);return h.nSigBytes=4*t,new e.Q({key:h,iv:v,salt:f})}}},7008:function(n,t,r){r.d(t,{E:function(){return s}});var i,e=r(5561),o=r(6367),u=r(3354),f=r(9541),c=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),s=function(n){function t(t){var r=n.call(this,t)||this;return r.on=4,r.un=e.SHA256,r.fn=1e4,t&&(r.on=void 0!==t.keySize?t.keySize:r.on,r.un=void 0!==t.Hasher?t.Hasher:r.un,r.fn=void 0!==t.iterations?t.iterations:r.fn),r}return c(t,n),t.prototype.compute=function(n,t){for(var r=new o.Hmac(new this.un,n),i=new u.e,e=new u.e([1]),f=i.words,c=e.words,s=this.on,a=this.fn;f.length<s;){var h=r.update(t).finalize(e);r.reset();for(var v=h.words,w=v.length,l=h,d=1;d<a;d++){l=r.finalize(l),r.reset();for(var b=l.words,y=0;y<w;y++)v[y]^=b[y]}i.concat(h),c[0]++}return i.nSigBytes=4*s,i},t.getKey=function(n,r,i){return new t(i).compute(n,r)},t}(f._)},9541:function(n,t,r){r.d(t,{_:function(){return i}});var i=function(){function n(n){this.v=n}return n.prototype.compute=function(n,t){throw new Error("Not implemented")},n.getKey=function(n,t,r){throw new Error("Not implemented")},n}()},1863:function(n,t,r){r.d(t,{T:function(){return i}});var i=function(){function n(n){this.v=n,this.cn=n.cipher,this.en=n.iv}return n.prototype.processBlock=function(n,t){},n.createEncryptor=function(n){throw new Error("Not implemented yet")},n.createDecryptor=function(n){throw new Error("Not implemented yet")},n}()},4344:function(n,t,r){r.d(t,{n:function(){return u}});var i,e=r(1863),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.sn=[],r}return o(t,n),t.prototype.xorBlock=function(n,t,r){var i,e=this.en;e?(i=e.words,this.en=void 0):i=this.sn;for(var o=0;o<r;o++)n[t+o]^=i[o]},t.createEncryptor=function(n){return new t.Encryptor(n)},t.createDecryptor=function(n){return new t.Decryptor(n)},t.Encryptor=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return o(t,n),t.prototype.processBlock=function(n,t){var r=this.cn,i=r.blockSize;this.xorBlock(n,t,i),r.encryptBlock(n,t),this.sn=n.slice(t,t+i)},t}(t),t.Decryptor=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return o(t,n),t.prototype.processBlock=function(n,t){var r=this.cn,i=r.blockSize,e=n.slice(t,t+i);r.decryptBlock(n,t),this.xorBlock(n,t,i),this.sn=e},t}(t),t}(e.T)},4055:function(n,t,r){r.d(t,{z6:function(){return e},ur:function(){return o}});var i=r(3354);function e(n,t){return new i.e(n.words.slice(),t)}function o(n,t){for(var r=n.nSigBytes-t,e=[],o=0;o<t;o++){var u=o>>>2,f=r+o,c=f>>>2,s=n.words[c]>>>24-f%4*8&255;e[u]=0|e[u]|s<<24-o%4*8}var a=new i.e(e,t);return a.clamp(),a}},7919:function(n,t,r){r.d(t,{l:function(){return e}});var i=r(3354);var e={pad:function(n,t){for(var r=4*t,e=r-n.nSigBytes%r,o=e<<24|e<<16|e<<8|e,u=[],f=0;f<e;f+=4)u.push(o);var c=new i.e(u,e);n.concat(c)},unpad:function(n){var t=255&n.words[n.nSigBytes-1>>>2];n.nSigBytes-=t}}},1756:function(n,t,r){r.d(t,{w:function(){return u}});var i,e="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(i=parseInt((/msie (\d+)/.exec(e)||[])[1],10),isNaN(i)?(i=parseInt((/trident\/.*; rv:(\d+)/.exec(e)||[])[1],10),!isNaN(i)&&i):i);function u(n,t){return!1!==o&&(!t||("<"===n?o<t:"<="===n?o<=t:">"===n?o>t:">="===n?o>=t:o===t))}},1773:function(n,t,r){r.d(t,{D:function(){return f}});for(var i=r(3354),e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=[],u=0;u<e.length;u++)o[e.charCodeAt(u)]=u;var f={stringify:function(n){var t=n.words,r=n.nSigBytes;n.clamp();for(var i=[],o=0;o<r;o+=3)for(var u=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,f=0;f<4&&o+.75*f<r;f++)i.push(e.charAt(u>>>6*(3-f)&63));var c=e.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(n){var t=n.length,r=e.charAt(64);if(r){var u=n.indexOf(r);-1!==u&&(t=u)}for(var f=[],c=0,s=0;s<t;s++)if(s%4){var a=o[n.charCodeAt(s-1)]<<s%4*2|o[n.charCodeAt(s)]>>>6-s%4*2;f[c>>>2]|=a<<24-c%4*8,c++}return new i.e(f,c)}}},5720:function(n,t,r){r.d(t,{p:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var r=[],e=0;e<t;e+=2)r[e>>>3]|=parseInt(n.substr(e,2),16)<<24-e%8*4;return new i.e(r,t/2)}}},8702:function(n,t,r){r.d(t,{m:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push(String.fromCharCode(o))}return i.join("")},parse:function(n){for(var t=n.length,r=[],e=0;e<t;e++)r[e>>>2]|=(255&n.charCodeAt(e))<<24-e%4*8;return new i.e(r,t)}}},4768:function(n,t,r){r.d(t,{d:function(){return e}});var i=r(8702),e={stringify:function(n){try{return decodeURIComponent(escape(i.m.stringify(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return i.m.parse(unescape(encodeURIComponent(n)))}}},9054:function(n,t,r){r.d(t,{M:function(){return e}});var i=r(1756);var e=function(){if("undefined"!=typeof window){var n=window.crypto||window.msCrypto;if(!n){if((0,i.w)("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return n.getRandomValues(new Uint32Array(1))[0]}}return void 0!==r.g&&r.g.crypto?function(){return r.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}()},3664:function(n,t,r){r.d(t,{K:function(){return c}});var i,e=r(1863),o=r(3354),u=r(4055),f=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),c=function(n){function t(t){var r=n.call(this,t)||this;r.an=1;var i=t.cipher,e=t.iv;if(4!==i.blockSize)throw new Error("In CCM, cipher block size must be 128bit");if(e&&(e.nSigBytes>13||e.nSigBytes<7))throw new Error("Byte size of iv must be between 7 and 13");return r.hn=e||new o.e([0,0],8),r.vn=15-r.hn.nSigBytes,r}return f(t,n),t.getB0=function(n,t,r,i){if(r.nSigBytes+i.nSigBytes!==15)throw new Error("LEN(Q)+LEN(N) must be 15");var e=255&(0|(n?1:0)<<6|(t-2)/2<<3|r.nSigBytes-1),u=i.clone().concat(r);return new o.e([e<<24],1).concat(u)},t.formatAssociatedDataAndPayload=function(n,t){var r,i=n.nSigBytes;if(0===i)r=new o.e([0],0);else if(i<Math.pow(2,16)-Math.pow(2,8))r=new o.e([i<<16],2);else{if(!(i<Math.pow(2,32)))throw new Error("LEN(A) larger than 2**32-1 is not supported");r=new o.e([4294836224],2).concat(new o.e([i],4))}for(var e=Math.floor(n.nSigBytes/4),u=0;u<e;u++)r.concat(new o.e([n.words[u]],4));n.nSigBytes%4&&(r.concat(new o.e([n.words[e]],n.nSigBytes%4)),r.concat(new o.e([0],4-n.nSigBytes%4))),r.nSigBytes%16&&r.concat(new o.e([0],16-r.nSigBytes%16));var f=Math.floor(t.nSigBytes/4);for(u=0;u<f;u++)r.concat(new o.e([t.words[u]],4));return t.nSigBytes%4&&(r.concat(new o.e([t.words[f]],t.nSigBytes%4)),r.concat(new o.e([0],4-t.nSigBytes%4))),r.nSigBytes%16&&r.concat(new o.e([0],16-r.nSigBytes%16)),r},t.genCtr=function(n,t,r){if(t.nSigBytes+n!==15)throw new Error("LEN(Q)+LEN(N) must be 15");for(var i=new o.e([(n-1&7)<<24],1),e=new o.e([],0),u=Math.floor(n/4),f=0;f<u-1;f++)e.concat(new o.e([0],4));return n%4?n>4?(e.concat(new o.e([0],n%4)),e.concat(new o.e([r],4))):e.concat(new o.e([r<<32-8*n],n)):e.concat(new o.e([r],4)),i.concat(t).concat(e)},t.mac=function(n,r,i,e,f,c){var s=new n({key:r,iv:i});if(4!==s.blockSize)throw new Error("In CCM, cipher block size must be 128bit");if(i&&(i.nSigBytes>13||i.nSigBytes<7))throw new Error("Byte size of iv must be between 7 and 13");var a=i||new o.e([0,0],8),h=(null==e?void 0:e.clone())||new o.e,v=h.nSigBytes,w=(null==f?void 0:f.clone())||new o.e,l=w.nSigBytes;if(l>>>0>4294967295)throw new Error("Byte length of Payload(plainText) larger than 2^32-1 (4,294,967,295byte) is not supported at this time.");var d=15-a.nSigBytes,b=(0,u.ur)(new o.e([0,l],8),d),y=c||16,p=t.getB0(Boolean(v),y,b,a),m=t.formatAssociatedDataAndPayload(h,w),j=p.words.slice();s.encryptBlock(j,0);for(var g=m.nSigBytes/16,O=m.words,E=j,_=0;_<g;_++){var A=[O[4*_]^E[0],O[4*_+1]^E[1],O[4*_+2]^E[2],O[4*_+3]^E[3]];s.encryptBlock(A,0),E=A}var M=new o.e(E,y),N=t.genCtr(d,a,0);s.encryptBlock(N.words,0);for(_=0;_<4;_++)M.words[_]^=N.words[_];return M.clamp(),M},t.combineCipherTextAndAuthTag=function(n,t){return n.clone().concat(t)},t.splitCipherTextAndAuthTag=function(n,t){var r=t||16;return{cipherText:(0,u.z6)(n,n.nSigBytes-r),authTag:(0,u.ur)(n,r)}},t.createEncryptor=function(n){return new t.Encryptor(n)},t.createDecryptor=function(n){return new t.Decryptor(n)},t.Encryptor=function(n){function r(){return null!==n&&n.apply(this,arguments)||this}return f(r,n),r.prototype.processBlock=function(n,r){var i=this.cn,e=i.blockSize,o=t.genCtr(this.vn,this.hn,this.an);i.encryptBlock(o.words,0);for(var u=0;u<e;u++)n[r+u]^=o.words[u];this.an++},r}(t),t.Decryptor=function(n){function r(){return null!==n&&n.apply(this,arguments)||this}return f(r,n),r.prototype.processBlock=function(n,r){var i=this.cn,e=i.blockSize,o=t.genCtr(this.vn,this.hn,this.an);i.encryptBlock(o.words,0);for(var u=0;u<e;u++)n[r+u]^=o.words[u];this.an++},r}(t),t}(e.T)}},t={};function r(i){var e=t[i];if(void 0!==e)return e.exports;var o=t[i]={exports:{}};return n[i](o,o.exports,r),o.exports}r.d=function(n,t){for(var i in t)r.o(t,i)&&!r.o(n,i)&&Object.defineProperty(n,i,{enumerable:!0,get:t[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"wn",{value:!0})};var i={};return function(){r.r(i),r.d(i,{CBCMAC:function(){return u}});var n=r(4768),t=r(3354),e=r(9691),o=r(3664);function u(r,i,u,f,c,s){var a=s&&s.Cipher?s.Cipher:e.AES,h="string"==typeof u?n.d.parse(u):u,v=f||new t.e([0,0]),w="string"==typeof i?n.d.parse(i):i,l="string"==typeof r?n.d.parse(r):r,d=c||16;return o.K.mac(a,h,v,w,l,d)}}(),i}()})); | |
| \ No newline at end of file | ... | ... |
| 1 | +export { CipherParams } from "./lib/algorithm/cipher/CipherParams"; | ... | ... |
app/static/content/jscrypto/CipherParams.js
0 → 100644
| 1 | +!function(r,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var n=t();for(var e in r.JsCrypto=r.JsCrypto||{},n)r.JsCrypto[e]=n[e]}}(this,(function(){return function(){"use strict";var r={d:function(t,n){for(var e in n)r.o(n,e)&&!r.o(t,e)&&Object.defineProperty(t,e,{enumerable:!0,get:n[e]})}};r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(r){if("object"==typeof window)return window}}(),r.o=function(r,t){return Object.prototype.hasOwnProperty.call(r,t)},r.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"t",{value:!0})};var t={};r.r(t),r.d(t,{CipherParams:function(){return y}});var n,e=function(r){for(var t=r.nSigBytes,n=r.words,e=[],i=0;i<t;i++){var o=n[i>>>2]>>>24-i%4*8&255;e.push((o>>>4).toString(16)),e.push((15&o).toString(16))}return e.join("")},i="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(n=parseInt((/msie (\d+)/.exec(i)||[])[1],10),isNaN(n)?(n=parseInt((/trident\/.*; rv:(\d+)/.exec(i)||[])[1],10),!isNaN(n)&&n):n);for(var a=function(){if("undefined"!=typeof window){var t=window.crypto||window.msCrypto;if(!t){if(function(r,t){return!1!==o&&(!t||("<"===r?o<t:"<="===r?o<=t:">"===r?o>t:">="===r?o>=t:o===t))}("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return t.getRandomValues(new Uint32Array(1))[0]}}return void 0!==r.g&&r.g.crypto?function(){return r.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}(),f=function(){function r(t,n){if(Array.isArray(t)||!t)return this.i=Array.isArray(t)?t:[],void(this.u="number"==typeof n?n:4*this.i.length);if(t instanceof r)return this.i=t.words.slice(),void(this.u=t.nSigBytes);var e;try{t instanceof ArrayBuffer?e=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(e=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw new Error("Invalid argument")}if(!e)throw new Error("Invalid argument");for(var i=e.byteLength,o=[],a=0;a<i;a++)o[a>>>2]|=e[a]<<24-a%4*8;this.i=o,this.u=i}return Object.defineProperty(r.prototype,"nSigBytes",{get:function(){return this.u},set:function(r){this.u=r},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"words",{get:function(){return this.i},enumerable:!1,configurable:!0}),r.prototype.toString=function(r){return r?r.stringify(this):e(this)},r.prototype.toUint8Array=function(){for(var r=this.i,t=this.u,n=new Uint8Array(t),e=0;e<t;e++)n[e]=r[e>>>2]>>>24-e%4*8&255;return n},r.prototype.concat=function(r){var t=r.words.slice(),n=r.nSigBytes;if(this.clamp(),this.u%4)for(var e=0;e<n;e++){var i=t[e>>>2]>>>24-e%4*8&255;this.i[this.u+e>>>2]|=i<<24-(this.u+e)%4*8}else for(e=0;e<n;e+=4)this.i[this.u+e>>>2]=t[e>>>2];return this.u+=n,this},r.prototype.clamp=function(){var r=this.u;this.i[r>>>2]&=4294967295<<32-r%4*8,this.i.length=Math.ceil(r/4)},r.prototype.clone=function(){return new r(this.i.slice(),this.u)},r.random=function(t){for(var n=[],e=0;e<t;e+=4)n.push(a());return new r(n,t)},r}(),u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",s=[],c=0;c<u.length;c++)s[u.charCodeAt(c)]=c;var h={stringify:function(r){var t=r.words,n=r.nSigBytes;r.clamp();for(var e=[],i=0;i<n;i+=3)for(var o=(t[i>>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,a=0;a<4&&i+.75*a<n;a++)e.push(u.charAt(o>>>6*(3-a)&63));var f=u.charAt(64);if(f)for(;e.length%4;)e.push(f);return e.join("")},parse:function(r){var t=r.length,n=u.charAt(64);if(n){var e=r.indexOf(n);-1!==e&&(t=e)}for(var i=[],o=0,a=0;a<t;a++)if(a%4){var c=s[r.charCodeAt(a-1)]<<a%4*2|s[r.charCodeAt(a)]>>>6-a%4*2;i[o>>>2]|=c<<24-o%4*8,o++}return new f(i,o)}},v={stringify:function(r){var t=r.cipherText,n=r.salt;return t?n?new f([1398893684,1701076831]).concat(n).concat(t).toString(h):t.toString(h):""},parse:function(r){var t,n=h.parse(r),e=n.words;return 1398893684===e[0]&&1701076831===e[1]&&(t=new f(e.slice(2,4)),e.splice(0,4),n.nSigBytes-=16),new y({cipherText:n,salt:t})}},y=function(){function r(r){this.formatter=v,r&&(this.cipherText=r.cipherText,this.key=r.key,this.iv=r.iv,this.salt=r.salt,this.Algorithm=r.Algorithm,this.mode=r.mode,this.padding=r.padding,this.blockSize=r.blockSize,this.formatter=r.formatter||v)}return r.prototype.toString=function(r){return(r||this.formatter).stringify(this)},r}();return t}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/DES.d.ts
0 → 100644
| 1 | +import { BlockCipher, BlockCipherProps } from "./lib/algorithm/cipher/BlockCipher"; | |
| 2 | +import { CipherProps, PropsWithKey } from "./lib/algorithm/cipher/Cipher"; | |
| 3 | +import { Word32Array } from "./lib/Word32Array"; | |
| 4 | +import { CipherParams } from "./lib/algorithm/cipher/CipherParams"; | |
| 5 | +export interface DESProps extends BlockCipherProps { | |
| 6 | +} | |
| 7 | +export declare class DES extends BlockCipher { | |
| 8 | + static readonly keySize: number; | |
| 9 | + static readonly ivSize: number; | |
| 10 | + protected _blockSize: number; | |
| 11 | + _props: PropsWithKey<DESProps>; | |
| 12 | + protected _subKeys: number[][]; | |
| 13 | + protected _invSubKeys: number[][]; | |
| 14 | + protected _lBlock: number; | |
| 15 | + protected _rBlock: number; | |
| 16 | + constructor(props: PropsWithKey<DESProps>); | |
| 17 | + protected _doReset(): void; | |
| 18 | + encryptBlock(words: number[], offset: number): void; | |
| 19 | + decryptBlock(words: number[], offset: number): void; | |
| 20 | + protected _doCryptoBlock(words: number[], offset: number, subKeys: number[][]): void; | |
| 21 | + protected _exchangeLR(offset: number, mask: number): void; | |
| 22 | + protected _exchangeRL(offset: number, mask: number): void; | |
| 23 | + /** | |
| 24 | + * Creates this cipher in encryption mode. | |
| 25 | + * | |
| 26 | + * @param {Word32Array} key The key. | |
| 27 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 28 | + * @return {Cipher} A cipher instance. | |
| 29 | + * @example | |
| 30 | + * var cipher = DES.createEncryptor(keyWordArray, { iv: ivWordArray }); | |
| 31 | + */ | |
| 32 | + static createEncryptor(key: Word32Array, props?: Partial<CipherProps>): DES; | |
| 33 | + /** | |
| 34 | + * Creates this cipher in decryption mode. | |
| 35 | + * | |
| 36 | + * @param {Word32Array} key The key. | |
| 37 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 38 | + * @return {Cipher} A cipher instance. | |
| 39 | + * @example | |
| 40 | + * var cipher = DES.createDecryptor(keyWordArray, { iv: ivWordArray }); | |
| 41 | + */ | |
| 42 | + static createDecryptor(key: Word32Array, props?: Partial<CipherProps>): DES; | |
| 43 | + /** | |
| 44 | + * Encrypt a message with key | |
| 45 | + * | |
| 46 | + * @param {Word32Array|string} message | |
| 47 | + * @param {Word32Array|string} key | |
| 48 | + * @param {Partial<AESProps>?} props | |
| 49 | + * @example | |
| 50 | + * var encryptedMessage = DES.encrypt("test", "pass"); | |
| 51 | + */ | |
| 52 | + static encrypt(message: Word32Array | string, key: Word32Array | string, props?: Partial<DESProps>): CipherParams; | |
| 53 | + /** | |
| 54 | + * Encrypt a encrypted message with key | |
| 55 | + * | |
| 56 | + * @param {CipherParams} cipherText | |
| 57 | + * @param {Word32Array|string} key | |
| 58 | + * @param {Partial<AESProps>?} props | |
| 59 | + * @example | |
| 60 | + * var encryptedMessage = DES.decrypt(cipherProps, "pass"); | |
| 61 | + */ | |
| 62 | + static decrypt(cipherText: CipherParams, key: Word32Array | string, props?: Partial<DESProps>): Word32Array; | |
| 63 | +} | ... | ... |
app/static/content/jscrypto/DES.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var r=t();for(var i in n.JsCrypto=n.JsCrypto||{},r)n.JsCrypto[i]=r[i]}}(this,(function(){return function(){"use strict";var n={6367:function(n,t,r){r.d(t,{Hmac:function(){return e}});var i=r(4768),e=function(){function n(n,t){this.i=n,"string"==typeof t&&(t=i.d.parse(t));var r=n.blockSize,e=4*r;t.nSigBytes>e&&(t=n.finalize(t)),t.clamp();for(var o=this.u=t.clone(),u=this.h=t.clone(),f=o.words,c=u.words,s=0;s<r;s++)f[s]^=1549556828,c[s]^=909522486;u.nSigBytes=e,o.nSigBytes=e,this.reset()}return n.prototype.reset=function(){this.i.reset(),this.i.update(this.h)},n.prototype.update=function(n){return this.i.update(n),this},n.prototype.finalize=function(n){var t=this.i.finalize(n);return this.i.reset(),this.i.finalize(this.u.clone().concat(t))},n}()},5561:function(n,t,r){r.d(t,{SHA256:function(){return v}});var i,e=r(1868),o=r(3354),u=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),f=[],c=[];function s(n){for(var t=Math.sqrt(n),r=2;r<=t;r++)if(!(n%r))return!1;return!0}function a(n){return 4294967296*(n-(0|n))|0}!function(){for(var n=2,t=0;t<64;)s(n)&&(t<8&&(f[t]=a(Math.pow(n,.5))),c[t]=a(Math.pow(n,1/3)),t++),n++}();var h=[],v=function(n){function t(t){var r=n.call(this,t)||this;return r.v=new o.e(f.slice(0)),r.j=t,t&&void 0!==t.hash&&(r.v=t.hash.clone()),r}return u(t,n),t.prototype.O=function(){this.v=new o.e(f.slice(0))},t.prototype.A=function(n,t){for(var r=this.v.words,i=r[0],e=r[1],o=r[2],u=r[3],f=r[4],s=r[5],a=r[6],v=r[7],w=0;w<64;w++){if(w<16)h[w]=0|n[t+w];else{var d=h[w-15],l=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,b=h[w-2],y=(b<<15|b>>>17)^(b<<13|b>>>19)^b>>>10;h[w]=l+h[w-7]+y+h[w-16]}var p=i&e^i&o^e&o,m=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),j=v+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(f&s^~f&a)+c[w]+h[w];v=a,a=s,s=f,f=u+j|0,u=o,o=e,e=i,i=j+(m+p)|0}r[0]=r[0]+i|0,r[1]=r[1]+e|0,r[2]=r[2]+o|0,r[3]=r[3]+u|0,r[4]=r[4]+f|0,r[5]=r[5]+s|0,r[6]=r[6]+a|0,r[7]=r[7]+v|0},t.prototype.N=function(){var n=this.k.words,t=8*this.I,r=8*this.k.nSigBytes;return n[r>>>5]|=128<<24-r%32,n[14+(r+64>>>9<<4)]=Math.floor(t/4294967296),n[15+(r+64>>>9<<4)]=t,this.k.nSigBytes=4*n.length,this.S(),this.v},t.prototype.clone=function(){return new t({hash:this.v,blockSize:this.U,data:this.k,nBytes:this.I})},t.hash=function(n,r){return new t(r).finalize(n)},t}(e.P)},3354:function(n,t,r){r.d(t,{e:function(){return o}});var i=r(5720),e=r(9054),o=function(){function n(t,r){if(Array.isArray(t)||!t)return this.F=Array.isArray(t)?t:[],void(this.H="number"==typeof r?r:4*this.F.length);if(t instanceof n)return this.F=t.words.slice(),void(this.H=t.nSigBytes);var i;try{t instanceof ArrayBuffer?i=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!i)throw new Error("Invalid argument");for(var e=i.byteLength,o=[],u=0;u<e;u++)o[u>>>2]|=i[u]<<24-u%4*8;this.F=o,this.H=e}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.H},set:function(n){this.H=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.F},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):i.p.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this.F,t=this.H,r=new Uint8Array(t),i=0;i<t;i++)r[i]=n[i>>>2]>>>24-i%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.H%4)for(var i=0;i<r;i++){var e=t[i>>>2]>>>24-i%4*8&255;this.F[this.H+i>>>2]|=e<<24-(this.H+i)%4*8}else for(i=0;i<r;i+=4)this.F[this.H+i>>>2]=t[i>>>2];return this.H+=r,this},n.prototype.clamp=function(){var n=this.H;this.F[n>>>2]&=4294967295<<32-n%4*8,this.F.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.F.slice(),this.H)},n.random=function(t){for(var r=[],i=0;i<t;i+=4)r.push((0,e.M)());return new n(r,t)},n}()},7211:function(n,t,r){r.d(t,{C:function(){return o}});var i=r(3354),e=r(4768),o=function(){function n(n){this.B=0,this.U=0,this.j=n,this.k=n&&void 0!==n.data?n.data.clone():new i.e,this.I=n&&"number"==typeof n.nBytes?n.nBytes:0}return Object.defineProperty(n.prototype,"blockSize",{get:function(){return this.U},enumerable:!1,configurable:!0}),n.prototype.reset=function(n,t){this.k=void 0!==n?n.clone():new i.e,this.I="number"==typeof t?t:0},n.prototype.R=function(n){var t="string"==typeof n?e.d.parse(n):n;this.k.concat(t),this.I+=t.nSigBytes},n.prototype.S=function(n){var t,r=this.k.words,e=this.k.nSigBytes,o=this.U,u=e/(4*this.U),f=(u=n?Math.ceil(u):Math.max((0|u)-this.B,0))*o,c=Math.min(4*f,e);if(f){for(var s=0;s<f;s+=o)this.A(r,s);t=r.splice(0,f),this.k.nSigBytes-=c}return new i.e(t,c)},n.prototype.A=function(n,t){throw new Error("Not implemented")},n}()},1868:function(n,t,r){r.d(t,{P:function(){return u}});var i,e=r(7211),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.U=16,r.j=t,t&&"number"==typeof t.blockSize&&(r.U=t.blockSize),r.reset(t?t.data:void 0,t?t.nBytes:void 0),r}return o(t,n),Object.defineProperty(t.prototype,"blockSize",{get:function(){return this.U},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.O()},t.prototype.update=function(n){return this.R(n),this.S(),this},t.prototype.finalize=function(n){return n&&this.R(n),this.N()},t.prototype.O=function(){throw new Error("Not implemented")},t.prototype.N=function(){throw new Error("Not implemented")},t}(e.C)},787:function(n,t,r){r.d(t,{G:function(){return s}});var i,e=r(9456),o=r(4344),u=r(7919),f=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),c=function(){return(c=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},s=function(n){function t(t){var r=n.call(this,t)||this;return r.U=4,r.q=o.n,r.J=u.l,r.j=t,r.q=void 0!==t.mode?t.mode:r.q,r.J=void 0!==t.padding?t.padding:r.J,r.reset(null==t?void 0:t.data,null==t?void 0:t.nBytes),r}return f(t,n),Object.defineProperty(t.prototype,"mode",{get:function(){return this.K},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"padding",{get:function(){return this.J},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){var i;n.prototype.reset.call(this,t,r),this.L===e.t.ENC_TRANSFORM_MODE?i=this.q.createEncryptor:(i=this.q.createDecryptor,this.B=1),this.q&&this.V===i?this.K=new this.q({cipher:this,iv:this.X}):(this.K=i.call(this.q,{cipher:this,iv:this.X}),this.V=i)},t.prototype.A=function(n,t){var r;null===(r=this.K)||void 0===r||r.processBlock(n,t)},t.prototype.N=function(){var n,t=this.J;return this.L===e.t.ENC_TRANSFORM_MODE?(t.pad(this.k,this.blockSize),n=this.S(!0)):(n=this.S(!0),t.unpad(n)),n},t.prototype.encryptBlock=function(n,t){throw new Error("Not implemented")},t.prototype.decryptBlock=function(n,t){throw new Error("Not implemented")},t.createEncryptor=function(n,r){return new t(c(c({},r=void 0===r?{}:r),{key:n,transformMode:e.t.ENC_TRANSFORM_MODE}))},t.createDecryptor=function(n,r){return new t(c(c({},r=void 0===r?{}:r),{key:n,transformMode:e.t.DEC_TRANSFORM_MODE}))},t}(e.t)},9456:function(n,t,r){r.d(t,{t:function(){return f}});var i,e=r(7211),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(){return(u=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},f=function(n){function t(t){var r=n.call(this,t)||this;return r.L=1,r.j=t,r.Y=t.key,r.X=void 0!==t.iv?t.iv:r.X,r.L=void 0!==t.transformMode?t.transformMode:r.L,r}return o(t,n),Object.defineProperty(t.prototype,"iv",{get:function(){return this.X},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.O()},t.prototype.process=function(n){return this.R(n),this.S()},t.prototype.finalize=function(n){return n&&this.R(n),this.N()},t.prototype.O=function(){throw new Error("Not implemented")},t.prototype.A=function(n,t){throw new Error("Not implemented")},t.prototype.N=function(){throw new Error("Not implemented")},t.createEncryptor=function(n,r){return new t(u(u({},r=void 0===r?{}:r),{key:n,transformMode:t.ENC_TRANSFORM_MODE}))},t.createDecryptor=function(n,r){return new t(u(u({},r=void 0===r?{}:r),{key:n,transformMode:t.DEC_TRANSFORM_MODE}))},t.ENC_TRANSFORM_MODE=1,t.DEC_TRANSFORM_MODE=2,t.keySize=4,t.ivSize=4,t}(e.C)},2505:function(n,t,r){r.d(t,{Q:function(){return e}});var i=r(1232),e=function(){function n(n){this.formatter=i.w,n&&(this.cipherText=n.cipherText,this.key=n.key,this.iv=n.iv,this.salt=n.salt,this.Algorithm=n.Algorithm,this.mode=n.mode,this.padding=n.padding,this.blockSize=n.blockSize,this.formatter=n.formatter||i.w)}return n.prototype.toString=function(n){return(n||this.formatter).stringify(this)},n}()},5693:function(n,t,r){r.d(t,{E:function(){return c}});var i=r(9109),e=r(2214),o=r(2505),u=r(1232),f=function(){return(f=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},c={encrypt:function(n,t,r,u){var c=u?f({},u):{},s=u&&u.KDF?u.KDF:e.s,a={};u&&u.kdfHasher&&(a.kdfHasher=u.kdfHasher),u&&u.kdfIterations&&(a.kdfIterations=u.kdfIterations),u&&u.kdfModule&&(a.kdfModule=u.kdfModule);var h=s.execute(r,n.keySize,n.ivSize,c.kdfSalt,a);c.iv=h.iv;var v=i.D.encrypt(n,t,h.key,c);return new o.Q(f(f({},v),{key:h.key,iv:h.iv,salt:h.salt}))},decrypt:function(n,t,r,o){var c=o?f({},o):{},s=c.KDF?c.KDF:e.s,a=c.formatter?c.formatter:u.w,h=(0,i.W)(t,a),v={};o&&o.kdfHasher&&(v.kdfHasher=o.kdfHasher),o&&o.kdfIterations&&(v.kdfIterations=o.kdfIterations),o&&o.kdfModule&&(v.kdfModule=o.kdfModule);var w=s.execute(r,n.keySize,n.ivSize,h.salt,v);return c.iv=w.iv,i.D.decrypt(n,h,w.key,c)}}},9109:function(n,t,r){r.d(t,{W:function(){return o},D:function(){return u}});var i=r(1232),e=r(2505);function o(n,t){return"string"==typeof n?t.parse(n):n}var u={encrypt:function(n,t,r,o){var u=n.createEncryptor(r,o),f=u.finalize(t);return new e.Q({cipherText:f,key:r,iv:u.iv,Algorithm:n,mode:u.mode,padding:u.padding,blockSize:u.blockSize,formatter:(null==o?void 0:o.formatter)||i.w})},decrypt:function(n,t,r,e){var u=n.createDecryptor(r,e),f=o(t,(null==e?void 0:e.formatter)||i.w);return u.finalize(f.cipherText||"")}}},1232:function(n,t,r){r.d(t,{w:function(){return u}});var i=r(2505),e=r(3354),o=r(1773),u={stringify:function(n){var t=n.cipherText,r=n.salt;return t?r?new e.e([1398893684,1701076831]).concat(r).concat(t).toString(o.D):t.toString(o.D):""},parse:function(n){var t,r=o.D.parse(n),u=r.words;return 1398893684===u[0]&&1701076831===u[1]&&(t=new e.e(u.slice(2,4)),u.splice(0,4),r.nSigBytes-=16),new i.Q({cipherText:r,salt:t})}}},2214:function(n,t,r){r.d(t,{s:function(){return f}});var i=r(3354),e=r(2505),o=r(7008),u=function(){return(u=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},f={execute:function(n,t,r,f,c){f||(f=i.e.random(8));var s=c&&c.kdfModule||o.E,a=c?{Hasher:c.kdfHasher,iterations:c.kdfIterations}:{},h=s.getKey(n,f,u(u({},a),{keySize:t+r})),v=new i.e(h.words.slice(t),4*r);return h.nSigBytes=4*t,new e.Q({key:h,iv:v,salt:f})}}},7008:function(n,t,r){r.d(t,{E:function(){return s}});var i,e=r(5561),o=r(6367),u=r(3354),f=r(9541),c=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),s=function(n){function t(t){var r=n.call(this,t)||this;return r.Z=4,r.$=e.SHA256,r.nn=1e4,t&&(r.Z=void 0!==t.keySize?t.keySize:r.Z,r.$=void 0!==t.Hasher?t.Hasher:r.$,r.nn=void 0!==t.iterations?t.iterations:r.nn),r}return c(t,n),t.prototype.compute=function(n,t){for(var r=new o.Hmac(new this.$,n),i=new u.e,e=new u.e([1]),f=i.words,c=e.words,s=this.Z,a=this.nn;f.length<s;){var h=r.update(t).finalize(e);r.reset();for(var v=h.words,w=v.length,d=h,l=1;l<a;l++){d=r.finalize(d),r.reset();for(var b=d.words,y=0;y<w;y++)v[y]^=b[y]}i.concat(h),c[0]++}return i.nSigBytes=4*s,i},t.getKey=function(n,r,i){return new t(i).compute(n,r)},t}(f._)},9541:function(n,t,r){r.d(t,{_:function(){return i}});var i=function(){function n(n){this.j=n}return n.prototype.compute=function(n,t){throw new Error("Not implemented")},n.getKey=function(n,t,r){throw new Error("Not implemented")},n}()},1863:function(n,t,r){r.d(t,{T:function(){return i}});var i=function(){function n(n){this.j=n,this.tn=n.cipher,this.X=n.iv}return n.prototype.processBlock=function(n,t){},n.createEncryptor=function(n){throw new Error("Not implemented yet")},n.createDecryptor=function(n){throw new Error("Not implemented yet")},n}()},4344:function(n,t,r){r.d(t,{n:function(){return u}});var i,e=r(1863),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.rn=[],r}return o(t,n),t.prototype.xorBlock=function(n,t,r){var i,e=this.X;e?(i=e.words,this.X=void 0):i=this.rn;for(var o=0;o<r;o++)n[t+o]^=i[o]},t.createEncryptor=function(n){return new t.Encryptor(n)},t.createDecryptor=function(n){return new t.Decryptor(n)},t.Encryptor=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return o(t,n),t.prototype.processBlock=function(n,t){var r=this.tn,i=r.blockSize;this.xorBlock(n,t,i),r.encryptBlock(n,t),this.rn=n.slice(t,t+i)},t}(t),t.Decryptor=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return o(t,n),t.prototype.processBlock=function(n,t){var r=this.tn,i=r.blockSize,e=n.slice(t,t+i);r.decryptBlock(n,t),this.xorBlock(n,t,i),this.rn=e},t}(t),t}(e.T)},7919:function(n,t,r){r.d(t,{l:function(){return e}});var i=r(3354);var e={pad:function(n,t){for(var r=4*t,e=r-n.nSigBytes%r,o=e<<24|e<<16|e<<8|e,u=[],f=0;f<e;f+=4)u.push(o);var c=new i.e(u,e);n.concat(c)},unpad:function(n){var t=255&n.words[n.nSigBytes-1>>>2];n.nSigBytes-=t}}},1756:function(n,t,r){r.d(t,{w:function(){return u}});var i,e="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(i=parseInt((/msie (\d+)/.exec(e)||[])[1],10),isNaN(i)?(i=parseInt((/trident\/.*; rv:(\d+)/.exec(e)||[])[1],10),!isNaN(i)&&i):i);function u(n,t){return!1!==o&&(!t||("<"===n?o<t:"<="===n?o<=t:">"===n?o>t:">="===n?o>=t:o===t))}},1773:function(n,t,r){r.d(t,{D:function(){return f}});for(var i=r(3354),e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=[],u=0;u<e.length;u++)o[e.charCodeAt(u)]=u;var f={stringify:function(n){var t=n.words,r=n.nSigBytes;n.clamp();for(var i=[],o=0;o<r;o+=3)for(var u=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,f=0;f<4&&o+.75*f<r;f++)i.push(e.charAt(u>>>6*(3-f)&63));var c=e.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(n){var t=n.length,r=e.charAt(64);if(r){var u=n.indexOf(r);-1!==u&&(t=u)}for(var f=[],c=0,s=0;s<t;s++)if(s%4){var a=o[n.charCodeAt(s-1)]<<s%4*2|o[n.charCodeAt(s)]>>>6-s%4*2;f[c>>>2]|=a<<24-c%4*8,c++}return new i.e(f,c)}}},5720:function(n,t,r){r.d(t,{p:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var r=[],e=0;e<t;e+=2)r[e>>>3]|=parseInt(n.substr(e,2),16)<<24-e%8*4;return new i.e(r,t/2)}}},8702:function(n,t,r){r.d(t,{m:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push(String.fromCharCode(o))}return i.join("")},parse:function(n){for(var t=n.length,r=[],e=0;e<t;e++)r[e>>>2]|=(255&n.charCodeAt(e))<<24-e%4*8;return new i.e(r,t)}}},4768:function(n,t,r){r.d(t,{d:function(){return e}});var i=r(8702),e={stringify:function(n){try{return decodeURIComponent(escape(i.m.stringify(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return i.m.parse(unescape(encodeURIComponent(n)))}}},9054:function(n,t,r){r.d(t,{M:function(){return e}});var i=r(1756);var e=function(){if("undefined"!=typeof window){var n=window.crypto||window.msCrypto;if(!n){if((0,i.w)("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return n.getRandomValues(new Uint32Array(1))[0]}}return void 0!==r.g&&r.g.crypto?function(){return r.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}()}},t={};function r(i){var e=t[i];if(void 0!==e)return e.exports;var o=t[i]={exports:{}};return n[i](o,o.exports,r),o.exports}r.d=function(n,t){for(var i in t)r.o(t,i)&&!r.o(n,i)&&Object.defineProperty(n,i,{enumerable:!0,get:t[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"en",{value:!0})};var i={};return function(){r.r(i),r.d(i,{DES:function(){return d}});var n,t=r(787),e=r(9456),o=r(5693),u=r(9109),f=(n=function(t,r){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(t,r)},function(t,r){function i(){this.constructor=t}n(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}),c=function(){return(c=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},s=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],a=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],h=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],v=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],w=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],d=function(n){function t(t){var r=n.call(this,t)||this;return r.U=2,r.on=[],r.un=[],r.fn=0,r.cn=0,r.j=t,r.O(),r}return f(t,n),t.prototype.O=function(){for(var n=this.Y.words,t=[],r=0;r<56;r++){var i=s[r]-1;t[r]=n[i>>>5]>>>31-i%32&1}for(var e=this.on=[],o=0;o<16;o++){var u=e[o]=[],f=h[o];for(r=0;r<24;r++)u[r/6|0]|=t[(a[r]-1+f)%28]<<31-r%6,u[4+(r/6|0)]|=t[28+(a[r+24]-1+f)%28]<<31-r%6;u[0]=u[0]<<1|u[0]>>>31;for(r=1;r<7;r++)u[r]=u[r]>>>4*(r-1)+3;u[7]=u[7]<<5|u[7]>>>27}this.un=[];for(r=0;r<16;r++)this.un[r]=e[15-r]},t.prototype.encryptBlock=function(n,t){this.sn(n,t,this.on)},t.prototype.decryptBlock=function(n,t){this.sn(n,t,this.un)},t.prototype.sn=function(n,t,r){this.fn=n[t],this.cn=n[t+1],this.an(4,252645135),this.an(16,65535),this.hn(2,858993459),this.hn(8,16711935),this.an(1,1431655765);for(var i=0;i<16;i++){for(var e=r[i],o=this.fn,u=this.cn,f=0,c=0;c<8;c++){var s=(u^e[c])&w[c];f|=v[c][s>>>0]}this.fn=u,this.cn=o^f}var a=this.fn;this.fn=this.cn,this.cn=a,this.an(1,1431655765),this.hn(8,16711935),this.hn(2,858993459),this.an(16,65535),this.an(4,252645135),n[t]=this.fn,n[t+1]=this.cn},t.prototype.an=function(n,t){var r=(this.fn>>>n^this.cn)&t;this.cn^=r,this.fn^=r<<n},t.prototype.hn=function(n,t){var r=(this.cn>>>n^this.fn)&t;this.fn^=r,this.cn^=r<<n},t.createEncryptor=function(n,r){return new t(c(c({},r=void 0===r?{}:r),{key:n,transformMode:e.t.ENC_TRANSFORM_MODE}))},t.createDecryptor=function(n,r){return new t(c(c({},r=void 0===r?{}:r),{key:n,transformMode:e.t.DEC_TRANSFORM_MODE}))},t.encrypt=function(n,r,i){return"string"==typeof r?o.E.encrypt(t,n,r,i):u.D.encrypt(t,n,r,i)},t.decrypt=function(n,r,i){return"string"==typeof r?o.E.decrypt(t,n,r,i):u.D.decrypt(t,n,r,i)},t.keySize=2,t.ivSize=2,t}(t.G)}(),i}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/DES3.d.ts
0 → 100644
| 1 | +import { BlockCipher, BlockCipherProps } from "./lib/algorithm/cipher/BlockCipher"; | |
| 2 | +import { CipherProps, PropsWithKey } from "./lib/algorithm/cipher/Cipher"; | |
| 3 | +import { DES } from "./DES"; | |
| 4 | +import { Word32Array } from "./lib/Word32Array"; | |
| 5 | +import { CipherParams } from "./lib/algorithm/cipher/CipherParams"; | |
| 6 | +export interface DES3Props extends BlockCipherProps { | |
| 7 | +} | |
| 8 | +export declare class DES3 extends BlockCipher { | |
| 9 | + static readonly keySize: number; | |
| 10 | + static readonly ivSize: number; | |
| 11 | + protected _blockSize: number; | |
| 12 | + protected _des1: DES; | |
| 13 | + protected _des2: DES; | |
| 14 | + protected _des3: DES; | |
| 15 | + constructor(props: PropsWithKey<DES3Props>); | |
| 16 | + protected _get3DES(): DES[]; | |
| 17 | + protected _doReset(): void; | |
| 18 | + encryptBlock(words: number[], offset: number): void; | |
| 19 | + decryptBlock(words: number[], offset: number): void; | |
| 20 | + /** | |
| 21 | + * Creates this cipher in encryption mode. | |
| 22 | + * | |
| 23 | + * @param {Word32Array} key The key. | |
| 24 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 25 | + * @return {Cipher} A cipher instance. | |
| 26 | + * @example | |
| 27 | + * var cipher = DES3.createEncryptor(keyWordArray, { iv: ivWordArray }); | |
| 28 | + */ | |
| 29 | + static createEncryptor(key: Word32Array, props?: Partial<CipherProps>): DES3; | |
| 30 | + /** | |
| 31 | + * Creates this cipher in decryption mode. | |
| 32 | + * | |
| 33 | + * @param {Word32Array} key The key. | |
| 34 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 35 | + * @return {Cipher} A cipher instance. | |
| 36 | + * @example | |
| 37 | + * var cipher = DES3.createDecryptor(keyWordArray, { iv: ivWordArray }); | |
| 38 | + */ | |
| 39 | + static createDecryptor(key: Word32Array, props?: Partial<CipherProps>): DES3; | |
| 40 | + /** | |
| 41 | + * Encrypt a message with key | |
| 42 | + * | |
| 43 | + * @param {Word32Array|string} message | |
| 44 | + * @param {Word32Array|string} key | |
| 45 | + * @param {Partial<AESProps>?} props | |
| 46 | + * @example | |
| 47 | + * var encryptedMessage = DES3.encrypt("test", "pass"); | |
| 48 | + */ | |
| 49 | + static encrypt(message: Word32Array | string, key: Word32Array | string, props?: Partial<DES3Props>): CipherParams; | |
| 50 | + /** | |
| 51 | + * Encrypt a encrypted message with key | |
| 52 | + * | |
| 53 | + * @param {CipherParams} cipherText | |
| 54 | + * @param {Word32Array|string} key | |
| 55 | + * @param {Partial<AESProps>?} props | |
| 56 | + * @example | |
| 57 | + * var encryptedMessage = DES3.decrypt(cipherProps, "pass"); | |
| 58 | + */ | |
| 59 | + static decrypt(cipherText: CipherParams, key: Word32Array | string, props?: Partial<DES3Props>): Word32Array; | |
| 60 | +} | ... | ... |
app/static/content/jscrypto/DES3.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var r=t();for(var i in n.JsCrypto=n.JsCrypto||{},r)n.JsCrypto[i]=r[i]}}(this,(function(){return function(){"use strict";var n={9910:function(n,t,r){r.d(t,{DES:function(){return l}});var i,e=r(787),o=r(9456),u=r(5693),f=r(9109),c=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),s=function(){return(s=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},a=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],h=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],v=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],w=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],d=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],l=function(n){function t(t){var r=n.call(this,t)||this;return r.i=2,r.u=[],r.h=[],r.v=0,r.j=0,r.O=t,r.A(),r}return c(t,n),t.prototype.A=function(){for(var n=this.k.words,t=[],r=0;r<56;r++){var i=a[r]-1;t[r]=n[i>>>5]>>>31-i%32&1}for(var e=this.u=[],o=0;o<16;o++){var u=e[o]=[],f=v[o];for(r=0;r<24;r++)u[r/6|0]|=t[(h[r]-1+f)%28]<<31-r%6,u[4+(r/6|0)]|=t[28+(h[r+24]-1+f)%28]<<31-r%6;u[0]=u[0]<<1|u[0]>>>31;for(r=1;r<7;r++)u[r]=u[r]>>>4*(r-1)+3;u[7]=u[7]<<5|u[7]>>>27}this.h=[];for(r=0;r<16;r++)this.h[r]=e[15-r]},t.prototype.encryptBlock=function(n,t){this.N(n,t,this.u)},t.prototype.decryptBlock=function(n,t){this.N(n,t,this.h)},t.prototype.N=function(n,t,r){this.v=n[t],this.j=n[t+1],this.I(4,252645135),this.I(16,65535),this.S(2,858993459),this.S(8,16711935),this.I(1,1431655765);for(var i=0;i<16;i++){for(var e=r[i],o=this.v,u=this.j,f=0,c=0;c<8;c++){var s=(u^e[c])&d[c];f|=w[c][s>>>0]}this.v=u,this.j=o^f}var a=this.v;this.v=this.j,this.j=a,this.I(1,1431655765),this.S(8,16711935),this.S(2,858993459),this.I(16,65535),this.I(4,252645135),n[t]=this.v,n[t+1]=this.j},t.prototype.I=function(n,t){var r=(this.v>>>n^this.j)&t;this.j^=r,this.v^=r<<n},t.prototype.S=function(n,t){var r=(this.j>>>n^this.v)&t;this.v^=r,this.j^=r<<n},t.createEncryptor=function(n,r){return new t(s(s({},r=void 0===r?{}:r),{key:n,transformMode:o.t.ENC_TRANSFORM_MODE}))},t.createDecryptor=function(n,r){return new t(s(s({},r=void 0===r?{}:r),{key:n,transformMode:o.t.DEC_TRANSFORM_MODE}))},t.encrypt=function(n,r,i){return"string"==typeof r?u.E.encrypt(t,n,r,i):f.D.encrypt(t,n,r,i)},t.decrypt=function(n,r,i){return"string"==typeof r?u.E.decrypt(t,n,r,i):f.D.decrypt(t,n,r,i)},t.keySize=2,t.ivSize=2,t}(e.G)},6367:function(n,t,r){r.d(t,{Hmac:function(){return e}});var i=r(4768),e=function(){function n(n,t){this.U=n,"string"==typeof t&&(t=i.d.parse(t));var r=n.blockSize,e=4*r;t.nSigBytes>e&&(t=n.finalize(t)),t.clamp();for(var o=this.F=t.clone(),u=this.H=t.clone(),f=o.words,c=u.words,s=0;s<r;s++)f[s]^=1549556828,c[s]^=909522486;u.nSigBytes=e,o.nSigBytes=e,this.reset()}return n.prototype.reset=function(){this.U.reset(),this.U.update(this.H)},n.prototype.update=function(n){return this.U.update(n),this},n.prototype.finalize=function(n){var t=this.U.finalize(n);return this.U.reset(),this.U.finalize(this.F.clone().concat(t))},n}()},5561:function(n,t,r){r.d(t,{SHA256:function(){return v}});var i,e=r(1868),o=r(3354),u=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),f=[],c=[];function s(n){for(var t=Math.sqrt(n),r=2;r<=t;r++)if(!(n%r))return!1;return!0}function a(n){return 4294967296*(n-(0|n))|0}!function(){for(var n=2,t=0;t<64;)s(n)&&(t<8&&(f[t]=a(Math.pow(n,.5))),c[t]=a(Math.pow(n,1/3)),t++),n++}();var h=[],v=function(n){function t(t){var r=n.call(this,t)||this;return r.B=new o.e(f.slice(0)),r.O=t,t&&void 0!==t.hash&&(r.B=t.hash.clone()),r}return u(t,n),t.prototype.A=function(){this.B=new o.e(f.slice(0))},t.prototype.q=function(n,t){for(var r=this.B.words,i=r[0],e=r[1],o=r[2],u=r[3],f=r[4],s=r[5],a=r[6],v=r[7],w=0;w<64;w++){if(w<16)h[w]=0|n[t+w];else{var d=h[w-15],l=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,b=h[w-2],y=(b<<15|b>>>17)^(b<<13|b>>>19)^b>>>10;h[w]=l+h[w-7]+y+h[w-16]}var p=i&e^i&o^e&o,m=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),j=v+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(f&s^~f&a)+c[w]+h[w];v=a,a=s,s=f,f=u+j|0,u=o,o=e,e=i,i=j+(m+p)|0}r[0]=r[0]+i|0,r[1]=r[1]+e|0,r[2]=r[2]+o|0,r[3]=r[3]+u|0,r[4]=r[4]+f|0,r[5]=r[5]+s|0,r[6]=r[6]+a|0,r[7]=r[7]+v|0},t.prototype.R=function(){var n=this.J.words,t=8*this.K,r=8*this.J.nSigBytes;return n[r>>>5]|=128<<24-r%32,n[14+(r+64>>>9<<4)]=Math.floor(t/4294967296),n[15+(r+64>>>9<<4)]=t,this.J.nSigBytes=4*n.length,this.L(),this.B},t.prototype.clone=function(){return new t({hash:this.B,blockSize:this.i,data:this.J,nBytes:this.K})},t.hash=function(n,r){return new t(r).finalize(n)},t}(e.P)},3354:function(n,t,r){r.d(t,{e:function(){return o}});var i=r(5720),e=r(9054),o=function(){function n(t,r){if(Array.isArray(t)||!t)return this.V=Array.isArray(t)?t:[],void(this.X="number"==typeof r?r:4*this.V.length);if(t instanceof n)return this.V=t.words.slice(),void(this.X=t.nSigBytes);var i;try{t instanceof ArrayBuffer?i=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!i)throw new Error("Invalid argument");for(var e=i.byteLength,o=[],u=0;u<e;u++)o[u>>>2]|=i[u]<<24-u%4*8;this.V=o,this.X=e}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.X},set:function(n){this.X=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.V},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):i.p.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this.V,t=this.X,r=new Uint8Array(t),i=0;i<t;i++)r[i]=n[i>>>2]>>>24-i%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.X%4)for(var i=0;i<r;i++){var e=t[i>>>2]>>>24-i%4*8&255;this.V[this.X+i>>>2]|=e<<24-(this.X+i)%4*8}else for(i=0;i<r;i+=4)this.V[this.X+i>>>2]=t[i>>>2];return this.X+=r,this},n.prototype.clamp=function(){var n=this.X;this.V[n>>>2]&=4294967295<<32-n%4*8,this.V.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.V.slice(),this.X)},n.random=function(t){for(var r=[],i=0;i<t;i+=4)r.push((0,e.M)());return new n(r,t)},n}()},7211:function(n,t,r){r.d(t,{C:function(){return o}});var i=r(3354),e=r(4768),o=function(){function n(n){this.Y=0,this.i=0,this.O=n,this.J=n&&void 0!==n.data?n.data.clone():new i.e,this.K=n&&"number"==typeof n.nBytes?n.nBytes:0}return Object.defineProperty(n.prototype,"blockSize",{get:function(){return this.i},enumerable:!1,configurable:!0}),n.prototype.reset=function(n,t){this.J=void 0!==n?n.clone():new i.e,this.K="number"==typeof t?t:0},n.prototype.Z=function(n){var t="string"==typeof n?e.d.parse(n):n;this.J.concat(t),this.K+=t.nSigBytes},n.prototype.L=function(n){var t,r=this.J.words,e=this.J.nSigBytes,o=this.i,u=e/(4*this.i),f=(u=n?Math.ceil(u):Math.max((0|u)-this.Y,0))*o,c=Math.min(4*f,e);if(f){for(var s=0;s<f;s+=o)this.q(r,s);t=r.splice(0,f),this.J.nSigBytes-=c}return new i.e(t,c)},n.prototype.q=function(n,t){throw new Error("Not implemented")},n}()},1868:function(n,t,r){r.d(t,{P:function(){return u}});var i,e=r(7211),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.i=16,r.O=t,t&&"number"==typeof t.blockSize&&(r.i=t.blockSize),r.reset(t?t.data:void 0,t?t.nBytes:void 0),r}return o(t,n),Object.defineProperty(t.prototype,"blockSize",{get:function(){return this.i},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.A()},t.prototype.update=function(n){return this.Z(n),this.L(),this},t.prototype.finalize=function(n){return n&&this.Z(n),this.R()},t.prototype.A=function(){throw new Error("Not implemented")},t.prototype.R=function(){throw new Error("Not implemented")},t}(e.C)},787:function(n,t,r){r.d(t,{G:function(){return s}});var i,e=r(9456),o=r(4344),u=r(7919),f=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),c=function(){return(c=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},s=function(n){function t(t){var r=n.call(this,t)||this;return r.i=4,r.$=o.n,r.nn=u.l,r.O=t,r.$=void 0!==t.mode?t.mode:r.$,r.nn=void 0!==t.padding?t.padding:r.nn,r.reset(null==t?void 0:t.data,null==t?void 0:t.nBytes),r}return f(t,n),Object.defineProperty(t.prototype,"mode",{get:function(){return this.tn},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"padding",{get:function(){return this.nn},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){var i;n.prototype.reset.call(this,t,r),this.rn===e.t.ENC_TRANSFORM_MODE?i=this.$.createEncryptor:(i=this.$.createDecryptor,this.Y=1),this.$&&this.en===i?this.tn=new this.$({cipher:this,iv:this.on}):(this.tn=i.call(this.$,{cipher:this,iv:this.on}),this.en=i)},t.prototype.q=function(n,t){var r;null===(r=this.tn)||void 0===r||r.processBlock(n,t)},t.prototype.R=function(){var n,t=this.nn;return this.rn===e.t.ENC_TRANSFORM_MODE?(t.pad(this.J,this.blockSize),n=this.L(!0)):(n=this.L(!0),t.unpad(n)),n},t.prototype.encryptBlock=function(n,t){throw new Error("Not implemented")},t.prototype.decryptBlock=function(n,t){throw new Error("Not implemented")},t.createEncryptor=function(n,r){return new t(c(c({},r=void 0===r?{}:r),{key:n,transformMode:e.t.ENC_TRANSFORM_MODE}))},t.createDecryptor=function(n,r){return new t(c(c({},r=void 0===r?{}:r),{key:n,transformMode:e.t.DEC_TRANSFORM_MODE}))},t}(e.t)},9456:function(n,t,r){r.d(t,{t:function(){return f}});var i,e=r(7211),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(){return(u=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},f=function(n){function t(t){var r=n.call(this,t)||this;return r.rn=1,r.O=t,r.k=t.key,r.on=void 0!==t.iv?t.iv:r.on,r.rn=void 0!==t.transformMode?t.transformMode:r.rn,r}return o(t,n),Object.defineProperty(t.prototype,"iv",{get:function(){return this.on},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.A()},t.prototype.process=function(n){return this.Z(n),this.L()},t.prototype.finalize=function(n){return n&&this.Z(n),this.R()},t.prototype.A=function(){throw new Error("Not implemented")},t.prototype.q=function(n,t){throw new Error("Not implemented")},t.prototype.R=function(){throw new Error("Not implemented")},t.createEncryptor=function(n,r){return new t(u(u({},r=void 0===r?{}:r),{key:n,transformMode:t.ENC_TRANSFORM_MODE}))},t.createDecryptor=function(n,r){return new t(u(u({},r=void 0===r?{}:r),{key:n,transformMode:t.DEC_TRANSFORM_MODE}))},t.ENC_TRANSFORM_MODE=1,t.DEC_TRANSFORM_MODE=2,t.keySize=4,t.ivSize=4,t}(e.C)},2505:function(n,t,r){r.d(t,{Q:function(){return e}});var i=r(1232),e=function(){function n(n){this.formatter=i.w,n&&(this.cipherText=n.cipherText,this.key=n.key,this.iv=n.iv,this.salt=n.salt,this.Algorithm=n.Algorithm,this.mode=n.mode,this.padding=n.padding,this.blockSize=n.blockSize,this.formatter=n.formatter||i.w)}return n.prototype.toString=function(n){return(n||this.formatter).stringify(this)},n}()},5693:function(n,t,r){r.d(t,{E:function(){return c}});var i=r(9109),e=r(2214),o=r(2505),u=r(1232),f=function(){return(f=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},c={encrypt:function(n,t,r,u){var c=u?f({},u):{},s=u&&u.KDF?u.KDF:e.s,a={};u&&u.kdfHasher&&(a.kdfHasher=u.kdfHasher),u&&u.kdfIterations&&(a.kdfIterations=u.kdfIterations),u&&u.kdfModule&&(a.kdfModule=u.kdfModule);var h=s.execute(r,n.keySize,n.ivSize,c.kdfSalt,a);c.iv=h.iv;var v=i.D.encrypt(n,t,h.key,c);return new o.Q(f(f({},v),{key:h.key,iv:h.iv,salt:h.salt}))},decrypt:function(n,t,r,o){var c=o?f({},o):{},s=c.KDF?c.KDF:e.s,a=c.formatter?c.formatter:u.w,h=(0,i.W)(t,a),v={};o&&o.kdfHasher&&(v.kdfHasher=o.kdfHasher),o&&o.kdfIterations&&(v.kdfIterations=o.kdfIterations),o&&o.kdfModule&&(v.kdfModule=o.kdfModule);var w=s.execute(r,n.keySize,n.ivSize,h.salt,v);return c.iv=w.iv,i.D.decrypt(n,h,w.key,c)}}},9109:function(n,t,r){r.d(t,{W:function(){return o},D:function(){return u}});var i=r(1232),e=r(2505);function o(n,t){return"string"==typeof n?t.parse(n):n}var u={encrypt:function(n,t,r,o){var u=n.createEncryptor(r,o),f=u.finalize(t);return new e.Q({cipherText:f,key:r,iv:u.iv,Algorithm:n,mode:u.mode,padding:u.padding,blockSize:u.blockSize,formatter:(null==o?void 0:o.formatter)||i.w})},decrypt:function(n,t,r,e){var u=n.createDecryptor(r,e),f=o(t,(null==e?void 0:e.formatter)||i.w);return u.finalize(f.cipherText||"")}}},1232:function(n,t,r){r.d(t,{w:function(){return u}});var i=r(2505),e=r(3354),o=r(1773),u={stringify:function(n){var t=n.cipherText,r=n.salt;return t?r?new e.e([1398893684,1701076831]).concat(r).concat(t).toString(o.D):t.toString(o.D):""},parse:function(n){var t,r=o.D.parse(n),u=r.words;return 1398893684===u[0]&&1701076831===u[1]&&(t=new e.e(u.slice(2,4)),u.splice(0,4),r.nSigBytes-=16),new i.Q({cipherText:r,salt:t})}}},2214:function(n,t,r){r.d(t,{s:function(){return f}});var i=r(3354),e=r(2505),o=r(7008),u=function(){return(u=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},f={execute:function(n,t,r,f,c){f||(f=i.e.random(8));var s=c&&c.kdfModule||o.E,a=c?{Hasher:c.kdfHasher,iterations:c.kdfIterations}:{},h=s.getKey(n,f,u(u({},a),{keySize:t+r})),v=new i.e(h.words.slice(t),4*r);return h.nSigBytes=4*t,new e.Q({key:h,iv:v,salt:f})}}},7008:function(n,t,r){r.d(t,{E:function(){return s}});var i,e=r(5561),o=r(6367),u=r(3354),f=r(9541),c=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),s=function(n){function t(t){var r=n.call(this,t)||this;return r.un=4,r.fn=e.SHA256,r.cn=1e4,t&&(r.un=void 0!==t.keySize?t.keySize:r.un,r.fn=void 0!==t.Hasher?t.Hasher:r.fn,r.cn=void 0!==t.iterations?t.iterations:r.cn),r}return c(t,n),t.prototype.compute=function(n,t){for(var r=new o.Hmac(new this.fn,n),i=new u.e,e=new u.e([1]),f=i.words,c=e.words,s=this.un,a=this.cn;f.length<s;){var h=r.update(t).finalize(e);r.reset();for(var v=h.words,w=v.length,d=h,l=1;l<a;l++){d=r.finalize(d),r.reset();for(var b=d.words,y=0;y<w;y++)v[y]^=b[y]}i.concat(h),c[0]++}return i.nSigBytes=4*s,i},t.getKey=function(n,r,i){return new t(i).compute(n,r)},t}(f._)},9541:function(n,t,r){r.d(t,{_:function(){return i}});var i=function(){function n(n){this.O=n}return n.prototype.compute=function(n,t){throw new Error("Not implemented")},n.getKey=function(n,t,r){throw new Error("Not implemented")},n}()},1863:function(n,t,r){r.d(t,{T:function(){return i}});var i=function(){function n(n){this.O=n,this.sn=n.cipher,this.on=n.iv}return n.prototype.processBlock=function(n,t){},n.createEncryptor=function(n){throw new Error("Not implemented yet")},n.createDecryptor=function(n){throw new Error("Not implemented yet")},n}()},4344:function(n,t,r){r.d(t,{n:function(){return u}});var i,e=r(1863),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.an=[],r}return o(t,n),t.prototype.xorBlock=function(n,t,r){var i,e=this.on;e?(i=e.words,this.on=void 0):i=this.an;for(var o=0;o<r;o++)n[t+o]^=i[o]},t.createEncryptor=function(n){return new t.Encryptor(n)},t.createDecryptor=function(n){return new t.Decryptor(n)},t.Encryptor=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return o(t,n),t.prototype.processBlock=function(n,t){var r=this.sn,i=r.blockSize;this.xorBlock(n,t,i),r.encryptBlock(n,t),this.an=n.slice(t,t+i)},t}(t),t.Decryptor=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return o(t,n),t.prototype.processBlock=function(n,t){var r=this.sn,i=r.blockSize,e=n.slice(t,t+i);r.decryptBlock(n,t),this.xorBlock(n,t,i),this.an=e},t}(t),t}(e.T)},7919:function(n,t,r){r.d(t,{l:function(){return e}});var i=r(3354);var e={pad:function(n,t){for(var r=4*t,e=r-n.nSigBytes%r,o=e<<24|e<<16|e<<8|e,u=[],f=0;f<e;f+=4)u.push(o);var c=new i.e(u,e);n.concat(c)},unpad:function(n){var t=255&n.words[n.nSigBytes-1>>>2];n.nSigBytes-=t}}},1756:function(n,t,r){r.d(t,{w:function(){return u}});var i,e="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(i=parseInt((/msie (\d+)/.exec(e)||[])[1],10),isNaN(i)?(i=parseInt((/trident\/.*; rv:(\d+)/.exec(e)||[])[1],10),!isNaN(i)&&i):i);function u(n,t){return!1!==o&&(!t||("<"===n?o<t:"<="===n?o<=t:">"===n?o>t:">="===n?o>=t:o===t))}},1773:function(n,t,r){r.d(t,{D:function(){return f}});for(var i=r(3354),e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=[],u=0;u<e.length;u++)o[e.charCodeAt(u)]=u;var f={stringify:function(n){var t=n.words,r=n.nSigBytes;n.clamp();for(var i=[],o=0;o<r;o+=3)for(var u=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,f=0;f<4&&o+.75*f<r;f++)i.push(e.charAt(u>>>6*(3-f)&63));var c=e.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(n){var t=n.length,r=e.charAt(64);if(r){var u=n.indexOf(r);-1!==u&&(t=u)}for(var f=[],c=0,s=0;s<t;s++)if(s%4){var a=o[n.charCodeAt(s-1)]<<s%4*2|o[n.charCodeAt(s)]>>>6-s%4*2;f[c>>>2]|=a<<24-c%4*8,c++}return new i.e(f,c)}}},5720:function(n,t,r){r.d(t,{p:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var r=[],e=0;e<t;e+=2)r[e>>>3]|=parseInt(n.substr(e,2),16)<<24-e%8*4;return new i.e(r,t/2)}}},8702:function(n,t,r){r.d(t,{m:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push(String.fromCharCode(o))}return i.join("")},parse:function(n){for(var t=n.length,r=[],e=0;e<t;e++)r[e>>>2]|=(255&n.charCodeAt(e))<<24-e%4*8;return new i.e(r,t)}}},4768:function(n,t,r){r.d(t,{d:function(){return e}});var i=r(8702),e={stringify:function(n){try{return decodeURIComponent(escape(i.m.stringify(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return i.m.parse(unescape(encodeURIComponent(n)))}}},9054:function(n,t,r){r.d(t,{M:function(){return e}});var i=r(1756);var e=function(){if("undefined"!=typeof window){var n=window.crypto||window.msCrypto;if(!n){if((0,i.w)("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return n.getRandomValues(new Uint32Array(1))[0]}}return void 0!==r.g&&r.g.crypto?function(){return r.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}()}},t={};function r(i){var e=t[i];if(void 0!==e)return e.exports;var o=t[i]={exports:{}};return n[i](o,o.exports,r),o.exports}r.d=function(n,t){for(var i in t)r.o(t,i)&&!r.o(n,i)&&Object.defineProperty(n,i,{enumerable:!0,get:t[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"hn",{value:!0})};var i={};return function(){r.r(i),r.d(i,{DES3:function(){return h}});var n,t=r(9109),e=r(787),o=r(9456),u=r(9910),f=r(3354),c=r(5693),s=(n=function(t,r){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(t,r)},function(t,r){function i(){this.constructor=t}n(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}),a=function(){return(a=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},h=function(n){function r(t){var r=n.call(this,t)||this;r.i=2,r.O=t;var i=r.vn();return r.wn=i[0],r.dn=i[1],r.ln=i[2],r}return s(r,n),r.prototype.vn=function(){var n=this.k.words;if(2!==n.length&&4!==n.length&&n.length<6)throw new Error("Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.");var t=n.slice(0,2),r=n.length<4?n.slice(0,2):n.slice(2,4),i=n.length<6?n.slice(0,2):n.slice(4,6);return[u.DES.createEncryptor(new f.e(t)),u.DES.createEncryptor(new f.e(r)),u.DES.createEncryptor(new f.e(i))]},r.prototype.A=function(){var n=this.vn();this.wn=n[0],this.dn=n[1],this.ln=n[2]},r.prototype.encryptBlock=function(n,t){this.wn.encryptBlock(n,t),this.dn.decryptBlock(n,t),this.ln.encryptBlock(n,t)},r.prototype.decryptBlock=function(n,t){this.ln.decryptBlock(n,t),this.dn.encryptBlock(n,t),this.wn.decryptBlock(n,t)},r.createEncryptor=function(n,t){return new r(a(a({},t=void 0===t?{}:t),{key:n,transformMode:o.t.ENC_TRANSFORM_MODE}))},r.createDecryptor=function(n,t){return new r(a(a({},t=void 0===t?{}:t),{key:n,transformMode:o.t.DEC_TRANSFORM_MODE}))},r.encrypt=function(n,i,e){return"string"==typeof i?c.E.encrypt(r,n,i,e):t.D.encrypt(r,n,i,e)},r.decrypt=function(n,i,e){return"string"==typeof i?c.E.decrypt(r,n,i,e):t.D.decrypt(r,n,i,e)},r.keySize=6,r.ivSize=2,r}(e.G)}(),i}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/EvpKDF.d.ts
0 → 100644
| 1 | +export { EvpKDF } from "./lib/algorithm/cipher/kdf/module/EvpKDF"; | ... | ... |
app/static/content/jscrypto/EvpKDF.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var r=t();for(var i in n.JsCrypto=n.JsCrypto||{},r)n.JsCrypto[i]=r[i]}}(this,(function(){return function(){"use strict";var n={670:function(n,t,r){r.d(t,{MD5:function(){return v}});var i,e=r(3354),o=r(1868),u=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),f=[];function c(n,t,r,i,e,o,u){var f=n+(t&r|~t&i)+e+u;return(f<<o|f>>>32-o)+t}function a(n,t,r,i,e,o,u){var f=n+(t&i|r&~i)+e+u;return(f<<o|f>>>32-o)+t}function s(n,t,r,i,e,o,u){var f=n+(t^r^i)+e+u;return(f<<o|f>>>32-o)+t}function h(n,t,r,i,e,o,u){var f=n+(r^(t|~i))+e+u;return(f<<o|f>>>32-o)+t}!function(){for(var n=0;n<64;n++)f[n]=4294967296*Math.abs(Math.sin(n+1))|0}();var v=function(n){function t(t){var r=n.call(this,t)||this;return r.t=new e.e([1732584193,4023233417,2562383102,271733878]),t&&void 0!==t.hash&&(r.t=t.hash.clone()),r}return u(t,n),t.prototype.i=function(){this.t=new e.e([1732584193,4023233417,2562383102,271733878])},t.prototype.u=function(n,t){for(var r=0;r<16;r++){var i=t+r,e=n[i];n[i]=16711935&(e<<8|e>>>24)|4278255360&(e<<24|e>>>8)}var o=this.t.words,u=n[t],v=n[t+1],w=n[t+2],d=n[t+3],l=n[t+4],y=n[t+5],b=n[t+6],p=n[t+7],m=n[t+8],g=n[t+9],j=n[t+10],A=n[t+11],O=n[t+12],E=n[t+13],M=n[t+14],_=n[t+15],I=o[0],U=o[1],N=o[2],S=o[3];I=c(I,U,N,S,u,7,f[0]),S=c(S,I,U,N,v,12,f[1]),N=c(N,S,I,U,w,17,f[2]),U=c(U,N,S,I,d,22,f[3]),I=c(I,U,N,S,l,7,f[4]),S=c(S,I,U,N,y,12,f[5]),N=c(N,S,I,U,b,17,f[6]),U=c(U,N,S,I,p,22,f[7]),I=c(I,U,N,S,m,7,f[8]),S=c(S,I,U,N,g,12,f[9]),N=c(N,S,I,U,j,17,f[10]),U=c(U,N,S,I,A,22,f[11]),I=c(I,U,N,S,O,7,f[12]),S=c(S,I,U,N,E,12,f[13]),N=c(N,S,I,U,M,17,f[14]),I=a(I,U=c(U,N,S,I,_,22,f[15]),N,S,v,5,f[16]),S=a(S,I,U,N,b,9,f[17]),N=a(N,S,I,U,A,14,f[18]),U=a(U,N,S,I,u,20,f[19]),I=a(I,U,N,S,y,5,f[20]),S=a(S,I,U,N,j,9,f[21]),N=a(N,S,I,U,_,14,f[22]),U=a(U,N,S,I,l,20,f[23]),I=a(I,U,N,S,g,5,f[24]),S=a(S,I,U,N,M,9,f[25]),N=a(N,S,I,U,d,14,f[26]),U=a(U,N,S,I,m,20,f[27]),I=a(I,U,N,S,E,5,f[28]),S=a(S,I,U,N,w,9,f[29]),N=a(N,S,I,U,p,14,f[30]),I=s(I,U=a(U,N,S,I,O,20,f[31]),N,S,y,4,f[32]),S=s(S,I,U,N,m,11,f[33]),N=s(N,S,I,U,A,16,f[34]),U=s(U,N,S,I,M,23,f[35]),I=s(I,U,N,S,v,4,f[36]),S=s(S,I,U,N,l,11,f[37]),N=s(N,S,I,U,p,16,f[38]),U=s(U,N,S,I,j,23,f[39]),I=s(I,U,N,S,E,4,f[40]),S=s(S,I,U,N,u,11,f[41]),N=s(N,S,I,U,d,16,f[42]),U=s(U,N,S,I,b,23,f[43]),I=s(I,U,N,S,g,4,f[44]),S=s(S,I,U,N,O,11,f[45]),N=s(N,S,I,U,_,16,f[46]),I=h(I,U=s(U,N,S,I,w,23,f[47]),N,S,u,6,f[48]),S=h(S,I,U,N,p,10,f[49]),N=h(N,S,I,U,M,15,f[50]),U=h(U,N,S,I,y,21,f[51]),I=h(I,U,N,S,O,6,f[52]),S=h(S,I,U,N,d,10,f[53]),N=h(N,S,I,U,j,15,f[54]),U=h(U,N,S,I,v,21,f[55]),I=h(I,U,N,S,m,6,f[56]),S=h(S,I,U,N,_,10,f[57]),N=h(N,S,I,U,b,15,f[58]),U=h(U,N,S,I,E,21,f[59]),I=h(I,U,N,S,l,6,f[60]),S=h(S,I,U,N,A,10,f[61]),N=h(N,S,I,U,w,15,f[62]),U=h(U,N,S,I,g,21,f[63]),o[0]=o[0]+I|0,o[1]=o[1]+U|0,o[2]=o[2]+N|0,o[3]=o[3]+S|0},t.prototype.h=function(){var n=this.v,t=n.words,r=8*this.l,i=8*n.nSigBytes;t[i>>>5]|=128<<24-i%32;var e=Math.floor(r/4294967296),o=r;t[15+(i+64>>>9<<4)]=16711935&(e<<8|e>>>24)|4278255360&(e<<24|e>>>8),t[14+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),n.nSigBytes=4*(t.length+1),this.j();for(var u=this.t,f=u.words,c=0;c<4;c++){var a=f[c];f[c]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}return u},t.prototype.clone=function(){return new t({hash:this.t,blockSize:this.A,data:this.v,nBytes:this.l})},t.hash=function(n){return(new t).finalize(n)},t}(o.P)},3354:function(n,t,r){r.d(t,{e:function(){return o}});var i=r(5720),e=r(9054),o=function(){function n(t,r){if(Array.isArray(t)||!t)return this.O=Array.isArray(t)?t:[],void(this._="number"==typeof r?r:4*this.O.length);if(t instanceof n)return this.O=t.words.slice(),void(this._=t.nSigBytes);var i;try{t instanceof ArrayBuffer?i=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!i)throw new Error("Invalid argument");for(var e=i.byteLength,o=[],u=0;u<e;u++)o[u>>>2]|=i[u]<<24-u%4*8;this.O=o,this._=e}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this._},set:function(n){this._=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.O},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):i.p.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this.O,t=this._,r=new Uint8Array(t),i=0;i<t;i++)r[i]=n[i>>>2]>>>24-i%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this._%4)for(var i=0;i<r;i++){var e=t[i>>>2]>>>24-i%4*8&255;this.O[this._+i>>>2]|=e<<24-(this._+i)%4*8}else for(i=0;i<r;i+=4)this.O[this._+i>>>2]=t[i>>>2];return this._+=r,this},n.prototype.clamp=function(){var n=this._;this.O[n>>>2]&=4294967295<<32-n%4*8,this.O.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.O.slice(),this._)},n.random=function(t){for(var r=[],i=0;i<t;i+=4)r.push((0,e.M)());return new n(r,t)},n}()},7211:function(n,t,r){r.d(t,{C:function(){return o}});var i=r(3354),e=r(4768),o=function(){function n(n){this.I=0,this.A=0,this.U=n,this.v=n&&void 0!==n.data?n.data.clone():new i.e,this.l=n&&"number"==typeof n.nBytes?n.nBytes:0}return Object.defineProperty(n.prototype,"blockSize",{get:function(){return this.A},enumerable:!1,configurable:!0}),n.prototype.reset=function(n,t){this.v=void 0!==n?n.clone():new i.e,this.l="number"==typeof t?t:0},n.prototype.N=function(n){var t="string"==typeof n?e.d.parse(n):n;this.v.concat(t),this.l+=t.nSigBytes},n.prototype.j=function(n){var t,r=this.v.words,e=this.v.nSigBytes,o=this.A,u=e/(4*this.A),f=(u=n?Math.ceil(u):Math.max((0|u)-this.I,0))*o,c=Math.min(4*f,e);if(f){for(var a=0;a<f;a+=o)this.u(r,a);t=r.splice(0,f),this.v.nSigBytes-=c}return new i.e(t,c)},n.prototype.u=function(n,t){throw new Error("Not implemented")},n}()},1868:function(n,t,r){r.d(t,{P:function(){return u}});var i,e=r(7211),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.A=16,r.U=t,t&&"number"==typeof t.blockSize&&(r.A=t.blockSize),r.reset(t?t.data:void 0,t?t.nBytes:void 0),r}return o(t,n),Object.defineProperty(t.prototype,"blockSize",{get:function(){return this.A},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.i()},t.prototype.update=function(n){return this.N(n),this.j(),this},t.prototype.finalize=function(n){return n&&this.N(n),this.h()},t.prototype.i=function(){throw new Error("Not implemented")},t.prototype.h=function(){throw new Error("Not implemented")},t}(e.C)},1756:function(n,t,r){r.d(t,{w:function(){return u}});var i,e="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(i=parseInt((/msie (\d+)/.exec(e)||[])[1],10),isNaN(i)?(i=parseInt((/trident\/.*; rv:(\d+)/.exec(e)||[])[1],10),!isNaN(i)&&i):i);function u(n,t){return!1!==o&&(!t||("<"===n?o<t:"<="===n?o<=t:">"===n?o>t:">="===n?o>=t:o===t))}},5720:function(n,t,r){r.d(t,{p:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var r=[],e=0;e<t;e+=2)r[e>>>3]|=parseInt(n.substr(e,2),16)<<24-e%8*4;return new i.e(r,t/2)}}},8702:function(n,t,r){r.d(t,{m:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push(String.fromCharCode(o))}return i.join("")},parse:function(n){for(var t=n.length,r=[],e=0;e<t;e++)r[e>>>2]|=(255&n.charCodeAt(e))<<24-e%4*8;return new i.e(r,t)}}},4768:function(n,t,r){r.d(t,{d:function(){return e}});var i=r(8702),e={stringify:function(n){try{return decodeURIComponent(escape(i.m.stringify(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return i.m.parse(unescape(encodeURIComponent(n)))}}},9054:function(n,t,r){r.d(t,{M:function(){return e}});var i=r(1756);var e=function(){if("undefined"!=typeof window){var n=window.crypto||window.msCrypto;if(!n){if((0,i.w)("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return n.getRandomValues(new Uint32Array(1))[0]}}return void 0!==r.g&&r.g.crypto?function(){return r.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}()}},t={};function r(i){var e=t[i];if(void 0!==e)return e.exports;var o=t[i]={exports:{}};return n[i](o,o.exports,r),o.exports}r.d=function(n,t){for(var i in t)r.o(t,i)&&!r.o(n,i)&&Object.defineProperty(n,i,{enumerable:!0,get:t[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"S",{value:!0})};var i={};return function(){r.r(i),r.d(i,{EvpKDF:function(){return f}});var n,t=r(670),e=r(3354),o=function(){function n(n){this.U=n}return n.prototype.compute=function(n,t){throw new Error("Not implemented")},n.getKey=function(n,t,r){throw new Error("Not implemented")},n}(),u=(n=function(t,r){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(t,r)},function(t,r){function i(){this.constructor=t}n(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}),f=function(n){function r(r){var i=n.call(this,r)||this;return i.F=4,i.k=t.MD5,i.B=1,r&&(i.F=void 0!==r.keySize?r.keySize:i.F,i.k=void 0!==r.Hasher?r.Hasher:i.k,i.B=void 0!==r.iterations?r.iterations:i.B),i}return u(r,n),r.prototype.compute=function(n,t){for(var r,i=new this.k,o=new e.e,u=o.words,f=this.F,c=this.B;u.length<f;){r&&i.update(r),r=i.update(n).finalize(t),i.reset();for(var a=1;a<c;a++)r=i.finalize(r),i.reset();o.concat(r)}return o.nSigBytes=4*f,o},r.getKey=function(n,t,i){return new r(i).compute(n,t)},r}(o)}(),i}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/GMAC.d.ts
0 → 100644
| 1 | +import { Word32Array } from "./lib/Word32Array"; | |
| 2 | +import { BlockCipher } from "./lib/algorithm/cipher/BlockCipher"; | |
| 3 | +export declare type GMACProps = { | |
| 4 | + Cipher: typeof BlockCipher; | |
| 5 | +}; | |
| 6 | +export declare function GMAC(message: Word32Array | string, key: Word32Array | string, iv?: Word32Array, tagLength?: number, props?: Partial<GMACProps>): Word32Array; | ... | ... |
app/static/content/jscrypto/GMAC.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var r=t();for(var i in n.JsCrypto=n.JsCrypto||{},r)n.JsCrypto[i]=r[i]}}(this,(function(){return function(){"use strict";var n={9691:function(n,t,r){r.d(t,{AES:function(){return O}});var i,e=r(9456),o=r(787),u=r(5693),f=r(9109),c=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),a=function(){return(a=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},s=[],h=[],v=[],w=[],l=[],d=[],b=[],y=[],p=[],m=[];!function(){for(var n=[],t=0;t<256;t++)n[t]=t<128?t<<1:t<<1^283;var r=0,i=0;for(t=0;t<256;t++){var e=i^i<<1^i<<2^i<<3^i<<4;e=e>>>8^255&e^99,s[r]=e,h[e]=r;var o=n[r],u=n[o],f=n[u],c=257*n[e]^16843008*e;v[r]=c<<24|c>>>8,w[r]=c<<16|c>>>16,l[r]=c<<8|c>>>24,d[r]=c,c=16843009*f^65537*u^257*o^16843008*r,b[e]=c<<24|c>>>8,y[e]=c<<16|c>>>16,p[e]=c<<8|c>>>24,m[e]=c,r?(r=o^n[n[n[f^o]]],i^=n[n[i]]):r=i=1}}();var j=[0,1,2,4,8,16,32,64,128,27,54],O=function(n){function t(t){var r=n.call(this,t)||this;return r.i=0,r.u=[],r.h=[],r.v=t,r.j(),r}return c(t,n),t.prototype.j=function(){var n;if(!this.i||this.O!==this.A){for(var t=this.O=this.A,r=t.words,i=t.nSigBytes/4,e=4*((this.i=i+6)+1),o=this.u=[],u=0;u<e;u++)u<i?o[u]=r[u]:(n=o[u-1],u%i?i>6&&u%i==4&&(n=s[n>>>24]<<24|s[n>>>16&255]<<16|s[n>>>8&255]<<8|s[255&n]):(n=s[(n=n<<8|n>>>24)>>>24]<<24|s[n>>>16&255]<<16|s[n>>>8&255]<<8|s[255&n],n^=j[u/i|0]<<24),o[u]=o[u-i]^n);this.h=[];for(var f=0;f<e;f++){u=e-f;n=f%4?o[u]:o[u-4],this.h[f]=f<4||u<=4?n:b[s[n>>>24]]^y[s[n>>>16&255]]^p[s[n>>>8&255]]^m[s[255&n]]}}},t.prototype.encryptBlock=function(n,t){this.k(n,t,this.u,v,w,l,d,s)},t.prototype.decryptBlock=function(n,t){var r=n[t+1];n[t+1]=n[t+3],n[t+3]=r,this.k(n,t,this.h,b,y,p,m,h),r=n[t+1],n[t+1]=n[t+3],n[t+3]=r},t.prototype.k=function(n,t,r,i,e,o,u,f){for(var c=this.i,a=n[t]^r[0],s=n[t+1]^r[1],h=n[t+2]^r[2],v=n[t+3]^r[3],w=4,l=1;l<c;l++){var d=i[a>>>24]^e[s>>>16&255]^o[h>>>8&255]^u[255&v]^r[w++],b=i[s>>>24]^e[h>>>16&255]^o[v>>>8&255]^u[255&a]^r[w++],y=i[h>>>24]^e[v>>>16&255]^o[a>>>8&255]^u[255&s]^r[w++],p=i[v>>>24]^e[a>>>16&255]^o[s>>>8&255]^u[255&h]^r[w++];a=d,s=b,h=y,v=p}var m=(f[a>>>24]<<24|f[s>>>16&255]<<16|f[h>>>8&255]<<8|f[255&v])^r[w++],j=(f[s>>>24]<<24|f[h>>>16&255]<<16|f[v>>>8&255]<<8|f[255&a])^r[w++],O=(f[h>>>24]<<24|f[v>>>16&255]<<16|f[a>>>8&255]<<8|f[255&s])^r[w++],g=(f[v>>>24]<<24|f[a>>>16&255]<<16|f[s>>>8&255]<<8|f[255&h])^r[w++];n[t]=m,n[t+1]=j,n[t+2]=O,n[t+3]=g},t.createEncryptor=function(n,r){return new t(a(a({},r=void 0===r?{}:r),{key:n,transformMode:e.t.ENC_TRANSFORM_MODE}))},t.createDecryptor=function(n,r){return new t(a(a({},r=void 0===r?{}:r),{key:n,transformMode:e.t.DEC_TRANSFORM_MODE}))},t.encrypt=function(n,r,i){if("string"==typeof r)return u.E.encrypt(t,n,r,i);if(r.nSigBytes%4!=0)throw new Error("Key size must be multiple of 32bit/4byte/1word");return f.D.encrypt(t,n,r,i)},t.decrypt=function(n,r,i){if("string"==typeof r)return u.E.decrypt(t,n,r,i);if(r.nSigBytes%4!=0)throw new Error("Key size must be multiple of 32bit/4byte/1word");return f.D.decrypt(t,n,r,i)},t.keySize=8,t}(o.G)},6367:function(n,t,r){r.d(t,{Hmac:function(){return e}});var i=r(4768),e=function(){function n(n,t){this.I=n,"string"==typeof t&&(t=i.d.parse(t));var r=n.blockSize,e=4*r;t.nSigBytes>e&&(t=n.finalize(t)),t.clamp();for(var o=this.N=t.clone(),u=this.S=t.clone(),f=o.words,c=u.words,a=0;a<r;a++)f[a]^=1549556828,c[a]^=909522486;u.nSigBytes=e,o.nSigBytes=e,this.reset()}return n.prototype.reset=function(){this.I.reset(),this.I.update(this.S)},n.prototype.update=function(n){return this.I.update(n),this},n.prototype.finalize=function(n){var t=this.I.finalize(n);return this.I.reset(),this.I.finalize(this.N.clone().concat(t))},n}()},5561:function(n,t,r){r.d(t,{SHA256:function(){return v}});var i,e=r(1868),o=r(3354),u=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),f=[],c=[];function a(n){for(var t=Math.sqrt(n),r=2;r<=t;r++)if(!(n%r))return!1;return!0}function s(n){return 4294967296*(n-(0|n))|0}!function(){for(var n=2,t=0;t<64;)a(n)&&(t<8&&(f[t]=s(Math.pow(n,.5))),c[t]=s(Math.pow(n,1/3)),t++),n++}();var h=[],v=function(n){function t(t){var r=n.call(this,t)||this;return r.U=new o.e(f.slice(0)),r.v=t,t&&void 0!==t.hash&&(r.U=t.hash.clone()),r}return u(t,n),t.prototype.j=function(){this.U=new o.e(f.slice(0))},t.prototype.H=function(n,t){for(var r=this.U.words,i=r[0],e=r[1],o=r[2],u=r[3],f=r[4],a=r[5],s=r[6],v=r[7],w=0;w<64;w++){if(w<16)h[w]=0|n[t+w];else{var l=h[w-15],d=(l<<25|l>>>7)^(l<<14|l>>>18)^l>>>3,b=h[w-2],y=(b<<15|b>>>17)^(b<<13|b>>>19)^b>>>10;h[w]=d+h[w-7]+y+h[w-16]}var p=i&e^i&o^e&o,m=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),j=v+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(f&a^~f&s)+c[w]+h[w];v=s,s=a,a=f,f=u+j|0,u=o,o=e,e=i,i=j+(m+p)|0}r[0]=r[0]+i|0,r[1]=r[1]+e|0,r[2]=r[2]+o|0,r[3]=r[3]+u|0,r[4]=r[4]+f|0,r[5]=r[5]+a|0,r[6]=r[6]+s|0,r[7]=r[7]+v|0},t.prototype.F=function(){var n=this.B.words,t=8*this.K,r=8*this.B.nSigBytes;return n[r>>>5]|=128<<24-r%32,n[14+(r+64>>>9<<4)]=Math.floor(t/4294967296),n[15+(r+64>>>9<<4)]=t,this.B.nSigBytes=4*n.length,this.L(),this.U},t.prototype.clone=function(){return new t({hash:this.U,blockSize:this.R,data:this.B,nBytes:this.K})},t.hash=function(n,r){return new t(r).finalize(n)},t}(e.P)},3354:function(n,t,r){r.d(t,{e:function(){return o}});var i=r(5720),e=r(9054),o=function(){function n(t,r){if(Array.isArray(t)||!t)return this.q=Array.isArray(t)?t:[],void(this.X="number"==typeof r?r:4*this.q.length);if(t instanceof n)return this.q=t.words.slice(),void(this.X=t.nSigBytes);var i;try{t instanceof ArrayBuffer?i=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!i)throw new Error("Invalid argument");for(var e=i.byteLength,o=[],u=0;u<e;u++)o[u>>>2]|=i[u]<<24-u%4*8;this.q=o,this.X=e}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.X},set:function(n){this.X=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.q},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):i.p.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this.q,t=this.X,r=new Uint8Array(t),i=0;i<t;i++)r[i]=n[i>>>2]>>>24-i%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.X%4)for(var i=0;i<r;i++){var e=t[i>>>2]>>>24-i%4*8&255;this.q[this.X+i>>>2]|=e<<24-(this.X+i)%4*8}else for(i=0;i<r;i+=4)this.q[this.X+i>>>2]=t[i>>>2];return this.X+=r,this},n.prototype.clamp=function(){var n=this.X;this.q[n>>>2]&=4294967295<<32-n%4*8,this.q.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.q.slice(),this.X)},n.random=function(t){for(var r=[],i=0;i<t;i+=4)r.push((0,e.M)());return new n(r,t)},n}()},7211:function(n,t,r){r.d(t,{C:function(){return o}});var i=r(3354),e=r(4768),o=function(){function n(n){this.J=0,this.R=0,this.v=n,this.B=n&&void 0!==n.data?n.data.clone():new i.e,this.K=n&&"number"==typeof n.nBytes?n.nBytes:0}return Object.defineProperty(n.prototype,"blockSize",{get:function(){return this.R},enumerable:!1,configurable:!0}),n.prototype.reset=function(n,t){this.B=void 0!==n?n.clone():new i.e,this.K="number"==typeof t?t:0},n.prototype.Y=function(n){var t="string"==typeof n?e.d.parse(n):n;this.B.concat(t),this.K+=t.nSigBytes},n.prototype.L=function(n){var t,r=this.B.words,e=this.B.nSigBytes,o=this.R,u=e/(4*this.R),f=(u=n?Math.ceil(u):Math.max((0|u)-this.J,0))*o,c=Math.min(4*f,e);if(f){for(var a=0;a<f;a+=o)this.H(r,a);t=r.splice(0,f),this.B.nSigBytes-=c}return new i.e(t,c)},n.prototype.H=function(n,t){throw new Error("Not implemented")},n}()},1868:function(n,t,r){r.d(t,{P:function(){return u}});var i,e=r(7211),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.R=16,r.v=t,t&&"number"==typeof t.blockSize&&(r.R=t.blockSize),r.reset(t?t.data:void 0,t?t.nBytes:void 0),r}return o(t,n),Object.defineProperty(t.prototype,"blockSize",{get:function(){return this.R},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.j()},t.prototype.update=function(n){return this.Y(n),this.L(),this},t.prototype.finalize=function(n){return n&&this.Y(n),this.F()},t.prototype.j=function(){throw new Error("Not implemented")},t.prototype.F=function(){throw new Error("Not implemented")},t}(e.C)},787:function(n,t,r){r.d(t,{G:function(){return a}});var i,e=r(9456),o=r(4344),u=r(7919),f=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),c=function(){return(c=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},a=function(n){function t(t){var r=n.call(this,t)||this;return r.R=4,r.Z=o.n,r.$=u.l,r.v=t,r.Z=void 0!==t.mode?t.mode:r.Z,r.$=void 0!==t.padding?t.padding:r.$,r.reset(null==t?void 0:t.data,null==t?void 0:t.nBytes),r}return f(t,n),Object.defineProperty(t.prototype,"mode",{get:function(){return this.nn},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"padding",{get:function(){return this.$},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){var i;n.prototype.reset.call(this,t,r),this.tn===e.t.ENC_TRANSFORM_MODE?i=this.Z.createEncryptor:(i=this.Z.createDecryptor,this.J=1),this.Z&&this.rn===i?this.nn=new this.Z({cipher:this,iv:this.en}):(this.nn=i.call(this.Z,{cipher:this,iv:this.en}),this.rn=i)},t.prototype.H=function(n,t){var r;null===(r=this.nn)||void 0===r||r.processBlock(n,t)},t.prototype.F=function(){var n,t=this.$;return this.tn===e.t.ENC_TRANSFORM_MODE?(t.pad(this.B,this.blockSize),n=this.L(!0)):(n=this.L(!0),t.unpad(n)),n},t.prototype.encryptBlock=function(n,t){throw new Error("Not implemented")},t.prototype.decryptBlock=function(n,t){throw new Error("Not implemented")},t.createEncryptor=function(n,r){return new t(c(c({},r=void 0===r?{}:r),{key:n,transformMode:e.t.ENC_TRANSFORM_MODE}))},t.createDecryptor=function(n,r){return new t(c(c({},r=void 0===r?{}:r),{key:n,transformMode:e.t.DEC_TRANSFORM_MODE}))},t}(e.t)},9456:function(n,t,r){r.d(t,{t:function(){return f}});var i,e=r(7211),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(){return(u=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},f=function(n){function t(t){var r=n.call(this,t)||this;return r.tn=1,r.v=t,r.A=t.key,r.en=void 0!==t.iv?t.iv:r.en,r.tn=void 0!==t.transformMode?t.transformMode:r.tn,r}return o(t,n),Object.defineProperty(t.prototype,"iv",{get:function(){return this.en},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.j()},t.prototype.process=function(n){return this.Y(n),this.L()},t.prototype.finalize=function(n){return n&&this.Y(n),this.F()},t.prototype.j=function(){throw new Error("Not implemented")},t.prototype.H=function(n,t){throw new Error("Not implemented")},t.prototype.F=function(){throw new Error("Not implemented")},t.createEncryptor=function(n,r){return new t(u(u({},r=void 0===r?{}:r),{key:n,transformMode:t.ENC_TRANSFORM_MODE}))},t.createDecryptor=function(n,r){return new t(u(u({},r=void 0===r?{}:r),{key:n,transformMode:t.DEC_TRANSFORM_MODE}))},t.ENC_TRANSFORM_MODE=1,t.DEC_TRANSFORM_MODE=2,t.keySize=4,t.ivSize=4,t}(e.C)},2505:function(n,t,r){r.d(t,{Q:function(){return e}});var i=r(1232),e=function(){function n(n){this.formatter=i.w,n&&(this.cipherText=n.cipherText,this.key=n.key,this.iv=n.iv,this.salt=n.salt,this.Algorithm=n.Algorithm,this.mode=n.mode,this.padding=n.padding,this.blockSize=n.blockSize,this.formatter=n.formatter||i.w)}return n.prototype.toString=function(n){return(n||this.formatter).stringify(this)},n}()},5693:function(n,t,r){r.d(t,{E:function(){return c}});var i=r(9109),e=r(2214),o=r(2505),u=r(1232),f=function(){return(f=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},c={encrypt:function(n,t,r,u){var c=u?f({},u):{},a=u&&u.KDF?u.KDF:e.s,s={};u&&u.kdfHasher&&(s.kdfHasher=u.kdfHasher),u&&u.kdfIterations&&(s.kdfIterations=u.kdfIterations),u&&u.kdfModule&&(s.kdfModule=u.kdfModule);var h=a.execute(r,n.keySize,n.ivSize,c.kdfSalt,s);c.iv=h.iv;var v=i.D.encrypt(n,t,h.key,c);return new o.Q(f(f({},v),{key:h.key,iv:h.iv,salt:h.salt}))},decrypt:function(n,t,r,o){var c=o?f({},o):{},a=c.KDF?c.KDF:e.s,s=c.formatter?c.formatter:u.w,h=(0,i.W)(t,s),v={};o&&o.kdfHasher&&(v.kdfHasher=o.kdfHasher),o&&o.kdfIterations&&(v.kdfIterations=o.kdfIterations),o&&o.kdfModule&&(v.kdfModule=o.kdfModule);var w=a.execute(r,n.keySize,n.ivSize,h.salt,v);return c.iv=w.iv,i.D.decrypt(n,h,w.key,c)}}},9109:function(n,t,r){r.d(t,{W:function(){return o},D:function(){return u}});var i=r(1232),e=r(2505);function o(n,t){return"string"==typeof n?t.parse(n):n}var u={encrypt:function(n,t,r,o){var u=n.createEncryptor(r,o),f=u.finalize(t);return new e.Q({cipherText:f,key:r,iv:u.iv,Algorithm:n,mode:u.mode,padding:u.padding,blockSize:u.blockSize,formatter:(null==o?void 0:o.formatter)||i.w})},decrypt:function(n,t,r,e){var u=n.createDecryptor(r,e),f=o(t,(null==e?void 0:e.formatter)||i.w);return u.finalize(f.cipherText||"")}}},1232:function(n,t,r){r.d(t,{w:function(){return u}});var i=r(2505),e=r(3354),o=r(1773),u={stringify:function(n){var t=n.cipherText,r=n.salt;return t?r?new e.e([1398893684,1701076831]).concat(r).concat(t).toString(o.D):t.toString(o.D):""},parse:function(n){var t,r=o.D.parse(n),u=r.words;return 1398893684===u[0]&&1701076831===u[1]&&(t=new e.e(u.slice(2,4)),u.splice(0,4),r.nSigBytes-=16),new i.Q({cipherText:r,salt:t})}}},2214:function(n,t,r){r.d(t,{s:function(){return f}});var i=r(3354),e=r(2505),o=r(7008),u=function(){return(u=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},f={execute:function(n,t,r,f,c){f||(f=i.e.random(8));var a=c&&c.kdfModule||o.E,s=c?{Hasher:c.kdfHasher,iterations:c.kdfIterations}:{},h=a.getKey(n,f,u(u({},s),{keySize:t+r})),v=new i.e(h.words.slice(t),4*r);return h.nSigBytes=4*t,new e.Q({key:h,iv:v,salt:f})}}},7008:function(n,t,r){r.d(t,{E:function(){return a}});var i,e=r(5561),o=r(6367),u=r(3354),f=r(9541),c=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),a=function(n){function t(t){var r=n.call(this,t)||this;return r.on=4,r.un=e.SHA256,r.fn=1e4,t&&(r.on=void 0!==t.keySize?t.keySize:r.on,r.un=void 0!==t.Hasher?t.Hasher:r.un,r.fn=void 0!==t.iterations?t.iterations:r.fn),r}return c(t,n),t.prototype.compute=function(n,t){for(var r=new o.Hmac(new this.un,n),i=new u.e,e=new u.e([1]),f=i.words,c=e.words,a=this.on,s=this.fn;f.length<a;){var h=r.update(t).finalize(e);r.reset();for(var v=h.words,w=v.length,l=h,d=1;d<s;d++){l=r.finalize(l),r.reset();for(var b=l.words,y=0;y<w;y++)v[y]^=b[y]}i.concat(h),c[0]++}return i.nSigBytes=4*a,i},t.getKey=function(n,r,i){return new t(i).compute(n,r)},t}(f._)},9541:function(n,t,r){r.d(t,{_:function(){return i}});var i=function(){function n(n){this.v=n}return n.prototype.compute=function(n,t){throw new Error("Not implemented")},n.getKey=function(n,t,r){throw new Error("Not implemented")},n}()},1863:function(n,t,r){r.d(t,{T:function(){return i}});var i=function(){function n(n){this.v=n,this.cn=n.cipher,this.en=n.iv}return n.prototype.processBlock=function(n,t){},n.createEncryptor=function(n){throw new Error("Not implemented yet")},n.createDecryptor=function(n){throw new Error("Not implemented yet")},n}()},4344:function(n,t,r){r.d(t,{n:function(){return u}});var i,e=r(1863),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.an=[],r}return o(t,n),t.prototype.xorBlock=function(n,t,r){var i,e=this.en;e?(i=e.words,this.en=void 0):i=this.an;for(var o=0;o<r;o++)n[t+o]^=i[o]},t.createEncryptor=function(n){return new t.Encryptor(n)},t.createDecryptor=function(n){return new t.Decryptor(n)},t.Encryptor=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return o(t,n),t.prototype.processBlock=function(n,t){var r=this.cn,i=r.blockSize;this.xorBlock(n,t,i),r.encryptBlock(n,t),this.an=n.slice(t,t+i)},t}(t),t.Decryptor=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return o(t,n),t.prototype.processBlock=function(n,t){var r=this.cn,i=r.blockSize,e=n.slice(t,t+i);r.decryptBlock(n,t),this.xorBlock(n,t,i),this.an=e},t}(t),t}(e.T)},4055:function(n,t,r){r.d(t,{I4:function(){return e},z6:function(){return o}});var i=r(3354);function e(n){var t=n.nSigBytes%16;if(0!==t){for(var r=16-t,e=[],o=Math.floor(r/4),u=0;u<o;u++)e.push(0);r%4>0&&e.push(0),n.concat(new i.e(e,r))}}function o(n,t){return new i.e(n.words.slice(),t)}},7919:function(n,t,r){r.d(t,{l:function(){return e}});var i=r(3354);var e={pad:function(n,t){for(var r=4*t,e=r-n.nSigBytes%r,o=e<<24|e<<16|e<<8|e,u=[],f=0;f<e;f+=4)u.push(o);var c=new i.e(u,e);n.concat(c)},unpad:function(n){var t=255&n.words[n.nSigBytes-1>>>2];n.nSigBytes-=t}}},1756:function(n,t,r){r.d(t,{w:function(){return u}});var i,e="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(i=parseInt((/msie (\d+)/.exec(e)||[])[1],10),isNaN(i)?(i=parseInt((/trident\/.*; rv:(\d+)/.exec(e)||[])[1],10),!isNaN(i)&&i):i);function u(n,t){return!1!==o&&(!t||("<"===n?o<t:"<="===n?o<=t:">"===n?o>t:">="===n?o>=t:o===t))}},1773:function(n,t,r){r.d(t,{D:function(){return f}});for(var i=r(3354),e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=[],u=0;u<e.length;u++)o[e.charCodeAt(u)]=u;var f={stringify:function(n){var t=n.words,r=n.nSigBytes;n.clamp();for(var i=[],o=0;o<r;o+=3)for(var u=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,f=0;f<4&&o+.75*f<r;f++)i.push(e.charAt(u>>>6*(3-f)&63));var c=e.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(n){var t=n.length,r=e.charAt(64);if(r){var u=n.indexOf(r);-1!==u&&(t=u)}for(var f=[],c=0,a=0;a<t;a++)if(a%4){var s=o[n.charCodeAt(a-1)]<<a%4*2|o[n.charCodeAt(a)]>>>6-a%4*2;f[c>>>2]|=s<<24-c%4*8,c++}return new i.e(f,c)}}},5720:function(n,t,r){r.d(t,{p:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var r=[],e=0;e<t;e+=2)r[e>>>3]|=parseInt(n.substr(e,2),16)<<24-e%8*4;return new i.e(r,t/2)}}},8702:function(n,t,r){r.d(t,{m:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push(String.fromCharCode(o))}return i.join("")},parse:function(n){for(var t=n.length,r=[],e=0;e<t;e++)r[e>>>2]|=(255&n.charCodeAt(e))<<24-e%4*8;return new i.e(r,t)}}},4768:function(n,t,r){r.d(t,{d:function(){return e}});var i=r(8702),e={stringify:function(n){try{return decodeURIComponent(escape(i.m.stringify(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return i.m.parse(unescape(encodeURIComponent(n)))}}},9054:function(n,t,r){r.d(t,{M:function(){return e}});var i=r(1756);var e=function(){if("undefined"!=typeof window){var n=window.crypto||window.msCrypto;if(!n){if((0,i.w)("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return n.getRandomValues(new Uint32Array(1))[0]}}return void 0!==r.g&&r.g.crypto?function(){return r.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}()},5607:function(n,t,r){r.d(t,{V:function(){return c}});var i,e=r(1863),o=r(3354),u=r(4055),f=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),c=function(n){function t(r){var i=n.call(this,r)||this;if(i.sn=[],i.hn=[],i.vn=[],4!==r.cipher.blockSize)throw new Error("In GCM block cipher mode, cipher block size must be 128bit");var e=r.cipher,o=r.iv,u=[0,0,0,0];return e.encryptBlock(u,0),i.sn=u,i.hn=t.getJ0(u,null==o?void 0:o.words),i.vn=i.hn.slice(),i}return f(t,n),t.getJ0=function(n,r){var i;if(r&&0!==r.length)if(3===r.length)i=[r[0],r[1],r[2],1];else{for(var e=r.length%4>0?4-r.length%4:0,o=r.slice(),u=0;u<e+2;u++)o.push(0);o.push(0),o.push(32*r.length),i=t.GHASH(n,o)}else i=[0,0,0,1];return i},t.inc32=function(n){var t=n.slice(),r=t[3]>>>0,i=r+1>>>0<r;if(t[3]=t[3]+1|0,i){var e=t[2]>>>0,o=e+1>>>0<e;t[2]=t[2]+1|0,o&&(t[1]=t[1]+1|0)}return t},t.mul=function(n,t){for(var r=[3774873600,0,0,0],i=[0,0,0,0],e=t.slice(),o=0;o<128;o++){(n[o>>>5]>>>31-o%32&1)>0&&(i[0]=i[0]^e[0],i[1]=i[1]^e[1],i[2]=i[2]^e[2],i[3]=i[3]^e[3]);var u=(1&e[3])>>>0,f=(1&e[0])>>>0,c=(1&e[1])>>>0,a=(1&e[2])>>>0;e[0]=e[0]>>>1,e[1]=e[1]>>>1|(f?2147483648:0),e[2]=e[2]>>>1|(c?2147483648:0),e[3]=e[3]>>>1|(a?2147483648:0),u>0&&(e[0]^=r[0],e[1]^=r[1],e[2]^=r[2],e[3]^=r[3])}return i},t.GHASH=function(n,r){if(n.length%4!=0)throw new Error("Length of 32bit word array 'H' must be multiple of 4(128bit)");if(r.length%4!=0)throw new Error("Length of 32bit word array 'X' must be multiple of 4(128bit)");for(var i=r.length,e=[0,0,0,0],o=0;o<i;o+=4)e[0]=e[0]^r[o],e[1]=e[1]^r[o+1],e[2]=e[2]^r[o+2],e[3]=e[3]^r[o+3],e=t.mul(e,n);return e},t.GCTR=function(n,r,i){if(0===i.nSigBytes)return i.clone();if(4!==r.length)throw new Error("Initial Counter Block size must be 128bit");for(var e=i.words,u=Math.ceil(i.nSigBytes/16),f=[r.slice()],c=1;c<u;c++){var a=t.inc32(f[c-1]);f.push(a)}var s=new o.e;for(c=0;c<u;c++){n.encryptBlock(f[c],0);var h=i.nSigBytes%16;if(c<u-1||0===h){var v=e[4*c]^f[c][0],w=e[4*c+1]^f[c][1],l=e[4*c+2]^f[c][2],d=e[4*c+3]^f[c][3],b=new o.e([v,w,l,d]);s.concat(b)}else{for(var y=[],p=0,m=Math.floor(h/4),j=0;j<m;j++){var O=e[4*c+j]^f[c][j];y.push(O),p+=4}var g=h%4;if(g>0){var _=e[4*c+m]<<32-8*g^f[c][m];y.push(_),p+=g}var A=new o.e(y,p);s.concat(A)}}return s.nSigBytes=i.nSigBytes,s.clamp(),s},t.mac=function(n,r,i,e,f,c){var a=new n({key:r,iv:i}),s=[0,0,0,0];a.encryptBlock(s,0);var h=t.getJ0(s,i.words),v=(null==e?void 0:e.clone())||new o.e,w=[0,8*v.nSigBytes],l=(null==f?void 0:f.clone())||new o.e,d=[0,8*l.nSigBytes],b=c||16;(0,u.I4)(v),(0,u.I4)(l);var y=v.words.concat(l.words).concat(w).concat(d),p=t.GHASH(s,y),m=t.GCTR(a,h,new o.e(p));return(0,u.z6)(m,b)},t.createEncryptor=function(n){return new t.Encryptor(n)},t.createDecryptor=function(n){return new t.Decryptor(n)},t.Encryptor=function(n){function r(){return null!==n&&n.apply(this,arguments)||this}return f(r,n),r.prototype.processBlock=function(n,r){var i=this.cn.blockSize;this.vn=t.inc32(this.vn);for(var e=new o.e(n.slice(r,r+i)),u=t.GCTR(this.cn,this.vn,e),f=0;f<i;f++)n[r+f]=u.words[f]},r}(t),t.Decryptor=function(n){function r(){return null!==n&&n.apply(this,arguments)||this}return f(r,n),r.prototype.processBlock=function(n,r){var i=this.cn.blockSize;this.vn=t.inc32(this.vn);for(var e=new o.e(n.slice(r,r+i)),u=t.GCTR(this.cn,this.vn,e),f=0;f<i;f++)n[r+f]=u.words[f]},r}(t),t}(e.T)}},t={};function r(i){var e=t[i];if(void 0!==e)return e.exports;var o=t[i]={exports:{}};return n[i](o,o.exports,r),o.exports}r.d=function(n,t){for(var i in t)r.o(t,i)&&!r.o(n,i)&&Object.defineProperty(n,i,{enumerable:!0,get:t[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"wn",{value:!0})};var i={};return function(){r.r(i),r.d(i,{GMAC:function(){return u}});var n=r(4768),t=r(3354),e=r(9691),o=r(5607);function u(r,i,u,f,c){var a="string"==typeof r?n.d.parse(r):r,s=u||new t.e([0,0,0,0]),h=c&&c.Cipher?c.Cipher:e.AES,v="string"==typeof i?n.d.parse(i):i,w=f||16;return o.V.mac(h,v,s,a,void 0,w)}}(),i}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/Hex.d.ts
0 → 100644
| 1 | +export { Hex } from "./lib/encoder/Hex"; | ... | ... |
app/static/content/jscrypto/Hex.js
0 → 100644
| 1 | +!function(n,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else if("object"==typeof exports)exports.JsCrypto=r();else{var t=r();for(var e in n.JsCrypto=n.JsCrypto||{},t)n.JsCrypto[e]=t[e]}}(this,(function(){return function(){"use strict";var n={d:function(r,t){for(var e in t)n.o(t,e)&&!n.o(r,e)&&Object.defineProperty(r,e,{enumerable:!0,get:t[e]})}};n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),n.o=function(n,r){return Object.prototype.hasOwnProperty.call(n,r)},n.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"t",{value:!0})};var r={};n.r(r),n.d(r,{Hex:function(){return f}});var t,e="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",i=(t=parseInt((/msie (\d+)/.exec(e)||[])[1],10),isNaN(t)?(t=parseInt((/trident\/.*; rv:(\d+)/.exec(e)||[])[1],10),!isNaN(t)&&t):t);var o=function(){if("undefined"!=typeof window){var r=window.crypto||window.msCrypto;if(!r){if(function(n,r){return!1!==i&&(!r||("<"===n?i<r:"<="===n?i<=r:">"===n?i>r:">="===n?i>=r:i===r))}("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return r.getRandomValues(new Uint32Array(1))[0]}}return void 0!==n.g&&n.g.crypto?function(){return n.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}(),a=function(){function n(r,t){if(Array.isArray(r)||!r)return this.i=Array.isArray(r)?r:[],void(this.u="number"==typeof t?t:4*this.i.length);if(r instanceof n)return this.i=r.words.slice(),void(this.u=r.nSigBytes);var e;try{r instanceof ArrayBuffer?e=new Uint8Array(r):(r instanceof Uint8Array||r instanceof Int8Array||r instanceof Uint8ClampedArray||r instanceof Int16Array||r instanceof Uint16Array||r instanceof Int32Array||r instanceof Uint32Array||r instanceof Float32Array||r instanceof Float64Array)&&(e=new Uint8Array(r.buffer,r.byteOffset,r.byteLength))}catch(n){throw new Error("Invalid argument")}if(!e)throw new Error("Invalid argument");for(var i=e.byteLength,o=[],a=0;a<i;a++)o[a>>>2]|=e[a]<<24-a%4*8;this.i=o,this.u=i}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.u},set:function(n){this.u=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.i},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):f.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this.i,r=this.u,t=new Uint8Array(r),e=0;e<r;e++)t[e]=n[e>>>2]>>>24-e%4*8&255;return t},n.prototype.concat=function(n){var r=n.words.slice(),t=n.nSigBytes;if(this.clamp(),this.u%4)for(var e=0;e<t;e++){var i=r[e>>>2]>>>24-e%4*8&255;this.i[this.u+e>>>2]|=i<<24-(this.u+e)%4*8}else for(e=0;e<t;e+=4)this.i[this.u+e>>>2]=r[e>>>2];return this.u+=t,this},n.prototype.clamp=function(){var n=this.u;this.i[n>>>2]&=4294967295<<32-n%4*8,this.i.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.i.slice(),this.u)},n.random=function(r){for(var t=[],e=0;e<r;e+=4)t.push(o());return new n(t,r)},n}(),f={stringify:function(n){for(var r=n.nSigBytes,t=n.words,e=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;e.push((o>>>4).toString(16)),e.push((15&o).toString(16))}return e.join("")},parse:function(n){var r=n.length;if(r%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var t=[],e=0;e<r;e+=2)t[e>>>3]|=parseInt(n.substr(e,2),16)<<24-e%8*4;return new a(t,r/2)}};return r}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/Hmac.d.ts
0 → 100644
| 1 | +import type { Hasher } from "./lib/algorithm/Hasher"; | |
| 2 | +import type { Word32Array } from "./lib/Word32Array"; | |
| 3 | +export declare class Hmac { | |
| 4 | + private _hasher; | |
| 5 | + private _oKey; | |
| 6 | + private _iKey; | |
| 7 | + constructor(hasher: Hasher, key: Word32Array | string); | |
| 8 | + /** | |
| 9 | + * Resets this Hmac to its initial state. | |
| 10 | + * | |
| 11 | + * @example | |
| 12 | + * hmacHasher.reset(); | |
| 13 | + */ | |
| 14 | + reset(): void; | |
| 15 | + /** | |
| 16 | + * Updates this Hmac with a message. | |
| 17 | + * | |
| 18 | + * @param {Word32Array|string} messageUpdate The message to append. | |
| 19 | + * @return {Hmac} This Hmac instance. | |
| 20 | + * @example | |
| 21 | + * hmacHasher.update('message'); | |
| 22 | + * hmacHasher.update(wordArray); | |
| 23 | + */ | |
| 24 | + update(messageUpdate: Word32Array | string): this; | |
| 25 | + /** | |
| 26 | + * Finalizes the Hmac computation. | |
| 27 | + * Note that the finalize operation is effectively a destructive, read-once operation. | |
| 28 | + * | |
| 29 | + * @param {Word32Array|string} messageUpdate (Optional) A final message update. | |
| 30 | + * @return {Word32Array} The Hmac. | |
| 31 | + * @example | |
| 32 | + * var hmac = hmacHasher.finalize(); | |
| 33 | + * var hmac = hmacHasher.finalize('message'); | |
| 34 | + * var hmac = hmacHasher.finalize(wordArray); | |
| 35 | + */ | |
| 36 | + finalize(messageUpdate: Word32Array | string): Word32Array; | |
| 37 | +} | ... | ... |
app/static/content/jscrypto/Hmac.js
0 → 100644
| 1 | +!function(n,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else if("object"==typeof exports)exports.JsCrypto=r();else{var t=r();for(var e in n.JsCrypto=n.JsCrypto||{},t)n.JsCrypto[e]=t[e]}}(this,(function(){return function(){"use strict";var n={3354:function(n,r,t){t.d(r,{e:function(){return o}});var e=t(5720),i=t(9054),o=function(){function n(r,t){if(Array.isArray(r)||!r)return this.t=Array.isArray(r)?r:[],void(this.i="number"==typeof t?t:4*this.t.length);if(r instanceof n)return this.t=r.words.slice(),void(this.i=r.nSigBytes);var e;try{r instanceof ArrayBuffer?e=new Uint8Array(r):(r instanceof Uint8Array||r instanceof Int8Array||r instanceof Uint8ClampedArray||r instanceof Int16Array||r instanceof Uint16Array||r instanceof Int32Array||r instanceof Uint32Array||r instanceof Float32Array||r instanceof Float64Array)&&(e=new Uint8Array(r.buffer,r.byteOffset,r.byteLength))}catch(n){throw new Error("Invalid argument")}if(!e)throw new Error("Invalid argument");for(var i=e.byteLength,o=[],u=0;u<i;u++)o[u>>>2]|=e[u]<<24-u%4*8;this.t=o,this.i=i}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.i},set:function(n){this.i=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.t},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):e.p.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this.t,r=this.i,t=new Uint8Array(r),e=0;e<r;e++)t[e]=n[e>>>2]>>>24-e%4*8&255;return t},n.prototype.concat=function(n){var r=n.words.slice(),t=n.nSigBytes;if(this.clamp(),this.i%4)for(var e=0;e<t;e++){var i=r[e>>>2]>>>24-e%4*8&255;this.t[this.i+e>>>2]|=i<<24-(this.i+e)%4*8}else for(e=0;e<t;e+=4)this.t[this.i+e>>>2]=r[e>>>2];return this.i+=t,this},n.prototype.clamp=function(){var n=this.i;this.t[n>>>2]&=4294967295<<32-n%4*8,this.t.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.t.slice(),this.i)},n.random=function(r){for(var t=[],e=0;e<r;e+=4)t.push((0,i.M)());return new n(t,r)},n}()},1756:function(n,r,t){t.d(r,{w:function(){return u}});var e,i="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(e=parseInt((/msie (\d+)/.exec(i)||[])[1],10),isNaN(e)?(e=parseInt((/trident\/.*; rv:(\d+)/.exec(i)||[])[1],10),!isNaN(e)&&e):e);function u(n,r){return!1!==o&&(!r||("<"===n?o<r:"<="===n?o<=r:">"===n?o>r:">="===n?o>=r:o===r))}},5720:function(n,r,t){t.d(r,{p:function(){return i}});var e=t(3354),i={stringify:function(n){for(var r=n.nSigBytes,t=n.words,e=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;e.push((o>>>4).toString(16)),e.push((15&o).toString(16))}return e.join("")},parse:function(n){var r=n.length;if(r%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var t=[],i=0;i<r;i+=2)t[i>>>3]|=parseInt(n.substr(i,2),16)<<24-i%8*4;return new e.e(t,r/2)}}},8702:function(n,r,t){t.d(r,{m:function(){return i}});var e=t(3354),i={stringify:function(n){for(var r=n.nSigBytes,t=n.words,e=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;e.push(String.fromCharCode(o))}return e.join("")},parse:function(n){for(var r=n.length,t=[],i=0;i<r;i++)t[i>>>2]|=(255&n.charCodeAt(i))<<24-i%4*8;return new e.e(t,r)}}},4768:function(n,r,t){t.d(r,{d:function(){return i}});var e=t(8702),i={stringify:function(n){try{return decodeURIComponent(escape(e.m.stringify(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return e.m.parse(unescape(encodeURIComponent(n)))}}},9054:function(n,r,t){t.d(r,{M:function(){return i}});var e=t(1756);var i=function(){if("undefined"!=typeof window){var n=window.crypto||window.msCrypto;if(!n){if((0,e.w)("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return n.getRandomValues(new Uint32Array(1))[0]}}return void 0!==t.g&&t.g.crypto?function(){return t.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}()}},r={};function t(e){var i=r[e];if(void 0!==i)return i.exports;var o=r[e]={exports:{}};return n[e](o,o.exports,t),o.exports}t.d=function(n,r){for(var e in r)t.o(r,e)&&!t.o(n,e)&&Object.defineProperty(n,e,{enumerable:!0,get:r[e]})},t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),t.o=function(n,r){return Object.prototype.hasOwnProperty.call(n,r)},t.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"u",{value:!0})};var e={};return function(){t.r(e),t.d(e,{Hmac:function(){return r}});var n=t(4768),r=function(){function r(r,t){this.h=r,"string"==typeof t&&(t=n.d.parse(t));var e=r.blockSize,i=4*e;t.nSigBytes>i&&(t=r.finalize(t)),t.clamp();for(var o=this.v=t.clone(),u=this.l=t.clone(),f=o.words,a=u.words,s=0;s<e;s++)f[s]^=1549556828,a[s]^=909522486;u.nSigBytes=i,o.nSigBytes=i,this.reset()}return r.prototype.reset=function(){this.h.reset(),this.h.update(this.l)},r.prototype.update=function(n){return this.h.update(n),this},r.prototype.finalize=function(n){var r=this.h.finalize(n);return this.h.reset(),this.h.finalize(this.v.clone().concat(r))},r}()}(),e}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/HmacMD5.d.ts
0 → 100644
app/static/content/jscrypto/HmacMD5.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var r=t();for(var i in n.JsCrypto=n.JsCrypto||{},r)n.JsCrypto[i]=r[i]}}(this,(function(){return function(){"use strict";var n={6367:function(n,t,r){r.d(t,{Hmac:function(){return e}});var i=r(4768),e=function(){function n(n,t){this.t=n,"string"==typeof t&&(t=i.d.parse(t));var r=n.blockSize,e=4*r;t.nSigBytes>e&&(t=n.finalize(t)),t.clamp();for(var o=this.i=t.clone(),u=this.u=t.clone(),f=o.words,c=u.words,a=0;a<r;a++)f[a]^=1549556828,c[a]^=909522486;u.nSigBytes=e,o.nSigBytes=e,this.reset()}return n.prototype.reset=function(){this.t.reset(),this.t.update(this.u)},n.prototype.update=function(n){return this.t.update(n),this},n.prototype.finalize=function(n){var t=this.t.finalize(n);return this.t.reset(),this.t.finalize(this.i.clone().concat(t))},n}()},670:function(n,t,r){r.d(t,{MD5:function(){return v}});var i,e=r(3354),o=r(1868),u=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),f=[];function c(n,t,r,i,e,o,u){var f=n+(t&r|~t&i)+e+u;return(f<<o|f>>>32-o)+t}function a(n,t,r,i,e,o,u){var f=n+(t&i|r&~i)+e+u;return(f<<o|f>>>32-o)+t}function s(n,t,r,i,e,o,u){var f=n+(t^r^i)+e+u;return(f<<o|f>>>32-o)+t}function h(n,t,r,i,e,o,u){var f=n+(r^(t|~i))+e+u;return(f<<o|f>>>32-o)+t}!function(){for(var n=0;n<64;n++)f[n]=4294967296*Math.abs(Math.sin(n+1))|0}();var v=function(n){function t(t){var r=n.call(this,t)||this;return r.h=new e.e([1732584193,4023233417,2562383102,271733878]),t&&void 0!==t.hash&&(r.h=t.hash.clone()),r}return u(t,n),t.prototype.v=function(){this.h=new e.e([1732584193,4023233417,2562383102,271733878])},t.prototype.l=function(n,t){for(var r=0;r<16;r++){var i=t+r,e=n[i];n[i]=16711935&(e<<8|e>>>24)|4278255360&(e<<24|e>>>8)}var o=this.h.words,u=n[t],v=n[t+1],w=n[t+2],d=n[t+3],l=n[t+4],y=n[t+5],b=n[t+6],p=n[t+7],m=n[t+8],g=n[t+9],j=n[t+10],A=n[t+11],M=n[t+12],O=n[t+13],I=n[t+14],E=n[t+15],U=o[0],_=o[1],S=o[2],N=o[3];U=c(U,_,S,N,u,7,f[0]),N=c(N,U,_,S,v,12,f[1]),S=c(S,N,U,_,w,17,f[2]),_=c(_,S,N,U,d,22,f[3]),U=c(U,_,S,N,l,7,f[4]),N=c(N,U,_,S,y,12,f[5]),S=c(S,N,U,_,b,17,f[6]),_=c(_,S,N,U,p,22,f[7]),U=c(U,_,S,N,m,7,f[8]),N=c(N,U,_,S,g,12,f[9]),S=c(S,N,U,_,j,17,f[10]),_=c(_,S,N,U,A,22,f[11]),U=c(U,_,S,N,M,7,f[12]),N=c(N,U,_,S,O,12,f[13]),S=c(S,N,U,_,I,17,f[14]),U=a(U,_=c(_,S,N,U,E,22,f[15]),S,N,v,5,f[16]),N=a(N,U,_,S,b,9,f[17]),S=a(S,N,U,_,A,14,f[18]),_=a(_,S,N,U,u,20,f[19]),U=a(U,_,S,N,y,5,f[20]),N=a(N,U,_,S,j,9,f[21]),S=a(S,N,U,_,E,14,f[22]),_=a(_,S,N,U,l,20,f[23]),U=a(U,_,S,N,g,5,f[24]),N=a(N,U,_,S,I,9,f[25]),S=a(S,N,U,_,d,14,f[26]),_=a(_,S,N,U,m,20,f[27]),U=a(U,_,S,N,O,5,f[28]),N=a(N,U,_,S,w,9,f[29]),S=a(S,N,U,_,p,14,f[30]),U=s(U,_=a(_,S,N,U,M,20,f[31]),S,N,y,4,f[32]),N=s(N,U,_,S,m,11,f[33]),S=s(S,N,U,_,A,16,f[34]),_=s(_,S,N,U,I,23,f[35]),U=s(U,_,S,N,v,4,f[36]),N=s(N,U,_,S,l,11,f[37]),S=s(S,N,U,_,p,16,f[38]),_=s(_,S,N,U,j,23,f[39]),U=s(U,_,S,N,O,4,f[40]),N=s(N,U,_,S,u,11,f[41]),S=s(S,N,U,_,d,16,f[42]),_=s(_,S,N,U,b,23,f[43]),U=s(U,_,S,N,g,4,f[44]),N=s(N,U,_,S,M,11,f[45]),S=s(S,N,U,_,E,16,f[46]),U=h(U,_=s(_,S,N,U,w,23,f[47]),S,N,u,6,f[48]),N=h(N,U,_,S,p,10,f[49]),S=h(S,N,U,_,I,15,f[50]),_=h(_,S,N,U,y,21,f[51]),U=h(U,_,S,N,M,6,f[52]),N=h(N,U,_,S,d,10,f[53]),S=h(S,N,U,_,j,15,f[54]),_=h(_,S,N,U,v,21,f[55]),U=h(U,_,S,N,m,6,f[56]),N=h(N,U,_,S,E,10,f[57]),S=h(S,N,U,_,b,15,f[58]),_=h(_,S,N,U,O,21,f[59]),U=h(U,_,S,N,l,6,f[60]),N=h(N,U,_,S,A,10,f[61]),S=h(S,N,U,_,w,15,f[62]),_=h(_,S,N,U,g,21,f[63]),o[0]=o[0]+U|0,o[1]=o[1]+_|0,o[2]=o[2]+S|0,o[3]=o[3]+N|0},t.prototype.j=function(){var n=this.A,t=n.words,r=8*this.O,i=8*n.nSigBytes;t[i>>>5]|=128<<24-i%32;var e=Math.floor(r/4294967296),o=r;t[15+(i+64>>>9<<4)]=16711935&(e<<8|e>>>24)|4278255360&(e<<24|e>>>8),t[14+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),n.nSigBytes=4*(t.length+1),this.I();for(var u=this.h,f=u.words,c=0;c<4;c++){var a=f[c];f[c]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}return u},t.prototype.clone=function(){return new t({hash:this.h,blockSize:this.U,data:this.A,nBytes:this.O})},t.hash=function(n){return(new t).finalize(n)},t}(o.P)},3354:function(n,t,r){r.d(t,{e:function(){return o}});var i=r(5720),e=r(9054),o=function(){function n(t,r){if(Array.isArray(t)||!t)return this._=Array.isArray(t)?t:[],void(this.S="number"==typeof r?r:4*this._.length);if(t instanceof n)return this._=t.words.slice(),void(this.S=t.nSigBytes);var i;try{t instanceof ArrayBuffer?i=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!i)throw new Error("Invalid argument");for(var e=i.byteLength,o=[],u=0;u<e;u++)o[u>>>2]|=i[u]<<24-u%4*8;this._=o,this.S=e}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.S},set:function(n){this.S=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this._},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):i.p.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this._,t=this.S,r=new Uint8Array(t),i=0;i<t;i++)r[i]=n[i>>>2]>>>24-i%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.S%4)for(var i=0;i<r;i++){var e=t[i>>>2]>>>24-i%4*8&255;this._[this.S+i>>>2]|=e<<24-(this.S+i)%4*8}else for(i=0;i<r;i+=4)this._[this.S+i>>>2]=t[i>>>2];return this.S+=r,this},n.prototype.clamp=function(){var n=this.S;this._[n>>>2]&=4294967295<<32-n%4*8,this._.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this._.slice(),this.S)},n.random=function(t){for(var r=[],i=0;i<t;i+=4)r.push((0,e.M)());return new n(r,t)},n}()},7211:function(n,t,r){r.d(t,{C:function(){return o}});var i=r(3354),e=r(4768),o=function(){function n(n){this.N=0,this.U=0,this.F=n,this.A=n&&void 0!==n.data?n.data.clone():new i.e,this.O=n&&"number"==typeof n.nBytes?n.nBytes:0}return Object.defineProperty(n.prototype,"blockSize",{get:function(){return this.U},enumerable:!1,configurable:!0}),n.prototype.reset=function(n,t){this.A=void 0!==n?n.clone():new i.e,this.O="number"==typeof t?t:0},n.prototype.H=function(n){var t="string"==typeof n?e.d.parse(n):n;this.A.concat(t),this.O+=t.nSigBytes},n.prototype.I=function(n){var t,r=this.A.words,e=this.A.nSigBytes,o=this.U,u=e/(4*this.U),f=(u=n?Math.ceil(u):Math.max((0|u)-this.N,0))*o,c=Math.min(4*f,e);if(f){for(var a=0;a<f;a+=o)this.l(r,a);t=r.splice(0,f),this.A.nSigBytes-=c}return new i.e(t,c)},n.prototype.l=function(n,t){throw new Error("Not implemented")},n}()},1868:function(n,t,r){r.d(t,{P:function(){return u}});var i,e=r(7211),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.U=16,r.F=t,t&&"number"==typeof t.blockSize&&(r.U=t.blockSize),r.reset(t?t.data:void 0,t?t.nBytes:void 0),r}return o(t,n),Object.defineProperty(t.prototype,"blockSize",{get:function(){return this.U},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.v()},t.prototype.update=function(n){return this.H(n),this.I(),this},t.prototype.finalize=function(n){return n&&this.H(n),this.j()},t.prototype.v=function(){throw new Error("Not implemented")},t.prototype.j=function(){throw new Error("Not implemented")},t}(e.C)},1756:function(n,t,r){r.d(t,{w:function(){return u}});var i,e="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(i=parseInt((/msie (\d+)/.exec(e)||[])[1],10),isNaN(i)?(i=parseInt((/trident\/.*; rv:(\d+)/.exec(e)||[])[1],10),!isNaN(i)&&i):i);function u(n,t){return!1!==o&&(!t||("<"===n?o<t:"<="===n?o<=t:">"===n?o>t:">="===n?o>=t:o===t))}},5720:function(n,t,r){r.d(t,{p:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var r=[],e=0;e<t;e+=2)r[e>>>3]|=parseInt(n.substr(e,2),16)<<24-e%8*4;return new i.e(r,t/2)}}},8702:function(n,t,r){r.d(t,{m:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push(String.fromCharCode(o))}return i.join("")},parse:function(n){for(var t=n.length,r=[],e=0;e<t;e++)r[e>>>2]|=(255&n.charCodeAt(e))<<24-e%4*8;return new i.e(r,t)}}},4768:function(n,t,r){r.d(t,{d:function(){return e}});var i=r(8702),e={stringify:function(n){try{return decodeURIComponent(escape(i.m.stringify(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return i.m.parse(unescape(encodeURIComponent(n)))}}},9054:function(n,t,r){r.d(t,{M:function(){return e}});var i=r(1756);var e=function(){if("undefined"!=typeof window){var n=window.crypto||window.msCrypto;if(!n){if((0,i.w)("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return n.getRandomValues(new Uint32Array(1))[0]}}return void 0!==r.g&&r.g.crypto?function(){return r.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}()}},t={};function r(i){var e=t[i];if(void 0!==e)return e.exports;var o=t[i]={exports:{}};return n[i](o,o.exports,r),o.exports}r.d=function(n,t){for(var i in t)r.o(t,i)&&!r.o(n,i)&&Object.defineProperty(n,i,{enumerable:!0,get:t[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"k",{value:!0})};var i={};return function(){r.r(i),r.d(i,{HmacMD5:function(){return e}});var n=r(6367),t=r(670);function e(r,i){return new n.Hmac(new t.MD5,i).finalize(r)}}(),i}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/HmacSHA1.d.ts
0 → 100644
app/static/content/jscrypto/HmacSHA1.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var r=t();for(var i in n.JsCrypto=n.JsCrypto||{},r)n.JsCrypto[i]=r[i]}}(this,(function(){return function(){"use strict";var n={6367:function(n,t,r){r.d(t,{Hmac:function(){return e}});var i=r(4768),e=function(){function n(n,t){this.t=n,"string"==typeof t&&(t=i.d.parse(t));var r=n.blockSize,e=4*r;t.nSigBytes>e&&(t=n.finalize(t)),t.clamp();for(var o=this.i=t.clone(),u=this.u=t.clone(),f=o.words,c=u.words,s=0;s<r;s++)f[s]^=1549556828,c[s]^=909522486;u.nSigBytes=e,o.nSigBytes=e,this.reset()}return n.prototype.reset=function(){this.t.reset(),this.t.update(this.u)},n.prototype.update=function(n){return this.t.update(n),this},n.prototype.finalize=function(n){var t=this.t.finalize(n);return this.t.reset(),this.t.finalize(this.i.clone().concat(t))},n}()},3173:function(n,t,r){r.d(t,{SHA1:function(){return c}});var i,e=r(1868),o=r(3354),u=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),f=[],c=function(n){function t(t){var r=n.call(this,t)||this;return r.h=new o.e([1732584193,4023233417,2562383102,271733878,3285377520]),r.v=t,t&&void 0!==t.hash&&(r.h=t.hash.clone()),r}return u(t,n),t.prototype.l=function(){this.h=new o.e([1732584193,4023233417,2562383102,271733878,3285377520])},t.prototype.A=function(n,t){for(var r=this.h.words,i=r[0],e=r[1],o=r[2],u=r[3],c=r[4],s=0;s<80;s++){if(s<16)f[s]=0|n[t+s];else{var a=f[s-3]^f[s-8]^f[s-14]^f[s-16];f[s]=a<<1|a>>>31}var h=(i<<5|i>>>27)+c+f[s];h+=s<20?1518500249+(e&o|~e&u):s<40?1859775393+(e^o^u):s<60?(e&o|e&u|o&u)-1894007588:(e^o^u)-899497514,c=u,u=o,o=e<<30|e>>>2,e=i,i=h}r[0]=r[0]+i|0,r[1]=r[1]+e|0,r[2]=r[2]+o|0,r[3]=r[3]+u|0,r[4]=r[4]+c|0},t.prototype.j=function(){var n=this.O.words,t=8*this.I,r=8*this.O.nSigBytes;return n[r>>>5]|=128<<24-r%32,n[14+(r+64>>>9<<4)]=Math.floor(t/4294967296),n[15+(r+64>>>9<<4)]=t,this.O.nSigBytes=4*n.length,this.U(),this.h},t.prototype.clone=function(){return new t({hash:this.h,blockSize:this.S,data:this.O,nBytes:this.I})},t.hash=function(n,r){return new t(r).finalize(n)},t}(e.P)},3354:function(n,t,r){r.d(t,{e:function(){return o}});var i=r(5720),e=r(9054),o=function(){function n(t,r){if(Array.isArray(t)||!t)return this._=Array.isArray(t)?t:[],void(this.N="number"==typeof r?r:4*this._.length);if(t instanceof n)return this._=t.words.slice(),void(this.N=t.nSigBytes);var i;try{t instanceof ArrayBuffer?i=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!i)throw new Error("Invalid argument");for(var e=i.byteLength,o=[],u=0;u<e;u++)o[u>>>2]|=i[u]<<24-u%4*8;this._=o,this.N=e}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.N},set:function(n){this.N=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this._},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):i.p.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this._,t=this.N,r=new Uint8Array(t),i=0;i<t;i++)r[i]=n[i>>>2]>>>24-i%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.N%4)for(var i=0;i<r;i++){var e=t[i>>>2]>>>24-i%4*8&255;this._[this.N+i>>>2]|=e<<24-(this.N+i)%4*8}else for(i=0;i<r;i+=4)this._[this.N+i>>>2]=t[i>>>2];return this.N+=r,this},n.prototype.clamp=function(){var n=this.N;this._[n>>>2]&=4294967295<<32-n%4*8,this._.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this._.slice(),this.N)},n.random=function(t){for(var r=[],i=0;i<t;i+=4)r.push((0,e.M)());return new n(r,t)},n}()},7211:function(n,t,r){r.d(t,{C:function(){return o}});var i=r(3354),e=r(4768),o=function(){function n(n){this.H=0,this.S=0,this.v=n,this.O=n&&void 0!==n.data?n.data.clone():new i.e,this.I=n&&"number"==typeof n.nBytes?n.nBytes:0}return Object.defineProperty(n.prototype,"blockSize",{get:function(){return this.S},enumerable:!1,configurable:!0}),n.prototype.reset=function(n,t){this.O=void 0!==n?n.clone():new i.e,this.I="number"==typeof t?t:0},n.prototype.F=function(n){var t="string"==typeof n?e.d.parse(n):n;this.O.concat(t),this.I+=t.nSigBytes},n.prototype.U=function(n){var t,r=this.O.words,e=this.O.nSigBytes,o=this.S,u=e/(4*this.S),f=(u=n?Math.ceil(u):Math.max((0|u)-this.H,0))*o,c=Math.min(4*f,e);if(f){for(var s=0;s<f;s+=o)this.A(r,s);t=r.splice(0,f),this.O.nSigBytes-=c}return new i.e(t,c)},n.prototype.A=function(n,t){throw new Error("Not implemented")},n}()},1868:function(n,t,r){r.d(t,{P:function(){return u}});var i,e=r(7211),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.S=16,r.v=t,t&&"number"==typeof t.blockSize&&(r.S=t.blockSize),r.reset(t?t.data:void 0,t?t.nBytes:void 0),r}return o(t,n),Object.defineProperty(t.prototype,"blockSize",{get:function(){return this.S},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.l()},t.prototype.update=function(n){return this.F(n),this.U(),this},t.prototype.finalize=function(n){return n&&this.F(n),this.j()},t.prototype.l=function(){throw new Error("Not implemented")},t.prototype.j=function(){throw new Error("Not implemented")},t}(e.C)},1756:function(n,t,r){r.d(t,{w:function(){return u}});var i,e="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(i=parseInt((/msie (\d+)/.exec(e)||[])[1],10),isNaN(i)?(i=parseInt((/trident\/.*; rv:(\d+)/.exec(e)||[])[1],10),!isNaN(i)&&i):i);function u(n,t){return!1!==o&&(!t||("<"===n?o<t:"<="===n?o<=t:">"===n?o>t:">="===n?o>=t:o===t))}},5720:function(n,t,r){r.d(t,{p:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var r=[],e=0;e<t;e+=2)r[e>>>3]|=parseInt(n.substr(e,2),16)<<24-e%8*4;return new i.e(r,t/2)}}},8702:function(n,t,r){r.d(t,{m:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push(String.fromCharCode(o))}return i.join("")},parse:function(n){for(var t=n.length,r=[],e=0;e<t;e++)r[e>>>2]|=(255&n.charCodeAt(e))<<24-e%4*8;return new i.e(r,t)}}},4768:function(n,t,r){r.d(t,{d:function(){return e}});var i=r(8702),e={stringify:function(n){try{return decodeURIComponent(escape(i.m.stringify(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return i.m.parse(unescape(encodeURIComponent(n)))}}},9054:function(n,t,r){r.d(t,{M:function(){return e}});var i=r(1756);var e=function(){if("undefined"!=typeof window){var n=window.crypto||window.msCrypto;if(!n){if((0,i.w)("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return n.getRandomValues(new Uint32Array(1))[0]}}return void 0!==r.g&&r.g.crypto?function(){return r.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}()}},t={};function r(i){var e=t[i];if(void 0!==e)return e.exports;var o=t[i]={exports:{}};return n[i](o,o.exports,r),o.exports}r.d=function(n,t){for(var i in t)r.o(t,i)&&!r.o(n,i)&&Object.defineProperty(n,i,{enumerable:!0,get:t[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"k",{value:!0})};var i={};return function(){r.r(i),r.d(i,{HmacSHA1:function(){return e}});var n=r(6367),t=r(3173);function e(r,i){return new n.Hmac(new t.SHA1,i).finalize(r)}}(),i}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/HmacSHA224.d.ts
0 → 100644
app/static/content/jscrypto/HmacSHA224.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var r=t();for(var i in n.JsCrypto=n.JsCrypto||{},r)n.JsCrypto[i]=r[i]}}(this,(function(){return function(){"use strict";var n={6367:function(n,t,r){r.d(t,{Hmac:function(){return e}});var i=r(4768),e=function(){function n(n,t){this.t=n,"string"==typeof t&&(t=i.d.parse(t));var r=n.blockSize,e=4*r;t.nSigBytes>e&&(t=n.finalize(t)),t.clamp();for(var o=this.i=t.clone(),u=this.u=t.clone(),f=o.words,c=u.words,s=0;s<r;s++)f[s]^=1549556828,c[s]^=909522486;u.nSigBytes=e,o.nSigBytes=e,this.reset()}return n.prototype.reset=function(){this.t.reset(),this.t.update(this.u)},n.prototype.update=function(n){return this.t.update(n),this},n.prototype.finalize=function(n){var t=this.t.finalize(n);return this.t.reset(),this.t.finalize(this.i.clone().concat(t))},n}()},766:function(n,t,r){r.d(t,{SHA224:function(){return f}});var i,e=r(3354),o=r(5561),u=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),f=function(n){function t(t){var r=n.call(this,t)||this;return r.h=new e.e([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),r.v=t,t&&void 0!==t.hash&&(r.h=t.hash.clone()),r}return u(t,n),t.prototype.l=function(){this.h=new e.e([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},t.prototype.A=function(){var t=n.prototype.A.call(this);return t.nSigBytes-=4,t},t.prototype.clone=function(){return new t({hash:this.h,blockSize:this.j,data:this.O,nBytes:this._})},t.hash=function(n,r){return new t(r).finalize(n)},t}(o.SHA256)},5561:function(n,t,r){r.d(t,{SHA256:function(){return v}});var i,e=r(1868),o=r(3354),u=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),f=[],c=[];function s(n){for(var t=Math.sqrt(n),r=2;r<=t;r++)if(!(n%r))return!1;return!0}function a(n){return 4294967296*(n-(0|n))|0}!function(){for(var n=2,t=0;t<64;)s(n)&&(t<8&&(f[t]=a(Math.pow(n,.5))),c[t]=a(Math.pow(n,1/3)),t++),n++}();var h=[],v=function(n){function t(t){var r=n.call(this,t)||this;return r.h=new o.e(f.slice(0)),r.v=t,t&&void 0!==t.hash&&(r.h=t.hash.clone()),r}return u(t,n),t.prototype.l=function(){this.h=new o.e(f.slice(0))},t.prototype.I=function(n,t){for(var r=this.h.words,i=r[0],e=r[1],o=r[2],u=r[3],f=r[4],s=r[5],a=r[6],v=r[7],w=0;w<64;w++){if(w<16)h[w]=0|n[t+w];else{var d=h[w-15],l=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,y=h[w-2],b=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;h[w]=l+h[w-7]+b+h[w-16]}var p=i&e^i&o^e&o,m=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),g=v+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(f&s^~f&a)+c[w]+h[w];v=a,a=s,s=f,f=u+g|0,u=o,o=e,e=i,i=g+(m+p)|0}r[0]=r[0]+i|0,r[1]=r[1]+e|0,r[2]=r[2]+o|0,r[3]=r[3]+u|0,r[4]=r[4]+f|0,r[5]=r[5]+s|0,r[6]=r[6]+a|0,r[7]=r[7]+v|0},t.prototype.A=function(){var n=this.O.words,t=8*this._,r=8*this.O.nSigBytes;return n[r>>>5]|=128<<24-r%32,n[14+(r+64>>>9<<4)]=Math.floor(t/4294967296),n[15+(r+64>>>9<<4)]=t,this.O.nSigBytes=4*n.length,this.S(),this.h},t.prototype.clone=function(){return new t({hash:this.h,blockSize:this.j,data:this.O,nBytes:this._})},t.hash=function(n,r){return new t(r).finalize(n)},t}(e.P)},3354:function(n,t,r){r.d(t,{e:function(){return o}});var i=r(5720),e=r(9054),o=function(){function n(t,r){if(Array.isArray(t)||!t)return this.U=Array.isArray(t)?t:[],void(this.H="number"==typeof r?r:4*this.U.length);if(t instanceof n)return this.U=t.words.slice(),void(this.H=t.nSigBytes);var i;try{t instanceof ArrayBuffer?i=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!i)throw new Error("Invalid argument");for(var e=i.byteLength,o=[],u=0;u<e;u++)o[u>>>2]|=i[u]<<24-u%4*8;this.U=o,this.H=e}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.H},set:function(n){this.H=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.U},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):i.p.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this.U,t=this.H,r=new Uint8Array(t),i=0;i<t;i++)r[i]=n[i>>>2]>>>24-i%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.H%4)for(var i=0;i<r;i++){var e=t[i>>>2]>>>24-i%4*8&255;this.U[this.H+i>>>2]|=e<<24-(this.H+i)%4*8}else for(i=0;i<r;i+=4)this.U[this.H+i>>>2]=t[i>>>2];return this.H+=r,this},n.prototype.clamp=function(){var n=this.H;this.U[n>>>2]&=4294967295<<32-n%4*8,this.U.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.U.slice(),this.H)},n.random=function(t){for(var r=[],i=0;i<t;i+=4)r.push((0,e.M)());return new n(r,t)},n}()},7211:function(n,t,r){r.d(t,{C:function(){return o}});var i=r(3354),e=r(4768),o=function(){function n(n){this.N=0,this.j=0,this.v=n,this.O=n&&void 0!==n.data?n.data.clone():new i.e,this._=n&&"number"==typeof n.nBytes?n.nBytes:0}return Object.defineProperty(n.prototype,"blockSize",{get:function(){return this.j},enumerable:!1,configurable:!0}),n.prototype.reset=function(n,t){this.O=void 0!==n?n.clone():new i.e,this._="number"==typeof t?t:0},n.prototype.F=function(n){var t="string"==typeof n?e.d.parse(n):n;this.O.concat(t),this._+=t.nSigBytes},n.prototype.S=function(n){var t,r=this.O.words,e=this.O.nSigBytes,o=this.j,u=e/(4*this.j),f=(u=n?Math.ceil(u):Math.max((0|u)-this.N,0))*o,c=Math.min(4*f,e);if(f){for(var s=0;s<f;s+=o)this.I(r,s);t=r.splice(0,f),this.O.nSigBytes-=c}return new i.e(t,c)},n.prototype.I=function(n,t){throw new Error("Not implemented")},n}()},1868:function(n,t,r){r.d(t,{P:function(){return u}});var i,e=r(7211),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.j=16,r.v=t,t&&"number"==typeof t.blockSize&&(r.j=t.blockSize),r.reset(t?t.data:void 0,t?t.nBytes:void 0),r}return o(t,n),Object.defineProperty(t.prototype,"blockSize",{get:function(){return this.j},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.l()},t.prototype.update=function(n){return this.F(n),this.S(),this},t.prototype.finalize=function(n){return n&&this.F(n),this.A()},t.prototype.l=function(){throw new Error("Not implemented")},t.prototype.A=function(){throw new Error("Not implemented")},t}(e.C)},1756:function(n,t,r){r.d(t,{w:function(){return u}});var i,e="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(i=parseInt((/msie (\d+)/.exec(e)||[])[1],10),isNaN(i)?(i=parseInt((/trident\/.*; rv:(\d+)/.exec(e)||[])[1],10),!isNaN(i)&&i):i);function u(n,t){return!1!==o&&(!t||("<"===n?o<t:"<="===n?o<=t:">"===n?o>t:">="===n?o>=t:o===t))}},5720:function(n,t,r){r.d(t,{p:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var r=[],e=0;e<t;e+=2)r[e>>>3]|=parseInt(n.substr(e,2),16)<<24-e%8*4;return new i.e(r,t/2)}}},8702:function(n,t,r){r.d(t,{m:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push(String.fromCharCode(o))}return i.join("")},parse:function(n){for(var t=n.length,r=[],e=0;e<t;e++)r[e>>>2]|=(255&n.charCodeAt(e))<<24-e%4*8;return new i.e(r,t)}}},4768:function(n,t,r){r.d(t,{d:function(){return e}});var i=r(8702),e={stringify:function(n){try{return decodeURIComponent(escape(i.m.stringify(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return i.m.parse(unescape(encodeURIComponent(n)))}}},9054:function(n,t,r){r.d(t,{M:function(){return e}});var i=r(1756);var e=function(){if("undefined"!=typeof window){var n=window.crypto||window.msCrypto;if(!n){if((0,i.w)("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return n.getRandomValues(new Uint32Array(1))[0]}}return void 0!==r.g&&r.g.crypto?function(){return r.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}()}},t={};function r(i){var e=t[i];if(void 0!==e)return e.exports;var o=t[i]={exports:{}};return n[i](o,o.exports,r),o.exports}r.d=function(n,t){for(var i in t)r.o(t,i)&&!r.o(n,i)&&Object.defineProperty(n,i,{enumerable:!0,get:t[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"k",{value:!0})};var i={};return function(){r.r(i),r.d(i,{HmacSHA224:function(){return e}});var n=r(6367),t=r(766);function e(r,i){return new n.Hmac(new t.SHA224,i).finalize(r)}}(),i}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/HmacSHA256.d.ts
0 → 100644
app/static/content/jscrypto/HmacSHA256.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var r=t();for(var i in n.JsCrypto=n.JsCrypto||{},r)n.JsCrypto[i]=r[i]}}(this,(function(){return function(){"use strict";var n={6367:function(n,t,r){r.d(t,{Hmac:function(){return e}});var i=r(4768),e=function(){function n(n,t){this.t=n,"string"==typeof t&&(t=i.d.parse(t));var r=n.blockSize,e=4*r;t.nSigBytes>e&&(t=n.finalize(t)),t.clamp();for(var o=this.i=t.clone(),u=this.u=t.clone(),f=o.words,c=u.words,a=0;a<r;a++)f[a]^=1549556828,c[a]^=909522486;u.nSigBytes=e,o.nSigBytes=e,this.reset()}return n.prototype.reset=function(){this.t.reset(),this.t.update(this.u)},n.prototype.update=function(n){return this.t.update(n),this},n.prototype.finalize=function(n){var t=this.t.finalize(n);return this.t.reset(),this.t.finalize(this.i.clone().concat(t))},n}()},5561:function(n,t,r){r.d(t,{SHA256:function(){return v}});var i,e=r(1868),o=r(3354),u=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),f=[],c=[];function a(n){for(var t=Math.sqrt(n),r=2;r<=t;r++)if(!(n%r))return!1;return!0}function s(n){return 4294967296*(n-(0|n))|0}!function(){for(var n=2,t=0;t<64;)a(n)&&(t<8&&(f[t]=s(Math.pow(n,.5))),c[t]=s(Math.pow(n,1/3)),t++),n++}();var h=[],v=function(n){function t(t){var r=n.call(this,t)||this;return r.h=new o.e(f.slice(0)),r.v=t,t&&void 0!==t.hash&&(r.h=t.hash.clone()),r}return u(t,n),t.prototype.l=function(){this.h=new o.e(f.slice(0))},t.prototype.A=function(n,t){for(var r=this.h.words,i=r[0],e=r[1],o=r[2],u=r[3],f=r[4],a=r[5],s=r[6],v=r[7],w=0;w<64;w++){if(w<16)h[w]=0|n[t+w];else{var d=h[w-15],l=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,y=h[w-2],b=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;h[w]=l+h[w-7]+b+h[w-16]}var p=i&e^i&o^e&o,m=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),g=v+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(f&a^~f&s)+c[w]+h[w];v=s,s=a,a=f,f=u+g|0,u=o,o=e,e=i,i=g+(m+p)|0}r[0]=r[0]+i|0,r[1]=r[1]+e|0,r[2]=r[2]+o|0,r[3]=r[3]+u|0,r[4]=r[4]+f|0,r[5]=r[5]+a|0,r[6]=r[6]+s|0,r[7]=r[7]+v|0},t.prototype.j=function(){var n=this.O.words,t=8*this.I,r=8*this.O.nSigBytes;return n[r>>>5]|=128<<24-r%32,n[14+(r+64>>>9<<4)]=Math.floor(t/4294967296),n[15+(r+64>>>9<<4)]=t,this.O.nSigBytes=4*n.length,this.U(),this.h},t.prototype.clone=function(){return new t({hash:this.h,blockSize:this.S,data:this.O,nBytes:this.I})},t.hash=function(n,r){return new t(r).finalize(n)},t}(e.P)},3354:function(n,t,r){r.d(t,{e:function(){return o}});var i=r(5720),e=r(9054),o=function(){function n(t,r){if(Array.isArray(t)||!t)return this._=Array.isArray(t)?t:[],void(this.N="number"==typeof r?r:4*this._.length);if(t instanceof n)return this._=t.words.slice(),void(this.N=t.nSigBytes);var i;try{t instanceof ArrayBuffer?i=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!i)throw new Error("Invalid argument");for(var e=i.byteLength,o=[],u=0;u<e;u++)o[u>>>2]|=i[u]<<24-u%4*8;this._=o,this.N=e}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.N},set:function(n){this.N=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this._},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):i.p.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this._,t=this.N,r=new Uint8Array(t),i=0;i<t;i++)r[i]=n[i>>>2]>>>24-i%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.N%4)for(var i=0;i<r;i++){var e=t[i>>>2]>>>24-i%4*8&255;this._[this.N+i>>>2]|=e<<24-(this.N+i)%4*8}else for(i=0;i<r;i+=4)this._[this.N+i>>>2]=t[i>>>2];return this.N+=r,this},n.prototype.clamp=function(){var n=this.N;this._[n>>>2]&=4294967295<<32-n%4*8,this._.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this._.slice(),this.N)},n.random=function(t){for(var r=[],i=0;i<t;i+=4)r.push((0,e.M)());return new n(r,t)},n}()},7211:function(n,t,r){r.d(t,{C:function(){return o}});var i=r(3354),e=r(4768),o=function(){function n(n){this.H=0,this.S=0,this.v=n,this.O=n&&void 0!==n.data?n.data.clone():new i.e,this.I=n&&"number"==typeof n.nBytes?n.nBytes:0}return Object.defineProperty(n.prototype,"blockSize",{get:function(){return this.S},enumerable:!1,configurable:!0}),n.prototype.reset=function(n,t){this.O=void 0!==n?n.clone():new i.e,this.I="number"==typeof t?t:0},n.prototype.F=function(n){var t="string"==typeof n?e.d.parse(n):n;this.O.concat(t),this.I+=t.nSigBytes},n.prototype.U=function(n){var t,r=this.O.words,e=this.O.nSigBytes,o=this.S,u=e/(4*this.S),f=(u=n?Math.ceil(u):Math.max((0|u)-this.H,0))*o,c=Math.min(4*f,e);if(f){for(var a=0;a<f;a+=o)this.A(r,a);t=r.splice(0,f),this.O.nSigBytes-=c}return new i.e(t,c)},n.prototype.A=function(n,t){throw new Error("Not implemented")},n}()},1868:function(n,t,r){r.d(t,{P:function(){return u}});var i,e=r(7211),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.S=16,r.v=t,t&&"number"==typeof t.blockSize&&(r.S=t.blockSize),r.reset(t?t.data:void 0,t?t.nBytes:void 0),r}return o(t,n),Object.defineProperty(t.prototype,"blockSize",{get:function(){return this.S},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.l()},t.prototype.update=function(n){return this.F(n),this.U(),this},t.prototype.finalize=function(n){return n&&this.F(n),this.j()},t.prototype.l=function(){throw new Error("Not implemented")},t.prototype.j=function(){throw new Error("Not implemented")},t}(e.C)},1756:function(n,t,r){r.d(t,{w:function(){return u}});var i,e="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(i=parseInt((/msie (\d+)/.exec(e)||[])[1],10),isNaN(i)?(i=parseInt((/trident\/.*; rv:(\d+)/.exec(e)||[])[1],10),!isNaN(i)&&i):i);function u(n,t){return!1!==o&&(!t||("<"===n?o<t:"<="===n?o<=t:">"===n?o>t:">="===n?o>=t:o===t))}},5720:function(n,t,r){r.d(t,{p:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var r=[],e=0;e<t;e+=2)r[e>>>3]|=parseInt(n.substr(e,2),16)<<24-e%8*4;return new i.e(r,t/2)}}},8702:function(n,t,r){r.d(t,{m:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push(String.fromCharCode(o))}return i.join("")},parse:function(n){for(var t=n.length,r=[],e=0;e<t;e++)r[e>>>2]|=(255&n.charCodeAt(e))<<24-e%4*8;return new i.e(r,t)}}},4768:function(n,t,r){r.d(t,{d:function(){return e}});var i=r(8702),e={stringify:function(n){try{return decodeURIComponent(escape(i.m.stringify(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return i.m.parse(unescape(encodeURIComponent(n)))}}},9054:function(n,t,r){r.d(t,{M:function(){return e}});var i=r(1756);var e=function(){if("undefined"!=typeof window){var n=window.crypto||window.msCrypto;if(!n){if((0,i.w)("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return n.getRandomValues(new Uint32Array(1))[0]}}return void 0!==r.g&&r.g.crypto?function(){return r.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}()}},t={};function r(i){var e=t[i];if(void 0!==e)return e.exports;var o=t[i]={exports:{}};return n[i](o,o.exports,r),o.exports}r.d=function(n,t){for(var i in t)r.o(t,i)&&!r.o(n,i)&&Object.defineProperty(n,i,{enumerable:!0,get:t[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"k",{value:!0})};var i={};return function(){r.r(i),r.d(i,{HmacSHA256:function(){return e}});var n=r(6367),t=r(5561);function e(r,i){return new n.Hmac(new t.SHA256,i).finalize(r)}}(),i}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/HmacSHA384.d.ts
0 → 100644
app/static/content/jscrypto/HmacSHA384.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var e=t();for(var r in n.JsCrypto=n.JsCrypto||{},e)n.JsCrypto[r]=e[r]}}(this,(function(){return function(){"use strict";var n={6367:function(n,t,e){e.d(t,{Hmac:function(){return i}});var r=e(4768),i=function(){function n(n,t){this.t=n,"string"==typeof t&&(t=r.d.parse(t));var e=n.blockSize,i=4*e;t.nSigBytes>i&&(t=n.finalize(t)),t.clamp();for(var o=this.i=t.clone(),u=this.u=t.clone(),f=o.words,c=u.words,s=0;s<e;s++)f[s]^=1549556828,c[s]^=909522486;u.nSigBytes=i,o.nSigBytes=i,this.reset()}return n.prototype.reset=function(){this.t.reset(),this.t.update(this.u)},n.prototype.update=function(n){return this.t.update(n),this},n.prototype.finalize=function(n){var t=this.t.finalize(n);return this.t.reset(),this.t.finalize(this.i.clone().concat(t))},n}()},6324:function(n,t,e){e.d(t,{SHA384:function(){return f}});var r,i=e(6957),o=e(7491),u=(r=function(n,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e])})(n,t)},function(n,t){function e(){this.constructor=n}r(n,t),n.prototype=null===t?Object.create(t):(e.prototype=t.prototype,new e)}),f=function(n){function t(t){var e=n.call(this,t)||this;return e.h=new i.m([new i.r(3418070365,3238371032),new i.r(1654270250,914150663),new i.r(2438529370,812702999),new i.r(355462360,4144912697),new i.r(1731405415,4290775857),new i.r(2394180231,1750603025),new i.r(3675008525,1694076839),new i.r(1203062813,3204075428)]),e.v=t,t&&void 0!==t.hash&&(e.h=t.hash.clone()),e}return u(t,n),t.prototype.l=function(){this.h=new i.m([new i.r(3418070365,3238371032),new i.r(1654270250,914150663),new i.r(2438529370,812702999),new i.r(355462360,4144912697),new i.r(1731405415,4290775857),new i.r(2394180231,1750603025),new i.r(3675008525,1694076839),new i.r(1203062813,3204075428)])},t.prototype.j=function(){var t=n.prototype.j.call(this);return t.nSigBytes-=16,t},t.prototype.clone=function(){return new t({hash:this.h,blockSize:this.A,data:this.O,nBytes:this._})},t.hash=function(n,e){return new t(e).finalize(n)},t}(o.SHA512)},7491:function(n,t,e){e.d(t,{SHA512:function(){return s}});var r,i=e(1868),o=e(6957),u=(r=function(n,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e])})(n,t)},function(n,t){function e(){this.constructor=n}r(n,t),n.prototype=null===t?Object.create(t):(e.prototype=t.prototype,new e)}),f=[new o.r(1116352408,3609767458),new o.r(1899447441,602891725),new o.r(3049323471,3964484399),new o.r(3921009573,2173295548),new o.r(961987163,4081628472),new o.r(1508970993,3053834265),new o.r(2453635748,2937671579),new o.r(2870763221,3664609560),new o.r(3624381080,2734883394),new o.r(310598401,1164996542),new o.r(607225278,1323610764),new o.r(1426881987,3590304994),new o.r(1925078388,4068182383),new o.r(2162078206,991336113),new o.r(2614888103,633803317),new o.r(3248222580,3479774868),new o.r(3835390401,2666613458),new o.r(4022224774,944711139),new o.r(264347078,2341262773),new o.r(604807628,2007800933),new o.r(770255983,1495990901),new o.r(1249150122,1856431235),new o.r(1555081692,3175218132),new o.r(1996064986,2198950837),new o.r(2554220882,3999719339),new o.r(2821834349,766784016),new o.r(2952996808,2566594879),new o.r(3210313671,3203337956),new o.r(3336571891,1034457026),new o.r(3584528711,2466948901),new o.r(113926993,3758326383),new o.r(338241895,168717936),new o.r(666307205,1188179964),new o.r(773529912,1546045734),new o.r(1294757372,1522805485),new o.r(1396182291,2643833823),new o.r(1695183700,2343527390),new o.r(1986661051,1014477480),new o.r(2177026350,1206759142),new o.r(2456956037,344077627),new o.r(2730485921,1290863460),new o.r(2820302411,3158454273),new o.r(3259730800,3505952657),new o.r(3345764771,106217008),new o.r(3516065817,3606008344),new o.r(3600352804,1432725776),new o.r(4094571909,1467031594),new o.r(275423344,851169720),new o.r(430227734,3100823752),new o.r(506948616,1363258195),new o.r(659060556,3750685593),new o.r(883997877,3785050280),new o.r(958139571,3318307427),new o.r(1322822218,3812723403),new o.r(1537002063,2003034995),new o.r(1747873779,3602036899),new o.r(1955562222,1575990012),new o.r(2024104815,1125592928),new o.r(2227730452,2716904306),new o.r(2361852424,442776044),new o.r(2428436474,593698344),new o.r(2756734187,3733110249),new o.r(3204031479,2999351573),new o.r(3329325298,3815920427),new o.r(3391569614,3928383900),new o.r(3515267271,566280711),new o.r(3940187606,3454069534),new o.r(4118630271,4000239992),new o.r(116418474,1914138554),new o.r(174292421,2731055270),new o.r(289380356,3203993006),new o.r(460393269,320620315),new o.r(685471733,587496836),new o.r(852142971,1086792851),new o.r(1017036298,365543100),new o.r(1126000580,2618297676),new o.r(1288033470,3409855158),new o.r(1501505948,4234509866),new o.r(1607167915,987167468),new o.r(1816402316,1246189591)],c=[];!function(){for(var n=0;n<80;n++)c[n]=new o.r(0,0)}();var s=function(n){function t(t){var e=n.call(this,t)||this;return e.A=32,e.h=new o.m([new o.r(1779033703,4089235720),new o.r(3144134277,2227873595),new o.r(1013904242,4271175723),new o.r(2773480762,1595750129),new o.r(1359893119,2917565137),new o.r(2600822924,725511199),new o.r(528734635,4215389547),new o.r(1541459225,327033209)]),e.v=t,t&&void 0!==t.hash&&(e.h=t.hash.clone()),e}return u(t,n),t.prototype.l=function(){this.h=new o.m([new o.r(1779033703,4089235720),new o.r(3144134277,2227873595),new o.r(1013904242,4271175723),new o.r(2773480762,1595750129),new o.r(1359893119,2917565137),new o.r(2600822924,725511199),new o.r(528734635,4215389547),new o.r(1541459225,327033209)])},t.prototype.I=function(n,t){for(var e=this.h.words,r=e[0],i=e[1],o=e[2],u=e[3],s=e[4],w=e[5],a=e[6],h=e[7],v=r.high,d=r.low,l=i.high,b=i.low,y=o.high,p=o.low,m=u.high,g=u.low,j=s.high,A=s.low,O=w.high,_=w.low,I=a.high,S=a.low,E=h.high,M=h.low,U=v,H=d,N=l,x=b,B=y,C=p,F=m,k=g,z=j,T=A,P=O,R=_,q=I,$=S,D=E,G=M,J=0;J<80;J++){var K=void 0,L=void 0,Q=c[J];if(J<16)L=Q.high=0|n[t+2*J],K=Q.low=0|n[t+2*J+1];else{var V=c[J-15],W=V.high,X=V.low,Y=(W>>>1|X<<31)^(W>>>8|X<<24)^W>>>7,Z=(X>>>1|W<<31)^(X>>>8|W<<24)^(X>>>7|W<<25),nn=c[J-2],tn=nn.high,en=nn.low,rn=(tn>>>19|en<<13)^(tn<<3|en>>>29)^tn>>>6,on=(en>>>19|tn<<13)^(en<<3|tn>>>29)^(en>>>6|tn<<26),un=c[J-7],fn=un.high,cn=un.low,sn=c[J-16],wn=sn.high,an=sn.low;L=(L=(L=Y+fn+((K=Z+cn)>>>0<Z>>>0?1:0))+rn+((K+=on)>>>0<on>>>0?1:0))+wn+((K+=an)>>>0<an>>>0?1:0),Q.high=L,Q.low=K}var hn=z&P^~z&q,vn=T&R^~T&$,dn=U&N^U&B^N&B,ln=H&x^H&C^x&C,bn=(U>>>28|H<<4)^(U<<30|H>>>2)^(U<<25|H>>>7),yn=(H>>>28|U<<4)^(H<<30|U>>>2)^(H<<25|U>>>7),pn=(z>>>14|T<<18)^(z>>>18|T<<14)^(z<<23|T>>>9),mn=(T>>>14|z<<18)^(T>>>18|z<<14)^(T<<23|z>>>9),gn=f[J],jn=gn.high,An=gn.low,On=G+mn,_n=D+pn+(On>>>0<G>>>0?1:0),In=yn+ln;D=q,G=$,q=P,$=R,P=z,R=T,z=F+(_n=(_n=(_n=_n+hn+((On+=vn)>>>0<vn>>>0?1:0))+jn+((On+=An)>>>0<An>>>0?1:0))+L+((On+=K)>>>0<K>>>0?1:0))+((T=k+On|0)>>>0<k>>>0?1:0)|0,F=B,k=C,B=N,C=x,N=U,x=H,U=_n+(bn+dn+(In>>>0<yn>>>0?1:0))+((H=On+In|0)>>>0<On>>>0?1:0)|0}d=r.low=d+H,r.high=v+U+(d>>>0<H>>>0?1:0),b=i.low=b+x,i.high=l+N+(b>>>0<x>>>0?1:0),p=o.low=p+C,o.high=y+B+(p>>>0<C>>>0?1:0),g=u.low=g+k,u.high=m+F+(g>>>0<k>>>0?1:0),A=s.low=A+T,s.high=j+z+(A>>>0<T>>>0?1:0),_=w.low=_+R,w.high=O+P+(_>>>0<R>>>0?1:0),S=a.low=S+$,a.high=I+q+(S>>>0<$>>>0?1:0),M=h.low=M+G,h.high=E+D+(M>>>0<G>>>0?1:0)},t.prototype.j=function(){var n=this.O,t=n.words,e=8*this._,r=8*n.nSigBytes;return t[r>>>5]|=128<<24-r%32,t[30+(r+128>>>10<<5)]=Math.floor(e/4294967296),t[31+(r+128>>>10<<5)]=e,n.nSigBytes=4*t.length,this.S(),this.h.to32()},t.prototype.clone=function(){return new t({hash:this.h,blockSize:this.A,data:this.O,nBytes:this._})},t.hash=function(n,e){return new t(e).finalize(n)},t}(i.P)},3354:function(n,t,e){e.d(t,{e:function(){return o}});var r=e(5720),i=e(9054),o=function(){function n(t,e){if(Array.isArray(t)||!t)return this.U=Array.isArray(t)?t:[],void(this.H="number"==typeof e?e:4*this.U.length);if(t instanceof n)return this.U=t.words.slice(),void(this.H=t.nSigBytes);var r;try{t instanceof ArrayBuffer?r=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!r)throw new Error("Invalid argument");for(var i=r.byteLength,o=[],u=0;u<i;u++)o[u>>>2]|=r[u]<<24-u%4*8;this.U=o,this.H=i}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.H},set:function(n){this.H=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.U},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):r.p.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this.U,t=this.H,e=new Uint8Array(t),r=0;r<t;r++)e[r]=n[r>>>2]>>>24-r%4*8&255;return e},n.prototype.concat=function(n){var t=n.words.slice(),e=n.nSigBytes;if(this.clamp(),this.H%4)for(var r=0;r<e;r++){var i=t[r>>>2]>>>24-r%4*8&255;this.U[this.H+r>>>2]|=i<<24-(this.H+r)%4*8}else for(r=0;r<e;r+=4)this.U[this.H+r>>>2]=t[r>>>2];return this.H+=e,this},n.prototype.clamp=function(){var n=this.H;this.U[n>>>2]&=4294967295<<32-n%4*8,this.U.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.U.slice(),this.H)},n.random=function(t){for(var e=[],r=0;r<t;r+=4)e.push((0,i.M)());return new n(e,t)},n}()},6957:function(n,t,e){e.d(t,{r:function(){return o},m:function(){return u}});var r=e(5720),i=e(3354),o=function(){function n(n,t){this.high=n,this.low=t}return n.prototype.clone=function(){return new n(this.high,this.low)},n}(),u=function(){function n(n,t){this.U=n||[],this.H="number"==typeof t?t:8*this.U.length}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.H},set:function(n){this.H=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.U},enumerable:!1,configurable:!0}),n.prototype.to32=function(){for(var n=[],t=0;t<this.U.length;t++){var e=this.U[t];n.push(e.high),n.push(e.low)}return new i.e(n,this.H)},n.prototype.toString=function(n){return n?n.stringify(this.to32()):r.p.stringify(this.to32())},n.prototype.clone=function(){for(var t=this.U.slice(),e=0;e<t.length;e++)t[e]=t[e].clone();return new n(t,this.H)},n}()},7211:function(n,t,e){e.d(t,{C:function(){return o}});var r=e(3354),i=e(4768),o=function(){function n(n){this.N=0,this.A=0,this.v=n,this.O=n&&void 0!==n.data?n.data.clone():new r.e,this._=n&&"number"==typeof n.nBytes?n.nBytes:0}return Object.defineProperty(n.prototype,"blockSize",{get:function(){return this.A},enumerable:!1,configurable:!0}),n.prototype.reset=function(n,t){this.O=void 0!==n?n.clone():new r.e,this._="number"==typeof t?t:0},n.prototype.B=function(n){var t="string"==typeof n?i.d.parse(n):n;this.O.concat(t),this._+=t.nSigBytes},n.prototype.S=function(n){var t,e=this.O.words,i=this.O.nSigBytes,o=this.A,u=i/(4*this.A),f=(u=n?Math.ceil(u):Math.max((0|u)-this.N,0))*o,c=Math.min(4*f,i);if(f){for(var s=0;s<f;s+=o)this.I(e,s);t=e.splice(0,f),this.O.nSigBytes-=c}return new r.e(t,c)},n.prototype.I=function(n,t){throw new Error("Not implemented")},n}()},1868:function(n,t,e){e.d(t,{P:function(){return u}});var r,i=e(7211),o=(r=function(n,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e])})(n,t)},function(n,t){function e(){this.constructor=n}r(n,t),n.prototype=null===t?Object.create(t):(e.prototype=t.prototype,new e)}),u=function(n){function t(t){var e=n.call(this,t)||this;return e.A=16,e.v=t,t&&"number"==typeof t.blockSize&&(e.A=t.blockSize),e.reset(t?t.data:void 0,t?t.nBytes:void 0),e}return o(t,n),Object.defineProperty(t.prototype,"blockSize",{get:function(){return this.A},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,e){n.prototype.reset.call(this,t,e),this.l()},t.prototype.update=function(n){return this.B(n),this.S(),this},t.prototype.finalize=function(n){return n&&this.B(n),this.j()},t.prototype.l=function(){throw new Error("Not implemented")},t.prototype.j=function(){throw new Error("Not implemented")},t}(i.C)},1756:function(n,t,e){e.d(t,{w:function(){return u}});var r,i="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(r=parseInt((/msie (\d+)/.exec(i)||[])[1],10),isNaN(r)?(r=parseInt((/trident\/.*; rv:(\d+)/.exec(i)||[])[1],10),!isNaN(r)&&r):r);function u(n,t){return!1!==o&&(!t||("<"===n?o<t:"<="===n?o<=t:">"===n?o>t:">="===n?o>=t:o===t))}},5720:function(n,t,e){e.d(t,{p:function(){return i}});var r=e(3354),i={stringify:function(n){for(var t=n.nSigBytes,e=n.words,r=[],i=0;i<t;i++){var o=e[i>>>2]>>>24-i%4*8&255;r.push((o>>>4).toString(16)),r.push((15&o).toString(16))}return r.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var e=[],i=0;i<t;i+=2)e[i>>>3]|=parseInt(n.substr(i,2),16)<<24-i%8*4;return new r.e(e,t/2)}}},8702:function(n,t,e){e.d(t,{m:function(){return i}});var r=e(3354),i={stringify:function(n){for(var t=n.nSigBytes,e=n.words,r=[],i=0;i<t;i++){var o=e[i>>>2]>>>24-i%4*8&255;r.push(String.fromCharCode(o))}return r.join("")},parse:function(n){for(var t=n.length,e=[],i=0;i<t;i++)e[i>>>2]|=(255&n.charCodeAt(i))<<24-i%4*8;return new r.e(e,t)}}},4768:function(n,t,e){e.d(t,{d:function(){return i}});var r=e(8702),i={stringify:function(n){try{return decodeURIComponent(escape(r.m.stringify(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return r.m.parse(unescape(encodeURIComponent(n)))}}},9054:function(n,t,e){e.d(t,{M:function(){return i}});var r=e(1756);var i=function(){if("undefined"!=typeof window){var n=window.crypto||window.msCrypto;if(!n){if((0,r.w)("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return n.getRandomValues(new Uint32Array(1))[0]}}return void 0!==e.g&&e.g.crypto?function(){return e.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}()}},t={};function e(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return n[r](o,o.exports,e),o.exports}e.d=function(n,t){for(var r in t)e.o(t,r)&&!e.o(n,r)&&Object.defineProperty(n,r,{enumerable:!0,get:t[r]})},e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),e.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},e.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"F",{value:!0})};var r={};return function(){e.r(r),e.d(r,{HmacSHA384:function(){return i}});var n=e(6367),t=e(6324);function i(e,r){return new n.Hmac(new t.SHA384,r).finalize(e)}}(),r}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/HmacSHA512.d.ts
0 → 100644
app/static/content/jscrypto/HmacSHA512.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var e=t();for(var r in n.JsCrypto=n.JsCrypto||{},e)n.JsCrypto[r]=e[r]}}(this,(function(){return function(){"use strict";var n={6367:function(n,t,e){e.d(t,{Hmac:function(){return i}});var r=e(4768),i=function(){function n(n,t){this.t=n,"string"==typeof t&&(t=r.d.parse(t));var e=n.blockSize,i=4*e;t.nSigBytes>i&&(t=n.finalize(t)),t.clamp();for(var o=this.i=t.clone(),u=this.u=t.clone(),f=o.words,c=u.words,s=0;s<e;s++)f[s]^=1549556828,c[s]^=909522486;u.nSigBytes=i,o.nSigBytes=i,this.reset()}return n.prototype.reset=function(){this.t.reset(),this.t.update(this.u)},n.prototype.update=function(n){return this.t.update(n),this},n.prototype.finalize=function(n){var t=this.t.finalize(n);return this.t.reset(),this.t.finalize(this.i.clone().concat(t))},n}()},7491:function(n,t,e){e.d(t,{SHA512:function(){return s}});var r,i=e(1868),o=e(6957),u=(r=function(n,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e])})(n,t)},function(n,t){function e(){this.constructor=n}r(n,t),n.prototype=null===t?Object.create(t):(e.prototype=t.prototype,new e)}),f=[new o.r(1116352408,3609767458),new o.r(1899447441,602891725),new o.r(3049323471,3964484399),new o.r(3921009573,2173295548),new o.r(961987163,4081628472),new o.r(1508970993,3053834265),new o.r(2453635748,2937671579),new o.r(2870763221,3664609560),new o.r(3624381080,2734883394),new o.r(310598401,1164996542),new o.r(607225278,1323610764),new o.r(1426881987,3590304994),new o.r(1925078388,4068182383),new o.r(2162078206,991336113),new o.r(2614888103,633803317),new o.r(3248222580,3479774868),new o.r(3835390401,2666613458),new o.r(4022224774,944711139),new o.r(264347078,2341262773),new o.r(604807628,2007800933),new o.r(770255983,1495990901),new o.r(1249150122,1856431235),new o.r(1555081692,3175218132),new o.r(1996064986,2198950837),new o.r(2554220882,3999719339),new o.r(2821834349,766784016),new o.r(2952996808,2566594879),new o.r(3210313671,3203337956),new o.r(3336571891,1034457026),new o.r(3584528711,2466948901),new o.r(113926993,3758326383),new o.r(338241895,168717936),new o.r(666307205,1188179964),new o.r(773529912,1546045734),new o.r(1294757372,1522805485),new o.r(1396182291,2643833823),new o.r(1695183700,2343527390),new o.r(1986661051,1014477480),new o.r(2177026350,1206759142),new o.r(2456956037,344077627),new o.r(2730485921,1290863460),new o.r(2820302411,3158454273),new o.r(3259730800,3505952657),new o.r(3345764771,106217008),new o.r(3516065817,3606008344),new o.r(3600352804,1432725776),new o.r(4094571909,1467031594),new o.r(275423344,851169720),new o.r(430227734,3100823752),new o.r(506948616,1363258195),new o.r(659060556,3750685593),new o.r(883997877,3785050280),new o.r(958139571,3318307427),new o.r(1322822218,3812723403),new o.r(1537002063,2003034995),new o.r(1747873779,3602036899),new o.r(1955562222,1575990012),new o.r(2024104815,1125592928),new o.r(2227730452,2716904306),new o.r(2361852424,442776044),new o.r(2428436474,593698344),new o.r(2756734187,3733110249),new o.r(3204031479,2999351573),new o.r(3329325298,3815920427),new o.r(3391569614,3928383900),new o.r(3515267271,566280711),new o.r(3940187606,3454069534),new o.r(4118630271,4000239992),new o.r(116418474,1914138554),new o.r(174292421,2731055270),new o.r(289380356,3203993006),new o.r(460393269,320620315),new o.r(685471733,587496836),new o.r(852142971,1086792851),new o.r(1017036298,365543100),new o.r(1126000580,2618297676),new o.r(1288033470,3409855158),new o.r(1501505948,4234509866),new o.r(1607167915,987167468),new o.r(1816402316,1246189591)],c=[];!function(){for(var n=0;n<80;n++)c[n]=new o.r(0,0)}();var s=function(n){function t(t){var e=n.call(this,t)||this;return e.h=32,e.v=new o.m([new o.r(1779033703,4089235720),new o.r(3144134277,2227873595),new o.r(1013904242,4271175723),new o.r(2773480762,1595750129),new o.r(1359893119,2917565137),new o.r(2600822924,725511199),new o.r(528734635,4215389547),new o.r(1541459225,327033209)]),e.l=t,t&&void 0!==t.hash&&(e.v=t.hash.clone()),e}return u(t,n),t.prototype.j=function(){this.v=new o.m([new o.r(1779033703,4089235720),new o.r(3144134277,2227873595),new o.r(1013904242,4271175723),new o.r(2773480762,1595750129),new o.r(1359893119,2917565137),new o.r(2600822924,725511199),new o.r(528734635,4215389547),new o.r(1541459225,327033209)])},t.prototype.A=function(n,t){for(var e=this.v.words,r=e[0],i=e[1],o=e[2],u=e[3],s=e[4],w=e[5],a=e[6],h=e[7],v=r.high,d=r.low,l=i.high,b=i.low,y=o.high,p=o.low,m=u.high,g=u.low,j=s.high,A=s.low,O=w.high,I=w.low,E=a.high,M=a.low,S=h.high,U=h.low,_=v,N=d,x=l,H=b,C=y,F=p,B=m,k=g,z=j,T=A,P=O,R=I,q=E,$=M,D=S,G=U,J=0;J<80;J++){var K=void 0,L=void 0,Q=c[J];if(J<16)L=Q.high=0|n[t+2*J],K=Q.low=0|n[t+2*J+1];else{var V=c[J-15],W=V.high,X=V.low,Y=(W>>>1|X<<31)^(W>>>8|X<<24)^W>>>7,Z=(X>>>1|W<<31)^(X>>>8|W<<24)^(X>>>7|W<<25),nn=c[J-2],tn=nn.high,en=nn.low,rn=(tn>>>19|en<<13)^(tn<<3|en>>>29)^tn>>>6,on=(en>>>19|tn<<13)^(en<<3|tn>>>29)^(en>>>6|tn<<26),un=c[J-7],fn=un.high,cn=un.low,sn=c[J-16],wn=sn.high,an=sn.low;L=(L=(L=Y+fn+((K=Z+cn)>>>0<Z>>>0?1:0))+rn+((K+=on)>>>0<on>>>0?1:0))+wn+((K+=an)>>>0<an>>>0?1:0),Q.high=L,Q.low=K}var hn=z&P^~z&q,vn=T&R^~T&$,dn=_&x^_&C^x&C,ln=N&H^N&F^H&F,bn=(_>>>28|N<<4)^(_<<30|N>>>2)^(_<<25|N>>>7),yn=(N>>>28|_<<4)^(N<<30|_>>>2)^(N<<25|_>>>7),pn=(z>>>14|T<<18)^(z>>>18|T<<14)^(z<<23|T>>>9),mn=(T>>>14|z<<18)^(T>>>18|z<<14)^(T<<23|z>>>9),gn=f[J],jn=gn.high,An=gn.low,On=G+mn,In=D+pn+(On>>>0<G>>>0?1:0),En=yn+ln;D=q,G=$,q=P,$=R,P=z,R=T,z=B+(In=(In=(In=In+hn+((On+=vn)>>>0<vn>>>0?1:0))+jn+((On+=An)>>>0<An>>>0?1:0))+L+((On+=K)>>>0<K>>>0?1:0))+((T=k+On|0)>>>0<k>>>0?1:0)|0,B=C,k=F,C=x,F=H,x=_,H=N,_=In+(bn+dn+(En>>>0<yn>>>0?1:0))+((N=On+En|0)>>>0<On>>>0?1:0)|0}d=r.low=d+N,r.high=v+_+(d>>>0<N>>>0?1:0),b=i.low=b+H,i.high=l+x+(b>>>0<H>>>0?1:0),p=o.low=p+F,o.high=y+C+(p>>>0<F>>>0?1:0),g=u.low=g+k,u.high=m+B+(g>>>0<k>>>0?1:0),A=s.low=A+T,s.high=j+z+(A>>>0<T>>>0?1:0),I=w.low=I+R,w.high=O+P+(I>>>0<R>>>0?1:0),M=a.low=M+$,a.high=E+q+(M>>>0<$>>>0?1:0),U=h.low=U+G,h.high=S+D+(U>>>0<G>>>0?1:0)},t.prototype.O=function(){var n=this.I,t=n.words,e=8*this.S,r=8*n.nSigBytes;return t[r>>>5]|=128<<24-r%32,t[30+(r+128>>>10<<5)]=Math.floor(e/4294967296),t[31+(r+128>>>10<<5)]=e,n.nSigBytes=4*t.length,this.U(),this.v.to32()},t.prototype.clone=function(){return new t({hash:this.v,blockSize:this.h,data:this.I,nBytes:this.S})},t.hash=function(n,e){return new t(e).finalize(n)},t}(i.P)},3354:function(n,t,e){e.d(t,{e:function(){return o}});var r=e(5720),i=e(9054),o=function(){function n(t,e){if(Array.isArray(t)||!t)return this._=Array.isArray(t)?t:[],void(this.N="number"==typeof e?e:4*this._.length);if(t instanceof n)return this._=t.words.slice(),void(this.N=t.nSigBytes);var r;try{t instanceof ArrayBuffer?r=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!r)throw new Error("Invalid argument");for(var i=r.byteLength,o=[],u=0;u<i;u++)o[u>>>2]|=r[u]<<24-u%4*8;this._=o,this.N=i}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.N},set:function(n){this.N=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this._},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):r.p.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this._,t=this.N,e=new Uint8Array(t),r=0;r<t;r++)e[r]=n[r>>>2]>>>24-r%4*8&255;return e},n.prototype.concat=function(n){var t=n.words.slice(),e=n.nSigBytes;if(this.clamp(),this.N%4)for(var r=0;r<e;r++){var i=t[r>>>2]>>>24-r%4*8&255;this._[this.N+r>>>2]|=i<<24-(this.N+r)%4*8}else for(r=0;r<e;r+=4)this._[this.N+r>>>2]=t[r>>>2];return this.N+=e,this},n.prototype.clamp=function(){var n=this.N;this._[n>>>2]&=4294967295<<32-n%4*8,this._.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this._.slice(),this.N)},n.random=function(t){for(var e=[],r=0;r<t;r+=4)e.push((0,i.M)());return new n(e,t)},n}()},6957:function(n,t,e){e.d(t,{r:function(){return o},m:function(){return u}});var r=e(5720),i=e(3354),o=function(){function n(n,t){this.high=n,this.low=t}return n.prototype.clone=function(){return new n(this.high,this.low)},n}(),u=function(){function n(n,t){this._=n||[],this.N="number"==typeof t?t:8*this._.length}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.N},set:function(n){this.N=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this._},enumerable:!1,configurable:!0}),n.prototype.to32=function(){for(var n=[],t=0;t<this._.length;t++){var e=this._[t];n.push(e.high),n.push(e.low)}return new i.e(n,this.N)},n.prototype.toString=function(n){return n?n.stringify(this.to32()):r.p.stringify(this.to32())},n.prototype.clone=function(){for(var t=this._.slice(),e=0;e<t.length;e++)t[e]=t[e].clone();return new n(t,this.N)},n}()},7211:function(n,t,e){e.d(t,{C:function(){return o}});var r=e(3354),i=e(4768),o=function(){function n(n){this.H=0,this.h=0,this.l=n,this.I=n&&void 0!==n.data?n.data.clone():new r.e,this.S=n&&"number"==typeof n.nBytes?n.nBytes:0}return Object.defineProperty(n.prototype,"blockSize",{get:function(){return this.h},enumerable:!1,configurable:!0}),n.prototype.reset=function(n,t){this.I=void 0!==n?n.clone():new r.e,this.S="number"==typeof t?t:0},n.prototype.F=function(n){var t="string"==typeof n?i.d.parse(n):n;this.I.concat(t),this.S+=t.nSigBytes},n.prototype.U=function(n){var t,e=this.I.words,i=this.I.nSigBytes,o=this.h,u=i/(4*this.h),f=(u=n?Math.ceil(u):Math.max((0|u)-this.H,0))*o,c=Math.min(4*f,i);if(f){for(var s=0;s<f;s+=o)this.A(e,s);t=e.splice(0,f),this.I.nSigBytes-=c}return new r.e(t,c)},n.prototype.A=function(n,t){throw new Error("Not implemented")},n}()},1868:function(n,t,e){e.d(t,{P:function(){return u}});var r,i=e(7211),o=(r=function(n,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e])})(n,t)},function(n,t){function e(){this.constructor=n}r(n,t),n.prototype=null===t?Object.create(t):(e.prototype=t.prototype,new e)}),u=function(n){function t(t){var e=n.call(this,t)||this;return e.h=16,e.l=t,t&&"number"==typeof t.blockSize&&(e.h=t.blockSize),e.reset(t?t.data:void 0,t?t.nBytes:void 0),e}return o(t,n),Object.defineProperty(t.prototype,"blockSize",{get:function(){return this.h},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,e){n.prototype.reset.call(this,t,e),this.j()},t.prototype.update=function(n){return this.F(n),this.U(),this},t.prototype.finalize=function(n){return n&&this.F(n),this.O()},t.prototype.j=function(){throw new Error("Not implemented")},t.prototype.O=function(){throw new Error("Not implemented")},t}(i.C)},1756:function(n,t,e){e.d(t,{w:function(){return u}});var r,i="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(r=parseInt((/msie (\d+)/.exec(i)||[])[1],10),isNaN(r)?(r=parseInt((/trident\/.*; rv:(\d+)/.exec(i)||[])[1],10),!isNaN(r)&&r):r);function u(n,t){return!1!==o&&(!t||("<"===n?o<t:"<="===n?o<=t:">"===n?o>t:">="===n?o>=t:o===t))}},5720:function(n,t,e){e.d(t,{p:function(){return i}});var r=e(3354),i={stringify:function(n){for(var t=n.nSigBytes,e=n.words,r=[],i=0;i<t;i++){var o=e[i>>>2]>>>24-i%4*8&255;r.push((o>>>4).toString(16)),r.push((15&o).toString(16))}return r.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var e=[],i=0;i<t;i+=2)e[i>>>3]|=parseInt(n.substr(i,2),16)<<24-i%8*4;return new r.e(e,t/2)}}},8702:function(n,t,e){e.d(t,{m:function(){return i}});var r=e(3354),i={stringify:function(n){for(var t=n.nSigBytes,e=n.words,r=[],i=0;i<t;i++){var o=e[i>>>2]>>>24-i%4*8&255;r.push(String.fromCharCode(o))}return r.join("")},parse:function(n){for(var t=n.length,e=[],i=0;i<t;i++)e[i>>>2]|=(255&n.charCodeAt(i))<<24-i%4*8;return new r.e(e,t)}}},4768:function(n,t,e){e.d(t,{d:function(){return i}});var r=e(8702),i={stringify:function(n){try{return decodeURIComponent(escape(r.m.stringify(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return r.m.parse(unescape(encodeURIComponent(n)))}}},9054:function(n,t,e){e.d(t,{M:function(){return i}});var r=e(1756);var i=function(){if("undefined"!=typeof window){var n=window.crypto||window.msCrypto;if(!n){if((0,r.w)("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return n.getRandomValues(new Uint32Array(1))[0]}}return void 0!==e.g&&e.g.crypto?function(){return e.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}()}},t={};function e(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return n[r](o,o.exports,e),o.exports}e.d=function(n,t){for(var r in t)e.o(t,r)&&!e.o(n,r)&&Object.defineProperty(n,r,{enumerable:!0,get:t[r]})},e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),e.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},e.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"B",{value:!0})};var r={};return function(){e.r(r),e.d(r,{HmacSHA512:function(){return i}});var n=e(6367),t=e(7491);function i(e,r){return new n.Hmac(new t.SHA512,r).finalize(e)}}(),r}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/LICENSE
0 → 100644
| 1 | +The MIT License | |
| 2 | + | |
| 3 | +Copyright (c) 2019 Izumi Hoshino <rindo.hinase@gmail.com> | |
| 4 | + | |
| 5 | +Permission is hereby granted, free of charge, to any person obtaining a copy | |
| 6 | +of this software and associated documentation files (the "Software"), to deal | |
| 7 | +in the Software without restriction, including without limitation the rights | |
| 8 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| 9 | +copies of the Software, and to permit persons to whom the Software is | |
| 10 | +furnished to do so, subject to the following conditions: | |
| 11 | + | |
| 12 | +The above copyright notice and this permission notice shall be included in | |
| 13 | +all copies or substantial portions of the Software. | |
| 14 | + | |
| 15 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 16 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 17 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| 18 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 19 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| 20 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
| 21 | +THE SOFTWARE. | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/Latin1.d.ts
0 → 100644
| 1 | +export { Latin1 } from "./lib/encoder/Latin1"; | ... | ... |
app/static/content/jscrypto/Latin1.js
0 → 100644
| 1 | +!function(n,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else if("object"==typeof exports)exports.JsCrypto=r();else{var t=r();for(var e in n.JsCrypto=n.JsCrypto||{},t)n.JsCrypto[e]=t[e]}}(this,(function(){return function(){"use strict";var n={d:function(r,t){for(var e in t)n.o(t,e)&&!n.o(r,e)&&Object.defineProperty(r,e,{enumerable:!0,get:t[e]})}};n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),n.o=function(n,r){return Object.prototype.hasOwnProperty.call(n,r)},n.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"t",{value:!0})};var r={};n.r(r),n.d(r,{Latin1:function(){return u}});var t,e=function(n){for(var r=n.nSigBytes,t=n.words,e=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;e.push((o>>>4).toString(16)),e.push((15&o).toString(16))}return e.join("")},i="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(t=parseInt((/msie (\d+)/.exec(i)||[])[1],10),isNaN(t)?(t=parseInt((/trident\/.*; rv:(\d+)/.exec(i)||[])[1],10),!isNaN(t)&&t):t);var a=function(){if("undefined"!=typeof window){var r=window.crypto||window.msCrypto;if(!r){if(function(n,r){return!1!==o&&(!r||("<"===n?o<r:"<="===n?o<=r:">"===n?o>r:">="===n?o>=r:o===r))}("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return r.getRandomValues(new Uint32Array(1))[0]}}return void 0!==n.g&&n.g.crypto?function(){return n.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}(),f=function(){function n(r,t){if(Array.isArray(r)||!r)return this.i=Array.isArray(r)?r:[],void(this.u="number"==typeof t?t:4*this.i.length);if(r instanceof n)return this.i=r.words.slice(),void(this.u=r.nSigBytes);var e;try{r instanceof ArrayBuffer?e=new Uint8Array(r):(r instanceof Uint8Array||r instanceof Int8Array||r instanceof Uint8ClampedArray||r instanceof Int16Array||r instanceof Uint16Array||r instanceof Int32Array||r instanceof Uint32Array||r instanceof Float32Array||r instanceof Float64Array)&&(e=new Uint8Array(r.buffer,r.byteOffset,r.byteLength))}catch(n){throw new Error("Invalid argument")}if(!e)throw new Error("Invalid argument");for(var i=e.byteLength,o=[],a=0;a<i;a++)o[a>>>2]|=e[a]<<24-a%4*8;this.i=o,this.u=i}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.u},set:function(n){this.u=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.i},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):e(this)},n.prototype.toUint8Array=function(){for(var n=this.i,r=this.u,t=new Uint8Array(r),e=0;e<r;e++)t[e]=n[e>>>2]>>>24-e%4*8&255;return t},n.prototype.concat=function(n){var r=n.words.slice(),t=n.nSigBytes;if(this.clamp(),this.u%4)for(var e=0;e<t;e++){var i=r[e>>>2]>>>24-e%4*8&255;this.i[this.u+e>>>2]|=i<<24-(this.u+e)%4*8}else for(e=0;e<t;e+=4)this.i[this.u+e>>>2]=r[e>>>2];return this.u+=t,this},n.prototype.clamp=function(){var n=this.u;this.i[n>>>2]&=4294967295<<32-n%4*8,this.i.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.i.slice(),this.u)},n.random=function(r){for(var t=[],e=0;e<r;e+=4)t.push(a());return new n(t,r)},n}(),u={stringify:function(n){for(var r=n.nSigBytes,t=n.words,e=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;e.push(String.fromCharCode(o))}return e.join("")},parse:function(n){for(var r=n.length,t=[],e=0;e<r;e++)t[e>>>2]|=(255&n.charCodeAt(e))<<24-e%4*8;return new f(t,r)}};return r}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/MD5.d.ts
0 → 100644
| 1 | +import { Word32Array } from "./lib/Word32Array"; | |
| 2 | +import { Hasher, HasherProps } from "./lib/algorithm/Hasher"; | |
| 3 | +export interface MD5Props extends HasherProps { | |
| 4 | + hash: Word32Array; | |
| 5 | +} | |
| 6 | +/** | |
| 7 | + * MD5 hash algorithm | |
| 8 | + */ | |
| 9 | +export declare class MD5 extends Hasher { | |
| 10 | + private _hash; | |
| 11 | + constructor(props?: MD5Props); | |
| 12 | + protected _doReset(): void; | |
| 13 | + protected _doProcessBlock(words: number[], offset: number): void; | |
| 14 | + protected _doFinalize(): Word32Array; | |
| 15 | + clone(): MD5; | |
| 16 | + static hash(message: Word32Array | string): Word32Array; | |
| 17 | +} | ... | ... |
app/static/content/jscrypto/MD5.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var r=t();for(var i in n.JsCrypto=n.JsCrypto||{},r)n.JsCrypto[i]=r[i]}}(this,(function(){return function(){"use strict";var n={3354:function(n,t,r){r.d(t,{e:function(){return o}});var i=r(5720),e=r(9054),o=function(){function n(t,r){if(Array.isArray(t)||!t)return this.t=Array.isArray(t)?t:[],void(this.i="number"==typeof r?r:4*this.t.length);if(t instanceof n)return this.t=t.words.slice(),void(this.i=t.nSigBytes);var i;try{t instanceof ArrayBuffer?i=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!i)throw new Error("Invalid argument");for(var e=i.byteLength,o=[],u=0;u<e;u++)o[u>>>2]|=i[u]<<24-u%4*8;this.t=o,this.i=e}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.i},set:function(n){this.i=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.t},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):i.p.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this.t,t=this.i,r=new Uint8Array(t),i=0;i<t;i++)r[i]=n[i>>>2]>>>24-i%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.i%4)for(var i=0;i<r;i++){var e=t[i>>>2]>>>24-i%4*8&255;this.t[this.i+i>>>2]|=e<<24-(this.i+i)%4*8}else for(i=0;i<r;i+=4)this.t[this.i+i>>>2]=t[i>>>2];return this.i+=r,this},n.prototype.clamp=function(){var n=this.i;this.t[n>>>2]&=4294967295<<32-n%4*8,this.t.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.t.slice(),this.i)},n.random=function(t){for(var r=[],i=0;i<t;i+=4)r.push((0,e.M)());return new n(r,t)},n}()},7211:function(n,t,r){r.d(t,{C:function(){return o}});var i=r(3354),e=r(4768),o=function(){function n(n){this.u=0,this.h=0,this.v=n,this.l=n&&void 0!==n.data?n.data.clone():new i.e,this.j=n&&"number"==typeof n.nBytes?n.nBytes:0}return Object.defineProperty(n.prototype,"blockSize",{get:function(){return this.h},enumerable:!1,configurable:!0}),n.prototype.reset=function(n,t){this.l=void 0!==n?n.clone():new i.e,this.j="number"==typeof t?t:0},n.prototype.A=function(n){var t="string"==typeof n?e.d.parse(n):n;this.l.concat(t),this.j+=t.nSigBytes},n.prototype.O=function(n){var t,r=this.l.words,e=this.l.nSigBytes,o=this.h,u=e/(4*this.h),f=(u=n?Math.ceil(u):Math.max((0|u)-this.u,0))*o,a=Math.min(4*f,e);if(f){for(var c=0;c<f;c+=o)this.I(r,c);t=r.splice(0,f),this.l.nSigBytes-=a}return new i.e(t,a)},n.prototype.I=function(n,t){throw new Error("Not implemented")},n}()},1868:function(n,t,r){r.d(t,{P:function(){return u}});var i,e=r(7211),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.h=16,r.v=t,t&&"number"==typeof t.blockSize&&(r.h=t.blockSize),r.reset(t?t.data:void 0,t?t.nBytes:void 0),r}return o(t,n),Object.defineProperty(t.prototype,"blockSize",{get:function(){return this.h},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.U()},t.prototype.update=function(n){return this.A(n),this.O(),this},t.prototype.finalize=function(n){return n&&this.A(n),this._()},t.prototype.U=function(){throw new Error("Not implemented")},t.prototype._=function(){throw new Error("Not implemented")},t}(e.C)},1756:function(n,t,r){r.d(t,{w:function(){return u}});var i,e="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(i=parseInt((/msie (\d+)/.exec(e)||[])[1],10),isNaN(i)?(i=parseInt((/trident\/.*; rv:(\d+)/.exec(e)||[])[1],10),!isNaN(i)&&i):i);function u(n,t){return!1!==o&&(!t||("<"===n?o<t:"<="===n?o<=t:">"===n?o>t:">="===n?o>=t:o===t))}},5720:function(n,t,r){r.d(t,{p:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var r=[],e=0;e<t;e+=2)r[e>>>3]|=parseInt(n.substr(e,2),16)<<24-e%8*4;return new i.e(r,t/2)}}},8702:function(n,t,r){r.d(t,{m:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push(String.fromCharCode(o))}return i.join("")},parse:function(n){for(var t=n.length,r=[],e=0;e<t;e++)r[e>>>2]|=(255&n.charCodeAt(e))<<24-e%4*8;return new i.e(r,t)}}},4768:function(n,t,r){r.d(t,{d:function(){return e}});var i=r(8702),e={stringify:function(n){try{return decodeURIComponent(escape(i.m.stringify(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return i.m.parse(unescape(encodeURIComponent(n)))}}},9054:function(n,t,r){r.d(t,{M:function(){return e}});var i=r(1756);var e=function(){if("undefined"!=typeof window){var n=window.crypto||window.msCrypto;if(!n){if((0,i.w)("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return n.getRandomValues(new Uint32Array(1))[0]}}return void 0!==r.g&&r.g.crypto?function(){return r.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}()}},t={};function r(i){var e=t[i];if(void 0!==e)return e.exports;var o=t[i]={exports:{}};return n[i](o,o.exports,r),o.exports}r.d=function(n,t){for(var i in t)r.o(t,i)&&!r.o(n,i)&&Object.defineProperty(n,i,{enumerable:!0,get:t[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"S",{value:!0})};var i={};return function(){r.r(i),r.d(i,{MD5:function(){return h}});var n,t=r(3354),e=r(1868),o=(n=function(t,r){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(t,r)},function(t,r){function i(){this.constructor=t}n(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}),u=[];function f(n,t,r,i,e,o,u){var f=n+(t&r|~t&i)+e+u;return(f<<o|f>>>32-o)+t}function a(n,t,r,i,e,o,u){var f=n+(t&i|r&~i)+e+u;return(f<<o|f>>>32-o)+t}function c(n,t,r,i,e,o,u){var f=n+(t^r^i)+e+u;return(f<<o|f>>>32-o)+t}function s(n,t,r,i,e,o,u){var f=n+(r^(t|~i))+e+u;return(f<<o|f>>>32-o)+t}!function(){for(var n=0;n<64;n++)u[n]=4294967296*Math.abs(Math.sin(n+1))|0}();var h=function(n){function r(r){var i=n.call(this,r)||this;return i.N=new t.e([1732584193,4023233417,2562383102,271733878]),r&&void 0!==r.hash&&(i.N=r.hash.clone()),i}return o(r,n),r.prototype.U=function(){this.N=new t.e([1732584193,4023233417,2562383102,271733878])},r.prototype.I=function(n,t){for(var r=0;r<16;r++){var i=t+r,e=n[i];n[i]=16711935&(e<<8|e>>>24)|4278255360&(e<<24|e>>>8)}var o=this.N.words,h=n[t],v=n[t+1],d=n[t+2],w=n[t+3],l=n[t+4],y=n[t+5],b=n[t+6],p=n[t+7],m=n[t+8],g=n[t+9],j=n[t+10],A=n[t+11],M=n[t+12],O=n[t+13],I=n[t+14],E=n[t+15],U=o[0],_=o[1],S=o[2],N=o[3];U=f(U,_,S,N,h,7,u[0]),N=f(N,U,_,S,v,12,u[1]),S=f(S,N,U,_,d,17,u[2]),_=f(_,S,N,U,w,22,u[3]),U=f(U,_,S,N,l,7,u[4]),N=f(N,U,_,S,y,12,u[5]),S=f(S,N,U,_,b,17,u[6]),_=f(_,S,N,U,p,22,u[7]),U=f(U,_,S,N,m,7,u[8]),N=f(N,U,_,S,g,12,u[9]),S=f(S,N,U,_,j,17,u[10]),_=f(_,S,N,U,A,22,u[11]),U=f(U,_,S,N,M,7,u[12]),N=f(N,U,_,S,O,12,u[13]),S=f(S,N,U,_,I,17,u[14]),U=a(U,_=f(_,S,N,U,E,22,u[15]),S,N,v,5,u[16]),N=a(N,U,_,S,b,9,u[17]),S=a(S,N,U,_,A,14,u[18]),_=a(_,S,N,U,h,20,u[19]),U=a(U,_,S,N,y,5,u[20]),N=a(N,U,_,S,j,9,u[21]),S=a(S,N,U,_,E,14,u[22]),_=a(_,S,N,U,l,20,u[23]),U=a(U,_,S,N,g,5,u[24]),N=a(N,U,_,S,I,9,u[25]),S=a(S,N,U,_,w,14,u[26]),_=a(_,S,N,U,m,20,u[27]),U=a(U,_,S,N,O,5,u[28]),N=a(N,U,_,S,d,9,u[29]),S=a(S,N,U,_,p,14,u[30]),U=c(U,_=a(_,S,N,U,M,20,u[31]),S,N,y,4,u[32]),N=c(N,U,_,S,m,11,u[33]),S=c(S,N,U,_,A,16,u[34]),_=c(_,S,N,U,I,23,u[35]),U=c(U,_,S,N,v,4,u[36]),N=c(N,U,_,S,l,11,u[37]),S=c(S,N,U,_,p,16,u[38]),_=c(_,S,N,U,j,23,u[39]),U=c(U,_,S,N,O,4,u[40]),N=c(N,U,_,S,h,11,u[41]),S=c(S,N,U,_,w,16,u[42]),_=c(_,S,N,U,b,23,u[43]),U=c(U,_,S,N,g,4,u[44]),N=c(N,U,_,S,M,11,u[45]),S=c(S,N,U,_,E,16,u[46]),U=s(U,_=c(_,S,N,U,d,23,u[47]),S,N,h,6,u[48]),N=s(N,U,_,S,p,10,u[49]),S=s(S,N,U,_,I,15,u[50]),_=s(_,S,N,U,y,21,u[51]),U=s(U,_,S,N,M,6,u[52]),N=s(N,U,_,S,w,10,u[53]),S=s(S,N,U,_,j,15,u[54]),_=s(_,S,N,U,v,21,u[55]),U=s(U,_,S,N,m,6,u[56]),N=s(N,U,_,S,E,10,u[57]),S=s(S,N,U,_,b,15,u[58]),_=s(_,S,N,U,O,21,u[59]),U=s(U,_,S,N,l,6,u[60]),N=s(N,U,_,S,A,10,u[61]),S=s(S,N,U,_,d,15,u[62]),_=s(_,S,N,U,g,21,u[63]),o[0]=o[0]+U|0,o[1]=o[1]+_|0,o[2]=o[2]+S|0,o[3]=o[3]+N|0},r.prototype._=function(){var n=this.l,t=n.words,r=8*this.j,i=8*n.nSigBytes;t[i>>>5]|=128<<24-i%32;var e=Math.floor(r/4294967296),o=r;t[15+(i+64>>>9<<4)]=16711935&(e<<8|e>>>24)|4278255360&(e<<24|e>>>8),t[14+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),n.nSigBytes=4*(t.length+1),this.O();for(var u=this.N,f=u.words,a=0;a<4;a++){var c=f[a];f[a]=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8)}return u},r.prototype.clone=function(){return new r({hash:this.N,blockSize:this.h,data:this.l,nBytes:this.j})},r.hash=function(n){return(new r).finalize(n)},r}(e.P)}(),i}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/OpenSSLKDF.d.ts
0 → 100644
| 1 | +export { OpenSSLKDF } from "./lib/algorithm/cipher/kdf/OpenSSLKDF"; | ... | ... |
app/static/content/jscrypto/OpenSSLKDF.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var r=t();for(var i in n.JsCrypto=n.JsCrypto||{},r)n.JsCrypto[i]=r[i]}}(this,(function(){return function(){"use strict";var n={6367:function(n,t,r){r.d(t,{Hmac:function(){return e}});var i=r(4768),e=function(){function n(n,t){this.t=n,"string"==typeof t&&(t=i.d.parse(t));var r=n.blockSize,e=4*r;t.nSigBytes>e&&(t=n.finalize(t)),t.clamp();for(var o=this.i=t.clone(),u=this.u=t.clone(),f=o.words,c=u.words,s=0;s<r;s++)f[s]^=1549556828,c[s]^=909522486;u.nSigBytes=e,o.nSigBytes=e,this.reset()}return n.prototype.reset=function(){this.t.reset(),this.t.update(this.u)},n.prototype.update=function(n){return this.t.update(n),this},n.prototype.finalize=function(n){var t=this.t.finalize(n);return this.t.reset(),this.t.finalize(this.i.clone().concat(t))},n}()},5561:function(n,t,r){r.d(t,{SHA256:function(){return v}});var i,e=r(1868),o=r(3354),u=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),f=[],c=[];function s(n){for(var t=Math.sqrt(n),r=2;r<=t;r++)if(!(n%r))return!1;return!0}function a(n){return 4294967296*(n-(0|n))|0}!function(){for(var n=2,t=0;t<64;)s(n)&&(t<8&&(f[t]=a(Math.pow(n,.5))),c[t]=a(Math.pow(n,1/3)),t++),n++}();var h=[],v=function(n){function t(t){var r=n.call(this,t)||this;return r.h=new o.e(f.slice(0)),r.v=t,t&&void 0!==t.hash&&(r.h=t.hash.clone()),r}return u(t,n),t.prototype.l=function(){this.h=new o.e(f.slice(0))},t.prototype.j=function(n,t){for(var r=this.h.words,i=r[0],e=r[1],o=r[2],u=r[3],f=r[4],s=r[5],a=r[6],v=r[7],w=0;w<64;w++){if(w<16)h[w]=0|n[t+w];else{var d=h[w-15],l=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,y=h[w-2],b=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;h[w]=l+h[w-7]+b+h[w-16]}var p=i&e^i&o^e&o,m=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),g=v+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(f&s^~f&a)+c[w]+h[w];v=a,a=s,s=f,f=u+g|0,u=o,o=e,e=i,i=g+(m+p)|0}r[0]=r[0]+i|0,r[1]=r[1]+e|0,r[2]=r[2]+o|0,r[3]=r[3]+u|0,r[4]=r[4]+f|0,r[5]=r[5]+s|0,r[6]=r[6]+a|0,r[7]=r[7]+v|0},t.prototype.A=function(){var n=this.O.words,t=8*this.I,r=8*this.O.nSigBytes;return n[r>>>5]|=128<<24-r%32,n[14+(r+64>>>9<<4)]=Math.floor(t/4294967296),n[15+(r+64>>>9<<4)]=t,this.O.nSigBytes=4*n.length,this._(),this.h},t.prototype.clone=function(){return new t({hash:this.h,blockSize:this.S,data:this.O,nBytes:this.I})},t.hash=function(n,r){return new t(r).finalize(n)},t}(e.P)},3354:function(n,t,r){r.d(t,{e:function(){return o}});var i=r(5720),e=r(9054),o=function(){function n(t,r){if(Array.isArray(t)||!t)return this.U=Array.isArray(t)?t:[],void(this.N="number"==typeof r?r:4*this.U.length);if(t instanceof n)return this.U=t.words.slice(),void(this.N=t.nSigBytes);var i;try{t instanceof ArrayBuffer?i=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!i)throw new Error("Invalid argument");for(var e=i.byteLength,o=[],u=0;u<e;u++)o[u>>>2]|=i[u]<<24-u%4*8;this.U=o,this.N=e}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.N},set:function(n){this.N=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.U},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):i.p.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this.U,t=this.N,r=new Uint8Array(t),i=0;i<t;i++)r[i]=n[i>>>2]>>>24-i%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.N%4)for(var i=0;i<r;i++){var e=t[i>>>2]>>>24-i%4*8&255;this.U[this.N+i>>>2]|=e<<24-(this.N+i)%4*8}else for(i=0;i<r;i+=4)this.U[this.N+i>>>2]=t[i>>>2];return this.N+=r,this},n.prototype.clamp=function(){var n=this.N;this.U[n>>>2]&=4294967295<<32-n%4*8,this.U.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.U.slice(),this.N)},n.random=function(t){for(var r=[],i=0;i<t;i+=4)r.push((0,e.M)());return new n(r,t)},n}()},7211:function(n,t,r){r.d(t,{C:function(){return o}});var i=r(3354),e=r(4768),o=function(){function n(n){this.F=0,this.S=0,this.v=n,this.O=n&&void 0!==n.data?n.data.clone():new i.e,this.I=n&&"number"==typeof n.nBytes?n.nBytes:0}return Object.defineProperty(n.prototype,"blockSize",{get:function(){return this.S},enumerable:!1,configurable:!0}),n.prototype.reset=function(n,t){this.O=void 0!==n?n.clone():new i.e,this.I="number"==typeof t?t:0},n.prototype.k=function(n){var t="string"==typeof n?e.d.parse(n):n;this.O.concat(t),this.I+=t.nSigBytes},n.prototype._=function(n){var t,r=this.O.words,e=this.O.nSigBytes,o=this.S,u=e/(4*this.S),f=(u=n?Math.ceil(u):Math.max((0|u)-this.F,0))*o,c=Math.min(4*f,e);if(f){for(var s=0;s<f;s+=o)this.j(r,s);t=r.splice(0,f),this.O.nSigBytes-=c}return new i.e(t,c)},n.prototype.j=function(n,t){throw new Error("Not implemented")},n}()},1868:function(n,t,r){r.d(t,{P:function(){return u}});var i,e=r(7211),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.S=16,r.v=t,t&&"number"==typeof t.blockSize&&(r.S=t.blockSize),r.reset(t?t.data:void 0,t?t.nBytes:void 0),r}return o(t,n),Object.defineProperty(t.prototype,"blockSize",{get:function(){return this.S},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.l()},t.prototype.update=function(n){return this.k(n),this._(),this},t.prototype.finalize=function(n){return n&&this.k(n),this.A()},t.prototype.l=function(){throw new Error("Not implemented")},t.prototype.A=function(){throw new Error("Not implemented")},t}(e.C)},1756:function(n,t,r){r.d(t,{w:function(){return u}});var i,e="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(i=parseInt((/msie (\d+)/.exec(e)||[])[1],10),isNaN(i)?(i=parseInt((/trident\/.*; rv:(\d+)/.exec(e)||[])[1],10),!isNaN(i)&&i):i);function u(n,t){return!1!==o&&(!t||("<"===n?o<t:"<="===n?o<=t:">"===n?o>t:">="===n?o>=t:o===t))}},5720:function(n,t,r){r.d(t,{p:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var r=[],e=0;e<t;e+=2)r[e>>>3]|=parseInt(n.substr(e,2),16)<<24-e%8*4;return new i.e(r,t/2)}}},8702:function(n,t,r){r.d(t,{m:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push(String.fromCharCode(o))}return i.join("")},parse:function(n){for(var t=n.length,r=[],e=0;e<t;e++)r[e>>>2]|=(255&n.charCodeAt(e))<<24-e%4*8;return new i.e(r,t)}}},4768:function(n,t,r){r.d(t,{d:function(){return e}});var i=r(8702),e={stringify:function(n){try{return decodeURIComponent(escape(i.m.stringify(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return i.m.parse(unescape(encodeURIComponent(n)))}}},9054:function(n,t,r){r.d(t,{M:function(){return e}});var i=r(1756);var e=function(){if("undefined"!=typeof window){var n=window.crypto||window.msCrypto;if(!n){if((0,i.w)("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return n.getRandomValues(new Uint32Array(1))[0]}}return void 0!==r.g&&r.g.crypto?function(){return r.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}()}},t={};function r(i){var e=t[i];if(void 0!==e)return e.exports;var o=t[i]={exports:{}};return n[i](o,o.exports,r),o.exports}r.d=function(n,t){for(var i in t)r.o(t,i)&&!r.o(n,i)&&Object.defineProperty(n,i,{enumerable:!0,get:t[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"H",{value:!0})};var i={};return function(){r.r(i),r.d(i,{OpenSSLKDF:function(){return y}});for(var n=r(3354),t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",e=[],o=0;o<t.length;o++)e[t.charCodeAt(o)]=o;var u,f={stringify:function(n){var r=n.words,i=n.nSigBytes;n.clamp();for(var e=[],o=0;o<i;o+=3)for(var u=(r[o>>>2]>>>24-o%4*8&255)<<16|(r[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|r[o+2>>>2]>>>24-(o+2)%4*8&255,f=0;f<4&&o+.75*f<i;f++)e.push(t.charAt(u>>>6*(3-f)&63));var c=t.charAt(64);if(c)for(;e.length%4;)e.push(c);return e.join("")},parse:function(r){var i=r.length,o=t.charAt(64);if(o){var u=r.indexOf(o);-1!==u&&(i=u)}for(var f=[],c=0,s=0;s<i;s++)if(s%4){var a=e[r.charCodeAt(s-1)]<<s%4*2|e[r.charCodeAt(s)]>>>6-s%4*2;f[c>>>2]|=a<<24-c%4*8,c++}return new n.e(f,c)}},c={stringify:function(t){var r=t.cipherText,i=t.salt;return r?i?new n.e([1398893684,1701076831]).concat(i).concat(r).toString(f):r.toString(f):""},parse:function(t){var r,i=f.parse(t),e=i.words;return 1398893684===e[0]&&1701076831===e[1]&&(r=new n.e(e.slice(2,4)),e.splice(0,4),i.nSigBytes-=16),new s({cipherText:i,salt:r})}},s=function(){function n(n){this.formatter=c,n&&(this.cipherText=n.cipherText,this.key=n.key,this.iv=n.iv,this.salt=n.salt,this.Algorithm=n.Algorithm,this.mode=n.mode,this.padding=n.padding,this.blockSize=n.blockSize,this.formatter=n.formatter||c)}return n.prototype.toString=function(n){return(n||this.formatter).stringify(this)},n}(),a=r(5561),h=r(6367),v=function(){function n(n){this.v=n}return n.prototype.compute=function(n,t){throw new Error("Not implemented")},n.getKey=function(n,t,r){throw new Error("Not implemented")},n}(),w=(u=function(n,t){return(u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}u(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),d=function(t){function r(n){var r=t.call(this,n)||this;return r.T=4,r.B=a.SHA256,r.R=1e4,n&&(r.T=void 0!==n.keySize?n.keySize:r.T,r.B=void 0!==n.Hasher?n.Hasher:r.B,r.R=void 0!==n.iterations?n.iterations:r.R),r}return w(r,t),r.prototype.compute=function(t,r){for(var i=new h.Hmac(new this.B,t),e=new n.e,o=new n.e([1]),u=e.words,f=o.words,c=this.T,s=this.R;u.length<c;){var a=i.update(r).finalize(o);i.reset();for(var v=a.words,w=v.length,d=a,l=1;l<s;l++){d=i.finalize(d),i.reset();for(var y=d.words,b=0;b<w;b++)v[b]^=y[b]}e.concat(a),f[0]++}return e.nSigBytes=4*c,e},r.getKey=function(n,t,i){return new r(i).compute(n,t)},r}(v),l=function(){return(l=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},y={execute:function(t,r,i,e,o){e||(e=n.e.random(8));var u=o&&o.kdfModule||d,f=o?{Hasher:o.kdfHasher,iterations:o.kdfIterations}:{},c=u.getKey(t,e,l(l({},f),{keySize:r+i})),a=new n.e(c.words.slice(r),4*i);return c.nSigBytes=4*r,new s({key:c,iv:a,salt:e})}}}(),i}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/PBKDF2.d.ts
0 → 100644
| 1 | +export { PBKDF2 } from "./lib/algorithm/cipher/kdf/module/PBKDF2"; | ... | ... |
app/static/content/jscrypto/PBKDF2.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var r=t();for(var i in n.JsCrypto=n.JsCrypto||{},r)n.JsCrypto[i]=r[i]}}(this,(function(){return function(){"use strict";var n={6367:function(n,t,r){r.d(t,{Hmac:function(){return e}});var i=r(4768),e=function(){function n(n,t){this.t=n,"string"==typeof t&&(t=i.d.parse(t));var r=n.blockSize,e=4*r;t.nSigBytes>e&&(t=n.finalize(t)),t.clamp();for(var o=this.i=t.clone(),u=this.u=t.clone(),f=o.words,c=u.words,s=0;s<r;s++)f[s]^=1549556828,c[s]^=909522486;u.nSigBytes=e,o.nSigBytes=e,this.reset()}return n.prototype.reset=function(){this.t.reset(),this.t.update(this.u)},n.prototype.update=function(n){return this.t.update(n),this},n.prototype.finalize=function(n){var t=this.t.finalize(n);return this.t.reset(),this.t.finalize(this.i.clone().concat(t))},n}()},5561:function(n,t,r){r.d(t,{SHA256:function(){return v}});var i,e=r(1868),o=r(3354),u=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),f=[],c=[];function s(n){for(var t=Math.sqrt(n),r=2;r<=t;r++)if(!(n%r))return!1;return!0}function a(n){return 4294967296*(n-(0|n))|0}!function(){for(var n=2,t=0;t<64;)s(n)&&(t<8&&(f[t]=a(Math.pow(n,.5))),c[t]=a(Math.pow(n,1/3)),t++),n++}();var h=[],v=function(n){function t(t){var r=n.call(this,t)||this;return r.h=new o.e(f.slice(0)),r.v=t,t&&void 0!==t.hash&&(r.h=t.hash.clone()),r}return u(t,n),t.prototype.l=function(){this.h=new o.e(f.slice(0))},t.prototype.j=function(n,t){for(var r=this.h.words,i=r[0],e=r[1],o=r[2],u=r[3],f=r[4],s=r[5],a=r[6],v=r[7],w=0;w<64;w++){if(w<16)h[w]=0|n[t+w];else{var d=h[w-15],l=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,y=h[w-2],b=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;h[w]=l+h[w-7]+b+h[w-16]}var p=i&e^i&o^e&o,m=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),g=v+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(f&s^~f&a)+c[w]+h[w];v=a,a=s,s=f,f=u+g|0,u=o,o=e,e=i,i=g+(m+p)|0}r[0]=r[0]+i|0,r[1]=r[1]+e|0,r[2]=r[2]+o|0,r[3]=r[3]+u|0,r[4]=r[4]+f|0,r[5]=r[5]+s|0,r[6]=r[6]+a|0,r[7]=r[7]+v|0},t.prototype.A=function(){var n=this.O.words,t=8*this._,r=8*this.O.nSigBytes;return n[r>>>5]|=128<<24-r%32,n[14+(r+64>>>9<<4)]=Math.floor(t/4294967296),n[15+(r+64>>>9<<4)]=t,this.O.nSigBytes=4*n.length,this.I(),this.h},t.prototype.clone=function(){return new t({hash:this.h,blockSize:this.U,data:this.O,nBytes:this._})},t.hash=function(n,r){return new t(r).finalize(n)},t}(e.P)},3354:function(n,t,r){r.d(t,{e:function(){return o}});var i=r(5720),e=r(9054),o=function(){function n(t,r){if(Array.isArray(t)||!t)return this.N=Array.isArray(t)?t:[],void(this.S="number"==typeof r?r:4*this.N.length);if(t instanceof n)return this.N=t.words.slice(),void(this.S=t.nSigBytes);var i;try{t instanceof ArrayBuffer?i=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!i)throw new Error("Invalid argument");for(var e=i.byteLength,o=[],u=0;u<e;u++)o[u>>>2]|=i[u]<<24-u%4*8;this.N=o,this.S=e}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.S},set:function(n){this.S=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.N},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):i.p.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this.N,t=this.S,r=new Uint8Array(t),i=0;i<t;i++)r[i]=n[i>>>2]>>>24-i%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.S%4)for(var i=0;i<r;i++){var e=t[i>>>2]>>>24-i%4*8&255;this.N[this.S+i>>>2]|=e<<24-(this.S+i)%4*8}else for(i=0;i<r;i+=4)this.N[this.S+i>>>2]=t[i>>>2];return this.S+=r,this},n.prototype.clamp=function(){var n=this.S;this.N[n>>>2]&=4294967295<<32-n%4*8,this.N.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.N.slice(),this.S)},n.random=function(t){for(var r=[],i=0;i<t;i+=4)r.push((0,e.M)());return new n(r,t)},n}()},7211:function(n,t,r){r.d(t,{C:function(){return o}});var i=r(3354),e=r(4768),o=function(){function n(n){this.F=0,this.U=0,this.v=n,this.O=n&&void 0!==n.data?n.data.clone():new i.e,this._=n&&"number"==typeof n.nBytes?n.nBytes:0}return Object.defineProperty(n.prototype,"blockSize",{get:function(){return this.U},enumerable:!1,configurable:!0}),n.prototype.reset=function(n,t){this.O=void 0!==n?n.clone():new i.e,this._="number"==typeof t?t:0},n.prototype.B=function(n){var t="string"==typeof n?e.d.parse(n):n;this.O.concat(t),this._+=t.nSigBytes},n.prototype.I=function(n){var t,r=this.O.words,e=this.O.nSigBytes,o=this.U,u=e/(4*this.U),f=(u=n?Math.ceil(u):Math.max((0|u)-this.F,0))*o,c=Math.min(4*f,e);if(f){for(var s=0;s<f;s+=o)this.j(r,s);t=r.splice(0,f),this.O.nSigBytes-=c}return new i.e(t,c)},n.prototype.j=function(n,t){throw new Error("Not implemented")},n}()},1868:function(n,t,r){r.d(t,{P:function(){return u}});var i,e=r(7211),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.U=16,r.v=t,t&&"number"==typeof t.blockSize&&(r.U=t.blockSize),r.reset(t?t.data:void 0,t?t.nBytes:void 0),r}return o(t,n),Object.defineProperty(t.prototype,"blockSize",{get:function(){return this.U},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.l()},t.prototype.update=function(n){return this.B(n),this.I(),this},t.prototype.finalize=function(n){return n&&this.B(n),this.A()},t.prototype.l=function(){throw new Error("Not implemented")},t.prototype.A=function(){throw new Error("Not implemented")},t}(e.C)},1756:function(n,t,r){r.d(t,{w:function(){return u}});var i,e="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(i=parseInt((/msie (\d+)/.exec(e)||[])[1],10),isNaN(i)?(i=parseInt((/trident\/.*; rv:(\d+)/.exec(e)||[])[1],10),!isNaN(i)&&i):i);function u(n,t){return!1!==o&&(!t||("<"===n?o<t:"<="===n?o<=t:">"===n?o>t:">="===n?o>=t:o===t))}},5720:function(n,t,r){r.d(t,{p:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var r=[],e=0;e<t;e+=2)r[e>>>3]|=parseInt(n.substr(e,2),16)<<24-e%8*4;return new i.e(r,t/2)}}},8702:function(n,t,r){r.d(t,{m:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push(String.fromCharCode(o))}return i.join("")},parse:function(n){for(var t=n.length,r=[],e=0;e<t;e++)r[e>>>2]|=(255&n.charCodeAt(e))<<24-e%4*8;return new i.e(r,t)}}},4768:function(n,t,r){r.d(t,{d:function(){return e}});var i=r(8702),e={stringify:function(n){try{return decodeURIComponent(escape(i.m.stringify(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return i.m.parse(unescape(encodeURIComponent(n)))}}},9054:function(n,t,r){r.d(t,{M:function(){return e}});var i=r(1756);var e=function(){if("undefined"!=typeof window){var n=window.crypto||window.msCrypto;if(!n){if((0,i.w)("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return n.getRandomValues(new Uint32Array(1))[0]}}return void 0!==r.g&&r.g.crypto?function(){return r.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}()}},t={};function r(i){var e=t[i];if(void 0!==e)return e.exports;var o=t[i]={exports:{}};return n[i](o,o.exports,r),o.exports}r.d=function(n,t){for(var i in t)r.o(t,i)&&!r.o(n,i)&&Object.defineProperty(n,i,{enumerable:!0,get:t[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"H",{value:!0})};var i={};return function(){r.r(i),r.d(i,{PBKDF2:function(){return c}});var n,t=r(5561),e=r(6367),o=r(3354),u=function(){function n(n){this.v=n}return n.prototype.compute=function(n,t){throw new Error("Not implemented")},n.getKey=function(n,t,r){throw new Error("Not implemented")},n}(),f=(n=function(t,r){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(t,r)},function(t,r){function i(){this.constructor=t}n(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}),c=function(n){function r(r){var i=n.call(this,r)||this;return i.k=4,i.T=t.SHA256,i.R=1e4,r&&(i.k=void 0!==r.keySize?r.keySize:i.k,i.T=void 0!==r.Hasher?r.Hasher:i.T,i.R=void 0!==r.iterations?r.iterations:i.R),i}return f(r,n),r.prototype.compute=function(n,t){for(var r=new e.Hmac(new this.T,n),i=new o.e,u=new o.e([1]),f=i.words,c=u.words,s=this.k,a=this.R;f.length<s;){var h=r.update(t).finalize(u);r.reset();for(var v=h.words,w=v.length,d=h,l=1;l<a;l++){d=r.finalize(d),r.reset();for(var y=d.words,b=0;b<w;b++)v[b]^=y[b]}i.concat(h),c[0]++}return i.nSigBytes=4*s,i},r.getKey=function(n,t,i){return new r(i).compute(n,t)},r}(u)}(),i}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/RC4.d.ts
0 → 100644
| 1 | +import { PropsWithKey } from "./lib/algorithm/cipher/Cipher"; | |
| 2 | +import type { Word32Array } from "./lib/Word32Array"; | |
| 3 | +import { StreamCipher, StreamCipherProps } from "./lib/algorithm/cipher/StreamCipher"; | |
| 4 | +import { CipherParams } from "./lib/algorithm/cipher/CipherParams"; | |
| 5 | +export interface RC4Props extends StreamCipherProps { | |
| 6 | +} | |
| 7 | +export declare class RC4 extends StreamCipher { | |
| 8 | + static readonly ivSize = 0; | |
| 9 | + static readonly keySize: number; | |
| 10 | + protected _props: PropsWithKey<RC4Props>; | |
| 11 | + protected S: number[]; | |
| 12 | + protected i: number; | |
| 13 | + protected j: number; | |
| 14 | + constructor(props: PropsWithKey<RC4Props>); | |
| 15 | + protected _doReset(): void; | |
| 16 | + protected _doProcessBlock(words: number[], offset: number): void; | |
| 17 | + protected generateKeyStreamWord(): number; | |
| 18 | + /** | |
| 19 | + * Creates this cipher in encryption mode. | |
| 20 | + * | |
| 21 | + * @param {Word32Array} key The key. | |
| 22 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 23 | + * @return {Cipher} A cipher instance. | |
| 24 | + * @example | |
| 25 | + * var cipher = RC4.createEncryptor(keyWordArray); | |
| 26 | + */ | |
| 27 | + static createEncryptor(key: Word32Array, props?: Partial<StreamCipherProps>): RC4; | |
| 28 | + /** | |
| 29 | + * Creates this cipher in decryption mode. | |
| 30 | + * | |
| 31 | + * @param {Word32Array} key The key. | |
| 32 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 33 | + * @return {Cipher} A cipher instance. | |
| 34 | + * @example | |
| 35 | + * var cipher = RC4.createDecryptor(keyWordArray, { iv: ivWordArray }); | |
| 36 | + */ | |
| 37 | + static createDecryptor(key: Word32Array, props?: Partial<StreamCipherProps>): RC4; | |
| 38 | + /** | |
| 39 | + * Encrypt a message with key | |
| 40 | + * | |
| 41 | + * @param {Word32Array|string} message | |
| 42 | + * @param {Word32Array|string} key | |
| 43 | + * @param {Partial<AESProps>?} props | |
| 44 | + * @example | |
| 45 | + * var encryptedMessage = RC4.encrypt("test", "pass"); | |
| 46 | + */ | |
| 47 | + static encrypt(message: Word32Array | string, key: Word32Array | string, props?: Partial<RC4Props>): CipherParams; | |
| 48 | + /** | |
| 49 | + * Encrypt a encrypted message with key | |
| 50 | + * | |
| 51 | + * @param {CipherParams} cipherText | |
| 52 | + * @param {Word32Array|string} key | |
| 53 | + * @param {Partial<AESProps>?} props | |
| 54 | + * @example | |
| 55 | + * var encryptedMessage = RC4.decrypt(cipherProps, "pass"); | |
| 56 | + */ | |
| 57 | + static decrypt(cipherText: CipherParams, key: Word32Array | string, props?: Partial<RC4Props>): Word32Array; | |
| 58 | +} | ... | ... |
app/static/content/jscrypto/RC4.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var r=t();for(var i in n.JsCrypto=n.JsCrypto||{},r)n.JsCrypto[i]=r[i]}}(this,(function(){return function(){"use strict";var n={6367:function(n,t,r){r.d(t,{Hmac:function(){return e}});var i=r(4768),e=function(){function n(n,t){this.u=n,"string"==typeof t&&(t=i.d.parse(t));var r=n.blockSize,e=4*r;t.nSigBytes>e&&(t=n.finalize(t)),t.clamp();for(var o=this.h=t.clone(),u=this.v=t.clone(),f=o.words,c=u.words,a=0;a<r;a++)f[a]^=1549556828,c[a]^=909522486;u.nSigBytes=e,o.nSigBytes=e,this.reset()}return n.prototype.reset=function(){this.u.reset(),this.u.update(this.v)},n.prototype.update=function(n){return this.u.update(n),this},n.prototype.finalize=function(n){var t=this.u.finalize(n);return this.u.reset(),this.u.finalize(this.h.clone().concat(t))},n}()},5561:function(n,t,r){r.d(t,{SHA256:function(){return v}});var i,e=r(1868),o=r(3354),u=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),f=[],c=[];function a(n){for(var t=Math.sqrt(n),r=2;r<=t;r++)if(!(n%r))return!1;return!0}function s(n){return 4294967296*(n-(0|n))|0}!function(){for(var n=2,t=0;t<64;)a(n)&&(t<8&&(f[t]=s(Math.pow(n,.5))),c[t]=s(Math.pow(n,1/3)),t++),n++}();var h=[],v=function(n){function t(t){var r=n.call(this,t)||this;return r.l=new o.e(f.slice(0)),r.O=t,t&&void 0!==t.hash&&(r.l=t.hash.clone()),r}return u(t,n),t.prototype.A=function(){this.l=new o.e(f.slice(0))},t.prototype.I=function(n,t){for(var r=this.l.words,i=r[0],e=r[1],o=r[2],u=r[3],f=r[4],a=r[5],s=r[6],v=r[7],w=0;w<64;w++){if(w<16)h[w]=0|n[t+w];else{var d=h[w-15],l=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,y=h[w-2],b=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;h[w]=l+h[w-7]+b+h[w-16]}var p=i&e^i&o^e&o,m=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),j=v+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(f&a^~f&s)+c[w]+h[w];v=s,s=a,a=f,f=u+j|0,u=o,o=e,e=i,i=j+(m+p)|0}r[0]=r[0]+i|0,r[1]=r[1]+e|0,r[2]=r[2]+o|0,r[3]=r[3]+u|0,r[4]=r[4]+f|0,r[5]=r[5]+a|0,r[6]=r[6]+s|0,r[7]=r[7]+v|0},t.prototype.k=function(){var n=this.N.words,t=8*this.U,r=8*this.N.nSigBytes;return n[r>>>5]|=128<<24-r%32,n[14+(r+64>>>9<<4)]=Math.floor(t/4294967296),n[15+(r+64>>>9<<4)]=t,this.N.nSigBytes=4*n.length,this.F(),this.l},t.prototype.clone=function(){return new t({hash:this.l,blockSize:this.H,data:this.N,nBytes:this.U})},t.hash=function(n,r){return new t(r).finalize(n)},t}(e.P)},3354:function(n,t,r){r.d(t,{e:function(){return o}});var i=r(5720),e=r(9054),o=function(){function n(t,r){if(Array.isArray(t)||!t)return this.T=Array.isArray(t)?t:[],void(this.B="number"==typeof r?r:4*this.T.length);if(t instanceof n)return this.T=t.words.slice(),void(this.B=t.nSigBytes);var i;try{t instanceof ArrayBuffer?i=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!i)throw new Error("Invalid argument");for(var e=i.byteLength,o=[],u=0;u<e;u++)o[u>>>2]|=i[u]<<24-u%4*8;this.T=o,this.B=e}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.B},set:function(n){this.B=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.T},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):i.p.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this.T,t=this.B,r=new Uint8Array(t),i=0;i<t;i++)r[i]=n[i>>>2]>>>24-i%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.B%4)for(var i=0;i<r;i++){var e=t[i>>>2]>>>24-i%4*8&255;this.T[this.B+i>>>2]|=e<<24-(this.B+i)%4*8}else for(i=0;i<r;i+=4)this.T[this.B+i>>>2]=t[i>>>2];return this.B+=r,this},n.prototype.clamp=function(){var n=this.B;this.T[n>>>2]&=4294967295<<32-n%4*8,this.T.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.T.slice(),this.B)},n.random=function(t){for(var r=[],i=0;i<t;i+=4)r.push((0,e.M)());return new n(r,t)},n}()},7211:function(n,t,r){r.d(t,{C:function(){return o}});var i=r(3354),e=r(4768),o=function(){function n(n){this.R=0,this.H=0,this.O=n,this.N=n&&void 0!==n.data?n.data.clone():new i.e,this.U=n&&"number"==typeof n.nBytes?n.nBytes:0}return Object.defineProperty(n.prototype,"blockSize",{get:function(){return this.H},enumerable:!1,configurable:!0}),n.prototype.reset=function(n,t){this.N=void 0!==n?n.clone():new i.e,this.U="number"==typeof t?t:0},n.prototype.G=function(n){var t="string"==typeof n?e.d.parse(n):n;this.N.concat(t),this.U+=t.nSigBytes},n.prototype.F=function(n){var t,r=this.N.words,e=this.N.nSigBytes,o=this.H,u=e/(4*this.H),f=(u=n?Math.ceil(u):Math.max((0|u)-this.R,0))*o,c=Math.min(4*f,e);if(f){for(var a=0;a<f;a+=o)this.I(r,a);t=r.splice(0,f),this.N.nSigBytes-=c}return new i.e(t,c)},n.prototype.I=function(n,t){throw new Error("Not implemented")},n}()},1868:function(n,t,r){r.d(t,{P:function(){return u}});var i,e=r(7211),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.H=16,r.O=t,t&&"number"==typeof t.blockSize&&(r.H=t.blockSize),r.reset(t?t.data:void 0,t?t.nBytes:void 0),r}return o(t,n),Object.defineProperty(t.prototype,"blockSize",{get:function(){return this.H},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.A()},t.prototype.update=function(n){return this.G(n),this.F(),this},t.prototype.finalize=function(n){return n&&this.G(n),this.k()},t.prototype.A=function(){throw new Error("Not implemented")},t.prototype.k=function(){throw new Error("Not implemented")},t}(e.C)},9456:function(n,t,r){r.d(t,{t:function(){return f}});var i,e=r(7211),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(){return(u=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},f=function(n){function t(t){var r=n.call(this,t)||this;return r.J=1,r.O=t,r.K=t.key,r.L=void 0!==t.iv?t.iv:r.L,r.J=void 0!==t.transformMode?t.transformMode:r.J,r}return o(t,n),Object.defineProperty(t.prototype,"iv",{get:function(){return this.L},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.A()},t.prototype.process=function(n){return this.G(n),this.F()},t.prototype.finalize=function(n){return n&&this.G(n),this.k()},t.prototype.A=function(){throw new Error("Not implemented")},t.prototype.I=function(n,t){throw new Error("Not implemented")},t.prototype.k=function(){throw new Error("Not implemented")},t.createEncryptor=function(n,r){return new t(u(u({},r=void 0===r?{}:r),{key:n,transformMode:t.ENC_TRANSFORM_MODE}))},t.createDecryptor=function(n,r){return new t(u(u({},r=void 0===r?{}:r),{key:n,transformMode:t.DEC_TRANSFORM_MODE}))},t.ENC_TRANSFORM_MODE=1,t.DEC_TRANSFORM_MODE=2,t.keySize=4,t.ivSize=4,t}(e.C)},2505:function(n,t,r){r.d(t,{Q:function(){return e}});var i=r(1232),e=function(){function n(n){this.formatter=i.w,n&&(this.cipherText=n.cipherText,this.key=n.key,this.iv=n.iv,this.salt=n.salt,this.Algorithm=n.Algorithm,this.mode=n.mode,this.padding=n.padding,this.blockSize=n.blockSize,this.formatter=n.formatter||i.w)}return n.prototype.toString=function(n){return(n||this.formatter).stringify(this)},n}()},5693:function(n,t,r){r.d(t,{E:function(){return c}});var i=r(9109),e=r(2214),o=r(2505),u=r(1232),f=function(){return(f=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},c={encrypt:function(n,t,r,u){var c=u?f({},u):{},a=u&&u.KDF?u.KDF:e.s,s={};u&&u.kdfHasher&&(s.kdfHasher=u.kdfHasher),u&&u.kdfIterations&&(s.kdfIterations=u.kdfIterations),u&&u.kdfModule&&(s.kdfModule=u.kdfModule);var h=a.execute(r,n.keySize,n.ivSize,c.kdfSalt,s);c.iv=h.iv;var v=i.D.encrypt(n,t,h.key,c);return new o.Q(f(f({},v),{key:h.key,iv:h.iv,salt:h.salt}))},decrypt:function(n,t,r,o){var c=o?f({},o):{},a=c.KDF?c.KDF:e.s,s=c.formatter?c.formatter:u.w,h=(0,i.W)(t,s),v={};o&&o.kdfHasher&&(v.kdfHasher=o.kdfHasher),o&&o.kdfIterations&&(v.kdfIterations=o.kdfIterations),o&&o.kdfModule&&(v.kdfModule=o.kdfModule);var w=a.execute(r,n.keySize,n.ivSize,h.salt,v);return c.iv=w.iv,i.D.decrypt(n,h,w.key,c)}}},9109:function(n,t,r){r.d(t,{W:function(){return o},D:function(){return u}});var i=r(1232),e=r(2505);function o(n,t){return"string"==typeof n?t.parse(n):n}var u={encrypt:function(n,t,r,o){var u=n.createEncryptor(r,o),f=u.finalize(t);return new e.Q({cipherText:f,key:r,iv:u.iv,Algorithm:n,mode:u.mode,padding:u.padding,blockSize:u.blockSize,formatter:(null==o?void 0:o.formatter)||i.w})},decrypt:function(n,t,r,e){var u=n.createDecryptor(r,e),f=o(t,(null==e?void 0:e.formatter)||i.w);return u.finalize(f.cipherText||"")}}},30:function(n,t,r){r.d(t,{q:function(){return u}});var i,e=r(9456),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.H=1,r}return o(t,n),t.prototype.k=function(){return this.F(!0)},t}(e.t)},1232:function(n,t,r){r.d(t,{w:function(){return u}});var i=r(2505),e=r(3354),o=r(1773),u={stringify:function(n){var t=n.cipherText,r=n.salt;return t?r?new e.e([1398893684,1701076831]).concat(r).concat(t).toString(o.D):t.toString(o.D):""},parse:function(n){var t,r=o.D.parse(n),u=r.words;return 1398893684===u[0]&&1701076831===u[1]&&(t=new e.e(u.slice(2,4)),u.splice(0,4),r.nSigBytes-=16),new i.Q({cipherText:r,salt:t})}}},2214:function(n,t,r){r.d(t,{s:function(){return f}});var i=r(3354),e=r(2505),o=r(7008),u=function(){return(u=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},f={execute:function(n,t,r,f,c){f||(f=i.e.random(8));var a=c&&c.kdfModule||o.E,s=c?{Hasher:c.kdfHasher,iterations:c.kdfIterations}:{},h=a.getKey(n,f,u(u({},s),{keySize:t+r})),v=new i.e(h.words.slice(t),4*r);return h.nSigBytes=4*t,new e.Q({key:h,iv:v,salt:f})}}},7008:function(n,t,r){r.d(t,{E:function(){return a}});var i,e=r(5561),o=r(6367),u=r(3354),f=r(9541),c=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),a=function(n){function t(t){var r=n.call(this,t)||this;return r.V=4,r.X=e.SHA256,r.Y=1e4,t&&(r.V=void 0!==t.keySize?t.keySize:r.V,r.X=void 0!==t.Hasher?t.Hasher:r.X,r.Y=void 0!==t.iterations?t.iterations:r.Y),r}return c(t,n),t.prototype.compute=function(n,t){for(var r=new o.Hmac(new this.X,n),i=new u.e,e=new u.e([1]),f=i.words,c=e.words,a=this.V,s=this.Y;f.length<a;){var h=r.update(t).finalize(e);r.reset();for(var v=h.words,w=v.length,d=h,l=1;l<s;l++){d=r.finalize(d),r.reset();for(var y=d.words,b=0;b<w;b++)v[b]^=y[b]}i.concat(h),c[0]++}return i.nSigBytes=4*a,i},t.getKey=function(n,r,i){return new t(i).compute(n,r)},t}(f._)},9541:function(n,t,r){r.d(t,{_:function(){return i}});var i=function(){function n(n){this.O=n}return n.prototype.compute=function(n,t){throw new Error("Not implemented")},n.getKey=function(n,t,r){throw new Error("Not implemented")},n}()},1756:function(n,t,r){r.d(t,{w:function(){return u}});var i,e="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(i=parseInt((/msie (\d+)/.exec(e)||[])[1],10),isNaN(i)?(i=parseInt((/trident\/.*; rv:(\d+)/.exec(e)||[])[1],10),!isNaN(i)&&i):i);function u(n,t){return!1!==o&&(!t||("<"===n?o<t:"<="===n?o<=t:">"===n?o>t:">="===n?o>=t:o===t))}},1773:function(n,t,r){r.d(t,{D:function(){return f}});for(var i=r(3354),e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=[],u=0;u<e.length;u++)o[e.charCodeAt(u)]=u;var f={stringify:function(n){var t=n.words,r=n.nSigBytes;n.clamp();for(var i=[],o=0;o<r;o+=3)for(var u=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,f=0;f<4&&o+.75*f<r;f++)i.push(e.charAt(u>>>6*(3-f)&63));var c=e.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(n){var t=n.length,r=e.charAt(64);if(r){var u=n.indexOf(r);-1!==u&&(t=u)}for(var f=[],c=0,a=0;a<t;a++)if(a%4){var s=o[n.charCodeAt(a-1)]<<a%4*2|o[n.charCodeAt(a)]>>>6-a%4*2;f[c>>>2]|=s<<24-c%4*8,c++}return new i.e(f,c)}}},5720:function(n,t,r){r.d(t,{p:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var r=[],e=0;e<t;e+=2)r[e>>>3]|=parseInt(n.substr(e,2),16)<<24-e%8*4;return new i.e(r,t/2)}}},8702:function(n,t,r){r.d(t,{m:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push(String.fromCharCode(o))}return i.join("")},parse:function(n){for(var t=n.length,r=[],e=0;e<t;e++)r[e>>>2]|=(255&n.charCodeAt(e))<<24-e%4*8;return new i.e(r,t)}}},4768:function(n,t,r){r.d(t,{d:function(){return e}});var i=r(8702),e={stringify:function(n){try{return decodeURIComponent(escape(i.m.stringify(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return i.m.parse(unescape(encodeURIComponent(n)))}}},9054:function(n,t,r){r.d(t,{M:function(){return e}});var i=r(1756);var e=function(){if("undefined"!=typeof window){var n=window.crypto||window.msCrypto;if(!n){if((0,i.w)("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return n.getRandomValues(new Uint32Array(1))[0]}}return void 0!==r.g&&r.g.crypto?function(){return r.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}()}},t={};function r(i){var e=t[i];if(void 0!==e)return e.exports;var o=t[i]={exports:{}};return n[i](o,o.exports,r),o.exports}r.d=function(n,t){for(var i in t)r.o(t,i)&&!r.o(n,i)&&Object.defineProperty(n,i,{enumerable:!0,get:t[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"Z",{value:!0})};var i={};return function(){r.r(i),r.d(i,{RC4:function(){return c}});var n,t=r(30),e=r(5693),o=r(9109),u=(n=function(t,r){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(t,r)},function(t,r){function i(){this.constructor=t}n(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}),f=function(){return(f=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},c=function(n){function t(t){var r=n.call(this,t)||this;return r.S=[],r.i=0,r.j=0,r.O=t,r.A(),r}return u(t,n),t.prototype.A=function(){var n=this.K,t=n.words,r=n.nSigBytes;this.S=[];for(var i=0;i<256;i++)this.S[i]=i;i=0;for(var e=0;i<256;i++){var o=i%r,u=t[o>>>2]>>>24-o%4*8&255;e=(e+this.S[i]+u)%256;var f=this.S[i];this.S[i]=this.S[e],this.S[e]=f}this.i=this.j=0},t.prototype.I=function(n,t){n[t]^=this.generateKeyStreamWord()},t.prototype.generateKeyStreamWord=function(){for(var n=this.S,t=this.i,r=this.j,i=0,e=0;e<4;e++){r=(r+n[t=(t+1)%256])%256;var o=n[t];n[t]=n[r],n[r]=o,i|=n[(n[t]+n[r])%256]<<24-8*e}return this.i=t,this.j=r,i},t.createEncryptor=function(n,r){return new t(f(f({},r=void 0===r?{}:r),{key:n}))},t.createDecryptor=function(n,r){return new t(f(f({},r=void 0===r?{}:r),{key:n}))},t.encrypt=function(n,r,i){return"string"==typeof r?e.E.encrypt(t,n,r,i):o.D.encrypt(t,n,r,i)},t.decrypt=function(n,r,i){return"string"==typeof r?e.E.decrypt(t,n,r,i):o.D.decrypt(t,n,r,i)},t.ivSize=0,t.keySize=8,t}(t.q)}(),i}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/RC4Drop.d.ts
0 → 100644
| 1 | +import { CipherProps, PropsWithKey } from "./lib/algorithm/cipher/Cipher"; | |
| 2 | +import type { Word32Array } from "./lib/Word32Array"; | |
| 3 | +import { CipherParams } from "./lib/algorithm/cipher/CipherParams"; | |
| 4 | +import { RC4 } from "./RC4"; | |
| 5 | +export interface RC4DropProps extends CipherProps { | |
| 6 | + drop?: number; | |
| 7 | +} | |
| 8 | +export declare class RC4Drop extends RC4 { | |
| 9 | + protected drop: number; | |
| 10 | + constructor(props: PropsWithKey<RC4DropProps>); | |
| 11 | + protected _doReset(): void; | |
| 12 | + /** | |
| 13 | + * Creates this cipher in encryption mode. | |
| 14 | + * | |
| 15 | + * @param {Word32Array} key The key. | |
| 16 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 17 | + * @return {Cipher} A cipher instance. | |
| 18 | + * @example | |
| 19 | + * var cipher = RC4Drop.createEncryptor(keyWordArray); | |
| 20 | + */ | |
| 21 | + static createEncryptor(key: Word32Array, props?: Partial<CipherProps>): RC4Drop; | |
| 22 | + /** | |
| 23 | + * Creates this cipher in decryption mode. | |
| 24 | + * | |
| 25 | + * @param {Word32Array} key The key. | |
| 26 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 27 | + * @return {Cipher} A cipher instance. | |
| 28 | + * @example | |
| 29 | + * var cipher = RC4Drop.createDecryptor(keyWordArray, { iv: ivWordArray }); | |
| 30 | + */ | |
| 31 | + static createDecryptor(key: Word32Array, props?: Partial<CipherProps>): RC4Drop; | |
| 32 | + /** | |
| 33 | + * Encrypt a message with key | |
| 34 | + * | |
| 35 | + * @param {Word32Array|string} message | |
| 36 | + * @param {Word32Array|string} key | |
| 37 | + * @param {Partial<AESProps>?} props | |
| 38 | + * @example | |
| 39 | + * var encryptedMessage = RC4Drop.encrypt("test", "pass"); | |
| 40 | + */ | |
| 41 | + static encrypt(message: Word32Array | string, key: Word32Array | string, props?: Partial<RC4DropProps>): CipherParams; | |
| 42 | + /** | |
| 43 | + * Encrypt a encrypted message with key | |
| 44 | + * | |
| 45 | + * @param {CipherParams} cipherText | |
| 46 | + * @param {Word32Array|string} key | |
| 47 | + * @param {Partial<AESProps>?} props | |
| 48 | + * @example | |
| 49 | + * var encryptedMessage = RC4Drop.decrypt(cipherProps, "pass"); | |
| 50 | + */ | |
| 51 | + static decrypt(cipherText: CipherParams, key: Word32Array | string, props?: Partial<RC4DropProps>): Word32Array; | |
| 52 | +} | ... | ... |
app/static/content/jscrypto/RC4Drop.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var r=t();for(var i in n.JsCrypto=n.JsCrypto||{},r)n.JsCrypto[i]=r[i]}}(this,(function(){return function(){"use strict";var n={6367:function(n,t,r){r.d(t,{Hmac:function(){return e}});var i=r(4768),e=function(){function n(n,t){this.u=n,"string"==typeof t&&(t=i.d.parse(t));var r=n.blockSize,e=4*r;t.nSigBytes>e&&(t=n.finalize(t)),t.clamp();for(var o=this.h=t.clone(),u=this.v=t.clone(),f=o.words,c=u.words,a=0;a<r;a++)f[a]^=1549556828,c[a]^=909522486;u.nSigBytes=e,o.nSigBytes=e,this.reset()}return n.prototype.reset=function(){this.u.reset(),this.u.update(this.v)},n.prototype.update=function(n){return this.u.update(n),this},n.prototype.finalize=function(n){var t=this.u.finalize(n);return this.u.reset(),this.u.finalize(this.h.clone().concat(t))},n}()},4615:function(n,t,r){r.d(t,{RC4:function(){return a}});var i,e=r(30),o=r(5693),u=r(9109),f=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),c=function(){return(c=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},a=function(n){function t(t){var r=n.call(this,t)||this;return r.S=[],r.i=0,r.j=0,r.l=t,r.O(),r}return f(t,n),t.prototype.O=function(){var n=this.A,t=n.words,r=n.nSigBytes;this.S=[];for(var i=0;i<256;i++)this.S[i]=i;i=0;for(var e=0;i<256;i++){var o=i%r,u=t[o>>>2]>>>24-o%4*8&255;e=(e+this.S[i]+u)%256;var f=this.S[i];this.S[i]=this.S[e],this.S[e]=f}this.i=this.j=0},t.prototype.k=function(n,t){n[t]^=this.generateKeyStreamWord()},t.prototype.generateKeyStreamWord=function(){for(var n=this.S,t=this.i,r=this.j,i=0,e=0;e<4;e++){r=(r+n[t=(t+1)%256])%256;var o=n[t];n[t]=n[r],n[r]=o,i|=n[(n[t]+n[r])%256]<<24-8*e}return this.i=t,this.j=r,i},t.createEncryptor=function(n,r){return new t(c(c({},r=void 0===r?{}:r),{key:n}))},t.createDecryptor=function(n,r){return new t(c(c({},r=void 0===r?{}:r),{key:n}))},t.encrypt=function(n,r,i){return"string"==typeof r?o.E.encrypt(t,n,r,i):u.D.encrypt(t,n,r,i)},t.decrypt=function(n,r,i){return"string"==typeof r?o.E.decrypt(t,n,r,i):u.D.decrypt(t,n,r,i)},t.ivSize=0,t.keySize=8,t}(e.q)},5561:function(n,t,r){r.d(t,{SHA256:function(){return v}});var i,e=r(1868),o=r(3354),u=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),f=[],c=[];function a(n){for(var t=Math.sqrt(n),r=2;r<=t;r++)if(!(n%r))return!1;return!0}function s(n){return 4294967296*(n-(0|n))|0}!function(){for(var n=2,t=0;t<64;)a(n)&&(t<8&&(f[t]=s(Math.pow(n,.5))),c[t]=s(Math.pow(n,1/3)),t++),n++}();var h=[],v=function(n){function t(t){var r=n.call(this,t)||this;return r.I=new o.e(f.slice(0)),r.l=t,t&&void 0!==t.hash&&(r.I=t.hash.clone()),r}return u(t,n),t.prototype.O=function(){this.I=new o.e(f.slice(0))},t.prototype.k=function(n,t){for(var r=this.I.words,i=r[0],e=r[1],o=r[2],u=r[3],f=r[4],a=r[5],s=r[6],v=r[7],w=0;w<64;w++){if(w<16)h[w]=0|n[t+w];else{var d=h[w-15],l=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,y=h[w-2],b=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;h[w]=l+h[w-7]+b+h[w-16]}var p=i&e^i&o^e&o,m=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),j=v+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(f&a^~f&s)+c[w]+h[w];v=s,s=a,a=f,f=u+j|0,u=o,o=e,e=i,i=j+(m+p)|0}r[0]=r[0]+i|0,r[1]=r[1]+e|0,r[2]=r[2]+o|0,r[3]=r[3]+u|0,r[4]=r[4]+f|0,r[5]=r[5]+a|0,r[6]=r[6]+s|0,r[7]=r[7]+v|0},t.prototype.N=function(){var n=this.U.words,t=8*this.F,r=8*this.U.nSigBytes;return n[r>>>5]|=128<<24-r%32,n[14+(r+64>>>9<<4)]=Math.floor(t/4294967296),n[15+(r+64>>>9<<4)]=t,this.U.nSigBytes=4*n.length,this.H(),this.I},t.prototype.clone=function(){return new t({hash:this.I,blockSize:this.T,data:this.U,nBytes:this.F})},t.hash=function(n,r){return new t(r).finalize(n)},t}(e.P)},3354:function(n,t,r){r.d(t,{e:function(){return o}});var i=r(5720),e=r(9054),o=function(){function n(t,r){if(Array.isArray(t)||!t)return this.R=Array.isArray(t)?t:[],void(this.B="number"==typeof r?r:4*this.R.length);if(t instanceof n)return this.R=t.words.slice(),void(this.B=t.nSigBytes);var i;try{t instanceof ArrayBuffer?i=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!i)throw new Error("Invalid argument");for(var e=i.byteLength,o=[],u=0;u<e;u++)o[u>>>2]|=i[u]<<24-u%4*8;this.R=o,this.B=e}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.B},set:function(n){this.B=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.R},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):i.p.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this.R,t=this.B,r=new Uint8Array(t),i=0;i<t;i++)r[i]=n[i>>>2]>>>24-i%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.B%4)for(var i=0;i<r;i++){var e=t[i>>>2]>>>24-i%4*8&255;this.R[this.B+i>>>2]|=e<<24-(this.B+i)%4*8}else for(i=0;i<r;i+=4)this.R[this.B+i>>>2]=t[i>>>2];return this.B+=r,this},n.prototype.clamp=function(){var n=this.B;this.R[n>>>2]&=4294967295<<32-n%4*8,this.R.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.R.slice(),this.B)},n.random=function(t){for(var r=[],i=0;i<t;i+=4)r.push((0,e.M)());return new n(r,t)},n}()},7211:function(n,t,r){r.d(t,{C:function(){return o}});var i=r(3354),e=r(4768),o=function(){function n(n){this.G=0,this.T=0,this.l=n,this.U=n&&void 0!==n.data?n.data.clone():new i.e,this.F=n&&"number"==typeof n.nBytes?n.nBytes:0}return Object.defineProperty(n.prototype,"blockSize",{get:function(){return this.T},enumerable:!1,configurable:!0}),n.prototype.reset=function(n,t){this.U=void 0!==n?n.clone():new i.e,this.F="number"==typeof t?t:0},n.prototype.J=function(n){var t="string"==typeof n?e.d.parse(n):n;this.U.concat(t),this.F+=t.nSigBytes},n.prototype.H=function(n){var t,r=this.U.words,e=this.U.nSigBytes,o=this.T,u=e/(4*this.T),f=(u=n?Math.ceil(u):Math.max((0|u)-this.G,0))*o,c=Math.min(4*f,e);if(f){for(var a=0;a<f;a+=o)this.k(r,a);t=r.splice(0,f),this.U.nSigBytes-=c}return new i.e(t,c)},n.prototype.k=function(n,t){throw new Error("Not implemented")},n}()},1868:function(n,t,r){r.d(t,{P:function(){return u}});var i,e=r(7211),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.T=16,r.l=t,t&&"number"==typeof t.blockSize&&(r.T=t.blockSize),r.reset(t?t.data:void 0,t?t.nBytes:void 0),r}return o(t,n),Object.defineProperty(t.prototype,"blockSize",{get:function(){return this.T},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.O()},t.prototype.update=function(n){return this.J(n),this.H(),this},t.prototype.finalize=function(n){return n&&this.J(n),this.N()},t.prototype.O=function(){throw new Error("Not implemented")},t.prototype.N=function(){throw new Error("Not implemented")},t}(e.C)},9456:function(n,t,r){r.d(t,{t:function(){return f}});var i,e=r(7211),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(){return(u=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},f=function(n){function t(t){var r=n.call(this,t)||this;return r.K=1,r.l=t,r.A=t.key,r.L=void 0!==t.iv?t.iv:r.L,r.K=void 0!==t.transformMode?t.transformMode:r.K,r}return o(t,n),Object.defineProperty(t.prototype,"iv",{get:function(){return this.L},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.O()},t.prototype.process=function(n){return this.J(n),this.H()},t.prototype.finalize=function(n){return n&&this.J(n),this.N()},t.prototype.O=function(){throw new Error("Not implemented")},t.prototype.k=function(n,t){throw new Error("Not implemented")},t.prototype.N=function(){throw new Error("Not implemented")},t.createEncryptor=function(n,r){return new t(u(u({},r=void 0===r?{}:r),{key:n,transformMode:t.ENC_TRANSFORM_MODE}))},t.createDecryptor=function(n,r){return new t(u(u({},r=void 0===r?{}:r),{key:n,transformMode:t.DEC_TRANSFORM_MODE}))},t.ENC_TRANSFORM_MODE=1,t.DEC_TRANSFORM_MODE=2,t.keySize=4,t.ivSize=4,t}(e.C)},2505:function(n,t,r){r.d(t,{Q:function(){return e}});var i=r(1232),e=function(){function n(n){this.formatter=i.w,n&&(this.cipherText=n.cipherText,this.key=n.key,this.iv=n.iv,this.salt=n.salt,this.Algorithm=n.Algorithm,this.mode=n.mode,this.padding=n.padding,this.blockSize=n.blockSize,this.formatter=n.formatter||i.w)}return n.prototype.toString=function(n){return(n||this.formatter).stringify(this)},n}()},5693:function(n,t,r){r.d(t,{E:function(){return c}});var i=r(9109),e=r(2214),o=r(2505),u=r(1232),f=function(){return(f=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},c={encrypt:function(n,t,r,u){var c=u?f({},u):{},a=u&&u.KDF?u.KDF:e.s,s={};u&&u.kdfHasher&&(s.kdfHasher=u.kdfHasher),u&&u.kdfIterations&&(s.kdfIterations=u.kdfIterations),u&&u.kdfModule&&(s.kdfModule=u.kdfModule);var h=a.execute(r,n.keySize,n.ivSize,c.kdfSalt,s);c.iv=h.iv;var v=i.D.encrypt(n,t,h.key,c);return new o.Q(f(f({},v),{key:h.key,iv:h.iv,salt:h.salt}))},decrypt:function(n,t,r,o){var c=o?f({},o):{},a=c.KDF?c.KDF:e.s,s=c.formatter?c.formatter:u.w,h=(0,i.W)(t,s),v={};o&&o.kdfHasher&&(v.kdfHasher=o.kdfHasher),o&&o.kdfIterations&&(v.kdfIterations=o.kdfIterations),o&&o.kdfModule&&(v.kdfModule=o.kdfModule);var w=a.execute(r,n.keySize,n.ivSize,h.salt,v);return c.iv=w.iv,i.D.decrypt(n,h,w.key,c)}}},9109:function(n,t,r){r.d(t,{W:function(){return o},D:function(){return u}});var i=r(1232),e=r(2505);function o(n,t){return"string"==typeof n?t.parse(n):n}var u={encrypt:function(n,t,r,o){var u=n.createEncryptor(r,o),f=u.finalize(t);return new e.Q({cipherText:f,key:r,iv:u.iv,Algorithm:n,mode:u.mode,padding:u.padding,blockSize:u.blockSize,formatter:(null==o?void 0:o.formatter)||i.w})},decrypt:function(n,t,r,e){var u=n.createDecryptor(r,e),f=o(t,(null==e?void 0:e.formatter)||i.w);return u.finalize(f.cipherText||"")}}},30:function(n,t,r){r.d(t,{q:function(){return u}});var i,e=r(9456),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.T=1,r}return o(t,n),t.prototype.N=function(){return this.H(!0)},t}(e.t)},1232:function(n,t,r){r.d(t,{w:function(){return u}});var i=r(2505),e=r(3354),o=r(1773),u={stringify:function(n){var t=n.cipherText,r=n.salt;return t?r?new e.e([1398893684,1701076831]).concat(r).concat(t).toString(o.D):t.toString(o.D):""},parse:function(n){var t,r=o.D.parse(n),u=r.words;return 1398893684===u[0]&&1701076831===u[1]&&(t=new e.e(u.slice(2,4)),u.splice(0,4),r.nSigBytes-=16),new i.Q({cipherText:r,salt:t})}}},2214:function(n,t,r){r.d(t,{s:function(){return f}});var i=r(3354),e=r(2505),o=r(7008),u=function(){return(u=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},f={execute:function(n,t,r,f,c){f||(f=i.e.random(8));var a=c&&c.kdfModule||o.E,s=c?{Hasher:c.kdfHasher,iterations:c.kdfIterations}:{},h=a.getKey(n,f,u(u({},s),{keySize:t+r})),v=new i.e(h.words.slice(t),4*r);return h.nSigBytes=4*t,new e.Q({key:h,iv:v,salt:f})}}},7008:function(n,t,r){r.d(t,{E:function(){return a}});var i,e=r(5561),o=r(6367),u=r(3354),f=r(9541),c=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),a=function(n){function t(t){var r=n.call(this,t)||this;return r.V=4,r.X=e.SHA256,r.Y=1e4,t&&(r.V=void 0!==t.keySize?t.keySize:r.V,r.X=void 0!==t.Hasher?t.Hasher:r.X,r.Y=void 0!==t.iterations?t.iterations:r.Y),r}return c(t,n),t.prototype.compute=function(n,t){for(var r=new o.Hmac(new this.X,n),i=new u.e,e=new u.e([1]),f=i.words,c=e.words,a=this.V,s=this.Y;f.length<a;){var h=r.update(t).finalize(e);r.reset();for(var v=h.words,w=v.length,d=h,l=1;l<s;l++){d=r.finalize(d),r.reset();for(var y=d.words,b=0;b<w;b++)v[b]^=y[b]}i.concat(h),c[0]++}return i.nSigBytes=4*a,i},t.getKey=function(n,r,i){return new t(i).compute(n,r)},t}(f._)},9541:function(n,t,r){r.d(t,{_:function(){return i}});var i=function(){function n(n){this.l=n}return n.prototype.compute=function(n,t){throw new Error("Not implemented")},n.getKey=function(n,t,r){throw new Error("Not implemented")},n}()},1756:function(n,t,r){r.d(t,{w:function(){return u}});var i,e="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(i=parseInt((/msie (\d+)/.exec(e)||[])[1],10),isNaN(i)?(i=parseInt((/trident\/.*; rv:(\d+)/.exec(e)||[])[1],10),!isNaN(i)&&i):i);function u(n,t){return!1!==o&&(!t||("<"===n?o<t:"<="===n?o<=t:">"===n?o>t:">="===n?o>=t:o===t))}},1773:function(n,t,r){r.d(t,{D:function(){return f}});for(var i=r(3354),e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=[],u=0;u<e.length;u++)o[e.charCodeAt(u)]=u;var f={stringify:function(n){var t=n.words,r=n.nSigBytes;n.clamp();for(var i=[],o=0;o<r;o+=3)for(var u=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,f=0;f<4&&o+.75*f<r;f++)i.push(e.charAt(u>>>6*(3-f)&63));var c=e.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(n){var t=n.length,r=e.charAt(64);if(r){var u=n.indexOf(r);-1!==u&&(t=u)}for(var f=[],c=0,a=0;a<t;a++)if(a%4){var s=o[n.charCodeAt(a-1)]<<a%4*2|o[n.charCodeAt(a)]>>>6-a%4*2;f[c>>>2]|=s<<24-c%4*8,c++}return new i.e(f,c)}}},5720:function(n,t,r){r.d(t,{p:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var r=[],e=0;e<t;e+=2)r[e>>>3]|=parseInt(n.substr(e,2),16)<<24-e%8*4;return new i.e(r,t/2)}}},8702:function(n,t,r){r.d(t,{m:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push(String.fromCharCode(o))}return i.join("")},parse:function(n){for(var t=n.length,r=[],e=0;e<t;e++)r[e>>>2]|=(255&n.charCodeAt(e))<<24-e%4*8;return new i.e(r,t)}}},4768:function(n,t,r){r.d(t,{d:function(){return e}});var i=r(8702),e={stringify:function(n){try{return decodeURIComponent(escape(i.m.stringify(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return i.m.parse(unescape(encodeURIComponent(n)))}}},9054:function(n,t,r){r.d(t,{M:function(){return e}});var i=r(1756);var e=function(){if("undefined"!=typeof window){var n=window.crypto||window.msCrypto;if(!n){if((0,i.w)("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return n.getRandomValues(new Uint32Array(1))[0]}}return void 0!==r.g&&r.g.crypto?function(){return r.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}()}},t={};function r(i){var e=t[i];if(void 0!==e)return e.exports;var o=t[i]={exports:{}};return n[i](o,o.exports,r),o.exports}r.d=function(n,t){for(var i in t)r.o(t,i)&&!r.o(n,i)&&Object.defineProperty(n,i,{enumerable:!0,get:t[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"Z",{value:!0})};var i={};return function(){r.r(i),r.d(i,{RC4Drop:function(){return c}});var n,t=r(5693),e=r(9109),o=r(4615),u=(n=function(t,r){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(t,r)},function(t,r){function i(){this.constructor=t}n(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}),f=function(){return(f=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},c=function(n){function r(t){var r=n.call(this,t)||this;return r.drop=192,r.l=t,t&&"number"==typeof t.drop&&(r.drop=t.drop),r.O(),r}return u(r,n),r.prototype.O=function(){n.prototype.O.call(this);for(var t=this.drop;t>0;t--)this.generateKeyStreamWord()},r.createEncryptor=function(n,t){return new r(f(f({},t=void 0===t?{}:t),{key:n}))},r.createDecryptor=function(n,t){return new r(f(f({},t=void 0===t?{}:t),{key:n}))},r.encrypt=function(n,i,o){return"string"==typeof i?t.E.encrypt(r,n,i,o):e.D.encrypt(r,n,i,o)},r.decrypt=function(n,i,o){return"string"==typeof i?t.E.decrypt(r,n,i,o):e.D.decrypt(r,n,i,o)},r}(o.RC4)}(),i}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/README.md
0 → 100644
| 1 | +# jscrypto | |
| 2 | +[](https://badge.fury.io/js/jscrypto) | |
| 3 | +[](https://opensource.org/licenses/MIT) | |
| 4 | + | |
| 5 | + | |
| 6 | +[crypto-js](https://github.com/brix/crypto-js) enhancement for modern js environments. | |
| 7 | + | |
| 8 | +- Works in modern browsers and **IE9/10/11**. | |
| 9 | + \*IE9/10 uses weak random generator on cipher encryption with string password. Use it at your own risk. | |
| 10 | + \*If only using decryption or hash/hmac, weak random generator does not cause any trouble. | |
| 11 | +- Loadable with ES6/CommonJS/Typescript/Browser runtimes. | |
| 12 | +- Support [`GCM`][GCM]/[`GMAC`][GMAC]/[`CCM`][CCM]/[`CBC-MAC`][CBC-MAC] :tada::tada::tada: | |
| 13 | +- [CLI commands](#cli) available: | |
| 14 | + i.e. `npx jscrypto sha1 "message"`, `npx jscrypto aes enc "message" "password"`, etc. | |
| 15 | +- Written in Typescript with rich type declarations. | |
| 16 | +- When bundling only SHA256 module, the webpack-ed js file can be less than 6kb. | |
| 17 | +- Default parameters for Block cipher (AES/DES/Triple-DES) is tuned to be OpenSSL(1.1.1f) compatible. | |
| 18 | + Read further [here](#openssl-compat) | |
| 19 | + | |
| 20 | +### Breaking changes for version 0.x.x users | |
| 21 | +There are several breaking changes between version 0.x and 1.x. | |
| 22 | +Please see detail in [CHANGELOG](https://github.com/Hinaser/jscrypto/blob/master/CHANGELOG.md) | |
| 23 | + | |
| 24 | + | |
| 25 | +## Install | |
| 26 | + | |
| 27 | +``` | |
| 28 | +npm install jscrypto | |
| 29 | +# or | |
| 30 | +yarn add jscrypto | |
| 31 | +``` | |
| 32 | + | |
| 33 | +If you only want to use [CLI commands](#cli), you don't even need to install `jscrypto`. | |
| 34 | +Just dispatch `npx` command like `npx jscrypto sha256 "message"`. | |
| 35 | +Read further [here](#cli) | |
| 36 | + | |
| 37 | +## Usage | |
| 38 | +### CommonJS Environment (Node.js environment like node CLI, AWS Lambda, etc) | |
| 39 | +```js | |
| 40 | +// Load whole library modules. | |
| 41 | +const JsCrypto = require("jscrypto"); | |
| 42 | +console.log(JsCrypto.SHA256.hash("test").toString()); | |
| 43 | + | |
| 44 | +// or load only necessary modules (Recommended for faster loading and reduced size) | |
| 45 | +const {SHA256} = require("jscrypto/SHA256"); | |
| 46 | +console.log(SHA256.hash("test").toString()); | |
| 47 | +``` | |
| 48 | + | |
| 49 | +### ES6 Environment (i.e. Creating app/library with webpack/react-scripts or some es6-compatible bundlers) | |
| 50 | +**Be sure to load the module from `jscrypto/es6`.** | |
| 51 | +This can greatly reduce bundle size by bundlers tree-shaking ability. | |
| 52 | +Don't forget to add `/es6` following `jscrypto` | |
| 53 | +```ecmascript 6 | |
| 54 | +// Load whole library modules. | |
| 55 | +import JsCrypto from "jscrypto/es6"; | |
| 56 | +console.log(JsCrypto.SHA256.hash("test").toString()); | |
| 57 | +... | |
| 58 | +import {SHA256} from "jscrypto/es6/SHA256"; // Recommended | |
| 59 | +console.log(SHA256.hash("test").toString()); | |
| 60 | +``` | |
| 61 | + | |
| 62 | +### Typescript Environment | |
| 63 | +**Be sure to load the module from `jscrypto/es6`.** | |
| 64 | +```ecmascript 6 | |
| 65 | +// Load whole library modules. | |
| 66 | +import * as JsCrypto from "jscrypto/es6"; | |
| 67 | +console.log(JsCrypto.SHA256.hash("test").toString()); | |
| 68 | +... | |
| 69 | +import {SHA256} from "jscrypto/es6/SHA256"; // Recommended | |
| 70 | +console.log(SHA256.hash("test").toString()); | |
| 71 | +``` | |
| 72 | + | |
| 73 | +### Browser | |
| 74 | +Copy js files/directories under `/dist` dir into somewhere browser can access. | |
| 75 | +Then directly load js file into `<script>` tag. | |
| 76 | +```html | |
| 77 | +<script src="dist/index.js"></script> <!-- All modules are loaded into browser --> | |
| 78 | +<script type="text/javascript"> | |
| 79 | + // This will output: "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08" | |
| 80 | + console.log(JsCrypto.SHA256.hash("test").toString()); | |
| 81 | +</script> | |
| 82 | +<!-- OR --> | |
| 83 | +<script src="dist/SHA256.js"></script> <!-- Single module loading is lightweight and faster. --> | |
| 84 | +<script type="text/javascript"> | |
| 85 | + // This will output: "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08" | |
| 86 | + console.log(JsCrypto.SHA256.hash("test").toString()); | |
| 87 | +</script> | |
| 88 | +``` | |
| 89 | + | |
| 90 | +<h3 id='cli'>CLI</h3> | |
| 91 | + | |
| 92 | +Command Line Interface to try various crypto modules on terminal. | |
| 93 | +```cmd | |
| 94 | + Usage: npx jscrypto <hash|hmac|cipher> [command options] | |
| 95 | + | |
| 96 | + hash: md5, sha1, sha3, sha224, sha256, sha384, sha512, ripemd160 | |
| 97 | + hmac: hmac-md5, hmac-sha1, hmac-sha224, hmac-sha256, hmac-sha384, hmac-sha512 | |
| 98 | + cipher: aes, des, des3, rc4 | |
| 99 | + | |
| 100 | + | |
| 101 | + $ npx jscrypto <hash> message [-msg hex|base64|utf8] [-out hex|base64] | |
| 102 | + | |
| 103 | + default: | |
| 104 | + -msg: utf8 ... recognize message as utf-8 string | |
| 105 | + -out: hex ... output hashed binary as hex string | |
| 106 | + example: | |
| 107 | + #Output of below 3 examples are the same | |
| 108 | + npx jscrypto sha1 test | |
| 109 | + npx jscrypto sha1 74657374 -msg hex | |
| 110 | + npx jscrypto sha1 dGVzdA== -msg base64 | |
| 111 | + | |
| 112 | + | |
| 113 | + $ npx jscrypto <hmac> message key [msg hex|base64|utf8] [-key hex|base64|utf8] [-out hex|base64] | |
| 114 | + | |
| 115 | + default: | |
| 116 | + -msg: utf8 ... recognize message as utf-8 string | |
| 117 | + -key: utf8 ... recognize key as utf-8 string | |
| 118 | + -out: hex ... output hashed binary as hex string | |
| 119 | + example: | |
| 120 | + #Output of below 3 examples are the same | |
| 121 | + npx jscrypto hmac-sha1 test key | |
| 122 | + npx jscrypto hmac-sha1 74657374 6b6579 -msg hex -key hex | |
| 123 | + npx jscrypto hmac-sha1 dGVzdA== a2V5 -msg base64 -key base64 | |
| 124 | + | |
| 125 | + | |
| 126 | + $ npx jscrypto <cipher> message key [-msg hex|base64|utf8] [-key hex|base64|utf8] [-out hex|base64|utf8] [-mode cbc|ecb|ofb|cfb] [-pad pkcs7|iso10126|iso97971|ansix923|nopadding] [-kdf pbkdf2|evpkdf] | |
| 127 | + | |
| 128 | + default: | |
| 129 | + -msg: utf8 ... recognize message as utf-8 string | |
| 130 | + -key: utf8 ... recognize key as utf-8 string | |
| 131 | + -out: base64|hex ... base64 on encryption, hex on decryption. Note: utf8 cannot be used on encryption. | |
| 132 | + -mode: cbc ... Code block chaining as block cipher mode | |
| 133 | + -pad: pkcs7 ... Pkcs7 padding as block padding | |
| 134 | + -kdf: pbkdf2 ... PBKDF2 as key derivation function | |
| 135 | + example: | |
| 136 | + #Encrypt (Output would not be the same because of a random salt, but can be decrypted with the same key) | |
| 137 | + npx jscrypto aes enc test password | |
| 138 | + npx jscrypto aes enc 74657374 70617373776f7264 -msg hex -key hex | |
| 139 | + npx jscrypto aes enc dGVzdA== cGFzc3dvcmQ= -msg base64 -key base64 | |
| 140 | + #Decrypt | |
| 141 | + npx jscrypto aes dec U2FsdGVkX19Kf/wItWMuaTrQYV3OljA3Cr9WPMhC6Tk= password -out utf8 | |
| 142 | + npx jscrypto aes dec A2pYDd/3oeENsRFGA1Y0Mg== 70617373776f7264 -key hex -out utf8 | |
| 143 | + npx jscrypto aes dec A2pYDd/3oeENsRFGA1Y0Mg== cGFzc3dvcmQ= -key base64 -out utf8 | |
| 144 | +``` | |
| 145 | + | |
| 146 | +<h3 id='openssl-compat'>OpenSSL compatibility</h3> | |
| 147 | + | |
| 148 | +#### Encryption | |
| 149 | + ```js | |
| 150 | + encryptedData = JsCrypto.AES.encrypt("message", "secret phrase").toString(); | |
| 151 | + ``` | |
| 152 | +is equivalent in OpenSSL (1.1.1f) to | |
| 153 | + ```shell | |
| 154 | + echo -n "message" | openssl enc -e -aes-256-cbc -pass pass:"secret phrase" -base64 -pbkdf2 | |
| 155 | + # Note: Because of a random salt, everytime it produces different base64 string. | |
| 156 | + # But it is OK for decryption. | |
| 157 | + ``` | |
| 158 | + | |
| 159 | +#### Decryption | |
| 160 | +Encrypted data can be decrypted by | |
| 161 | + ```js | |
| 162 | + JsCrypto.AES.decrypt(encryptedData, "secret phrase").toString(JsCrypto.Utf8); // "message" | |
| 163 | + ``` | |
| 164 | +or in OpenSSL | |
| 165 | + ```shell | |
| 166 | + echo "U2FsdGVkX1..." | openssl enc -d -aes-256-cbc -pass pass:"secret phrase" -base64 -pbkdf2 | |
| 167 | + # U2FsdGVkX1... is the output from either JsCrypto/OpenSSL encryption code/command. | |
| 168 | + ``` | |
| 169 | + | |
| 170 | +## FAQ | |
| 171 | +#### Failed to import jscrypto in Typescript environment. | |
| 172 | + | |
| 173 | +In most cases, your `tsconfig.json` is configured not to load npm module from `node_modules` folder. | |
| 174 | +Check your `tsconfig.js` to be: | |
| 175 | +```json | |
| 176 | +{ | |
| 177 | + "compilerOptions": { | |
| 178 | + "moduleResolution": "Node" | |
| 179 | + } | |
| 180 | +} | |
| 181 | +``` | |
| 182 | + | |
| 183 | +## API | |
| 184 | +`jscrypto` supports crypto modules as well as `cryptojs`. | |
| 185 | + | |
| 186 | +### *Popular* | |
| 187 | +**Hash** [`MD5`][MD5], [`SHA1`][SHA1], [`SHA3`][SHA3], [`SHA224`][SHA224], [`SHA256`][SHA256], [`SHA384`][SHA384], [`SHA512`][SHA512], [`RIPEMD160`][RIPEMD160], | |
| 188 | +**Message/Key Hash** [`HMAC-MD5`][HMAC-MD5], [`HMAC-SHA224`][HMAC-SHA224], [`HMAC-SHA256`][HMAC-SHA256], [`HMAC-SHA384`][HMAC-SHA384], [`HMAC-SHA512`][HMAC-SHA512], [`GMAC`][GMAC], [`CBC-MAC`][CBC-MAC] | |
| 189 | +**Block Cipher** [`AES`][AES], [`DES`][DES], [`Triple-DES`][Triple-DES] | |
| 190 | + | |
| 191 | +### *Basic structure* | |
| 192 | +**Word** [`Word32Array`][Word32Array], [`Word64Array`][Word64Array] | |
| 193 | +**Encoder** [`Base64`][Base64], [`Hex`][Hex], [`Latin1`][Latin1], [`Utf8`][Utf8], [`Utf16`][Utf16] | |
| 194 | + | |
| 195 | +### *Misc* | |
| 196 | +**Stream Cipher** [`Rabbits`][Rabbits], [`RC4`][RC4], [`RC4Drop`][RC4Drop] | |
| 197 | +**Key Derive Function** [`OpenSSLKDF`][OpenSSLKDF], [`EvpKDF`][EvpKDF], [`PBKDF2`][PBKDF2] | |
| 198 | +**Block Cipher mode** [`CBC`][CBC], [`CFB`][CFB], [`CTR`][CTR], [`ECB`][ECB], [`OFB`][OFB], [`GCM`][GCM], [`CCM`][CCM] | |
| 199 | +**Block Padding** [`AnsiX923`][AnsiX923], [`ISO10126`][ISO10126], [`ISO97971`][ISO97971], [`NoPadding`][NoPadding], [`Pkcs7`][Pkcs7], [`Zero`][Zero] | |
| 200 | +**Formatter** [`OpenSSLFormatter`][OpenSSLFormatter] | |
| 201 | + | |
| 202 | +[MD5]: https://github.com/Hinaser/jscrypto/blob/master/API.md#md5 | |
| 203 | +[SHA1]: https://github.com/Hinaser/jscrypto/blob/master/API.md#sha1 | |
| 204 | +[SHA3]: https://github.com/Hinaser/jscrypto/blob/master/API.md#sha3 | |
| 205 | +[SHA224]: https://github.com/Hinaser/jscrypto/blob/master/API.md#sha224 | |
| 206 | +[SHA256]: https://github.com/Hinaser/jscrypto/blob/master/API.md#sha256 | |
| 207 | +[SHA384]: https://github.com/Hinaser/jscrypto/blob/master/API.md#sha384 | |
| 208 | +[SHA512]: https://github.com/Hinaser/jscrypto/blob/master/API.md#sha512 | |
| 209 | +[RIPEMD160]: https://github.com/Hinaser/jscrypto/blob/master/API.md#ripemd160 | |
| 210 | +[HMAC-MD5]: https://github.com/Hinaser/jscrypto/blob/master/API.md#hmac-md5 | |
| 211 | +[HMAC-SHA224]: https://github.com/Hinaser/jscrypto/blob/master/API.md#hmac-sha224 | |
| 212 | +[HMAC-SHA256]: https://github.com/Hinaser/jscrypto/blob/master/API.md#hmac-sha256 | |
| 213 | +[HMAC-SHA384]: https://github.com/Hinaser/jscrypto/blob/master/API.md#hmac-sha384 | |
| 214 | +[HMAC-SHA512]: https://github.com/Hinaser/jscrypto/blob/master/API.md#hmac-sha512 | |
| 215 | +[GMAC]: https://github.com/Hinaser/jscrypto/blob/master/API.md#gmac | |
| 216 | +[CBC-MAC]: https://github.com/Hinaser/jscrypto/blob/master/API.md#cbc-mac | |
| 217 | +[AES]: https://github.com/Hinaser/jscrypto/blob/master/API.md#aes | |
| 218 | +[AES-GCM]: https://github.com/Hinaser/jscrypto/blob/master/API.md#aes-gcm | |
| 219 | +[AES-CCM]: https://github.com/Hinaser/jscrypto/blob/master/API.md#aes-ccm | |
| 220 | +[DES]: https://github.com/Hinaser/jscrypto/blob/master/API.md#des | |
| 221 | +[Triple-DES]: https://github.com/Hinaser/jscrypto/blob/master/API.md#des3 | |
| 222 | +[Word32Array]: https://github.com/Hinaser/jscrypto/blob/master/API.md#word32array | |
| 223 | +[Word64Array]: https://github.com/Hinaser/jscrypto/blob/master/API.md#mword64Array | |
| 224 | +[Base64]: https://github.com/Hinaser/jscrypto/blob/master/API.md#base64 | |
| 225 | +[Hex]: https://github.com/Hinaser/jscrypto/blob/master/API.md#hex | |
| 226 | +[Latin1]: https://github.com/Hinaser/jscrypto/blob/master/API.md#latin1 | |
| 227 | +[Utf8]: https://github.com/Hinaser/jscrypto/blob/master/API.md#utf8 | |
| 228 | +[Utf16]: https://github.com/Hinaser/jscrypto/blob/master/API.md#utf16 | |
| 229 | +[Rabbits]: https://github.com/Hinaser/jscrypto/blob/master/API.md#rabbits | |
| 230 | +[RC4]: https://github.com/Hinaser/jscrypto/blob/master/API.md#rc4 | |
| 231 | +[RC4Drop]: https://github.com/Hinaser/jscrypto/blob/master/API.md#rc4drop | |
| 232 | +[OpenSSLKDF]: https://github.com/Hinaser/jscrypto/blob/master/API.md#opensslkdf | |
| 233 | +[EvpKDF]: https://github.com/Hinaser/jscrypto/blob/master/API.md#evpkdf | |
| 234 | +[PBKDF2]: https://github.com/Hinaser/jscrypto/blob/master/API.md#pbkdf2 | |
| 235 | +[CBC]: https://github.com/Hinaser/jscrypto/blob/master/API.md#cbc | |
| 236 | +[CFB]: https://github.com/Hinaser/jscrypto/blob/master/API.md#cfb | |
| 237 | +[CTR]: https://github.com/Hinaser/jscrypto/blob/master/API.md#ctr | |
| 238 | +[ECB]: https://github.com/Hinaser/jscrypto/blob/master/API.md#ecb | |
| 239 | +[OFB]: https://github.com/Hinaser/jscrypto/blob/master/API.md#ofb | |
| 240 | +[GCM]: https://github.com/Hinaser/jscrypto/blob/master/API.md#gcm | |
| 241 | +[CCM]: https://github.com/Hinaser/jscrypto/blob/master/API.md#ccm | |
| 242 | +[AnsiX923]: https://github.com/Hinaser/jscrypto/blob/master/API.md#ansix923 | |
| 243 | +[ISO10126]: https://github.com/Hinaser/jscrypto/blob/master/API.md#iso10126 | |
| 244 | +[ISO97971]: https://github.com/Hinaser/jscrypto/blob/master/API.md#iso97971 | |
| 245 | +[NoPadding]: https://github.com/Hinaser/jscrypto/blob/master/API.md#nopadding | |
| 246 | +[Pkcs7]: https://github.com/Hinaser/jscrypto/blob/master/API.md#pkcs7 | |
| 247 | +[Zero]: https://github.com/Hinaser/jscrypto/blob/master/API.md#zero | |
| 248 | +[OpenSSLFormatter]: https://github.com/Hinaser/jscrypto/blob/master/API.md#opensslformatter | ... | ... |
app/static/content/jscrypto/REFERENCE.md
0 → 100644
| 1 | +[crypto-js](https://github.com/brix/crypto-js) / | |
| 2 | +[The MIT License (MIT)](http://opensource.org/licenses/MIT) | |
| 3 | +Copyright (c) 2009-2013 Jeff Mott | |
| 4 | +Copyright (c) 2013-2016 Evan Vosberg | |
| 5 | + | |
| 6 | +[crypto-es](https://github.com/entronad/crypto-es) / | |
| 7 | +[The MIT License (MIT)](http://opensource.org/licenses/MIT) | |
| 8 | +Copyright (c) 2018-2020 LIN Chen | |
| 9 | + | |
| 10 | +[NIST Special Publication 800-38D](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf) | |
| 11 | +NIST/Morris Dworkin | |
| 12 | + | |
| 13 | +[NIST Special Publication 800-38C](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38c.pdf) | |
| 14 | +NIST/Morris Dworkin | ... | ... |
app/static/content/jscrypto/RIPEMD160.d.ts
0 → 100644
| 1 | +/** @preserve | |
| 2 | +(c) 2012 by Cédric Mesnil. All rights reserved. | |
| 3 | +Redistribution and use in source and binary forms, with or without modification, | |
| 4 | + are permitted provided that the following conditions are met: | |
| 5 | + | |
| 6 | +- Redistributions of source code must retain the above copyright notice, | |
| 7 | + this list of conditions and the following disclaimer. | |
| 8 | +- Redistributions in binary form must reproduce the above copyright notice, | |
| 9 | + this list of conditions and the following disclaimer in the documentation | |
| 10 | + and/or other materials provided with the distribution. | |
| 11 | + | |
| 12 | +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, | |
| 13 | +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
| 14 | +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
| 15 | +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
| 16 | +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | |
| 17 | +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | |
| 18 | +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 19 | + */ | |
| 20 | +import { Hasher, HasherProps } from "./lib/algorithm/Hasher"; | |
| 21 | +import { Word32Array } from "./lib/Word32Array"; | |
| 22 | +export interface RIPEMD160Props extends HasherProps { | |
| 23 | + hash: Word32Array; | |
| 24 | +} | |
| 25 | +export declare class RIPEMD160 extends Hasher { | |
| 26 | + protected _props?: Partial<RIPEMD160Props>; | |
| 27 | + private _hash; | |
| 28 | + constructor(props?: RIPEMD160Props); | |
| 29 | + protected _doReset(): void; | |
| 30 | + protected _doProcessBlock(words: number[], offset: number): void; | |
| 31 | + protected _doFinalize(): Word32Array; | |
| 32 | + clone(): RIPEMD160; | |
| 33 | + static hash(message: Word32Array | string, props?: RIPEMD160Props): Word32Array; | |
| 34 | +} | ... | ... |
app/static/content/jscrypto/RIPEMD160.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var r=t();for(var e in n.JsCrypto=n.JsCrypto||{},r)n.JsCrypto[e]=r[e]}}(this,(function(){return function(){"use strict";var n={3354:function(n,t,r){r.d(t,{e:function(){return o}});var e=r(5720),i=r(9054),o=function(){function n(t,r){if(Array.isArray(t)||!t)return this.t=Array.isArray(t)?t:[],void(this.i="number"==typeof r?r:4*this.t.length);if(t instanceof n)return this.t=t.words.slice(),void(this.i=t.nSigBytes);var e;try{t instanceof ArrayBuffer?e=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(e=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!e)throw new Error("Invalid argument");for(var i=e.byteLength,o=[],u=0;u<i;u++)o[u>>>2]|=e[u]<<24-u%4*8;this.t=o,this.i=i}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.i},set:function(n){this.i=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.t},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):e.p.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this.t,t=this.i,r=new Uint8Array(t),e=0;e<t;e++)r[e]=n[e>>>2]>>>24-e%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.i%4)for(var e=0;e<r;e++){var i=t[e>>>2]>>>24-e%4*8&255;this.t[this.i+e>>>2]|=i<<24-(this.i+e)%4*8}else for(e=0;e<r;e+=4)this.t[this.i+e>>>2]=t[e>>>2];return this.i+=r,this},n.prototype.clamp=function(){var n=this.i;this.t[n>>>2]&=4294967295<<32-n%4*8,this.t.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.t.slice(),this.i)},n.random=function(t){for(var r=[],e=0;e<t;e+=4)r.push((0,i.M)());return new n(r,t)},n}()},7211:function(n,t,r){r.d(t,{C:function(){return o}});var e=r(3354),i=r(4768),o=function(){function n(n){this.u=0,this.h=0,this.v=n,this.l=n&&void 0!==n.data?n.data.clone():new e.e,this.j=n&&"number"==typeof n.nBytes?n.nBytes:0}return Object.defineProperty(n.prototype,"blockSize",{get:function(){return this.h},enumerable:!1,configurable:!0}),n.prototype.reset=function(n,t){this.l=void 0!==n?n.clone():new e.e,this.j="number"==typeof t?t:0},n.prototype.A=function(n){var t="string"==typeof n?i.d.parse(n):n;this.l.concat(t),this.j+=t.nSigBytes},n.prototype.I=function(n){var t,r=this.l.words,i=this.l.nSigBytes,o=this.h,u=i/(4*this.h),f=(u=n?Math.ceil(u):Math.max((0|u)-this.u,0))*o,c=Math.min(4*f,i);if(f){for(var a=0;a<f;a+=o)this.O(r,a);t=r.splice(0,f),this.l.nSigBytes-=c}return new e.e(t,c)},n.prototype.O=function(n,t){throw new Error("Not implemented")},n}()},1868:function(n,t,r){r.d(t,{P:function(){return u}});var e,i=r(7211),o=(e=function(n,t){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}e(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.h=16,r.v=t,t&&"number"==typeof t.blockSize&&(r.h=t.blockSize),r.reset(t?t.data:void 0,t?t.nBytes:void 0),r}return o(t,n),Object.defineProperty(t.prototype,"blockSize",{get:function(){return this.h},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.U()},t.prototype.update=function(n){return this.A(n),this.I(),this},t.prototype.finalize=function(n){return n&&this.A(n),this._()},t.prototype.U=function(){throw new Error("Not implemented")},t.prototype._=function(){throw new Error("Not implemented")},t}(i.C)},1756:function(n,t,r){r.d(t,{w:function(){return u}});var e,i="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(e=parseInt((/msie (\d+)/.exec(i)||[])[1],10),isNaN(e)?(e=parseInt((/trident\/.*; rv:(\d+)/.exec(i)||[])[1],10),!isNaN(e)&&e):e);function u(n,t){return!1!==o&&(!t||("<"===n?o<t:"<="===n?o<=t:">"===n?o>t:">="===n?o>=t:o===t))}},5720:function(n,t,r){r.d(t,{p:function(){return i}});var e=r(3354),i={stringify:function(n){for(var t=n.nSigBytes,r=n.words,e=[],i=0;i<t;i++){var o=r[i>>>2]>>>24-i%4*8&255;e.push((o>>>4).toString(16)),e.push((15&o).toString(16))}return e.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var r=[],i=0;i<t;i+=2)r[i>>>3]|=parseInt(n.substr(i,2),16)<<24-i%8*4;return new e.e(r,t/2)}}},8702:function(n,t,r){r.d(t,{m:function(){return i}});var e=r(3354),i={stringify:function(n){for(var t=n.nSigBytes,r=n.words,e=[],i=0;i<t;i++){var o=r[i>>>2]>>>24-i%4*8&255;e.push(String.fromCharCode(o))}return e.join("")},parse:function(n){for(var t=n.length,r=[],i=0;i<t;i++)r[i>>>2]|=(255&n.charCodeAt(i))<<24-i%4*8;return new e.e(r,t)}}},4768:function(n,t,r){r.d(t,{d:function(){return i}});var e=r(8702),i={stringify:function(n){try{return decodeURIComponent(escape(e.m.stringify(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return e.m.parse(unescape(encodeURIComponent(n)))}}},9054:function(n,t,r){r.d(t,{M:function(){return i}});var e=r(1756);var i=function(){if("undefined"!=typeof window){var n=window.crypto||window.msCrypto;if(!n){if((0,e.w)("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return n.getRandomValues(new Uint32Array(1))[0]}}return void 0!==r.g&&r.g.crypto?function(){return r.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}()}},t={};function r(e){var i=t[e];if(void 0!==i)return i.exports;var o=t[e]={exports:{}};return n[e](o,o.exports,r),o.exports}r.d=function(n,t){for(var e in t)r.o(t,e)&&!r.o(n,e)&&Object.defineProperty(n,e,{enumerable:!0,get:t[e]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"S",{value:!0})};var e={};return function(){r.r(e),r.d(e,{RIPEMD160:function(){return p}});var n,t=r(1868),i=r(3354),o=(n=function(t,r){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(t,r)},function(t,r){function e(){this.constructor=t}n(t,r),t.prototype=null===r?Object.create(r):(e.prototype=r.prototype,new e)}),u=new i.e([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),f=new i.e([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),c=new i.e([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),a=new i.e([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),s=new i.e([0,1518500249,1859775393,2400959708,2840853838]),h=new i.e([1352829926,1548603684,1836072691,2053994217,0]);function v(n,t,r){return n^t^r}function w(n,t,r){return n&t|~n&r}function d(n,t,r){return(n|~t)^r}function l(n,t,r){return n&r|t&~r}function y(n,t,r){return n^(t|~r)}function b(n,t){return n<<t|n>>>32-t}var p=function(n){function t(t){var r=n.call(this,t)||this;return r.N=new i.e([1732584193,4023233417,2562383102,271733878,3285377520]),r.v=t,t&&void 0!==t.hash&&(r.N=t.hash.clone()),r}return o(t,n),t.prototype.U=function(){this.N=new i.e([1732584193,4023233417,2562383102,271733878,3285377520])},t.prototype.O=function(n,t){for(var r=0;r<16;r++){var e=t+r,i=n[e];n[e]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o,p,m,g,j,A,I,O,E,M,U,_=this.N.words,S=s.words,N=h.words,x=u.words,C=f.words,F=c.words,k=a.words;A=o=_[0],I=p=_[1],O=m=_[2],E=g=_[3],M=j=_[4];for(r=0;r<80;r+=1)U=o+n[t+x[r]]|0,U+=r<16?v(p,m,g)+S[0]:r<32?w(p,m,g)+S[1]:r<48?d(p,m,g)+S[2]:r<64?l(p,m,g)+S[3]:y(p,m,g)+S[4],U=(U=b(U|=0,F[r]))+j|0,o=j,j=g,g=b(m,10),m=p,p=U,U=A+n[t+C[r]]|0,U+=r<16?y(I,O,E)+N[0]:r<32?l(I,O,E)+N[1]:r<48?d(I,O,E)+N[2]:r<64?w(I,O,E)+N[3]:v(I,O,E)+N[4],U=(U=b(U|=0,k[r]))+M|0,A=M,M=E,E=b(O,10),O=I,I=U;U=_[1]+m+E|0,_[1]=_[2]+g+M|0,_[2]=_[3]+j+A|0,_[3]=_[4]+o+I|0,_[4]=_[0]+p+O|0,_[0]=U},t.prototype._=function(){var n=this.l,t=n.words,r=8*this.j,e=8*n.nSigBytes;t[e>>>5]|=128<<24-e%32,t[14+(e+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),n.nSigBytes=4*(t.length+1),this.I();for(var i=this.N,o=i.words,u=0;u<5;u++){var f=o[u];o[u]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8)}return i},t.prototype.clone=function(){return new t({hash:this.N,blockSize:this.h,data:this.l,nBytes:this.j})},t.hash=function(n,r){return new t(r).finalize(n)},t}(t.P)}(),e}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/Rabbit.d.ts
0 → 100644
| 1 | +import { CipherProps, PropsWithKey } from "./lib/algorithm/cipher/Cipher"; | |
| 2 | +import type { Word32Array } from "./lib/Word32Array"; | |
| 3 | +import { StreamCipher } from "./lib/algorithm/cipher/StreamCipher"; | |
| 4 | +import { CipherParams } from "./lib/algorithm/cipher/CipherParams"; | |
| 5 | +export interface RabbitProps extends CipherProps { | |
| 6 | +} | |
| 7 | +export declare class Rabbit extends StreamCipher { | |
| 8 | + protected _blockSize: number; | |
| 9 | + static readonly ivSize: number; | |
| 10 | + protected _props: PropsWithKey<RabbitProps>; | |
| 11 | + protected S: number[]; | |
| 12 | + protected C: number[]; | |
| 13 | + protected G: number[]; | |
| 14 | + protected _X: number[]; | |
| 15 | + protected _C: number[]; | |
| 16 | + protected _b: number; | |
| 17 | + constructor(props: PropsWithKey<RabbitProps>); | |
| 18 | + protected _doReset(): void; | |
| 19 | + protected _doProcessBlock(words: number[], offset: number): void; | |
| 20 | + protected nextState(): void; | |
| 21 | + /** | |
| 22 | + * Creates this cipher in encryption mode. | |
| 23 | + * | |
| 24 | + * @param {Word32Array} key The key. | |
| 25 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 26 | + * @return {Cipher} A cipher instance. | |
| 27 | + * @example | |
| 28 | + * var cipher = Rabbit.createEncryptor(keyWordArray); | |
| 29 | + */ | |
| 30 | + static createEncryptor(key: Word32Array, props?: Partial<CipherProps>): Rabbit; | |
| 31 | + /** | |
| 32 | + * Creates this cipher in decryption mode. | |
| 33 | + * | |
| 34 | + * @param {Word32Array} key The key. | |
| 35 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 36 | + * @return {Cipher} A cipher instance. | |
| 37 | + * @example | |
| 38 | + * var cipher = Rabbit.createDecryptor(keyWordArray, { iv: ivWordArray }); | |
| 39 | + */ | |
| 40 | + static createDecryptor(key: Word32Array, props?: Partial<CipherProps>): Rabbit; | |
| 41 | + /** | |
| 42 | + * Encrypt a message with key | |
| 43 | + * | |
| 44 | + * @param {Word32Array|string} message | |
| 45 | + * @param {Word32Array|string} key | |
| 46 | + * @param {Partial<AESProps>?} props | |
| 47 | + * @example | |
| 48 | + * var encryptedMessage = Rabbit.encrypt("test", "pass"); | |
| 49 | + */ | |
| 50 | + static encrypt(message: Word32Array | string, key: Word32Array | string, props?: Partial<RabbitProps>): CipherParams; | |
| 51 | + /** | |
| 52 | + * Encrypt a encrypted message with key | |
| 53 | + * | |
| 54 | + * @param {CipherParams} cipherText | |
| 55 | + * @param {Word32Array|string} key | |
| 56 | + * @param {Partial<AESProps>?} props | |
| 57 | + * @example | |
| 58 | + * var encryptedMessage = Rabbit.decrypt(cipherProps, "pass"); | |
| 59 | + */ | |
| 60 | + static decrypt(cipherText: CipherParams, key: Word32Array | string, props?: Partial<RabbitProps>): Word32Array; | |
| 61 | +} | ... | ... |
app/static/content/jscrypto/Rabbit.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var r=t();for(var i in n.JsCrypto=n.JsCrypto||{},r)n.JsCrypto[i]=r[i]}}(this,(function(){return function(){"use strict";var n={6367:function(n,t,r){r.d(t,{Hmac:function(){return e}});var i=r(4768),e=function(){function n(n,t){this.i=n,"string"==typeof t&&(t=i.d.parse(t));var r=n.blockSize,e=4*r;t.nSigBytes>e&&(t=n.finalize(t)),t.clamp();for(var o=this.u=t.clone(),u=this.h=t.clone(),f=o.words,c=u.words,s=0;s<r;s++)f[s]^=1549556828,c[s]^=909522486;u.nSigBytes=e,o.nSigBytes=e,this.reset()}return n.prototype.reset=function(){this.i.reset(),this.i.update(this.h)},n.prototype.update=function(n){return this.i.update(n),this},n.prototype.finalize=function(n){var t=this.i.finalize(n);return this.i.reset(),this.i.finalize(this.u.clone().concat(t))},n}()},5561:function(n,t,r){r.d(t,{SHA256:function(){return v}});var i,e=r(1868),o=r(3354),u=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),f=[],c=[];function s(n){for(var t=Math.sqrt(n),r=2;r<=t;r++)if(!(n%r))return!1;return!0}function a(n){return 4294967296*(n-(0|n))|0}!function(){for(var n=2,t=0;t<64;)s(n)&&(t<8&&(f[t]=a(Math.pow(n,.5))),c[t]=a(Math.pow(n,1/3)),t++),n++}();var h=[],v=function(n){function t(t){var r=n.call(this,t)||this;return r.v=new o.e(f.slice(0)),r.l=t,t&&void 0!==t.hash&&(r.v=t.hash.clone()),r}return u(t,n),t.prototype.j=function(){this.v=new o.e(f.slice(0))},t.prototype.O=function(n,t){for(var r=this.v.words,i=r[0],e=r[1],o=r[2],u=r[3],f=r[4],s=r[5],a=r[6],v=r[7],w=0;w<64;w++){if(w<16)h[w]=0|n[t+w];else{var d=h[w-15],l=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,b=h[w-2],y=(b<<15|b>>>17)^(b<<13|b>>>19)^b>>>10;h[w]=l+h[w-7]+y+h[w-16]}var p=i&e^i&o^e&o,m=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),j=v+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(f&s^~f&a)+c[w]+h[w];v=a,a=s,s=f,f=u+j|0,u=o,o=e,e=i,i=j+(m+p)|0}r[0]=r[0]+i|0,r[1]=r[1]+e|0,r[2]=r[2]+o|0,r[3]=r[3]+u|0,r[4]=r[4]+f|0,r[5]=r[5]+s|0,r[6]=r[6]+a|0,r[7]=r[7]+v|0},t.prototype.A=function(){var n=this.I.words,t=8*this.k,r=8*this.I.nSigBytes;return n[r>>>5]|=128<<24-r%32,n[14+(r+64>>>9<<4)]=Math.floor(t/4294967296),n[15+(r+64>>>9<<4)]=t,this.I.nSigBytes=4*n.length,this.N(),this.v},t.prototype.clone=function(){return new t({hash:this.v,blockSize:this.U,data:this.I,nBytes:this.k})},t.hash=function(n,r){return new t(r).finalize(n)},t}(e.P)},3354:function(n,t,r){r.d(t,{e:function(){return o}});var i=r(5720),e=r(9054),o=function(){function n(t,r){if(Array.isArray(t)||!t)return this.F=Array.isArray(t)?t:[],void(this.H="number"==typeof r?r:4*this.F.length);if(t instanceof n)return this.F=t.words.slice(),void(this.H=t.nSigBytes);var i;try{t instanceof ArrayBuffer?i=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!i)throw new Error("Invalid argument");for(var e=i.byteLength,o=[],u=0;u<e;u++)o[u>>>2]|=i[u]<<24-u%4*8;this.F=o,this.H=e}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.H},set:function(n){this.H=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.F},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):i.p.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this.F,t=this.H,r=new Uint8Array(t),i=0;i<t;i++)r[i]=n[i>>>2]>>>24-i%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.H%4)for(var i=0;i<r;i++){var e=t[i>>>2]>>>24-i%4*8&255;this.F[this.H+i>>>2]|=e<<24-(this.H+i)%4*8}else for(i=0;i<r;i+=4)this.F[this.H+i>>>2]=t[i>>>2];return this.H+=r,this},n.prototype.clamp=function(){var n=this.H;this.F[n>>>2]&=4294967295<<32-n%4*8,this.F.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.F.slice(),this.H)},n.random=function(t){for(var r=[],i=0;i<t;i+=4)r.push((0,e.M)());return new n(r,t)},n}()},7211:function(n,t,r){r.d(t,{C:function(){return o}});var i=r(3354),e=r(4768),o=function(){function n(n){this.T=0,this.U=0,this.l=n,this.I=n&&void 0!==n.data?n.data.clone():new i.e,this.k=n&&"number"==typeof n.nBytes?n.nBytes:0}return Object.defineProperty(n.prototype,"blockSize",{get:function(){return this.U},enumerable:!1,configurable:!0}),n.prototype.reset=function(n,t){this.I=void 0!==n?n.clone():new i.e,this.k="number"==typeof t?t:0},n.prototype.B=function(n){var t="string"==typeof n?e.d.parse(n):n;this.I.concat(t),this.k+=t.nSigBytes},n.prototype.N=function(n){var t,r=this.I.words,e=this.I.nSigBytes,o=this.U,u=e/(4*this.U),f=(u=n?Math.ceil(u):Math.max((0|u)-this.T,0))*o,c=Math.min(4*f,e);if(f){for(var s=0;s<f;s+=o)this.O(r,s);t=r.splice(0,f),this.I.nSigBytes-=c}return new i.e(t,c)},n.prototype.O=function(n,t){throw new Error("Not implemented")},n}()},1868:function(n,t,r){r.d(t,{P:function(){return u}});var i,e=r(7211),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.U=16,r.l=t,t&&"number"==typeof t.blockSize&&(r.U=t.blockSize),r.reset(t?t.data:void 0,t?t.nBytes:void 0),r}return o(t,n),Object.defineProperty(t.prototype,"blockSize",{get:function(){return this.U},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.j()},t.prototype.update=function(n){return this.B(n),this.N(),this},t.prototype.finalize=function(n){return n&&this.B(n),this.A()},t.prototype.j=function(){throw new Error("Not implemented")},t.prototype.A=function(){throw new Error("Not implemented")},t}(e.C)},9456:function(n,t,r){r.d(t,{t:function(){return f}});var i,e=r(7211),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(){return(u=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},f=function(n){function t(t){var r=n.call(this,t)||this;return r.R=1,r.l=t,r.J=t.key,r.K=void 0!==t.iv?t.iv:r.K,r.R=void 0!==t.transformMode?t.transformMode:r.R,r}return o(t,n),Object.defineProperty(t.prototype,"iv",{get:function(){return this.K},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.j()},t.prototype.process=function(n){return this.B(n),this.N()},t.prototype.finalize=function(n){return n&&this.B(n),this.A()},t.prototype.j=function(){throw new Error("Not implemented")},t.prototype.O=function(n,t){throw new Error("Not implemented")},t.prototype.A=function(){throw new Error("Not implemented")},t.createEncryptor=function(n,r){return new t(u(u({},r=void 0===r?{}:r),{key:n,transformMode:t.ENC_TRANSFORM_MODE}))},t.createDecryptor=function(n,r){return new t(u(u({},r=void 0===r?{}:r),{key:n,transformMode:t.DEC_TRANSFORM_MODE}))},t.ENC_TRANSFORM_MODE=1,t.DEC_TRANSFORM_MODE=2,t.keySize=4,t.ivSize=4,t}(e.C)},2505:function(n,t,r){r.d(t,{Q:function(){return e}});var i=r(1232),e=function(){function n(n){this.formatter=i.w,n&&(this.cipherText=n.cipherText,this.key=n.key,this.iv=n.iv,this.salt=n.salt,this.Algorithm=n.Algorithm,this.mode=n.mode,this.padding=n.padding,this.blockSize=n.blockSize,this.formatter=n.formatter||i.w)}return n.prototype.toString=function(n){return(n||this.formatter).stringify(this)},n}()},5693:function(n,t,r){r.d(t,{E:function(){return c}});var i=r(9109),e=r(2214),o=r(2505),u=r(1232),f=function(){return(f=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},c={encrypt:function(n,t,r,u){var c=u?f({},u):{},s=u&&u.KDF?u.KDF:e.s,a={};u&&u.kdfHasher&&(a.kdfHasher=u.kdfHasher),u&&u.kdfIterations&&(a.kdfIterations=u.kdfIterations),u&&u.kdfModule&&(a.kdfModule=u.kdfModule);var h=s.execute(r,n.keySize,n.ivSize,c.kdfSalt,a);c.iv=h.iv;var v=i.D.encrypt(n,t,h.key,c);return new o.Q(f(f({},v),{key:h.key,iv:h.iv,salt:h.salt}))},decrypt:function(n,t,r,o){var c=o?f({},o):{},s=c.KDF?c.KDF:e.s,a=c.formatter?c.formatter:u.w,h=(0,i.W)(t,a),v={};o&&o.kdfHasher&&(v.kdfHasher=o.kdfHasher),o&&o.kdfIterations&&(v.kdfIterations=o.kdfIterations),o&&o.kdfModule&&(v.kdfModule=o.kdfModule);var w=s.execute(r,n.keySize,n.ivSize,h.salt,v);return c.iv=w.iv,i.D.decrypt(n,h,w.key,c)}}},9109:function(n,t,r){r.d(t,{W:function(){return o},D:function(){return u}});var i=r(1232),e=r(2505);function o(n,t){return"string"==typeof n?t.parse(n):n}var u={encrypt:function(n,t,r,o){var u=n.createEncryptor(r,o),f=u.finalize(t);return new e.Q({cipherText:f,key:r,iv:u.iv,Algorithm:n,mode:u.mode,padding:u.padding,blockSize:u.blockSize,formatter:(null==o?void 0:o.formatter)||i.w})},decrypt:function(n,t,r,e){var u=n.createDecryptor(r,e),f=o(t,(null==e?void 0:e.formatter)||i.w);return u.finalize(f.cipherText||"")}}},30:function(n,t,r){r.d(t,{q:function(){return u}});var i,e=r(9456),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.U=1,r}return o(t,n),t.prototype.A=function(){return this.N(!0)},t}(e.t)},1232:function(n,t,r){r.d(t,{w:function(){return u}});var i=r(2505),e=r(3354),o=r(1773),u={stringify:function(n){var t=n.cipherText,r=n.salt;return t?r?new e.e([1398893684,1701076831]).concat(r).concat(t).toString(o.D):t.toString(o.D):""},parse:function(n){var t,r=o.D.parse(n),u=r.words;return 1398893684===u[0]&&1701076831===u[1]&&(t=new e.e(u.slice(2,4)),u.splice(0,4),r.nSigBytes-=16),new i.Q({cipherText:r,salt:t})}}},2214:function(n,t,r){r.d(t,{s:function(){return f}});var i=r(3354),e=r(2505),o=r(7008),u=function(){return(u=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},f={execute:function(n,t,r,f,c){f||(f=i.e.random(8));var s=c&&c.kdfModule||o.E,a=c?{Hasher:c.kdfHasher,iterations:c.kdfIterations}:{},h=s.getKey(n,f,u(u({},a),{keySize:t+r})),v=new i.e(h.words.slice(t),4*r);return h.nSigBytes=4*t,new e.Q({key:h,iv:v,salt:f})}}},7008:function(n,t,r){r.d(t,{E:function(){return s}});var i,e=r(5561),o=r(6367),u=r(3354),f=r(9541),c=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),s=function(n){function t(t){var r=n.call(this,t)||this;return r.L=4,r.V=e.SHA256,r.X=1e4,t&&(r.L=void 0!==t.keySize?t.keySize:r.L,r.V=void 0!==t.Hasher?t.Hasher:r.V,r.X=void 0!==t.iterations?t.iterations:r.X),r}return c(t,n),t.prototype.compute=function(n,t){for(var r=new o.Hmac(new this.V,n),i=new u.e,e=new u.e([1]),f=i.words,c=e.words,s=this.L,a=this.X;f.length<s;){var h=r.update(t).finalize(e);r.reset();for(var v=h.words,w=v.length,d=h,l=1;l<a;l++){d=r.finalize(d),r.reset();for(var b=d.words,y=0;y<w;y++)v[y]^=b[y]}i.concat(h),c[0]++}return i.nSigBytes=4*s,i},t.getKey=function(n,r,i){return new t(i).compute(n,r)},t}(f._)},9541:function(n,t,r){r.d(t,{_:function(){return i}});var i=function(){function n(n){this.l=n}return n.prototype.compute=function(n,t){throw new Error("Not implemented")},n.getKey=function(n,t,r){throw new Error("Not implemented")},n}()},1756:function(n,t,r){r.d(t,{w:function(){return u}});var i,e="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(i=parseInt((/msie (\d+)/.exec(e)||[])[1],10),isNaN(i)?(i=parseInt((/trident\/.*; rv:(\d+)/.exec(e)||[])[1],10),!isNaN(i)&&i):i);function u(n,t){return!1!==o&&(!t||("<"===n?o<t:"<="===n?o<=t:">"===n?o>t:">="===n?o>=t:o===t))}},1773:function(n,t,r){r.d(t,{D:function(){return f}});for(var i=r(3354),e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=[],u=0;u<e.length;u++)o[e.charCodeAt(u)]=u;var f={stringify:function(n){var t=n.words,r=n.nSigBytes;n.clamp();for(var i=[],o=0;o<r;o+=3)for(var u=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,f=0;f<4&&o+.75*f<r;f++)i.push(e.charAt(u>>>6*(3-f)&63));var c=e.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(n){var t=n.length,r=e.charAt(64);if(r){var u=n.indexOf(r);-1!==u&&(t=u)}for(var f=[],c=0,s=0;s<t;s++)if(s%4){var a=o[n.charCodeAt(s-1)]<<s%4*2|o[n.charCodeAt(s)]>>>6-s%4*2;f[c>>>2]|=a<<24-c%4*8,c++}return new i.e(f,c)}}},5720:function(n,t,r){r.d(t,{p:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var r=[],e=0;e<t;e+=2)r[e>>>3]|=parseInt(n.substr(e,2),16)<<24-e%8*4;return new i.e(r,t/2)}}},8702:function(n,t,r){r.d(t,{m:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push(String.fromCharCode(o))}return i.join("")},parse:function(n){for(var t=n.length,r=[],e=0;e<t;e++)r[e>>>2]|=(255&n.charCodeAt(e))<<24-e%4*8;return new i.e(r,t)}}},4768:function(n,t,r){r.d(t,{d:function(){return e}});var i=r(8702),e={stringify:function(n){try{return decodeURIComponent(escape(i.m.stringify(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return i.m.parse(unescape(encodeURIComponent(n)))}}},9054:function(n,t,r){r.d(t,{M:function(){return e}});var i=r(1756);var e=function(){if("undefined"!=typeof window){var n=window.crypto||window.msCrypto;if(!n){if((0,i.w)("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return n.getRandomValues(new Uint32Array(1))[0]}}return void 0!==r.g&&r.g.crypto?function(){return r.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}()}},t={};function r(i){var e=t[i];if(void 0!==e)return e.exports;var o=t[i]={exports:{}};return n[i](o,o.exports,r),o.exports}r.d=function(n,t){for(var i in t)r.o(t,i)&&!r.o(n,i)&&Object.defineProperty(n,i,{enumerable:!0,get:t[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"Y",{value:!0})};var i={};return function(){r.r(i),r.d(i,{Rabbit:function(){return c}});var n,t=r(30),e=r(5693),o=r(9109),u=(n=function(t,r){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(t,r)},function(t,r){function i(){this.constructor=t}n(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}),f=function(){return(f=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},c=function(n){function t(t){var r=n.call(this,t)||this;return r.U=4,r.S=[],r.C=[],r.G=[],r.Z=[],r.$=[],r.nn=0,r.l=t,r.j(),r}return u(t,n),t.prototype.j=function(){for(var n=this.J.words,t=this.K,r=0;r<4;r++)n[r]=16711935&(n[r]<<8|n[r]>>>24)|4278255360&(n[r]<<24|n[r]>>>8);var i=this.Z=[n[0],n[3]<<16|n[2]>>>16,n[1],n[0]<<16|n[3]>>>16,n[2],n[1]<<16|n[0]>>>16,n[3],n[2]<<16|n[1]>>>16],e=this.$=[n[2]<<16|n[2]>>>16,4294901760&n[0]|65535&n[1],n[3]<<16|n[3]>>>16,4294901760&n[1]|65535&n[2],n[0]<<16|n[0]>>>16,4294901760&n[2]|65535&n[3],n[1]<<16|n[1]>>>16,4294901760&n[3]|65535&n[0]];this.nn=0;for(r=0;r<4;r++)this.nextState();for(r=0;r<8;r++)e[r]^=i[r+4&7];if(t){var o=t.words,u=o[0],f=o[1],c=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8),s=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8),a=c>>>16|4294901760&s,h=s<<16|65535&c;e[0]^=c,e[1]^=a,e[2]^=s,e[3]^=h,e[4]^=c,e[5]^=a,e[6]^=s,e[7]^=h;for(r=0;r<4;r++)this.nextState()}},t.prototype.O=function(n,t){var r=this.Z;this.nextState(),this.S[0]=r[0]^r[5]>>>16^r[3]<<16,this.S[1]=r[2]^r[7]>>>16^r[5]<<16,this.S[2]=r[4]^r[1]>>>16^r[7]<<16,this.S[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)this.S[i]=16711935&(this.S[i]<<8|this.S[i]>>>24)|4278255360&(this.S[i]<<24|this.S[i]>>>8),n[t+i]^=this.S[i]},t.prototype.nextState=function(){for(var n=this.Z,t=this.$,r=0;r<8;r++)this.C[r]=t[r];t[0]=t[0]+1295307597+this.nn|0,t[1]=t[1]+3545052371+(t[0]>>>0<this.C[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<this.C[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<this.C[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<this.C[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<this.C[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<this.C[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<this.C[6]>>>0?1:0)|0,this.nn=t[7]>>>0<this.C[7]>>>0?1:0;for(r=0;r<8;r++){var i=n[r]+t[r],e=65535&i,o=i>>>16,u=((e*e>>>17)+e*o>>>15)+o*o,f=((4294901760&i)*i|0)+((65535&i)*i|0);this.G[r]=u^f}var c=this.G;n[0]=c[0]+(c[7]<<16|c[7]>>>16)+(c[6]<<16|c[6]>>>16)|0,n[1]=c[1]+(c[0]<<8|c[0]>>>24)+c[7]|0,n[2]=c[2]+(c[1]<<16|c[1]>>>16)+(c[0]<<16|c[0]>>>16)|0,n[3]=c[3]+(c[2]<<8|c[2]>>>24)+c[1]|0,n[4]=c[4]+(c[3]<<16|c[3]>>>16)+(c[2]<<16|c[2]>>>16)|0,n[5]=c[5]+(c[4]<<8|c[4]>>>24)+c[3]|0,n[6]=c[6]+(c[5]<<16|c[5]>>>16)+(c[4]<<16|c[4]>>>16)|0,n[7]=c[7]+(c[6]<<8|c[6]>>>24)+c[5]|0},t.createEncryptor=function(n,r){return new t(f(f({},r=void 0===r?{}:r),{key:n}))},t.createDecryptor=function(n,r){return new t(f(f({},r=void 0===r?{}:r),{key:n}))},t.encrypt=function(n,r,i){return"string"==typeof r?e.E.encrypt(t,n,r,i):o.D.encrypt(t,n,r,i)},t.decrypt=function(n,r,i){return"string"==typeof r?e.E.decrypt(t,n,r,i):o.D.decrypt(t,n,r,i)},t.ivSize=4,t}(t.q)}(),i}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/SHA1.d.ts
0 → 100644
| 1 | +import { Hasher, HasherProps } from "./lib/algorithm/Hasher"; | |
| 2 | +import { Word32Array } from "./lib/Word32Array"; | |
| 3 | +export interface SHA1Props extends HasherProps { | |
| 4 | + hash: Word32Array; | |
| 5 | +} | |
| 6 | +export declare class SHA1 extends Hasher { | |
| 7 | + protected _props?: Partial<SHA1Props>; | |
| 8 | + private _hash; | |
| 9 | + constructor(props?: SHA1Props); | |
| 10 | + protected _doReset(): void; | |
| 11 | + protected _doProcessBlock(words: number[], offset: number): void; | |
| 12 | + protected _doFinalize(): Word32Array; | |
| 13 | + clone(): SHA1; | |
| 14 | + static hash(message: Word32Array | string, props?: SHA1Props): Word32Array; | |
| 15 | +} | ... | ... |
app/static/content/jscrypto/SHA1.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var r=t();for(var i in n.JsCrypto=n.JsCrypto||{},r)n.JsCrypto[i]=r[i]}}(this,(function(){return function(){"use strict";var n={3354:function(n,t,r){r.d(t,{e:function(){return o}});var i=r(5720),e=r(9054),o=function(){function n(t,r){if(Array.isArray(t)||!t)return this.t=Array.isArray(t)?t:[],void(this.i="number"==typeof r?r:4*this.t.length);if(t instanceof n)return this.t=t.words.slice(),void(this.i=t.nSigBytes);var i;try{t instanceof ArrayBuffer?i=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!i)throw new Error("Invalid argument");for(var e=i.byteLength,o=[],u=0;u<e;u++)o[u>>>2]|=i[u]<<24-u%4*8;this.t=o,this.i=e}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.i},set:function(n){this.i=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.t},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):i.p.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this.t,t=this.i,r=new Uint8Array(t),i=0;i<t;i++)r[i]=n[i>>>2]>>>24-i%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.i%4)for(var i=0;i<r;i++){var e=t[i>>>2]>>>24-i%4*8&255;this.t[this.i+i>>>2]|=e<<24-(this.i+i)%4*8}else for(i=0;i<r;i+=4)this.t[this.i+i>>>2]=t[i>>>2];return this.i+=r,this},n.prototype.clamp=function(){var n=this.i;this.t[n>>>2]&=4294967295<<32-n%4*8,this.t.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.t.slice(),this.i)},n.random=function(t){for(var r=[],i=0;i<t;i+=4)r.push((0,e.M)());return new n(r,t)},n}()},7211:function(n,t,r){r.d(t,{C:function(){return o}});var i=r(3354),e=r(4768),o=function(){function n(n){this.u=0,this.h=0,this.v=n,this.l=n&&void 0!==n.data?n.data.clone():new i.e,this.A=n&&"number"==typeof n.nBytes?n.nBytes:0}return Object.defineProperty(n.prototype,"blockSize",{get:function(){return this.h},enumerable:!1,configurable:!0}),n.prototype.reset=function(n,t){this.l=void 0!==n?n.clone():new i.e,this.A="number"==typeof t?t:0},n.prototype.j=function(n){var t="string"==typeof n?e.d.parse(n):n;this.l.concat(t),this.A+=t.nSigBytes},n.prototype.O=function(n){var t,r=this.l.words,e=this.l.nSigBytes,o=this.h,u=e/(4*this.h),f=(u=n?Math.ceil(u):Math.max((0|u)-this.u,0))*o,c=Math.min(4*f,e);if(f){for(var a=0;a<f;a+=o)this.I(r,a);t=r.splice(0,f),this.l.nSigBytes-=c}return new i.e(t,c)},n.prototype.I=function(n,t){throw new Error("Not implemented")},n}()},1868:function(n,t,r){r.d(t,{P:function(){return u}});var i,e=r(7211),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.h=16,r.v=t,t&&"number"==typeof t.blockSize&&(r.h=t.blockSize),r.reset(t?t.data:void 0,t?t.nBytes:void 0),r}return o(t,n),Object.defineProperty(t.prototype,"blockSize",{get:function(){return this.h},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.U()},t.prototype.update=function(n){return this.j(n),this.O(),this},t.prototype.finalize=function(n){return n&&this.j(n),this._()},t.prototype.U=function(){throw new Error("Not implemented")},t.prototype._=function(){throw new Error("Not implemented")},t}(e.C)},1756:function(n,t,r){r.d(t,{w:function(){return u}});var i,e="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(i=parseInt((/msie (\d+)/.exec(e)||[])[1],10),isNaN(i)?(i=parseInt((/trident\/.*; rv:(\d+)/.exec(e)||[])[1],10),!isNaN(i)&&i):i);function u(n,t){return!1!==o&&(!t||("<"===n?o<t:"<="===n?o<=t:">"===n?o>t:">="===n?o>=t:o===t))}},5720:function(n,t,r){r.d(t,{p:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var r=[],e=0;e<t;e+=2)r[e>>>3]|=parseInt(n.substr(e,2),16)<<24-e%8*4;return new i.e(r,t/2)}}},8702:function(n,t,r){r.d(t,{m:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push(String.fromCharCode(o))}return i.join("")},parse:function(n){for(var t=n.length,r=[],e=0;e<t;e++)r[e>>>2]|=(255&n.charCodeAt(e))<<24-e%4*8;return new i.e(r,t)}}},4768:function(n,t,r){r.d(t,{d:function(){return e}});var i=r(8702),e={stringify:function(n){try{return decodeURIComponent(escape(i.m.stringify(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return i.m.parse(unescape(encodeURIComponent(n)))}}},9054:function(n,t,r){r.d(t,{M:function(){return e}});var i=r(1756);var e=function(){if("undefined"!=typeof window){var n=window.crypto||window.msCrypto;if(!n){if((0,i.w)("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return n.getRandomValues(new Uint32Array(1))[0]}}return void 0!==r.g&&r.g.crypto?function(){return r.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}()}},t={};function r(i){var e=t[i];if(void 0!==e)return e.exports;var o=t[i]={exports:{}};return n[i](o,o.exports,r),o.exports}r.d=function(n,t){for(var i in t)r.o(t,i)&&!r.o(n,i)&&Object.defineProperty(n,i,{enumerable:!0,get:t[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"S",{value:!0})};var i={};return function(){r.r(i),r.d(i,{SHA1:function(){return f}});var n,t=r(1868),e=r(3354),o=(n=function(t,r){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(t,r)},function(t,r){function i(){this.constructor=t}n(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}),u=[],f=function(n){function t(t){var r=n.call(this,t)||this;return r.N=new e.e([1732584193,4023233417,2562383102,271733878,3285377520]),r.v=t,t&&void 0!==t.hash&&(r.N=t.hash.clone()),r}return o(t,n),t.prototype.U=function(){this.N=new e.e([1732584193,4023233417,2562383102,271733878,3285377520])},t.prototype.I=function(n,t){for(var r=this.N.words,i=r[0],e=r[1],o=r[2],f=r[3],c=r[4],a=0;a<80;a++){if(a<16)u[a]=0|n[t+a];else{var s=u[a-3]^u[a-8]^u[a-14]^u[a-16];u[a]=s<<1|s>>>31}var h=(i<<5|i>>>27)+c+u[a];h+=a<20?1518500249+(e&o|~e&f):a<40?1859775393+(e^o^f):a<60?(e&o|e&f|o&f)-1894007588:(e^o^f)-899497514,c=f,f=o,o=e<<30|e>>>2,e=i,i=h}r[0]=r[0]+i|0,r[1]=r[1]+e|0,r[2]=r[2]+o|0,r[3]=r[3]+f|0,r[4]=r[4]+c|0},t.prototype._=function(){var n=this.l.words,t=8*this.A,r=8*this.l.nSigBytes;return n[r>>>5]|=128<<24-r%32,n[14+(r+64>>>9<<4)]=Math.floor(t/4294967296),n[15+(r+64>>>9<<4)]=t,this.l.nSigBytes=4*n.length,this.O(),this.N},t.prototype.clone=function(){return new t({hash:this.N,blockSize:this.h,data:this.l,nBytes:this.A})},t.hash=function(n,r){return new t(r).finalize(n)},t}(t.P)}(),i}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/SHA224.d.ts
0 → 100644
| 1 | +import { Word32Array } from "./lib/Word32Array"; | |
| 2 | +import { SHA256 } from "./SHA256"; | |
| 3 | +import type { HasherProps } from "./lib/algorithm/Hasher"; | |
| 4 | +export interface SHA224Props extends HasherProps { | |
| 5 | + hash: Word32Array; | |
| 6 | +} | |
| 7 | +export declare class SHA224 extends SHA256 { | |
| 8 | + protected _props?: Partial<SHA224Props>; | |
| 9 | + protected _hash: Word32Array; | |
| 10 | + constructor(props?: SHA224Props); | |
| 11 | + protected _doReset(): void; | |
| 12 | + protected _doFinalize(): Word32Array; | |
| 13 | + clone(): SHA224; | |
| 14 | + static hash(message: Word32Array | string, props?: SHA224Props): Word32Array; | |
| 15 | +} | ... | ... |
app/static/content/jscrypto/SHA224.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var r=t();for(var i in n.JsCrypto=n.JsCrypto||{},r)n.JsCrypto[i]=r[i]}}(this,(function(){return function(){"use strict";var n={5561:function(n,t,r){r.d(t,{SHA256:function(){return v}});var i,e=r(1868),o=r(3354),u=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),f=[],c=[];function a(n){for(var t=Math.sqrt(n),r=2;r<=t;r++)if(!(n%r))return!1;return!0}function s(n){return 4294967296*(n-(0|n))|0}!function(){for(var n=2,t=0;t<64;)a(n)&&(t<8&&(f[t]=s(Math.pow(n,.5))),c[t]=s(Math.pow(n,1/3)),t++),n++}();var h=[],v=function(n){function t(t){var r=n.call(this,t)||this;return r.t=new o.e(f.slice(0)),r.i=t,t&&void 0!==t.hash&&(r.t=t.hash.clone()),r}return u(t,n),t.prototype.u=function(){this.t=new o.e(f.slice(0))},t.prototype.h=function(n,t){for(var r=this.t.words,i=r[0],e=r[1],o=r[2],u=r[3],f=r[4],a=r[5],s=r[6],v=r[7],w=0;w<64;w++){if(w<16)h[w]=0|n[t+w];else{var d=h[w-15],l=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,y=h[w-2],b=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;h[w]=l+h[w-7]+b+h[w-16]}var p=i&e^i&o^e&o,m=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),g=v+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(f&a^~f&s)+c[w]+h[w];v=s,s=a,a=f,f=u+g|0,u=o,o=e,e=i,i=g+(m+p)|0}r[0]=r[0]+i|0,r[1]=r[1]+e|0,r[2]=r[2]+o|0,r[3]=r[3]+u|0,r[4]=r[4]+f|0,r[5]=r[5]+a|0,r[6]=r[6]+s|0,r[7]=r[7]+v|0},t.prototype.v=function(){var n=this.l.words,t=8*this.j,r=8*this.l.nSigBytes;return n[r>>>5]|=128<<24-r%32,n[14+(r+64>>>9<<4)]=Math.floor(t/4294967296),n[15+(r+64>>>9<<4)]=t,this.l.nSigBytes=4*n.length,this.A(),this.t},t.prototype.clone=function(){return new t({hash:this.t,blockSize:this.O,data:this.l,nBytes:this.j})},t.hash=function(n,r){return new t(r).finalize(n)},t}(e.P)},3354:function(n,t,r){r.d(t,{e:function(){return o}});var i=r(5720),e=r(9054),o=function(){function n(t,r){if(Array.isArray(t)||!t)return this._=Array.isArray(t)?t:[],void(this.I="number"==typeof r?r:4*this._.length);if(t instanceof n)return this._=t.words.slice(),void(this.I=t.nSigBytes);var i;try{t instanceof ArrayBuffer?i=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!i)throw new Error("Invalid argument");for(var e=i.byteLength,o=[],u=0;u<e;u++)o[u>>>2]|=i[u]<<24-u%4*8;this._=o,this.I=e}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.I},set:function(n){this.I=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this._},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):i.p.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this._,t=this.I,r=new Uint8Array(t),i=0;i<t;i++)r[i]=n[i>>>2]>>>24-i%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.I%4)for(var i=0;i<r;i++){var e=t[i>>>2]>>>24-i%4*8&255;this._[this.I+i>>>2]|=e<<24-(this.I+i)%4*8}else for(i=0;i<r;i+=4)this._[this.I+i>>>2]=t[i>>>2];return this.I+=r,this},n.prototype.clamp=function(){var n=this.I;this._[n>>>2]&=4294967295<<32-n%4*8,this._.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this._.slice(),this.I)},n.random=function(t){for(var r=[],i=0;i<t;i+=4)r.push((0,e.M)());return new n(r,t)},n}()},7211:function(n,t,r){r.d(t,{C:function(){return o}});var i=r(3354),e=r(4768),o=function(){function n(n){this.S=0,this.O=0,this.i=n,this.l=n&&void 0!==n.data?n.data.clone():new i.e,this.j=n&&"number"==typeof n.nBytes?n.nBytes:0}return Object.defineProperty(n.prototype,"blockSize",{get:function(){return this.O},enumerable:!1,configurable:!0}),n.prototype.reset=function(n,t){this.l=void 0!==n?n.clone():new i.e,this.j="number"==typeof t?t:0},n.prototype.U=function(n){var t="string"==typeof n?e.d.parse(n):n;this.l.concat(t),this.j+=t.nSigBytes},n.prototype.A=function(n){var t,r=this.l.words,e=this.l.nSigBytes,o=this.O,u=e/(4*this.O),f=(u=n?Math.ceil(u):Math.max((0|u)-this.S,0))*o,c=Math.min(4*f,e);if(f){for(var a=0;a<f;a+=o)this.h(r,a);t=r.splice(0,f),this.l.nSigBytes-=c}return new i.e(t,c)},n.prototype.h=function(n,t){throw new Error("Not implemented")},n}()},1868:function(n,t,r){r.d(t,{P:function(){return u}});var i,e=r(7211),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.O=16,r.i=t,t&&"number"==typeof t.blockSize&&(r.O=t.blockSize),r.reset(t?t.data:void 0,t?t.nBytes:void 0),r}return o(t,n),Object.defineProperty(t.prototype,"blockSize",{get:function(){return this.O},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.u()},t.prototype.update=function(n){return this.U(n),this.A(),this},t.prototype.finalize=function(n){return n&&this.U(n),this.v()},t.prototype.u=function(){throw new Error("Not implemented")},t.prototype.v=function(){throw new Error("Not implemented")},t}(e.C)},1756:function(n,t,r){r.d(t,{w:function(){return u}});var i,e="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(i=parseInt((/msie (\d+)/.exec(e)||[])[1],10),isNaN(i)?(i=parseInt((/trident\/.*; rv:(\d+)/.exec(e)||[])[1],10),!isNaN(i)&&i):i);function u(n,t){return!1!==o&&(!t||("<"===n?o<t:"<="===n?o<=t:">"===n?o>t:">="===n?o>=t:o===t))}},5720:function(n,t,r){r.d(t,{p:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var r=[],e=0;e<t;e+=2)r[e>>>3]|=parseInt(n.substr(e,2),16)<<24-e%8*4;return new i.e(r,t/2)}}},8702:function(n,t,r){r.d(t,{m:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push(String.fromCharCode(o))}return i.join("")},parse:function(n){for(var t=n.length,r=[],e=0;e<t;e++)r[e>>>2]|=(255&n.charCodeAt(e))<<24-e%4*8;return new i.e(r,t)}}},4768:function(n,t,r){r.d(t,{d:function(){return e}});var i=r(8702),e={stringify:function(n){try{return decodeURIComponent(escape(i.m.stringify(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return i.m.parse(unescape(encodeURIComponent(n)))}}},9054:function(n,t,r){r.d(t,{M:function(){return e}});var i=r(1756);var e=function(){if("undefined"!=typeof window){var n=window.crypto||window.msCrypto;if(!n){if((0,i.w)("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return n.getRandomValues(new Uint32Array(1))[0]}}return void 0!==r.g&&r.g.crypto?function(){return r.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}()}},t={};function r(i){var e=t[i];if(void 0!==e)return e.exports;var o=t[i]={exports:{}};return n[i](o,o.exports,r),o.exports}r.d=function(n,t){for(var i in t)r.o(t,i)&&!r.o(n,i)&&Object.defineProperty(n,i,{enumerable:!0,get:t[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"N",{value:!0})};var i={};return function(){r.r(i),r.d(i,{SHA224:function(){return u}});var n,t=r(3354),e=r(5561),o=(n=function(t,r){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(t,r)},function(t,r){function i(){this.constructor=t}n(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}),u=function(n){function r(r){var i=n.call(this,r)||this;return i.t=new t.e([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),i.i=r,r&&void 0!==r.hash&&(i.t=r.hash.clone()),i}return o(r,n),r.prototype.u=function(){this.t=new t.e([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},r.prototype.v=function(){var t=n.prototype.v.call(this);return t.nSigBytes-=4,t},r.prototype.clone=function(){return new r({hash:this.t,blockSize:this.O,data:this.l,nBytes:this.j})},r.hash=function(n,t){return new r(t).finalize(n)},r}(e.SHA256)}(),i}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/SHA256.d.ts
0 → 100644
| 1 | +import { Hasher, HasherProps } from "./lib/algorithm/Hasher"; | |
| 2 | +import { Word32Array } from "./lib/Word32Array"; | |
| 3 | +export interface SHA256Props extends HasherProps { | |
| 4 | + hash: Word32Array; | |
| 5 | +} | |
| 6 | +export declare class SHA256 extends Hasher { | |
| 7 | + protected _props?: Partial<SHA256Props>; | |
| 8 | + protected _hash: Word32Array; | |
| 9 | + constructor(props?: SHA256Props); | |
| 10 | + protected _doReset(): void; | |
| 11 | + protected _doProcessBlock(words: number[], offset: number): void; | |
| 12 | + protected _doFinalize(): Word32Array; | |
| 13 | + clone(): SHA256; | |
| 14 | + static hash(message: Word32Array | string, props?: SHA256Props): Word32Array; | |
| 15 | +} | ... | ... |
app/static/content/jscrypto/SHA256.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var r=t();for(var i in n.JsCrypto=n.JsCrypto||{},r)n.JsCrypto[i]=r[i]}}(this,(function(){return function(){"use strict";var n={3354:function(n,t,r){r.d(t,{e:function(){return o}});var i=r(5720),e=r(9054),o=function(){function n(t,r){if(Array.isArray(t)||!t)return this.t=Array.isArray(t)?t:[],void(this.i="number"==typeof r?r:4*this.t.length);if(t instanceof n)return this.t=t.words.slice(),void(this.i=t.nSigBytes);var i;try{t instanceof ArrayBuffer?i=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!i)throw new Error("Invalid argument");for(var e=i.byteLength,o=[],u=0;u<e;u++)o[u>>>2]|=i[u]<<24-u%4*8;this.t=o,this.i=e}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.i},set:function(n){this.i=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.t},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):i.p.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this.t,t=this.i,r=new Uint8Array(t),i=0;i<t;i++)r[i]=n[i>>>2]>>>24-i%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.i%4)for(var i=0;i<r;i++){var e=t[i>>>2]>>>24-i%4*8&255;this.t[this.i+i>>>2]|=e<<24-(this.i+i)%4*8}else for(i=0;i<r;i+=4)this.t[this.i+i>>>2]=t[i>>>2];return this.i+=r,this},n.prototype.clamp=function(){var n=this.i;this.t[n>>>2]&=4294967295<<32-n%4*8,this.t.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.t.slice(),this.i)},n.random=function(t){for(var r=[],i=0;i<t;i+=4)r.push((0,e.M)());return new n(r,t)},n}()},7211:function(n,t,r){r.d(t,{C:function(){return o}});var i=r(3354),e=r(4768),o=function(){function n(n){this.u=0,this.h=0,this.v=n,this.l=n&&void 0!==n.data?n.data.clone():new i.e,this.A=n&&"number"==typeof n.nBytes?n.nBytes:0}return Object.defineProperty(n.prototype,"blockSize",{get:function(){return this.h},enumerable:!1,configurable:!0}),n.prototype.reset=function(n,t){this.l=void 0!==n?n.clone():new i.e,this.A="number"==typeof t?t:0},n.prototype.j=function(n){var t="string"==typeof n?e.d.parse(n):n;this.l.concat(t),this.A+=t.nSigBytes},n.prototype.O=function(n){var t,r=this.l.words,e=this.l.nSigBytes,o=this.h,u=e/(4*this.h),f=(u=n?Math.ceil(u):Math.max((0|u)-this.u,0))*o,c=Math.min(4*f,e);if(f){for(var a=0;a<f;a+=o)this.I(r,a);t=r.splice(0,f),this.l.nSigBytes-=c}return new i.e(t,c)},n.prototype.I=function(n,t){throw new Error("Not implemented")},n}()},1868:function(n,t,r){r.d(t,{P:function(){return u}});var i,e=r(7211),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.h=16,r.v=t,t&&"number"==typeof t.blockSize&&(r.h=t.blockSize),r.reset(t?t.data:void 0,t?t.nBytes:void 0),r}return o(t,n),Object.defineProperty(t.prototype,"blockSize",{get:function(){return this.h},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.U()},t.prototype.update=function(n){return this.j(n),this.O(),this},t.prototype.finalize=function(n){return n&&this.j(n),this._()},t.prototype.U=function(){throw new Error("Not implemented")},t.prototype._=function(){throw new Error("Not implemented")},t}(e.C)},1756:function(n,t,r){r.d(t,{w:function(){return u}});var i,e="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(i=parseInt((/msie (\d+)/.exec(e)||[])[1],10),isNaN(i)?(i=parseInt((/trident\/.*; rv:(\d+)/.exec(e)||[])[1],10),!isNaN(i)&&i):i);function u(n,t){return!1!==o&&(!t||("<"===n?o<t:"<="===n?o<=t:">"===n?o>t:">="===n?o>=t:o===t))}},5720:function(n,t,r){r.d(t,{p:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var r=[],e=0;e<t;e+=2)r[e>>>3]|=parseInt(n.substr(e,2),16)<<24-e%8*4;return new i.e(r,t/2)}}},8702:function(n,t,r){r.d(t,{m:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push(String.fromCharCode(o))}return i.join("")},parse:function(n){for(var t=n.length,r=[],e=0;e<t;e++)r[e>>>2]|=(255&n.charCodeAt(e))<<24-e%4*8;return new i.e(r,t)}}},4768:function(n,t,r){r.d(t,{d:function(){return e}});var i=r(8702),e={stringify:function(n){try{return decodeURIComponent(escape(i.m.stringify(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return i.m.parse(unescape(encodeURIComponent(n)))}}},9054:function(n,t,r){r.d(t,{M:function(){return e}});var i=r(1756);var e=function(){if("undefined"!=typeof window){var n=window.crypto||window.msCrypto;if(!n){if((0,i.w)("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return n.getRandomValues(new Uint32Array(1))[0]}}return void 0!==r.g&&r.g.crypto?function(){return r.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}()}},t={};function r(i){var e=t[i];if(void 0!==e)return e.exports;var o=t[i]={exports:{}};return n[i](o,o.exports,r),o.exports}r.d=function(n,t){for(var i in t)r.o(t,i)&&!r.o(n,i)&&Object.defineProperty(n,i,{enumerable:!0,get:t[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"S",{value:!0})};var i={};return function(){r.r(i),r.d(i,{SHA256:function(){return h}});var n,t=r(1868),e=r(3354),o=(n=function(t,r){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(t,r)},function(t,r){function i(){this.constructor=t}n(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}),u=[],f=[];function c(n){for(var t=Math.sqrt(n),r=2;r<=t;r++)if(!(n%r))return!1;return!0}function a(n){return 4294967296*(n-(0|n))|0}!function(){for(var n=2,t=0;t<64;)c(n)&&(t<8&&(u[t]=a(Math.pow(n,.5))),f[t]=a(Math.pow(n,1/3)),t++),n++}();var s=[],h=function(n){function t(t){var r=n.call(this,t)||this;return r.N=new e.e(u.slice(0)),r.v=t,t&&void 0!==t.hash&&(r.N=t.hash.clone()),r}return o(t,n),t.prototype.U=function(){this.N=new e.e(u.slice(0))},t.prototype.I=function(n,t){for(var r=this.N.words,i=r[0],e=r[1],o=r[2],u=r[3],c=r[4],a=r[5],h=r[6],v=r[7],d=0;d<64;d++){if(d<16)s[d]=0|n[t+d];else{var w=s[d-15],l=(w<<25|w>>>7)^(w<<14|w>>>18)^w>>>3,y=s[d-2],b=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;s[d]=l+s[d-7]+b+s[d-16]}var p=i&e^i&o^e&o,m=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),g=v+((c<<26|c>>>6)^(c<<21|c>>>11)^(c<<7|c>>>25))+(c&a^~c&h)+f[d]+s[d];v=h,h=a,a=c,c=u+g|0,u=o,o=e,e=i,i=g+(m+p)|0}r[0]=r[0]+i|0,r[1]=r[1]+e|0,r[2]=r[2]+o|0,r[3]=r[3]+u|0,r[4]=r[4]+c|0,r[5]=r[5]+a|0,r[6]=r[6]+h|0,r[7]=r[7]+v|0},t.prototype._=function(){var n=this.l.words,t=8*this.A,r=8*this.l.nSigBytes;return n[r>>>5]|=128<<24-r%32,n[14+(r+64>>>9<<4)]=Math.floor(t/4294967296),n[15+(r+64>>>9<<4)]=t,this.l.nSigBytes=4*n.length,this.O(),this.N},t.prototype.clone=function(){return new t({hash:this.N,blockSize:this.h,data:this.l,nBytes:this.A})},t.hash=function(n,r){return new t(r).finalize(n)},t}(t.P)}(),i}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/SHA3.d.ts
0 → 100644
| 1 | +import { Word64 } from "./lib/Word64Array"; | |
| 2 | +import { Hasher, HasherProps } from "./lib/algorithm/Hasher"; | |
| 3 | +import { Word32Array } from "./lib/Word32Array"; | |
| 4 | +export interface SHA3Props extends HasherProps { | |
| 5 | + state: Word64[]; | |
| 6 | + outputLength: number; | |
| 7 | +} | |
| 8 | +export declare class SHA3 extends Hasher { | |
| 9 | + protected _props?: Partial<SHA3Props>; | |
| 10 | + protected _blockSize: number; | |
| 11 | + protected _state: Word64[]; | |
| 12 | + protected _outputLength: number; | |
| 13 | + constructor(props?: Partial<SHA3Props>); | |
| 14 | + protected _doReset(): void; | |
| 15 | + protected _doProcessBlock(words: number[], offset: number): void; | |
| 16 | + protected _doFinalize(): Word32Array; | |
| 17 | + clone(): SHA3; | |
| 18 | + static hash(message: Word32Array | string, props?: SHA3Props): Word32Array; | |
| 19 | +} | ... | ... |
app/static/content/jscrypto/SHA3.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var r=t();for(var i in n.JsCrypto=n.JsCrypto||{},r)n.JsCrypto[i]=r[i]}}(this,(function(){return function(){"use strict";var n={3354:function(n,t,r){r.d(t,{e:function(){return o}});var i=r(5720),e=r(9054),o=function(){function n(t,r){if(Array.isArray(t)||!t)return this.t=Array.isArray(t)?t:[],void(this.i="number"==typeof r?r:4*this.t.length);if(t instanceof n)return this.t=t.words.slice(),void(this.i=t.nSigBytes);var i;try{t instanceof ArrayBuffer?i=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!i)throw new Error("Invalid argument");for(var e=i.byteLength,o=[],u=0;u<e;u++)o[u>>>2]|=i[u]<<24-u%4*8;this.t=o,this.i=e}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.i},set:function(n){this.i=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.t},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):i.p.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this.t,t=this.i,r=new Uint8Array(t),i=0;i<t;i++)r[i]=n[i>>>2]>>>24-i%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.i%4)for(var i=0;i<r;i++){var e=t[i>>>2]>>>24-i%4*8&255;this.t[this.i+i>>>2]|=e<<24-(this.i+i)%4*8}else for(i=0;i<r;i+=4)this.t[this.i+i>>>2]=t[i>>>2];return this.i+=r,this},n.prototype.clamp=function(){var n=this.i;this.t[n>>>2]&=4294967295<<32-n%4*8,this.t.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.t.slice(),this.i)},n.random=function(t){for(var r=[],i=0;i<t;i+=4)r.push((0,e.M)());return new n(r,t)},n}()},6957:function(n,t,r){r.d(t,{r:function(){return o}});var i=r(5720),e=r(3354),o=function(){function n(n,t){this.high=n,this.low=t}return n.prototype.clone=function(){return new n(this.high,this.low)},n}();!function(){function n(n,t){this.t=n||[],this.i="number"==typeof t?t:8*this.t.length}Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.i},set:function(n){this.i=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.t},enumerable:!1,configurable:!0}),n.prototype.to32=function(){for(var n=[],t=0;t<this.t.length;t++){var r=this.t[t];n.push(r.high),n.push(r.low)}return new e.e(n,this.i)},n.prototype.toString=function(n){return n?n.stringify(this.to32()):i.p.stringify(this.to32())},n.prototype.clone=function(){for(var t=this.t.slice(),r=0;r<t.length;r++)t[r]=t[r].clone();return new n(t,this.i)}}()},7211:function(n,t,r){r.d(t,{C:function(){return o}});var i=r(3354),e=r(4768),o=function(){function n(n){this.u=0,this.h=0,this.v=n,this.l=n&&void 0!==n.data?n.data.clone():new i.e,this.j=n&&"number"==typeof n.nBytes?n.nBytes:0}return Object.defineProperty(n.prototype,"blockSize",{get:function(){return this.h},enumerable:!1,configurable:!0}),n.prototype.reset=function(n,t){this.l=void 0!==n?n.clone():new i.e,this.j="number"==typeof t?t:0},n.prototype.A=function(n){var t="string"==typeof n?e.d.parse(n):n;this.l.concat(t),this.j+=t.nSigBytes},n.prototype.O=function(n){var t,r=this.l.words,e=this.l.nSigBytes,o=this.h,u=e/(4*this.h),f=(u=n?Math.ceil(u):Math.max((0|u)-this.u,0))*o,a=Math.min(4*f,e);if(f){for(var c=0;c<f;c+=o)this.I(r,c);t=r.splice(0,f),this.l.nSigBytes-=a}return new i.e(t,a)},n.prototype.I=function(n,t){throw new Error("Not implemented")},n}()},1868:function(n,t,r){r.d(t,{P:function(){return u}});var i,e=r(7211),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.h=16,r.v=t,t&&"number"==typeof t.blockSize&&(r.h=t.blockSize),r.reset(t?t.data:void 0,t?t.nBytes:void 0),r}return o(t,n),Object.defineProperty(t.prototype,"blockSize",{get:function(){return this.h},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.U()},t.prototype.update=function(n){return this.A(n),this.O(),this},t.prototype.finalize=function(n){return n&&this.A(n),this.S()},t.prototype.U=function(){throw new Error("Not implemented")},t.prototype.S=function(){throw new Error("Not implemented")},t}(e.C)},1756:function(n,t,r){r.d(t,{w:function(){return u}});var i,e="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(i=parseInt((/msie (\d+)/.exec(e)||[])[1],10),isNaN(i)?(i=parseInt((/trident\/.*; rv:(\d+)/.exec(e)||[])[1],10),!isNaN(i)&&i):i);function u(n,t){return!1!==o&&(!t||("<"===n?o<t:"<="===n?o<=t:">"===n?o>t:">="===n?o>=t:o===t))}},5720:function(n,t,r){r.d(t,{p:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var r=[],e=0;e<t;e+=2)r[e>>>3]|=parseInt(n.substr(e,2),16)<<24-e%8*4;return new i.e(r,t/2)}}},8702:function(n,t,r){r.d(t,{m:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push(String.fromCharCode(o))}return i.join("")},parse:function(n){for(var t=n.length,r=[],e=0;e<t;e++)r[e>>>2]|=(255&n.charCodeAt(e))<<24-e%4*8;return new i.e(r,t)}}},4768:function(n,t,r){r.d(t,{d:function(){return e}});var i=r(8702),e={stringify:function(n){try{return decodeURIComponent(escape(i.m.stringify(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return i.m.parse(unescape(encodeURIComponent(n)))}}},9054:function(n,t,r){r.d(t,{M:function(){return e}});var i=r(1756);var e=function(){if("undefined"!=typeof window){var n=window.crypto||window.msCrypto;if(!n){if((0,i.w)("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return n.getRandomValues(new Uint32Array(1))[0]}}return void 0!==r.g&&r.g.crypto?function(){return r.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}()}},t={};function r(i){var e=t[i];if(void 0!==e)return e.exports;var o=t[i]={exports:{}};return n[i](o,o.exports,r),o.exports}r.d=function(n,t){for(var i in t)r.o(t,i)&&!r.o(n,i)&&Object.defineProperty(n,i,{enumerable:!0,get:t[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"_",{value:!0})};var i={};return function(){r.r(i),r.d(i,{SHA3:function(){return h}});var n,t=r(6957),e=r(1868),o=r(3354),u=(n=function(t,r){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(t,r)},function(t,r){function i(){this.constructor=t}n(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}),f=[],a=[],c=[];!function(){for(var n=1,r=0,i=0;i<24;i++){f[n+5*r]=(i+1)*(i+2)/2%64;var e=(2*n+3*r)%5;n=r%5,r=e}for(var o=0;o<5;o++)for(var u=0;u<5;u++)a[o+5*u]=u+(2*o+3*u)%5*5;for(var s=1,h=0;h<24;h++){for(var v=0,w=0,d=0;d<7;d++){if(1&s){var l=(1<<d)-1;l<32?w^=1<<l:v^=1<<l-32}128&s?s=s<<1^113:s<<=1}c[h]=new t.r(v,w)}}();var s=[];!function(){for(var n=0;n<25;n++)s[n]=new t.r(0,0)}();var h=function(n){function r(r){var i=n.call(this,r)||this;if(i.h=32,i.N=[],i.F=512,i.v=r,r){if(void 0!==r.outputLength){if(![224,256,384,512].includes(r.outputLength))throw new Error("Unsupported output length.");i.F=r.outputLength}void 0!==r.state&&(i.N=r.state.map((function(n){return n.clone()})))}if(0===i.N.length)for(var e=0;e<25;e++)i.N[e]=new t.r(0,0);return i.h=(1600-2*i.F)/32,i}return u(r,n),r.prototype.U=function(){this.N=[];for(var n=0;n<25;n++)this.N[n]=new t.r(0,0);this.h=(1600-2*this.F)/32},r.prototype.I=function(n,t){for(var r=this.N,i=this.h/2,e=0;e<i;e++){var o=n[t+2*e],u=n[t+2*e+1];o=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),u=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8),r[e].high^=u,r[e].low^=o}for(var h=0;h<24;h++){for(var v=0;v<5;v++){for(var w=0,d=0,l=0;l<5;l++){w^=(S=r[v+5*l]).high,d^=S.low}var b=s[v];b.high=w,b.low=d}for(v=0;v<5;v++){var y=s[(v+4)%5],p=s[(v+1)%5],m=p.high,g=p.low;for(w=y.high^(m<<1|g>>>31),d=y.low^(g<<1|m>>>31),l=0;l<5;l++){(S=r[v+5*l]).high^=w,S.low^=d}}for(var j=1;j<25;j++){w=void 0,d=void 0;var A=r[j].high,O=r[j].low,I=f[j];I<32?(w=A<<I|O>>>32-I,d=O<<I|A>>>32-I):(w=O<<I-32|A>>>64-I,d=A<<I-32|O>>>64-I);var E=s[a[j]];E.high=w,E.low=d}var U=s[0],M=r[0];U.high=M.high,U.low=M.low;for(v=0;v<5;v++)for(l=0;l<5;l++){var S=r[j=v+5*l],_=s[j],N=s[(v+1)%5+5*l],x=s[(v+2)%5+5*l];S.high=_.high^~N.high&x.high,S.low=_.low^~N.low&x.low}var C=r[0],F=c[h];C.high^=F.high,C.low^=F.low}},r.prototype.S=function(){var n=this.l,t=n.words,r=8*n.nSigBytes,i=32*this.blockSize;t[r>>>5]|=1<<24-r%32,t[(Math.ceil((r+1)/i)*i>>>5)-1]|=128,n.nSigBytes=4*t.length,this.O();for(var e=this.N,u=this.F/8,f=u/8,a=[],c=0;c<f;c++){var s=e[c],h=s.high,v=s.low;h=16711935&(h<<8|h>>>24)|4278255360&(h<<24|h>>>8),v=16711935&(v<<8|v>>>24)|4278255360&(v<<24|v>>>8),a.push(v),a.push(h)}return new o.e(a,u)},r.prototype.clone=function(){return new r({outputLength:this.F,state:this.N,blockSize:this.h,data:this.l,nBytes:this.j})},r.hash=function(n,t){return new r(t).finalize(n)},r}(e.P)}(),i}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/SHA384.d.ts
0 → 100644
| 1 | +import { Word64Array } from "./lib/Word64Array"; | |
| 2 | +import { SHA512 } from "./SHA512"; | |
| 3 | +import type { HasherProps } from "./lib/algorithm/Hasher"; | |
| 4 | +import type { Word32Array } from "./lib/Word32Array"; | |
| 5 | +export interface SHA384Props extends HasherProps { | |
| 6 | + hash: Word64Array; | |
| 7 | +} | |
| 8 | +export declare class SHA384 extends SHA512 { | |
| 9 | + protected _props?: Partial<SHA384Props>; | |
| 10 | + protected _hash: Word64Array; | |
| 11 | + constructor(props?: Partial<SHA384Props>); | |
| 12 | + protected _doReset(): void; | |
| 13 | + protected _doFinalize(): Word32Array; | |
| 14 | + clone(): SHA384; | |
| 15 | + static hash(message: Word32Array | string, props?: SHA384Props): Word32Array; | |
| 16 | +} | ... | ... |
app/static/content/jscrypto/SHA384.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var e=t();for(var r in n.JsCrypto=n.JsCrypto||{},e)n.JsCrypto[r]=e[r]}}(this,(function(){return function(){"use strict";var n={7491:function(n,t,e){e.d(t,{SHA512:function(){return w}});var r,i=e(1868),o=e(6957),u=(r=function(n,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e])})(n,t)},function(n,t){function e(){this.constructor=n}r(n,t),n.prototype=null===t?Object.create(t):(e.prototype=t.prototype,new e)}),f=[new o.r(1116352408,3609767458),new o.r(1899447441,602891725),new o.r(3049323471,3964484399),new o.r(3921009573,2173295548),new o.r(961987163,4081628472),new o.r(1508970993,3053834265),new o.r(2453635748,2937671579),new o.r(2870763221,3664609560),new o.r(3624381080,2734883394),new o.r(310598401,1164996542),new o.r(607225278,1323610764),new o.r(1426881987,3590304994),new o.r(1925078388,4068182383),new o.r(2162078206,991336113),new o.r(2614888103,633803317),new o.r(3248222580,3479774868),new o.r(3835390401,2666613458),new o.r(4022224774,944711139),new o.r(264347078,2341262773),new o.r(604807628,2007800933),new o.r(770255983,1495990901),new o.r(1249150122,1856431235),new o.r(1555081692,3175218132),new o.r(1996064986,2198950837),new o.r(2554220882,3999719339),new o.r(2821834349,766784016),new o.r(2952996808,2566594879),new o.r(3210313671,3203337956),new o.r(3336571891,1034457026),new o.r(3584528711,2466948901),new o.r(113926993,3758326383),new o.r(338241895,168717936),new o.r(666307205,1188179964),new o.r(773529912,1546045734),new o.r(1294757372,1522805485),new o.r(1396182291,2643833823),new o.r(1695183700,2343527390),new o.r(1986661051,1014477480),new o.r(2177026350,1206759142),new o.r(2456956037,344077627),new o.r(2730485921,1290863460),new o.r(2820302411,3158454273),new o.r(3259730800,3505952657),new o.r(3345764771,106217008),new o.r(3516065817,3606008344),new o.r(3600352804,1432725776),new o.r(4094571909,1467031594),new o.r(275423344,851169720),new o.r(430227734,3100823752),new o.r(506948616,1363258195),new o.r(659060556,3750685593),new o.r(883997877,3785050280),new o.r(958139571,3318307427),new o.r(1322822218,3812723403),new o.r(1537002063,2003034995),new o.r(1747873779,3602036899),new o.r(1955562222,1575990012),new o.r(2024104815,1125592928),new o.r(2227730452,2716904306),new o.r(2361852424,442776044),new o.r(2428436474,593698344),new o.r(2756734187,3733110249),new o.r(3204031479,2999351573),new o.r(3329325298,3815920427),new o.r(3391569614,3928383900),new o.r(3515267271,566280711),new o.r(3940187606,3454069534),new o.r(4118630271,4000239992),new o.r(116418474,1914138554),new o.r(174292421,2731055270),new o.r(289380356,3203993006),new o.r(460393269,320620315),new o.r(685471733,587496836),new o.r(852142971,1086792851),new o.r(1017036298,365543100),new o.r(1126000580,2618297676),new o.r(1288033470,3409855158),new o.r(1501505948,4234509866),new o.r(1607167915,987167468),new o.r(1816402316,1246189591)],c=[];!function(){for(var n=0;n<80;n++)c[n]=new o.r(0,0)}();var w=function(n){function t(t){var e=n.call(this,t)||this;return e.t=32,e.i=new o.m([new o.r(1779033703,4089235720),new o.r(3144134277,2227873595),new o.r(1013904242,4271175723),new o.r(2773480762,1595750129),new o.r(1359893119,2917565137),new o.r(2600822924,725511199),new o.r(528734635,4215389547),new o.r(1541459225,327033209)]),e.u=t,t&&void 0!==t.hash&&(e.i=t.hash.clone()),e}return u(t,n),t.prototype.h=function(){this.i=new o.m([new o.r(1779033703,4089235720),new o.r(3144134277,2227873595),new o.r(1013904242,4271175723),new o.r(2773480762,1595750129),new o.r(1359893119,2917565137),new o.r(2600822924,725511199),new o.r(528734635,4215389547),new o.r(1541459225,327033209)])},t.prototype.v=function(n,t){for(var e=this.i.words,r=e[0],i=e[1],o=e[2],u=e[3],w=e[4],s=e[5],a=e[6],h=e[7],v=r.high,d=r.low,l=i.high,b=i.low,y=o.high,p=o.low,m=u.high,g=u.low,j=w.high,A=w.low,O=s.high,_=s.low,I=a.high,S=a.low,E=h.high,M=h.low,U=v,N=d,x=l,B=b,C=y,F=p,k=m,z=g,H=j,T=A,P=O,R=_,q=I,$=S,D=E,G=M,J=0;J<80;J++){var K=void 0,L=void 0,Q=c[J];if(J<16)L=Q.high=0|n[t+2*J],K=Q.low=0|n[t+2*J+1];else{var V=c[J-15],W=V.high,X=V.low,Y=(W>>>1|X<<31)^(W>>>8|X<<24)^W>>>7,Z=(X>>>1|W<<31)^(X>>>8|W<<24)^(X>>>7|W<<25),nn=c[J-2],tn=nn.high,en=nn.low,rn=(tn>>>19|en<<13)^(tn<<3|en>>>29)^tn>>>6,on=(en>>>19|tn<<13)^(en<<3|tn>>>29)^(en>>>6|tn<<26),un=c[J-7],fn=un.high,cn=un.low,wn=c[J-16],sn=wn.high,an=wn.low;L=(L=(L=Y+fn+((K=Z+cn)>>>0<Z>>>0?1:0))+rn+((K+=on)>>>0<on>>>0?1:0))+sn+((K+=an)>>>0<an>>>0?1:0),Q.high=L,Q.low=K}var hn=H&P^~H&q,vn=T&R^~T&$,dn=U&x^U&C^x&C,ln=N&B^N&F^B&F,bn=(U>>>28|N<<4)^(U<<30|N>>>2)^(U<<25|N>>>7),yn=(N>>>28|U<<4)^(N<<30|U>>>2)^(N<<25|U>>>7),pn=(H>>>14|T<<18)^(H>>>18|T<<14)^(H<<23|T>>>9),mn=(T>>>14|H<<18)^(T>>>18|H<<14)^(T<<23|H>>>9),gn=f[J],jn=gn.high,An=gn.low,On=G+mn,_n=D+pn+(On>>>0<G>>>0?1:0),In=yn+ln;D=q,G=$,q=P,$=R,P=H,R=T,H=k+(_n=(_n=(_n=_n+hn+((On+=vn)>>>0<vn>>>0?1:0))+jn+((On+=An)>>>0<An>>>0?1:0))+L+((On+=K)>>>0<K>>>0?1:0))+((T=z+On|0)>>>0<z>>>0?1:0)|0,k=C,z=F,C=x,F=B,x=U,B=N,U=_n+(bn+dn+(In>>>0<yn>>>0?1:0))+((N=On+In|0)>>>0<On>>>0?1:0)|0}d=r.low=d+N,r.high=v+U+(d>>>0<N>>>0?1:0),b=i.low=b+B,i.high=l+x+(b>>>0<B>>>0?1:0),p=o.low=p+F,o.high=y+C+(p>>>0<F>>>0?1:0),g=u.low=g+z,u.high=m+k+(g>>>0<z>>>0?1:0),A=w.low=A+T,w.high=j+H+(A>>>0<T>>>0?1:0),_=s.low=_+R,s.high=O+P+(_>>>0<R>>>0?1:0),S=a.low=S+$,a.high=I+q+(S>>>0<$>>>0?1:0),M=h.low=M+G,h.high=E+D+(M>>>0<G>>>0?1:0)},t.prototype.l=function(){var n=this.j,t=n.words,e=8*this.A,r=8*n.nSigBytes;return t[r>>>5]|=128<<24-r%32,t[30+(r+128>>>10<<5)]=Math.floor(e/4294967296),t[31+(r+128>>>10<<5)]=e,n.nSigBytes=4*t.length,this.O(),this.i.to32()},t.prototype.clone=function(){return new t({hash:this.i,blockSize:this.t,data:this.j,nBytes:this.A})},t.hash=function(n,e){return new t(e).finalize(n)},t}(i.P)},3354:function(n,t,e){e.d(t,{e:function(){return o}});var r=e(5720),i=e(9054),o=function(){function n(t,e){if(Array.isArray(t)||!t)return this._=Array.isArray(t)?t:[],void(this.I="number"==typeof e?e:4*this._.length);if(t instanceof n)return this._=t.words.slice(),void(this.I=t.nSigBytes);var r;try{t instanceof ArrayBuffer?r=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!r)throw new Error("Invalid argument");for(var i=r.byteLength,o=[],u=0;u<i;u++)o[u>>>2]|=r[u]<<24-u%4*8;this._=o,this.I=i}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.I},set:function(n){this.I=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this._},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):r.p.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this._,t=this.I,e=new Uint8Array(t),r=0;r<t;r++)e[r]=n[r>>>2]>>>24-r%4*8&255;return e},n.prototype.concat=function(n){var t=n.words.slice(),e=n.nSigBytes;if(this.clamp(),this.I%4)for(var r=0;r<e;r++){var i=t[r>>>2]>>>24-r%4*8&255;this._[this.I+r>>>2]|=i<<24-(this.I+r)%4*8}else for(r=0;r<e;r+=4)this._[this.I+r>>>2]=t[r>>>2];return this.I+=e,this},n.prototype.clamp=function(){var n=this.I;this._[n>>>2]&=4294967295<<32-n%4*8,this._.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this._.slice(),this.I)},n.random=function(t){for(var e=[],r=0;r<t;r+=4)e.push((0,i.M)());return new n(e,t)},n}()},6957:function(n,t,e){e.d(t,{r:function(){return o},m:function(){return u}});var r=e(5720),i=e(3354),o=function(){function n(n,t){this.high=n,this.low=t}return n.prototype.clone=function(){return new n(this.high,this.low)},n}(),u=function(){function n(n,t){this._=n||[],this.I="number"==typeof t?t:8*this._.length}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.I},set:function(n){this.I=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this._},enumerable:!1,configurable:!0}),n.prototype.to32=function(){for(var n=[],t=0;t<this._.length;t++){var e=this._[t];n.push(e.high),n.push(e.low)}return new i.e(n,this.I)},n.prototype.toString=function(n){return n?n.stringify(this.to32()):r.p.stringify(this.to32())},n.prototype.clone=function(){for(var t=this._.slice(),e=0;e<t.length;e++)t[e]=t[e].clone();return new n(t,this.I)},n}()},7211:function(n,t,e){e.d(t,{C:function(){return o}});var r=e(3354),i=e(4768),o=function(){function n(n){this.S=0,this.t=0,this.u=n,this.j=n&&void 0!==n.data?n.data.clone():new r.e,this.A=n&&"number"==typeof n.nBytes?n.nBytes:0}return Object.defineProperty(n.prototype,"blockSize",{get:function(){return this.t},enumerable:!1,configurable:!0}),n.prototype.reset=function(n,t){this.j=void 0!==n?n.clone():new r.e,this.A="number"==typeof t?t:0},n.prototype.U=function(n){var t="string"==typeof n?i.d.parse(n):n;this.j.concat(t),this.A+=t.nSigBytes},n.prototype.O=function(n){var t,e=this.j.words,i=this.j.nSigBytes,o=this.t,u=i/(4*this.t),f=(u=n?Math.ceil(u):Math.max((0|u)-this.S,0))*o,c=Math.min(4*f,i);if(f){for(var w=0;w<f;w+=o)this.v(e,w);t=e.splice(0,f),this.j.nSigBytes-=c}return new r.e(t,c)},n.prototype.v=function(n,t){throw new Error("Not implemented")},n}()},1868:function(n,t,e){e.d(t,{P:function(){return u}});var r,i=e(7211),o=(r=function(n,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e])})(n,t)},function(n,t){function e(){this.constructor=n}r(n,t),n.prototype=null===t?Object.create(t):(e.prototype=t.prototype,new e)}),u=function(n){function t(t){var e=n.call(this,t)||this;return e.t=16,e.u=t,t&&"number"==typeof t.blockSize&&(e.t=t.blockSize),e.reset(t?t.data:void 0,t?t.nBytes:void 0),e}return o(t,n),Object.defineProperty(t.prototype,"blockSize",{get:function(){return this.t},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,e){n.prototype.reset.call(this,t,e),this.h()},t.prototype.update=function(n){return this.U(n),this.O(),this},t.prototype.finalize=function(n){return n&&this.U(n),this.l()},t.prototype.h=function(){throw new Error("Not implemented")},t.prototype.l=function(){throw new Error("Not implemented")},t}(i.C)},1756:function(n,t,e){e.d(t,{w:function(){return u}});var r,i="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(r=parseInt((/msie (\d+)/.exec(i)||[])[1],10),isNaN(r)?(r=parseInt((/trident\/.*; rv:(\d+)/.exec(i)||[])[1],10),!isNaN(r)&&r):r);function u(n,t){return!1!==o&&(!t||("<"===n?o<t:"<="===n?o<=t:">"===n?o>t:">="===n?o>=t:o===t))}},5720:function(n,t,e){e.d(t,{p:function(){return i}});var r=e(3354),i={stringify:function(n){for(var t=n.nSigBytes,e=n.words,r=[],i=0;i<t;i++){var o=e[i>>>2]>>>24-i%4*8&255;r.push((o>>>4).toString(16)),r.push((15&o).toString(16))}return r.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var e=[],i=0;i<t;i+=2)e[i>>>3]|=parseInt(n.substr(i,2),16)<<24-i%8*4;return new r.e(e,t/2)}}},8702:function(n,t,e){e.d(t,{m:function(){return i}});var r=e(3354),i={stringify:function(n){for(var t=n.nSigBytes,e=n.words,r=[],i=0;i<t;i++){var o=e[i>>>2]>>>24-i%4*8&255;r.push(String.fromCharCode(o))}return r.join("")},parse:function(n){for(var t=n.length,e=[],i=0;i<t;i++)e[i>>>2]|=(255&n.charCodeAt(i))<<24-i%4*8;return new r.e(e,t)}}},4768:function(n,t,e){e.d(t,{d:function(){return i}});var r=e(8702),i={stringify:function(n){try{return decodeURIComponent(escape(r.m.stringify(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return r.m.parse(unescape(encodeURIComponent(n)))}}},9054:function(n,t,e){e.d(t,{M:function(){return i}});var r=e(1756);var i=function(){if("undefined"!=typeof window){var n=window.crypto||window.msCrypto;if(!n){if((0,r.w)("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return n.getRandomValues(new Uint32Array(1))[0]}}return void 0!==e.g&&e.g.crypto?function(){return e.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}()}},t={};function e(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return n[r](o,o.exports,e),o.exports}e.d=function(n,t){for(var r in t)e.o(t,r)&&!e.o(n,r)&&Object.defineProperty(n,r,{enumerable:!0,get:t[r]})},e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),e.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},e.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"N",{value:!0})};var r={};return function(){e.r(r),e.d(r,{SHA384:function(){return u}});var n,t=e(6957),i=e(7491),o=(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),u=function(n){function e(e){var r=n.call(this,e)||this;return r.i=new t.m([new t.r(3418070365,3238371032),new t.r(1654270250,914150663),new t.r(2438529370,812702999),new t.r(355462360,4144912697),new t.r(1731405415,4290775857),new t.r(2394180231,1750603025),new t.r(3675008525,1694076839),new t.r(1203062813,3204075428)]),r.u=e,e&&void 0!==e.hash&&(r.i=e.hash.clone()),r}return o(e,n),e.prototype.h=function(){this.i=new t.m([new t.r(3418070365,3238371032),new t.r(1654270250,914150663),new t.r(2438529370,812702999),new t.r(355462360,4144912697),new t.r(1731405415,4290775857),new t.r(2394180231,1750603025),new t.r(3675008525,1694076839),new t.r(1203062813,3204075428)])},e.prototype.l=function(){var t=n.prototype.l.call(this);return t.nSigBytes-=16,t},e.prototype.clone=function(){return new e({hash:this.i,blockSize:this.t,data:this.j,nBytes:this.A})},e.hash=function(n,t){return new e(t).finalize(n)},e}(i.SHA512)}(),r}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/SHA512.d.ts
0 → 100644
| 1 | +import { Hasher, HasherProps } from "./lib/algorithm/Hasher"; | |
| 2 | +import { Word64Array } from "./lib/Word64Array"; | |
| 3 | +import type { Word32Array } from "./lib/Word32Array"; | |
| 4 | +export interface SHA512Props extends HasherProps { | |
| 5 | + hash: Word64Array; | |
| 6 | +} | |
| 7 | +export declare class SHA512 extends Hasher { | |
| 8 | + protected _props?: Partial<SHA512Props>; | |
| 9 | + protected _blockSize: number; | |
| 10 | + protected _hash: Word64Array; | |
| 11 | + constructor(props?: Partial<SHA512Props>); | |
| 12 | + protected _doReset(): void; | |
| 13 | + protected _doProcessBlock(words: number[], offset: number): void; | |
| 14 | + protected _doFinalize(): Word32Array; | |
| 15 | + clone(): SHA512; | |
| 16 | + static hash(message: Word32Array | string, props?: SHA512Props): Word32Array; | |
| 17 | +} | ... | ... |
app/static/content/jscrypto/SHA512.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var e=t();for(var r in n.JsCrypto=n.JsCrypto||{},e)n.JsCrypto[r]=e[r]}}(this,(function(){return function(){"use strict";var n={3354:function(n,t,e){e.d(t,{e:function(){return o}});var r=e(5720),i=e(9054),o=function(){function n(t,e){if(Array.isArray(t)||!t)return this.t=Array.isArray(t)?t:[],void(this.i="number"==typeof e?e:4*this.t.length);if(t instanceof n)return this.t=t.words.slice(),void(this.i=t.nSigBytes);var r;try{t instanceof ArrayBuffer?r=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!r)throw new Error("Invalid argument");for(var i=r.byteLength,o=[],u=0;u<i;u++)o[u>>>2]|=r[u]<<24-u%4*8;this.t=o,this.i=i}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.i},set:function(n){this.i=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.t},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):r.p.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this.t,t=this.i,e=new Uint8Array(t),r=0;r<t;r++)e[r]=n[r>>>2]>>>24-r%4*8&255;return e},n.prototype.concat=function(n){var t=n.words.slice(),e=n.nSigBytes;if(this.clamp(),this.i%4)for(var r=0;r<e;r++){var i=t[r>>>2]>>>24-r%4*8&255;this.t[this.i+r>>>2]|=i<<24-(this.i+r)%4*8}else for(r=0;r<e;r+=4)this.t[this.i+r>>>2]=t[r>>>2];return this.i+=e,this},n.prototype.clamp=function(){var n=this.i;this.t[n>>>2]&=4294967295<<32-n%4*8,this.t.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.t.slice(),this.i)},n.random=function(t){for(var e=[],r=0;r<t;r+=4)e.push((0,i.M)());return new n(e,t)},n}()},6957:function(n,t,e){e.d(t,{r:function(){return o},m:function(){return u}});var r=e(5720),i=e(3354),o=function(){function n(n,t){this.high=n,this.low=t}return n.prototype.clone=function(){return new n(this.high,this.low)},n}(),u=function(){function n(n,t){this.t=n||[],this.i="number"==typeof t?t:8*this.t.length}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.i},set:function(n){this.i=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.t},enumerable:!1,configurable:!0}),n.prototype.to32=function(){for(var n=[],t=0;t<this.t.length;t++){var e=this.t[t];n.push(e.high),n.push(e.low)}return new i.e(n,this.i)},n.prototype.toString=function(n){return n?n.stringify(this.to32()):r.p.stringify(this.to32())},n.prototype.clone=function(){for(var t=this.t.slice(),e=0;e<t.length;e++)t[e]=t[e].clone();return new n(t,this.i)},n}()},7211:function(n,t,e){e.d(t,{C:function(){return o}});var r=e(3354),i=e(4768),o=function(){function n(n){this.u=0,this.h=0,this.v=n,this.l=n&&void 0!==n.data?n.data.clone():new r.e,this.j=n&&"number"==typeof n.nBytes?n.nBytes:0}return Object.defineProperty(n.prototype,"blockSize",{get:function(){return this.h},enumerable:!1,configurable:!0}),n.prototype.reset=function(n,t){this.l=void 0!==n?n.clone():new r.e,this.j="number"==typeof t?t:0},n.prototype.A=function(n){var t="string"==typeof n?i.d.parse(n):n;this.l.concat(t),this.j+=t.nSigBytes},n.prototype.O=function(n){var t,e=this.l.words,i=this.l.nSigBytes,o=this.h,u=i/(4*this.h),f=(u=n?Math.ceil(u):Math.max((0|u)-this.u,0))*o,c=Math.min(4*f,i);if(f){for(var s=0;s<f;s+=o)this.I(e,s);t=e.splice(0,f),this.l.nSigBytes-=c}return new r.e(t,c)},n.prototype.I=function(n,t){throw new Error("Not implemented")},n}()},1868:function(n,t,e){e.d(t,{P:function(){return u}});var r,i=e(7211),o=(r=function(n,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e])})(n,t)},function(n,t){function e(){this.constructor=n}r(n,t),n.prototype=null===t?Object.create(t):(e.prototype=t.prototype,new e)}),u=function(n){function t(t){var e=n.call(this,t)||this;return e.h=16,e.v=t,t&&"number"==typeof t.blockSize&&(e.h=t.blockSize),e.reset(t?t.data:void 0,t?t.nBytes:void 0),e}return o(t,n),Object.defineProperty(t.prototype,"blockSize",{get:function(){return this.h},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,e){n.prototype.reset.call(this,t,e),this.U()},t.prototype.update=function(n){return this.A(n),this.O(),this},t.prototype.finalize=function(n){return n&&this.A(n),this.S()},t.prototype.U=function(){throw new Error("Not implemented")},t.prototype.S=function(){throw new Error("Not implemented")},t}(i.C)},1756:function(n,t,e){e.d(t,{w:function(){return u}});var r,i="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(r=parseInt((/msie (\d+)/.exec(i)||[])[1],10),isNaN(r)?(r=parseInt((/trident\/.*; rv:(\d+)/.exec(i)||[])[1],10),!isNaN(r)&&r):r);function u(n,t){return!1!==o&&(!t||("<"===n?o<t:"<="===n?o<=t:">"===n?o>t:">="===n?o>=t:o===t))}},5720:function(n,t,e){e.d(t,{p:function(){return i}});var r=e(3354),i={stringify:function(n){for(var t=n.nSigBytes,e=n.words,r=[],i=0;i<t;i++){var o=e[i>>>2]>>>24-i%4*8&255;r.push((o>>>4).toString(16)),r.push((15&o).toString(16))}return r.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var e=[],i=0;i<t;i+=2)e[i>>>3]|=parseInt(n.substr(i,2),16)<<24-i%8*4;return new r.e(e,t/2)}}},8702:function(n,t,e){e.d(t,{m:function(){return i}});var r=e(3354),i={stringify:function(n){for(var t=n.nSigBytes,e=n.words,r=[],i=0;i<t;i++){var o=e[i>>>2]>>>24-i%4*8&255;r.push(String.fromCharCode(o))}return r.join("")},parse:function(n){for(var t=n.length,e=[],i=0;i<t;i++)e[i>>>2]|=(255&n.charCodeAt(i))<<24-i%4*8;return new r.e(e,t)}}},4768:function(n,t,e){e.d(t,{d:function(){return i}});var r=e(8702),i={stringify:function(n){try{return decodeURIComponent(escape(r.m.stringify(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return r.m.parse(unescape(encodeURIComponent(n)))}}},9054:function(n,t,e){e.d(t,{M:function(){return i}});var r=e(1756);var i=function(){if("undefined"!=typeof window){var n=window.crypto||window.msCrypto;if(!n){if((0,r.w)("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return n.getRandomValues(new Uint32Array(1))[0]}}return void 0!==e.g&&e.g.crypto?function(){return e.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}()}},t={};function e(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return n[r](o,o.exports,e),o.exports}e.d=function(n,t){for(var r in t)e.o(t,r)&&!e.o(n,r)&&Object.defineProperty(n,r,{enumerable:!0,get:t[r]})},e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),e.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},e.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"_",{value:!0})};var r={};return function(){e.r(r),e.d(r,{SHA512:function(){return c}});var n,t=e(1868),i=e(6957),o=(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),u=[new i.r(1116352408,3609767458),new i.r(1899447441,602891725),new i.r(3049323471,3964484399),new i.r(3921009573,2173295548),new i.r(961987163,4081628472),new i.r(1508970993,3053834265),new i.r(2453635748,2937671579),new i.r(2870763221,3664609560),new i.r(3624381080,2734883394),new i.r(310598401,1164996542),new i.r(607225278,1323610764),new i.r(1426881987,3590304994),new i.r(1925078388,4068182383),new i.r(2162078206,991336113),new i.r(2614888103,633803317),new i.r(3248222580,3479774868),new i.r(3835390401,2666613458),new i.r(4022224774,944711139),new i.r(264347078,2341262773),new i.r(604807628,2007800933),new i.r(770255983,1495990901),new i.r(1249150122,1856431235),new i.r(1555081692,3175218132),new i.r(1996064986,2198950837),new i.r(2554220882,3999719339),new i.r(2821834349,766784016),new i.r(2952996808,2566594879),new i.r(3210313671,3203337956),new i.r(3336571891,1034457026),new i.r(3584528711,2466948901),new i.r(113926993,3758326383),new i.r(338241895,168717936),new i.r(666307205,1188179964),new i.r(773529912,1546045734),new i.r(1294757372,1522805485),new i.r(1396182291,2643833823),new i.r(1695183700,2343527390),new i.r(1986661051,1014477480),new i.r(2177026350,1206759142),new i.r(2456956037,344077627),new i.r(2730485921,1290863460),new i.r(2820302411,3158454273),new i.r(3259730800,3505952657),new i.r(3345764771,106217008),new i.r(3516065817,3606008344),new i.r(3600352804,1432725776),new i.r(4094571909,1467031594),new i.r(275423344,851169720),new i.r(430227734,3100823752),new i.r(506948616,1363258195),new i.r(659060556,3750685593),new i.r(883997877,3785050280),new i.r(958139571,3318307427),new i.r(1322822218,3812723403),new i.r(1537002063,2003034995),new i.r(1747873779,3602036899),new i.r(1955562222,1575990012),new i.r(2024104815,1125592928),new i.r(2227730452,2716904306),new i.r(2361852424,442776044),new i.r(2428436474,593698344),new i.r(2756734187,3733110249),new i.r(3204031479,2999351573),new i.r(3329325298,3815920427),new i.r(3391569614,3928383900),new i.r(3515267271,566280711),new i.r(3940187606,3454069534),new i.r(4118630271,4000239992),new i.r(116418474,1914138554),new i.r(174292421,2731055270),new i.r(289380356,3203993006),new i.r(460393269,320620315),new i.r(685471733,587496836),new i.r(852142971,1086792851),new i.r(1017036298,365543100),new i.r(1126000580,2618297676),new i.r(1288033470,3409855158),new i.r(1501505948,4234509866),new i.r(1607167915,987167468),new i.r(1816402316,1246189591)],f=[];!function(){for(var n=0;n<80;n++)f[n]=new i.r(0,0)}();var c=function(n){function t(t){var e=n.call(this,t)||this;return e.h=32,e.N=new i.m([new i.r(1779033703,4089235720),new i.r(3144134277,2227873595),new i.r(1013904242,4271175723),new i.r(2773480762,1595750129),new i.r(1359893119,2917565137),new i.r(2600822924,725511199),new i.r(528734635,4215389547),new i.r(1541459225,327033209)]),e.v=t,t&&void 0!==t.hash&&(e.N=t.hash.clone()),e}return o(t,n),t.prototype.U=function(){this.N=new i.m([new i.r(1779033703,4089235720),new i.r(3144134277,2227873595),new i.r(1013904242,4271175723),new i.r(2773480762,1595750129),new i.r(1359893119,2917565137),new i.r(2600822924,725511199),new i.r(528734635,4215389547),new i.r(1541459225,327033209)])},t.prototype.I=function(n,t){for(var e=this.N.words,r=e[0],i=e[1],o=e[2],c=e[3],s=e[4],w=e[5],a=e[6],h=e[7],v=r.high,d=r.low,l=i.high,b=i.low,y=o.high,p=o.low,m=c.high,g=c.low,j=s.high,A=s.low,O=w.high,I=w.low,E=a.high,M=a.low,U=h.high,S=h.low,_=v,N=d,x=l,C=b,F=y,B=p,k=m,z=g,H=j,T=A,P=O,R=I,q=E,$=M,D=U,G=S,J=0;J<80;J++){var K=void 0,L=void 0,Q=f[J];if(J<16)L=Q.high=0|n[t+2*J],K=Q.low=0|n[t+2*J+1];else{var V=f[J-15],W=V.high,X=V.low,Y=(W>>>1|X<<31)^(W>>>8|X<<24)^W>>>7,Z=(X>>>1|W<<31)^(X>>>8|W<<24)^(X>>>7|W<<25),nn=f[J-2],tn=nn.high,en=nn.low,rn=(tn>>>19|en<<13)^(tn<<3|en>>>29)^tn>>>6,on=(en>>>19|tn<<13)^(en<<3|tn>>>29)^(en>>>6|tn<<26),un=f[J-7],fn=un.high,cn=un.low,sn=f[J-16],wn=sn.high,an=sn.low;L=(L=(L=Y+fn+((K=Z+cn)>>>0<Z>>>0?1:0))+rn+((K+=on)>>>0<on>>>0?1:0))+wn+((K+=an)>>>0<an>>>0?1:0),Q.high=L,Q.low=K}var hn=H&P^~H&q,vn=T&R^~T&$,dn=_&x^_&F^x&F,ln=N&C^N&B^C&B,bn=(_>>>28|N<<4)^(_<<30|N>>>2)^(_<<25|N>>>7),yn=(N>>>28|_<<4)^(N<<30|_>>>2)^(N<<25|_>>>7),pn=(H>>>14|T<<18)^(H>>>18|T<<14)^(H<<23|T>>>9),mn=(T>>>14|H<<18)^(T>>>18|H<<14)^(T<<23|H>>>9),gn=u[J],jn=gn.high,An=gn.low,On=G+mn,In=D+pn+(On>>>0<G>>>0?1:0),En=yn+ln;D=q,G=$,q=P,$=R,P=H,R=T,H=k+(In=(In=(In=In+hn+((On+=vn)>>>0<vn>>>0?1:0))+jn+((On+=An)>>>0<An>>>0?1:0))+L+((On+=K)>>>0<K>>>0?1:0))+((T=z+On|0)>>>0<z>>>0?1:0)|0,k=F,z=B,F=x,B=C,x=_,C=N,_=In+(bn+dn+(En>>>0<yn>>>0?1:0))+((N=On+En|0)>>>0<On>>>0?1:0)|0}d=r.low=d+N,r.high=v+_+(d>>>0<N>>>0?1:0),b=i.low=b+C,i.high=l+x+(b>>>0<C>>>0?1:0),p=o.low=p+B,o.high=y+F+(p>>>0<B>>>0?1:0),g=c.low=g+z,c.high=m+k+(g>>>0<z>>>0?1:0),A=s.low=A+T,s.high=j+H+(A>>>0<T>>>0?1:0),I=w.low=I+R,w.high=O+P+(I>>>0<R>>>0?1:0),M=a.low=M+$,a.high=E+q+(M>>>0<$>>>0?1:0),S=h.low=S+G,h.high=U+D+(S>>>0<G>>>0?1:0)},t.prototype.S=function(){var n=this.l,t=n.words,e=8*this.j,r=8*n.nSigBytes;return t[r>>>5]|=128<<24-r%32,t[30+(r+128>>>10<<5)]=Math.floor(e/4294967296),t[31+(r+128>>>10<<5)]=e,n.nSigBytes=4*t.length,this.O(),this.N.to32()},t.prototype.clone=function(){return new t({hash:this.N,blockSize:this.h,data:this.l,nBytes:this.j})},t.hash=function(n,e){return new t(e).finalize(n)},t}(t.P)}(),r}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/Utf16.d.ts
0 → 100644
| 1 | +export { Utf16LE, Utf16BE, Utf16 } from "./lib/encoder/Utf16"; | ... | ... |
app/static/content/jscrypto/Utf16.js
0 → 100644
| 1 | +!function(n,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else if("object"==typeof exports)exports.JsCrypto=r();else{var t=r();for(var e in n.JsCrypto=n.JsCrypto||{},t)n.JsCrypto[e]=t[e]}}(this,(function(){return function(){"use strict";var n={d:function(r,t){for(var e in t)n.o(t,e)&&!n.o(r,e)&&Object.defineProperty(r,e,{enumerable:!0,get:t[e]})}};n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),n.o=function(n,r){return Object.prototype.hasOwnProperty.call(n,r)},n.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"t",{value:!0})};var r={};n.r(r),n.d(r,{Utf16:function(){return h},Utf16BE:function(){return a},Utf16LE:function(){return c}});var t,e=function(n){for(var r=n.nSigBytes,t=n.words,e=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;e.push((o>>>4).toString(16)),e.push((15&o).toString(16))}return e.join("")},i="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(t=parseInt((/msie (\d+)/.exec(i)||[])[1],10),isNaN(t)?(t=parseInt((/trident\/.*; rv:(\d+)/.exec(i)||[])[1],10),!isNaN(t)&&t):t);var f=function(){if("undefined"!=typeof window){var r=window.crypto||window.msCrypto;if(!r){if(function(n,r){return!1!==o&&(!r||("<"===n?o<r:"<="===n?o<=r:">"===n?o>r:">="===n?o>=r:o===r))}("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return r.getRandomValues(new Uint32Array(1))[0]}}return void 0!==n.g&&n.g.crypto?function(){return n.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}(),u=function(){function n(r,t){if(Array.isArray(r)||!r)return this.i=Array.isArray(r)?r:[],void(this.u="number"==typeof t?t:4*this.i.length);if(r instanceof n)return this.i=r.words.slice(),void(this.u=r.nSigBytes);var e;try{r instanceof ArrayBuffer?e=new Uint8Array(r):(r instanceof Uint8Array||r instanceof Int8Array||r instanceof Uint8ClampedArray||r instanceof Int16Array||r instanceof Uint16Array||r instanceof Int32Array||r instanceof Uint32Array||r instanceof Float32Array||r instanceof Float64Array)&&(e=new Uint8Array(r.buffer,r.byteOffset,r.byteLength))}catch(n){throw new Error("Invalid argument")}if(!e)throw new Error("Invalid argument");for(var i=e.byteLength,o=[],f=0;f<i;f++)o[f>>>2]|=e[f]<<24-f%4*8;this.i=o,this.u=i}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.u},set:function(n){this.u=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.i},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):e(this)},n.prototype.toUint8Array=function(){for(var n=this.i,r=this.u,t=new Uint8Array(r),e=0;e<r;e++)t[e]=n[e>>>2]>>>24-e%4*8&255;return t},n.prototype.concat=function(n){var r=n.words.slice(),t=n.nSigBytes;if(this.clamp(),this.u%4)for(var e=0;e<t;e++){var i=r[e>>>2]>>>24-e%4*8&255;this.i[this.u+e>>>2]|=i<<24-(this.u+e)%4*8}else for(e=0;e<t;e+=4)this.i[this.u+e>>>2]=r[e>>>2];return this.u+=t,this},n.prototype.clamp=function(){var n=this.u;this.i[n>>>2]&=4294967295<<32-n%4*8,this.i.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.i.slice(),this.u)},n.random=function(r){for(var t=[],e=0;e<r;e+=4)t.push(f());return new n(t,r)},n}(),a={stringify:function(n){for(var r=n.words,t=n.nSigBytes,e=[],i=0;i<t;i+=2){var o=r[i>>>2]>>>16-i%4*8&65535;e.push(String.fromCharCode(o))}return e.join("")},parse:function(n){for(var r=n.length,t=[],e=0;e<r;e++)t[e>>>1]|=n.charCodeAt(e)<<16-e%2*16;return new u(t,2*r)}};function s(n){return n<<8&4278255360|n>>>8&16711935}var c={stringify:function(n){for(var r=n.words,t=n.nSigBytes,e=[],i=0;i<t;i+=2){var o=s(r[i>>>2]>>>16-i%4*8&65535);e.push(String.fromCharCode(o))}return e.join("")},parse:function(n){for(var r=n.length,t=[],e=0;e<r;e++)t[e>>>1]|=s(n.charCodeAt(e)<<16-e%2*16);return new u(t,2*r)}},h=a;return r}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/Utf8.d.ts
0 → 100644
| 1 | +export { Utf8 } from "./lib/encoder/Utf8"; | ... | ... |
app/static/content/jscrypto/Utf8.js
0 → 100644
| 1 | +!function(n,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else if("object"==typeof exports)exports.JsCrypto=r();else{var t=r();for(var e in n.JsCrypto=n.JsCrypto||{},t)n.JsCrypto[e]=t[e]}}(this,(function(){return function(){"use strict";var n={d:function(r,t){for(var e in t)n.o(t,e)&&!n.o(r,e)&&Object.defineProperty(r,e,{enumerable:!0,get:t[e]})}};n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),n.o=function(n,r){return Object.prototype.hasOwnProperty.call(n,r)},n.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"t",{value:!0})};var r={};n.r(r),n.d(r,{Utf8:function(){return c}});var t,e=function(n){for(var r=n.nSigBytes,t=n.words,e=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;e.push((o>>>4).toString(16)),e.push((15&o).toString(16))}return e.join("")},i="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(t=parseInt((/msie (\d+)/.exec(i)||[])[1],10),isNaN(t)?(t=parseInt((/trident\/.*; rv:(\d+)/.exec(i)||[])[1],10),!isNaN(t)&&t):t);var a=function(){if("undefined"!=typeof window){var r=window.crypto||window.msCrypto;if(!r){if(function(n,r){return!1!==o&&(!r||("<"===n?o<r:"<="===n?o<=r:">"===n?o>r:">="===n?o>=r:o===r))}("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return r.getRandomValues(new Uint32Array(1))[0]}}return void 0!==n.g&&n.g.crypto?function(){return n.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}(),u=function(){function n(r,t){if(Array.isArray(r)||!r)return this.i=Array.isArray(r)?r:[],void(this.u="number"==typeof t?t:4*this.i.length);if(r instanceof n)return this.i=r.words.slice(),void(this.u=r.nSigBytes);var e;try{r instanceof ArrayBuffer?e=new Uint8Array(r):(r instanceof Uint8Array||r instanceof Int8Array||r instanceof Uint8ClampedArray||r instanceof Int16Array||r instanceof Uint16Array||r instanceof Int32Array||r instanceof Uint32Array||r instanceof Float32Array||r instanceof Float64Array)&&(e=new Uint8Array(r.buffer,r.byteOffset,r.byteLength))}catch(n){throw new Error("Invalid argument")}if(!e)throw new Error("Invalid argument");for(var i=e.byteLength,o=[],a=0;a<i;a++)o[a>>>2]|=e[a]<<24-a%4*8;this.i=o,this.u=i}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.u},set:function(n){this.u=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.i},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):e(this)},n.prototype.toUint8Array=function(){for(var n=this.i,r=this.u,t=new Uint8Array(r),e=0;e<r;e++)t[e]=n[e>>>2]>>>24-e%4*8&255;return t},n.prototype.concat=function(n){var r=n.words.slice(),t=n.nSigBytes;if(this.clamp(),this.u%4)for(var e=0;e<t;e++){var i=r[e>>>2]>>>24-e%4*8&255;this.i[this.u+e>>>2]|=i<<24-(this.u+e)%4*8}else for(e=0;e<t;e+=4)this.i[this.u+e>>>2]=r[e>>>2];return this.u+=t,this},n.prototype.clamp=function(){var n=this.u;this.i[n>>>2]&=4294967295<<32-n%4*8,this.i.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.i.slice(),this.u)},n.random=function(r){for(var t=[],e=0;e<r;e+=4)t.push(a());return new n(t,r)},n}(),f=function(n){for(var r=n.nSigBytes,t=n.words,e=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;e.push(String.fromCharCode(o))}return e.join("")},s=function(n){for(var r=n.length,t=[],e=0;e<r;e++)t[e>>>2]|=(255&n.charCodeAt(e))<<24-e%4*8;return new u(t,r)},c={stringify:function(n){try{return decodeURIComponent(escape(f(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return s(unescape(encodeURIComponent(n)))}};return r}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/Word32Array.d.ts
0 → 100644
| 1 | +export { Word32Array } from "./lib/Word32Array"; | ... | ... |
app/static/content/jscrypto/Word32Array.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var r=t();for(var e in n.JsCrypto=n.JsCrypto||{},r)n.JsCrypto[e]=r[e]}}(this,(function(){return function(){"use strict";var n={d:function(t,r){for(var e in r)n.o(r,e)&&!n.o(t,e)&&Object.defineProperty(t,e,{enumerable:!0,get:r[e]})}};n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),n.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},n.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"t",{value:!0})};var t={};n.r(t),n.d(t,{Word32Array:function(){return u}});var r,e=function(n){for(var t=n.nSigBytes,r=n.words,e=[],i=0;i<t;i++){var o=r[i>>>2]>>>24-i%4*8&255;e.push((o>>>4).toString(16)),e.push((15&o).toString(16))}return e.join("")},i="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(r=parseInt((/msie (\d+)/.exec(i)||[])[1],10),isNaN(r)?(r=parseInt((/trident\/.*; rv:(\d+)/.exec(i)||[])[1],10),!isNaN(r)&&r):r);var a=function(){if("undefined"!=typeof window){var t=window.crypto||window.msCrypto;if(!t){if(function(n,t){return!1!==o&&(!t||("<"===n?o<t:"<="===n?o<=t:">"===n?o>t:">="===n?o>=t:o===t))}("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return t.getRandomValues(new Uint32Array(1))[0]}}return void 0!==n.g&&n.g.crypto?function(){return n.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}(),u=function(){function n(t,r){if(Array.isArray(t)||!t)return this.i=Array.isArray(t)?t:[],void(this.u="number"==typeof r?r:4*this.i.length);if(t instanceof n)return this.i=t.words.slice(),void(this.u=t.nSigBytes);var e;try{t instanceof ArrayBuffer?e=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(e=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!e)throw new Error("Invalid argument");for(var i=e.byteLength,o=[],a=0;a<i;a++)o[a>>>2]|=e[a]<<24-a%4*8;this.i=o,this.u=i}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.u},set:function(n){this.u=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.i},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):e(this)},n.prototype.toUint8Array=function(){for(var n=this.i,t=this.u,r=new Uint8Array(t),e=0;e<t;e++)r[e]=n[e>>>2]>>>24-e%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.u%4)for(var e=0;e<r;e++){var i=t[e>>>2]>>>24-e%4*8&255;this.i[this.u+e>>>2]|=i<<24-(this.u+e)%4*8}else for(e=0;e<r;e+=4)this.i[this.u+e>>>2]=t[e>>>2];return this.u+=r,this},n.prototype.clamp=function(){var n=this.u;this.i[n>>>2]&=4294967295<<32-n%4*8,this.i.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.i.slice(),this.u)},n.random=function(t){for(var r=[],e=0;e<t;e+=4)r.push(a());return new n(r,t)},n}();return t}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/Word64Array.d.ts
0 → 100644
| 1 | +export { Word64, Word64Array } from "./lib/Word64Array"; | ... | ... |
app/static/content/jscrypto/Word64Array.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var r=t();for(var e in n.JsCrypto=n.JsCrypto||{},r)n.JsCrypto[e]=r[e]}}(this,(function(){return function(){"use strict";var n={d:function(t,r){for(var e in r)n.o(r,e)&&!n.o(t,e)&&Object.defineProperty(t,e,{enumerable:!0,get:r[e]})}};n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),n.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},n.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"t",{value:!0})};var t={};n.r(t),n.d(t,{Word64:function(){return s},Word64Array:function(){return a}});var r,e="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",i=(r=parseInt((/msie (\d+)/.exec(e)||[])[1],10),isNaN(r)?(r=parseInt((/trident\/.*; rv:(\d+)/.exec(e)||[])[1],10),!isNaN(r)&&r):r);var o=function(){if("undefined"!=typeof window){var t=window.crypto||window.msCrypto;if(!t){if(function(n,t){return!1!==i&&(!t||("<"===n?i<t:"<="===n?i<=t:">"===n?i>t:">="===n?i>=t:i===t))}("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return t.getRandomValues(new Uint32Array(1))[0]}}return void 0!==n.g&&n.g.crypto?function(){return n.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}(),u=function(){function n(t,r){if(Array.isArray(t)||!t)return this.i=Array.isArray(t)?t:[],void(this.u="number"==typeof r?r:4*this.i.length);if(t instanceof n)return this.i=t.words.slice(),void(this.u=t.nSigBytes);var e;try{t instanceof ArrayBuffer?e=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(e=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!e)throw new Error("Invalid argument");for(var i=e.byteLength,o=[],u=0;u<i;u++)o[u>>>2]|=e[u]<<24-u%4*8;this.i=o,this.u=i}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.u},set:function(n){this.u=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.i},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):f.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this.i,t=this.u,r=new Uint8Array(t),e=0;e<t;e++)r[e]=n[e>>>2]>>>24-e%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.u%4)for(var e=0;e<r;e++){var i=t[e>>>2]>>>24-e%4*8&255;this.i[this.u+e>>>2]|=i<<24-(this.u+e)%4*8}else for(e=0;e<r;e+=4)this.i[this.u+e>>>2]=t[e>>>2];return this.u+=r,this},n.prototype.clamp=function(){var n=this.u;this.i[n>>>2]&=4294967295<<32-n%4*8,this.i.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.i.slice(),this.u)},n.random=function(t){for(var r=[],e=0;e<t;e+=4)r.push(o());return new n(r,t)},n}(),f={stringify:function(n){for(var t=n.nSigBytes,r=n.words,e=[],i=0;i<t;i++){var o=r[i>>>2]>>>24-i%4*8&255;e.push((o>>>4).toString(16)),e.push((15&o).toString(16))}return e.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var r=[],e=0;e<t;e+=2)r[e>>>3]|=parseInt(n.substr(e,2),16)<<24-e%8*4;return new u(r,t/2)}},s=function(){function n(n,t){this.high=n,this.low=t}return n.prototype.clone=function(){return new n(this.high,this.low)},n}(),a=function(){function n(n,t){this.i=n||[],this.u="number"==typeof t?t:8*this.i.length}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.u},set:function(n){this.u=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.i},enumerable:!1,configurable:!0}),n.prototype.to32=function(){for(var n=[],t=0;t<this.i.length;t++){var r=this.i[t];n.push(r.high),n.push(r.low)}return new u(n,this.u)},n.prototype.toString=function(n){return n?n.stringify(this.to32()):f.stringify(this.to32())},n.prototype.clone=function(){for(var t=this.i.slice(),r=0;r<t.length;r++)t[r]=t[r].clone();return new n(t,this.u)},n}();return t}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/bin/cli.js
0 → 100644
| 1 | +#!/usr/bin/env node | |
| 2 | + | |
| 3 | +const hashCommands = [ | |
| 4 | + "md5", "sha1", "sha3", "sha224", "sha256", "sha384", "sha512", "ripemd160" | |
| 5 | +]; | |
| 6 | + | |
| 7 | +const hmacCommands = [ | |
| 8 | + "hmac-md5", "hmac-sha1", "hmac-sha224", "hmac-sha256", "hmac-sha384", "hmac-sha512" | |
| 9 | +]; | |
| 10 | + | |
| 11 | +const cipherCommands = [ | |
| 12 | + "aes", "des", "des3", "rc4" | |
| 13 | +]; | |
| 14 | + | |
| 15 | +const exeCommand = "npx jscrypto"// process.argv.slice(0, 2).join(" "); | |
| 16 | + | |
| 17 | +const manJsCrypto = [ | |
| 18 | + `Usage: ${exeCommand} <hash|hmac|cipher> [command options]\n`, | |
| 19 | + "\n", | |
| 20 | + " hash: " + hashCommands.join(", ") + "\n", | |
| 21 | + " hmac: " + hmacCommands.join(", ") + "\n", | |
| 22 | + " cipher: " + cipherCommands.join(", ") + "\n", | |
| 23 | +].join(""); | |
| 24 | + | |
| 25 | +const manJsCryptoHash = [ | |
| 26 | + `${exeCommand} <hash> message [-msg hex|base64|utf8] [-out hex|base64]\n`, | |
| 27 | + "\n", | |
| 28 | + ` <hash>: ${hashCommands.join(", ")}\n`, | |
| 29 | + " default:\n", | |
| 30 | + " -msg: utf8 ... recognize message as utf-8 string\n", | |
| 31 | + " -out: hex ... output hashed binary as hex string\n", | |
| 32 | + " example: \n", | |
| 33 | + " #Output of below 3 examples are the same\n", | |
| 34 | + " npx jscrypto sha1 test\n", | |
| 35 | + " npx jscrypto sha1 74657374 -in hex\n", | |
| 36 | + " npx jscrypto sha1 dGVzdA== -in base64\n", | |
| 37 | +].join(""); | |
| 38 | + | |
| 39 | +const manJsCryptoHmac = [ | |
| 40 | + `${exeCommand} <hmac> message key [-msg hex|base64|utf8] [-key hex|base64|utf8] [-out hex|base64]\n`, | |
| 41 | + "\n", | |
| 42 | + ` <hmac>: ${hmacCommands.join(", ")}\n`, | |
| 43 | + " default:\n", | |
| 44 | + " -msg: utf8 ... recognize message as utf-8 string\n", | |
| 45 | + " -key: utf8 ... recognize key as utf-8 string\n", | |
| 46 | + " -out: hex ... output hashed binary as hex string\n", | |
| 47 | + " example: \n", | |
| 48 | + " #Output of below 3 examples are the same\n", | |
| 49 | + " npx jscrypto hmac-sha1 test key\n", | |
| 50 | + " npx jscrypto hmac-sha1 74657374 6b6579 -msg hex -key hex\n", | |
| 51 | + " npx jscrypto hmac-sha1 dGVzdA== a2V5 -msg base64 -key base64\n", | |
| 52 | +].join(""); | |
| 53 | + | |
| 54 | +const manJsCryptoCipher = [ | |
| 55 | + `${exeCommand} <cipher> <enc|dec> <message> key [-msg hex|base64|utf8] [-key hex|base64|utf8] [-out hex|base64|utf8] [-mode cbc|ecb|ofb|cfb|ctr] [-pad pkcs7|iso10126|iso97971|ansix923|nopadding] [-kdf pbkdf2|evpkdf] [-kdfIter n] [-kdfHasher hash]\n`, | |
| 56 | + "\n", | |
| 57 | + ` <cipher>: ${cipherCommands.join(", ")}\n`, | |
| 58 | + " <message>: If encrypting, utf8/hex/base64 value. If decrypting, base64 encoded encrypted string\n", | |
| 59 | + " default:\n", | |
| 60 | + " -msg: utf8 ... recognize message as utf-8 string\n", | |
| 61 | + " -key: utf8 ... recognize key as utf-8 string\n", | |
| 62 | + " -out: hex ... for decryption only. output hashed binary as hex string\n", | |
| 63 | + " -mode: cbc ... Cipher block chaining as block cipher mode\n", | |
| 64 | + " -pad: pkcs7 ... Pkcs7 padding as block padding\n", | |
| 65 | + " -kdf: pbkdf2 ... PBKDF2 as key derivation function\n", | |
| 66 | + " -kdfIter: 10000 ... kdf iteration count\n", | |
| 67 | + " -kdfHasher: sha256 ... kdf hasher\n", | |
| 68 | + " example: \n", | |
| 69 | + " #Encrypt (Output would not be the same because of a random salt, but can be decrypted with the same key)\n", | |
| 70 | + " npx jscrypto aes enc test password\n", | |
| 71 | + " npx jscrypto aes enc 74657374 70617373776f7264 -msg hex -key hex\n", | |
| 72 | + " npx jscrypto aes enc dGVzdA== cGFzc3dvcmQ= -msg base64 -key base64\n", | |
| 73 | + " #Decrypt\n", | |
| 74 | + " npx jscrypto aes dec U2FsdGVkX19Kf/wItWMuaTrQYV3OljA3Cr9WPMhC6Tk= password -out utf8\n", | |
| 75 | + " npx jscrypto aes dec A2pYDd/3oeENsRFGA1Y0Mg== 70617373776f7264 -key hex -out utf8\n", | |
| 76 | + " npx jscrypto aes dec A2pYDd/3oeENsRFGA1Y0Mg== cGFzc3dvcmQ= -key base64 -out utf8\n", | |
| 77 | +].join(""); | |
| 78 | + | |
| 79 | +const man = [ | |
| 80 | + manJsCrypto, | |
| 81 | + manJsCryptoHash, | |
| 82 | + manJsCryptoHmac, | |
| 83 | + manJsCryptoCipher, | |
| 84 | +].join("\n\n"); | |
| 85 | + | |
| 86 | +// const resolve = (file) => `../dist/${file}`; // Use if you git clone this project and want to debug cli.js | |
| 87 | +const path = require("path"); | |
| 88 | +const resolve = (file) => path.join("..", file); | |
| 89 | + | |
| 90 | +const args = process.argv.slice(2); | |
| 91 | + | |
| 92 | +if(args.length < 1){ | |
| 93 | + console.error("ERROR: command is not specified"); | |
| 94 | + console.error(""); | |
| 95 | + console.log(man); | |
| 96 | + process.exit(1); | |
| 97 | +} | |
| 98 | + | |
| 99 | +const command = args[0]; | |
| 100 | +if(hashCommands.includes(command)){ | |
| 101 | + doHash(); | |
| 102 | +} | |
| 103 | +else if(hmacCommands.includes(command)){ | |
| 104 | + doHmac(); | |
| 105 | +} | |
| 106 | +else if(cipherCommands.includes(command)){ | |
| 107 | + doCipher(); | |
| 108 | +} | |
| 109 | +else{ | |
| 110 | + console.error("ERROR: Unknown command"); | |
| 111 | + console.error(""); | |
| 112 | + console.log(man); | |
| 113 | + process.exit(1); | |
| 114 | +} | |
| 115 | + | |
| 116 | +function doHash(){ | |
| 117 | + const messageArg = args[1]; | |
| 118 | + const optionArgs = args.slice(2); | |
| 119 | + const options = { | |
| 120 | + msg: "utf8", | |
| 121 | + out: "hex", | |
| 122 | + }; | |
| 123 | + | |
| 124 | + if(optionArgs){ | |
| 125 | + for(let i=0;i<optionArgs.length;i++){ | |
| 126 | + const o1 = optionArgs[i]; | |
| 127 | + const o2 = optionArgs[i+1]; | |
| 128 | + if(o1 === "-msg"){ | |
| 129 | + if(!["hex", "base64", "utf8"].includes(o2)){ | |
| 130 | + console.error("ERROR: Unknown -in value"); | |
| 131 | + console.error(""); | |
| 132 | + console.log(manJsCryptoHash); | |
| 133 | + process.exit(1); | |
| 134 | + } | |
| 135 | + options.msg = o2; | |
| 136 | + i += 1; | |
| 137 | + } | |
| 138 | + else if(o1 === "-out"){ | |
| 139 | + if(!["hex", "base64", "utf8"].includes(o2)){ | |
| 140 | + console.error("ERROR: Unknown -out value"); | |
| 141 | + console.error(""); | |
| 142 | + console.log(manJsCryptoHash); | |
| 143 | + process.exit(1); | |
| 144 | + } | |
| 145 | + options.out = o2; | |
| 146 | + i += 1; | |
| 147 | + } | |
| 148 | + else{ | |
| 149 | + console.error("ERROR: Unknown option"); | |
| 150 | + console.error(""); | |
| 151 | + console.log(manJsCryptoHash); | |
| 152 | + process.exit(1); | |
| 153 | + } | |
| 154 | + } | |
| 155 | + } | |
| 156 | + | |
| 157 | + let Hasher; | |
| 158 | + switch (command.toLowerCase()){ | |
| 159 | + case "md5": Hasher = require(resolve("MD5")).MD5; break; | |
| 160 | + case "sha1": Hasher = require(resolve("SHA1")).SHA1; break; | |
| 161 | + case "sha3": Hasher = require(resolve("SHA3")).SHA3; break; | |
| 162 | + case "sha224": Hasher = require(resolve("SHA224")).SHA224; break; | |
| 163 | + case "sha256": Hasher = require(resolve("SHA256")).SHA256; break; | |
| 164 | + case "sha384": Hasher = require(resolve("SHA384")).SHA384; break; | |
| 165 | + case "sha512": Hasher = require(resolve("SHA512")).SHA512; break; | |
| 166 | + case "ripemd160": Hasher = require(resolve("RIPEMD160")).RIPEMD160; break; | |
| 167 | + default: | |
| 168 | + console.error("ERROR: Unknown hash"); | |
| 169 | + console.error(""); | |
| 170 | + console.log(manJsCryptoHash); | |
| 171 | + process.exit(1); | |
| 172 | + } | |
| 173 | + | |
| 174 | + let message; | |
| 175 | + if(options.msg.toLowerCase() === "utf8"){ | |
| 176 | + message = messageArg; | |
| 177 | + } | |
| 178 | + else if(options.msg.toLowerCase() === "hex"){ | |
| 179 | + if(!/^[0-9a-fA-F]+$/.test(messageArg)){ | |
| 180 | + console.error("ERROR: Invalid Hex input"); | |
| 181 | + process.exit(1); | |
| 182 | + } | |
| 183 | + else if(messageArg.length % 2 !== 0){ | |
| 184 | + console.error("ERROR: Hex character count must be even"); | |
| 185 | + process.exit(1); | |
| 186 | + } | |
| 187 | + | |
| 188 | + const {Hex} = require(resolve("Hex")); | |
| 189 | + message = Hex.parse(messageArg); | |
| 190 | + } | |
| 191 | + else if(options.msg.toLowerCase() === "base64"){ | |
| 192 | + const {Base64} = require(resolve("Base64")); | |
| 193 | + message = Base64.parse(messageArg); | |
| 194 | + } | |
| 195 | + else{ | |
| 196 | + console.error("ERROR: unknown -msg value"); | |
| 197 | + process.exit(1); | |
| 198 | + } | |
| 199 | + | |
| 200 | + let outputEncoding; | |
| 201 | + if(options.out.toLowerCase() === "hex"){ | |
| 202 | + outputEncoding = require(resolve("Hex")).Hex; | |
| 203 | + } | |
| 204 | + else if(options.out.toLowerCase() === "base64"){ | |
| 205 | + outputEncoding = require(resolve("Base64")).Base64; | |
| 206 | + } | |
| 207 | + else{ | |
| 208 | + console.error("ERROR: unknown -out value"); | |
| 209 | + process.exit(1); | |
| 210 | + } | |
| 211 | + | |
| 212 | + const result = Hasher.hash(message); | |
| 213 | + let output; | |
| 214 | + try{ | |
| 215 | + output = result.toString(outputEncoding); | |
| 216 | + } | |
| 217 | + catch(e){ | |
| 218 | + if(options.out === "utf8"){ | |
| 219 | + console.error("ERROR: Byte array could not be recognized as UTF-8"); | |
| 220 | + } | |
| 221 | + else{ | |
| 222 | + console.error("ERROR: Failed to hash message"); | |
| 223 | + } | |
| 224 | + process.exit(1); | |
| 225 | + } | |
| 226 | + | |
| 227 | + console.log(output); | |
| 228 | + process.exit(0); | |
| 229 | +} | |
| 230 | + | |
| 231 | +function doHmac(){ | |
| 232 | + const messageArg = args[1] || ""; | |
| 233 | + const keyArg = args[2] || ""; | |
| 234 | + const optionArgs = args.slice(3); | |
| 235 | + const options = { | |
| 236 | + msg: "utf8", | |
| 237 | + key: "utf8", | |
| 238 | + out: "hex", | |
| 239 | + }; | |
| 240 | + | |
| 241 | + if(optionArgs){ | |
| 242 | + for(let i=0;i<optionArgs.length;i++){ | |
| 243 | + const o1 = optionArgs[i]; | |
| 244 | + const o2 = optionArgs[i+1]; | |
| 245 | + if(o1 === "-msg"){ | |
| 246 | + if(!["hex", "base64", "utf8"].includes(o2)){ | |
| 247 | + console.error("ERROR: Unknown -msg value"); | |
| 248 | + console.error(""); | |
| 249 | + console.log(manJsCryptoHmac); | |
| 250 | + process.exit(1); | |
| 251 | + } | |
| 252 | + options.msg = o2; | |
| 253 | + i += 1; | |
| 254 | + } | |
| 255 | + else if(o1 === "-key"){ | |
| 256 | + if(!["hex", "base64", "utf8"].includes(o2)){ | |
| 257 | + console.error("ERROR: Unknown -key value"); | |
| 258 | + console.error(""); | |
| 259 | + console.log(manJsCryptoHmac); | |
| 260 | + process.exit(1); | |
| 261 | + } | |
| 262 | + options.key = o2; | |
| 263 | + i += 1; | |
| 264 | + } | |
| 265 | + else if(o1 === "-out"){ | |
| 266 | + if(!["hex", "base64", "utf8"].includes(o2)){ | |
| 267 | + console.error("ERROR: Unknown -out value"); | |
| 268 | + console.error(""); | |
| 269 | + console.log(manJsCryptoHmac); | |
| 270 | + process.exit(1); | |
| 271 | + } | |
| 272 | + options.out = o2; | |
| 273 | + i += 1; | |
| 274 | + } | |
| 275 | + else{ | |
| 276 | + console.error("ERROR: Unknown option"); | |
| 277 | + console.error(""); | |
| 278 | + console.log(manJsCryptoHmac); | |
| 279 | + process.exit(1); | |
| 280 | + } | |
| 281 | + } | |
| 282 | + } | |
| 283 | + | |
| 284 | + let Hasher; | |
| 285 | + switch (command.replace(/-/g, "").toLowerCase()){ | |
| 286 | + case "hmacmd5": Hasher = require(resolve("HmacMD5")).HmacMD5; break; | |
| 287 | + case "hmacsha1": Hasher = require(resolve("HmacSHA1")).HmacSHA1; break; | |
| 288 | + case "hmacsha224": Hasher = require(resolve("HmacSHA224")).HmacSHA224; break; | |
| 289 | + case "hmacsha256": Hasher = require(resolve("HmacSHA256")).HmacSHA256; break; | |
| 290 | + case "hmacsha384": Hasher = require(resolve("HmacSHA384")).HmacSHA384; break; | |
| 291 | + case "hmacsha512": Hasher = require(resolve("HmacSHA512")).HmacSHA512; break; | |
| 292 | + default: | |
| 293 | + console.error("ERROR: Unknown hmac hasher"); | |
| 294 | + console.error(""); | |
| 295 | + console.log(manJsCryptoHmac); | |
| 296 | + process.exit(1); | |
| 297 | + } | |
| 298 | + | |
| 299 | + let message; | |
| 300 | + if(options.msg.toLowerCase() === "utf8"){ | |
| 301 | + message = messageArg; | |
| 302 | + } | |
| 303 | + else if(options.msg.toLowerCase() === "hex"){ | |
| 304 | + if(!/^[0-9a-fA-F]+$/.test(messageArg)){ | |
| 305 | + console.error("ERROR: Invalid Hex input"); | |
| 306 | + process.exit(1); | |
| 307 | + } | |
| 308 | + else if(messageArg.length % 2 !== 0){ | |
| 309 | + console.error("ERROR: Hex character count must be even"); | |
| 310 | + process.exit(1); | |
| 311 | + } | |
| 312 | + | |
| 313 | + const {Hex} = require(resolve("Hex")); | |
| 314 | + message = Hex.parse(messageArg); | |
| 315 | + } | |
| 316 | + else if(options.msg.toLowerCase() === "base64"){ | |
| 317 | + const {Base64} = require(resolve("Base64")); | |
| 318 | + message = Base64.parse(messageArg); | |
| 319 | + } | |
| 320 | + else{ | |
| 321 | + console.error("ERROR: unknown -msg value"); | |
| 322 | + process.exit(1); | |
| 323 | + } | |
| 324 | + | |
| 325 | + let key; | |
| 326 | + if(options.key.toLowerCase() === "utf8"){ | |
| 327 | + key = keyArg; | |
| 328 | + } | |
| 329 | + else if(options.key.toLowerCase() === "hex"){ | |
| 330 | + if(!/^[0-9a-zA-Z]+$/.test(keyArg)){ | |
| 331 | + console.error("ERROR: Invalid Hex input"); | |
| 332 | + process.exit(1); | |
| 333 | + } | |
| 334 | + else if(keyArg.length % 2 !== 0){ | |
| 335 | + console.error("ERROR: Hex character count must be even"); | |
| 336 | + process.exit(1); | |
| 337 | + } | |
| 338 | + | |
| 339 | + const {Hex} = require(resolve("Hex")); | |
| 340 | + key = Hex.parse(keyArg); | |
| 341 | + } | |
| 342 | + else if(options.key.toLowerCase() === "base64"){ | |
| 343 | + const {Base64} = require(resolve("Base64")); | |
| 344 | + key = Base64.parse(keyArg); | |
| 345 | + } | |
| 346 | + else{ | |
| 347 | + console.error("ERROR: unknown -key value"); | |
| 348 | + process.exit(1); | |
| 349 | + } | |
| 350 | + | |
| 351 | + let outputEncoding; | |
| 352 | + if(options.out.toLowerCase() === "hex"){ | |
| 353 | + outputEncoding = require(resolve("Hex")).Hex; | |
| 354 | + } | |
| 355 | + else if(options.out.toLowerCase() === "base64"){ | |
| 356 | + outputEncoding = require(resolve("Base64")).Base64; | |
| 357 | + } | |
| 358 | + else{ | |
| 359 | + console.error("ERROR: unknown -out value"); | |
| 360 | + process.exit(1); | |
| 361 | + } | |
| 362 | + | |
| 363 | + const result = Hasher(message, key); | |
| 364 | + let output; | |
| 365 | + try{ | |
| 366 | + output = result.toString(outputEncoding); | |
| 367 | + } | |
| 368 | + catch(e){ | |
| 369 | + if(options.out === "utf8"){ | |
| 370 | + console.error("ERROR: Byte array could not be recognized as UTF-8"); | |
| 371 | + } | |
| 372 | + else{ | |
| 373 | + console.error("ERROR: Failed to hash message"); | |
| 374 | + } | |
| 375 | + process.exit(1); | |
| 376 | + } | |
| 377 | + | |
| 378 | + console.log(output); | |
| 379 | + process.exit(0); | |
| 380 | +} | |
| 381 | + | |
| 382 | +function doCipher(){ | |
| 383 | + const encTypeArg = args[1]; | |
| 384 | + const messageArg = args[2] || ""; | |
| 385 | + const keyArg = args[3] || ""; | |
| 386 | + const optionArgs = args.slice(4); | |
| 387 | + const options = { | |
| 388 | + msg: "utf8", | |
| 389 | + key: "utf8", | |
| 390 | + out: "", // default value will be set later | |
| 391 | + mode: "cbc", | |
| 392 | + pad: "pkcs7", | |
| 393 | + kdf: "pbkdf2", | |
| 394 | + iter: 10000, | |
| 395 | + hasher: "sha256" | |
| 396 | + }; | |
| 397 | + | |
| 398 | + if(optionArgs){ | |
| 399 | + for(let i=0;i<optionArgs.length;i++){ | |
| 400 | + const o1 = optionArgs[i]; | |
| 401 | + const o2 = optionArgs[i+1]; | |
| 402 | + if(o1 === "-msg"){ | |
| 403 | + if(!["hex", "base64", "utf8"].includes(o2)){ | |
| 404 | + console.error("ERROR: Unknown -msg value"); | |
| 405 | + console.error(""); | |
| 406 | + console.log(manJsCryptoCipher); | |
| 407 | + process.exit(1); | |
| 408 | + } | |
| 409 | + options.msg = o2; | |
| 410 | + i += 1; | |
| 411 | + } | |
| 412 | + else if(o1 === "-key"){ | |
| 413 | + if(!["hex", "base64", "utf8"].includes(o2)){ | |
| 414 | + console.error("ERROR: Unknown -key value"); | |
| 415 | + console.error(""); | |
| 416 | + console.log(manJsCryptoCipher); | |
| 417 | + process.exit(1); | |
| 418 | + } | |
| 419 | + options.key = o2; | |
| 420 | + i += 1; | |
| 421 | + } | |
| 422 | + else if(o1 === "-out"){ | |
| 423 | + if(!["hex", "base64", "utf8"].includes(o2)){ | |
| 424 | + console.error("ERROR: Unknown -out value"); | |
| 425 | + console.error(""); | |
| 426 | + console.log(manJsCryptoCipher); | |
| 427 | + process.exit(1); | |
| 428 | + } | |
| 429 | + options.out = o2; | |
| 430 | + i += 1; | |
| 431 | + } | |
| 432 | + else if(o1 === "-mode"){ | |
| 433 | + if(!["cbc", "ecb", "cfb", "ofb", "ctr"].includes(o2)){ | |
| 434 | + console.error("ERROR: Unknown -mode value"); | |
| 435 | + console.error(""); | |
| 436 | + console.log(manJsCryptoCipher); | |
| 437 | + process.exit(1); | |
| 438 | + } | |
| 439 | + options.mode = o2; | |
| 440 | + i += 1; | |
| 441 | + } | |
| 442 | + else if(o1 === "-pad"){ | |
| 443 | + if(!["ansix923", "iso10126", "iso97971", "nopadding", "pkcs7"].includes(o2)){ | |
| 444 | + console.error("ERROR: Unknown -pad value"); | |
| 445 | + console.error(""); | |
| 446 | + console.log(manJsCryptoCipher); | |
| 447 | + process.exit(1); | |
| 448 | + } | |
| 449 | + options.pad = o2; | |
| 450 | + i += 1; | |
| 451 | + } | |
| 452 | + else if(o1 === "-kdf"){ | |
| 453 | + if(!["pbkdf2", "evpkdf"].includes(o2)){ | |
| 454 | + console.error("ERROR: Unknown -kdf value"); | |
| 455 | + console.error(""); | |
| 456 | + console.log(manJsCryptoCipher); | |
| 457 | + process.exit(1); | |
| 458 | + } | |
| 459 | + options.kdf = o2; | |
| 460 | + i += 1; | |
| 461 | + } | |
| 462 | + else if(o1 === "-kdfIter"){ | |
| 463 | + if(isNaN(+o2) || !isFinite(+o2)){ | |
| 464 | + console.error("ERROR: -iter value must be number"); | |
| 465 | + console.error(""); | |
| 466 | + console.log(manJsCryptoCipher); | |
| 467 | + process.exit(1); | |
| 468 | + } | |
| 469 | + options.iter = +o2; | |
| 470 | + i += 1; | |
| 471 | + } | |
| 472 | + else if(o1 === "-kdfHasher"){ | |
| 473 | + if(!hashCommands.includes(o2.toLowerCase())){ | |
| 474 | + console.error("ERROR: Unknown -kdf value"); | |
| 475 | + console.error(""); | |
| 476 | + console.log(manJsCryptoCipher); | |
| 477 | + process.exit(1); | |
| 478 | + } | |
| 479 | + options.hasher = o2.toLowerCase(); | |
| 480 | + i += 1; | |
| 481 | + } | |
| 482 | + else{ | |
| 483 | + console.error("ERROR: Unknown option"); | |
| 484 | + console.error(""); | |
| 485 | + console.log(manJsCryptoCipher); | |
| 486 | + process.exit(1); | |
| 487 | + } | |
| 488 | + } | |
| 489 | + } | |
| 490 | + | |
| 491 | + let Cipher; | |
| 492 | + switch (command.toLowerCase()){ | |
| 493 | + case "aes": Cipher = require(resolve("AES")).AES; break; | |
| 494 | + case "des": Cipher = require(resolve("DES")).DES; break; | |
| 495 | + case "des3": Cipher = require(resolve("DES3")).DES3; break; | |
| 496 | + case "rabbit": Cipher = require(resolve("Rabbit ")).Rabbit; break; | |
| 497 | + case "rc4": Cipher = require(resolve("RC4")).RC4; break; | |
| 498 | + default: | |
| 499 | + console.error("ERROR: Unknown cipher"); | |
| 500 | + console.error(""); | |
| 501 | + console.log(manJsCryptoCipher); | |
| 502 | + process.exit(1); | |
| 503 | + } | |
| 504 | + | |
| 505 | + let encType; | |
| 506 | + if(["enc", "dec"].includes(encTypeArg)){ | |
| 507 | + encType = encTypeArg; | |
| 508 | + } | |
| 509 | + else{ | |
| 510 | + console.error("ERROR: Must specify enc/dec"); | |
| 511 | + console.error(""); | |
| 512 | + console.log(manJsCryptoCipher); | |
| 513 | + process.exit(1); | |
| 514 | + } | |
| 515 | + | |
| 516 | + let message; | |
| 517 | + if(encType === "enc"){ | |
| 518 | + if(options.msg.toLowerCase() === "utf8"){ | |
| 519 | + message = messageArg; | |
| 520 | + } | |
| 521 | + else if(options.msg.toLowerCase() === "hex"){ | |
| 522 | + if(!/^[0-9a-fA-F]+$/.test(messageArg)){ | |
| 523 | + console.error("ERROR: Invalid Hex input"); | |
| 524 | + process.exit(1); | |
| 525 | + } | |
| 526 | + else if(messageArg.length % 2 !== 0){ | |
| 527 | + console.error("ERROR: Hex character count must be even"); | |
| 528 | + process.exit(1); | |
| 529 | + } | |
| 530 | + | |
| 531 | + const {Hex} = require(resolve("Hex")); | |
| 532 | + message = Hex.parse(messageArg); | |
| 533 | + } | |
| 534 | + else if(options.msg.toLowerCase() === "base64"){ | |
| 535 | + const {Base64} = require(resolve("Base64")); | |
| 536 | + message = Base64.parse(messageArg); | |
| 537 | + } | |
| 538 | + else{ | |
| 539 | + console.error("ERROR: unknown -msg value"); | |
| 540 | + process.exit(1); | |
| 541 | + } | |
| 542 | + } | |
| 543 | + else{ // encType === "dec" | |
| 544 | + message = messageArg; | |
| 545 | + } | |
| 546 | + | |
| 547 | + let key; | |
| 548 | + if(options.key.toLowerCase() === "utf8"){ | |
| 549 | + key = keyArg; | |
| 550 | + } | |
| 551 | + else if(options.key.toLowerCase() === "hex"){ | |
| 552 | + if(!/^[0-9a-zA-Z]+$/.test(keyArg)){ | |
| 553 | + console.error("ERROR: Invalid Hex input"); | |
| 554 | + process.exit(1); | |
| 555 | + } | |
| 556 | + else if(keyArg.length % 2 !== 0){ | |
| 557 | + console.error("ERROR: Hex character count must be even"); | |
| 558 | + process.exit(1); | |
| 559 | + } | |
| 560 | + | |
| 561 | + const {Hex} = require(resolve("Hex")); | |
| 562 | + key = Hex.parse(keyArg); | |
| 563 | + | |
| 564 | + if(command === "aes" && key.nSigBytes % 4 !== 0){ | |
| 565 | + console.error("ERROR: Key size for AES must be multiple of 32bit/4byte/1word"); | |
| 566 | + process.exit(1); | |
| 567 | + } | |
| 568 | + else if(command === "des3" && ![8,16].includes(key.nSigBytes) && key.nSigBytes < 24){ | |
| 569 | + console.error("ERROR: 3DES requires the key length to be 64, 128, 192 or >192 bits."); | |
| 570 | + process.exit(1); | |
| 571 | + } | |
| 572 | + } | |
| 573 | + else if(options.key.toLowerCase() === "base64"){ | |
| 574 | + const {Base64} = require(resolve("Base64")); | |
| 575 | + key = Base64.parse(keyArg); | |
| 576 | + | |
| 577 | + if(command === "aes" && key.nSigBytes % 4 !== 0){ | |
| 578 | + console.error("ERROR: Key size for AES must be multiple of 32bit/4byte/1word"); | |
| 579 | + process.exit(1); | |
| 580 | + } | |
| 581 | + else if(command === "des3" && ![8,16].includes(key.nSigBytes) && key.nSigBytes < 24){ | |
| 582 | + console.error("ERROR: 3DES requires the key length to be 64, 128, 192 or >192 bits."); | |
| 583 | + process.exit(1); | |
| 584 | + } | |
| 585 | + } | |
| 586 | + else{ | |
| 587 | + console.error("ERROR: unknown -key value"); | |
| 588 | + process.exit(1); | |
| 589 | + } | |
| 590 | + | |
| 591 | + // Decide -out default value | |
| 592 | + if(!options.out){ | |
| 593 | + if(encType === "enc"){ | |
| 594 | + options.out = "base64"; | |
| 595 | + } | |
| 596 | + else{ | |
| 597 | + options.out = "hex"; | |
| 598 | + } | |
| 599 | + } | |
| 600 | + else if(encType === "enc" && options.out.toLowerCase() === "utf8"){ | |
| 601 | + console.error("ERROR: '-out utf8' cannot be used on encryption"); | |
| 602 | + process.exit(1); | |
| 603 | + } | |
| 604 | + | |
| 605 | + let outputEncoding; | |
| 606 | + if(options.out.toLowerCase() === "hex"){ | |
| 607 | + outputEncoding = require(resolve("Hex")).Hex; | |
| 608 | + } | |
| 609 | + else if(options.out.toLowerCase() === "base64"){ | |
| 610 | + outputEncoding = require(resolve("Base64")).Base64; | |
| 611 | + } | |
| 612 | + else if(options.out.toLowerCase() === "utf8"){ | |
| 613 | + outputEncoding = require(resolve("Utf8")).Utf8; | |
| 614 | + } | |
| 615 | + else{ | |
| 616 | + console.error("ERROR: unknown -out value"); | |
| 617 | + process.exit(1); | |
| 618 | + } | |
| 619 | + | |
| 620 | + let mode; | |
| 621 | + if(options.mode.toLowerCase() === "cbc"){ | |
| 622 | + mode = require(resolve("mode/CBC")).CBC; | |
| 623 | + } | |
| 624 | + else if(options.mode.toLowerCase() === "ecb"){ | |
| 625 | + mode = require(resolve("mode/ECB")).ECB; | |
| 626 | + } | |
| 627 | + else if(options.mode.toLowerCase() === "ofb"){ | |
| 628 | + mode = require(resolve("mode/OFB")).OFB; | |
| 629 | + } | |
| 630 | + else if(options.mode.toLowerCase() === "cfb"){ | |
| 631 | + mode = require(resolve("mode/CFB")).CFB; | |
| 632 | + } | |
| 633 | + else if(options.mode.toLowerCase() === "ctr"){ | |
| 634 | + mode = require(resolve("mode/CTR")).CTR; | |
| 635 | + } | |
| 636 | + else{ | |
| 637 | + console.error("ERROR: unknown -mode value"); | |
| 638 | + process.exit(1); | |
| 639 | + } | |
| 640 | + | |
| 641 | + let padding; | |
| 642 | + if(options.pad.toLowerCase() === "ansix923"){ | |
| 643 | + padding = require(resolve("pad/AnsiX923")).AnsiX923; | |
| 644 | + } | |
| 645 | + else if(options.pad.toLowerCase() === "iso10126"){ | |
| 646 | + padding = require(resolve("pad/ISO10126")).ISO10126; | |
| 647 | + } | |
| 648 | + else if(options.pad.toLowerCase() === "iso97971"){ | |
| 649 | + padding = require(resolve("pad/ISO97971")).ISO97971; | |
| 650 | + } | |
| 651 | + else if(options.pad.toLowerCase() === "nopadding"){ | |
| 652 | + padding = require(resolve("pad/NoPadding")).NoPadding; | |
| 653 | + } | |
| 654 | + else if(options.pad.toLowerCase() === "pkcs7"){ | |
| 655 | + padding = require(resolve("pad/Pkcs7")).Pkcs7; | |
| 656 | + } | |
| 657 | + else if(options.pad.toLowerCase() === "zero"){ | |
| 658 | + padding = require(resolve("pad/Zero")).Zero; | |
| 659 | + } | |
| 660 | + else{ | |
| 661 | + console.error("ERROR: unknown -pad value"); | |
| 662 | + process.exit(1); | |
| 663 | + } | |
| 664 | + | |
| 665 | + let kdfModule; | |
| 666 | + if(options.kdf.toLowerCase() === "pbkdf2"){ | |
| 667 | + kdfModule = require(resolve("PBKDF2")).PBKDF2; | |
| 668 | + } | |
| 669 | + else if(options.kdf.toLowerCase() === "evpkdf"){ | |
| 670 | + kdfModule = require(resolve("EvpKDF")).EvpKDF; | |
| 671 | + } | |
| 672 | + else{ | |
| 673 | + console.error("ERROR: unknown -kdf value"); | |
| 674 | + process.exit(1); | |
| 675 | + } | |
| 676 | + | |
| 677 | + let kdfIterations = options.iter; | |
| 678 | + | |
| 679 | + let kdfHasher; | |
| 680 | + switch (options.hasher.toLowerCase()){ | |
| 681 | + case "md5": kdfHasher = require(resolve("MD5")).MD5; break; | |
| 682 | + case "sha1": kdfHasher = require(resolve("SHA1")).SHA1; break; | |
| 683 | + case "sha3": kdfHasher = require(resolve("SHA3")).SHA3; break; | |
| 684 | + case "sha224": kdfHasher = require(resolve("SHA224")).SHA224; break; | |
| 685 | + case "sha256": kdfHasher = require(resolve("SHA256")).SHA256; break; | |
| 686 | + case "sha384": kdfHasher = require(resolve("SHA384")).SHA384; break; | |
| 687 | + case "sha512": kdfHasher = require(resolve("SHA512")).SHA512; break; | |
| 688 | + case "ripemd160": kdfHasher = require(resolve("RIPEMD160")).RIPEMD160; break; | |
| 689 | + default: | |
| 690 | + console.error("ERROR: Unknown hash"); | |
| 691 | + process.exit(1); | |
| 692 | + } | |
| 693 | + | |
| 694 | + let result; | |
| 695 | + | |
| 696 | + if(encType === "enc"){ | |
| 697 | + result = Cipher.encrypt(message, key, {mode, padding, kdfModule, kdfIterations, kdfHasher}); | |
| 698 | + } | |
| 699 | + else{ | |
| 700 | + result = Cipher.decrypt(message, key, {mode, padding, kdfModule, kdfIterations, kdfHasher}); | |
| 701 | + } | |
| 702 | + | |
| 703 | + let output; | |
| 704 | + try{ | |
| 705 | + if(encType === "enc"){ | |
| 706 | + if(options.out.toLowerCase() === "base64"){ | |
| 707 | + output = result.toString(); | |
| 708 | + } | |
| 709 | + else{ | |
| 710 | + const {Base64} = require(resolve("Base64")); | |
| 711 | + const word = Base64.parse(result.toString()); | |
| 712 | + output = word.toString(require(resolve("Hex")).Hex); | |
| 713 | + } | |
| 714 | + } | |
| 715 | + else{ | |
| 716 | + output = result.toString(outputEncoding); | |
| 717 | + } | |
| 718 | + } | |
| 719 | + catch(e){ | |
| 720 | + if(options.out === "utf8"){ | |
| 721 | + console.error("ERROR: Byte array could not be recognized as UTF-8"); | |
| 722 | + } | |
| 723 | + else{ | |
| 724 | + console.error("ERROR: Failed to decrypt message"); | |
| 725 | + } | |
| 726 | + process.exit(1); | |
| 727 | + } | |
| 728 | + | |
| 729 | + console.log(output); | |
| 730 | + process.exit(0); | |
| 731 | +} | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/es6/AES.d.ts
0 → 100644
| 1 | +import { CipherProps, PropsWithKey } from "./lib/algorithm/cipher/Cipher"; | |
| 2 | +import type { Word32Array } from "./lib/Word32Array"; | |
| 3 | +import { BlockCipher, BlockCipherProps } from "./lib/algorithm/cipher/BlockCipher"; | |
| 4 | +import type { CipherParams } from "./lib/algorithm/cipher/CipherParams"; | |
| 5 | +export interface AESProps extends BlockCipherProps { | |
| 6 | +} | |
| 7 | +export declare class AES extends BlockCipher { | |
| 8 | + static readonly keySize: number; | |
| 9 | + protected _props: PropsWithKey<AESProps>; | |
| 10 | + protected _nRounds: number; | |
| 11 | + protected _keyPriorReset: Word32Array | undefined; | |
| 12 | + protected _keySchedule: number[]; | |
| 13 | + protected _invKeySchedule: number[]; | |
| 14 | + constructor(props: PropsWithKey<AESProps>); | |
| 15 | + protected _doReset(): void; | |
| 16 | + encryptBlock(words: number[], offset: number): void; | |
| 17 | + decryptBlock(words: number[], offset: number): void; | |
| 18 | + protected _doCryptBlock(words: number[], offset: number, keySchedule: number[], subMix0: number[], subMix1: number[], subMix2: number[], subMix3: number[], sBox: number[]): void; | |
| 19 | + /** | |
| 20 | + * Creates this cipher in encryption mode. | |
| 21 | + * | |
| 22 | + * @param {Word32Array} key The key. | |
| 23 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 24 | + * @return {Cipher} A cipher instance. | |
| 25 | + * @example | |
| 26 | + * var cipher = AES.createEncryptor(keyWordArray, { iv: ivWordArray }); | |
| 27 | + */ | |
| 28 | + static createEncryptor(key: Word32Array, props?: Partial<CipherProps>): AES; | |
| 29 | + /** | |
| 30 | + * Creates this cipher in decryption mode. | |
| 31 | + * | |
| 32 | + * @param {Word32Array} key The key. | |
| 33 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 34 | + * @return {Cipher} A cipher instance. | |
| 35 | + * @example | |
| 36 | + * var cipher = AES.createDecryptor(keyWordArray, { iv: ivWordArray }); | |
| 37 | + */ | |
| 38 | + static createDecryptor(key: Word32Array, props?: Partial<CipherProps>): AES; | |
| 39 | + /** | |
| 40 | + * Encrypt a message with key | |
| 41 | + * | |
| 42 | + * @param {Word32Array|string} message | |
| 43 | + * @param {Word32Array|string} key | |
| 44 | + * @param {Partial<AESProps>?} props | |
| 45 | + * @example | |
| 46 | + * var encryptedMessage = AES.encrypt("test", "pass"); | |
| 47 | + */ | |
| 48 | + static encrypt(message: Word32Array | string, key: Word32Array | string, props?: Partial<AESProps>): CipherParams; | |
| 49 | + /** | |
| 50 | + * Encrypt a encrypted message with key | |
| 51 | + * | |
| 52 | + * @param {CipherParams|string} cipherParams | |
| 53 | + * @param {Word32Array|string} key | |
| 54 | + * @param {Partial<AESProps>?} props | |
| 55 | + * @example | |
| 56 | + * var encryptedMessage = AES.decrypt(cipherProps, "pass"); | |
| 57 | + */ | |
| 58 | + static decrypt(cipherParams: CipherParams | string, key: Word32Array | string, props?: Partial<AESProps>): Word32Array; | |
| 59 | +} | ... | ... |
app/static/content/jscrypto/es6/AES.js
0 → 100644
| 1 | +import { Cipher } from "./lib/algorithm/cipher/Cipher"; | |
| 2 | +import { BlockCipher } from "./lib/algorithm/cipher/BlockCipher"; | |
| 3 | +import { PasswordBasedCipher } from "./lib/algorithm/cipher/PasswordBasedCipher"; | |
| 4 | +import { SerializableCipher } from "./lib/algorithm/cipher/SerializableCipher"; | |
| 5 | +// Lookup tables | |
| 6 | +const SBOX = []; | |
| 7 | +const INV_SBOX = []; | |
| 8 | +const SUB_MIX_0 = []; | |
| 9 | +const SUB_MIX_1 = []; | |
| 10 | +const SUB_MIX_2 = []; | |
| 11 | +const SUB_MIX_3 = []; | |
| 12 | +const INV_SUB_MIX_0 = []; | |
| 13 | +const INV_SUB_MIX_1 = []; | |
| 14 | +const INV_SUB_MIX_2 = []; | |
| 15 | +const INV_SUB_MIX_3 = []; | |
| 16 | +(function computeLookupTables() { | |
| 17 | + // Compute double table | |
| 18 | + const d = []; | |
| 19 | + for (let i = 0; i < 256; i++) { | |
| 20 | + if (i < 128) { | |
| 21 | + d[i] = i << 1; | |
| 22 | + } | |
| 23 | + else { | |
| 24 | + d[i] = (i << 1) ^ 0x11b; | |
| 25 | + } | |
| 26 | + } | |
| 27 | + // Walk GF(2^8) | |
| 28 | + let x = 0; | |
| 29 | + let xi = 0; | |
| 30 | + for (let i = 0; i < 256; i++) { | |
| 31 | + // Compute sbox | |
| 32 | + let sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4); | |
| 33 | + sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63; | |
| 34 | + SBOX[x] = sx; | |
| 35 | + INV_SBOX[sx] = x; | |
| 36 | + // Compute multiplication | |
| 37 | + const x2 = d[x]; | |
| 38 | + const x4 = d[x2]; | |
| 39 | + const x8 = d[x4]; | |
| 40 | + // Compute sub bytes, mix columns tables | |
| 41 | + let t = (d[sx] * 0x101) ^ (sx * 0x1010100); | |
| 42 | + SUB_MIX_0[x] = (t << 24) | (t >>> 8); | |
| 43 | + SUB_MIX_1[x] = (t << 16) | (t >>> 16); | |
| 44 | + SUB_MIX_2[x] = (t << 8) | (t >>> 24); | |
| 45 | + SUB_MIX_3[x] = t; | |
| 46 | + // Compute inv sub bytes, inv mix columns tables | |
| 47 | + t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100); | |
| 48 | + INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8); | |
| 49 | + INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16); | |
| 50 | + INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24); | |
| 51 | + INV_SUB_MIX_3[sx] = t; | |
| 52 | + // Compute next counter | |
| 53 | + if (!x) { | |
| 54 | + x = xi = 1; | |
| 55 | + } | |
| 56 | + else { | |
| 57 | + x = x2 ^ d[d[d[x8 ^ x2]]]; | |
| 58 | + xi ^= d[d[xi]]; | |
| 59 | + } | |
| 60 | + } | |
| 61 | +}()); | |
| 62 | +// Precomputed Rcon lookup | |
| 63 | +const RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36]; | |
| 64 | +export class AES extends BlockCipher { | |
| 65 | + constructor(props) { | |
| 66 | + super(props); | |
| 67 | + this._nRounds = 0; | |
| 68 | + this._keySchedule = []; | |
| 69 | + this._invKeySchedule = []; | |
| 70 | + this._props = props; | |
| 71 | + this._doReset(); | |
| 72 | + } | |
| 73 | + _doReset() { | |
| 74 | + let t; | |
| 75 | + // Skip reset of nRounds has been set before and key did not change | |
| 76 | + if (this._nRounds && this._keyPriorReset === this._key) { | |
| 77 | + return; | |
| 78 | + } | |
| 79 | + // Shortcuts | |
| 80 | + const key = this._keyPriorReset = this._key; | |
| 81 | + const keyWords = key.words; | |
| 82 | + const keySize = key.nSigBytes / 4; | |
| 83 | + // Compute number of rounds | |
| 84 | + const nRounds = this._nRounds = keySize + 6; | |
| 85 | + // Compute number of key schedule rows | |
| 86 | + const ksRows = (nRounds + 1) * 4; | |
| 87 | + // Compute key schedule | |
| 88 | + const keySchedule = this._keySchedule = []; | |
| 89 | + for (let ksRow = 0; ksRow < ksRows; ksRow++) { | |
| 90 | + if (ksRow < keySize) { | |
| 91 | + keySchedule[ksRow] = keyWords[ksRow]; | |
| 92 | + } | |
| 93 | + else { | |
| 94 | + t = keySchedule[ksRow - 1]; | |
| 95 | + if (!(ksRow % keySize)) { | |
| 96 | + // Rot word | |
| 97 | + t = (t << 8) | (t >>> 24); | |
| 98 | + // Sub word | |
| 99 | + t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff]; | |
| 100 | + // Mix Rcon | |
| 101 | + t ^= RCON[(ksRow / keySize) | 0] << 24; | |
| 102 | + } | |
| 103 | + else if (keySize > 6 && ksRow % keySize === 4) { | |
| 104 | + // Sub word | |
| 105 | + t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff]; | |
| 106 | + } | |
| 107 | + keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t; | |
| 108 | + } | |
| 109 | + } | |
| 110 | + // Compute inv key schedule | |
| 111 | + this._invKeySchedule = []; | |
| 112 | + for (let invKsRow = 0; invKsRow < ksRows; invKsRow++) { | |
| 113 | + const ksRow = ksRows - invKsRow; | |
| 114 | + if (invKsRow % 4) { | |
| 115 | + t = keySchedule[ksRow]; | |
| 116 | + } | |
| 117 | + else { | |
| 118 | + t = keySchedule[ksRow - 4]; | |
| 119 | + } | |
| 120 | + if (invKsRow < 4 || ksRow <= 4) { | |
| 121 | + this._invKeySchedule[invKsRow] = t; | |
| 122 | + } | |
| 123 | + else { | |
| 124 | + this._invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^ | |
| 125 | + INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]]; | |
| 126 | + } | |
| 127 | + } | |
| 128 | + } | |
| 129 | + encryptBlock(words, offset) { | |
| 130 | + this._doCryptBlock(words, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX); | |
| 131 | + } | |
| 132 | + decryptBlock(words, offset) { | |
| 133 | + // Swap 2nd and 4th rows | |
| 134 | + let t = words[offset + 1]; | |
| 135 | + words[offset + 1] = words[offset + 3]; | |
| 136 | + words[offset + 3] = t; | |
| 137 | + this._doCryptBlock(words, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX); | |
| 138 | + // Inv swap 2nd and 4th rows | |
| 139 | + t = words[offset + 1]; | |
| 140 | + words[offset + 1] = words[offset + 3]; | |
| 141 | + words[offset + 3] = t; | |
| 142 | + } | |
| 143 | + _doCryptBlock(words, offset, keySchedule, subMix0, subMix1, subMix2, subMix3, sBox) { | |
| 144 | + // Shortcut | |
| 145 | + const nRounds = this._nRounds; | |
| 146 | + // Get input, add round key | |
| 147 | + let s0 = words[offset] ^ keySchedule[0]; | |
| 148 | + let s1 = words[offset + 1] ^ keySchedule[1]; | |
| 149 | + let s2 = words[offset + 2] ^ keySchedule[2]; | |
| 150 | + let s3 = words[offset + 3] ^ keySchedule[3]; | |
| 151 | + // Key schedule row counter | |
| 152 | + let ksRow = 4; | |
| 153 | + // Rounds | |
| 154 | + for (let round = 1; round < nRounds; round++) { | |
| 155 | + // Shift rows, sub bytes, mix columns, add round key | |
| 156 | + const _s0 = subMix0[s0 >>> 24] ^ subMix1[(s1 >>> 16) & 0xff] | |
| 157 | + ^ subMix2[(s2 >>> 8) & 0xff] ^ subMix3[s3 & 0xff] ^ keySchedule[ksRow++]; | |
| 158 | + const _s1 = subMix0[s1 >>> 24] ^ subMix1[(s2 >>> 16) & 0xff] | |
| 159 | + ^ subMix2[(s3 >>> 8) & 0xff] ^ subMix3[s0 & 0xff] ^ keySchedule[ksRow++]; | |
| 160 | + const _s2 = subMix0[s2 >>> 24] ^ subMix1[(s3 >>> 16) & 0xff] | |
| 161 | + ^ subMix2[(s0 >>> 8) & 0xff] ^ subMix3[s1 & 0xff] ^ keySchedule[ksRow++]; | |
| 162 | + const _s3 = subMix0[s3 >>> 24] ^ subMix1[(s0 >>> 16) & 0xff] | |
| 163 | + ^ subMix2[(s1 >>> 8) & 0xff] ^ subMix3[s2 & 0xff] ^ keySchedule[ksRow++]; | |
| 164 | + // Update state | |
| 165 | + s0 = _s0; | |
| 166 | + s1 = _s1; | |
| 167 | + s2 = _s2; | |
| 168 | + s3 = _s3; | |
| 169 | + } | |
| 170 | + // Shift rows, sub bytes, add round key | |
| 171 | + const t0 = ((sBox[s0 >>> 24] << 24) | (sBox[(s1 >>> 16) & 0xff] << 16) | |
| 172 | + | (sBox[(s2 >>> 8) & 0xff] << 8) | sBox[s3 & 0xff]) ^ keySchedule[ksRow++]; | |
| 173 | + const t1 = ((sBox[s1 >>> 24] << 24) | (sBox[(s2 >>> 16) & 0xff] << 16) | |
| 174 | + | (sBox[(s3 >>> 8) & 0xff] << 8) | sBox[s0 & 0xff]) ^ keySchedule[ksRow++]; | |
| 175 | + const t2 = ((sBox[s2 >>> 24] << 24) | (sBox[(s3 >>> 16) & 0xff] << 16) | |
| 176 | + | (sBox[(s0 >>> 8) & 0xff] << 8) | sBox[s1 & 0xff]) ^ keySchedule[ksRow++]; | |
| 177 | + const t3 = ((sBox[s3 >>> 24] << 24) | (sBox[(s0 >>> 16) & 0xff] << 16) | |
| 178 | + | (sBox[(s1 >>> 8) & 0xff] << 8) | sBox[s2 & 0xff]) ^ keySchedule[ksRow++]; | |
| 179 | + // Set output | |
| 180 | + words[offset] = t0; | |
| 181 | + words[offset + 1] = t1; | |
| 182 | + words[offset + 2] = t2; | |
| 183 | + words[offset + 3] = t3; | |
| 184 | + } | |
| 185 | + /** | |
| 186 | + * Creates this cipher in encryption mode. | |
| 187 | + * | |
| 188 | + * @param {Word32Array} key The key. | |
| 189 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 190 | + * @return {Cipher} A cipher instance. | |
| 191 | + * @example | |
| 192 | + * var cipher = AES.createEncryptor(keyWordArray, { iv: ivWordArray }); | |
| 193 | + */ | |
| 194 | + static createEncryptor(key, props) { | |
| 195 | + props = typeof props === "undefined" ? {} : props; | |
| 196 | + return new AES(Object.assign(Object.assign({}, props), { key, transformMode: Cipher.ENC_TRANSFORM_MODE })); | |
| 197 | + } | |
| 198 | + /** | |
| 199 | + * Creates this cipher in decryption mode. | |
| 200 | + * | |
| 201 | + * @param {Word32Array} key The key. | |
| 202 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 203 | + * @return {Cipher} A cipher instance. | |
| 204 | + * @example | |
| 205 | + * var cipher = AES.createDecryptor(keyWordArray, { iv: ivWordArray }); | |
| 206 | + */ | |
| 207 | + static createDecryptor(key, props) { | |
| 208 | + props = typeof props === "undefined" ? {} : props; | |
| 209 | + return new AES(Object.assign(Object.assign({}, props), { key, transformMode: Cipher.DEC_TRANSFORM_MODE })); | |
| 210 | + } | |
| 211 | + /** | |
| 212 | + * Encrypt a message with key | |
| 213 | + * | |
| 214 | + * @param {Word32Array|string} message | |
| 215 | + * @param {Word32Array|string} key | |
| 216 | + * @param {Partial<AESProps>?} props | |
| 217 | + * @example | |
| 218 | + * var encryptedMessage = AES.encrypt("test", "pass"); | |
| 219 | + */ | |
| 220 | + static encrypt(message, key, props) { | |
| 221 | + if (typeof key === "string") { | |
| 222 | + return PasswordBasedCipher.encrypt(AES, message, key, props); | |
| 223 | + } | |
| 224 | + if (key.nSigBytes % 4 !== 0) { | |
| 225 | + throw new Error("Key size must be multiple of 32bit/4byte/1word"); | |
| 226 | + } | |
| 227 | + return SerializableCipher.encrypt(AES, message, key, props); | |
| 228 | + } | |
| 229 | + /** | |
| 230 | + * Encrypt a encrypted message with key | |
| 231 | + * | |
| 232 | + * @param {CipherParams|string} cipherParams | |
| 233 | + * @param {Word32Array|string} key | |
| 234 | + * @param {Partial<AESProps>?} props | |
| 235 | + * @example | |
| 236 | + * var encryptedMessage = AES.decrypt(cipherProps, "pass"); | |
| 237 | + */ | |
| 238 | + static decrypt(cipherParams, key, props) { | |
| 239 | + if (typeof key === "string") { | |
| 240 | + return PasswordBasedCipher.decrypt(AES, cipherParams, key, props); | |
| 241 | + } | |
| 242 | + if (key.nSigBytes % 4 !== 0) { | |
| 243 | + throw new Error("Key size must be multiple of 32bit/4byte/1word"); | |
| 244 | + } | |
| 245 | + return SerializableCipher.decrypt(AES, cipherParams, key, props); | |
| 246 | + } | |
| 247 | +} | |
| 248 | +AES.keySize = 256 / 32; | ... | ... |
app/static/content/jscrypto/es6/Base64.d.ts
0 → 100644
| 1 | +export { Base64 } from "./lib/encoder/Base64"; | ... | ... |
app/static/content/jscrypto/es6/Base64.js
0 → 100644
| 1 | +export { Base64 } from "./lib/encoder/Base64"; | ... | ... |
app/static/content/jscrypto/es6/CBCMAC.d.ts
0 → 100644
| 1 | +import { Word32Array } from "./lib/Word32Array"; | |
| 2 | +import { BlockCipher } from "./lib/algorithm/cipher/BlockCipher"; | |
| 3 | +export declare type CBCMACProps = { | |
| 4 | + Cipher: typeof BlockCipher; | |
| 5 | +}; | |
| 6 | +export declare function CBCMAC(plainText: Word32Array | string, associatedData: Word32Array | string, key: Word32Array | string, iv: Word32Array | null, tagLength?: number, props?: Partial<CBCMACProps>): Word32Array; | ... | ... |
app/static/content/jscrypto/es6/CBCMAC.js
0 → 100644
| 1 | +import { Utf8 } from "./lib/encoder/Utf8"; | |
| 2 | +import { Word32Array } from "./lib/Word32Array"; | |
| 3 | +import { AES } from "./AES"; | |
| 4 | +import { CCM } from "./mode/CCM"; | |
| 5 | +export function CBCMAC(plainText, associatedData, key, iv, tagLength, props) { | |
| 6 | + const Cipher = (props && props.Cipher) ? props.Cipher : AES; | |
| 7 | + const K = typeof key === "string" ? Utf8.parse(key) : key; | |
| 8 | + const N = iv ? iv : new Word32Array([0, 0]); | |
| 9 | + const A = typeof associatedData === "string" ? Utf8.parse(associatedData) : associatedData; | |
| 10 | + const P = typeof plainText === "string" ? Utf8.parse(plainText) : plainText; | |
| 11 | + const t = tagLength || 16; | |
| 12 | + return CCM.mac(Cipher, K, N, A, P, t); | |
| 13 | +} | ... | ... |
| 1 | +export { CipherParams } from "./lib/algorithm/cipher/CipherParams"; | ... | ... |
| 1 | +export { CipherParams } from "./lib/algorithm/cipher/CipherParams"; | ... | ... |
app/static/content/jscrypto/es6/DES.d.ts
0 → 100644
| 1 | +import { BlockCipher, BlockCipherProps } from "./lib/algorithm/cipher/BlockCipher"; | |
| 2 | +import { CipherProps, PropsWithKey } from "./lib/algorithm/cipher/Cipher"; | |
| 3 | +import { Word32Array } from "./lib/Word32Array"; | |
| 4 | +import { CipherParams } from "./lib/algorithm/cipher/CipherParams"; | |
| 5 | +export interface DESProps extends BlockCipherProps { | |
| 6 | +} | |
| 7 | +export declare class DES extends BlockCipher { | |
| 8 | + static readonly keySize: number; | |
| 9 | + static readonly ivSize: number; | |
| 10 | + protected _blockSize: number; | |
| 11 | + _props: PropsWithKey<DESProps>; | |
| 12 | + protected _subKeys: number[][]; | |
| 13 | + protected _invSubKeys: number[][]; | |
| 14 | + protected _lBlock: number; | |
| 15 | + protected _rBlock: number; | |
| 16 | + constructor(props: PropsWithKey<DESProps>); | |
| 17 | + protected _doReset(): void; | |
| 18 | + encryptBlock(words: number[], offset: number): void; | |
| 19 | + decryptBlock(words: number[], offset: number): void; | |
| 20 | + protected _doCryptoBlock(words: number[], offset: number, subKeys: number[][]): void; | |
| 21 | + protected _exchangeLR(offset: number, mask: number): void; | |
| 22 | + protected _exchangeRL(offset: number, mask: number): void; | |
| 23 | + /** | |
| 24 | + * Creates this cipher in encryption mode. | |
| 25 | + * | |
| 26 | + * @param {Word32Array} key The key. | |
| 27 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 28 | + * @return {Cipher} A cipher instance. | |
| 29 | + * @example | |
| 30 | + * var cipher = DES.createEncryptor(keyWordArray, { iv: ivWordArray }); | |
| 31 | + */ | |
| 32 | + static createEncryptor(key: Word32Array, props?: Partial<CipherProps>): DES; | |
| 33 | + /** | |
| 34 | + * Creates this cipher in decryption mode. | |
| 35 | + * | |
| 36 | + * @param {Word32Array} key The key. | |
| 37 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 38 | + * @return {Cipher} A cipher instance. | |
| 39 | + * @example | |
| 40 | + * var cipher = DES.createDecryptor(keyWordArray, { iv: ivWordArray }); | |
| 41 | + */ | |
| 42 | + static createDecryptor(key: Word32Array, props?: Partial<CipherProps>): DES; | |
| 43 | + /** | |
| 44 | + * Encrypt a message with key | |
| 45 | + * | |
| 46 | + * @param {Word32Array|string} message | |
| 47 | + * @param {Word32Array|string} key | |
| 48 | + * @param {Partial<AESProps>?} props | |
| 49 | + * @example | |
| 50 | + * var encryptedMessage = DES.encrypt("test", "pass"); | |
| 51 | + */ | |
| 52 | + static encrypt(message: Word32Array | string, key: Word32Array | string, props?: Partial<DESProps>): CipherParams; | |
| 53 | + /** | |
| 54 | + * Encrypt a encrypted message with key | |
| 55 | + * | |
| 56 | + * @param {CipherParams} cipherText | |
| 57 | + * @param {Word32Array|string} key | |
| 58 | + * @param {Partial<AESProps>?} props | |
| 59 | + * @example | |
| 60 | + * var encryptedMessage = DES.decrypt(cipherProps, "pass"); | |
| 61 | + */ | |
| 62 | + static decrypt(cipherText: CipherParams, key: Word32Array | string, props?: Partial<DESProps>): Word32Array; | |
| 63 | +} | ... | ... |
app/static/content/jscrypto/es6/DES.js
0 → 100644
| 1 | +// Permuted Choice 1 constants | |
| 2 | +import { BlockCipher } from "./lib/algorithm/cipher/BlockCipher"; | |
| 3 | +import { Cipher } from "./lib/algorithm/cipher/Cipher"; | |
| 4 | +import { PasswordBasedCipher } from "./lib/algorithm/cipher/PasswordBasedCipher"; | |
| 5 | +import { SerializableCipher } from "./lib/algorithm/cipher/SerializableCipher"; | |
| 6 | +const PC1 = [ | |
| 7 | + 57, 49, 41, 33, 25, 17, 9, 1, | |
| 8 | + 58, 50, 42, 34, 26, 18, 10, 2, | |
| 9 | + 59, 51, 43, 35, 27, 19, 11, 3, | |
| 10 | + 60, 52, 44, 36, 63, 55, 47, 39, | |
| 11 | + 31, 23, 15, 7, 62, 54, 46, 38, | |
| 12 | + 30, 22, 14, 6, 61, 53, 45, 37, | |
| 13 | + 29, 21, 13, 5, 28, 20, 12, 4 | |
| 14 | +]; | |
| 15 | +// Permuted Choice 2 constants | |
| 16 | +const PC2 = [ | |
| 17 | + 14, 17, 11, 24, 1, 5, | |
| 18 | + 3, 28, 15, 6, 21, 10, | |
| 19 | + 23, 19, 12, 4, 26, 8, | |
| 20 | + 16, 7, 27, 20, 13, 2, | |
| 21 | + 41, 52, 31, 37, 47, 55, | |
| 22 | + 30, 40, 51, 45, 33, 48, | |
| 23 | + 44, 49, 39, 56, 34, 53, | |
| 24 | + 46, 42, 50, 36, 29, 32 | |
| 25 | +]; | |
| 26 | +// Cumulative bit shift constants | |
| 27 | +const BIT_SHIFTS = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28]; | |
| 28 | +// SBOXes and round permutation constants | |
| 29 | +const SBOX_P = [ | |
| 30 | + { | |
| 31 | + 0x0: 0x808200, | |
| 32 | + 0x10000000: 0x8000, | |
| 33 | + 0x20000000: 0x808002, | |
| 34 | + 0x30000000: 0x2, | |
| 35 | + 0x40000000: 0x200, | |
| 36 | + 0x50000000: 0x808202, | |
| 37 | + 0x60000000: 0x800202, | |
| 38 | + 0x70000000: 0x800000, | |
| 39 | + 0x80000000: 0x202, | |
| 40 | + 0x90000000: 0x800200, | |
| 41 | + 0xa0000000: 0x8200, | |
| 42 | + 0xb0000000: 0x808000, | |
| 43 | + 0xc0000000: 0x8002, | |
| 44 | + 0xd0000000: 0x800002, | |
| 45 | + 0xe0000000: 0x0, | |
| 46 | + 0xf0000000: 0x8202, | |
| 47 | + 0x8000000: 0x0, | |
| 48 | + 0x18000000: 0x808202, | |
| 49 | + 0x28000000: 0x8202, | |
| 50 | + 0x38000000: 0x8000, | |
| 51 | + 0x48000000: 0x808200, | |
| 52 | + 0x58000000: 0x200, | |
| 53 | + 0x68000000: 0x808002, | |
| 54 | + 0x78000000: 0x2, | |
| 55 | + 0x88000000: 0x800200, | |
| 56 | + 0x98000000: 0x8200, | |
| 57 | + 0xa8000000: 0x808000, | |
| 58 | + 0xb8000000: 0x800202, | |
| 59 | + 0xc8000000: 0x800002, | |
| 60 | + 0xd8000000: 0x8002, | |
| 61 | + 0xe8000000: 0x202, | |
| 62 | + 0xf8000000: 0x800000, | |
| 63 | + 0x1: 0x8000, | |
| 64 | + 0x10000001: 0x2, | |
| 65 | + 0x20000001: 0x808200, | |
| 66 | + 0x30000001: 0x800000, | |
| 67 | + 0x40000001: 0x808002, | |
| 68 | + 0x50000001: 0x8200, | |
| 69 | + 0x60000001: 0x200, | |
| 70 | + 0x70000001: 0x800202, | |
| 71 | + 0x80000001: 0x808202, | |
| 72 | + 0x90000001: 0x808000, | |
| 73 | + 0xa0000001: 0x800002, | |
| 74 | + 0xb0000001: 0x8202, | |
| 75 | + 0xc0000001: 0x202, | |
| 76 | + 0xd0000001: 0x800200, | |
| 77 | + 0xe0000001: 0x8002, | |
| 78 | + 0xf0000001: 0x0, | |
| 79 | + 0x8000001: 0x808202, | |
| 80 | + 0x18000001: 0x808000, | |
| 81 | + 0x28000001: 0x800000, | |
| 82 | + 0x38000001: 0x200, | |
| 83 | + 0x48000001: 0x8000, | |
| 84 | + 0x58000001: 0x800002, | |
| 85 | + 0x68000001: 0x2, | |
| 86 | + 0x78000001: 0x8202, | |
| 87 | + 0x88000001: 0x8002, | |
| 88 | + 0x98000001: 0x800202, | |
| 89 | + 0xa8000001: 0x202, | |
| 90 | + 0xb8000001: 0x808200, | |
| 91 | + 0xc8000001: 0x800200, | |
| 92 | + 0xd8000001: 0x0, | |
| 93 | + 0xe8000001: 0x8200, | |
| 94 | + 0xf8000001: 0x808002 | |
| 95 | + }, | |
| 96 | + { | |
| 97 | + 0x0: 0x40084010, | |
| 98 | + 0x1000000: 0x4000, | |
| 99 | + 0x2000000: 0x80000, | |
| 100 | + 0x3000000: 0x40080010, | |
| 101 | + 0x4000000: 0x40000010, | |
| 102 | + 0x5000000: 0x40084000, | |
| 103 | + 0x6000000: 0x40004000, | |
| 104 | + 0x7000000: 0x10, | |
| 105 | + 0x8000000: 0x84000, | |
| 106 | + 0x9000000: 0x40004010, | |
| 107 | + 0xa000000: 0x40000000, | |
| 108 | + 0xb000000: 0x84010, | |
| 109 | + 0xc000000: 0x80010, | |
| 110 | + 0xd000000: 0x0, | |
| 111 | + 0xe000000: 0x4010, | |
| 112 | + 0xf000000: 0x40080000, | |
| 113 | + 0x800000: 0x40004000, | |
| 114 | + 0x1800000: 0x84010, | |
| 115 | + 0x2800000: 0x10, | |
| 116 | + 0x3800000: 0x40004010, | |
| 117 | + 0x4800000: 0x40084010, | |
| 118 | + 0x5800000: 0x40000000, | |
| 119 | + 0x6800000: 0x80000, | |
| 120 | + 0x7800000: 0x40080010, | |
| 121 | + 0x8800000: 0x80010, | |
| 122 | + 0x9800000: 0x0, | |
| 123 | + 0xa800000: 0x4000, | |
| 124 | + 0xb800000: 0x40080000, | |
| 125 | + 0xc800000: 0x40000010, | |
| 126 | + 0xd800000: 0x84000, | |
| 127 | + 0xe800000: 0x40084000, | |
| 128 | + 0xf800000: 0x4010, | |
| 129 | + 0x10000000: 0x0, | |
| 130 | + 0x11000000: 0x40080010, | |
| 131 | + 0x12000000: 0x40004010, | |
| 132 | + 0x13000000: 0x40084000, | |
| 133 | + 0x14000000: 0x40080000, | |
| 134 | + 0x15000000: 0x10, | |
| 135 | + 0x16000000: 0x84010, | |
| 136 | + 0x17000000: 0x4000, | |
| 137 | + 0x18000000: 0x4010, | |
| 138 | + 0x19000000: 0x80000, | |
| 139 | + 0x1a000000: 0x80010, | |
| 140 | + 0x1b000000: 0x40000010, | |
| 141 | + 0x1c000000: 0x84000, | |
| 142 | + 0x1d000000: 0x40004000, | |
| 143 | + 0x1e000000: 0x40000000, | |
| 144 | + 0x1f000000: 0x40084010, | |
| 145 | + 0x10800000: 0x84010, | |
| 146 | + 0x11800000: 0x80000, | |
| 147 | + 0x12800000: 0x40080000, | |
| 148 | + 0x13800000: 0x4000, | |
| 149 | + 0x14800000: 0x40004000, | |
| 150 | + 0x15800000: 0x40084010, | |
| 151 | + 0x16800000: 0x10, | |
| 152 | + 0x17800000: 0x40000000, | |
| 153 | + 0x18800000: 0x40084000, | |
| 154 | + 0x19800000: 0x40000010, | |
| 155 | + 0x1a800000: 0x40004010, | |
| 156 | + 0x1b800000: 0x80010, | |
| 157 | + 0x1c800000: 0x0, | |
| 158 | + 0x1d800000: 0x4010, | |
| 159 | + 0x1e800000: 0x40080010, | |
| 160 | + 0x1f800000: 0x84000 | |
| 161 | + }, | |
| 162 | + { | |
| 163 | + 0x0: 0x104, | |
| 164 | + 0x100000: 0x0, | |
| 165 | + 0x200000: 0x4000100, | |
| 166 | + 0x300000: 0x10104, | |
| 167 | + 0x400000: 0x10004, | |
| 168 | + 0x500000: 0x4000004, | |
| 169 | + 0x600000: 0x4010104, | |
| 170 | + 0x700000: 0x4010000, | |
| 171 | + 0x800000: 0x4000000, | |
| 172 | + 0x900000: 0x4010100, | |
| 173 | + 0xa00000: 0x10100, | |
| 174 | + 0xb00000: 0x4010004, | |
| 175 | + 0xc00000: 0x4000104, | |
| 176 | + 0xd00000: 0x10000, | |
| 177 | + 0xe00000: 0x4, | |
| 178 | + 0xf00000: 0x100, | |
| 179 | + 0x80000: 0x4010100, | |
| 180 | + 0x180000: 0x4010004, | |
| 181 | + 0x280000: 0x0, | |
| 182 | + 0x380000: 0x4000100, | |
| 183 | + 0x480000: 0x4000004, | |
| 184 | + 0x580000: 0x10000, | |
| 185 | + 0x680000: 0x10004, | |
| 186 | + 0x780000: 0x104, | |
| 187 | + 0x880000: 0x4, | |
| 188 | + 0x980000: 0x100, | |
| 189 | + 0xa80000: 0x4010000, | |
| 190 | + 0xb80000: 0x10104, | |
| 191 | + 0xc80000: 0x10100, | |
| 192 | + 0xd80000: 0x4000104, | |
| 193 | + 0xe80000: 0x4010104, | |
| 194 | + 0xf80000: 0x4000000, | |
| 195 | + 0x1000000: 0x4010100, | |
| 196 | + 0x1100000: 0x10004, | |
| 197 | + 0x1200000: 0x10000, | |
| 198 | + 0x1300000: 0x4000100, | |
| 199 | + 0x1400000: 0x100, | |
| 200 | + 0x1500000: 0x4010104, | |
| 201 | + 0x1600000: 0x4000004, | |
| 202 | + 0x1700000: 0x0, | |
| 203 | + 0x1800000: 0x4000104, | |
| 204 | + 0x1900000: 0x4000000, | |
| 205 | + 0x1a00000: 0x4, | |
| 206 | + 0x1b00000: 0x10100, | |
| 207 | + 0x1c00000: 0x4010000, | |
| 208 | + 0x1d00000: 0x104, | |
| 209 | + 0x1e00000: 0x10104, | |
| 210 | + 0x1f00000: 0x4010004, | |
| 211 | + 0x1080000: 0x4000000, | |
| 212 | + 0x1180000: 0x104, | |
| 213 | + 0x1280000: 0x4010100, | |
| 214 | + 0x1380000: 0x0, | |
| 215 | + 0x1480000: 0x10004, | |
| 216 | + 0x1580000: 0x4000100, | |
| 217 | + 0x1680000: 0x100, | |
| 218 | + 0x1780000: 0x4010004, | |
| 219 | + 0x1880000: 0x10000, | |
| 220 | + 0x1980000: 0x4010104, | |
| 221 | + 0x1a80000: 0x10104, | |
| 222 | + 0x1b80000: 0x4000004, | |
| 223 | + 0x1c80000: 0x4000104, | |
| 224 | + 0x1d80000: 0x4010000, | |
| 225 | + 0x1e80000: 0x4, | |
| 226 | + 0x1f80000: 0x10100 | |
| 227 | + }, | |
| 228 | + { | |
| 229 | + 0x0: 0x80401000, | |
| 230 | + 0x10000: 0x80001040, | |
| 231 | + 0x20000: 0x401040, | |
| 232 | + 0x30000: 0x80400000, | |
| 233 | + 0x40000: 0x0, | |
| 234 | + 0x50000: 0x401000, | |
| 235 | + 0x60000: 0x80000040, | |
| 236 | + 0x70000: 0x400040, | |
| 237 | + 0x80000: 0x80000000, | |
| 238 | + 0x90000: 0x400000, | |
| 239 | + 0xa0000: 0x40, | |
| 240 | + 0xb0000: 0x80001000, | |
| 241 | + 0xc0000: 0x80400040, | |
| 242 | + 0xd0000: 0x1040, | |
| 243 | + 0xe0000: 0x1000, | |
| 244 | + 0xf0000: 0x80401040, | |
| 245 | + 0x8000: 0x80001040, | |
| 246 | + 0x18000: 0x40, | |
| 247 | + 0x28000: 0x80400040, | |
| 248 | + 0x38000: 0x80001000, | |
| 249 | + 0x48000: 0x401000, | |
| 250 | + 0x58000: 0x80401040, | |
| 251 | + 0x68000: 0x0, | |
| 252 | + 0x78000: 0x80400000, | |
| 253 | + 0x88000: 0x1000, | |
| 254 | + 0x98000: 0x80401000, | |
| 255 | + 0xa8000: 0x400000, | |
| 256 | + 0xb8000: 0x1040, | |
| 257 | + 0xc8000: 0x80000000, | |
| 258 | + 0xd8000: 0x400040, | |
| 259 | + 0xe8000: 0x401040, | |
| 260 | + 0xf8000: 0x80000040, | |
| 261 | + 0x100000: 0x400040, | |
| 262 | + 0x110000: 0x401000, | |
| 263 | + 0x120000: 0x80000040, | |
| 264 | + 0x130000: 0x0, | |
| 265 | + 0x140000: 0x1040, | |
| 266 | + 0x150000: 0x80400040, | |
| 267 | + 0x160000: 0x80401000, | |
| 268 | + 0x170000: 0x80001040, | |
| 269 | + 0x180000: 0x80401040, | |
| 270 | + 0x190000: 0x80000000, | |
| 271 | + 0x1a0000: 0x80400000, | |
| 272 | + 0x1b0000: 0x401040, | |
| 273 | + 0x1c0000: 0x80001000, | |
| 274 | + 0x1d0000: 0x400000, | |
| 275 | + 0x1e0000: 0x40, | |
| 276 | + 0x1f0000: 0x1000, | |
| 277 | + 0x108000: 0x80400000, | |
| 278 | + 0x118000: 0x80401040, | |
| 279 | + 0x128000: 0x0, | |
| 280 | + 0x138000: 0x401000, | |
| 281 | + 0x148000: 0x400040, | |
| 282 | + 0x158000: 0x80000000, | |
| 283 | + 0x168000: 0x80001040, | |
| 284 | + 0x178000: 0x40, | |
| 285 | + 0x188000: 0x80000040, | |
| 286 | + 0x198000: 0x1000, | |
| 287 | + 0x1a8000: 0x80001000, | |
| 288 | + 0x1b8000: 0x80400040, | |
| 289 | + 0x1c8000: 0x1040, | |
| 290 | + 0x1d8000: 0x80401000, | |
| 291 | + 0x1e8000: 0x400000, | |
| 292 | + 0x1f8000: 0x401040 | |
| 293 | + }, | |
| 294 | + { | |
| 295 | + 0x0: 0x80, | |
| 296 | + 0x1000: 0x1040000, | |
| 297 | + 0x2000: 0x40000, | |
| 298 | + 0x3000: 0x20000000, | |
| 299 | + 0x4000: 0x20040080, | |
| 300 | + 0x5000: 0x1000080, | |
| 301 | + 0x6000: 0x21000080, | |
| 302 | + 0x7000: 0x40080, | |
| 303 | + 0x8000: 0x1000000, | |
| 304 | + 0x9000: 0x20040000, | |
| 305 | + 0xa000: 0x20000080, | |
| 306 | + 0xb000: 0x21040080, | |
| 307 | + 0xc000: 0x21040000, | |
| 308 | + 0xd000: 0x0, | |
| 309 | + 0xe000: 0x1040080, | |
| 310 | + 0xf000: 0x21000000, | |
| 311 | + 0x800: 0x1040080, | |
| 312 | + 0x1800: 0x21000080, | |
| 313 | + 0x2800: 0x80, | |
| 314 | + 0x3800: 0x1040000, | |
| 315 | + 0x4800: 0x40000, | |
| 316 | + 0x5800: 0x20040080, | |
| 317 | + 0x6800: 0x21040000, | |
| 318 | + 0x7800: 0x20000000, | |
| 319 | + 0x8800: 0x20040000, | |
| 320 | + 0x9800: 0x0, | |
| 321 | + 0xa800: 0x21040080, | |
| 322 | + 0xb800: 0x1000080, | |
| 323 | + 0xc800: 0x20000080, | |
| 324 | + 0xd800: 0x21000000, | |
| 325 | + 0xe800: 0x1000000, | |
| 326 | + 0xf800: 0x40080, | |
| 327 | + 0x10000: 0x40000, | |
| 328 | + 0x11000: 0x80, | |
| 329 | + 0x12000: 0x20000000, | |
| 330 | + 0x13000: 0x21000080, | |
| 331 | + 0x14000: 0x1000080, | |
| 332 | + 0x15000: 0x21040000, | |
| 333 | + 0x16000: 0x20040080, | |
| 334 | + 0x17000: 0x1000000, | |
| 335 | + 0x18000: 0x21040080, | |
| 336 | + 0x19000: 0x21000000, | |
| 337 | + 0x1a000: 0x1040000, | |
| 338 | + 0x1b000: 0x20040000, | |
| 339 | + 0x1c000: 0x40080, | |
| 340 | + 0x1d000: 0x20000080, | |
| 341 | + 0x1e000: 0x0, | |
| 342 | + 0x1f000: 0x1040080, | |
| 343 | + 0x10800: 0x21000080, | |
| 344 | + 0x11800: 0x1000000, | |
| 345 | + 0x12800: 0x1040000, | |
| 346 | + 0x13800: 0x20040080, | |
| 347 | + 0x14800: 0x20000000, | |
| 348 | + 0x15800: 0x1040080, | |
| 349 | + 0x16800: 0x80, | |
| 350 | + 0x17800: 0x21040000, | |
| 351 | + 0x18800: 0x40080, | |
| 352 | + 0x19800: 0x21040080, | |
| 353 | + 0x1a800: 0x0, | |
| 354 | + 0x1b800: 0x21000000, | |
| 355 | + 0x1c800: 0x1000080, | |
| 356 | + 0x1d800: 0x40000, | |
| 357 | + 0x1e800: 0x20040000, | |
| 358 | + 0x1f800: 0x20000080 | |
| 359 | + }, | |
| 360 | + { | |
| 361 | + 0x0: 0x10000008, | |
| 362 | + 0x100: 0x2000, | |
| 363 | + 0x200: 0x10200000, | |
| 364 | + 0x300: 0x10202008, | |
| 365 | + 0x400: 0x10002000, | |
| 366 | + 0x500: 0x200000, | |
| 367 | + 0x600: 0x200008, | |
| 368 | + 0x700: 0x10000000, | |
| 369 | + 0x800: 0x0, | |
| 370 | + 0x900: 0x10002008, | |
| 371 | + 0xa00: 0x202000, | |
| 372 | + 0xb00: 0x8, | |
| 373 | + 0xc00: 0x10200008, | |
| 374 | + 0xd00: 0x202008, | |
| 375 | + 0xe00: 0x2008, | |
| 376 | + 0xf00: 0x10202000, | |
| 377 | + 0x80: 0x10200000, | |
| 378 | + 0x180: 0x10202008, | |
| 379 | + 0x280: 0x8, | |
| 380 | + 0x380: 0x200000, | |
| 381 | + 0x480: 0x202008, | |
| 382 | + 0x580: 0x10000008, | |
| 383 | + 0x680: 0x10002000, | |
| 384 | + 0x780: 0x2008, | |
| 385 | + 0x880: 0x200008, | |
| 386 | + 0x980: 0x2000, | |
| 387 | + 0xa80: 0x10002008, | |
| 388 | + 0xb80: 0x10200008, | |
| 389 | + 0xc80: 0x0, | |
| 390 | + 0xd80: 0x10202000, | |
| 391 | + 0xe80: 0x202000, | |
| 392 | + 0xf80: 0x10000000, | |
| 393 | + 0x1000: 0x10002000, | |
| 394 | + 0x1100: 0x10200008, | |
| 395 | + 0x1200: 0x10202008, | |
| 396 | + 0x1300: 0x2008, | |
| 397 | + 0x1400: 0x200000, | |
| 398 | + 0x1500: 0x10000000, | |
| 399 | + 0x1600: 0x10000008, | |
| 400 | + 0x1700: 0x202000, | |
| 401 | + 0x1800: 0x202008, | |
| 402 | + 0x1900: 0x0, | |
| 403 | + 0x1a00: 0x8, | |
| 404 | + 0x1b00: 0x10200000, | |
| 405 | + 0x1c00: 0x2000, | |
| 406 | + 0x1d00: 0x10002008, | |
| 407 | + 0x1e00: 0x10202000, | |
| 408 | + 0x1f00: 0x200008, | |
| 409 | + 0x1080: 0x8, | |
| 410 | + 0x1180: 0x202000, | |
| 411 | + 0x1280: 0x200000, | |
| 412 | + 0x1380: 0x10000008, | |
| 413 | + 0x1480: 0x10002000, | |
| 414 | + 0x1580: 0x2008, | |
| 415 | + 0x1680: 0x10202008, | |
| 416 | + 0x1780: 0x10200000, | |
| 417 | + 0x1880: 0x10202000, | |
| 418 | + 0x1980: 0x10200008, | |
| 419 | + 0x1a80: 0x2000, | |
| 420 | + 0x1b80: 0x202008, | |
| 421 | + 0x1c80: 0x200008, | |
| 422 | + 0x1d80: 0x0, | |
| 423 | + 0x1e80: 0x10000000, | |
| 424 | + 0x1f80: 0x10002008 | |
| 425 | + }, | |
| 426 | + { | |
| 427 | + 0x0: 0x100000, | |
| 428 | + 0x10: 0x2000401, | |
| 429 | + 0x20: 0x400, | |
| 430 | + 0x30: 0x100401, | |
| 431 | + 0x40: 0x2100401, | |
| 432 | + 0x50: 0x0, | |
| 433 | + 0x60: 0x1, | |
| 434 | + 0x70: 0x2100001, | |
| 435 | + 0x80: 0x2000400, | |
| 436 | + 0x90: 0x100001, | |
| 437 | + 0xa0: 0x2000001, | |
| 438 | + 0xb0: 0x2100400, | |
| 439 | + 0xc0: 0x2100000, | |
| 440 | + 0xd0: 0x401, | |
| 441 | + 0xe0: 0x100400, | |
| 442 | + 0xf0: 0x2000000, | |
| 443 | + 0x8: 0x2100001, | |
| 444 | + 0x18: 0x0, | |
| 445 | + 0x28: 0x2000401, | |
| 446 | + 0x38: 0x2100400, | |
| 447 | + 0x48: 0x100000, | |
| 448 | + 0x58: 0x2000001, | |
| 449 | + 0x68: 0x2000000, | |
| 450 | + 0x78: 0x401, | |
| 451 | + 0x88: 0x100401, | |
| 452 | + 0x98: 0x2000400, | |
| 453 | + 0xa8: 0x2100000, | |
| 454 | + 0xb8: 0x100001, | |
| 455 | + 0xc8: 0x400, | |
| 456 | + 0xd8: 0x2100401, | |
| 457 | + 0xe8: 0x1, | |
| 458 | + 0xf8: 0x100400, | |
| 459 | + 0x100: 0x2000000, | |
| 460 | + 0x110: 0x100000, | |
| 461 | + 0x120: 0x2000401, | |
| 462 | + 0x130: 0x2100001, | |
| 463 | + 0x140: 0x100001, | |
| 464 | + 0x150: 0x2000400, | |
| 465 | + 0x160: 0x2100400, | |
| 466 | + 0x170: 0x100401, | |
| 467 | + 0x180: 0x401, | |
| 468 | + 0x190: 0x2100401, | |
| 469 | + 0x1a0: 0x100400, | |
| 470 | + 0x1b0: 0x1, | |
| 471 | + 0x1c0: 0x0, | |
| 472 | + 0x1d0: 0x2100000, | |
| 473 | + 0x1e0: 0x2000001, | |
| 474 | + 0x1f0: 0x400, | |
| 475 | + 0x108: 0x100400, | |
| 476 | + 0x118: 0x2000401, | |
| 477 | + 0x128: 0x2100001, | |
| 478 | + 0x138: 0x1, | |
| 479 | + 0x148: 0x2000000, | |
| 480 | + 0x158: 0x100000, | |
| 481 | + 0x168: 0x401, | |
| 482 | + 0x178: 0x2100400, | |
| 483 | + 0x188: 0x2000001, | |
| 484 | + 0x198: 0x2100000, | |
| 485 | + 0x1a8: 0x0, | |
| 486 | + 0x1b8: 0x2100401, | |
| 487 | + 0x1c8: 0x100401, | |
| 488 | + 0x1d8: 0x400, | |
| 489 | + 0x1e8: 0x2000400, | |
| 490 | + 0x1f8: 0x100001 | |
| 491 | + }, | |
| 492 | + { | |
| 493 | + 0x0: 0x8000820, | |
| 494 | + 0x1: 0x20000, | |
| 495 | + 0x2: 0x8000000, | |
| 496 | + 0x3: 0x20, | |
| 497 | + 0x4: 0x20020, | |
| 498 | + 0x5: 0x8020820, | |
| 499 | + 0x6: 0x8020800, | |
| 500 | + 0x7: 0x800, | |
| 501 | + 0x8: 0x8020000, | |
| 502 | + 0x9: 0x8000800, | |
| 503 | + 0xa: 0x20800, | |
| 504 | + 0xb: 0x8020020, | |
| 505 | + 0xc: 0x820, | |
| 506 | + 0xd: 0x0, | |
| 507 | + 0xe: 0x8000020, | |
| 508 | + 0xf: 0x20820, | |
| 509 | + 0x80000000: 0x800, | |
| 510 | + 0x80000001: 0x8020820, | |
| 511 | + 0x80000002: 0x8000820, | |
| 512 | + 0x80000003: 0x8000000, | |
| 513 | + 0x80000004: 0x8020000, | |
| 514 | + 0x80000005: 0x20800, | |
| 515 | + 0x80000006: 0x20820, | |
| 516 | + 0x80000007: 0x20, | |
| 517 | + 0x80000008: 0x8000020, | |
| 518 | + 0x80000009: 0x820, | |
| 519 | + 0x8000000a: 0x20020, | |
| 520 | + 0x8000000b: 0x8020800, | |
| 521 | + 0x8000000c: 0x0, | |
| 522 | + 0x8000000d: 0x8020020, | |
| 523 | + 0x8000000e: 0x8000800, | |
| 524 | + 0x8000000f: 0x20000, | |
| 525 | + 0x10: 0x20820, | |
| 526 | + 0x11: 0x8020800, | |
| 527 | + 0x12: 0x20, | |
| 528 | + 0x13: 0x800, | |
| 529 | + 0x14: 0x8000800, | |
| 530 | + 0x15: 0x8000020, | |
| 531 | + 0x16: 0x8020020, | |
| 532 | + 0x17: 0x20000, | |
| 533 | + 0x18: 0x0, | |
| 534 | + 0x19: 0x20020, | |
| 535 | + 0x1a: 0x8020000, | |
| 536 | + 0x1b: 0x8000820, | |
| 537 | + 0x1c: 0x8020820, | |
| 538 | + 0x1d: 0x20800, | |
| 539 | + 0x1e: 0x820, | |
| 540 | + 0x1f: 0x8000000, | |
| 541 | + 0x80000010: 0x20000, | |
| 542 | + 0x80000011: 0x800, | |
| 543 | + 0x80000012: 0x8020020, | |
| 544 | + 0x80000013: 0x20820, | |
| 545 | + 0x80000014: 0x20, | |
| 546 | + 0x80000015: 0x8020000, | |
| 547 | + 0x80000016: 0x8000000, | |
| 548 | + 0x80000017: 0x8000820, | |
| 549 | + 0x80000018: 0x8020820, | |
| 550 | + 0x80000019: 0x8000020, | |
| 551 | + 0x8000001a: 0x8000800, | |
| 552 | + 0x8000001b: 0x0, | |
| 553 | + 0x8000001c: 0x20800, | |
| 554 | + 0x8000001d: 0x820, | |
| 555 | + 0x8000001e: 0x20020, | |
| 556 | + 0x8000001f: 0x8020800 | |
| 557 | + } | |
| 558 | +]; | |
| 559 | +// Masks that select the SBOX input | |
| 560 | +const SBOX_MASK = [ | |
| 561 | + 0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000, | |
| 562 | + 0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f | |
| 563 | +]; | |
| 564 | +export class DES extends BlockCipher { | |
| 565 | + constructor(props) { | |
| 566 | + super(props); | |
| 567 | + this._blockSize = 64 / 32; | |
| 568 | + this._subKeys = []; | |
| 569 | + this._invSubKeys = []; | |
| 570 | + this._lBlock = 0; | |
| 571 | + this._rBlock = 0; | |
| 572 | + this._props = props; | |
| 573 | + this._doReset(); | |
| 574 | + } | |
| 575 | + _doReset() { | |
| 576 | + // Shortcuts | |
| 577 | + const key = this._key; | |
| 578 | + const keyWords = key.words; | |
| 579 | + // Select 56 bits according to PC1 | |
| 580 | + const keyBits = []; | |
| 581 | + for (let i = 0; i < 56; i++) { | |
| 582 | + const keyBitPos = PC1[i] - 1; | |
| 583 | + keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1; | |
| 584 | + } | |
| 585 | + // Assemble 16 subkeys | |
| 586 | + const subKeys = this._subKeys = []; | |
| 587 | + for (let nSubKey = 0; nSubKey < 16; nSubKey++) { | |
| 588 | + // Create subkey | |
| 589 | + const subKey = subKeys[nSubKey] = []; | |
| 590 | + // Shortcut | |
| 591 | + const bitShift = BIT_SHIFTS[nSubKey]; | |
| 592 | + // Select 48 bits according to PC2 | |
| 593 | + for (let i = 0; i < 24; i++) { | |
| 594 | + // Select from the left 28 key bits | |
| 595 | + subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6); | |
| 596 | + // Select from the right 28 key bits | |
| 597 | + subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6); | |
| 598 | + } | |
| 599 | + // Since each subkey is applied to an expanded 32-bit input, | |
| 600 | + // the subkey can be broken into 8 values scaled to 32-bits, | |
| 601 | + // which allows the key to be used without expansion | |
| 602 | + subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31); | |
| 603 | + for (let i = 1; i < 7; i++) { | |
| 604 | + subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3); | |
| 605 | + } | |
| 606 | + subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27); | |
| 607 | + } | |
| 608 | + // Compute inverse subkeys | |
| 609 | + this._invSubKeys = []; | |
| 610 | + for (let i = 0; i < 16; i++) { | |
| 611 | + this._invSubKeys[i] = subKeys[15 - i]; | |
| 612 | + } | |
| 613 | + } | |
| 614 | + encryptBlock(words, offset) { | |
| 615 | + this._doCryptoBlock(words, offset, this._subKeys); | |
| 616 | + } | |
| 617 | + decryptBlock(words, offset) { | |
| 618 | + this._doCryptoBlock(words, offset, this._invSubKeys); | |
| 619 | + } | |
| 620 | + _doCryptoBlock(words, offset, subKeys) { | |
| 621 | + // Get input | |
| 622 | + this._lBlock = words[offset]; | |
| 623 | + this._rBlock = words[offset + 1]; | |
| 624 | + // Initial permutation | |
| 625 | + this._exchangeLR(4, 0x0f0f0f0f); | |
| 626 | + this._exchangeLR(16, 0x0000ffff); | |
| 627 | + this._exchangeRL(2, 0x33333333); | |
| 628 | + this._exchangeRL(8, 0x00ff00ff); | |
| 629 | + this._exchangeLR(1, 0x55555555); | |
| 630 | + // Rounds | |
| 631 | + for (let round = 0; round < 16; round++) { | |
| 632 | + // Shortcuts | |
| 633 | + const subKey = subKeys[round]; | |
| 634 | + const lBlock = this._lBlock; | |
| 635 | + const rBlock = this._rBlock; | |
| 636 | + // Feistel function | |
| 637 | + let f = 0; | |
| 638 | + for (let i = 0; i < 8; i++) { | |
| 639 | + const s = ((rBlock ^ subKey[i]) & SBOX_MASK[i]); | |
| 640 | + f |= SBOX_P[i][s >>> 0]; | |
| 641 | + } | |
| 642 | + this._lBlock = rBlock; | |
| 643 | + this._rBlock = lBlock ^ f; | |
| 644 | + } | |
| 645 | + // Undo swap from last round | |
| 646 | + const t = this._lBlock; | |
| 647 | + this._lBlock = this._rBlock; | |
| 648 | + this._rBlock = t; | |
| 649 | + // Final permutation | |
| 650 | + this._exchangeLR(1, 0x55555555); | |
| 651 | + this._exchangeRL(8, 0x00ff00ff); | |
| 652 | + this._exchangeRL(2, 0x33333333); | |
| 653 | + this._exchangeLR(16, 0x0000ffff); | |
| 654 | + this._exchangeLR(4, 0x0f0f0f0f); | |
| 655 | + // Set output | |
| 656 | + words[offset] = this._lBlock; | |
| 657 | + words[offset + 1] = this._rBlock; | |
| 658 | + } | |
| 659 | + _exchangeLR(offset, mask) { | |
| 660 | + const t = ((this._lBlock >>> offset) ^ this._rBlock) & mask; | |
| 661 | + this._rBlock ^= t; | |
| 662 | + this._lBlock ^= t << offset; | |
| 663 | + } | |
| 664 | + _exchangeRL(offset, mask) { | |
| 665 | + const t = ((this._rBlock >>> offset) ^ this._lBlock) & mask; | |
| 666 | + this._lBlock ^= t; | |
| 667 | + this._rBlock ^= t << offset; | |
| 668 | + } | |
| 669 | + /** | |
| 670 | + * Creates this cipher in encryption mode. | |
| 671 | + * | |
| 672 | + * @param {Word32Array} key The key. | |
| 673 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 674 | + * @return {Cipher} A cipher instance. | |
| 675 | + * @example | |
| 676 | + * var cipher = DES.createEncryptor(keyWordArray, { iv: ivWordArray }); | |
| 677 | + */ | |
| 678 | + static createEncryptor(key, props) { | |
| 679 | + props = typeof props === "undefined" ? {} : props; | |
| 680 | + return new DES(Object.assign(Object.assign({}, props), { key, transformMode: Cipher.ENC_TRANSFORM_MODE })); | |
| 681 | + } | |
| 682 | + /** | |
| 683 | + * Creates this cipher in decryption mode. | |
| 684 | + * | |
| 685 | + * @param {Word32Array} key The key. | |
| 686 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 687 | + * @return {Cipher} A cipher instance. | |
| 688 | + * @example | |
| 689 | + * var cipher = DES.createDecryptor(keyWordArray, { iv: ivWordArray }); | |
| 690 | + */ | |
| 691 | + static createDecryptor(key, props) { | |
| 692 | + props = typeof props === "undefined" ? {} : props; | |
| 693 | + return new DES(Object.assign(Object.assign({}, props), { key, transformMode: Cipher.DEC_TRANSFORM_MODE })); | |
| 694 | + } | |
| 695 | + /** | |
| 696 | + * Encrypt a message with key | |
| 697 | + * | |
| 698 | + * @param {Word32Array|string} message | |
| 699 | + * @param {Word32Array|string} key | |
| 700 | + * @param {Partial<AESProps>?} props | |
| 701 | + * @example | |
| 702 | + * var encryptedMessage = DES.encrypt("test", "pass"); | |
| 703 | + */ | |
| 704 | + static encrypt(message, key, props) { | |
| 705 | + if (typeof key === "string") { | |
| 706 | + return PasswordBasedCipher.encrypt(DES, message, key, props); | |
| 707 | + } | |
| 708 | + return SerializableCipher.encrypt(DES, message, key, props); | |
| 709 | + } | |
| 710 | + /** | |
| 711 | + * Encrypt a encrypted message with key | |
| 712 | + * | |
| 713 | + * @param {CipherParams} cipherText | |
| 714 | + * @param {Word32Array|string} key | |
| 715 | + * @param {Partial<AESProps>?} props | |
| 716 | + * @example | |
| 717 | + * var encryptedMessage = DES.decrypt(cipherProps, "pass"); | |
| 718 | + */ | |
| 719 | + static decrypt(cipherText, key, props) { | |
| 720 | + if (typeof key === "string") { | |
| 721 | + return PasswordBasedCipher.decrypt(DES, cipherText, key, props); | |
| 722 | + } | |
| 723 | + return SerializableCipher.decrypt(DES, cipherText, key, props); | |
| 724 | + } | |
| 725 | +} | |
| 726 | +DES.keySize = 64 / 32; | |
| 727 | +DES.ivSize = 64 / 32; | ... | ... |
app/static/content/jscrypto/es6/DES3.d.ts
0 → 100644
| 1 | +import { BlockCipher, BlockCipherProps } from "./lib/algorithm/cipher/BlockCipher"; | |
| 2 | +import { CipherProps, PropsWithKey } from "./lib/algorithm/cipher/Cipher"; | |
| 3 | +import { DES } from "./DES"; | |
| 4 | +import { Word32Array } from "./lib/Word32Array"; | |
| 5 | +import { CipherParams } from "./lib/algorithm/cipher/CipherParams"; | |
| 6 | +export interface DES3Props extends BlockCipherProps { | |
| 7 | +} | |
| 8 | +export declare class DES3 extends BlockCipher { | |
| 9 | + static readonly keySize: number; | |
| 10 | + static readonly ivSize: number; | |
| 11 | + protected _blockSize: number; | |
| 12 | + protected _des1: DES; | |
| 13 | + protected _des2: DES; | |
| 14 | + protected _des3: DES; | |
| 15 | + constructor(props: PropsWithKey<DES3Props>); | |
| 16 | + protected _get3DES(): DES[]; | |
| 17 | + protected _doReset(): void; | |
| 18 | + encryptBlock(words: number[], offset: number): void; | |
| 19 | + decryptBlock(words: number[], offset: number): void; | |
| 20 | + /** | |
| 21 | + * Creates this cipher in encryption mode. | |
| 22 | + * | |
| 23 | + * @param {Word32Array} key The key. | |
| 24 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 25 | + * @return {Cipher} A cipher instance. | |
| 26 | + * @example | |
| 27 | + * var cipher = DES3.createEncryptor(keyWordArray, { iv: ivWordArray }); | |
| 28 | + */ | |
| 29 | + static createEncryptor(key: Word32Array, props?: Partial<CipherProps>): DES3; | |
| 30 | + /** | |
| 31 | + * Creates this cipher in decryption mode. | |
| 32 | + * | |
| 33 | + * @param {Word32Array} key The key. | |
| 34 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 35 | + * @return {Cipher} A cipher instance. | |
| 36 | + * @example | |
| 37 | + * var cipher = DES3.createDecryptor(keyWordArray, { iv: ivWordArray }); | |
| 38 | + */ | |
| 39 | + static createDecryptor(key: Word32Array, props?: Partial<CipherProps>): DES3; | |
| 40 | + /** | |
| 41 | + * Encrypt a message with key | |
| 42 | + * | |
| 43 | + * @param {Word32Array|string} message | |
| 44 | + * @param {Word32Array|string} key | |
| 45 | + * @param {Partial<AESProps>?} props | |
| 46 | + * @example | |
| 47 | + * var encryptedMessage = DES3.encrypt("test", "pass"); | |
| 48 | + */ | |
| 49 | + static encrypt(message: Word32Array | string, key: Word32Array | string, props?: Partial<DES3Props>): CipherParams; | |
| 50 | + /** | |
| 51 | + * Encrypt a encrypted message with key | |
| 52 | + * | |
| 53 | + * @param {CipherParams} cipherText | |
| 54 | + * @param {Word32Array|string} key | |
| 55 | + * @param {Partial<AESProps>?} props | |
| 56 | + * @example | |
| 57 | + * var encryptedMessage = DES3.decrypt(cipherProps, "pass"); | |
| 58 | + */ | |
| 59 | + static decrypt(cipherText: CipherParams, key: Word32Array | string, props?: Partial<DES3Props>): Word32Array; | |
| 60 | +} | ... | ... |
app/static/content/jscrypto/es6/DES3.js
0 → 100644
| 1 | +import { SerializableCipher } from "./lib/algorithm/cipher/SerializableCipher"; | |
| 2 | +import { BlockCipher } from "./lib/algorithm/cipher/BlockCipher"; | |
| 3 | +import { Cipher } from "./lib/algorithm/cipher/Cipher"; | |
| 4 | +import { DES } from "./DES"; | |
| 5 | +import { Word32Array } from "./lib/Word32Array"; | |
| 6 | +import { PasswordBasedCipher } from "./lib/algorithm/cipher/PasswordBasedCipher"; | |
| 7 | +export class DES3 extends BlockCipher { | |
| 8 | + constructor(props) { | |
| 9 | + super(props); | |
| 10 | + this._blockSize = 64 / 32; | |
| 11 | + this._props = props; | |
| 12 | + const TripleDES = this._get3DES(); | |
| 13 | + // Create DES instances | |
| 14 | + this._des1 = TripleDES[0]; | |
| 15 | + this._des2 = TripleDES[1]; | |
| 16 | + this._des3 = TripleDES[2]; | |
| 17 | + } | |
| 18 | + _get3DES() { | |
| 19 | + // Shortcuts | |
| 20 | + const key = this._key; | |
| 21 | + const keyWords = key.words; | |
| 22 | + // Make sure the key length is valid (64, 128 or >= 192 bit) | |
| 23 | + if (keyWords.length !== 2 && keyWords.length !== 4 && keyWords.length < 6) { | |
| 24 | + throw new Error("Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192."); | |
| 25 | + } | |
| 26 | + // Extend the key according to the keying options defined in 3DES standard | |
| 27 | + const key1 = keyWords.slice(0, 2); | |
| 28 | + const key2 = keyWords.length < 4 ? keyWords.slice(0, 2) : keyWords.slice(2, 4); | |
| 29 | + const key3 = keyWords.length < 6 ? keyWords.slice(0, 2) : keyWords.slice(4, 6); | |
| 30 | + // Create DES instances | |
| 31 | + const des1 = DES.createEncryptor(new Word32Array(key1)); | |
| 32 | + const des2 = DES.createEncryptor(new Word32Array(key2)); | |
| 33 | + const des3 = DES.createEncryptor(new Word32Array(key3)); | |
| 34 | + return [des1, des2, des3]; | |
| 35 | + } | |
| 36 | + _doReset() { | |
| 37 | + const TripleDES = this._get3DES(); | |
| 38 | + // Create DES instances | |
| 39 | + this._des1 = TripleDES[0]; | |
| 40 | + this._des2 = TripleDES[1]; | |
| 41 | + this._des3 = TripleDES[2]; | |
| 42 | + } | |
| 43 | + encryptBlock(words, offset) { | |
| 44 | + this._des1.encryptBlock(words, offset); | |
| 45 | + this._des2.decryptBlock(words, offset); | |
| 46 | + this._des3.encryptBlock(words, offset); | |
| 47 | + } | |
| 48 | + decryptBlock(words, offset) { | |
| 49 | + this._des3.decryptBlock(words, offset); | |
| 50 | + this._des2.encryptBlock(words, offset); | |
| 51 | + this._des1.decryptBlock(words, offset); | |
| 52 | + } | |
| 53 | + /** | |
| 54 | + * Creates this cipher in encryption mode. | |
| 55 | + * | |
| 56 | + * @param {Word32Array} key The key. | |
| 57 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 58 | + * @return {Cipher} A cipher instance. | |
| 59 | + * @example | |
| 60 | + * var cipher = DES3.createEncryptor(keyWordArray, { iv: ivWordArray }); | |
| 61 | + */ | |
| 62 | + static createEncryptor(key, props) { | |
| 63 | + props = typeof props === "undefined" ? {} : props; | |
| 64 | + return new DES3(Object.assign(Object.assign({}, props), { key, transformMode: Cipher.ENC_TRANSFORM_MODE })); | |
| 65 | + } | |
| 66 | + /** | |
| 67 | + * Creates this cipher in decryption mode. | |
| 68 | + * | |
| 69 | + * @param {Word32Array} key The key. | |
| 70 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 71 | + * @return {Cipher} A cipher instance. | |
| 72 | + * @example | |
| 73 | + * var cipher = DES3.createDecryptor(keyWordArray, { iv: ivWordArray }); | |
| 74 | + */ | |
| 75 | + static createDecryptor(key, props) { | |
| 76 | + props = typeof props === "undefined" ? {} : props; | |
| 77 | + return new DES3(Object.assign(Object.assign({}, props), { key, transformMode: Cipher.DEC_TRANSFORM_MODE })); | |
| 78 | + } | |
| 79 | + /** | |
| 80 | + * Encrypt a message with key | |
| 81 | + * | |
| 82 | + * @param {Word32Array|string} message | |
| 83 | + * @param {Word32Array|string} key | |
| 84 | + * @param {Partial<AESProps>?} props | |
| 85 | + * @example | |
| 86 | + * var encryptedMessage = DES3.encrypt("test", "pass"); | |
| 87 | + */ | |
| 88 | + static encrypt(message, key, props) { | |
| 89 | + if (typeof key === "string") { | |
| 90 | + return PasswordBasedCipher.encrypt(DES3, message, key, props); | |
| 91 | + } | |
| 92 | + return SerializableCipher.encrypt(DES3, message, key, props); | |
| 93 | + } | |
| 94 | + /** | |
| 95 | + * Encrypt a encrypted message with key | |
| 96 | + * | |
| 97 | + * @param {CipherParams} cipherText | |
| 98 | + * @param {Word32Array|string} key | |
| 99 | + * @param {Partial<AESProps>?} props | |
| 100 | + * @example | |
| 101 | + * var encryptedMessage = DES3.decrypt(cipherProps, "pass"); | |
| 102 | + */ | |
| 103 | + static decrypt(cipherText, key, props) { | |
| 104 | + if (typeof key === "string") { | |
| 105 | + return PasswordBasedCipher.decrypt(DES3, cipherText, key, props); | |
| 106 | + } | |
| 107 | + return SerializableCipher.decrypt(DES3, cipherText, key, props); | |
| 108 | + } | |
| 109 | +} | |
| 110 | +DES3.keySize = 192 / 32; | |
| 111 | +DES3.ivSize = 64 / 32; | ... | ... |
app/static/content/jscrypto/es6/EvpKDF.d.ts
0 → 100644
| 1 | +export { EvpKDF } from "./lib/algorithm/cipher/kdf/module/EvpKDF"; | ... | ... |
app/static/content/jscrypto/es6/EvpKDF.js
0 → 100644
| 1 | +export { EvpKDF } from "./lib/algorithm/cipher/kdf/module/EvpKDF"; | ... | ... |
app/static/content/jscrypto/es6/GMAC.d.ts
0 → 100644
| 1 | +import { Word32Array } from "./lib/Word32Array"; | |
| 2 | +import { BlockCipher } from "./lib/algorithm/cipher/BlockCipher"; | |
| 3 | +export declare type GMACProps = { | |
| 4 | + Cipher: typeof BlockCipher; | |
| 5 | +}; | |
| 6 | +export declare function GMAC(message: Word32Array | string, key: Word32Array | string, iv?: Word32Array, tagLength?: number, props?: Partial<GMACProps>): Word32Array; | ... | ... |
app/static/content/jscrypto/es6/GMAC.js
0 → 100644
| 1 | +import { Utf8 } from "./lib/encoder/Utf8"; | |
| 2 | +import { Word32Array } from "./lib/Word32Array"; | |
| 3 | +import { AES } from "./AES"; | |
| 4 | +import { GCM } from "./mode/GCM"; | |
| 5 | +export function GMAC(message, key, iv, tagLength, props) { | |
| 6 | + const aad = typeof message === "string" ? Utf8.parse(message) : message; | |
| 7 | + const initializingVector = iv ? iv : new Word32Array([0, 0, 0, 0]); | |
| 8 | + const Cipher = (props && props.Cipher) ? props.Cipher : AES; | |
| 9 | + const wKey = typeof key === "string" ? Utf8.parse(key) : key; | |
| 10 | + const t = tagLength || 16; | |
| 11 | + return GCM.mac(Cipher, wKey, initializingVector, aad, undefined, t); | |
| 12 | +} | ... | ... |
app/static/content/jscrypto/es6/Hex.d.ts
0 → 100644
| 1 | +export { Hex } from "./lib/encoder/Hex"; | ... | ... |
app/static/content/jscrypto/es6/Hex.js
0 → 100644
| 1 | +export { Hex } from "./lib/encoder/Hex"; | ... | ... |
app/static/content/jscrypto/es6/Hmac.d.ts
0 → 100644
| 1 | +import type { Hasher } from "./lib/algorithm/Hasher"; | |
| 2 | +import type { Word32Array } from "./lib/Word32Array"; | |
| 3 | +export declare class Hmac { | |
| 4 | + private _hasher; | |
| 5 | + private _oKey; | |
| 6 | + private _iKey; | |
| 7 | + constructor(hasher: Hasher, key: Word32Array | string); | |
| 8 | + /** | |
| 9 | + * Resets this Hmac to its initial state. | |
| 10 | + * | |
| 11 | + * @example | |
| 12 | + * hmacHasher.reset(); | |
| 13 | + */ | |
| 14 | + reset(): void; | |
| 15 | + /** | |
| 16 | + * Updates this Hmac with a message. | |
| 17 | + * | |
| 18 | + * @param {Word32Array|string} messageUpdate The message to append. | |
| 19 | + * @return {Hmac} This Hmac instance. | |
| 20 | + * @example | |
| 21 | + * hmacHasher.update('message'); | |
| 22 | + * hmacHasher.update(wordArray); | |
| 23 | + */ | |
| 24 | + update(messageUpdate: Word32Array | string): this; | |
| 25 | + /** | |
| 26 | + * Finalizes the Hmac computation. | |
| 27 | + * Note that the finalize operation is effectively a destructive, read-once operation. | |
| 28 | + * | |
| 29 | + * @param {Word32Array|string} messageUpdate (Optional) A final message update. | |
| 30 | + * @return {Word32Array} The Hmac. | |
| 31 | + * @example | |
| 32 | + * var hmac = hmacHasher.finalize(); | |
| 33 | + * var hmac = hmacHasher.finalize('message'); | |
| 34 | + * var hmac = hmacHasher.finalize(wordArray); | |
| 35 | + */ | |
| 36 | + finalize(messageUpdate: Word32Array | string): Word32Array; | |
| 37 | +} | ... | ... |
app/static/content/jscrypto/es6/Hmac.js
0 → 100644
| 1 | +import { Utf8 } from "./lib/encoder/Utf8"; | |
| 2 | +export class Hmac { | |
| 3 | + constructor(hasher, key) { | |
| 4 | + this._hasher = hasher; | |
| 5 | + // Convert string to WordArray, else assume WordArray already | |
| 6 | + if (typeof key == "string") { | |
| 7 | + key = Utf8.parse(key); | |
| 8 | + } | |
| 9 | + const hasherBlockSize = hasher.blockSize; | |
| 10 | + const hasherBlockSizeBytes = hasherBlockSize * 4; | |
| 11 | + // Allow arbitrary length keys | |
| 12 | + if (key.nSigBytes > hasherBlockSizeBytes) { | |
| 13 | + key = hasher.finalize(key); | |
| 14 | + } | |
| 15 | + // Clamp excess bits | |
| 16 | + key.clamp(); | |
| 17 | + const oKey = this._oKey = key.clone(); | |
| 18 | + const iKey = this._iKey = key.clone(); | |
| 19 | + const oKeyWords = oKey.words; | |
| 20 | + const iKeyWords = iKey.words; | |
| 21 | + for (let i = 0; i < hasherBlockSize; i++) { | |
| 22 | + oKeyWords[i] ^= 0x5c5c5c5c; | |
| 23 | + iKeyWords[i] ^= 0x36363636; | |
| 24 | + } | |
| 25 | + iKey.nSigBytes = hasherBlockSizeBytes; | |
| 26 | + oKey.nSigBytes = hasherBlockSizeBytes; | |
| 27 | + // Set initial values | |
| 28 | + this.reset(); | |
| 29 | + } | |
| 30 | + /** | |
| 31 | + * Resets this Hmac to its initial state. | |
| 32 | + * | |
| 33 | + * @example | |
| 34 | + * hmacHasher.reset(); | |
| 35 | + */ | |
| 36 | + reset() { | |
| 37 | + this._hasher.reset(); | |
| 38 | + this._hasher.update(this._iKey); | |
| 39 | + } | |
| 40 | + /** | |
| 41 | + * Updates this Hmac with a message. | |
| 42 | + * | |
| 43 | + * @param {Word32Array|string} messageUpdate The message to append. | |
| 44 | + * @return {Hmac} This Hmac instance. | |
| 45 | + * @example | |
| 46 | + * hmacHasher.update('message'); | |
| 47 | + * hmacHasher.update(wordArray); | |
| 48 | + */ | |
| 49 | + update(messageUpdate) { | |
| 50 | + this._hasher.update(messageUpdate); | |
| 51 | + return this; | |
| 52 | + } | |
| 53 | + /** | |
| 54 | + * Finalizes the Hmac computation. | |
| 55 | + * Note that the finalize operation is effectively a destructive, read-once operation. | |
| 56 | + * | |
| 57 | + * @param {Word32Array|string} messageUpdate (Optional) A final message update. | |
| 58 | + * @return {Word32Array} The Hmac. | |
| 59 | + * @example | |
| 60 | + * var hmac = hmacHasher.finalize(); | |
| 61 | + * var hmac = hmacHasher.finalize('message'); | |
| 62 | + * var hmac = hmacHasher.finalize(wordArray); | |
| 63 | + */ | |
| 64 | + finalize(messageUpdate) { | |
| 65 | + const innerHash = this._hasher.finalize(messageUpdate); | |
| 66 | + this._hasher.reset(); | |
| 67 | + return this._hasher.finalize(this._oKey.clone().concat(innerHash)); | |
| 68 | + } | |
| 69 | +} | ... | ... |
app/static/content/jscrypto/es6/HmacMD5.d.ts
0 → 100644
app/static/content/jscrypto/es6/HmacMD5.js
0 → 100644
app/static/content/jscrypto/es6/HmacSHA1.js
0 → 100644
app/static/content/jscrypto/es6/Latin1.d.ts
0 → 100644
| 1 | +export { Latin1 } from "./lib/encoder/Latin1"; | ... | ... |
app/static/content/jscrypto/es6/Latin1.js
0 → 100644
| 1 | +export { Latin1 } from "./lib/encoder/Latin1"; | ... | ... |
app/static/content/jscrypto/es6/MD5.d.ts
0 → 100644
| 1 | +import { Word32Array } from "./lib/Word32Array"; | |
| 2 | +import { Hasher, HasherProps } from "./lib/algorithm/Hasher"; | |
| 3 | +export interface MD5Props extends HasherProps { | |
| 4 | + hash: Word32Array; | |
| 5 | +} | |
| 6 | +/** | |
| 7 | + * MD5 hash algorithm | |
| 8 | + */ | |
| 9 | +export declare class MD5 extends Hasher { | |
| 10 | + private _hash; | |
| 11 | + constructor(props?: MD5Props); | |
| 12 | + protected _doReset(): void; | |
| 13 | + protected _doProcessBlock(words: number[], offset: number): void; | |
| 14 | + protected _doFinalize(): Word32Array; | |
| 15 | + clone(): MD5; | |
| 16 | + static hash(message: Word32Array | string): Word32Array; | |
| 17 | +} | ... | ... |
app/static/content/jscrypto/es6/MD5.js
0 → 100644
| 1 | +import { Word32Array } from "./lib/Word32Array"; | |
| 2 | +import { Hasher } from "./lib/algorithm/Hasher"; | |
| 3 | +// Constants table | |
| 4 | +const T = []; | |
| 5 | +(function computeConstant() { | |
| 6 | + for (let i = 0; i < 64; i++) { | |
| 7 | + T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0; | |
| 8 | + } | |
| 9 | +})(); | |
| 10 | +function FF(a, b, c, d, x, s, t) { | |
| 11 | + const n = a + ((b & c) | (~b & d)) + x + t; | |
| 12 | + return ((n << s) | (n >>> (32 - s))) + b; | |
| 13 | +} | |
| 14 | +function GG(a, b, c, d, x, s, t) { | |
| 15 | + const n = a + ((b & d) | (c & ~d)) + x + t; | |
| 16 | + return ((n << s) | (n >>> (32 - s))) + b; | |
| 17 | +} | |
| 18 | +function HH(a, b, c, d, x, s, t) { | |
| 19 | + const n = a + (b ^ c ^ d) + x + t; | |
| 20 | + return ((n << s) | (n >>> (32 - s))) + b; | |
| 21 | +} | |
| 22 | +function II(a, b, c, d, x, s, t) { | |
| 23 | + const n = a + (c ^ (b | ~d)) + x + t; | |
| 24 | + return ((n << s) | (n >>> (32 - s))) + b; | |
| 25 | +} | |
| 26 | +/** | |
| 27 | + * MD5 hash algorithm | |
| 28 | + */ | |
| 29 | +export class MD5 extends Hasher { | |
| 30 | + constructor(props) { | |
| 31 | + super(props); | |
| 32 | + this._hash = new Word32Array([ | |
| 33 | + 0x67452301, 0xefcdab89, | |
| 34 | + 0x98badcfe, 0x10325476 | |
| 35 | + ]); | |
| 36 | + if (props && typeof props.hash !== "undefined") { | |
| 37 | + this._hash = props.hash.clone(); | |
| 38 | + } | |
| 39 | + } | |
| 40 | + _doReset() { | |
| 41 | + this._hash = new Word32Array([ | |
| 42 | + 0x67452301, 0xefcdab89, | |
| 43 | + 0x98badcfe, 0x10325476 | |
| 44 | + ]); | |
| 45 | + } | |
| 46 | + _doProcessBlock(words, offset) { | |
| 47 | + // Swap endian | |
| 48 | + for (let i = 0; i < 16; i++) { | |
| 49 | + // Shortcuts | |
| 50 | + const offsetI = offset + i; | |
| 51 | + const wordsOffsetI = words[offsetI]; | |
| 52 | + words[offsetI] = ((((wordsOffsetI << 8) | (wordsOffsetI >>> 24)) & 0x00ff00ff) | |
| 53 | + | (((wordsOffsetI << 24) | (wordsOffsetI >>> 8)) & 0xff00ff00)); | |
| 54 | + } | |
| 55 | + // Shortcuts | |
| 56 | + const H = this._hash.words; | |
| 57 | + const wordOffset0 = words[offset]; | |
| 58 | + const wordOffset1 = words[offset + 1]; | |
| 59 | + const wordOffset2 = words[offset + 2]; | |
| 60 | + const wordOffset3 = words[offset + 3]; | |
| 61 | + const wordOffset4 = words[offset + 4]; | |
| 62 | + const wordOffset5 = words[offset + 5]; | |
| 63 | + const wordOffset6 = words[offset + 6]; | |
| 64 | + const wordOffset7 = words[offset + 7]; | |
| 65 | + const wordOffset8 = words[offset + 8]; | |
| 66 | + const wordOffset9 = words[offset + 9]; | |
| 67 | + const wordOffset10 = words[offset + 10]; | |
| 68 | + const wordOffset11 = words[offset + 11]; | |
| 69 | + const wordOffset12 = words[offset + 12]; | |
| 70 | + const wordOffset13 = words[offset + 13]; | |
| 71 | + const wordOffset14 = words[offset + 14]; | |
| 72 | + const wordOffset15 = words[offset + 15]; | |
| 73 | + // Working variables | |
| 74 | + let a = H[0]; | |
| 75 | + let b = H[1]; | |
| 76 | + let c = H[2]; | |
| 77 | + let d = H[3]; | |
| 78 | + // Computation | |
| 79 | + a = FF(a, b, c, d, wordOffset0, 7, T[0]); | |
| 80 | + d = FF(d, a, b, c, wordOffset1, 12, T[1]); | |
| 81 | + c = FF(c, d, a, b, wordOffset2, 17, T[2]); | |
| 82 | + b = FF(b, c, d, a, wordOffset3, 22, T[3]); | |
| 83 | + a = FF(a, b, c, d, wordOffset4, 7, T[4]); | |
| 84 | + d = FF(d, a, b, c, wordOffset5, 12, T[5]); | |
| 85 | + c = FF(c, d, a, b, wordOffset6, 17, T[6]); | |
| 86 | + b = FF(b, c, d, a, wordOffset7, 22, T[7]); | |
| 87 | + a = FF(a, b, c, d, wordOffset8, 7, T[8]); | |
| 88 | + d = FF(d, a, b, c, wordOffset9, 12, T[9]); | |
| 89 | + c = FF(c, d, a, b, wordOffset10, 17, T[10]); | |
| 90 | + b = FF(b, c, d, a, wordOffset11, 22, T[11]); | |
| 91 | + a = FF(a, b, c, d, wordOffset12, 7, T[12]); | |
| 92 | + d = FF(d, a, b, c, wordOffset13, 12, T[13]); | |
| 93 | + c = FF(c, d, a, b, wordOffset14, 17, T[14]); | |
| 94 | + b = FF(b, c, d, a, wordOffset15, 22, T[15]); | |
| 95 | + a = GG(a, b, c, d, wordOffset1, 5, T[16]); | |
| 96 | + d = GG(d, a, b, c, wordOffset6, 9, T[17]); | |
| 97 | + c = GG(c, d, a, b, wordOffset11, 14, T[18]); | |
| 98 | + b = GG(b, c, d, a, wordOffset0, 20, T[19]); | |
| 99 | + a = GG(a, b, c, d, wordOffset5, 5, T[20]); | |
| 100 | + d = GG(d, a, b, c, wordOffset10, 9, T[21]); | |
| 101 | + c = GG(c, d, a, b, wordOffset15, 14, T[22]); | |
| 102 | + b = GG(b, c, d, a, wordOffset4, 20, T[23]); | |
| 103 | + a = GG(a, b, c, d, wordOffset9, 5, T[24]); | |
| 104 | + d = GG(d, a, b, c, wordOffset14, 9, T[25]); | |
| 105 | + c = GG(c, d, a, b, wordOffset3, 14, T[26]); | |
| 106 | + b = GG(b, c, d, a, wordOffset8, 20, T[27]); | |
| 107 | + a = GG(a, b, c, d, wordOffset13, 5, T[28]); | |
| 108 | + d = GG(d, a, b, c, wordOffset2, 9, T[29]); | |
| 109 | + c = GG(c, d, a, b, wordOffset7, 14, T[30]); | |
| 110 | + b = GG(b, c, d, a, wordOffset12, 20, T[31]); | |
| 111 | + a = HH(a, b, c, d, wordOffset5, 4, T[32]); | |
| 112 | + d = HH(d, a, b, c, wordOffset8, 11, T[33]); | |
| 113 | + c = HH(c, d, a, b, wordOffset11, 16, T[34]); | |
| 114 | + b = HH(b, c, d, a, wordOffset14, 23, T[35]); | |
| 115 | + a = HH(a, b, c, d, wordOffset1, 4, T[36]); | |
| 116 | + d = HH(d, a, b, c, wordOffset4, 11, T[37]); | |
| 117 | + c = HH(c, d, a, b, wordOffset7, 16, T[38]); | |
| 118 | + b = HH(b, c, d, a, wordOffset10, 23, T[39]); | |
| 119 | + a = HH(a, b, c, d, wordOffset13, 4, T[40]); | |
| 120 | + d = HH(d, a, b, c, wordOffset0, 11, T[41]); | |
| 121 | + c = HH(c, d, a, b, wordOffset3, 16, T[42]); | |
| 122 | + b = HH(b, c, d, a, wordOffset6, 23, T[43]); | |
| 123 | + a = HH(a, b, c, d, wordOffset9, 4, T[44]); | |
| 124 | + d = HH(d, a, b, c, wordOffset12, 11, T[45]); | |
| 125 | + c = HH(c, d, a, b, wordOffset15, 16, T[46]); | |
| 126 | + b = HH(b, c, d, a, wordOffset2, 23, T[47]); | |
| 127 | + a = II(a, b, c, d, wordOffset0, 6, T[48]); | |
| 128 | + d = II(d, a, b, c, wordOffset7, 10, T[49]); | |
| 129 | + c = II(c, d, a, b, wordOffset14, 15, T[50]); | |
| 130 | + b = II(b, c, d, a, wordOffset5, 21, T[51]); | |
| 131 | + a = II(a, b, c, d, wordOffset12, 6, T[52]); | |
| 132 | + d = II(d, a, b, c, wordOffset3, 10, T[53]); | |
| 133 | + c = II(c, d, a, b, wordOffset10, 15, T[54]); | |
| 134 | + b = II(b, c, d, a, wordOffset1, 21, T[55]); | |
| 135 | + a = II(a, b, c, d, wordOffset8, 6, T[56]); | |
| 136 | + d = II(d, a, b, c, wordOffset15, 10, T[57]); | |
| 137 | + c = II(c, d, a, b, wordOffset6, 15, T[58]); | |
| 138 | + b = II(b, c, d, a, wordOffset13, 21, T[59]); | |
| 139 | + a = II(a, b, c, d, wordOffset4, 6, T[60]); | |
| 140 | + d = II(d, a, b, c, wordOffset11, 10, T[61]); | |
| 141 | + c = II(c, d, a, b, wordOffset2, 15, T[62]); | |
| 142 | + b = II(b, c, d, a, wordOffset9, 21, T[63]); | |
| 143 | + // Intermediate hash value | |
| 144 | + H[0] = (H[0] + a) | 0; | |
| 145 | + H[1] = (H[1] + b) | 0; | |
| 146 | + H[2] = (H[2] + c) | 0; | |
| 147 | + H[3] = (H[3] + d) | 0; | |
| 148 | + } | |
| 149 | + _doFinalize() { | |
| 150 | + // Shortcuts | |
| 151 | + const data = this._data; | |
| 152 | + const dataWords = data.words; | |
| 153 | + const nBitsTotal = this._nBytes * 8; | |
| 154 | + const nBitsLeft = data.nSigBytes * 8; | |
| 155 | + // Add padding | |
| 156 | + dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); | |
| 157 | + const nBitsTotalH = Math.floor(nBitsTotal / 0x100000000); | |
| 158 | + const nBitsTotalL = nBitsTotal; | |
| 159 | + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = ((((nBitsTotalH << 8) | (nBitsTotalH >>> 24)) & 0x00ff00ff) | | |
| 160 | + (((nBitsTotalH << 24) | (nBitsTotalH >>> 8)) & 0xff00ff00)); | |
| 161 | + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = ((((nBitsTotalL << 8) | (nBitsTotalL >>> 24)) & 0x00ff00ff) | | |
| 162 | + (((nBitsTotalL << 24) | (nBitsTotalL >>> 8)) & 0xff00ff00)); | |
| 163 | + data.nSigBytes = (dataWords.length + 1) * 4; | |
| 164 | + // Hash final blocks | |
| 165 | + this._process(); | |
| 166 | + // Shortcuts | |
| 167 | + const hash = this._hash; | |
| 168 | + const H = hash.words; | |
| 169 | + // Swap endian | |
| 170 | + for (let i = 0; i < 4; i++) { | |
| 171 | + // Shortcut | |
| 172 | + const Hi = H[i]; | |
| 173 | + H[i] = (((Hi << 8) | (Hi >>> 24)) & 0x00ff00ff) | |
| 174 | + | (((Hi << 24) | (Hi >>> 8)) & 0xff00ff00); | |
| 175 | + } | |
| 176 | + // Return final computed hash | |
| 177 | + return hash; | |
| 178 | + } | |
| 179 | + clone() { | |
| 180 | + const props = { hash: this._hash, blockSize: this._blockSize, data: this._data, nBytes: this._nBytes }; | |
| 181 | + return new MD5(props); | |
| 182 | + } | |
| 183 | + static hash(message) { | |
| 184 | + return new MD5().finalize(message); | |
| 185 | + } | |
| 186 | +} | ... | ... |
| 1 | +export { OpenSSLKDF } from "./lib/algorithm/cipher/kdf/OpenSSLKDF"; | ... | ... |
| 1 | +export { OpenSSLKDF } from "./lib/algorithm/cipher/kdf/OpenSSLKDF"; | ... | ... |
app/static/content/jscrypto/es6/PBKDF2.d.ts
0 → 100644
| 1 | +export { PBKDF2 } from "./lib/algorithm/cipher/kdf/module/PBKDF2"; | ... | ... |
app/static/content/jscrypto/es6/PBKDF2.js
0 → 100644
| 1 | +export { PBKDF2 } from "./lib/algorithm/cipher/kdf/module/PBKDF2"; | ... | ... |
app/static/content/jscrypto/es6/RC4.d.ts
0 → 100644
| 1 | +import { PropsWithKey } from "./lib/algorithm/cipher/Cipher"; | |
| 2 | +import type { Word32Array } from "./lib/Word32Array"; | |
| 3 | +import { StreamCipher, StreamCipherProps } from "./lib/algorithm/cipher/StreamCipher"; | |
| 4 | +import { CipherParams } from "./lib/algorithm/cipher/CipherParams"; | |
| 5 | +export interface RC4Props extends StreamCipherProps { | |
| 6 | +} | |
| 7 | +export declare class RC4 extends StreamCipher { | |
| 8 | + static readonly ivSize = 0; | |
| 9 | + static readonly keySize: number; | |
| 10 | + protected _props: PropsWithKey<RC4Props>; | |
| 11 | + protected S: number[]; | |
| 12 | + protected i: number; | |
| 13 | + protected j: number; | |
| 14 | + constructor(props: PropsWithKey<RC4Props>); | |
| 15 | + protected _doReset(): void; | |
| 16 | + protected _doProcessBlock(words: number[], offset: number): void; | |
| 17 | + protected generateKeyStreamWord(): number; | |
| 18 | + /** | |
| 19 | + * Creates this cipher in encryption mode. | |
| 20 | + * | |
| 21 | + * @param {Word32Array} key The key. | |
| 22 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 23 | + * @return {Cipher} A cipher instance. | |
| 24 | + * @example | |
| 25 | + * var cipher = RC4.createEncryptor(keyWordArray); | |
| 26 | + */ | |
| 27 | + static createEncryptor(key: Word32Array, props?: Partial<StreamCipherProps>): RC4; | |
| 28 | + /** | |
| 29 | + * Creates this cipher in decryption mode. | |
| 30 | + * | |
| 31 | + * @param {Word32Array} key The key. | |
| 32 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 33 | + * @return {Cipher} A cipher instance. | |
| 34 | + * @example | |
| 35 | + * var cipher = RC4.createDecryptor(keyWordArray, { iv: ivWordArray }); | |
| 36 | + */ | |
| 37 | + static createDecryptor(key: Word32Array, props?: Partial<StreamCipherProps>): RC4; | |
| 38 | + /** | |
| 39 | + * Encrypt a message with key | |
| 40 | + * | |
| 41 | + * @param {Word32Array|string} message | |
| 42 | + * @param {Word32Array|string} key | |
| 43 | + * @param {Partial<AESProps>?} props | |
| 44 | + * @example | |
| 45 | + * var encryptedMessage = RC4.encrypt("test", "pass"); | |
| 46 | + */ | |
| 47 | + static encrypt(message: Word32Array | string, key: Word32Array | string, props?: Partial<RC4Props>): CipherParams; | |
| 48 | + /** | |
| 49 | + * Encrypt a encrypted message with key | |
| 50 | + * | |
| 51 | + * @param {CipherParams} cipherText | |
| 52 | + * @param {Word32Array|string} key | |
| 53 | + * @param {Partial<AESProps>?} props | |
| 54 | + * @example | |
| 55 | + * var encryptedMessage = RC4.decrypt(cipherProps, "pass"); | |
| 56 | + */ | |
| 57 | + static decrypt(cipherText: CipherParams, key: Word32Array | string, props?: Partial<RC4Props>): Word32Array; | |
| 58 | +} | ... | ... |
app/static/content/jscrypto/es6/RC4.js
0 → 100644
| 1 | +import { StreamCipher } from "./lib/algorithm/cipher/StreamCipher"; | |
| 2 | +import { PasswordBasedCipher } from "./lib/algorithm/cipher/PasswordBasedCipher"; | |
| 3 | +import { SerializableCipher } from "./lib/algorithm/cipher/SerializableCipher"; | |
| 4 | +export class RC4 extends StreamCipher { | |
| 5 | + constructor(props) { | |
| 6 | + super(props); | |
| 7 | + this.S = []; | |
| 8 | + this.i = 0; | |
| 9 | + this.j = 0; | |
| 10 | + this._props = props; | |
| 11 | + this._doReset(); | |
| 12 | + } | |
| 13 | + _doReset() { | |
| 14 | + // Shortcuts | |
| 15 | + const key = this._key; | |
| 16 | + const keyWords = key.words; | |
| 17 | + const keySigBytes = key.nSigBytes; | |
| 18 | + // Init sbox | |
| 19 | + this.S = []; | |
| 20 | + for (let i = 0; i < 256; i++) { | |
| 21 | + this.S[i] = i; | |
| 22 | + } | |
| 23 | + // Key setup | |
| 24 | + for (let i = 0, j = 0; i < 256; i++) { | |
| 25 | + const keyByteIndex = i % keySigBytes; | |
| 26 | + const keyByte = (keyWords[keyByteIndex >>> 2] >>> (24 - (keyByteIndex % 4) * 8)) & 0xff; | |
| 27 | + j = (j + this.S[i] + keyByte) % 256; | |
| 28 | + // Swap | |
| 29 | + const t = this.S[i]; | |
| 30 | + this.S[i] = this.S[j]; | |
| 31 | + this.S[j] = t; | |
| 32 | + } | |
| 33 | + // Counters | |
| 34 | + this.i = this.j = 0; | |
| 35 | + } | |
| 36 | + _doProcessBlock(words, offset) { | |
| 37 | + words[offset] ^= this.generateKeyStreamWord(); | |
| 38 | + } | |
| 39 | + generateKeyStreamWord() { | |
| 40 | + // Shortcuts | |
| 41 | + const S = this.S; | |
| 42 | + let i = this.i; | |
| 43 | + let j = this.j; | |
| 44 | + // Generate keyStream word | |
| 45 | + let keyStreamWord = 0; | |
| 46 | + for (let n = 0; n < 4; n++) { | |
| 47 | + i = (i + 1) % 256; | |
| 48 | + j = (j + S[i]) % 256; | |
| 49 | + // Swap | |
| 50 | + const t = S[i]; | |
| 51 | + S[i] = S[j]; | |
| 52 | + S[j] = t; | |
| 53 | + keyStreamWord |= S[(S[i] + S[j]) % 256] << (24 - n * 8); | |
| 54 | + } | |
| 55 | + // Update counters | |
| 56 | + this.i = i; | |
| 57 | + this.j = j; | |
| 58 | + return keyStreamWord; | |
| 59 | + } | |
| 60 | + /** | |
| 61 | + * Creates this cipher in encryption mode. | |
| 62 | + * | |
| 63 | + * @param {Word32Array} key The key. | |
| 64 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 65 | + * @return {Cipher} A cipher instance. | |
| 66 | + * @example | |
| 67 | + * var cipher = RC4.createEncryptor(keyWordArray); | |
| 68 | + */ | |
| 69 | + static createEncryptor(key, props) { | |
| 70 | + props = typeof props === "undefined" ? {} : props; | |
| 71 | + return new RC4(Object.assign(Object.assign({}, props), { key })); | |
| 72 | + } | |
| 73 | + /** | |
| 74 | + * Creates this cipher in decryption mode. | |
| 75 | + * | |
| 76 | + * @param {Word32Array} key The key. | |
| 77 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 78 | + * @return {Cipher} A cipher instance. | |
| 79 | + * @example | |
| 80 | + * var cipher = RC4.createDecryptor(keyWordArray, { iv: ivWordArray }); | |
| 81 | + */ | |
| 82 | + static createDecryptor(key, props) { | |
| 83 | + props = typeof props === "undefined" ? {} : props; | |
| 84 | + return new RC4(Object.assign(Object.assign({}, props), { key })); | |
| 85 | + } | |
| 86 | + /** | |
| 87 | + * Encrypt a message with key | |
| 88 | + * | |
| 89 | + * @param {Word32Array|string} message | |
| 90 | + * @param {Word32Array|string} key | |
| 91 | + * @param {Partial<AESProps>?} props | |
| 92 | + * @example | |
| 93 | + * var encryptedMessage = RC4.encrypt("test", "pass"); | |
| 94 | + */ | |
| 95 | + static encrypt(message, key, props) { | |
| 96 | + if (typeof key === "string") { | |
| 97 | + return PasswordBasedCipher.encrypt(RC4, message, key, props); | |
| 98 | + } | |
| 99 | + return SerializableCipher.encrypt(RC4, message, key, props); | |
| 100 | + } | |
| 101 | + /** | |
| 102 | + * Encrypt a encrypted message with key | |
| 103 | + * | |
| 104 | + * @param {CipherParams} cipherText | |
| 105 | + * @param {Word32Array|string} key | |
| 106 | + * @param {Partial<AESProps>?} props | |
| 107 | + * @example | |
| 108 | + * var encryptedMessage = RC4.decrypt(cipherProps, "pass"); | |
| 109 | + */ | |
| 110 | + static decrypt(cipherText, key, props) { | |
| 111 | + if (typeof key === "string") { | |
| 112 | + return PasswordBasedCipher.decrypt(RC4, cipherText, key, props); | |
| 113 | + } | |
| 114 | + return SerializableCipher.decrypt(RC4, cipherText, key, props); | |
| 115 | + } | |
| 116 | +} | |
| 117 | +RC4.ivSize = 0; | |
| 118 | +RC4.keySize = 256 / 32; | ... | ... |
app/static/content/jscrypto/es6/RC4Drop.d.ts
0 → 100644
| 1 | +import { CipherProps, PropsWithKey } from "./lib/algorithm/cipher/Cipher"; | |
| 2 | +import type { Word32Array } from "./lib/Word32Array"; | |
| 3 | +import { CipherParams } from "./lib/algorithm/cipher/CipherParams"; | |
| 4 | +import { RC4 } from "./RC4"; | |
| 5 | +export interface RC4DropProps extends CipherProps { | |
| 6 | + drop?: number; | |
| 7 | +} | |
| 8 | +export declare class RC4Drop extends RC4 { | |
| 9 | + protected drop: number; | |
| 10 | + constructor(props: PropsWithKey<RC4DropProps>); | |
| 11 | + protected _doReset(): void; | |
| 12 | + /** | |
| 13 | + * Creates this cipher in encryption mode. | |
| 14 | + * | |
| 15 | + * @param {Word32Array} key The key. | |
| 16 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 17 | + * @return {Cipher} A cipher instance. | |
| 18 | + * @example | |
| 19 | + * var cipher = RC4Drop.createEncryptor(keyWordArray); | |
| 20 | + */ | |
| 21 | + static createEncryptor(key: Word32Array, props?: Partial<CipherProps>): RC4Drop; | |
| 22 | + /** | |
| 23 | + * Creates this cipher in decryption mode. | |
| 24 | + * | |
| 25 | + * @param {Word32Array} key The key. | |
| 26 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 27 | + * @return {Cipher} A cipher instance. | |
| 28 | + * @example | |
| 29 | + * var cipher = RC4Drop.createDecryptor(keyWordArray, { iv: ivWordArray }); | |
| 30 | + */ | |
| 31 | + static createDecryptor(key: Word32Array, props?: Partial<CipherProps>): RC4Drop; | |
| 32 | + /** | |
| 33 | + * Encrypt a message with key | |
| 34 | + * | |
| 35 | + * @param {Word32Array|string} message | |
| 36 | + * @param {Word32Array|string} key | |
| 37 | + * @param {Partial<AESProps>?} props | |
| 38 | + * @example | |
| 39 | + * var encryptedMessage = RC4Drop.encrypt("test", "pass"); | |
| 40 | + */ | |
| 41 | + static encrypt(message: Word32Array | string, key: Word32Array | string, props?: Partial<RC4DropProps>): CipherParams; | |
| 42 | + /** | |
| 43 | + * Encrypt a encrypted message with key | |
| 44 | + * | |
| 45 | + * @param {CipherParams} cipherText | |
| 46 | + * @param {Word32Array|string} key | |
| 47 | + * @param {Partial<AESProps>?} props | |
| 48 | + * @example | |
| 49 | + * var encryptedMessage = RC4Drop.decrypt(cipherProps, "pass"); | |
| 50 | + */ | |
| 51 | + static decrypt(cipherText: CipherParams, key: Word32Array | string, props?: Partial<RC4DropProps>): Word32Array; | |
| 52 | +} | ... | ... |
app/static/content/jscrypto/es6/RC4Drop.js
0 → 100644
| 1 | +import { PasswordBasedCipher } from "./lib/algorithm/cipher/PasswordBasedCipher"; | |
| 2 | +import { SerializableCipher } from "./lib/algorithm/cipher/SerializableCipher"; | |
| 3 | +import { RC4 } from "./RC4"; | |
| 4 | +export class RC4Drop extends RC4 { | |
| 5 | + constructor(props) { | |
| 6 | + super(props); | |
| 7 | + this.drop = 192; | |
| 8 | + this._props = props; | |
| 9 | + if (props && typeof props.drop === "number") { | |
| 10 | + this.drop = props.drop; | |
| 11 | + } | |
| 12 | + this._doReset(); | |
| 13 | + } | |
| 14 | + _doReset() { | |
| 15 | + super._doReset(); | |
| 16 | + // Drop | |
| 17 | + for (let i = this.drop; i > 0; i--) { | |
| 18 | + this.generateKeyStreamWord(); | |
| 19 | + } | |
| 20 | + } | |
| 21 | + /** | |
| 22 | + * Creates this cipher in encryption mode. | |
| 23 | + * | |
| 24 | + * @param {Word32Array} key The key. | |
| 25 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 26 | + * @return {Cipher} A cipher instance. | |
| 27 | + * @example | |
| 28 | + * var cipher = RC4Drop.createEncryptor(keyWordArray); | |
| 29 | + */ | |
| 30 | + static createEncryptor(key, props) { | |
| 31 | + props = typeof props === "undefined" ? {} : props; | |
| 32 | + return new RC4Drop(Object.assign(Object.assign({}, props), { key })); | |
| 33 | + } | |
| 34 | + /** | |
| 35 | + * Creates this cipher in decryption mode. | |
| 36 | + * | |
| 37 | + * @param {Word32Array} key The key. | |
| 38 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 39 | + * @return {Cipher} A cipher instance. | |
| 40 | + * @example | |
| 41 | + * var cipher = RC4Drop.createDecryptor(keyWordArray, { iv: ivWordArray }); | |
| 42 | + */ | |
| 43 | + static createDecryptor(key, props) { | |
| 44 | + props = typeof props === "undefined" ? {} : props; | |
| 45 | + return new RC4Drop(Object.assign(Object.assign({}, props), { key })); | |
| 46 | + } | |
| 47 | + /** | |
| 48 | + * Encrypt a message with key | |
| 49 | + * | |
| 50 | + * @param {Word32Array|string} message | |
| 51 | + * @param {Word32Array|string} key | |
| 52 | + * @param {Partial<AESProps>?} props | |
| 53 | + * @example | |
| 54 | + * var encryptedMessage = RC4Drop.encrypt("test", "pass"); | |
| 55 | + */ | |
| 56 | + static encrypt(message, key, props) { | |
| 57 | + if (typeof key === "string") { | |
| 58 | + return PasswordBasedCipher.encrypt(RC4Drop, message, key, props); | |
| 59 | + } | |
| 60 | + return SerializableCipher.encrypt(RC4Drop, message, key, props); | |
| 61 | + } | |
| 62 | + /** | |
| 63 | + * Encrypt a encrypted message with key | |
| 64 | + * | |
| 65 | + * @param {CipherParams} cipherText | |
| 66 | + * @param {Word32Array|string} key | |
| 67 | + * @param {Partial<AESProps>?} props | |
| 68 | + * @example | |
| 69 | + * var encryptedMessage = RC4Drop.decrypt(cipherProps, "pass"); | |
| 70 | + */ | |
| 71 | + static decrypt(cipherText, key, props) { | |
| 72 | + if (typeof key === "string") { | |
| 73 | + return PasswordBasedCipher.decrypt(RC4Drop, cipherText, key, props); | |
| 74 | + } | |
| 75 | + return SerializableCipher.decrypt(RC4Drop, cipherText, key, props); | |
| 76 | + } | |
| 77 | +} | ... | ... |
| 1 | +/** @preserve | |
| 2 | +(c) 2012 by Cédric Mesnil. All rights reserved. | |
| 3 | +Redistribution and use in source and binary forms, with or without modification, | |
| 4 | + are permitted provided that the following conditions are met: | |
| 5 | + | |
| 6 | +- Redistributions of source code must retain the above copyright notice, | |
| 7 | + this list of conditions and the following disclaimer. | |
| 8 | +- Redistributions in binary form must reproduce the above copyright notice, | |
| 9 | + this list of conditions and the following disclaimer in the documentation | |
| 10 | + and/or other materials provided with the distribution. | |
| 11 | + | |
| 12 | +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, | |
| 13 | +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
| 14 | +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
| 15 | +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
| 16 | +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | |
| 17 | +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | |
| 18 | +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 19 | + */ | |
| 20 | +import { Hasher, HasherProps } from "./lib/algorithm/Hasher"; | |
| 21 | +import { Word32Array } from "./lib/Word32Array"; | |
| 22 | +export interface RIPEMD160Props extends HasherProps { | |
| 23 | + hash: Word32Array; | |
| 24 | +} | |
| 25 | +export declare class RIPEMD160 extends Hasher { | |
| 26 | + protected _props?: Partial<RIPEMD160Props>; | |
| 27 | + private _hash; | |
| 28 | + constructor(props?: RIPEMD160Props); | |
| 29 | + protected _doReset(): void; | |
| 30 | + protected _doProcessBlock(words: number[], offset: number): void; | |
| 31 | + protected _doFinalize(): Word32Array; | |
| 32 | + clone(): RIPEMD160; | |
| 33 | + static hash(message: Word32Array | string, props?: RIPEMD160Props): Word32Array; | |
| 34 | +} | ... | ... |
app/static/content/jscrypto/es6/RIPEMD160.js
0 → 100644
| 1 | +/** @preserve | |
| 2 | +(c) 2012 by Cédric Mesnil. All rights reserved. | |
| 3 | +Redistribution and use in source and binary forms, with or without modification, | |
| 4 | + are permitted provided that the following conditions are met: | |
| 5 | + | |
| 6 | +- Redistributions of source code must retain the above copyright notice, | |
| 7 | + this list of conditions and the following disclaimer. | |
| 8 | +- Redistributions in binary form must reproduce the above copyright notice, | |
| 9 | + this list of conditions and the following disclaimer in the documentation | |
| 10 | + and/or other materials provided with the distribution. | |
| 11 | + | |
| 12 | +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, | |
| 13 | +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
| 14 | +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
| 15 | +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
| 16 | +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | |
| 17 | +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | |
| 18 | +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 19 | + */ | |
| 20 | +import { Hasher } from "./lib/algorithm/Hasher"; | |
| 21 | +import { Word32Array } from "./lib/Word32Array"; | |
| 22 | +// Constants table | |
| 23 | +const _zl = new Word32Array([ | |
| 24 | + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, | |
| 25 | + 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, | |
| 26 | + 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, | |
| 27 | + 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, | |
| 28 | + 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13, | |
| 29 | +]); | |
| 30 | +const _zr = new Word32Array([ | |
| 31 | + 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, | |
| 32 | + 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, | |
| 33 | + 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, | |
| 34 | + 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, | |
| 35 | + 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11, | |
| 36 | +]); | |
| 37 | +const _sl = new Word32Array([ | |
| 38 | + 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, | |
| 39 | + 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, | |
| 40 | + 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, | |
| 41 | + 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, | |
| 42 | + 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6, | |
| 43 | +]); | |
| 44 | +const _sr = new Word32Array([ | |
| 45 | + 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, | |
| 46 | + 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, | |
| 47 | + 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, | |
| 48 | + 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, | |
| 49 | + 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11, | |
| 50 | +]); | |
| 51 | +const _hl = new Word32Array([0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]); | |
| 52 | +const _hr = new Word32Array([0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]); | |
| 53 | +function f1(x, y, z) { | |
| 54 | + return ((x) ^ (y) ^ (z)); | |
| 55 | +} | |
| 56 | +function f2(x, y, z) { | |
| 57 | + return (((x) & (y)) | ((~x) & (z))); | |
| 58 | +} | |
| 59 | +function f3(x, y, z) { | |
| 60 | + return (((x) | (~(y))) ^ (z)); | |
| 61 | +} | |
| 62 | +function f4(x, y, z) { | |
| 63 | + return (((x) & (z)) | ((y) & (~(z)))); | |
| 64 | +} | |
| 65 | +function f5(x, y, z) { | |
| 66 | + return ((x) ^ ((y) | (~(z)))); | |
| 67 | +} | |
| 68 | +function rotl(x, n) { | |
| 69 | + return (x << n) | (x >>> (32 - n)); | |
| 70 | +} | |
| 71 | +export class RIPEMD160 extends Hasher { | |
| 72 | + constructor(props) { | |
| 73 | + super(props); | |
| 74 | + this._hash = new Word32Array([0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]); | |
| 75 | + this._props = props; | |
| 76 | + if (props && typeof props.hash !== "undefined") { | |
| 77 | + this._hash = props.hash.clone(); | |
| 78 | + } | |
| 79 | + } | |
| 80 | + _doReset() { | |
| 81 | + this._hash = new Word32Array([0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]); | |
| 82 | + } | |
| 83 | + _doProcessBlock(words, offset) { | |
| 84 | + // Swap endian | |
| 85 | + for (let i = 0; i < 16; i++) { | |
| 86 | + // Shortcuts | |
| 87 | + const offsetI = offset + i; | |
| 88 | + const wordsOffsetI = words[offsetI]; | |
| 89 | + // Swap | |
| 90 | + words[offsetI] = ((((wordsOffsetI << 8) | (wordsOffsetI >>> 24)) & 0x00ff00ff) | | |
| 91 | + (((wordsOffsetI << 24) | (wordsOffsetI >>> 8)) & 0xff00ff00)); | |
| 92 | + } | |
| 93 | + // Shortcut | |
| 94 | + const H = this._hash.words; | |
| 95 | + const hl = _hl.words; | |
| 96 | + const hr = _hr.words; | |
| 97 | + const zl = _zl.words; | |
| 98 | + const zr = _zr.words; | |
| 99 | + const sl = _sl.words; | |
| 100 | + const sr = _sr.words; | |
| 101 | + // Working variables | |
| 102 | + let al; | |
| 103 | + let bl; | |
| 104 | + let cl; | |
| 105 | + let dl; | |
| 106 | + let el; | |
| 107 | + let ar; | |
| 108 | + let br; | |
| 109 | + let cr; | |
| 110 | + let dr; | |
| 111 | + let er; | |
| 112 | + ar = al = H[0]; | |
| 113 | + br = bl = H[1]; | |
| 114 | + cr = cl = H[2]; | |
| 115 | + dr = dl = H[3]; | |
| 116 | + er = el = H[4]; | |
| 117 | + // Computation | |
| 118 | + let t; | |
| 119 | + for (let i = 0; i < 80; i += 1) { | |
| 120 | + t = (al + words[offset + zl[i]]) | 0; | |
| 121 | + if (i < 16) { | |
| 122 | + t += f1(bl, cl, dl) + hl[0]; | |
| 123 | + } | |
| 124 | + else if (i < 32) { | |
| 125 | + t += f2(bl, cl, dl) + hl[1]; | |
| 126 | + } | |
| 127 | + else if (i < 48) { | |
| 128 | + t += f3(bl, cl, dl) + hl[2]; | |
| 129 | + } | |
| 130 | + else if (i < 64) { | |
| 131 | + t += f4(bl, cl, dl) + hl[3]; | |
| 132 | + } | |
| 133 | + else { // if (i<80) { | |
| 134 | + t += f5(bl, cl, dl) + hl[4]; | |
| 135 | + } | |
| 136 | + t = t | 0; | |
| 137 | + t = rotl(t, sl[i]); | |
| 138 | + t = (t + el) | 0; | |
| 139 | + al = el; | |
| 140 | + el = dl; | |
| 141 | + dl = rotl(cl, 10); | |
| 142 | + cl = bl; | |
| 143 | + bl = t; | |
| 144 | + t = (ar + words[offset + zr[i]]) | 0; | |
| 145 | + if (i < 16) { | |
| 146 | + t += f5(br, cr, dr) + hr[0]; | |
| 147 | + } | |
| 148 | + else if (i < 32) { | |
| 149 | + t += f4(br, cr, dr) + hr[1]; | |
| 150 | + } | |
| 151 | + else if (i < 48) { | |
| 152 | + t += f3(br, cr, dr) + hr[2]; | |
| 153 | + } | |
| 154 | + else if (i < 64) { | |
| 155 | + t += f2(br, cr, dr) + hr[3]; | |
| 156 | + } | |
| 157 | + else { // if (i<80) { | |
| 158 | + t += f1(br, cr, dr) + hr[4]; | |
| 159 | + } | |
| 160 | + t = t | 0; | |
| 161 | + t = rotl(t, sr[i]); | |
| 162 | + t = (t + er) | 0; | |
| 163 | + ar = er; | |
| 164 | + er = dr; | |
| 165 | + dr = rotl(cr, 10); | |
| 166 | + cr = br; | |
| 167 | + br = t; | |
| 168 | + } | |
| 169 | + // Intermediate hash value | |
| 170 | + t = (H[1] + cl + dr) | 0; | |
| 171 | + H[1] = (H[2] + dl + er) | 0; | |
| 172 | + H[2] = (H[3] + el + ar) | 0; | |
| 173 | + H[3] = (H[4] + al + br) | 0; | |
| 174 | + H[4] = (H[0] + bl + cr) | 0; | |
| 175 | + H[0] = t; | |
| 176 | + } | |
| 177 | + _doFinalize() { | |
| 178 | + // Shortcuts | |
| 179 | + const data = this._data; | |
| 180 | + const dataWords = data.words; | |
| 181 | + const nBitsTotal = this._nBytes * 8; | |
| 182 | + const nBitsLeft = data.nSigBytes * 8; | |
| 183 | + // Add padding | |
| 184 | + dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); | |
| 185 | + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = ((((nBitsTotal << 8) | (nBitsTotal >>> 24)) & 0x00ff00ff) | | |
| 186 | + (((nBitsTotal << 24) | (nBitsTotal >>> 8)) & 0xff00ff00)); | |
| 187 | + data.nSigBytes = (dataWords.length + 1) * 4; | |
| 188 | + // Hash final blocks | |
| 189 | + this._process(); | |
| 190 | + // Shortcuts | |
| 191 | + const hash = this._hash; | |
| 192 | + const H = hash.words; | |
| 193 | + // Swap endian | |
| 194 | + for (let i = 0; i < 5; i++) { | |
| 195 | + // Shortcut | |
| 196 | + const Hi = H[i]; | |
| 197 | + // Swap | |
| 198 | + H[i] = (((Hi << 8) | (Hi >>> 24)) & 0x00ff00ff) | | |
| 199 | + (((Hi << 24) | (Hi >>> 8)) & 0xff00ff00); | |
| 200 | + } | |
| 201 | + // Return final computed hash | |
| 202 | + return hash; | |
| 203 | + } | |
| 204 | + clone() { | |
| 205 | + const props = { hash: this._hash, blockSize: this._blockSize, data: this._data, nBytes: this._nBytes }; | |
| 206 | + return new RIPEMD160(props); | |
| 207 | + } | |
| 208 | + static hash(message, props) { | |
| 209 | + return new RIPEMD160(props).finalize(message); | |
| 210 | + } | |
| 211 | +} | ... | ... |
app/static/content/jscrypto/es6/Rabbit.d.ts
0 → 100644
| 1 | +import { CipherProps, PropsWithKey } from "./lib/algorithm/cipher/Cipher"; | |
| 2 | +import type { Word32Array } from "./lib/Word32Array"; | |
| 3 | +import { StreamCipher } from "./lib/algorithm/cipher/StreamCipher"; | |
| 4 | +import { CipherParams } from "./lib/algorithm/cipher/CipherParams"; | |
| 5 | +export interface RabbitProps extends CipherProps { | |
| 6 | +} | |
| 7 | +export declare class Rabbit extends StreamCipher { | |
| 8 | + protected _blockSize: number; | |
| 9 | + static readonly ivSize: number; | |
| 10 | + protected _props: PropsWithKey<RabbitProps>; | |
| 11 | + protected S: number[]; | |
| 12 | + protected C: number[]; | |
| 13 | + protected G: number[]; | |
| 14 | + protected _X: number[]; | |
| 15 | + protected _C: number[]; | |
| 16 | + protected _b: number; | |
| 17 | + constructor(props: PropsWithKey<RabbitProps>); | |
| 18 | + protected _doReset(): void; | |
| 19 | + protected _doProcessBlock(words: number[], offset: number): void; | |
| 20 | + protected nextState(): void; | |
| 21 | + /** | |
| 22 | + * Creates this cipher in encryption mode. | |
| 23 | + * | |
| 24 | + * @param {Word32Array} key The key. | |
| 25 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 26 | + * @return {Cipher} A cipher instance. | |
| 27 | + * @example | |
| 28 | + * var cipher = Rabbit.createEncryptor(keyWordArray); | |
| 29 | + */ | |
| 30 | + static createEncryptor(key: Word32Array, props?: Partial<CipherProps>): Rabbit; | |
| 31 | + /** | |
| 32 | + * Creates this cipher in decryption mode. | |
| 33 | + * | |
| 34 | + * @param {Word32Array} key The key. | |
| 35 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 36 | + * @return {Cipher} A cipher instance. | |
| 37 | + * @example | |
| 38 | + * var cipher = Rabbit.createDecryptor(keyWordArray, { iv: ivWordArray }); | |
| 39 | + */ | |
| 40 | + static createDecryptor(key: Word32Array, props?: Partial<CipherProps>): Rabbit; | |
| 41 | + /** | |
| 42 | + * Encrypt a message with key | |
| 43 | + * | |
| 44 | + * @param {Word32Array|string} message | |
| 45 | + * @param {Word32Array|string} key | |
| 46 | + * @param {Partial<AESProps>?} props | |
| 47 | + * @example | |
| 48 | + * var encryptedMessage = Rabbit.encrypt("test", "pass"); | |
| 49 | + */ | |
| 50 | + static encrypt(message: Word32Array | string, key: Word32Array | string, props?: Partial<RabbitProps>): CipherParams; | |
| 51 | + /** | |
| 52 | + * Encrypt a encrypted message with key | |
| 53 | + * | |
| 54 | + * @param {CipherParams} cipherText | |
| 55 | + * @param {Word32Array|string} key | |
| 56 | + * @param {Partial<AESProps>?} props | |
| 57 | + * @example | |
| 58 | + * var encryptedMessage = Rabbit.decrypt(cipherProps, "pass"); | |
| 59 | + */ | |
| 60 | + static decrypt(cipherText: CipherParams, key: Word32Array | string, props?: Partial<RabbitProps>): Word32Array; | |
| 61 | +} | ... | ... |
app/static/content/jscrypto/es6/Rabbit.js
0 → 100644
| 1 | +import { StreamCipher } from "./lib/algorithm/cipher/StreamCipher"; | |
| 2 | +import { PasswordBasedCipher } from "./lib/algorithm/cipher/PasswordBasedCipher"; | |
| 3 | +import { SerializableCipher } from "./lib/algorithm/cipher/SerializableCipher"; | |
| 4 | +export class Rabbit extends StreamCipher { | |
| 5 | + constructor(props) { | |
| 6 | + super(props); | |
| 7 | + this._blockSize = 128 / 32; | |
| 8 | + this.S = []; | |
| 9 | + this.C = []; | |
| 10 | + this.G = []; | |
| 11 | + this._X = []; | |
| 12 | + this._C = []; | |
| 13 | + this._b = 0; | |
| 14 | + this._props = props; | |
| 15 | + this._doReset(); | |
| 16 | + } | |
| 17 | + _doReset() { | |
| 18 | + // Shortcuts | |
| 19 | + const K = this._key.words; | |
| 20 | + const iv = this._iv; | |
| 21 | + // Swap endian | |
| 22 | + for (let i = 0; i < 4; i++) { | |
| 23 | + K[i] = (((K[i] << 8) | (K[i] >>> 24)) & 0x00ff00ff) | |
| 24 | + | (((K[i] << 24) | (K[i] >>> 8)) & 0xff00ff00); | |
| 25 | + } | |
| 26 | + // Generate initial state values | |
| 27 | + const X = this._X = [ | |
| 28 | + K[0], (K[3] << 16) | (K[2] >>> 16), | |
| 29 | + K[1], (K[0] << 16) | (K[3] >>> 16), | |
| 30 | + K[2], (K[1] << 16) | (K[0] >>> 16), | |
| 31 | + K[3], (K[2] << 16) | (K[1] >>> 16) | |
| 32 | + ]; | |
| 33 | + // Generate initial counter values | |
| 34 | + const C = this._C = [ | |
| 35 | + (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff), | |
| 36 | + (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff), | |
| 37 | + (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff), | |
| 38 | + (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff) | |
| 39 | + ]; | |
| 40 | + // Carry bit | |
| 41 | + this._b = 0; | |
| 42 | + // Iterate the system four times | |
| 43 | + for (let i = 0; i < 4; i++) { | |
| 44 | + this.nextState(); | |
| 45 | + } | |
| 46 | + // Modify the counters | |
| 47 | + for (let i = 0; i < 8; i++) { | |
| 48 | + C[i] ^= X[(i + 4) & 7]; | |
| 49 | + } | |
| 50 | + // IV setup | |
| 51 | + if (!iv) { | |
| 52 | + return; | |
| 53 | + } | |
| 54 | + // Shortcuts | |
| 55 | + const IV = iv.words; | |
| 56 | + const IV_0 = IV[0]; | |
| 57 | + const IV_1 = IV[1]; | |
| 58 | + // Generate four sub vectors | |
| 59 | + const i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00); | |
| 60 | + const i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00); | |
| 61 | + const i1 = (i0 >>> 16) | (i2 & 0xffff0000); | |
| 62 | + const i3 = (i2 << 16) | (i0 & 0x0000ffff); | |
| 63 | + // Modify counter values | |
| 64 | + C[0] ^= i0; | |
| 65 | + C[1] ^= i1; | |
| 66 | + C[2] ^= i2; | |
| 67 | + C[3] ^= i3; | |
| 68 | + C[4] ^= i0; | |
| 69 | + C[5] ^= i1; | |
| 70 | + C[6] ^= i2; | |
| 71 | + C[7] ^= i3; | |
| 72 | + // Iterate the system four times | |
| 73 | + for (let i = 0; i < 4; i++) { | |
| 74 | + this.nextState(); | |
| 75 | + } | |
| 76 | + } | |
| 77 | + _doProcessBlock(words, offset) { | |
| 78 | + // Shortcut | |
| 79 | + const X = this._X; | |
| 80 | + // Iterate the system | |
| 81 | + this.nextState(); | |
| 82 | + // Generate four key stream words | |
| 83 | + this.S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16); | |
| 84 | + this.S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16); | |
| 85 | + this.S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16); | |
| 86 | + this.S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16); | |
| 87 | + for (let i = 0; i < 4; i++) { | |
| 88 | + // Swap endian | |
| 89 | + this.S[i] = (((this.S[i] << 8) | (this.S[i] >>> 24)) & 0x00ff00ff) | | |
| 90 | + (((this.S[i] << 24) | (this.S[i] >>> 8)) & 0xff00ff00); | |
| 91 | + // Encrypt | |
| 92 | + words[offset + i] ^= this.S[i]; | |
| 93 | + } | |
| 94 | + } | |
| 95 | + nextState() { | |
| 96 | + // Shortcuts | |
| 97 | + const X = this._X; | |
| 98 | + const C = this._C; | |
| 99 | + // Save old counter values | |
| 100 | + for (let i = 0; i < 8; i++) { | |
| 101 | + this.C[i] = C[i]; | |
| 102 | + } | |
| 103 | + // Calculate new counter values | |
| 104 | + C[0] = (C[0] + 0x4d34d34d + this._b) | 0; | |
| 105 | + C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (this.C[0] >>> 0) ? 1 : 0)) | 0; | |
| 106 | + C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (this.C[1] >>> 0) ? 1 : 0)) | 0; | |
| 107 | + C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (this.C[2] >>> 0) ? 1 : 0)) | 0; | |
| 108 | + C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (this.C[3] >>> 0) ? 1 : 0)) | 0; | |
| 109 | + C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (this.C[4] >>> 0) ? 1 : 0)) | 0; | |
| 110 | + C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (this.C[5] >>> 0) ? 1 : 0)) | 0; | |
| 111 | + C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (this.C[6] >>> 0) ? 1 : 0)) | 0; | |
| 112 | + this._b = (C[7] >>> 0) < (this.C[7] >>> 0) ? 1 : 0; | |
| 113 | + // Calculate the g-values | |
| 114 | + for (let i = 0; i < 8; i++) { | |
| 115 | + const gx = X[i] + C[i]; | |
| 116 | + // Construct high and low argument for squaring | |
| 117 | + const ga = gx & 0xffff; | |
| 118 | + const gb = gx >>> 16; | |
| 119 | + // Calculate high and low result of squaring | |
| 120 | + const gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb; | |
| 121 | + const gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0); | |
| 122 | + // High XOR low | |
| 123 | + this.G[i] = gh ^ gl; | |
| 124 | + } | |
| 125 | + const G = this.G; | |
| 126 | + // Calculate new state values | |
| 127 | + X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0; | |
| 128 | + X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0; | |
| 129 | + X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0; | |
| 130 | + X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0; | |
| 131 | + X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0; | |
| 132 | + X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0; | |
| 133 | + X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0; | |
| 134 | + X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0; | |
| 135 | + } | |
| 136 | + /** | |
| 137 | + * Creates this cipher in encryption mode. | |
| 138 | + * | |
| 139 | + * @param {Word32Array} key The key. | |
| 140 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 141 | + * @return {Cipher} A cipher instance. | |
| 142 | + * @example | |
| 143 | + * var cipher = Rabbit.createEncryptor(keyWordArray); | |
| 144 | + */ | |
| 145 | + static createEncryptor(key, props) { | |
| 146 | + props = typeof props === "undefined" ? {} : props; | |
| 147 | + return new Rabbit(Object.assign(Object.assign({}, props), { key })); | |
| 148 | + } | |
| 149 | + /** | |
| 150 | + * Creates this cipher in decryption mode. | |
| 151 | + * | |
| 152 | + * @param {Word32Array} key The key. | |
| 153 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 154 | + * @return {Cipher} A cipher instance. | |
| 155 | + * @example | |
| 156 | + * var cipher = Rabbit.createDecryptor(keyWordArray, { iv: ivWordArray }); | |
| 157 | + */ | |
| 158 | + static createDecryptor(key, props) { | |
| 159 | + props = typeof props === "undefined" ? {} : props; | |
| 160 | + return new Rabbit(Object.assign(Object.assign({}, props), { key })); | |
| 161 | + } | |
| 162 | + /** | |
| 163 | + * Encrypt a message with key | |
| 164 | + * | |
| 165 | + * @param {Word32Array|string} message | |
| 166 | + * @param {Word32Array|string} key | |
| 167 | + * @param {Partial<AESProps>?} props | |
| 168 | + * @example | |
| 169 | + * var encryptedMessage = Rabbit.encrypt("test", "pass"); | |
| 170 | + */ | |
| 171 | + static encrypt(message, key, props) { | |
| 172 | + if (typeof key === "string") { | |
| 173 | + return PasswordBasedCipher.encrypt(Rabbit, message, key, props); | |
| 174 | + } | |
| 175 | + return SerializableCipher.encrypt(Rabbit, message, key, props); | |
| 176 | + } | |
| 177 | + /** | |
| 178 | + * Encrypt a encrypted message with key | |
| 179 | + * | |
| 180 | + * @param {CipherParams} cipherText | |
| 181 | + * @param {Word32Array|string} key | |
| 182 | + * @param {Partial<AESProps>?} props | |
| 183 | + * @example | |
| 184 | + * var encryptedMessage = Rabbit.decrypt(cipherProps, "pass"); | |
| 185 | + */ | |
| 186 | + static decrypt(cipherText, key, props) { | |
| 187 | + if (typeof key === "string") { | |
| 188 | + return PasswordBasedCipher.decrypt(Rabbit, cipherText, key, props); | |
| 189 | + } | |
| 190 | + return SerializableCipher.decrypt(Rabbit, cipherText, key, props); | |
| 191 | + } | |
| 192 | +} | |
| 193 | +Rabbit.ivSize = 128 / 32; | ... | ... |
app/static/content/jscrypto/es6/SHA1.d.ts
0 → 100644
| 1 | +import { Hasher, HasherProps } from "./lib/algorithm/Hasher"; | |
| 2 | +import { Word32Array } from "./lib/Word32Array"; | |
| 3 | +export interface SHA1Props extends HasherProps { | |
| 4 | + hash: Word32Array; | |
| 5 | +} | |
| 6 | +export declare class SHA1 extends Hasher { | |
| 7 | + protected _props?: Partial<SHA1Props>; | |
| 8 | + private _hash; | |
| 9 | + constructor(props?: SHA1Props); | |
| 10 | + protected _doReset(): void; | |
| 11 | + protected _doProcessBlock(words: number[], offset: number): void; | |
| 12 | + protected _doFinalize(): Word32Array; | |
| 13 | + clone(): SHA1; | |
| 14 | + static hash(message: Word32Array | string, props?: SHA1Props): Word32Array; | |
| 15 | +} | ... | ... |
app/static/content/jscrypto/es6/SHA1.js
0 → 100644
| 1 | +import { Hasher } from "./lib/algorithm/Hasher"; | |
| 2 | +import { Word32Array } from "./lib/Word32Array"; | |
| 3 | +// Reusable object | |
| 4 | +const W = []; | |
| 5 | +export class SHA1 extends Hasher { | |
| 6 | + constructor(props) { | |
| 7 | + super(props); | |
| 8 | + this._hash = new Word32Array([ | |
| 9 | + 0x67452301, 0xefcdab89, | |
| 10 | + 0x98badcfe, 0x10325476, | |
| 11 | + 0xc3d2e1f0 | |
| 12 | + ]); | |
| 13 | + this._props = props; | |
| 14 | + if (props && typeof props.hash !== "undefined") { | |
| 15 | + this._hash = props.hash.clone(); | |
| 16 | + } | |
| 17 | + } | |
| 18 | + _doReset() { | |
| 19 | + this._hash = new Word32Array([ | |
| 20 | + 0x67452301, 0xefcdab89, | |
| 21 | + 0x98badcfe, 0x10325476, | |
| 22 | + 0xc3d2e1f0 | |
| 23 | + ]); | |
| 24 | + } | |
| 25 | + _doProcessBlock(words, offset) { | |
| 26 | + const H = this._hash.words; | |
| 27 | + // Working variables | |
| 28 | + let a = H[0]; | |
| 29 | + let b = H[1]; | |
| 30 | + let c = H[2]; | |
| 31 | + let d = H[3]; | |
| 32 | + let e = H[4]; | |
| 33 | + // Computation | |
| 34 | + for (let i = 0; i < 80; i++) { | |
| 35 | + if (i < 16) { | |
| 36 | + W[i] = words[offset + i] | 0; | |
| 37 | + } | |
| 38 | + else { | |
| 39 | + const n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]; | |
| 40 | + W[i] = (n << 1) | (n >>> 31); | |
| 41 | + } | |
| 42 | + let t = ((a << 5) | (a >>> 27)) + e + W[i]; | |
| 43 | + if (i < 20) { | |
| 44 | + t += ((b & c) | (~b & d)) + 0x5a827999; | |
| 45 | + } | |
| 46 | + else if (i < 40) { | |
| 47 | + t += (b ^ c ^ d) + 0x6ed9eba1; | |
| 48 | + } | |
| 49 | + else if (i < 60) { | |
| 50 | + t += ((b & c) | (b & d) | (c & d)) - 0x70e44324; | |
| 51 | + } | |
| 52 | + else /* if (i < 80) */ { | |
| 53 | + t += (b ^ c ^ d) - 0x359d3e2a; | |
| 54 | + } | |
| 55 | + e = d; | |
| 56 | + d = c; | |
| 57 | + c = (b << 30) | (b >>> 2); | |
| 58 | + b = a; | |
| 59 | + a = t; | |
| 60 | + } | |
| 61 | + // Intermediate hash value | |
| 62 | + H[0] = (H[0] + a) | 0; | |
| 63 | + H[1] = (H[1] + b) | 0; | |
| 64 | + H[2] = (H[2] + c) | 0; | |
| 65 | + H[3] = (H[3] + d) | 0; | |
| 66 | + H[4] = (H[4] + e) | 0; | |
| 67 | + } | |
| 68 | + _doFinalize() { | |
| 69 | + // Shortcuts | |
| 70 | + const dataWords = this._data.words; | |
| 71 | + const nBitsTotal = this._nBytes * 8; | |
| 72 | + const nBitsLeft = this._data.nSigBytes * 8; | |
| 73 | + // Add padding | |
| 74 | + dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); | |
| 75 | + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000); | |
| 76 | + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal; | |
| 77 | + this._data.nSigBytes = dataWords.length * 4; | |
| 78 | + // Hash final blocks | |
| 79 | + this._process(); | |
| 80 | + // Return final computed hash | |
| 81 | + return this._hash; | |
| 82 | + } | |
| 83 | + clone() { | |
| 84 | + const props = { hash: this._hash, blockSize: this._blockSize, data: this._data, nBytes: this._nBytes }; | |
| 85 | + return new SHA1(props); | |
| 86 | + } | |
| 87 | + static hash(message, props) { | |
| 88 | + return new SHA1(props).finalize(message); | |
| 89 | + } | |
| 90 | +} | ... | ... |
app/static/content/jscrypto/es6/SHA224.d.ts
0 → 100644
| 1 | +import { Word32Array } from "./lib/Word32Array"; | |
| 2 | +import { SHA256 } from "./SHA256"; | |
| 3 | +import type { HasherProps } from "./lib/algorithm/Hasher"; | |
| 4 | +export interface SHA224Props extends HasherProps { | |
| 5 | + hash: Word32Array; | |
| 6 | +} | |
| 7 | +export declare class SHA224 extends SHA256 { | |
| 8 | + protected _props?: Partial<SHA224Props>; | |
| 9 | + protected _hash: Word32Array; | |
| 10 | + constructor(props?: SHA224Props); | |
| 11 | + protected _doReset(): void; | |
| 12 | + protected _doFinalize(): Word32Array; | |
| 13 | + clone(): SHA224; | |
| 14 | + static hash(message: Word32Array | string, props?: SHA224Props): Word32Array; | |
| 15 | +} | ... | ... |
app/static/content/jscrypto/es6/SHA224.js
0 → 100644
| 1 | +import { Word32Array } from "./lib/Word32Array"; | |
| 2 | +import { SHA256 } from "./SHA256"; | |
| 3 | +export class SHA224 extends SHA256 { | |
| 4 | + constructor(props) { | |
| 5 | + super(props); | |
| 6 | + this._hash = new Word32Array([ | |
| 7 | + 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, | |
| 8 | + 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 | |
| 9 | + ]); | |
| 10 | + this._props = props; | |
| 11 | + if (props && typeof props.hash !== "undefined") { | |
| 12 | + this._hash = props.hash.clone(); | |
| 13 | + } | |
| 14 | + } | |
| 15 | + _doReset() { | |
| 16 | + this._hash = new Word32Array([ | |
| 17 | + 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, | |
| 18 | + 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 | |
| 19 | + ]); | |
| 20 | + } | |
| 21 | + _doFinalize() { | |
| 22 | + const hash = super._doFinalize.call(this); | |
| 23 | + hash.nSigBytes -= 4; | |
| 24 | + return hash; | |
| 25 | + } | |
| 26 | + clone() { | |
| 27 | + const props = { hash: this._hash, blockSize: this._blockSize, data: this._data, nBytes: this._nBytes }; | |
| 28 | + return new SHA224(props); | |
| 29 | + } | |
| 30 | + static hash(message, props) { | |
| 31 | + return new SHA224(props).finalize(message); | |
| 32 | + } | |
| 33 | +} | ... | ... |
app/static/content/jscrypto/es6/SHA256.d.ts
0 → 100644
| 1 | +import { Hasher, HasherProps } from "./lib/algorithm/Hasher"; | |
| 2 | +import { Word32Array } from "./lib/Word32Array"; | |
| 3 | +export interface SHA256Props extends HasherProps { | |
| 4 | + hash: Word32Array; | |
| 5 | +} | |
| 6 | +export declare class SHA256 extends Hasher { | |
| 7 | + protected _props?: Partial<SHA256Props>; | |
| 8 | + protected _hash: Word32Array; | |
| 9 | + constructor(props?: SHA256Props); | |
| 10 | + protected _doReset(): void; | |
| 11 | + protected _doProcessBlock(words: number[], offset: number): void; | |
| 12 | + protected _doFinalize(): Word32Array; | |
| 13 | + clone(): SHA256; | |
| 14 | + static hash(message: Word32Array | string, props?: SHA256Props): Word32Array; | |
| 15 | +} | ... | ... |
app/static/content/jscrypto/es6/SHA256.js
0 → 100644
| 1 | +import { Hasher } from "./lib/algorithm/Hasher"; | |
| 2 | +import { Word32Array } from "./lib/Word32Array"; | |
| 3 | +// Hash values | |
| 4 | +const H = []; | |
| 5 | +// Round constants | |
| 6 | +const K = []; | |
| 7 | +function isPrime(n) { | |
| 8 | + const sqrtN = Math.sqrt(n); | |
| 9 | + for (let factor = 2; factor <= sqrtN; factor++) { | |
| 10 | + if (!(n % factor)) { | |
| 11 | + return false; | |
| 12 | + } | |
| 13 | + } | |
| 14 | + return true; | |
| 15 | +} | |
| 16 | +function getFractionalBits(n) { | |
| 17 | + return ((n - (n | 0)) * 0x100000000) | 0; | |
| 18 | +} | |
| 19 | +(function computeRoundConstants() { | |
| 20 | + let n = 2; | |
| 21 | + let nPrime = 0; | |
| 22 | + while (nPrime < 64) { | |
| 23 | + if (isPrime(n)) { | |
| 24 | + if (nPrime < 8) { | |
| 25 | + H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2)); | |
| 26 | + } | |
| 27 | + K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3)); | |
| 28 | + nPrime++; | |
| 29 | + } | |
| 30 | + n++; | |
| 31 | + } | |
| 32 | +})(); | |
| 33 | +// Reusable object | |
| 34 | +const W = []; | |
| 35 | +export class SHA256 extends Hasher { | |
| 36 | + constructor(props) { | |
| 37 | + super(props); | |
| 38 | + this._hash = new Word32Array(H.slice(0)); | |
| 39 | + this._props = props; | |
| 40 | + if (props && typeof props.hash !== "undefined") { | |
| 41 | + this._hash = props.hash.clone(); | |
| 42 | + } | |
| 43 | + } | |
| 44 | + _doReset() { | |
| 45 | + this._hash = new Word32Array(H.slice(0)); | |
| 46 | + } | |
| 47 | + _doProcessBlock(words, offset) { | |
| 48 | + const _H = this._hash.words; | |
| 49 | + let a = _H[0]; | |
| 50 | + let b = _H[1]; | |
| 51 | + let c = _H[2]; | |
| 52 | + let d = _H[3]; | |
| 53 | + let e = _H[4]; | |
| 54 | + let f = _H[5]; | |
| 55 | + let g = _H[6]; | |
| 56 | + let h = _H[7]; | |
| 57 | + for (let i = 0; i < 64; i++) { | |
| 58 | + if (i < 16) { | |
| 59 | + W[i] = words[offset + i] | 0; | |
| 60 | + } | |
| 61 | + else { | |
| 62 | + const gamma0x = W[i - 15]; | |
| 63 | + const gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) | |
| 64 | + ^ ((gamma0x << 14) | (gamma0x >>> 18)) | |
| 65 | + ^ (gamma0x >>> 3); | |
| 66 | + const gamma1x = W[i - 2]; | |
| 67 | + const gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) | |
| 68 | + ^ ((gamma1x << 13) | (gamma1x >>> 19)) | |
| 69 | + ^ (gamma1x >>> 10); | |
| 70 | + W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]; | |
| 71 | + } | |
| 72 | + const ch = (e & f) ^ (~e & g); | |
| 73 | + const maj = (a & b) ^ (a & c) ^ (b & c); | |
| 74 | + const sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22)); | |
| 75 | + const sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25)); | |
| 76 | + const t1 = h + sigma1 + ch + K[i] + W[i]; | |
| 77 | + const t2 = sigma0 + maj; | |
| 78 | + h = g; | |
| 79 | + g = f; | |
| 80 | + f = e; | |
| 81 | + e = (d + t1) | 0; | |
| 82 | + d = c; | |
| 83 | + c = b; | |
| 84 | + b = a; | |
| 85 | + a = (t1 + t2) | 0; | |
| 86 | + } | |
| 87 | + // Intermediate hash value | |
| 88 | + _H[0] = (_H[0] + a) | 0; | |
| 89 | + _H[1] = (_H[1] + b) | 0; | |
| 90 | + _H[2] = (_H[2] + c) | 0; | |
| 91 | + _H[3] = (_H[3] + d) | 0; | |
| 92 | + _H[4] = (_H[4] + e) | 0; | |
| 93 | + _H[5] = (_H[5] + f) | 0; | |
| 94 | + _H[6] = (_H[6] + g) | 0; | |
| 95 | + _H[7] = (_H[7] + h) | 0; | |
| 96 | + } | |
| 97 | + _doFinalize() { | |
| 98 | + const words = this._data.words; | |
| 99 | + const nBitsTotal = this._nBytes * 8; | |
| 100 | + const nBitsLeft = this._data.nSigBytes * 8; | |
| 101 | + // Add padding | |
| 102 | + words[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); | |
| 103 | + words[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000); | |
| 104 | + words[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal; | |
| 105 | + this._data.nSigBytes = words.length * 4; | |
| 106 | + // Hash final blocks | |
| 107 | + this._process(); | |
| 108 | + // Return final computed hash | |
| 109 | + return this._hash; | |
| 110 | + } | |
| 111 | + clone() { | |
| 112 | + const props = { hash: this._hash, blockSize: this._blockSize, data: this._data, nBytes: this._nBytes }; | |
| 113 | + return new SHA256(props); | |
| 114 | + } | |
| 115 | + static hash(message, props) { | |
| 116 | + return new SHA256(props).finalize(message); | |
| 117 | + } | |
| 118 | +} | ... | ... |
app/static/content/jscrypto/es6/SHA3.d.ts
0 → 100644
| 1 | +import { Word64 } from "./lib/Word64Array"; | |
| 2 | +import { Hasher, HasherProps } from "./lib/algorithm/Hasher"; | |
| 3 | +import { Word32Array } from "./lib/Word32Array"; | |
| 4 | +export interface SHA3Props extends HasherProps { | |
| 5 | + state: Word64[]; | |
| 6 | + outputLength: number; | |
| 7 | +} | |
| 8 | +export declare class SHA3 extends Hasher { | |
| 9 | + protected _props?: Partial<SHA3Props>; | |
| 10 | + protected _blockSize: number; | |
| 11 | + protected _state: Word64[]; | |
| 12 | + protected _outputLength: number; | |
| 13 | + constructor(props?: Partial<SHA3Props>); | |
| 14 | + protected _doReset(): void; | |
| 15 | + protected _doProcessBlock(words: number[], offset: number): void; | |
| 16 | + protected _doFinalize(): Word32Array; | |
| 17 | + clone(): SHA3; | |
| 18 | + static hash(message: Word32Array | string, props?: SHA3Props): Word32Array; | |
| 19 | +} | ... | ... |
app/static/content/jscrypto/es6/SHA3.js
0 → 100644
| 1 | +// Constants tables | |
| 2 | +import { Word64 } from "./lib/Word64Array"; | |
| 3 | +import { Hasher } from "./lib/algorithm/Hasher"; | |
| 4 | +import { Word32Array } from "./lib/Word32Array"; | |
| 5 | +const RHO_OFFSETS = []; | |
| 6 | +const PI_INDEXES = []; | |
| 7 | +const ROUND_CONSTANTS = []; | |
| 8 | +// Compute Constants | |
| 9 | +(function computeConstants() { | |
| 10 | + // Compute rho offset constants | |
| 11 | + let x = 1; | |
| 12 | + let y = 0; | |
| 13 | + for (let t = 0; t < 24; t++) { | |
| 14 | + RHO_OFFSETS[x + 5 * y] = ((t + 1) * (t + 2) / 2) % 64; | |
| 15 | + const newX = y % 5; | |
| 16 | + const newY = (2 * x + 3 * y) % 5; | |
| 17 | + x = newX; | |
| 18 | + y = newY; | |
| 19 | + } | |
| 20 | + // Compute pi index constants | |
| 21 | + for (let p = 0; p < 5; p++) { | |
| 22 | + for (let q = 0; q < 5; q++) { | |
| 23 | + PI_INDEXES[p + 5 * q] = q + ((2 * p + 3 * q) % 5) * 5; | |
| 24 | + } | |
| 25 | + } | |
| 26 | + // Compute round constants | |
| 27 | + let LFSR = 0x01; | |
| 28 | + for (let i = 0; i < 24; i++) { | |
| 29 | + let roundConstantMsw = 0; | |
| 30 | + let roundConstantLsw = 0; | |
| 31 | + for (let j = 0; j < 7; j++) { | |
| 32 | + if (LFSR & 0x01) { | |
| 33 | + const bitPosition = (1 << j) - 1; | |
| 34 | + if (bitPosition < 32) { | |
| 35 | + roundConstantLsw ^= 1 << bitPosition; | |
| 36 | + } | |
| 37 | + else /* if (bitPosition >= 32) */ { | |
| 38 | + roundConstantMsw ^= 1 << (bitPosition - 32); | |
| 39 | + } | |
| 40 | + } | |
| 41 | + // Compute next LFSR | |
| 42 | + if (LFSR & 0x80) { | |
| 43 | + // Primitive polynomial over GF(2): x^8 + x^6 + x^5 + x^4 + 1 | |
| 44 | + LFSR = (LFSR << 1) ^ 0x71; | |
| 45 | + } | |
| 46 | + else { | |
| 47 | + LFSR <<= 1; | |
| 48 | + } | |
| 49 | + } | |
| 50 | + ROUND_CONSTANTS[i] = new Word64(roundConstantMsw, roundConstantLsw); | |
| 51 | + } | |
| 52 | +}()); | |
| 53 | +// Reusable objects for temporary values | |
| 54 | +const T = []; | |
| 55 | +(function () { | |
| 56 | + for (let i = 0; i < 25; i++) { | |
| 57 | + T[i] = new Word64(0, 0); | |
| 58 | + } | |
| 59 | +}()); | |
| 60 | +export class SHA3 extends Hasher { | |
| 61 | + constructor(props) { | |
| 62 | + super(props); | |
| 63 | + this._blockSize = 1024 / 32; | |
| 64 | + this._state = []; | |
| 65 | + this._outputLength = 512; | |
| 66 | + this._props = props; | |
| 67 | + if (props) { | |
| 68 | + if (typeof props.outputLength !== "undefined") { | |
| 69 | + if (![224, 256, 384, 512].includes(props.outputLength)) { | |
| 70 | + throw new Error("Unsupported output length."); | |
| 71 | + } | |
| 72 | + this._outputLength = props.outputLength; | |
| 73 | + } | |
| 74 | + if (typeof props.state !== "undefined") { | |
| 75 | + this._state = props.state.map(s => s.clone()); | |
| 76 | + } | |
| 77 | + } | |
| 78 | + if (this._state.length === 0) { | |
| 79 | + for (let i = 0; i < 25; i++) { | |
| 80 | + this._state[i] = new Word64(0, 0); | |
| 81 | + } | |
| 82 | + } | |
| 83 | + this._blockSize = (1600 - 2 * this._outputLength) / 32; | |
| 84 | + } | |
| 85 | + _doReset() { | |
| 86 | + this._state = []; | |
| 87 | + for (let i = 0; i < 25; i++) { | |
| 88 | + this._state[i] = new Word64(0, 0); | |
| 89 | + } | |
| 90 | + this._blockSize = (1600 - 2 * this._outputLength) / 32; | |
| 91 | + } | |
| 92 | + _doProcessBlock(words, offset) { | |
| 93 | + // Shortcuts | |
| 94 | + const state = this._state; | |
| 95 | + const nBlockSizeLanes = this._blockSize / 2; | |
| 96 | + // Absorb | |
| 97 | + for (let i = 0; i < nBlockSizeLanes; i++) { | |
| 98 | + // Shortcuts | |
| 99 | + let W2i = words[offset + 2 * i]; | |
| 100 | + let W2i1 = words[offset + 2 * i + 1]; | |
| 101 | + // Swap endian | |
| 102 | + W2i = ((((W2i << 8) | (W2i >>> 24)) & 0x00ff00ff) | | |
| 103 | + (((W2i << 24) | (W2i >>> 8)) & 0xff00ff00)); | |
| 104 | + W2i1 = ((((W2i1 << 8) | (W2i1 >>> 24)) & 0x00ff00ff) | | |
| 105 | + (((W2i1 << 24) | (W2i1 >>> 8)) & 0xff00ff00)); | |
| 106 | + // Absorb message into state | |
| 107 | + state[i].high ^= W2i1; | |
| 108 | + state[i].low ^= W2i; | |
| 109 | + } | |
| 110 | + // Rounds | |
| 111 | + for (let round = 0; round < 24; round++) { | |
| 112 | + // Theta | |
| 113 | + for (let x = 0; x < 5; x++) { | |
| 114 | + // Mix column lanes | |
| 115 | + let tMsw = 0; | |
| 116 | + let tLsw = 0; | |
| 117 | + for (let y = 0; y < 5; y++) { | |
| 118 | + const l = state[x + 5 * y]; | |
| 119 | + tMsw ^= l.high; | |
| 120 | + tLsw ^= l.low; | |
| 121 | + } | |
| 122 | + // Temporary values | |
| 123 | + const Tx = T[x]; | |
| 124 | + Tx.high = tMsw; | |
| 125 | + Tx.low = tLsw; | |
| 126 | + } | |
| 127 | + for (let x = 0; x < 5; x++) { | |
| 128 | + // Shortcuts | |
| 129 | + const Tx4 = T[(x + 4) % 5]; | |
| 130 | + const Tx1 = T[(x + 1) % 5]; | |
| 131 | + const Tx1Msw = Tx1.high; | |
| 132 | + const Tx1Lsw = Tx1.low; | |
| 133 | + // Mix surrounding columns | |
| 134 | + const tMsw = Tx4.high ^ ((Tx1Msw << 1) | (Tx1Lsw >>> 31)); | |
| 135 | + const tLsw = Tx4.low ^ ((Tx1Lsw << 1) | (Tx1Msw >>> 31)); | |
| 136 | + for (let y = 0; y < 5; y++) { | |
| 137 | + const l = state[x + 5 * y]; | |
| 138 | + l.high ^= tMsw; | |
| 139 | + l.low ^= tLsw; | |
| 140 | + } | |
| 141 | + } | |
| 142 | + // Rho Pi | |
| 143 | + for (let laneIndex = 1; laneIndex < 25; laneIndex++) { | |
| 144 | + let tMsw; | |
| 145 | + let tLsw; | |
| 146 | + // Shortcuts | |
| 147 | + const laneMsw = state[laneIndex].high; | |
| 148 | + const laneLsw = state[laneIndex].low; | |
| 149 | + const rhoOffset = RHO_OFFSETS[laneIndex]; | |
| 150 | + // Rotate lanes | |
| 151 | + if (rhoOffset < 32) { | |
| 152 | + tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset)); | |
| 153 | + tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset)); | |
| 154 | + } | |
| 155 | + else /* if (rhoOffset >= 32) */ { | |
| 156 | + tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset)); | |
| 157 | + tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset)); | |
| 158 | + } | |
| 159 | + // Transpose lanes | |
| 160 | + const TPiLane = T[PI_INDEXES[laneIndex]]; | |
| 161 | + TPiLane.high = tMsw; | |
| 162 | + TPiLane.low = tLsw; | |
| 163 | + } | |
| 164 | + // Rho pi at x = y = 0 | |
| 165 | + const T0 = T[0]; | |
| 166 | + const state0 = state[0]; | |
| 167 | + T0.high = state0.high; | |
| 168 | + T0.low = state0.low; | |
| 169 | + // Chi | |
| 170 | + for (let x = 0; x < 5; x++) { | |
| 171 | + for (let y = 0; y < 5; y++) { | |
| 172 | + // Shortcuts | |
| 173 | + const laneIndex = x + 5 * y; | |
| 174 | + const l = state[laneIndex]; | |
| 175 | + const TLane = T[laneIndex]; | |
| 176 | + const Tx1Lane = T[((x + 1) % 5) + 5 * y]; | |
| 177 | + const Tx2Lane = T[((x + 2) % 5) + 5 * y]; | |
| 178 | + // Mix rows | |
| 179 | + l.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high); | |
| 180 | + l.low = TLane.low ^ (~Tx1Lane.low & Tx2Lane.low); | |
| 181 | + } | |
| 182 | + } | |
| 183 | + // Iota | |
| 184 | + const lane = state[0]; | |
| 185 | + const roundConstant = ROUND_CONSTANTS[round]; | |
| 186 | + lane.high ^= roundConstant.high; | |
| 187 | + lane.low ^= roundConstant.low; | |
| 188 | + } | |
| 189 | + } | |
| 190 | + _doFinalize() { | |
| 191 | + // Shortcuts | |
| 192 | + const data = this._data; | |
| 193 | + const dataWords = data.words; | |
| 194 | + const nBitsLeft = data.nSigBytes * 8; | |
| 195 | + const blockSizeBits = this.blockSize * 32; | |
| 196 | + // Add padding | |
| 197 | + dataWords[nBitsLeft >>> 5] |= 0x1 << (24 - nBitsLeft % 32); | |
| 198 | + dataWords[((Math.ceil((nBitsLeft + 1) / blockSizeBits) * blockSizeBits) >>> 5) - 1] |= 0x80; | |
| 199 | + data.nSigBytes = dataWords.length * 4; | |
| 200 | + // Hash final blocks | |
| 201 | + this._process(); | |
| 202 | + // Shortcuts | |
| 203 | + const state = this._state; | |
| 204 | + const outputLengthBytes = this._outputLength / 8; | |
| 205 | + const outputLengthLanes = outputLengthBytes / 8; | |
| 206 | + // Squeeze | |
| 207 | + const hashWords = []; | |
| 208 | + for (let i = 0; i < outputLengthLanes; i++) { | |
| 209 | + // Shortcuts | |
| 210 | + const lane = state[i]; | |
| 211 | + let laneMsw = lane.high; | |
| 212 | + let laneLsw = lane.low; | |
| 213 | + // Swap endian | |
| 214 | + laneMsw = ((((laneMsw << 8) | (laneMsw >>> 24)) & 0x00ff00ff) | | |
| 215 | + (((laneMsw << 24) | (laneMsw >>> 8)) & 0xff00ff00)); | |
| 216 | + laneLsw = ((((laneLsw << 8) | (laneLsw >>> 24)) & 0x00ff00ff) | | |
| 217 | + (((laneLsw << 24) | (laneLsw >>> 8)) & 0xff00ff00)); | |
| 218 | + // Squeeze state to retrieve hash | |
| 219 | + hashWords.push(laneLsw); | |
| 220 | + hashWords.push(laneMsw); | |
| 221 | + } | |
| 222 | + // Return final computed hash | |
| 223 | + return new Word32Array(hashWords, outputLengthBytes); | |
| 224 | + } | |
| 225 | + clone() { | |
| 226 | + const props = { | |
| 227 | + outputLength: this._outputLength, | |
| 228 | + state: this._state, | |
| 229 | + blockSize: this._blockSize, | |
| 230 | + data: this._data, | |
| 231 | + nBytes: this._nBytes, | |
| 232 | + }; | |
| 233 | + return new SHA3(props); | |
| 234 | + } | |
| 235 | + static hash(message, props) { | |
| 236 | + return new SHA3(props).finalize(message); | |
| 237 | + } | |
| 238 | +} | ... | ... |
app/static/content/jscrypto/es6/SHA384.d.ts
0 → 100644
| 1 | +import { Word64Array } from "./lib/Word64Array"; | |
| 2 | +import { SHA512 } from "./SHA512"; | |
| 3 | +import type { HasherProps } from "./lib/algorithm/Hasher"; | |
| 4 | +import type { Word32Array } from "./lib/Word32Array"; | |
| 5 | +export interface SHA384Props extends HasherProps { | |
| 6 | + hash: Word64Array; | |
| 7 | +} | |
| 8 | +export declare class SHA384 extends SHA512 { | |
| 9 | + protected _props?: Partial<SHA384Props>; | |
| 10 | + protected _hash: Word64Array; | |
| 11 | + constructor(props?: Partial<SHA384Props>); | |
| 12 | + protected _doReset(): void; | |
| 13 | + protected _doFinalize(): Word32Array; | |
| 14 | + clone(): SHA384; | |
| 15 | + static hash(message: Word32Array | string, props?: SHA384Props): Word32Array; | |
| 16 | +} | ... | ... |
app/static/content/jscrypto/es6/SHA384.js
0 → 100644
| 1 | +import { Word64, Word64Array } from "./lib/Word64Array"; | |
| 2 | +import { SHA512 } from "./SHA512"; | |
| 3 | +export class SHA384 extends SHA512 { | |
| 4 | + constructor(props) { | |
| 5 | + super(props); | |
| 6 | + this._hash = new Word64Array([ | |
| 7 | + new Word64(0xcbbb9d5d, 0xc1059ed8), new Word64(0x629a292a, 0x367cd507), | |
| 8 | + new Word64(0x9159015a, 0x3070dd17), new Word64(0x152fecd8, 0xf70e5939), | |
| 9 | + new Word64(0x67332667, 0xffc00b31), new Word64(0x8eb44a87, 0x68581511), | |
| 10 | + new Word64(0xdb0c2e0d, 0x64f98fa7), new Word64(0x47b5481d, 0xbefa4fa4) | |
| 11 | + ]); | |
| 12 | + this._props = props; | |
| 13 | + if (props && typeof props.hash !== "undefined") { | |
| 14 | + this._hash = props.hash.clone(); | |
| 15 | + } | |
| 16 | + } | |
| 17 | + _doReset() { | |
| 18 | + this._hash = new Word64Array([ | |
| 19 | + new Word64(0xcbbb9d5d, 0xc1059ed8), new Word64(0x629a292a, 0x367cd507), | |
| 20 | + new Word64(0x9159015a, 0x3070dd17), new Word64(0x152fecd8, 0xf70e5939), | |
| 21 | + new Word64(0x67332667, 0xffc00b31), new Word64(0x8eb44a87, 0x68581511), | |
| 22 | + new Word64(0xdb0c2e0d, 0x64f98fa7), new Word64(0x47b5481d, 0xbefa4fa4) | |
| 23 | + ]); | |
| 24 | + } | |
| 25 | + _doFinalize() { | |
| 26 | + const hash = super._doFinalize.call(this); | |
| 27 | + hash.nSigBytes -= 16; | |
| 28 | + return hash; | |
| 29 | + } | |
| 30 | + clone() { | |
| 31 | + const props = { hash: this._hash, blockSize: this._blockSize, data: this._data, nBytes: this._nBytes }; | |
| 32 | + return new SHA384(props); | |
| 33 | + } | |
| 34 | + static hash(message, props) { | |
| 35 | + return new SHA384(props).finalize(message); | |
| 36 | + } | |
| 37 | +} | ... | ... |
app/static/content/jscrypto/es6/SHA512.d.ts
0 → 100644
| 1 | +import { Hasher, HasherProps } from "./lib/algorithm/Hasher"; | |
| 2 | +import { Word64Array } from "./lib/Word64Array"; | |
| 3 | +import type { Word32Array } from "./lib/Word32Array"; | |
| 4 | +export interface SHA512Props extends HasherProps { | |
| 5 | + hash: Word64Array; | |
| 6 | +} | |
| 7 | +export declare class SHA512 extends Hasher { | |
| 8 | + protected _props?: Partial<SHA512Props>; | |
| 9 | + protected _blockSize: number; | |
| 10 | + protected _hash: Word64Array; | |
| 11 | + constructor(props?: Partial<SHA512Props>); | |
| 12 | + protected _doReset(): void; | |
| 13 | + protected _doProcessBlock(words: number[], offset: number): void; | |
| 14 | + protected _doFinalize(): Word32Array; | |
| 15 | + clone(): SHA512; | |
| 16 | + static hash(message: Word32Array | string, props?: SHA512Props): Word32Array; | |
| 17 | +} | ... | ... |
app/static/content/jscrypto/es6/SHA512.js
0 → 100644
| 1 | +import { Hasher } from "./lib/algorithm/Hasher"; | |
| 2 | +import { Word64, Word64Array } from "./lib/Word64Array"; | |
| 3 | +const K = [ | |
| 4 | + new Word64(0x428a2f98, 0xd728ae22), new Word64(0x71374491, 0x23ef65cd), | |
| 5 | + new Word64(0xb5c0fbcf, 0xec4d3b2f), new Word64(0xe9b5dba5, 0x8189dbbc), | |
| 6 | + new Word64(0x3956c25b, 0xf348b538), new Word64(0x59f111f1, 0xb605d019), | |
| 7 | + new Word64(0x923f82a4, 0xaf194f9b), new Word64(0xab1c5ed5, 0xda6d8118), | |
| 8 | + new Word64(0xd807aa98, 0xa3030242), new Word64(0x12835b01, 0x45706fbe), | |
| 9 | + new Word64(0x243185be, 0x4ee4b28c), new Word64(0x550c7dc3, 0xd5ffb4e2), | |
| 10 | + new Word64(0x72be5d74, 0xf27b896f), new Word64(0x80deb1fe, 0x3b1696b1), | |
| 11 | + new Word64(0x9bdc06a7, 0x25c71235), new Word64(0xc19bf174, 0xcf692694), | |
| 12 | + new Word64(0xe49b69c1, 0x9ef14ad2), new Word64(0xefbe4786, 0x384f25e3), | |
| 13 | + new Word64(0x0fc19dc6, 0x8b8cd5b5), new Word64(0x240ca1cc, 0x77ac9c65), | |
| 14 | + new Word64(0x2de92c6f, 0x592b0275), new Word64(0x4a7484aa, 0x6ea6e483), | |
| 15 | + new Word64(0x5cb0a9dc, 0xbd41fbd4), new Word64(0x76f988da, 0x831153b5), | |
| 16 | + new Word64(0x983e5152, 0xee66dfab), new Word64(0xa831c66d, 0x2db43210), | |
| 17 | + new Word64(0xb00327c8, 0x98fb213f), new Word64(0xbf597fc7, 0xbeef0ee4), | |
| 18 | + new Word64(0xc6e00bf3, 0x3da88fc2), new Word64(0xd5a79147, 0x930aa725), | |
| 19 | + new Word64(0x06ca6351, 0xe003826f), new Word64(0x14292967, 0x0a0e6e70), | |
| 20 | + new Word64(0x27b70a85, 0x46d22ffc), new Word64(0x2e1b2138, 0x5c26c926), | |
| 21 | + new Word64(0x4d2c6dfc, 0x5ac42aed), new Word64(0x53380d13, 0x9d95b3df), | |
| 22 | + new Word64(0x650a7354, 0x8baf63de), new Word64(0x766a0abb, 0x3c77b2a8), | |
| 23 | + new Word64(0x81c2c92e, 0x47edaee6), new Word64(0x92722c85, 0x1482353b), | |
| 24 | + new Word64(0xa2bfe8a1, 0x4cf10364), new Word64(0xa81a664b, 0xbc423001), | |
| 25 | + new Word64(0xc24b8b70, 0xd0f89791), new Word64(0xc76c51a3, 0x0654be30), | |
| 26 | + new Word64(0xd192e819, 0xd6ef5218), new Word64(0xd6990624, 0x5565a910), | |
| 27 | + new Word64(0xf40e3585, 0x5771202a), new Word64(0x106aa070, 0x32bbd1b8), | |
| 28 | + new Word64(0x19a4c116, 0xb8d2d0c8), new Word64(0x1e376c08, 0x5141ab53), | |
| 29 | + new Word64(0x2748774c, 0xdf8eeb99), new Word64(0x34b0bcb5, 0xe19b48a8), | |
| 30 | + new Word64(0x391c0cb3, 0xc5c95a63), new Word64(0x4ed8aa4a, 0xe3418acb), | |
| 31 | + new Word64(0x5b9cca4f, 0x7763e373), new Word64(0x682e6ff3, 0xd6b2b8a3), | |
| 32 | + new Word64(0x748f82ee, 0x5defb2fc), new Word64(0x78a5636f, 0x43172f60), | |
| 33 | + new Word64(0x84c87814, 0xa1f0ab72), new Word64(0x8cc70208, 0x1a6439ec), | |
| 34 | + new Word64(0x90befffa, 0x23631e28), new Word64(0xa4506ceb, 0xde82bde9), | |
| 35 | + new Word64(0xbef9a3f7, 0xb2c67915), new Word64(0xc67178f2, 0xe372532b), | |
| 36 | + new Word64(0xca273ece, 0xea26619c), new Word64(0xd186b8c7, 0x21c0c207), | |
| 37 | + new Word64(0xeada7dd6, 0xcde0eb1e), new Word64(0xf57d4f7f, 0xee6ed178), | |
| 38 | + new Word64(0x06f067aa, 0x72176fba), new Word64(0x0a637dc5, 0xa2c898a6), | |
| 39 | + new Word64(0x113f9804, 0xbef90dae), new Word64(0x1b710b35, 0x131c471b), | |
| 40 | + new Word64(0x28db77f5, 0x23047d84), new Word64(0x32caab7b, 0x40c72493), | |
| 41 | + new Word64(0x3c9ebe0a, 0x15c9bebc), new Word64(0x431d67c4, 0x9c100d4c), | |
| 42 | + new Word64(0x4cc5d4be, 0xcb3e42b6), new Word64(0x597f299c, 0xfc657e2a), | |
| 43 | + new Word64(0x5fcb6fab, 0x3ad6faec), new Word64(0x6c44198c, 0x4a475817), | |
| 44 | +]; | |
| 45 | +const W = []; | |
| 46 | +(function computeConstants() { | |
| 47 | + for (let i = 0; i < 80; i++) { | |
| 48 | + W[i] = new Word64(0, 0); | |
| 49 | + } | |
| 50 | +})(); | |
| 51 | +export class SHA512 extends Hasher { | |
| 52 | + constructor(props) { | |
| 53 | + super(props); | |
| 54 | + this._blockSize = 1024 / 32; | |
| 55 | + this._hash = new Word64Array([ | |
| 56 | + new Word64(0x6a09e667, 0xf3bcc908), new Word64(0xbb67ae85, 0x84caa73b), | |
| 57 | + new Word64(0x3c6ef372, 0xfe94f82b), new Word64(0xa54ff53a, 0x5f1d36f1), | |
| 58 | + new Word64(0x510e527f, 0xade682d1), new Word64(0x9b05688c, 0x2b3e6c1f), | |
| 59 | + new Word64(0x1f83d9ab, 0xfb41bd6b), new Word64(0x5be0cd19, 0x137e2179) | |
| 60 | + ]); | |
| 61 | + this._props = props; | |
| 62 | + if (props && typeof props.hash !== "undefined") { | |
| 63 | + this._hash = props.hash.clone(); | |
| 64 | + } | |
| 65 | + } | |
| 66 | + _doReset() { | |
| 67 | + this._hash = new Word64Array([ | |
| 68 | + new Word64(0x6a09e667, 0xf3bcc908), new Word64(0xbb67ae85, 0x84caa73b), | |
| 69 | + new Word64(0x3c6ef372, 0xfe94f82b), new Word64(0xa54ff53a, 0x5f1d36f1), | |
| 70 | + new Word64(0x510e527f, 0xade682d1), new Word64(0x9b05688c, 0x2b3e6c1f), | |
| 71 | + new Word64(0x1f83d9ab, 0xfb41bd6b), new Word64(0x5be0cd19, 0x137e2179) | |
| 72 | + ]); | |
| 73 | + } | |
| 74 | + _doProcessBlock(words, offset) { | |
| 75 | + // Shortcuts | |
| 76 | + const H = this._hash.words; | |
| 77 | + const H0 = H[0]; | |
| 78 | + const H1 = H[1]; | |
| 79 | + const H2 = H[2]; | |
| 80 | + const H3 = H[3]; | |
| 81 | + const H4 = H[4]; | |
| 82 | + const H5 = H[5]; | |
| 83 | + const H6 = H[6]; | |
| 84 | + const H7 = H[7]; | |
| 85 | + const H0h = H0.high; | |
| 86 | + let H0l = H0.low; | |
| 87 | + const H1h = H1.high; | |
| 88 | + let H1l = H1.low; | |
| 89 | + const H2h = H2.high; | |
| 90 | + let H2l = H2.low; | |
| 91 | + const H3h = H3.high; | |
| 92 | + let H3l = H3.low; | |
| 93 | + const H4h = H4.high; | |
| 94 | + let H4l = H4.low; | |
| 95 | + const H5h = H5.high; | |
| 96 | + let H5l = H5.low; | |
| 97 | + const H6h = H6.high; | |
| 98 | + let H6l = H6.low; | |
| 99 | + const H7h = H7.high; | |
| 100 | + let H7l = H7.low; | |
| 101 | + // Working variables | |
| 102 | + let ah = H0h; | |
| 103 | + let al = H0l; | |
| 104 | + let bh = H1h; | |
| 105 | + let bl = H1l; | |
| 106 | + let ch = H2h; | |
| 107 | + let cl = H2l; | |
| 108 | + let dh = H3h; | |
| 109 | + let dl = H3l; | |
| 110 | + let eh = H4h; | |
| 111 | + let el = H4l; | |
| 112 | + let fh = H5h; | |
| 113 | + let fl = H5l; | |
| 114 | + let gh = H6h; | |
| 115 | + let gl = H6l; | |
| 116 | + let hh = H7h; | |
| 117 | + let hl = H7l; | |
| 118 | + // Rounds | |
| 119 | + for (let i = 0; i < 80; i++) { | |
| 120 | + let Wil; | |
| 121 | + let Wih; | |
| 122 | + // Shortcut | |
| 123 | + const Wi = W[i]; | |
| 124 | + // Extend message | |
| 125 | + if (i < 16) { | |
| 126 | + Wih = Wi.high = words[offset + i * 2] | 0; | |
| 127 | + Wil = Wi.low = words[offset + i * 2 + 1] | 0; | |
| 128 | + } | |
| 129 | + else { | |
| 130 | + // Gamma0 | |
| 131 | + const gamma0x = W[i - 15]; | |
| 132 | + const gamma0xh = gamma0x.high; | |
| 133 | + const gamma0xl = gamma0x.low; | |
| 134 | + const gamma0h = ((gamma0xh >>> 1) | (gamma0xl << 31)) | |
| 135 | + ^ ((gamma0xh >>> 8) | (gamma0xl << 24)) | |
| 136 | + ^ (gamma0xh >>> 7); | |
| 137 | + const gamma0l = ((gamma0xl >>> 1) | (gamma0xh << 31)) | |
| 138 | + ^ ((gamma0xl >>> 8) | (gamma0xh << 24)) | |
| 139 | + ^ ((gamma0xl >>> 7) | (gamma0xh << 25)); | |
| 140 | + // Gamma1 | |
| 141 | + const gamma1x = W[i - 2]; | |
| 142 | + const gamma1xh = gamma1x.high; | |
| 143 | + const gamma1xl = gamma1x.low; | |
| 144 | + const gamma1h = ((gamma1xh >>> 19) | (gamma1xl << 13)) | |
| 145 | + ^ ((gamma1xh << 3) | (gamma1xl >>> 29)) ^ (gamma1xh >>> 6); | |
| 146 | + const gamma1l = ((gamma1xl >>> 19) | (gamma1xh << 13)) | |
| 147 | + ^ ((gamma1xl << 3) | (gamma1xh >>> 29)) ^ ((gamma1xl >>> 6) | (gamma1xh << 26)); | |
| 148 | + // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16] | |
| 149 | + const Wi7 = W[i - 7]; | |
| 150 | + const Wi7h = Wi7.high; | |
| 151 | + const Wi7l = Wi7.low; | |
| 152 | + const Wi16 = W[i - 16]; | |
| 153 | + const Wi16h = Wi16.high; | |
| 154 | + const Wi16l = Wi16.low; | |
| 155 | + Wil = gamma0l + Wi7l; | |
| 156 | + Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0); | |
| 157 | + Wil = Wil + gamma1l; | |
| 158 | + Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0); | |
| 159 | + Wil = Wil + Wi16l; | |
| 160 | + Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0); | |
| 161 | + Wi.high = Wih; | |
| 162 | + Wi.low = Wil; | |
| 163 | + } | |
| 164 | + const chh = (eh & fh) ^ (~eh & gh); | |
| 165 | + const chl = (el & fl) ^ (~el & gl); | |
| 166 | + const majh = (ah & bh) ^ (ah & ch) ^ (bh & ch); | |
| 167 | + const majl = (al & bl) ^ (al & cl) ^ (bl & cl); | |
| 168 | + const sigma0h = ((ah >>> 28) | (al << 4)) ^ ((ah << 30) | (al >>> 2)) ^ ((ah << 25) | (al >>> 7)); | |
| 169 | + const sigma0l = ((al >>> 28) | (ah << 4)) ^ ((al << 30) | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7)); | |
| 170 | + const sigma1h = ((eh >>> 14) | (el << 18)) ^ ((eh >>> 18) | (el << 14)) ^ ((eh << 23) | (el >>> 9)); | |
| 171 | + const sigma1l = ((el >>> 14) | (eh << 18)) ^ ((el >>> 18) | (eh << 14)) ^ ((el << 23) | (eh >>> 9)); | |
| 172 | + // t1 = h + sigma1 + ch + K[i] + W[i] | |
| 173 | + const Ki = K[i]; | |
| 174 | + const Kih = Ki.high; | |
| 175 | + const Kil = Ki.low; | |
| 176 | + let t1l = hl + sigma1l; | |
| 177 | + let t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0); | |
| 178 | + t1l = t1l + chl; | |
| 179 | + t1h = t1h + chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0); | |
| 180 | + t1l = t1l + Kil; | |
| 181 | + t1h = t1h + Kih + ((t1l >>> 0) < (Kil >>> 0) ? 1 : 0); | |
| 182 | + t1l = t1l + Wil; | |
| 183 | + t1h = t1h + Wih + ((t1l >>> 0) < (Wil >>> 0) ? 1 : 0); | |
| 184 | + // t2 = sigma0 + maj | |
| 185 | + const t2l = sigma0l + majl; | |
| 186 | + const t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0); | |
| 187 | + // Update working variables | |
| 188 | + hh = gh; | |
| 189 | + hl = gl; | |
| 190 | + gh = fh; | |
| 191 | + gl = fl; | |
| 192 | + fh = eh; | |
| 193 | + fl = el; | |
| 194 | + el = (dl + t1l) | 0; | |
| 195 | + eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0; | |
| 196 | + dh = ch; | |
| 197 | + dl = cl; | |
| 198 | + ch = bh; | |
| 199 | + cl = bl; | |
| 200 | + bh = ah; | |
| 201 | + bl = al; | |
| 202 | + al = (t1l + t2l) | 0; | |
| 203 | + ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0; | |
| 204 | + } | |
| 205 | + // Intermediate hash value | |
| 206 | + H0l = H0.low = (H0l + al); | |
| 207 | + H0.high = (H0h + ah + ((H0l >>> 0) < (al >>> 0) ? 1 : 0)); | |
| 208 | + H1l = H1.low = (H1l + bl); | |
| 209 | + H1.high = (H1h + bh + ((H1l >>> 0) < (bl >>> 0) ? 1 : 0)); | |
| 210 | + H2l = H2.low = (H2l + cl); | |
| 211 | + H2.high = (H2h + ch + ((H2l >>> 0) < (cl >>> 0) ? 1 : 0)); | |
| 212 | + H3l = H3.low = (H3l + dl); | |
| 213 | + H3.high = (H3h + dh + ((H3l >>> 0) < (dl >>> 0) ? 1 : 0)); | |
| 214 | + H4l = H4.low = (H4l + el); | |
| 215 | + H4.high = (H4h + eh + ((H4l >>> 0) < (el >>> 0) ? 1 : 0)); | |
| 216 | + H5l = H5.low = (H5l + fl); | |
| 217 | + H5.high = (H5h + fh + ((H5l >>> 0) < (fl >>> 0) ? 1 : 0)); | |
| 218 | + H6l = H6.low = (H6l + gl); | |
| 219 | + H6.high = (H6h + gh + ((H6l >>> 0) < (gl >>> 0) ? 1 : 0)); | |
| 220 | + H7l = H7.low = (H7l + hl); | |
| 221 | + H7.high = (H7h + hh + ((H7l >>> 0) < (hl >>> 0) ? 1 : 0)); | |
| 222 | + } | |
| 223 | + _doFinalize() { | |
| 224 | + // Shortcuts | |
| 225 | + const data = this._data; | |
| 226 | + const dataWords = data.words; | |
| 227 | + const nBitsTotal = this._nBytes * 8; | |
| 228 | + const nBitsLeft = data.nSigBytes * 8; | |
| 229 | + // Add padding | |
| 230 | + dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); | |
| 231 | + dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 30] = Math.floor(nBitsTotal / 0x100000000); | |
| 232 | + dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 31] = nBitsTotal; | |
| 233 | + data.nSigBytes = dataWords.length * 4; | |
| 234 | + // Hash final blocks | |
| 235 | + this._process(); | |
| 236 | + // Convert hash to 32-bit word array before returning | |
| 237 | + return this._hash.to32(); | |
| 238 | + } | |
| 239 | + clone() { | |
| 240 | + const props = { hash: this._hash, blockSize: this._blockSize, data: this._data, nBytes: this._nBytes }; | |
| 241 | + return new SHA512(props); | |
| 242 | + } | |
| 243 | + static hash(message, props) { | |
| 244 | + return new SHA512(props).finalize(message); | |
| 245 | + } | |
| 246 | +} | ... | ... |
app/static/content/jscrypto/es6/Utf16.d.ts
0 → 100644
| 1 | +export { Utf16LE, Utf16BE, Utf16 } from "./lib/encoder/Utf16"; | ... | ... |
app/static/content/jscrypto/es6/Utf16.js
0 → 100644
| 1 | +export { Utf16LE, Utf16BE, Utf16 } from "./lib/encoder/Utf16"; | ... | ... |
app/static/content/jscrypto/es6/Utf8.d.ts
0 → 100644
| 1 | +export { Utf8 } from "./lib/encoder/Utf8"; | ... | ... |
app/static/content/jscrypto/es6/Utf8.js
0 → 100644
| 1 | +export { Utf8 } from "./lib/encoder/Utf8"; | ... | ... |
| 1 | +export { Word32Array } from "./lib/Word32Array"; | ... | ... |
| 1 | +export { Word32Array } from "./lib/Word32Array"; | ... | ... |
| 1 | +export { Word64, Word64Array } from "./lib/Word64Array"; | ... | ... |
| 1 | +export { Word64, Word64Array } from "./lib/Word64Array"; | ... | ... |
| 1 | +export { OpenSSLFormatter } from "../lib/algorithm/cipher/formatter/OpenSSLFormatter"; | ... | ... |
| 1 | +export { OpenSSLFormatter } from "../lib/algorithm/cipher/formatter/OpenSSLFormatter"; | ... | ... |
app/static/content/jscrypto/es6/index.d.ts
0 → 100644
| 1 | +export { Word32Array, Word64Array, Word64, Base64, Hex, Latin1, Utf8, Utf16, Utf16BE, Utf16LE, OpenSSLKDF, EvpKDF, PBKDF2, } from "./lib/index"; | |
| 2 | +export { SerializableCipher } from "./lib/algorithm/cipher/SerializableCipher"; | |
| 3 | +export { PasswordBasedCipher } from "./lib/algorithm/cipher/PasswordBasedCipher"; | |
| 4 | +export { CipherParams } from "./lib/algorithm/cipher/CipherParams"; | |
| 5 | +export { Hmac } from "./Hmac"; | |
| 6 | +export { HmacMD5 } from "./HmacMD5"; | |
| 7 | +export { HmacSHA1 } from "./HmacSHA1"; | |
| 8 | +export { HmacSHA224 } from "./HmacSHA224"; | |
| 9 | +export { HmacSHA256 } from "./HmacSHA256"; | |
| 10 | +export { HmacSHA384 } from "./HmacSHA384"; | |
| 11 | +export { HmacSHA512 } from "./HmacSHA512"; | |
| 12 | +export { GMAC } from "./GMAC"; | |
| 13 | +export { CBCMAC } from "./CBCMAC"; | |
| 14 | +export { MD5 } from "./MD5"; | |
| 15 | +export { SHA1 } from "./SHA1"; | |
| 16 | +export { SHA224 } from "./SHA224"; | |
| 17 | +export { SHA256 } from "./SHA256"; | |
| 18 | +export { SHA384 } from "./SHA384"; | |
| 19 | +export { SHA512 } from "./SHA512"; | |
| 20 | +export { SHA3 } from "./SHA3"; | |
| 21 | +export { AES } from "./AES"; | |
| 22 | +export { DES } from "./DES"; | |
| 23 | +export { DES3 } from "./DES3"; | |
| 24 | +export { RIPEMD160 } from "./RIPEMD160"; | |
| 25 | +export { Rabbit } from "./Rabbit"; | |
| 26 | +export { RC4 } from "./RC4"; | |
| 27 | +export { RC4Drop } from "./RC4Drop"; | |
| 28 | +import { CBC } from "./mode/CBC"; | |
| 29 | +import { CFB } from "./mode/CFB"; | |
| 30 | +import { CTR } from "./mode/CTR"; | |
| 31 | +import { ECB } from "./mode/ECB"; | |
| 32 | +import { OFB } from "./mode/OFB"; | |
| 33 | +import { GCM } from "./mode/GCM"; | |
| 34 | +import { CCM } from "./mode/CCM"; | |
| 35 | +export declare const mode: { | |
| 36 | + CBC: typeof CBC; | |
| 37 | + CFB: typeof CFB; | |
| 38 | + CTR: typeof CTR; | |
| 39 | + ECB: typeof ECB; | |
| 40 | + OFB: typeof OFB; | |
| 41 | + GCM: typeof GCM; | |
| 42 | + CCM: typeof CCM; | |
| 43 | +}; | |
| 44 | +export declare const pad: { | |
| 45 | + AnsiX923: import("./lib/algorithm/cipher/pad/type").Pad; | |
| 46 | + ISO10126: import("./lib/algorithm/cipher/pad/type").Pad; | |
| 47 | + ISO97971: import("./lib/algorithm/cipher/pad/type").Pad; | |
| 48 | + Pkcs7: import("./lib/algorithm/cipher/pad/type").Pad; | |
| 49 | + NoPadding: import("./lib/algorithm/cipher/pad/type").Pad; | |
| 50 | + Zero: import("./lib/algorithm/cipher/pad/type").Pad; | |
| 51 | +}; | |
| 52 | +export declare const formatter: { | |
| 53 | + OpenSSLFormatter: import("./lib/algorithm/cipher/formatter/type").Formatter; | |
| 54 | +}; | ... | ... |
app/static/content/jscrypto/es6/index.js
0 → 100644
| 1 | +export { Word32Array, Word64Array, Word64, Base64, Hex, Latin1, Utf8, Utf16, Utf16BE, Utf16LE, OpenSSLKDF, EvpKDF, PBKDF2, } from "./lib/index"; | |
| 2 | +export { SerializableCipher } from "./lib/algorithm/cipher/SerializableCipher"; | |
| 3 | +export { PasswordBasedCipher } from "./lib/algorithm/cipher/PasswordBasedCipher"; | |
| 4 | +export { CipherParams } from "./lib/algorithm/cipher/CipherParams"; | |
| 5 | +export { Hmac } from "./Hmac"; | |
| 6 | +export { HmacMD5 } from "./HmacMD5"; | |
| 7 | +export { HmacSHA1 } from "./HmacSHA1"; | |
| 8 | +export { HmacSHA224 } from "./HmacSHA224"; | |
| 9 | +export { HmacSHA256 } from "./HmacSHA256"; | |
| 10 | +export { HmacSHA384 } from "./HmacSHA384"; | |
| 11 | +export { HmacSHA512 } from "./HmacSHA512"; | |
| 12 | +export { GMAC } from "./GMAC"; | |
| 13 | +export { CBCMAC } from "./CBCMAC"; | |
| 14 | +export { MD5 } from "./MD5"; | |
| 15 | +export { SHA1 } from "./SHA1"; | |
| 16 | +export { SHA224 } from "./SHA224"; | |
| 17 | +export { SHA256 } from "./SHA256"; | |
| 18 | +export { SHA384 } from "./SHA384"; | |
| 19 | +export { SHA512 } from "./SHA512"; | |
| 20 | +export { SHA3 } from "./SHA3"; | |
| 21 | +export { AES } from "./AES"; | |
| 22 | +export { DES } from "./DES"; | |
| 23 | +export { DES3 } from "./DES3"; | |
| 24 | +export { RIPEMD160 } from "./RIPEMD160"; | |
| 25 | +export { Rabbit } from "./Rabbit"; | |
| 26 | +export { RC4 } from "./RC4"; | |
| 27 | +export { RC4Drop } from "./RC4Drop"; | |
| 28 | +import { CBC } from "./mode/CBC"; | |
| 29 | +import { CFB } from "./mode/CFB"; | |
| 30 | +import { CTR } from "./mode/CTR"; | |
| 31 | +import { ECB } from "./mode/ECB"; | |
| 32 | +import { OFB } from "./mode/OFB"; | |
| 33 | +import { GCM } from "./mode/GCM"; | |
| 34 | +import { CCM } from "./mode/CCM"; | |
| 35 | +export const mode = { | |
| 36 | + CBC, | |
| 37 | + CFB, | |
| 38 | + CTR, | |
| 39 | + ECB, | |
| 40 | + OFB, | |
| 41 | + GCM, | |
| 42 | + CCM, | |
| 43 | +}; | |
| 44 | +import { AnsiX923 } from "./pad/AnsiX923"; | |
| 45 | +import { ISO10126 } from "./pad/ISO10126"; | |
| 46 | +import { ISO97971 } from "./pad/ISO97971"; | |
| 47 | +import { Pkcs7 } from "./pad/Pkcs7"; | |
| 48 | +import { NoPadding } from "./pad/NoPadding"; | |
| 49 | +import { Zero } from "./pad/Zero"; | |
| 50 | +export const pad = { | |
| 51 | + AnsiX923, | |
| 52 | + ISO10126, | |
| 53 | + ISO97971, | |
| 54 | + Pkcs7, | |
| 55 | + NoPadding, | |
| 56 | + Zero, | |
| 57 | +}; | |
| 58 | +import { OpenSSLFormatter } from "./formatter/OpenSSLFormatter"; | |
| 59 | +export const formatter = { | |
| 60 | + OpenSSLFormatter, | |
| 61 | +}; | ... | ... |
| 1 | +import type { IEncoder } from "./type"; | |
| 2 | +declare type ByteArray = ArrayBuffer | Uint8Array | Int8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array; | |
| 3 | +/** | |
| 4 | + * An array of 32bit words | |
| 5 | + */ | |
| 6 | +export declare class Word32Array { | |
| 7 | + private readonly _words; | |
| 8 | + private _nSignificantBytes; | |
| 9 | + /** | |
| 10 | + * Initializes a newly created word array. | |
| 11 | + * | |
| 12 | + * ByteArray Support thanks to | |
| 13 | + * https://github.com/entronad/crypto-es/blob/master/lib/core.js | |
| 14 | + * MIT License Copyright(c) LIN Chen | |
| 15 | + * | |
| 16 | + * @param {Array} words (Optional) An array of 32-bit words. | |
| 17 | + * @param {number} nSignificantBytes (Optional) The number of significant bytes in the words. | |
| 18 | + * @example | |
| 19 | + * var words = new Word32Array(); | |
| 20 | + * var words = new Word32Array([0x00010203, 0x04050607]); | |
| 21 | + * var words = new Word32Array([0x00010203, 0x04050607], 6); | |
| 22 | + * // Cloning wordArray can be done like below. | |
| 23 | + * var clone = (new Word32Array([0x00010203, 0x04050607])).clone(); | |
| 24 | + * // or | |
| 25 | + * var clone = new Word32Array(new Word32Array([0x00010203, 0x04050607])); | |
| 26 | + */ | |
| 27 | + constructor(words?: number[] | Word32Array | ByteArray | unknown, nSignificantBytes?: number); | |
| 28 | + get nSigBytes(): number; | |
| 29 | + /** | |
| 30 | + * Set significant bytes | |
| 31 | + * @param {number} n - significant bytes | |
| 32 | + */ | |
| 33 | + set nSigBytes(n: number); | |
| 34 | + /** | |
| 35 | + * Get raw reference of internal words. | |
| 36 | + * Modification of this raw array will affect internal words. | |
| 37 | + */ | |
| 38 | + get words(): number[]; | |
| 39 | + /** | |
| 40 | + * Converts this word array to a string. | |
| 41 | + * | |
| 42 | + * @param {IEncoder?} encoder The encoding strategy to use. Default: CryptoJS.enc.Hex | |
| 43 | + * @return {string} The stringified word array. | |
| 44 | + * @example | |
| 45 | + * var string = wordArray + ''; | |
| 46 | + * var string = wordArray.toString(); | |
| 47 | + * var string = wordArray.toString(Utf8); | |
| 48 | + */ | |
| 49 | + toString(encoder?: IEncoder): string; | |
| 50 | + /** | |
| 51 | + * Converts this 32bit word array to Uint8Array | |
| 52 | + * | |
| 53 | + * @return {Uint8Array} Unsigned int 8bit array | |
| 54 | + * @example | |
| 55 | + * var word = new Word32Array([0x00102030]); | |
| 56 | + * var uint8 = word.toUint8Array(); // Uint8Array(4) [ 0, 16, 32, 48 ] | |
| 57 | + */ | |
| 58 | + toUint8Array(): Uint8Array; | |
| 59 | + /** | |
| 60 | + * Concatenates a word array to this word array. | |
| 61 | + * | |
| 62 | + * @param {Word32Array} w The word array to append. | |
| 63 | + * @return {Word32Array} This word array. | |
| 64 | + * @example | |
| 65 | + * wordArray1.concat(wordArray2); | |
| 66 | + */ | |
| 67 | + concat(w: Word32Array): this; | |
| 68 | + /** | |
| 69 | + * Removes insignificant bits. | |
| 70 | + * | |
| 71 | + * @example | |
| 72 | + * wordArray.clamp(); | |
| 73 | + */ | |
| 74 | + clamp(): void; | |
| 75 | + /** | |
| 76 | + * Creates a copy of this word array. | |
| 77 | + * | |
| 78 | + * @return {Word32Array} The clone. | |
| 79 | + * @example | |
| 80 | + * var clone = word32Array.clone(); | |
| 81 | + */ | |
| 82 | + clone(): Word32Array; | |
| 83 | + /** | |
| 84 | + * Creates a word array filled with random bytes. | |
| 85 | + * | |
| 86 | + * @param {number} nBytes The number of random bytes to generate. | |
| 87 | + * @return {Word32Array} The random word array. | |
| 88 | + * @static | |
| 89 | + * @example | |
| 90 | + * var wordArray = Word32Array.random(16); | |
| 91 | + */ | |
| 92 | + static random(nBytes: number): Word32Array; | |
| 93 | +} | |
| 94 | +export {}; | ... | ... |
| 1 | +import { Hex } from "./encoder/Hex"; | |
| 2 | +import { random } from "./random"; | |
| 3 | +/** | |
| 4 | + * An array of 32bit words | |
| 5 | + */ | |
| 6 | +export class Word32Array { | |
| 7 | + /** | |
| 8 | + * Initializes a newly created word array. | |
| 9 | + * | |
| 10 | + * ByteArray Support thanks to | |
| 11 | + * https://github.com/entronad/crypto-es/blob/master/lib/core.js | |
| 12 | + * MIT License Copyright(c) LIN Chen | |
| 13 | + * | |
| 14 | + * @param {Array} words (Optional) An array of 32-bit words. | |
| 15 | + * @param {number} nSignificantBytes (Optional) The number of significant bytes in the words. | |
| 16 | + * @example | |
| 17 | + * var words = new Word32Array(); | |
| 18 | + * var words = new Word32Array([0x00010203, 0x04050607]); | |
| 19 | + * var words = new Word32Array([0x00010203, 0x04050607], 6); | |
| 20 | + * // Cloning wordArray can be done like below. | |
| 21 | + * var clone = (new Word32Array([0x00010203, 0x04050607])).clone(); | |
| 22 | + * // or | |
| 23 | + * var clone = new Word32Array(new Word32Array([0x00010203, 0x04050607])); | |
| 24 | + */ | |
| 25 | + constructor(words, nSignificantBytes) { | |
| 26 | + if (Array.isArray(words) || !words) { | |
| 27 | + this._words = Array.isArray(words) ? words : []; | |
| 28 | + this._nSignificantBytes = typeof nSignificantBytes === "number" ? nSignificantBytes : this._words.length * 4; | |
| 29 | + return; | |
| 30 | + } | |
| 31 | + else if (words instanceof Word32Array) { | |
| 32 | + this._words = words.words.slice(); | |
| 33 | + this._nSignificantBytes = words.nSigBytes; | |
| 34 | + return; | |
| 35 | + } | |
| 36 | + let uint8Array; | |
| 37 | + // IE9 does not implement TypedArray. So catch exception for that case. | |
| 38 | + try { | |
| 39 | + if (words instanceof ArrayBuffer) { | |
| 40 | + uint8Array = new Uint8Array(words); | |
| 41 | + } | |
| 42 | + else if (words instanceof Uint8Array | |
| 43 | + || words instanceof Int8Array | |
| 44 | + || words instanceof Uint8ClampedArray | |
| 45 | + || words instanceof Int16Array | |
| 46 | + || words instanceof Uint16Array | |
| 47 | + || words instanceof Int32Array | |
| 48 | + || words instanceof Uint32Array | |
| 49 | + || words instanceof Float32Array | |
| 50 | + || words instanceof Float64Array) { | |
| 51 | + uint8Array = new Uint8Array(words.buffer, words.byteOffset, words.byteLength); | |
| 52 | + } | |
| 53 | + } | |
| 54 | + catch (e) { | |
| 55 | + throw new Error("Invalid argument"); | |
| 56 | + } | |
| 57 | + if (!uint8Array) { | |
| 58 | + throw new Error("Invalid argument"); | |
| 59 | + } | |
| 60 | + const byteLen = uint8Array.byteLength; | |
| 61 | + const w = []; | |
| 62 | + for (let i = 0; i < byteLen; i++) { | |
| 63 | + w[i >>> 2] |= uint8Array[i] << (24 - (i % 4) * 8); | |
| 64 | + } | |
| 65 | + this._words = w; | |
| 66 | + this._nSignificantBytes = byteLen; | |
| 67 | + } | |
| 68 | + get nSigBytes() { | |
| 69 | + return this._nSignificantBytes; | |
| 70 | + } | |
| 71 | + /** | |
| 72 | + * Set significant bytes | |
| 73 | + * @param {number} n - significant bytes | |
| 74 | + */ | |
| 75 | + set nSigBytes(n) { | |
| 76 | + this._nSignificantBytes = n; | |
| 77 | + } | |
| 78 | + /** | |
| 79 | + * Get raw reference of internal words. | |
| 80 | + * Modification of this raw array will affect internal words. | |
| 81 | + */ | |
| 82 | + get words() { | |
| 83 | + return this._words; | |
| 84 | + } | |
| 85 | + /** | |
| 86 | + * Converts this word array to a string. | |
| 87 | + * | |
| 88 | + * @param {IEncoder?} encoder The encoding strategy to use. Default: CryptoJS.enc.Hex | |
| 89 | + * @return {string} The stringified word array. | |
| 90 | + * @example | |
| 91 | + * var string = wordArray + ''; | |
| 92 | + * var string = wordArray.toString(); | |
| 93 | + * var string = wordArray.toString(Utf8); | |
| 94 | + */ | |
| 95 | + toString(encoder) { | |
| 96 | + if (!encoder) { | |
| 97 | + return Hex.stringify(this); | |
| 98 | + } | |
| 99 | + return encoder.stringify(this); | |
| 100 | + } | |
| 101 | + /** | |
| 102 | + * Converts this 32bit word array to Uint8Array | |
| 103 | + * | |
| 104 | + * @return {Uint8Array} Unsigned int 8bit array | |
| 105 | + * @example | |
| 106 | + * var word = new Word32Array([0x00102030]); | |
| 107 | + * var uint8 = word.toUint8Array(); // Uint8Array(4) [ 0, 16, 32, 48 ] | |
| 108 | + */ | |
| 109 | + toUint8Array() { | |
| 110 | + const words = this._words; | |
| 111 | + const nB = this._nSignificantBytes; | |
| 112 | + const uint8Array = new Uint8Array(nB); | |
| 113 | + for (let i = 0; i < nB; i++) { | |
| 114 | + uint8Array[i] = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; | |
| 115 | + } | |
| 116 | + return uint8Array; | |
| 117 | + } | |
| 118 | + /** | |
| 119 | + * Concatenates a word array to this word array. | |
| 120 | + * | |
| 121 | + * @param {Word32Array} w The word array to append. | |
| 122 | + * @return {Word32Array} This word array. | |
| 123 | + * @example | |
| 124 | + * wordArray1.concat(wordArray2); | |
| 125 | + */ | |
| 126 | + concat(w) { | |
| 127 | + const words = w.words.slice(); | |
| 128 | + const N = w.nSigBytes; | |
| 129 | + this.clamp(); | |
| 130 | + if (this._nSignificantBytes % 4) { | |
| 131 | + // Copy one byte at a time | |
| 132 | + for (let i = 0; i < N; i++) { | |
| 133 | + const b = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; | |
| 134 | + this._words[(this._nSignificantBytes + i) >>> 2] |= b << (24 - ((this._nSignificantBytes + i) % 4) * 8); | |
| 135 | + } | |
| 136 | + } | |
| 137 | + else { | |
| 138 | + // Copy one word at a time | |
| 139 | + for (let i = 0; i < N; i += 4) { | |
| 140 | + this._words[(this._nSignificantBytes + i) >>> 2] = words[i >>> 2]; | |
| 141 | + } | |
| 142 | + } | |
| 143 | + this._nSignificantBytes += N; | |
| 144 | + // Chainable | |
| 145 | + return this; | |
| 146 | + } | |
| 147 | + /** | |
| 148 | + * Removes insignificant bits. | |
| 149 | + * | |
| 150 | + * @example | |
| 151 | + * wordArray.clamp(); | |
| 152 | + */ | |
| 153 | + clamp() { | |
| 154 | + const n = this._nSignificantBytes; | |
| 155 | + this._words[n >>> 2] &= 0xffffffff << (32 - (n % 4) * 8); | |
| 156 | + this._words.length = Math.ceil(n / 4); | |
| 157 | + } | |
| 158 | + /** | |
| 159 | + * Creates a copy of this word array. | |
| 160 | + * | |
| 161 | + * @return {Word32Array} The clone. | |
| 162 | + * @example | |
| 163 | + * var clone = word32Array.clone(); | |
| 164 | + */ | |
| 165 | + clone() { | |
| 166 | + return new Word32Array(this._words.slice(), this._nSignificantBytes); | |
| 167 | + } | |
| 168 | + /** | |
| 169 | + * Creates a word array filled with random bytes. | |
| 170 | + * | |
| 171 | + * @param {number} nBytes The number of random bytes to generate. | |
| 172 | + * @return {Word32Array} The random word array. | |
| 173 | + * @static | |
| 174 | + * @example | |
| 175 | + * var wordArray = Word32Array.random(16); | |
| 176 | + */ | |
| 177 | + static random(nBytes) { | |
| 178 | + const words = []; | |
| 179 | + for (let i = 0; i < nBytes; i += 4) { | |
| 180 | + words.push(random()); | |
| 181 | + } | |
| 182 | + return new Word32Array(words, nBytes); | |
| 183 | + } | |
| 184 | +} | ... | ... |
| 1 | +import type { IEncoder } from "./type"; | |
| 2 | +import { Word32Array } from "./Word32Array"; | |
| 3 | +export declare class Word64 { | |
| 4 | + high: number; | |
| 5 | + low: number; | |
| 6 | + constructor(high: number, low: number); | |
| 7 | + clone(): Word64; | |
| 8 | +} | |
| 9 | +/** | |
| 10 | + * An array of 64bit words | |
| 11 | + */ | |
| 12 | +export declare class Word64Array { | |
| 13 | + private readonly _words; | |
| 14 | + private _nSignificantBytes; | |
| 15 | + /** | |
| 16 | + * Initializes a newly created word array. | |
| 17 | + * | |
| 18 | + * @param {Array} words (Optional) An array of 64-bit words. | |
| 19 | + * @param {number} nSignificantBytes (Optional) The number of significant bytes in the words. | |
| 20 | + * | |
| 21 | + * @example | |
| 22 | + * var wordArray = new Word64Array(); | |
| 23 | + * var wordArray = new Word64Array([new Word64(0x00010203, 0x04050607)]); | |
| 24 | + * var wordArray = new Word46Array([new Word64(0x00010203, 0x04050607)], 6); | |
| 25 | + */ | |
| 26 | + constructor(words?: Word64[], nSignificantBytes?: number); | |
| 27 | + get nSigBytes(): number; | |
| 28 | + /** | |
| 29 | + * Set significant bytes | |
| 30 | + * @param {number} n - significant bytes | |
| 31 | + */ | |
| 32 | + set nSigBytes(n: number); | |
| 33 | + /** | |
| 34 | + * Get raw reference of internal words. | |
| 35 | + * Modification of this raw array will affect internal words. | |
| 36 | + */ | |
| 37 | + get words(): Word64[]; | |
| 38 | + /** | |
| 39 | + * Converts this 64-bit word array to a 32-bit word array. | |
| 40 | + * | |
| 41 | + * @return {Word32Array} This word array's data as a 32-bit word array. | |
| 42 | + * | |
| 43 | + * @example | |
| 44 | + * | |
| 45 | + * var x32WordArray = x64WordArray.toX32(); | |
| 46 | + */ | |
| 47 | + to32(): Word32Array; | |
| 48 | + /** | |
| 49 | + * Converts this word array to a string. | |
| 50 | + * | |
| 51 | + * @param {IEncoder?} encoder The encoding strategy to use. Default: CryptoJS.enc.Hex | |
| 52 | + * @return {string} The stringified word array. | |
| 53 | + * @example | |
| 54 | + * var string = wordArray + ''; | |
| 55 | + * var string = wordArray.toString(); | |
| 56 | + * var string = wordArray.toString(Utf8); | |
| 57 | + */ | |
| 58 | + toString(encoder?: IEncoder): string; | |
| 59 | + /** | |
| 60 | + * Creates a copy of this word array. | |
| 61 | + * | |
| 62 | + * @return {Word64Array} The clone. | |
| 63 | + * @example | |
| 64 | + * var clone = wordArray.clone(); | |
| 65 | + */ | |
| 66 | + clone(): Word64Array; | |
| 67 | +} | ... | ... |
| 1 | +import { Hex } from "./encoder/Hex"; | |
| 2 | +import { Word32Array } from "./Word32Array"; | |
| 3 | +export class Word64 { | |
| 4 | + constructor(high, low) { | |
| 5 | + this.high = high; | |
| 6 | + this.low = low; | |
| 7 | + } | |
| 8 | + clone() { | |
| 9 | + return new Word64(this.high, this.low); | |
| 10 | + } | |
| 11 | +} | |
| 12 | +/** | |
| 13 | + * An array of 64bit words | |
| 14 | + */ | |
| 15 | +export class Word64Array { | |
| 16 | + /** | |
| 17 | + * Initializes a newly created word array. | |
| 18 | + * | |
| 19 | + * @param {Array} words (Optional) An array of 64-bit words. | |
| 20 | + * @param {number} nSignificantBytes (Optional) The number of significant bytes in the words. | |
| 21 | + * | |
| 22 | + * @example | |
| 23 | + * var wordArray = new Word64Array(); | |
| 24 | + * var wordArray = new Word64Array([new Word64(0x00010203, 0x04050607)]); | |
| 25 | + * var wordArray = new Word46Array([new Word64(0x00010203, 0x04050607)], 6); | |
| 26 | + */ | |
| 27 | + constructor(words, nSignificantBytes) { | |
| 28 | + this._words = words || []; | |
| 29 | + this._nSignificantBytes = typeof nSignificantBytes === "number" ? nSignificantBytes : this._words.length * 8; | |
| 30 | + } | |
| 31 | + get nSigBytes() { | |
| 32 | + return this._nSignificantBytes; | |
| 33 | + } | |
| 34 | + /** | |
| 35 | + * Set significant bytes | |
| 36 | + * @param {number} n - significant bytes | |
| 37 | + */ | |
| 38 | + set nSigBytes(n) { | |
| 39 | + this._nSignificantBytes = n; | |
| 40 | + } | |
| 41 | + /** | |
| 42 | + * Get raw reference of internal words. | |
| 43 | + * Modification of this raw array will affect internal words. | |
| 44 | + */ | |
| 45 | + get words() { | |
| 46 | + return this._words; | |
| 47 | + } | |
| 48 | + /** | |
| 49 | + * Converts this 64-bit word array to a 32-bit word array. | |
| 50 | + * | |
| 51 | + * @return {Word32Array} This word array's data as a 32-bit word array. | |
| 52 | + * | |
| 53 | + * @example | |
| 54 | + * | |
| 55 | + * var x32WordArray = x64WordArray.toX32(); | |
| 56 | + */ | |
| 57 | + to32() { | |
| 58 | + const words32 = []; | |
| 59 | + for (let i = 0; i < this._words.length; i++) { | |
| 60 | + const word64 = this._words[i]; | |
| 61 | + words32.push(word64.high); | |
| 62 | + words32.push(word64.low); | |
| 63 | + } | |
| 64 | + return new Word32Array(words32, this._nSignificantBytes); | |
| 65 | + } | |
| 66 | + /** | |
| 67 | + * Converts this word array to a string. | |
| 68 | + * | |
| 69 | + * @param {IEncoder?} encoder The encoding strategy to use. Default: CryptoJS.enc.Hex | |
| 70 | + * @return {string} The stringified word array. | |
| 71 | + * @example | |
| 72 | + * var string = wordArray + ''; | |
| 73 | + * var string = wordArray.toString(); | |
| 74 | + * var string = wordArray.toString(Utf8); | |
| 75 | + */ | |
| 76 | + toString(encoder) { | |
| 77 | + if (!encoder) { | |
| 78 | + return Hex.stringify(this.to32()); | |
| 79 | + } | |
| 80 | + return encoder.stringify(this.to32()); | |
| 81 | + } | |
| 82 | + /** | |
| 83 | + * Creates a copy of this word array. | |
| 84 | + * | |
| 85 | + * @return {Word64Array} The clone. | |
| 86 | + * @example | |
| 87 | + * var clone = wordArray.clone(); | |
| 88 | + */ | |
| 89 | + clone() { | |
| 90 | + const words = this._words.slice(); | |
| 91 | + for (let i = 0; i < words.length; i++) { | |
| 92 | + words[i] = words[i].clone(); | |
| 93 | + } | |
| 94 | + return new Word64Array(words, this._nSignificantBytes); | |
| 95 | + } | |
| 96 | +} | ... | ... |
| 1 | +import { Word32Array } from "../Word32Array"; | |
| 2 | +export interface BufferedBlockAlgorithmProps { | |
| 3 | + data: Word32Array; | |
| 4 | + nBytes: number; | |
| 5 | +} | |
| 6 | +export declare class BufferedBlockAlgorithm { | |
| 7 | + protected _props?: Partial<BufferedBlockAlgorithmProps>; | |
| 8 | + protected _data: Word32Array; | |
| 9 | + protected _nBytes: number; | |
| 10 | + protected _minBufferSize: number; | |
| 11 | + protected _blockSize: number; | |
| 12 | + constructor(props?: Partial<BufferedBlockAlgorithmProps>); | |
| 13 | + get blockSize(): number; | |
| 14 | + /** | |
| 15 | + * Resets this block algorithm's data buffer to its initial state. | |
| 16 | + * | |
| 17 | + * @example | |
| 18 | + * bufferedBlockAlgorithm.reset(); | |
| 19 | + */ | |
| 20 | + reset(data?: Word32Array, nBytes?: number): void; | |
| 21 | + /** | |
| 22 | + * Adds new data to this block algorithm's buffer. | |
| 23 | + * | |
| 24 | + * @param {Word32Array|string} data The data to append. Strings are converted to a WordArray using UTF-8. | |
| 25 | + * @example | |
| 26 | + * bufferedBlockAlgorithm.append('data'); | |
| 27 | + * bufferedBlockAlgorithm.append(wordArray); | |
| 28 | + */ | |
| 29 | + protected _append(data: Word32Array | string): void; | |
| 30 | + /** | |
| 31 | + * Processes available data blocks. | |
| 32 | + * This method invokes doProcessBlock(offset), which must be implemented by a concrete subtype. | |
| 33 | + * | |
| 34 | + * @param {boolean?} doFlush Whether all blocks and partial blocks should be processed. | |
| 35 | + * @return {Word32Array} The processed data. | |
| 36 | + * @example | |
| 37 | + * var processedData = bufferedBlockAlgorithm.process(); | |
| 38 | + * var processedData = bufferedBlockAlgorithm.process(!!'flush'); | |
| 39 | + */ | |
| 40 | + protected _process(doFlush?: boolean): Word32Array; | |
| 41 | + /** | |
| 42 | + * @abstract | |
| 43 | + */ | |
| 44 | + protected _doProcessBlock(words: number[], offset: number): void; | |
| 45 | +} | ... | ... |
| 1 | +import { Word32Array } from "../Word32Array"; | |
| 2 | +import { Utf8 } from "../encoder/Utf8"; | |
| 3 | +export class BufferedBlockAlgorithm { | |
| 4 | + constructor(props) { | |
| 5 | + this._minBufferSize = 0; | |
| 6 | + this._blockSize = 0; | |
| 7 | + this._props = props; | |
| 8 | + this._data = props && typeof props.data !== "undefined" ? props.data.clone() : new Word32Array(); | |
| 9 | + this._nBytes = props && typeof props.nBytes === "number" ? props.nBytes : 0; | |
| 10 | + } | |
| 11 | + get blockSize() { | |
| 12 | + return this._blockSize; | |
| 13 | + } | |
| 14 | + /** | |
| 15 | + * Resets this block algorithm's data buffer to its initial state. | |
| 16 | + * | |
| 17 | + * @example | |
| 18 | + * bufferedBlockAlgorithm.reset(); | |
| 19 | + */ | |
| 20 | + reset(data, nBytes) { | |
| 21 | + this._data = typeof data !== "undefined" ? data.clone() : new Word32Array(); | |
| 22 | + this._nBytes = typeof nBytes === "number" ? nBytes : 0; | |
| 23 | + } | |
| 24 | + /** | |
| 25 | + * Adds new data to this block algorithm's buffer. | |
| 26 | + * | |
| 27 | + * @param {Word32Array|string} data The data to append. Strings are converted to a WordArray using UTF-8. | |
| 28 | + * @example | |
| 29 | + * bufferedBlockAlgorithm.append('data'); | |
| 30 | + * bufferedBlockAlgorithm.append(wordArray); | |
| 31 | + */ | |
| 32 | + _append(data) { | |
| 33 | + const d = typeof data === "string" ? Utf8.parse(data) : data; | |
| 34 | + this._data.concat(d); | |
| 35 | + this._nBytes += d.nSigBytes; | |
| 36 | + } | |
| 37 | + /** | |
| 38 | + * Processes available data blocks. | |
| 39 | + * This method invokes doProcessBlock(offset), which must be implemented by a concrete subtype. | |
| 40 | + * | |
| 41 | + * @param {boolean?} doFlush Whether all blocks and partial blocks should be processed. | |
| 42 | + * @return {Word32Array} The processed data. | |
| 43 | + * @example | |
| 44 | + * var processedData = bufferedBlockAlgorithm.process(); | |
| 45 | + * var processedData = bufferedBlockAlgorithm.process(!!'flush'); | |
| 46 | + */ | |
| 47 | + _process(doFlush) { | |
| 48 | + let processedWords; | |
| 49 | + const words = this._data.words; | |
| 50 | + const nSigBytes = this._data.nSigBytes; | |
| 51 | + const blockSize = this._blockSize; | |
| 52 | + const blockSizeByte = this._blockSize * 4; | |
| 53 | + let nBlocksReady = nSigBytes / blockSizeByte; | |
| 54 | + if (doFlush) { | |
| 55 | + // Round up to include partial blocks | |
| 56 | + nBlocksReady = Math.ceil(nBlocksReady); | |
| 57 | + } | |
| 58 | + else { | |
| 59 | + nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0); | |
| 60 | + } | |
| 61 | + // Count words ready | |
| 62 | + const nWordsReady = nBlocksReady * blockSize; | |
| 63 | + // Count bytes ready | |
| 64 | + const nBytesReady = Math.min(nWordsReady * 4, nSigBytes); | |
| 65 | + // Process blocks | |
| 66 | + if (nWordsReady) { | |
| 67 | + for (let offset = 0; offset < nWordsReady; offset += blockSize) { | |
| 68 | + // Perform concrete-algorithm logic | |
| 69 | + this._doProcessBlock(words, offset); | |
| 70 | + } | |
| 71 | + // Remove processed words | |
| 72 | + processedWords = words.splice(0, nWordsReady); | |
| 73 | + this._data.nSigBytes -= nBytesReady; | |
| 74 | + } | |
| 75 | + // Return processed words | |
| 76 | + return new Word32Array(processedWords, nBytesReady); | |
| 77 | + } | |
| 78 | + /** | |
| 79 | + * @abstract | |
| 80 | + */ | |
| 81 | + _doProcessBlock(words, offset) { | |
| 82 | + throw new Error("Not implemented"); | |
| 83 | + } | |
| 84 | +} | ... | ... |
| 1 | +import { BufferedBlockAlgorithm, BufferedBlockAlgorithmProps } from "./BufferedBlockAlgorithm"; | |
| 2 | +import type { Word32Array } from "../Word32Array"; | |
| 3 | +export interface HasherProps extends BufferedBlockAlgorithmProps { | |
| 4 | + blockSize: number; | |
| 5 | +} | |
| 6 | +export declare class Hasher extends BufferedBlockAlgorithm { | |
| 7 | + protected _props?: Partial<HasherProps>; | |
| 8 | + protected _blockSize: number; | |
| 9 | + constructor(props?: Partial<HasherProps>); | |
| 10 | + get blockSize(): number; | |
| 11 | + /** | |
| 12 | + * Resets this hasher to its initial state. | |
| 13 | + * | |
| 14 | + * @example | |
| 15 | + * hasher.reset(); | |
| 16 | + */ | |
| 17 | + reset(data?: Word32Array, nBytes?: number): void; | |
| 18 | + /** | |
| 19 | + * Updates this hasher with a message. | |
| 20 | + * | |
| 21 | + * @param {Word32Array|string} messageUpdate The message to append. | |
| 22 | + * @return {Hasher} This hasher. | |
| 23 | + * @example | |
| 24 | + * hasher.update('message'); | |
| 25 | + * hasher.update(wordArray); | |
| 26 | + */ | |
| 27 | + update(messageUpdate: Word32Array | string): this; | |
| 28 | + /** | |
| 29 | + * Finalizes the hash computation. | |
| 30 | + * Note that the finalize operation is effectively a destructive, read-once operation. | |
| 31 | + * | |
| 32 | + * @param {Word32Array|string?} messageUpdate (Optional) A final message update. | |
| 33 | + * @return {Word32Array} The hash. | |
| 34 | + * @example | |
| 35 | + * var hash = hasher.finalize(); | |
| 36 | + * var hash = hasher.finalize('message'); | |
| 37 | + * var hash = hasher.finalize(wordArray); | |
| 38 | + */ | |
| 39 | + finalize(messageUpdate?: Word32Array | string): Word32Array; | |
| 40 | + /** | |
| 41 | + * @abstract | |
| 42 | + */ | |
| 43 | + protected _doReset(): void; | |
| 44 | + /** | |
| 45 | + * @abstract | |
| 46 | + */ | |
| 47 | + protected _doFinalize(): Word32Array; | |
| 48 | +} | ... | ... |
| 1 | +import { BufferedBlockAlgorithm } from "./BufferedBlockAlgorithm"; | |
| 2 | +export class Hasher extends BufferedBlockAlgorithm { | |
| 3 | + constructor(props) { | |
| 4 | + super(props); | |
| 5 | + this._blockSize = 512 / 32; | |
| 6 | + this._props = props; | |
| 7 | + if (props && typeof props.blockSize === "number") { | |
| 8 | + this._blockSize = props.blockSize; | |
| 9 | + } | |
| 10 | + this.reset(props ? props.data : undefined, props ? props.nBytes : undefined); | |
| 11 | + } | |
| 12 | + get blockSize() { | |
| 13 | + return this._blockSize; | |
| 14 | + } | |
| 15 | + /** | |
| 16 | + * Resets this hasher to its initial state. | |
| 17 | + * | |
| 18 | + * @example | |
| 19 | + * hasher.reset(); | |
| 20 | + */ | |
| 21 | + reset(data, nBytes) { | |
| 22 | + // Reset data buffer | |
| 23 | + super.reset.call(this, data, nBytes); | |
| 24 | + // Perform concrete-hasher logic | |
| 25 | + this._doReset(); | |
| 26 | + } | |
| 27 | + /** | |
| 28 | + * Updates this hasher with a message. | |
| 29 | + * | |
| 30 | + * @param {Word32Array|string} messageUpdate The message to append. | |
| 31 | + * @return {Hasher} This hasher. | |
| 32 | + * @example | |
| 33 | + * hasher.update('message'); | |
| 34 | + * hasher.update(wordArray); | |
| 35 | + */ | |
| 36 | + update(messageUpdate) { | |
| 37 | + this._append(messageUpdate); | |
| 38 | + this._process(); | |
| 39 | + return this; | |
| 40 | + } | |
| 41 | + /** | |
| 42 | + * Finalizes the hash computation. | |
| 43 | + * Note that the finalize operation is effectively a destructive, read-once operation. | |
| 44 | + * | |
| 45 | + * @param {Word32Array|string?} messageUpdate (Optional) A final message update. | |
| 46 | + * @return {Word32Array} The hash. | |
| 47 | + * @example | |
| 48 | + * var hash = hasher.finalize(); | |
| 49 | + * var hash = hasher.finalize('message'); | |
| 50 | + * var hash = hasher.finalize(wordArray); | |
| 51 | + */ | |
| 52 | + finalize(messageUpdate) { | |
| 53 | + // Final message update | |
| 54 | + if (messageUpdate) { | |
| 55 | + this._append(messageUpdate); | |
| 56 | + } | |
| 57 | + // Perform concrete-hasher logic | |
| 58 | + return this._doFinalize(); | |
| 59 | + } | |
| 60 | + /** | |
| 61 | + * @abstract | |
| 62 | + */ | |
| 63 | + _doReset() { | |
| 64 | + throw new Error("Not implemented"); | |
| 65 | + } | |
| 66 | + /** | |
| 67 | + * @abstract | |
| 68 | + */ | |
| 69 | + _doFinalize() { | |
| 70 | + throw new Error("Not implemented"); | |
| 71 | + } | |
| 72 | +} | ... | ... |
| 1 | +import { Cipher, CipherProps, PropsWithKey } from "./Cipher"; | |
| 2 | +import type { BlockCipherMode, BlockCipherModeProps } from "./mode/BlockCipherMode"; | |
| 3 | +import type { Pad } from "./pad/type"; | |
| 4 | +import type { Word32Array } from "../../Word32Array"; | |
| 5 | +import type { BaseKDFModule } from "./kdf/type"; | |
| 6 | +import type { Hasher } from "../Hasher"; | |
| 7 | +export interface BlockCipherProps extends CipherProps { | |
| 8 | + mode: typeof BlockCipherMode; | |
| 9 | + padding: Pad; | |
| 10 | + kdfSalt: Word32Array; | |
| 11 | + kdfModule: typeof BaseKDFModule; | |
| 12 | + kdfHasher: typeof Hasher; | |
| 13 | + kdfIterations: number; | |
| 14 | +} | |
| 15 | +export declare class BlockCipher extends Cipher { | |
| 16 | + protected _props: PropsWithKey<BlockCipherProps>; | |
| 17 | + protected _blockSize: number; | |
| 18 | + protected _Mode: typeof BlockCipherMode; | |
| 19 | + protected _mode?: BlockCipherMode; | |
| 20 | + protected _padding: Pad; | |
| 21 | + protected _modeCreator?: (props: BlockCipherModeProps) => BlockCipherMode; | |
| 22 | + /** | |
| 23 | + * @see https://github.com/Microsoft/TypeScript/issues/3841#issuecomment-337560146 | |
| 24 | + */ | |
| 25 | + ["constructor"]: typeof BlockCipher; | |
| 26 | + constructor(props: PropsWithKey<BlockCipherProps>); | |
| 27 | + get mode(): BlockCipherMode | undefined; | |
| 28 | + get padding(): Pad; | |
| 29 | + reset(data?: Word32Array, nBytes?: number): void; | |
| 30 | + protected _doProcessBlock(words: number[], offset: number): void; | |
| 31 | + protected _doFinalize(): Word32Array; | |
| 32 | + /** | |
| 33 | + * @abstract | |
| 34 | + */ | |
| 35 | + encryptBlock(words: number[], offset: number): void; | |
| 36 | + /** | |
| 37 | + * @abstract | |
| 38 | + */ | |
| 39 | + decryptBlock(words: number[], offset: number): void; | |
| 40 | + /** | |
| 41 | + * Creates this cipher in encryption mode. | |
| 42 | + * | |
| 43 | + * @param {Word32Array} key The key. | |
| 44 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 45 | + * @return {Cipher} A cipher instance. | |
| 46 | + * @example | |
| 47 | + * var cipher = AES.createEncryptor(keyWordArray, { iv: ivWordArray }); | |
| 48 | + */ | |
| 49 | + static createEncryptor(key: Word32Array, props?: Partial<BlockCipherProps>): BlockCipher; | |
| 50 | + /** | |
| 51 | + * Creates this cipher in decryption mode. | |
| 52 | + * @param {Word32Array} key The key. | |
| 53 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 54 | + * @return {Cipher} A cipher instance. | |
| 55 | + * @example | |
| 56 | + * var cipher = AES.createDecryptor(keyWordArray, { iv: ivWordArray }); | |
| 57 | + */ | |
| 58 | + static createDecryptor(key: Word32Array, props?: Partial<BlockCipherProps>): BlockCipher; | |
| 59 | +} | ... | ... |
| 1 | +import { Cipher } from "./Cipher"; | |
| 2 | +import { CBC } from "./mode/CBC"; | |
| 3 | +import { Pkcs7 } from "./pad/Pkcs7"; | |
| 4 | +export class BlockCipher extends Cipher { | |
| 5 | + constructor(props) { | |
| 6 | + super(props); | |
| 7 | + this._blockSize = 128 / 32; | |
| 8 | + this._Mode = CBC; | |
| 9 | + this._padding = Pkcs7; | |
| 10 | + this._props = props; | |
| 11 | + this._Mode = typeof props.mode !== "undefined" ? props.mode : this._Mode; | |
| 12 | + this._padding = typeof props.padding !== "undefined" ? props.padding : this._padding; | |
| 13 | + this.reset(props === null || props === void 0 ? void 0 : props.data, props === null || props === void 0 ? void 0 : props.nBytes); | |
| 14 | + } | |
| 15 | + get mode() { | |
| 16 | + return this._mode; | |
| 17 | + } | |
| 18 | + get padding() { | |
| 19 | + return this._padding; | |
| 20 | + } | |
| 21 | + reset(data, nBytes) { | |
| 22 | + super.reset(data, nBytes); | |
| 23 | + let modeCreator; | |
| 24 | + if (this._transformMode === Cipher.ENC_TRANSFORM_MODE) { | |
| 25 | + modeCreator = this._Mode.createEncryptor; | |
| 26 | + } | |
| 27 | + else { | |
| 28 | + modeCreator = this._Mode.createDecryptor; | |
| 29 | + // Keep at least one block in the buffer for unpadding | |
| 30 | + this._minBufferSize = 1; | |
| 31 | + } | |
| 32 | + if (this._Mode && this._modeCreator === modeCreator) { | |
| 33 | + this._mode = new this._Mode({ cipher: this, iv: this._iv }); | |
| 34 | + } | |
| 35 | + else { | |
| 36 | + this._mode = modeCreator.call(this._Mode, { cipher: this, iv: this._iv }); | |
| 37 | + this._modeCreator = modeCreator; | |
| 38 | + } | |
| 39 | + } | |
| 40 | + _doProcessBlock(words, offset) { | |
| 41 | + var _a; | |
| 42 | + (_a = this._mode) === null || _a === void 0 ? void 0 : _a.processBlock(words, offset); | |
| 43 | + } | |
| 44 | + _doFinalize() { | |
| 45 | + let finalProcessedBlocks; | |
| 46 | + // Shortcut | |
| 47 | + const padding = this._padding; | |
| 48 | + // Finalize | |
| 49 | + if (this._transformMode === Cipher.ENC_TRANSFORM_MODE) { | |
| 50 | + // Pad data | |
| 51 | + padding.pad(this._data, this.blockSize); | |
| 52 | + // Process final blocks | |
| 53 | + finalProcessedBlocks = this._process(true); | |
| 54 | + } | |
| 55 | + else /* if (this._transformMode == Cipher._DEC_TRANSFORM_MODE) */ { | |
| 56 | + // Process final blocks | |
| 57 | + finalProcessedBlocks = this._process(true); | |
| 58 | + // Unpad data | |
| 59 | + padding.unpad(finalProcessedBlocks); | |
| 60 | + } | |
| 61 | + return finalProcessedBlocks; | |
| 62 | + } | |
| 63 | + /** | |
| 64 | + * @abstract | |
| 65 | + */ | |
| 66 | + encryptBlock(words, offset) { | |
| 67 | + throw new Error("Not implemented"); | |
| 68 | + } | |
| 69 | + /** | |
| 70 | + * @abstract | |
| 71 | + */ | |
| 72 | + decryptBlock(words, offset) { | |
| 73 | + throw new Error("Not implemented"); | |
| 74 | + } | |
| 75 | + /** | |
| 76 | + * Creates this cipher in encryption mode. | |
| 77 | + * | |
| 78 | + * @param {Word32Array} key The key. | |
| 79 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 80 | + * @return {Cipher} A cipher instance. | |
| 81 | + * @example | |
| 82 | + * var cipher = AES.createEncryptor(keyWordArray, { iv: ivWordArray }); | |
| 83 | + */ | |
| 84 | + static createEncryptor(key, props) { | |
| 85 | + props = typeof props === "undefined" ? {} : props; | |
| 86 | + return new BlockCipher(Object.assign(Object.assign({}, props), { key, transformMode: Cipher.ENC_TRANSFORM_MODE })); | |
| 87 | + } | |
| 88 | + /** | |
| 89 | + * Creates this cipher in decryption mode. | |
| 90 | + * @param {Word32Array} key The key. | |
| 91 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 92 | + * @return {Cipher} A cipher instance. | |
| 93 | + * @example | |
| 94 | + * var cipher = AES.createDecryptor(keyWordArray, { iv: ivWordArray }); | |
| 95 | + */ | |
| 96 | + static createDecryptor(key, props) { | |
| 97 | + props = typeof props === "undefined" ? {} : props; | |
| 98 | + return new BlockCipher(Object.assign(Object.assign({}, props), { key, transformMode: Cipher.DEC_TRANSFORM_MODE })); | |
| 99 | + } | |
| 100 | +} | ... | ... |
| 1 | +import { BufferedBlockAlgorithm, BufferedBlockAlgorithmProps } from "../BufferedBlockAlgorithm"; | |
| 2 | +import type { Word32Array } from "../../Word32Array"; | |
| 3 | +export interface CipherProps extends BufferedBlockAlgorithmProps { | |
| 4 | + key: Word32Array; | |
| 5 | + iv: Word32Array; | |
| 6 | + transformMode: number; | |
| 7 | +} | |
| 8 | +export declare type PropsWithKey<T extends CipherProps> = Partial<T> & Pick<T, "key">; | |
| 9 | +export declare class Cipher extends BufferedBlockAlgorithm { | |
| 10 | + static readonly ENC_TRANSFORM_MODE = 1; | |
| 11 | + static readonly DEC_TRANSFORM_MODE = 2; | |
| 12 | + static readonly keySize: number; | |
| 13 | + static readonly ivSize: number; | |
| 14 | + protected _props: PropsWithKey<CipherProps>; | |
| 15 | + protected _transformMode: number; | |
| 16 | + protected _key: Word32Array; | |
| 17 | + protected _iv?: Word32Array; | |
| 18 | + constructor(props: PropsWithKey<CipherProps>); | |
| 19 | + get iv(): Word32Array | undefined; | |
| 20 | + /** | |
| 21 | + * Resets this cipher to its initial state. | |
| 22 | + * @example | |
| 23 | + * cipher.reset(); | |
| 24 | + */ | |
| 25 | + reset(data?: Word32Array, nBytes?: number): void; | |
| 26 | + /** | |
| 27 | + * Adds data to be encrypted or decrypted. | |
| 28 | + * @param {Word32Array|string} dataUpdate The data to encrypt or decrypt. | |
| 29 | + * @return {Word32Array} The data after processing. | |
| 30 | + * @example | |
| 31 | + * var encrypted = cipher.process('data'); | |
| 32 | + * var encrypted = cipher.process(wordArray); | |
| 33 | + */ | |
| 34 | + process(dataUpdate: Word32Array | string): Word32Array; | |
| 35 | + /** | |
| 36 | + * Finalizes the encryption or decryption process. | |
| 37 | + * Note that the finalize operation is effectively a destructive, read-once operation. | |
| 38 | + * @param {Word32Array|string?} dataUpdate The final data to encrypt or decrypt. | |
| 39 | + * @return {Word32Array} The data after final processing. | |
| 40 | + * @example | |
| 41 | + * var encrypted = cipher.finalize(); | |
| 42 | + * var encrypted = cipher.finalize('data'); | |
| 43 | + * var encrypted = cipher.finalize(wordArray); | |
| 44 | + */ | |
| 45 | + finalize(dataUpdate?: Word32Array | string): Word32Array; | |
| 46 | + /** | |
| 47 | + * @abstract | |
| 48 | + */ | |
| 49 | + protected _doReset(): void; | |
| 50 | + /** | |
| 51 | + * @abstract | |
| 52 | + */ | |
| 53 | + protected _doProcessBlock(words: number[], offset: number): void; | |
| 54 | + /** | |
| 55 | + * @abstract | |
| 56 | + */ | |
| 57 | + protected _doFinalize(): Word32Array; | |
| 58 | + /** | |
| 59 | + * Creates this cipher in encryption mode. | |
| 60 | + * | |
| 61 | + * @param {Word32Array} key The key. | |
| 62 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 63 | + * @return {Cipher} A cipher instance. | |
| 64 | + * @example | |
| 65 | + * var cipher = AES.createEncryptor(keyWordArray, { iv: ivWordArray }); | |
| 66 | + */ | |
| 67 | + static createEncryptor(key: Word32Array, props?: Partial<CipherProps>): Cipher; | |
| 68 | + /** | |
| 69 | + * Creates this cipher in decryption mode. | |
| 70 | + * @param {Word32Array} key The key. | |
| 71 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 72 | + * @return {Cipher} A cipher instance. | |
| 73 | + * @example | |
| 74 | + * var cipher = AES.createDecryptor(keyWordArray, { iv: ivWordArray }); | |
| 75 | + */ | |
| 76 | + static createDecryptor(key: Word32Array, props?: Partial<CipherProps>): Cipher; | |
| 77 | +} | ... | ... |
| 1 | +import { BufferedBlockAlgorithm } from "../BufferedBlockAlgorithm"; | |
| 2 | +export class Cipher extends BufferedBlockAlgorithm { | |
| 3 | + constructor(props) { | |
| 4 | + super(props); | |
| 5 | + this._transformMode = 1; | |
| 6 | + this._props = props; | |
| 7 | + this._key = props.key; | |
| 8 | + this._iv = typeof props.iv !== "undefined" ? props.iv : this._iv; | |
| 9 | + this._transformMode = typeof props.transformMode !== "undefined" ? props.transformMode : this._transformMode; | |
| 10 | + } | |
| 11 | + get iv() { | |
| 12 | + return this._iv; | |
| 13 | + } | |
| 14 | + /** | |
| 15 | + * Resets this cipher to its initial state. | |
| 16 | + * @example | |
| 17 | + * cipher.reset(); | |
| 18 | + */ | |
| 19 | + reset(data, nBytes) { | |
| 20 | + super.reset(data, nBytes); | |
| 21 | + this._doReset(); | |
| 22 | + } | |
| 23 | + /** | |
| 24 | + * Adds data to be encrypted or decrypted. | |
| 25 | + * @param {Word32Array|string} dataUpdate The data to encrypt or decrypt. | |
| 26 | + * @return {Word32Array} The data after processing. | |
| 27 | + * @example | |
| 28 | + * var encrypted = cipher.process('data'); | |
| 29 | + * var encrypted = cipher.process(wordArray); | |
| 30 | + */ | |
| 31 | + process(dataUpdate) { | |
| 32 | + this._append(dataUpdate); | |
| 33 | + return this._process(); | |
| 34 | + } | |
| 35 | + /** | |
| 36 | + * Finalizes the encryption or decryption process. | |
| 37 | + * Note that the finalize operation is effectively a destructive, read-once operation. | |
| 38 | + * @param {Word32Array|string?} dataUpdate The final data to encrypt or decrypt. | |
| 39 | + * @return {Word32Array} The data after final processing. | |
| 40 | + * @example | |
| 41 | + * var encrypted = cipher.finalize(); | |
| 42 | + * var encrypted = cipher.finalize('data'); | |
| 43 | + * var encrypted = cipher.finalize(wordArray); | |
| 44 | + */ | |
| 45 | + finalize(dataUpdate) { | |
| 46 | + // Final data update | |
| 47 | + if (dataUpdate) { | |
| 48 | + this._append(dataUpdate); | |
| 49 | + } | |
| 50 | + // Perform concrete-cipher logic | |
| 51 | + return this._doFinalize(); | |
| 52 | + } | |
| 53 | + /** | |
| 54 | + * @abstract | |
| 55 | + */ | |
| 56 | + _doReset() { | |
| 57 | + throw new Error("Not implemented"); | |
| 58 | + } | |
| 59 | + /** | |
| 60 | + * @abstract | |
| 61 | + */ | |
| 62 | + _doProcessBlock(words, offset) { | |
| 63 | + throw new Error("Not implemented"); | |
| 64 | + } | |
| 65 | + /** | |
| 66 | + * @abstract | |
| 67 | + */ | |
| 68 | + _doFinalize() { | |
| 69 | + throw new Error("Not implemented"); | |
| 70 | + } | |
| 71 | + /** | |
| 72 | + * Creates this cipher in encryption mode. | |
| 73 | + * | |
| 74 | + * @param {Word32Array} key The key. | |
| 75 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 76 | + * @return {Cipher} A cipher instance. | |
| 77 | + * @example | |
| 78 | + * var cipher = AES.createEncryptor(keyWordArray, { iv: ivWordArray }); | |
| 79 | + */ | |
| 80 | + static createEncryptor(key, props) { | |
| 81 | + props = typeof props === "undefined" ? {} : props; | |
| 82 | + return new Cipher(Object.assign(Object.assign({}, props), { key, transformMode: Cipher.ENC_TRANSFORM_MODE })); | |
| 83 | + } | |
| 84 | + /** | |
| 85 | + * Creates this cipher in decryption mode. | |
| 86 | + * @param {Word32Array} key The key. | |
| 87 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 88 | + * @return {Cipher} A cipher instance. | |
| 89 | + * @example | |
| 90 | + * var cipher = AES.createDecryptor(keyWordArray, { iv: ivWordArray }); | |
| 91 | + */ | |
| 92 | + static createDecryptor(key, props) { | |
| 93 | + props = typeof props === "undefined" ? {} : props; | |
| 94 | + return new Cipher(Object.assign(Object.assign({}, props), { key, transformMode: Cipher.DEC_TRANSFORM_MODE })); | |
| 95 | + } | |
| 96 | +} | |
| 97 | +Cipher.ENC_TRANSFORM_MODE = 1; | |
| 98 | +Cipher.DEC_TRANSFORM_MODE = 2; | |
| 99 | +Cipher.keySize = 128 / 32; | |
| 100 | +Cipher.ivSize = 128 / 32; | ... | ... |
| 1 | +import type { Word32Array } from "../../Word32Array"; | |
| 2 | +import type { BlockCipherMode } from "./mode/BlockCipherMode"; | |
| 3 | +import type { Pad } from "./pad/type"; | |
| 4 | +import type { Formatter } from "./formatter/type"; | |
| 5 | +import type { Cipher } from "./Cipher"; | |
| 6 | +/** | |
| 7 | + * A collection of cipher parameters. | |
| 8 | + * | |
| 9 | + * @property {Word32Array} ciphertext The raw ciphertext. | |
| 10 | + * @property {Word32Array} key The key to this ciphertext. | |
| 11 | + * @property {Word32Array} iv The IV used in the ciphering operation. | |
| 12 | + * @property {Word32Array} salt The salt used with a key derivation function. | |
| 13 | + * @property {typeof Cipher} algorithm The cipher algorithm. | |
| 14 | + * @property {BlockCipherMode} mode The block mode used in the ciphering operation. | |
| 15 | + * @property {Pad} padding The padding scheme used in the ciphering operation. | |
| 16 | + * @property {number} blockSize The block size of the cipher. | |
| 17 | + * @property {Formatter} formatter The default formatting strategy to convert this cipher params object to a string. | |
| 18 | + */ | |
| 19 | +export declare class CipherParams { | |
| 20 | + cipherText?: Word32Array; | |
| 21 | + key?: Word32Array; | |
| 22 | + iv?: Word32Array; | |
| 23 | + salt?: Word32Array; | |
| 24 | + Algorithm?: typeof Cipher; | |
| 25 | + mode?: BlockCipherMode; | |
| 26 | + padding?: Pad; | |
| 27 | + blockSize?: number; | |
| 28 | + formatter: Formatter; | |
| 29 | + /** | |
| 30 | + * Initializes a newly created cipher params object. | |
| 31 | + * | |
| 32 | + * @param {Partial<CipherParams>} cp An object with any of the possible cipher parameters. | |
| 33 | + * @example | |
| 34 | + * var cipherParams = new CipherParams({ | |
| 35 | + * ciphertext: ciphertextWordArray, | |
| 36 | + * key: keyWordArray, | |
| 37 | + * iv: ivWordArray, | |
| 38 | + * salt: saltWordArray, | |
| 39 | + * algorithm: AES, | |
| 40 | + * mode: CBC, | |
| 41 | + * padding: PKCS7, | |
| 42 | + * blockSize: 4, | |
| 43 | + * formatter: OpenSSLFormatter | |
| 44 | + * }); | |
| 45 | + */ | |
| 46 | + constructor(cp?: Partial<CipherParams>); | |
| 47 | + /** | |
| 48 | + * Converts this cipher params object to a string. | |
| 49 | + * | |
| 50 | + * @param {Formatter?} formatter (Optional) The formatting strategy to use. | |
| 51 | + * @return {string} The stringified cipher params. | |
| 52 | + * @throws Error If neither the formatter nor the default formatter is set. | |
| 53 | + * @example | |
| 54 | + * var string = cipherParams + ''; | |
| 55 | + * var string = cipherParams.toString(); | |
| 56 | + * var string = cipherParams.toString(OpenSSLFormatter); | |
| 57 | + */ | |
| 58 | + toString(formatter?: Formatter): string; | |
| 59 | +} | ... | ... |
| 1 | +import { OpenSSLFormatter } from "./formatter/OpenSSLFormatter"; | |
| 2 | +/** | |
| 3 | + * A collection of cipher parameters. | |
| 4 | + * | |
| 5 | + * @property {Word32Array} ciphertext The raw ciphertext. | |
| 6 | + * @property {Word32Array} key The key to this ciphertext. | |
| 7 | + * @property {Word32Array} iv The IV used in the ciphering operation. | |
| 8 | + * @property {Word32Array} salt The salt used with a key derivation function. | |
| 9 | + * @property {typeof Cipher} algorithm The cipher algorithm. | |
| 10 | + * @property {BlockCipherMode} mode The block mode used in the ciphering operation. | |
| 11 | + * @property {Pad} padding The padding scheme used in the ciphering operation. | |
| 12 | + * @property {number} blockSize The block size of the cipher. | |
| 13 | + * @property {Formatter} formatter The default formatting strategy to convert this cipher params object to a string. | |
| 14 | + */ | |
| 15 | +export class CipherParams { | |
| 16 | + /** | |
| 17 | + * Initializes a newly created cipher params object. | |
| 18 | + * | |
| 19 | + * @param {Partial<CipherParams>} cp An object with any of the possible cipher parameters. | |
| 20 | + * @example | |
| 21 | + * var cipherParams = new CipherParams({ | |
| 22 | + * ciphertext: ciphertextWordArray, | |
| 23 | + * key: keyWordArray, | |
| 24 | + * iv: ivWordArray, | |
| 25 | + * salt: saltWordArray, | |
| 26 | + * algorithm: AES, | |
| 27 | + * mode: CBC, | |
| 28 | + * padding: PKCS7, | |
| 29 | + * blockSize: 4, | |
| 30 | + * formatter: OpenSSLFormatter | |
| 31 | + * }); | |
| 32 | + */ | |
| 33 | + constructor(cp) { | |
| 34 | + this.formatter = OpenSSLFormatter; | |
| 35 | + if (cp) { | |
| 36 | + this.cipherText = cp.cipherText; | |
| 37 | + this.key = cp.key; | |
| 38 | + this.iv = cp.iv; | |
| 39 | + this.salt = cp.salt; | |
| 40 | + this.Algorithm = cp.Algorithm; | |
| 41 | + this.mode = cp.mode; | |
| 42 | + this.padding = cp.padding; | |
| 43 | + this.blockSize = cp.blockSize; | |
| 44 | + this.formatter = cp.formatter || OpenSSLFormatter; | |
| 45 | + } | |
| 46 | + } | |
| 47 | + /** | |
| 48 | + * Converts this cipher params object to a string. | |
| 49 | + * | |
| 50 | + * @param {Formatter?} formatter (Optional) The formatting strategy to use. | |
| 51 | + * @return {string} The stringified cipher params. | |
| 52 | + * @throws Error If neither the formatter nor the default formatter is set. | |
| 53 | + * @example | |
| 54 | + * var string = cipherParams + ''; | |
| 55 | + * var string = cipherParams.toString(); | |
| 56 | + * var string = cipherParams.toString(OpenSSLFormatter); | |
| 57 | + */ | |
| 58 | + toString(formatter) { | |
| 59 | + return (formatter || this.formatter).stringify(this); | |
| 60 | + } | |
| 61 | +} | ... | ... |
| 1 | +import { ISerializableCipher, SerializableCipherProps } from "./SerializableCipher"; | |
| 2 | +import type { KDF as KDFType, BaseKDFModule } from "./kdf/type"; | |
| 3 | +import type { Word32Array } from "../../Word32Array"; | |
| 4 | +import type { Hasher } from "../Hasher"; | |
| 5 | +export interface PasswordBasedCipherProps extends SerializableCipherProps { | |
| 6 | + KDF: KDFType; | |
| 7 | + kdfSalt: Word32Array; | |
| 8 | + kdfModule: typeof BaseKDFModule; | |
| 9 | + kdfHasher: typeof Hasher; | |
| 10 | + kdfIterations: number; | |
| 11 | +} | |
| 12 | +export declare const PasswordBasedCipher: ISerializableCipher<string>; | ... | ... |
| 1 | +import { parseCipherText, SerializableCipher, } from "./SerializableCipher"; | |
| 2 | +import { OpenSSLKDF } from "./kdf/OpenSSLKDF"; | |
| 3 | +import { CipherParams } from "./CipherParams"; | |
| 4 | +import { OpenSSLFormatter } from "./formatter/OpenSSLFormatter"; | |
| 5 | +export const PasswordBasedCipher = { | |
| 6 | + /** | |
| 7 | + * Encrypts a message using a password. | |
| 8 | + * | |
| 9 | + * @param {typeof Cipher} Cipher The cipher algorithm to use. | |
| 10 | + * @param {Word32Array|string} message The message to encrypt. | |
| 11 | + * @param {string} password The password. | |
| 12 | + * @param {Partial<PasswordBasedCipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 13 | + * @return {CipherParams} A cipher params object. | |
| 14 | + * @example | |
| 15 | + * var params = PasswordBasedCipher.encrypt(AES, message, 'password'); | |
| 16 | + * var params = PasswordBasedCipher.encrypt(AES, message, 'password', { format: OpenSSLFormatter }); | |
| 17 | + */ | |
| 18 | + encrypt(Cipher, message, password, props) { | |
| 19 | + const cipherProps = props ? Object.assign({}, props) : {}; | |
| 20 | + const KDF = props && props.KDF ? props.KDF : OpenSSLKDF; | |
| 21 | + const kdfProps = {}; | |
| 22 | + if (props && props.kdfHasher) { | |
| 23 | + kdfProps.kdfHasher = props.kdfHasher; | |
| 24 | + } | |
| 25 | + if (props && props.kdfIterations) { | |
| 26 | + kdfProps.kdfIterations = props.kdfIterations; | |
| 27 | + } | |
| 28 | + if (props && props.kdfModule) { | |
| 29 | + kdfProps.kdfModule = props.kdfModule; | |
| 30 | + } | |
| 31 | + const derivedParams = KDF.execute(password, Cipher.keySize, Cipher.ivSize, cipherProps.kdfSalt, kdfProps); | |
| 32 | + cipherProps.iv = derivedParams.iv; | |
| 33 | + const cipherParams = SerializableCipher.encrypt(Cipher, message, derivedParams.key, cipherProps); | |
| 34 | + return new CipherParams(Object.assign(Object.assign({}, cipherParams), { key: derivedParams.key, iv: derivedParams.iv, salt: derivedParams.salt })); | |
| 35 | + }, | |
| 36 | + /** | |
| 37 | + * Decrypts serialized ciphertext using a password. | |
| 38 | + * | |
| 39 | + * @param {typeof Cipher} Cipher The cipher algorithm to use. | |
| 40 | + * @param {CipherParams|string} cipherParams The ciphertext to decrypt. | |
| 41 | + * @param {string} password The password. | |
| 42 | + * @param {Partial<PasswordBasedCipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 43 | + * @return {Word32Array} The plaintext. | |
| 44 | + * @example | |
| 45 | + * var plaintext = PasswordBasedCipher.decrypt( | |
| 46 | + * AES, | |
| 47 | + * formattedCiphertext, | |
| 48 | + * 'password', | |
| 49 | + * { format: OpenSSLFormatter } | |
| 50 | + * ); | |
| 51 | + * var plaintext = PasswordBasedCipher.decrypt( | |
| 52 | + * AES, | |
| 53 | + * ciphertextParams, | |
| 54 | + * 'password', | |
| 55 | + * { format: OpenSSLFormatter } | |
| 56 | + * ); | |
| 57 | + */ | |
| 58 | + decrypt(Cipher, cipherParams, password, props) { | |
| 59 | + const p = props ? Object.assign({}, props) : {}; | |
| 60 | + const KDF = p.KDF ? p.KDF : OpenSSLKDF; | |
| 61 | + const formatter = p.formatter ? p.formatter : OpenSSLFormatter; | |
| 62 | + const cipherParamsObj = parseCipherText(cipherParams, formatter); | |
| 63 | + const kdfProps = {}; | |
| 64 | + if (props && props.kdfHasher) { | |
| 65 | + kdfProps.kdfHasher = props.kdfHasher; | |
| 66 | + } | |
| 67 | + if (props && props.kdfIterations) { | |
| 68 | + kdfProps.kdfIterations = props.kdfIterations; | |
| 69 | + } | |
| 70 | + if (props && props.kdfModule) { | |
| 71 | + kdfProps.kdfModule = props.kdfModule; | |
| 72 | + } | |
| 73 | + const derivedParams = KDF.execute(password, Cipher.keySize, Cipher.ivSize, cipherParamsObj.salt, kdfProps); | |
| 74 | + p.iv = derivedParams.iv; | |
| 75 | + return SerializableCipher.decrypt(Cipher, cipherParamsObj, derivedParams.key, p); | |
| 76 | + } | |
| 77 | +}; | ... | ... |
| 1 | +import type { Formatter } from "./formatter/type"; | |
| 2 | +import type { Word32Array } from "../../Word32Array"; | |
| 3 | +import type { BlockCipherProps } from "./BlockCipher"; | |
| 4 | +import { CipherParams } from "./CipherParams"; | |
| 5 | +import { Cipher as BaseCipher } from "./Cipher"; | |
| 6 | +export interface SerializableCipherProps extends BlockCipherProps { | |
| 7 | + formatter: Formatter; | |
| 8 | +} | |
| 9 | +export interface ISerializableCipher<K extends Word32Array | string> { | |
| 10 | + encrypt: (cipher: typeof BaseCipher, message: Word32Array | string, key: K, props?: Partial<SerializableCipherProps>) => CipherParams; | |
| 11 | + decrypt: (cipher: typeof BaseCipher, cipherParams: CipherParams | string, key: K, props?: Partial<SerializableCipherProps>) => Word32Array; | |
| 12 | +} | |
| 13 | +/** | |
| 14 | + * Converts serialized ciphertext to CipherParams, | |
| 15 | + * else assumed CipherParams already and returns ciphertext unchanged. | |
| 16 | + * @param {CipherParams|string} cipherTextParams The ciphertext. | |
| 17 | + * @param {Formatter} formatter The formatting strategy to use to parse serialized ciphertext. | |
| 18 | + * @return {CipherParams} The un-serialized ciphertext. | |
| 19 | + * @example | |
| 20 | + * var ciphertextParams = SerializableCipher.parse(ciphertextStringOrParams, format); | |
| 21 | + */ | |
| 22 | +export declare function parseCipherText(cipherTextParams: CipherParams | string, formatter: Formatter): CipherParams; | |
| 23 | +export declare const SerializableCipher: ISerializableCipher<Word32Array>; | ... | ... |
| 1 | +import { OpenSSLFormatter } from "./formatter/OpenSSLFormatter"; | |
| 2 | +import { CipherParams } from "./CipherParams"; | |
| 3 | +/** | |
| 4 | + * Converts serialized ciphertext to CipherParams, | |
| 5 | + * else assumed CipherParams already and returns ciphertext unchanged. | |
| 6 | + * @param {CipherParams|string} cipherTextParams The ciphertext. | |
| 7 | + * @param {Formatter} formatter The formatting strategy to use to parse serialized ciphertext. | |
| 8 | + * @return {CipherParams} The un-serialized ciphertext. | |
| 9 | + * @example | |
| 10 | + * var ciphertextParams = SerializableCipher.parse(ciphertextStringOrParams, format); | |
| 11 | + */ | |
| 12 | +export function parseCipherText(cipherTextParams, formatter) { | |
| 13 | + if (typeof cipherTextParams === "string") { | |
| 14 | + return formatter.parse(cipherTextParams); | |
| 15 | + } | |
| 16 | + return cipherTextParams; | |
| 17 | +} | |
| 18 | +export const SerializableCipher = { | |
| 19 | + /** | |
| 20 | + * Encrypts a message. | |
| 21 | + * | |
| 22 | + * @param {typeof Cipher} Cipher The cipher algorithm to use. | |
| 23 | + * @param {Word32Array|string} message The message to encrypt. | |
| 24 | + * @param {Word32Array} key The key. | |
| 25 | + * @param {Partial<SerializableCipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 26 | + * @return {CipherParams} A cipher params object. | |
| 27 | + * @example | |
| 28 | + * var ciphertextParams = SerializableCipher.encrypt(AES, message, key); | |
| 29 | + * var ciphertextParams = SerializableCipher.encrypt(AES, message, key, { iv: iv }); | |
| 30 | + */ | |
| 31 | + encrypt(Cipher, message, key, props) { | |
| 32 | + const encryptor = Cipher.createEncryptor(key, props); | |
| 33 | + const cipherText = encryptor.finalize(message); | |
| 34 | + return new CipherParams({ | |
| 35 | + cipherText, | |
| 36 | + key, | |
| 37 | + iv: encryptor.iv, | |
| 38 | + Algorithm: Cipher, | |
| 39 | + mode: encryptor.mode, | |
| 40 | + padding: encryptor.padding, | |
| 41 | + blockSize: encryptor.blockSize, | |
| 42 | + formatter: (props === null || props === void 0 ? void 0 : props.formatter) || OpenSSLFormatter, | |
| 43 | + }); | |
| 44 | + }, | |
| 45 | + /** | |
| 46 | + * Decrypts serialized ciphertext. | |
| 47 | + * | |
| 48 | + * @param {typeof Cipher} Cipher The cipher algorithm to use. | |
| 49 | + * @param {CipherParams|string} cipherParams The ciphertext to decrypt. | |
| 50 | + * @param {Word32Array} key The key. | |
| 51 | + * @param {Partial<SerializableCipherProps>} props (Optional) The configuration options to use for this operation. | |
| 52 | + * @return {Word32Array} The plaintext. | |
| 53 | + * @example | |
| 54 | + * var plaintext = SerializableCipher.decrypt(AES, formattedCiphertext, key, { iv: iv, format: OpenSSLFormatter }); | |
| 55 | + * var plaintext = SerializableCipher.decrypt(AES, ciphertextParams, key, { iv: iv, format: OpenSSLFormatter }); | |
| 56 | + */ | |
| 57 | + decrypt(Cipher, cipherParams, key, props) { | |
| 58 | + const decryptor = Cipher.createDecryptor(key, props); | |
| 59 | + const cipherParamsObj = parseCipherText(cipherParams, (props === null || props === void 0 ? void 0 : props.formatter) || OpenSSLFormatter); | |
| 60 | + return decryptor.finalize(cipherParamsObj.cipherText || ""); | |
| 61 | + } | |
| 62 | +}; | ... | ... |
| 1 | +import { Cipher, CipherProps, PropsWithKey } from "./Cipher"; | |
| 2 | +export interface StreamCipherProps extends CipherProps { | |
| 3 | +} | |
| 4 | +export declare abstract class StreamCipher extends Cipher { | |
| 5 | + protected _blockSize: number; | |
| 6 | + protected constructor(props: PropsWithKey<StreamCipherProps>); | |
| 7 | + protected _doFinalize(): import("../../Word32Array").Word32Array; | |
| 8 | +} | ... | ... |
| 1 | +import { CipherParams } from "../CipherParams"; | |
| 2 | +import { Word32Array } from "../../../Word32Array"; | |
| 3 | +import { Base64 } from "../../../encoder/Base64"; | |
| 4 | +export const OpenSSLFormatter = { | |
| 5 | + /** | |
| 6 | + * Converts a cipher params object to an OpenSSL-compatible string. | |
| 7 | + * | |
| 8 | + * @param {CipherParams} cipherParams The cipher params object. | |
| 9 | + * @return {string} The OpenSSL-compatible string. | |
| 10 | + * @example | |
| 11 | + * var openSSLString = OpenSSLFormatter.stringify(cipherParams); | |
| 12 | + */ | |
| 13 | + stringify(cipherParams) { | |
| 14 | + // Shortcuts | |
| 15 | + const cipherText = cipherParams.cipherText; | |
| 16 | + const salt = cipherParams.salt; | |
| 17 | + if (!cipherText) { | |
| 18 | + return ""; | |
| 19 | + } | |
| 20 | + // Format | |
| 21 | + if (salt) { | |
| 22 | + const wordArray = new Word32Array([0x53616c74, 0x65645f5f]).concat(salt).concat(cipherText); | |
| 23 | + return wordArray.toString(Base64); | |
| 24 | + } | |
| 25 | + return cipherText.toString(Base64); | |
| 26 | + }, | |
| 27 | + /** | |
| 28 | + * Converts an OpenSSL-compatible string to a cipher params object. | |
| 29 | + * | |
| 30 | + * @param {string} openSSLStr The OpenSSL-compatible string. | |
| 31 | + * @return {CipherParams} The cipher params object. | |
| 32 | + * @example | |
| 33 | + * var cipherParams = OpenSSLFormatter.parse(openSSLString); | |
| 34 | + */ | |
| 35 | + parse(openSSLStr) { | |
| 36 | + let salt; | |
| 37 | + // Parse base64 | |
| 38 | + const cipherText = Base64.parse(openSSLStr); | |
| 39 | + // Shortcut | |
| 40 | + const ciphertextWords = cipherText.words; | |
| 41 | + // Test for salt | |
| 42 | + if (ciphertextWords[0] === 0x53616c74 && ciphertextWords[1] === 0x65645f5f) { | |
| 43 | + // Extract salt | |
| 44 | + salt = new Word32Array(ciphertextWords.slice(2, 4)); | |
| 45 | + // Remove salt from ciphertext | |
| 46 | + ciphertextWords.splice(0, 4); | |
| 47 | + cipherText.nSigBytes -= 16; | |
| 48 | + } | |
| 49 | + return new CipherParams({ cipherText, salt }); | |
| 50 | + } | |
| 51 | +}; | ... | ... |
| 1 | +export {}; | ... | ... |
| 1 | +import type { KDF } from "./type"; | |
| 2 | +/** | |
| 3 | + * Derives a key and IV from a password. | |
| 4 | + * | |
| 5 | + * @param {string} password The password to derive from. | |
| 6 | + * @param {number} keySize The size in words of the key to generate. | |
| 7 | + * @param {number} ivSize The size in words of the IV to generate. | |
| 8 | + * @param {Word32Array?} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly. | |
| 9 | + * @return {CipherParams} A cipher params object with the key, IV, and salt. | |
| 10 | + * @example | |
| 11 | + * var derivedParams = OpenSSLKDF.execute('Password', 256/32, 128/32); | |
| 12 | + * var derivedParams = OpenSSLKDF.execute('Password', 256/32, 128/32, 'saltsalt'); | |
| 13 | + */ | |
| 14 | +export declare const OpenSSLKDF: KDF; | ... | ... |
| 1 | +import { Word32Array } from "../../../Word32Array"; | |
| 2 | +import { CipherParams } from "../CipherParams"; | |
| 3 | +import { PBKDF2 } from "./module/PBKDF2"; | |
| 4 | +/** | |
| 5 | + * Derives a key and IV from a password. | |
| 6 | + * | |
| 7 | + * @param {string} password The password to derive from. | |
| 8 | + * @param {number} keySize The size in words of the key to generate. | |
| 9 | + * @param {number} ivSize The size in words of the IV to generate. | |
| 10 | + * @param {Word32Array?} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly. | |
| 11 | + * @return {CipherParams} A cipher params object with the key, IV, and salt. | |
| 12 | + * @example | |
| 13 | + * var derivedParams = OpenSSLKDF.execute('Password', 256/32, 128/32); | |
| 14 | + * var derivedParams = OpenSSLKDF.execute('Password', 256/32, 128/32, 'saltsalt'); | |
| 15 | + */ | |
| 16 | +export const OpenSSLKDF = { | |
| 17 | + execute(password, keySize, ivSize, salt, props) { | |
| 18 | + // Generate random salt | |
| 19 | + if (!salt) { | |
| 20 | + salt = Word32Array.random(64 / 8); | |
| 21 | + } | |
| 22 | + const KDFModule = props && props.kdfModule || PBKDF2; | |
| 23 | + const kdfProps = props ? { Hasher: props.kdfHasher, iterations: props.kdfIterations } : {}; | |
| 24 | + // Derive key and IV | |
| 25 | + const key = KDFModule.getKey(password, salt, Object.assign(Object.assign({}, kdfProps), { keySize: keySize + ivSize })); | |
| 26 | + // Separate key and IV | |
| 27 | + const iv = new Word32Array(key.words.slice(keySize), ivSize * 4); | |
| 28 | + key.nSigBytes = keySize * 4; | |
| 29 | + // Return params | |
| 30 | + return new CipherParams({ key, iv, salt }); | |
| 31 | + } | |
| 32 | +}; | ... | ... |
| 1 | +import type { Hasher } from "../../../Hasher"; | |
| 2 | +import { Word32Array } from "../../../../Word32Array"; | |
| 3 | +import { BaseKDFModule, BaseKDFModuleProps } from "../type"; | |
| 4 | +export interface EvpKDFProps extends BaseKDFModuleProps { | |
| 5 | +} | |
| 6 | +/** | |
| 7 | + * This key derivation function is meant to conform with EVP_BytesToKey. | |
| 8 | + * https://www.openssl.org/docs/man1.1.1/man3/EVP_BytesToKey.html | |
| 9 | + * | |
| 10 | + * @property {number} keySize The key size in words to generate. Default: 4 (128 bits) | |
| 11 | + * @property {Hasher} hasher The hash algorithm to use. Default: MD5 | |
| 12 | + * @property {number} iterations The number of iterations to perform. Default: 1 | |
| 13 | + */ | |
| 14 | +export declare class EvpKDF extends BaseKDFModule<EvpKDFProps> { | |
| 15 | + protected _keySize: number; | |
| 16 | + protected _Hasher: typeof Hasher; | |
| 17 | + protected _iterations: number; | |
| 18 | + constructor(props?: Partial<EvpKDFProps>); | |
| 19 | + /** | |
| 20 | + * Derives a key from a password. | |
| 21 | + * | |
| 22 | + * @param {Word32Array|string} password The password. | |
| 23 | + * @param {Word32Array|string} salt A salt. | |
| 24 | + * @return {Word32Array} The derived key. | |
| 25 | + * @example | |
| 26 | + * var kdf = new EvpKDF(); | |
| 27 | + * var key = kdf.compute(password, salt); | |
| 28 | + */ | |
| 29 | + compute(password: Word32Array | string, salt: Word32Array | string): Word32Array; | |
| 30 | + /** | |
| 31 | + * Derives a key from a password. | |
| 32 | + * | |
| 33 | + * @param {Word32Array|string} password The password. | |
| 34 | + * @param {Word32Array|string} salt A salt. | |
| 35 | + * @param {Partial<EvpKDFProps>?} props (Optional) The configuration options to use for this computation. | |
| 36 | + * @return {Word32Array} The derived key. | |
| 37 | + * @static | |
| 38 | + * @example | |
| 39 | + * | |
| 40 | + * var key = EvpKDF.getKey(password, salt); | |
| 41 | + * var key = EvpKDF.getKey(password, salt, { keySize: 8 }); | |
| 42 | + * var key = EvpKDF.getKey(password, salt, { keySize: 8, iterations: 1000 }); | |
| 43 | + */ | |
| 44 | + static getKey(password: Word32Array | string, salt: Word32Array | string, props?: Partial<EvpKDFProps>): Word32Array; | |
| 45 | +} | ... | ... |
| 1 | +import { MD5 } from "../../../../../MD5"; | |
| 2 | +import { Word32Array } from "../../../../Word32Array"; | |
| 3 | +import { BaseKDFModule } from "../type"; | |
| 4 | +/** | |
| 5 | + * This key derivation function is meant to conform with EVP_BytesToKey. | |
| 6 | + * https://www.openssl.org/docs/man1.1.1/man3/EVP_BytesToKey.html | |
| 7 | + * | |
| 8 | + * @property {number} keySize The key size in words to generate. Default: 4 (128 bits) | |
| 9 | + * @property {Hasher} hasher The hash algorithm to use. Default: MD5 | |
| 10 | + * @property {number} iterations The number of iterations to perform. Default: 1 | |
| 11 | + */ | |
| 12 | +export class EvpKDF extends BaseKDFModule { | |
| 13 | + constructor(props) { | |
| 14 | + super(props); | |
| 15 | + this._keySize = 128 / 32; | |
| 16 | + this._Hasher = MD5; | |
| 17 | + this._iterations = 1; | |
| 18 | + if (props) { | |
| 19 | + this._keySize = typeof props.keySize !== "undefined" ? props.keySize : this._keySize; | |
| 20 | + this._Hasher = typeof props.Hasher !== "undefined" ? props.Hasher : this._Hasher; | |
| 21 | + this._iterations = typeof props.iterations !== "undefined" ? props.iterations : this._iterations; | |
| 22 | + } | |
| 23 | + } | |
| 24 | + /** | |
| 25 | + * Derives a key from a password. | |
| 26 | + * | |
| 27 | + * @param {Word32Array|string} password The password. | |
| 28 | + * @param {Word32Array|string} salt A salt. | |
| 29 | + * @return {Word32Array} The derived key. | |
| 30 | + * @example | |
| 31 | + * var kdf = new EvpKDF(); | |
| 32 | + * var key = kdf.compute(password, salt); | |
| 33 | + */ | |
| 34 | + compute(password, salt) { | |
| 35 | + let block; | |
| 36 | + // Init hasher | |
| 37 | + const hasher = new this._Hasher(); | |
| 38 | + // Initial values | |
| 39 | + const derivedKey = new Word32Array(); | |
| 40 | + // Shortcuts | |
| 41 | + const derivedKeyWords = derivedKey.words; | |
| 42 | + const keySize = this._keySize; | |
| 43 | + const iterations = this._iterations; | |
| 44 | + // Generate key | |
| 45 | + while (derivedKeyWords.length < keySize) { | |
| 46 | + if (block) { | |
| 47 | + hasher.update(block); | |
| 48 | + } | |
| 49 | + block = hasher.update(password).finalize(salt); | |
| 50 | + hasher.reset(); | |
| 51 | + // Iterations | |
| 52 | + for (let i = 1; i < iterations; i++) { | |
| 53 | + block = hasher.finalize(block); | |
| 54 | + hasher.reset(); | |
| 55 | + } | |
| 56 | + derivedKey.concat(block); | |
| 57 | + } | |
| 58 | + derivedKey.nSigBytes = keySize * 4; | |
| 59 | + return derivedKey; | |
| 60 | + } | |
| 61 | + /** | |
| 62 | + * Derives a key from a password. | |
| 63 | + * | |
| 64 | + * @param {Word32Array|string} password The password. | |
| 65 | + * @param {Word32Array|string} salt A salt. | |
| 66 | + * @param {Partial<EvpKDFProps>?} props (Optional) The configuration options to use for this computation. | |
| 67 | + * @return {Word32Array} The derived key. | |
| 68 | + * @static | |
| 69 | + * @example | |
| 70 | + * | |
| 71 | + * var key = EvpKDF.getKey(password, salt); | |
| 72 | + * var key = EvpKDF.getKey(password, salt, { keySize: 8 }); | |
| 73 | + * var key = EvpKDF.getKey(password, salt, { keySize: 8, iterations: 1000 }); | |
| 74 | + */ | |
| 75 | + static getKey(password, salt, props) { | |
| 76 | + return new EvpKDF(props).compute(password, salt); | |
| 77 | + } | |
| 78 | +} | ... | ... |
| 1 | +import type { Hasher } from "../../../Hasher"; | |
| 2 | +import { Word32Array } from "../../../../Word32Array"; | |
| 3 | +import { BaseKDFModule, BaseKDFModuleProps } from "../type"; | |
| 4 | +export interface PBKDF2Props extends BaseKDFModuleProps { | |
| 5 | +} | |
| 6 | +/** | |
| 7 | + * Password-Based Key Derivation Function 2 algorithm. | |
| 8 | + * | |
| 9 | + * @property {number} keySize The key size in words to generate. Default: 4 (128 bits) | |
| 10 | + * @property {Hasher} hasher The hash algorithm to use. Default: SHA1 | |
| 11 | + * @property {number} iterations The number of iterations to perform. Default: 1 | |
| 12 | + */ | |
| 13 | +export declare class PBKDF2 extends BaseKDFModule<PBKDF2Props> { | |
| 14 | + protected _keySize: number; | |
| 15 | + protected _Hasher: typeof Hasher; | |
| 16 | + protected _iterations: number; | |
| 17 | + constructor(props?: Partial<PBKDF2Props>); | |
| 18 | + /** | |
| 19 | + * Derives a key from a password. | |
| 20 | + * | |
| 21 | + * @param {Word32Array|string} password The password. | |
| 22 | + * @param {Word32Array|string} salt A salt. | |
| 23 | + * @return {Word32Array} The derived key. | |
| 24 | + * @example | |
| 25 | + * var kdf = new PBKDF2(); | |
| 26 | + * var key = kdf.compute(password, salt); | |
| 27 | + */ | |
| 28 | + compute(password: Word32Array | string, salt: Word32Array | string): Word32Array; | |
| 29 | + /** | |
| 30 | + * Derives a key from a password. | |
| 31 | + * | |
| 32 | + * @param {Word32Array|string} password The password. | |
| 33 | + * @param {Word32Array|string} salt A salt. | |
| 34 | + * @param {Partial<PBKDF2Props>?} props (Optional) The configuration options to use for this computation. | |
| 35 | + * @return {Word32Array} The derived key. | |
| 36 | + * @static | |
| 37 | + * @example | |
| 38 | + * var key = PBKDF2.getKey(password, salt); | |
| 39 | + * var key = PBKDF2.getKey(password, salt, { keySize: 8 }); | |
| 40 | + * var key = PBKDF2.getKey(password, salt, { keySize: 8, iterations: 1000 }); | |
| 41 | + */ | |
| 42 | + static getKey(password: Word32Array | string, salt: Word32Array | string, props?: Partial<PBKDF2Props>): Word32Array; | |
| 43 | +} | ... | ... |
| 1 | +import { SHA256 } from "../../../../../SHA256"; | |
| 2 | +import { Hmac } from "../../../../../Hmac"; | |
| 3 | +import { Word32Array } from "../../../../Word32Array"; | |
| 4 | +import { BaseKDFModule } from "../type"; | |
| 5 | +/** | |
| 6 | + * Password-Based Key Derivation Function 2 algorithm. | |
| 7 | + * | |
| 8 | + * @property {number} keySize The key size in words to generate. Default: 4 (128 bits) | |
| 9 | + * @property {Hasher} hasher The hash algorithm to use. Default: SHA1 | |
| 10 | + * @property {number} iterations The number of iterations to perform. Default: 1 | |
| 11 | + */ | |
| 12 | +export class PBKDF2 extends BaseKDFModule { | |
| 13 | + constructor(props) { | |
| 14 | + super(props); | |
| 15 | + this._keySize = 128 / 32; | |
| 16 | + this._Hasher = SHA256; | |
| 17 | + this._iterations = 10000; | |
| 18 | + if (props) { | |
| 19 | + this._keySize = typeof props.keySize !== "undefined" ? props.keySize : this._keySize; | |
| 20 | + this._Hasher = typeof props.Hasher !== "undefined" ? props.Hasher : this._Hasher; | |
| 21 | + this._iterations = typeof props.iterations !== "undefined" ? props.iterations : this._iterations; | |
| 22 | + } | |
| 23 | + } | |
| 24 | + /** | |
| 25 | + * Derives a key from a password. | |
| 26 | + * | |
| 27 | + * @param {Word32Array|string} password The password. | |
| 28 | + * @param {Word32Array|string} salt A salt. | |
| 29 | + * @return {Word32Array} The derived key. | |
| 30 | + * @example | |
| 31 | + * var kdf = new PBKDF2(); | |
| 32 | + * var key = kdf.compute(password, salt); | |
| 33 | + */ | |
| 34 | + compute(password, salt) { | |
| 35 | + // Init HMAC | |
| 36 | + const hmac = new Hmac(new this._Hasher(), password); | |
| 37 | + // Initial values | |
| 38 | + const derivedKey = new Word32Array(); | |
| 39 | + const blockIndex = new Word32Array([0x00000001]); | |
| 40 | + // Shortcuts | |
| 41 | + const derivedKeyWords = derivedKey.words; | |
| 42 | + const blockIndexWords = blockIndex.words; | |
| 43 | + const keySize = this._keySize; | |
| 44 | + const iterations = this._iterations; | |
| 45 | + // Generate key | |
| 46 | + while (derivedKeyWords.length < keySize) { | |
| 47 | + const block = hmac.update(salt).finalize(blockIndex); | |
| 48 | + hmac.reset(); | |
| 49 | + // Shortcuts | |
| 50 | + const blockWords = block.words; | |
| 51 | + const blockWordsLength = blockWords.length; | |
| 52 | + // Iterations | |
| 53 | + let intermediate = block; | |
| 54 | + for (let i = 1; i < iterations; i++) { | |
| 55 | + intermediate = hmac.finalize(intermediate); | |
| 56 | + hmac.reset(); | |
| 57 | + // Shortcut | |
| 58 | + const intermediateWords = intermediate.words; | |
| 59 | + // XOR intermediate with block | |
| 60 | + for (let j = 0; j < blockWordsLength; j++) { | |
| 61 | + blockWords[j] ^= intermediateWords[j]; | |
| 62 | + } | |
| 63 | + } | |
| 64 | + derivedKey.concat(block); | |
| 65 | + blockIndexWords[0]++; | |
| 66 | + } | |
| 67 | + derivedKey.nSigBytes = keySize * 4; | |
| 68 | + return derivedKey; | |
| 69 | + } | |
| 70 | + /** | |
| 71 | + * Derives a key from a password. | |
| 72 | + * | |
| 73 | + * @param {Word32Array|string} password The password. | |
| 74 | + * @param {Word32Array|string} salt A salt. | |
| 75 | + * @param {Partial<PBKDF2Props>?} props (Optional) The configuration options to use for this computation. | |
| 76 | + * @return {Word32Array} The derived key. | |
| 77 | + * @static | |
| 78 | + * @example | |
| 79 | + * var key = PBKDF2.getKey(password, salt); | |
| 80 | + * var key = PBKDF2.getKey(password, salt, { keySize: 8 }); | |
| 81 | + * var key = PBKDF2.getKey(password, salt, { keySize: 8, iterations: 1000 }); | |
| 82 | + */ | |
| 83 | + static getKey(password, salt, props) { | |
| 84 | + return new PBKDF2(props).compute(password, salt); | |
| 85 | + } | |
| 86 | +} | ... | ... |
| 1 | +import type { Hasher } from "../../Hasher"; | |
| 2 | +import type { CipherParams } from "../CipherParams"; | |
| 3 | +import type { Word32Array } from "../../../Word32Array"; | |
| 4 | +export interface KDFParams extends Pick<CipherParams, "toString"> { | |
| 5 | + key: Word32Array; | |
| 6 | + iv: Word32Array; | |
| 7 | + salt: Word32Array; | |
| 8 | +} | |
| 9 | +export interface KDFProps { | |
| 10 | + kdfModule: typeof BaseKDFModule; | |
| 11 | + kdfHasher: typeof Hasher; | |
| 12 | + kdfIterations: number; | |
| 13 | +} | |
| 14 | +export interface KDF { | |
| 15 | + execute: (password: Word32Array | string, keySize: number, ivSize: number, salt?: Word32Array, props?: Partial<KDFProps>) => KDFParams; | |
| 16 | +} | |
| 17 | +export interface BaseKDFModuleProps { | |
| 18 | + keySize: number; | |
| 19 | + Hasher: typeof Hasher; | |
| 20 | + iterations: number; | |
| 21 | +} | |
| 22 | +export declare class BaseKDFModule<P extends BaseKDFModuleProps = BaseKDFModuleProps> { | |
| 23 | + protected _props?: Partial<P>; | |
| 24 | + constructor(props?: Partial<P>); | |
| 25 | + compute(password: Word32Array | string, salt: Word32Array | string): Word32Array; | |
| 26 | + static getKey<P2 extends BaseKDFModuleProps>(password: Word32Array | string, salt: Word32Array | string, props?: Partial<P2>): Word32Array; | |
| 27 | +} | ... | ... |
| 1 | +import type { BlockCipher } from "../BlockCipher"; | |
| 2 | +import type { Word32Array } from "../../../Word32Array"; | |
| 3 | +export interface BlockCipherModeProps { | |
| 4 | + cipher: BlockCipher; | |
| 5 | + iv: Word32Array | undefined; | |
| 6 | +} | |
| 7 | +/** | |
| 8 | + * Abstract base block cipher mode template. | |
| 9 | + * @abstract | |
| 10 | + */ | |
| 11 | +export declare class BlockCipherMode { | |
| 12 | + protected _props: BlockCipherModeProps; | |
| 13 | + protected _cipher: BlockCipher; | |
| 14 | + protected _iv?: Word32Array; | |
| 15 | + constructor(props: BlockCipherModeProps); | |
| 16 | + /** | |
| 17 | + * @abstract | |
| 18 | + */ | |
| 19 | + processBlock(words: number[], offset: number): void; | |
| 20 | + /** | |
| 21 | + * Creates this mode for encryption. | |
| 22 | + * @param {BlockCipherModeProps} props | |
| 23 | + * @abstract | |
| 24 | + * @example | |
| 25 | + * var mode = CBC.createEncryptor(cipher, iv.words); | |
| 26 | + */ | |
| 27 | + static createEncryptor(props: BlockCipherModeProps): BlockCipherMode; | |
| 28 | + /** | |
| 29 | + * Creates this mode for decryption. | |
| 30 | + * @param {BlockCipherModeProps} props | |
| 31 | + * @abstract | |
| 32 | + * @example | |
| 33 | + * var mode = CBC.createDecryptor(cipher, iv.words); | |
| 34 | + */ | |
| 35 | + static createDecryptor(props: BlockCipherModeProps): BlockCipherMode; | |
| 36 | +} | ... | ... |
| 1 | +/** | |
| 2 | + * Abstract base block cipher mode template. | |
| 3 | + * @abstract | |
| 4 | + */ | |
| 5 | +export class BlockCipherMode { | |
| 6 | + constructor(props) { | |
| 7 | + this._props = props; | |
| 8 | + this._cipher = props.cipher; | |
| 9 | + this._iv = props.iv; | |
| 10 | + } | |
| 11 | + /** | |
| 12 | + * @abstract | |
| 13 | + */ | |
| 14 | + processBlock(words, offset) { | |
| 15 | + return; | |
| 16 | + } | |
| 17 | + /** | |
| 18 | + * Creates this mode for encryption. | |
| 19 | + * @param {BlockCipherModeProps} props | |
| 20 | + * @abstract | |
| 21 | + * @example | |
| 22 | + * var mode = CBC.createEncryptor(cipher, iv.words); | |
| 23 | + */ | |
| 24 | + static createEncryptor(props) { | |
| 25 | + throw new Error("Not implemented yet"); | |
| 26 | + } | |
| 27 | + /** | |
| 28 | + * Creates this mode for decryption. | |
| 29 | + * @param {BlockCipherModeProps} props | |
| 30 | + * @abstract | |
| 31 | + * @example | |
| 32 | + * var mode = CBC.createDecryptor(cipher, iv.words); | |
| 33 | + */ | |
| 34 | + static createDecryptor(props) { | |
| 35 | + throw new Error("Not implemented yet"); | |
| 36 | + } | |
| 37 | +} | ... | ... |
| 1 | +import { BlockCipherMode, BlockCipherModeProps } from "./BlockCipherMode"; | |
| 2 | +export interface CBCProps extends BlockCipherModeProps { | |
| 3 | +} | |
| 4 | +export declare class CBC extends BlockCipherMode { | |
| 5 | + protected _prevBlock: number[]; | |
| 6 | + /** | |
| 7 | + * CBC encryptor. | |
| 8 | + */ | |
| 9 | + static Encryptor: typeof CBC; | |
| 10 | + /** | |
| 11 | + * CBC decryptor. | |
| 12 | + */ | |
| 13 | + static Decryptor: typeof CBC; | |
| 14 | + constructor(props: CBCProps); | |
| 15 | + xorBlock(words: number[], offset: number, blockSize: number): void; | |
| 16 | + /** | |
| 17 | + * Creates this mode for encryption. | |
| 18 | + * @param {BlockCipherModeProps} props | |
| 19 | + * @example | |
| 20 | + * var mode = CBC.createEncryptor(cipher, iv.words); | |
| 21 | + */ | |
| 22 | + static createEncryptor(props: CBCProps): CBC; | |
| 23 | + /** | |
| 24 | + * Creates this mode for decryption. | |
| 25 | + * @param {BlockCipherModeProps} props | |
| 26 | + * @example | |
| 27 | + * var mode = CBC.createDecryptor(cipher, iv.words); | |
| 28 | + */ | |
| 29 | + static createDecryptor(props: CBCProps): CBC; | |
| 30 | +} | ... | ... |
| 1 | +import { BlockCipherMode } from "./BlockCipherMode"; | |
| 2 | +export class CBC extends BlockCipherMode { | |
| 3 | + constructor(props) { | |
| 4 | + super(props); | |
| 5 | + this._prevBlock = []; | |
| 6 | + } | |
| 7 | + xorBlock(words, offset, blockSize) { | |
| 8 | + let block; | |
| 9 | + // Shortcut | |
| 10 | + const iv = this._iv; | |
| 11 | + // Choose mixing block | |
| 12 | + if (iv) { | |
| 13 | + block = iv.words; | |
| 14 | + // Remove IV for subsequent blocks | |
| 15 | + this._iv = undefined; | |
| 16 | + } | |
| 17 | + else { | |
| 18 | + block = this._prevBlock; | |
| 19 | + } | |
| 20 | + // XOR blocks | |
| 21 | + for (let i = 0; i < blockSize; i++) { | |
| 22 | + words[offset + i] ^= block[i]; | |
| 23 | + } | |
| 24 | + } | |
| 25 | + /** | |
| 26 | + * Creates this mode for encryption. | |
| 27 | + * @param {BlockCipherModeProps} props | |
| 28 | + * @example | |
| 29 | + * var mode = CBC.createEncryptor(cipher, iv.words); | |
| 30 | + */ | |
| 31 | + static createEncryptor(props) { | |
| 32 | + return new CBC.Encryptor(props); | |
| 33 | + } | |
| 34 | + /** | |
| 35 | + * Creates this mode for decryption. | |
| 36 | + * @param {BlockCipherModeProps} props | |
| 37 | + * @example | |
| 38 | + * var mode = CBC.createDecryptor(cipher, iv.words); | |
| 39 | + */ | |
| 40 | + static createDecryptor(props) { | |
| 41 | + return new CBC.Decryptor(props); | |
| 42 | + } | |
| 43 | +} | |
| 44 | +/** | |
| 45 | + * CBC encryptor. | |
| 46 | + */ | |
| 47 | +CBC.Encryptor = class Encryptor extends CBC { | |
| 48 | + /** | |
| 49 | + * Processes the data block at offset. | |
| 50 | + * | |
| 51 | + * @param {number[]} words The data words to operate on. | |
| 52 | + * @param {number} offset The offset where the block starts. | |
| 53 | + * @example | |
| 54 | + * mode.processBlock(data.words, offset); | |
| 55 | + */ | |
| 56 | + processBlock(words, offset) { | |
| 57 | + // Shortcuts | |
| 58 | + const cipher = this._cipher; | |
| 59 | + const blockSize = cipher.blockSize; | |
| 60 | + // XOR and encrypt | |
| 61 | + this.xorBlock(words, offset, blockSize); | |
| 62 | + cipher.encryptBlock(words, offset); | |
| 63 | + // Remember this block to use with next block | |
| 64 | + this._prevBlock = words.slice(offset, offset + blockSize); | |
| 65 | + } | |
| 66 | +}; | |
| 67 | +/** | |
| 68 | + * CBC decryptor. | |
| 69 | + */ | |
| 70 | +CBC.Decryptor = class Decryptor extends CBC { | |
| 71 | + /** | |
| 72 | + * Processes the data block at offset. | |
| 73 | + * | |
| 74 | + * @param {number[]} words The data words to operate on. | |
| 75 | + * @param {number} offset The offset where the block starts. | |
| 76 | + * @example | |
| 77 | + * mode.processBlock(data.words, offset); | |
| 78 | + */ | |
| 79 | + processBlock(words, offset) { | |
| 80 | + // Shortcuts | |
| 81 | + const cipher = this._cipher; | |
| 82 | + const blockSize = cipher.blockSize; | |
| 83 | + // Remember this block to use with next block | |
| 84 | + const thisBlock = words.slice(offset, offset + blockSize); | |
| 85 | + // Decrypt and XOR | |
| 86 | + cipher.decryptBlock(words, offset); | |
| 87 | + this.xorBlock(words, offset, blockSize); | |
| 88 | + // This block becomes the previous block | |
| 89 | + this._prevBlock = thisBlock; | |
| 90 | + } | |
| 91 | +}; | ... | ... |
| 1 | +import { BlockCipherMode, BlockCipherModeProps } from "./BlockCipherMode"; | |
| 2 | +import { Word32Array } from "../../../Word32Array"; | |
| 3 | +import type { BlockCipher } from "../BlockCipher"; | |
| 4 | +/** | |
| 5 | + * Counter/CBC-MAC | |
| 6 | + */ | |
| 7 | +export declare class CCM extends BlockCipherMode { | |
| 8 | + protected _N: Word32Array; | |
| 9 | + protected _CBIndex: number; | |
| 10 | + protected readonly _q: number; | |
| 11 | + constructor(props: BlockCipherModeProps); | |
| 12 | + /** | |
| 13 | + * Generate first block of B. | |
| 14 | + * | |
| 15 | + * @param {boolean} hasAData - If payload has AData, true. | |
| 16 | + * @param {number} t - Octet length of T(Auth tag) | |
| 17 | + * @param {Word32Array} Q - Octet length of payload. | |
| 18 | + * @param {Word32Array} N - Nonce. | |
| 19 | + */ | |
| 20 | + static getB0(hasAData: boolean, t: number, Q: Word32Array, N: Word32Array): Word32Array; | |
| 21 | + /** | |
| 22 | + * Format associated data | |
| 23 | + * @param {Word32Array} A - Associated data | |
| 24 | + * @param {Word32Array} P - Payload | |
| 25 | + */ | |
| 26 | + static formatAssociatedDataAndPayload(A: Word32Array, P: Word32Array): Word32Array; | |
| 27 | + /** | |
| 28 | + * Generate Counter Block | |
| 29 | + * @param {number} q - LEN(Q) | |
| 30 | + * @param {Word32Array} N - Nonce | |
| 31 | + * @param {number} index - Block index of 32bit integer | |
| 32 | + */ | |
| 33 | + static genCtr(q: number, N: Word32Array, index: number): Word32Array; | |
| 34 | + /** | |
| 35 | + * Generate Message Authentication Code | |
| 36 | + * | |
| 37 | + * @param {typeof BlockCipher} Cipher - 128 bit block Cipher i.e. AES | |
| 38 | + * @param {Word32Array} key - Key | |
| 39 | + * @param {Word32Array} iv - Nonce. iv less than or equal to 8byte(64bit) is supported. | |
| 40 | + * @param {Word32Array?} authData - Associated data | |
| 41 | + * @param {Word32Array?} plainText - Payload | |
| 42 | + * @param {number?} tagLength - authTag size in octet length. If omitted, tagLength will be set to 16byte. | |
| 43 | + */ | |
| 44 | + static mac(Cipher: typeof BlockCipher, key: Word32Array, iv: Word32Array, authData?: Word32Array, plainText?: Word32Array, tagLength?: number): Word32Array; | |
| 45 | + static combineCipherTextAndAuthTag(cipherText: Word32Array, authTag: Word32Array): Word32Array; | |
| 46 | + static splitCipherTextAndAuthTag(cipherTextWithAuthTag: Word32Array, tLen?: number): { | |
| 47 | + cipherText: Word32Array; | |
| 48 | + authTag: Word32Array; | |
| 49 | + }; | |
| 50 | + /** | |
| 51 | + * CTR encryptor. | |
| 52 | + */ | |
| 53 | + static Encryptor: typeof CCM; | |
| 54 | + /** | |
| 55 | + * CTR decryptor. | |
| 56 | + */ | |
| 57 | + static Decryptor: typeof CCM; | |
| 58 | + /** | |
| 59 | + * Creates this mode for encryption. | |
| 60 | + * @param {BlockCipherModeProps} props | |
| 61 | + * @example | |
| 62 | + * var mode = CTR.createEncryptor(cipher, iv.words); | |
| 63 | + */ | |
| 64 | + static createEncryptor(props: BlockCipherModeProps): CCM; | |
| 65 | + /** | |
| 66 | + * Creates this mode for decryption. | |
| 67 | + * @param {BlockCipherModeProps} props | |
| 68 | + * @example | |
| 69 | + * var mode = CTR.createDecryptor(cipher, iv.words); | |
| 70 | + */ | |
| 71 | + static createDecryptor(props: BlockCipherModeProps): CCM; | |
| 72 | +} | ... | ... |
| 1 | +import { BlockCipherMode } from "./BlockCipherMode"; | |
| 2 | +import { Word32Array } from "../../../Word32Array"; | |
| 3 | +import { lsb, msb } from "./commonLib"; | |
| 4 | +/** | |
| 5 | + * Counter/CBC-MAC | |
| 6 | + */ | |
| 7 | +export class CCM extends BlockCipherMode { | |
| 8 | + constructor(props) { | |
| 9 | + super(props); | |
| 10 | + this._CBIndex = 1; | |
| 11 | + const { cipher, iv } = props; | |
| 12 | + if (cipher.blockSize !== 128 / 32) { | |
| 13 | + throw new Error("In CCM, cipher block size must be 128bit"); | |
| 14 | + } | |
| 15 | + else if (iv && (iv.nSigBytes > 13 || iv.nSigBytes < 7)) { | |
| 16 | + throw new Error("Byte size of iv must be between 7 and 13"); | |
| 17 | + } | |
| 18 | + this._N = iv || new Word32Array([0, 0], 8); | |
| 19 | + this._q = 15 - this._N.nSigBytes; | |
| 20 | + } | |
| 21 | + /** | |
| 22 | + * Generate first block of B. | |
| 23 | + * | |
| 24 | + * @param {boolean} hasAData - If payload has AData, true. | |
| 25 | + * @param {number} t - Octet length of T(Auth tag) | |
| 26 | + * @param {Word32Array} Q - Octet length of payload. | |
| 27 | + * @param {Word32Array} N - Nonce. | |
| 28 | + */ | |
| 29 | + static getB0(hasAData, t, Q, N) { | |
| 30 | + if (Q.nSigBytes + N.nSigBytes !== 15) { | |
| 31 | + throw new Error("LEN(Q)+LEN(N) must be 15"); | |
| 32 | + } | |
| 33 | + const reservedBit = 0 << 7; | |
| 34 | + const ADataBit = (hasAData ? 1 : 0) << 6; | |
| 35 | + const tBit = (((t - 2) / 2) << 3); // 3bits | |
| 36 | + const qBit = (Q.nSigBytes - 1); // 3bits | |
| 37 | + const flags = (reservedBit | ADataBit | tBit | qBit) & 0x000000ff; | |
| 38 | + const NQ = N.clone().concat(Q); | |
| 39 | + const B00 = new Word32Array([flags << 24], 1); | |
| 40 | + return B00.concat(NQ); | |
| 41 | + } | |
| 42 | + /** | |
| 43 | + * Format associated data | |
| 44 | + * @param {Word32Array} A - Associated data | |
| 45 | + * @param {Word32Array} P - Payload | |
| 46 | + */ | |
| 47 | + static formatAssociatedDataAndPayload(A, P) { | |
| 48 | + const a = A.nSigBytes; | |
| 49 | + let ad; | |
| 50 | + if (a === 0) { | |
| 51 | + ad = new Word32Array([0], 0); | |
| 52 | + } | |
| 53 | + else if (a < Math.pow(2, 16) - Math.pow(2, 8)) { | |
| 54 | + ad = new Word32Array([a << 16], 2); | |
| 55 | + } | |
| 56 | + else if (a < Math.pow(2, 32)) { | |
| 57 | + ad = new Word32Array([0xfffe0000], 2).concat(new Word32Array([a], 4)); | |
| 58 | + } | |
| 59 | + else { | |
| 60 | + throw new Error("LEN(A) larger than 2**32-1 is not supported"); | |
| 61 | + } | |
| 62 | + // Format AdditionalData | |
| 63 | + const nAd = Math.floor(A.nSigBytes / 4); | |
| 64 | + for (let i = 0; i < nAd; i++) { | |
| 65 | + ad.concat(new Word32Array([A.words[i]], 4)); | |
| 66 | + } | |
| 67 | + if (A.nSigBytes % 4) { | |
| 68 | + ad.concat(new Word32Array([A.words[nAd]], A.nSigBytes % 4)); | |
| 69 | + ad.concat(new Word32Array([0], 4 - A.nSigBytes % 4)); | |
| 70 | + } | |
| 71 | + // Align to 16byte block | |
| 72 | + if (ad.nSigBytes % 16) { | |
| 73 | + ad.concat(new Word32Array([0], 16 - ad.nSigBytes % 16)); | |
| 74 | + } | |
| 75 | + // Format Payload | |
| 76 | + const nPayload = Math.floor(P.nSigBytes / 4); | |
| 77 | + for (let i = 0; i < nPayload; i++) { | |
| 78 | + ad.concat(new Word32Array([P.words[i]], 4)); | |
| 79 | + } | |
| 80 | + if (P.nSigBytes % 4) { | |
| 81 | + ad.concat(new Word32Array([P.words[nPayload]], P.nSigBytes % 4)); | |
| 82 | + ad.concat(new Word32Array([0], 4 - P.nSigBytes % 4)); | |
| 83 | + } | |
| 84 | + // Align to 16byte block | |
| 85 | + if (ad.nSigBytes % 16) { | |
| 86 | + ad.concat(new Word32Array([0], 16 - ad.nSigBytes % 16)); | |
| 87 | + } | |
| 88 | + return ad; | |
| 89 | + } | |
| 90 | + /** | |
| 91 | + * Generate Counter Block | |
| 92 | + * @param {number} q - LEN(Q) | |
| 93 | + * @param {Word32Array} N - Nonce | |
| 94 | + * @param {number} index - Block index of 32bit integer | |
| 95 | + */ | |
| 96 | + static genCtr(q, N, index) { | |
| 97 | + if (N.nSigBytes + q !== 15) { | |
| 98 | + throw new Error("LEN(Q)+LEN(N) must be 15"); | |
| 99 | + } | |
| 100 | + const flag = new Word32Array([((q - 1) & 0x00000007) << 24], 1); | |
| 101 | + const indexBytes = new Word32Array([], 0); | |
| 102 | + const nq = Math.floor(q / 4); | |
| 103 | + for (let i = 0; i < nq - 1; i++) { | |
| 104 | + indexBytes.concat(new Word32Array([0], 4)); | |
| 105 | + } | |
| 106 | + if (q % 4) { | |
| 107 | + if (q > 4) { | |
| 108 | + indexBytes.concat(new Word32Array([0], q % 4)); | |
| 109 | + indexBytes.concat(new Word32Array([index], 4)); | |
| 110 | + } | |
| 111 | + else { | |
| 112 | + indexBytes.concat(new Word32Array([index << (32 - q * 8)], q)); | |
| 113 | + } | |
| 114 | + } | |
| 115 | + else { | |
| 116 | + indexBytes.concat(new Word32Array([index], 4)); | |
| 117 | + } | |
| 118 | + return flag.concat(N).concat(indexBytes); | |
| 119 | + } | |
| 120 | + /** | |
| 121 | + * Generate Message Authentication Code | |
| 122 | + * | |
| 123 | + * @param {typeof BlockCipher} Cipher - 128 bit block Cipher i.e. AES | |
| 124 | + * @param {Word32Array} key - Key | |
| 125 | + * @param {Word32Array} iv - Nonce. iv less than or equal to 8byte(64bit) is supported. | |
| 126 | + * @param {Word32Array?} authData - Associated data | |
| 127 | + * @param {Word32Array?} plainText - Payload | |
| 128 | + * @param {number?} tagLength - authTag size in octet length. If omitted, tagLength will be set to 16byte. | |
| 129 | + */ | |
| 130 | + static mac(Cipher, key, iv, authData, plainText, tagLength) { | |
| 131 | + const cipher = new Cipher({ key, iv }); | |
| 132 | + if (cipher.blockSize !== 128 / 32) { | |
| 133 | + throw new Error("In CCM, cipher block size must be 128bit"); | |
| 134 | + } | |
| 135 | + else if (iv && (iv.nSigBytes > 13 || iv.nSigBytes < 7)) { | |
| 136 | + throw new Error("Byte size of iv must be between 7 and 13"); | |
| 137 | + } | |
| 138 | + const N = iv || new Word32Array([0, 0], 8); | |
| 139 | + const A = (authData === null || authData === void 0 ? void 0 : authData.clone()) || new Word32Array(); | |
| 140 | + const a = A.nSigBytes; | |
| 141 | + const P = (plainText === null || plainText === void 0 ? void 0 : plainText.clone()) || new Word32Array(); | |
| 142 | + const p = P.nSigBytes; | |
| 143 | + if ((p >>> 0) > 4294967295) { | |
| 144 | + throw new Error("Byte length of Payload(plainText) larger than 2^32-1 (4,294,967,295byte) is not supported at this time."); | |
| 145 | + } | |
| 146 | + const q = 15 - N.nSigBytes; | |
| 147 | + const Q = lsb(new Word32Array([0, p], 8), q); | |
| 148 | + const t = tagLength || 16; | |
| 149 | + const B0 = CCM.getB0(Boolean(a), t, Q, N); | |
| 150 | + const Bi = CCM.formatAssociatedDataAndPayload(A, P); | |
| 151 | + const Y0 = B0.words.slice(); | |
| 152 | + cipher.encryptBlock(Y0, 0); | |
| 153 | + const n = Bi.nSigBytes / 16; | |
| 154 | + const wordsBi = Bi.words; | |
| 155 | + let Y = Y0; | |
| 156 | + for (let i = 0; i < n; i++) { | |
| 157 | + const Yi0 = wordsBi[i * 4] ^ Y[0]; | |
| 158 | + const Yi1 = wordsBi[i * 4 + 1] ^ Y[1]; | |
| 159 | + const Yi2 = wordsBi[i * 4 + 2] ^ Y[2]; | |
| 160 | + const Yi3 = wordsBi[i * 4 + 3] ^ Y[3]; | |
| 161 | + const Yi = [Yi0, Yi1, Yi2, Yi3]; | |
| 162 | + cipher.encryptBlock(Yi, 0); | |
| 163 | + Y = Yi; | |
| 164 | + } | |
| 165 | + const T = new Word32Array(Y, t); | |
| 166 | + const ctr0 = CCM.genCtr(q, N, 0); | |
| 167 | + cipher.encryptBlock(ctr0.words, 0); | |
| 168 | + for (let i = 0; i < 4; i++) { | |
| 169 | + T.words[i] ^= ctr0.words[i]; | |
| 170 | + } | |
| 171 | + T.clamp(); | |
| 172 | + return T; | |
| 173 | + } | |
| 174 | + static combineCipherTextAndAuthTag(cipherText, authTag) { | |
| 175 | + return cipherText.clone().concat(authTag); | |
| 176 | + } | |
| 177 | + static splitCipherTextAndAuthTag(cipherTextWithAuthTag, tLen) { | |
| 178 | + const t = tLen || 16; | |
| 179 | + const cipherText = msb(cipherTextWithAuthTag, cipherTextWithAuthTag.nSigBytes - t); | |
| 180 | + const authTag = lsb(cipherTextWithAuthTag, t); | |
| 181 | + return { cipherText, authTag }; | |
| 182 | + } | |
| 183 | + /** | |
| 184 | + * Creates this mode for encryption. | |
| 185 | + * @param {BlockCipherModeProps} props | |
| 186 | + * @example | |
| 187 | + * var mode = CTR.createEncryptor(cipher, iv.words); | |
| 188 | + */ | |
| 189 | + static createEncryptor(props) { | |
| 190 | + return new CCM.Encryptor(props); | |
| 191 | + } | |
| 192 | + /** | |
| 193 | + * Creates this mode for decryption. | |
| 194 | + * @param {BlockCipherModeProps} props | |
| 195 | + * @example | |
| 196 | + * var mode = CTR.createDecryptor(cipher, iv.words); | |
| 197 | + */ | |
| 198 | + static createDecryptor(props) { | |
| 199 | + return new CCM.Decryptor(props); | |
| 200 | + } | |
| 201 | +} | |
| 202 | +/** | |
| 203 | + * CTR encryptor. | |
| 204 | + */ | |
| 205 | +CCM.Encryptor = class Encryptor extends CCM { | |
| 206 | + /** | |
| 207 | + * Processes the data block at offset. | |
| 208 | + * | |
| 209 | + * @param {number[]} words The data words to operate on. | |
| 210 | + * @param {number} offset The offset where the block starts. | |
| 211 | + * @example | |
| 212 | + * mode.processBlock(data.words, offset); | |
| 213 | + */ | |
| 214 | + processBlock(words, offset) { | |
| 215 | + // Shortcuts | |
| 216 | + const cipher = this._cipher; | |
| 217 | + const blockSize = cipher.blockSize; | |
| 218 | + const CBi = CCM.genCtr(this._q, this._N, this._CBIndex); | |
| 219 | + cipher.encryptBlock(CBi.words, 0); | |
| 220 | + for (let i = 0; i < blockSize; i++) { | |
| 221 | + words[offset + i] ^= CBi.words[i]; | |
| 222 | + } | |
| 223 | + this._CBIndex++; | |
| 224 | + } | |
| 225 | +}; | |
| 226 | +/** | |
| 227 | + * CTR decryptor. | |
| 228 | + */ | |
| 229 | +CCM.Decryptor = class Decryptor extends CCM { | |
| 230 | + /** | |
| 231 | + * Processes the data block at offset. | |
| 232 | + * | |
| 233 | + * @param {number[]} words The data words to operate on. | |
| 234 | + * @param {number} offset The offset where the block starts. | |
| 235 | + * @example | |
| 236 | + * mode.processBlock(data.words, offset); | |
| 237 | + */ | |
| 238 | + processBlock(words, offset) { | |
| 239 | + // Shortcuts | |
| 240 | + const cipher = this._cipher; | |
| 241 | + const blockSize = cipher.blockSize; | |
| 242 | + const CBi = CCM.genCtr(this._q, this._N, this._CBIndex); | |
| 243 | + cipher.encryptBlock(CBi.words, 0); | |
| 244 | + for (let i = 0; i < blockSize; i++) { | |
| 245 | + words[offset + i] ^= CBi.words[i]; | |
| 246 | + } | |
| 247 | + this._CBIndex++; | |
| 248 | + } | |
| 249 | +}; | ... | ... |
| 1 | +import { BlockCipherMode, BlockCipherModeProps } from "./BlockCipherMode"; | |
| 2 | +import type { BlockCipher } from "../BlockCipher"; | |
| 3 | +/** | |
| 4 | + * Cipher Feedback Block mode | |
| 5 | + */ | |
| 6 | +export declare class CFB extends BlockCipherMode { | |
| 7 | + protected _prevBlock: number[]; | |
| 8 | + /** | |
| 9 | + * CFB encryptor. | |
| 10 | + */ | |
| 11 | + static Encryptor: typeof CFB; | |
| 12 | + /** | |
| 13 | + * CFB decryptor. | |
| 14 | + */ | |
| 15 | + static Decryptor: typeof CFB; | |
| 16 | + constructor(props: BlockCipherModeProps); | |
| 17 | + generateKeyStreamAndEncrypt(words: number[], offset: number, blockSize: number, cipher: BlockCipher): void; | |
| 18 | + /** | |
| 19 | + * Creates this mode for encryption. | |
| 20 | + * @param {BlockCipherModeProps} props | |
| 21 | + * @example | |
| 22 | + * var mode = CFB.createEncryptor(cipher, iv.words); | |
| 23 | + */ | |
| 24 | + static createEncryptor(props: BlockCipherModeProps): CFB; | |
| 25 | + /** | |
| 26 | + * Creates this mode for decryption. | |
| 27 | + * @param {BlockCipherModeProps} props | |
| 28 | + * @example | |
| 29 | + * var mode = CFB.createDecryptor(cipher, iv.words); | |
| 30 | + */ | |
| 31 | + static createDecryptor(props: BlockCipherModeProps): CFB; | |
| 32 | +} | ... | ... |
| 1 | +import { BlockCipherMode } from "./BlockCipherMode"; | |
| 2 | +/** | |
| 3 | + * Cipher Feedback Block mode | |
| 4 | + */ | |
| 5 | +export class CFB extends BlockCipherMode { | |
| 6 | + constructor(props) { | |
| 7 | + super(props); | |
| 8 | + this._prevBlock = []; | |
| 9 | + } | |
| 10 | + generateKeyStreamAndEncrypt(words, offset, blockSize, cipher) { | |
| 11 | + let keyStream; | |
| 12 | + // Shortcut | |
| 13 | + const iv = this._iv; | |
| 14 | + // Generate keyStream | |
| 15 | + if (iv) { | |
| 16 | + keyStream = iv.words.slice(0); | |
| 17 | + // Remove IV for subsequent blocks | |
| 18 | + this._iv = undefined; | |
| 19 | + } | |
| 20 | + else { | |
| 21 | + keyStream = this._prevBlock; | |
| 22 | + } | |
| 23 | + cipher.encryptBlock(keyStream, 0); | |
| 24 | + // Encrypt | |
| 25 | + for (let i = 0; i < blockSize; i++) { | |
| 26 | + words[offset + i] ^= keyStream[i]; | |
| 27 | + } | |
| 28 | + } | |
| 29 | + /** | |
| 30 | + * Creates this mode for encryption. | |
| 31 | + * @param {BlockCipherModeProps} props | |
| 32 | + * @example | |
| 33 | + * var mode = CFB.createEncryptor(cipher, iv.words); | |
| 34 | + */ | |
| 35 | + static createEncryptor(props) { | |
| 36 | + return new CFB.Encryptor(props); | |
| 37 | + } | |
| 38 | + /** | |
| 39 | + * Creates this mode for decryption. | |
| 40 | + * @param {BlockCipherModeProps} props | |
| 41 | + * @example | |
| 42 | + * var mode = CFB.createDecryptor(cipher, iv.words); | |
| 43 | + */ | |
| 44 | + static createDecryptor(props) { | |
| 45 | + return new CFB.Decryptor(props); | |
| 46 | + } | |
| 47 | +} | |
| 48 | +/** | |
| 49 | + * CFB encryptor. | |
| 50 | + */ | |
| 51 | +CFB.Encryptor = class Encryptor extends CFB { | |
| 52 | + /** | |
| 53 | + * Processes the data block at offset. | |
| 54 | + * | |
| 55 | + * @param {number[]} words The data words to operate on. | |
| 56 | + * @param {number} offset The offset where the block starts. | |
| 57 | + * @example | |
| 58 | + * mode.processBlock(data.words, offset); | |
| 59 | + */ | |
| 60 | + processBlock(words, offset) { | |
| 61 | + this.generateKeyStreamAndEncrypt(words, offset, this._cipher.blockSize, this._cipher); | |
| 62 | + // Remember this block to use with next block | |
| 63 | + this._prevBlock = words.slice(offset, offset + this._cipher.blockSize); | |
| 64 | + } | |
| 65 | +}; | |
| 66 | +/** | |
| 67 | + * CFB decryptor. | |
| 68 | + */ | |
| 69 | +CFB.Decryptor = class Encryptor extends CFB { | |
| 70 | + /** | |
| 71 | + * Processes the data block at offset. | |
| 72 | + * | |
| 73 | + * @param {number[]} words The data words to operate on. | |
| 74 | + * @param {number} offset The offset where the block starts. | |
| 75 | + * @example | |
| 76 | + * mode.processBlock(data.words, offset); | |
| 77 | + */ | |
| 78 | + processBlock(words, offset) { | |
| 79 | + // Remember this block to use with next block | |
| 80 | + const thisBlock = words.slice(offset, offset + this._cipher.blockSize); | |
| 81 | + this.generateKeyStreamAndEncrypt(words, offset, this._cipher.blockSize, this._cipher); | |
| 82 | + // This block becomes the previous block | |
| 83 | + this._prevBlock = thisBlock; | |
| 84 | + } | |
| 85 | +}; | ... | ... |
| 1 | +import { BlockCipherMode, BlockCipherModeProps } from "./BlockCipherMode"; | |
| 2 | +/** | |
| 3 | + * Output Feedback Block mode | |
| 4 | + */ | |
| 5 | +export declare class CTR extends BlockCipherMode { | |
| 6 | + protected _counter: number[]; | |
| 7 | + /** | |
| 8 | + * CTR encryptor. | |
| 9 | + */ | |
| 10 | + static Encryptor: typeof CTR; | |
| 11 | + /** | |
| 12 | + * CTR decryptor. | |
| 13 | + */ | |
| 14 | + static Decryptor: typeof CTR; | |
| 15 | + constructor(props: BlockCipherModeProps); | |
| 16 | + /** | |
| 17 | + * Creates this mode for encryption. | |
| 18 | + * @param {BlockCipherModeProps} props | |
| 19 | + * @example | |
| 20 | + * var mode = CTR.createEncryptor(cipher, iv.words); | |
| 21 | + */ | |
| 22 | + static createEncryptor(props: BlockCipherModeProps): CTR; | |
| 23 | + /** | |
| 24 | + * Creates this mode for decryption. | |
| 25 | + * @param {BlockCipherModeProps} props | |
| 26 | + * @example | |
| 27 | + * var mode = CTR.createDecryptor(cipher, iv.words); | |
| 28 | + */ | |
| 29 | + static createDecryptor(props: BlockCipherModeProps): CTR; | |
| 30 | +} | ... | ... |
| 1 | +import { BlockCipherMode } from "./BlockCipherMode"; | |
| 2 | +/** | |
| 3 | + * Output Feedback Block mode | |
| 4 | + */ | |
| 5 | +export class CTR extends BlockCipherMode { | |
| 6 | + constructor(props) { | |
| 7 | + super(props); | |
| 8 | + this._counter = []; | |
| 9 | + } | |
| 10 | + /** | |
| 11 | + * Creates this mode for encryption. | |
| 12 | + * @param {BlockCipherModeProps} props | |
| 13 | + * @example | |
| 14 | + * var mode = CTR.createEncryptor(cipher, iv.words); | |
| 15 | + */ | |
| 16 | + static createEncryptor(props) { | |
| 17 | + return new CTR.Encryptor(props); | |
| 18 | + } | |
| 19 | + /** | |
| 20 | + * Creates this mode for decryption. | |
| 21 | + * @param {BlockCipherModeProps} props | |
| 22 | + * @example | |
| 23 | + * var mode = CTR.createDecryptor(cipher, iv.words); | |
| 24 | + */ | |
| 25 | + static createDecryptor(props) { | |
| 26 | + return new CTR.Decryptor(props); | |
| 27 | + } | |
| 28 | +} | |
| 29 | +/** | |
| 30 | + * CTR encryptor. | |
| 31 | + */ | |
| 32 | +CTR.Encryptor = class Encryptor extends CTR { | |
| 33 | + /** | |
| 34 | + * Processes the data block at offset. | |
| 35 | + * | |
| 36 | + * @param {number[]} words The data words to operate on. | |
| 37 | + * @param {number} offset The offset where the block starts. | |
| 38 | + * @example | |
| 39 | + * mode.processBlock(data.words, offset); | |
| 40 | + */ | |
| 41 | + processBlock(words, offset) { | |
| 42 | + // Shortcuts | |
| 43 | + const cipher = this._cipher; | |
| 44 | + const blockSize = cipher.blockSize; | |
| 45 | + const iv = this._iv; | |
| 46 | + let counter = this._counter; | |
| 47 | + // Generate keyStream | |
| 48 | + if (iv) { | |
| 49 | + counter = this._counter = iv.words.slice(0); | |
| 50 | + // Remove IV for subsequent blocks | |
| 51 | + this._iv = undefined; | |
| 52 | + } | |
| 53 | + const keyStream = counter.slice(0); | |
| 54 | + cipher.encryptBlock(keyStream, 0); | |
| 55 | + // Increment counter | |
| 56 | + counter[blockSize - 1] = (counter[blockSize - 1] + 1) | 0; | |
| 57 | + // Encrypt | |
| 58 | + for (let i = 0; i < blockSize; i++) { | |
| 59 | + words[offset + i] ^= keyStream[i]; | |
| 60 | + } | |
| 61 | + } | |
| 62 | +}; | |
| 63 | +/** | |
| 64 | + * CTR decryptor. | |
| 65 | + */ | |
| 66 | +CTR.Decryptor = CTR.Encryptor; | ... | ... |
| 1 | +import { BlockCipherMode, BlockCipherModeProps } from "./BlockCipherMode"; | |
| 2 | +/** | |
| 3 | + * Electronic Codebook block mode. | |
| 4 | + */ | |
| 5 | +export declare class ECB extends BlockCipherMode { | |
| 6 | + /** | |
| 7 | + * ECB encryptor. | |
| 8 | + */ | |
| 9 | + static Encryptor: typeof ECB; | |
| 10 | + /** | |
| 11 | + * ECB decryptor. | |
| 12 | + */ | |
| 13 | + static Decryptor: typeof ECB; | |
| 14 | + constructor(props: BlockCipherModeProps); | |
| 15 | + /** | |
| 16 | + * Creates this mode for encryption. | |
| 17 | + * @param {BlockCipherModeProps} props | |
| 18 | + * @example | |
| 19 | + * var mode = ECB.createEncryptor(cipher, iv.words); | |
| 20 | + */ | |
| 21 | + static createEncryptor(props: BlockCipherModeProps): ECB; | |
| 22 | + /** | |
| 23 | + * Creates this mode for decryption. | |
| 24 | + * @param {BlockCipherModeProps} props | |
| 25 | + * @example | |
| 26 | + * var mode = ECB.createDecryptor(cipher, iv.words); | |
| 27 | + */ | |
| 28 | + static createDecryptor(props: BlockCipherModeProps): ECB; | |
| 29 | +} | ... | ... |
| 1 | +import { BlockCipherMode } from "./BlockCipherMode"; | |
| 2 | +/** | |
| 3 | + * Electronic Codebook block mode. | |
| 4 | + */ | |
| 5 | +export class ECB extends BlockCipherMode { | |
| 6 | + constructor(props) { | |
| 7 | + super(props); | |
| 8 | + } | |
| 9 | + /** | |
| 10 | + * Creates this mode for encryption. | |
| 11 | + * @param {BlockCipherModeProps} props | |
| 12 | + * @example | |
| 13 | + * var mode = ECB.createEncryptor(cipher, iv.words); | |
| 14 | + */ | |
| 15 | + static createEncryptor(props) { | |
| 16 | + return new ECB.Encryptor(props); | |
| 17 | + } | |
| 18 | + /** | |
| 19 | + * Creates this mode for decryption. | |
| 20 | + * @param {BlockCipherModeProps} props | |
| 21 | + * @example | |
| 22 | + * var mode = ECB.createDecryptor(cipher, iv.words); | |
| 23 | + */ | |
| 24 | + static createDecryptor(props) { | |
| 25 | + return new ECB.Decryptor(props); | |
| 26 | + } | |
| 27 | +} | |
| 28 | +/** | |
| 29 | + * ECB encryptor. | |
| 30 | + */ | |
| 31 | +ECB.Encryptor = class Encryptor extends ECB { | |
| 32 | + /** | |
| 33 | + * Processes the data block at offset. | |
| 34 | + * | |
| 35 | + * @param {number[]} words The data words to operate on. | |
| 36 | + * @param {number} offset The offset where the block starts. | |
| 37 | + * @example | |
| 38 | + * mode.processBlock(data.words, offset); | |
| 39 | + */ | |
| 40 | + processBlock(words, offset) { | |
| 41 | + this._cipher.encryptBlock(words, offset); | |
| 42 | + } | |
| 43 | +}; | |
| 44 | +/** | |
| 45 | + * ECB decryptor. | |
| 46 | + */ | |
| 47 | +ECB.Decryptor = class Decryptor extends ECB { | |
| 48 | + /** | |
| 49 | + * Processes the data block at offset. | |
| 50 | + * | |
| 51 | + * @param {number[]} words The data words to operate on. | |
| 52 | + * @param {number} offset The offset where the block starts. | |
| 53 | + * @example | |
| 54 | + * mode.processBlock(data.words, offset); | |
| 55 | + */ | |
| 56 | + processBlock(words, offset) { | |
| 57 | + this._cipher.decryptBlock(words, offset); | |
| 58 | + } | |
| 59 | +}; | ... | ... |
| 1 | +import { BlockCipherMode, BlockCipherModeProps } from "./BlockCipherMode"; | |
| 2 | +import { Word32Array } from "../../../Word32Array"; | |
| 3 | +import type { BlockCipher } from "../BlockCipher"; | |
| 4 | +/** | |
| 5 | + * Galois Counter Mode | |
| 6 | + */ | |
| 7 | +export declare class GCM extends BlockCipherMode { | |
| 8 | + protected _H: number[]; | |
| 9 | + protected _J0: number[]; | |
| 10 | + protected _CB: number[]; | |
| 11 | + constructor(props: BlockCipherModeProps); | |
| 12 | + /** | |
| 13 | + * Initialize Initial Counter Block J0. | |
| 14 | + * @param {[number, number, number, number]} H - 128bit(4word) block | |
| 15 | + * @param {number[]} iv - Initializing Vector which must be multiple of 32bit(4byte) | |
| 16 | + */ | |
| 17 | + static getJ0(H: number[], iv?: number[]): number[]; | |
| 18 | + /** | |
| 19 | + * https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf | |
| 20 | + * 6.2 Incrementing Function | |
| 21 | + * inc(s=32, X) = MSB(len(X)-s, X) || [int(LSB(s, X)+1 mod 2^s] | |
| 22 | + * | |
| 23 | + * @param {number[]} X - [32bit int, 32bit int, 32bit int, 32bit int]. | |
| 24 | + * @example | |
| 25 | + * inc32([0,0,0,0]) = [0,0,0,1] | |
| 26 | + * inc32([0,0,0,1]) = [0,0,0,2] | |
| 27 | + * inc32([0,0,0,0xffffffff]) = [0,0,1,0] | |
| 28 | + * inc32([0,0,0xffffffff,0xffffffff]) = [0,1,0,0] | |
| 29 | + * inc32([0,0xffffffff,0xffffffff,0xffffffff]) = [0,0,0,0] | |
| 30 | + */ | |
| 31 | + static inc32(X: number[]): number[]; | |
| 32 | + /** | |
| 33 | + * https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf | |
| 34 | + * 6.3 Multiplication Operation on Blocks | |
| 35 | + * | |
| 36 | + * @param {number[]} X - [32bit int, 32bit int, 32bit int, 32bit int], 128bit block. | |
| 37 | + * @param {number[]} Y - [32bit int, 32bit int, 32bit int, 32bit int], 128bit block. | |
| 38 | + * @returns 128bit block | |
| 39 | + */ | |
| 40 | + static mul(X: number[], Y: number[]): number[]; | |
| 41 | + /** | |
| 42 | + * https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf | |
| 43 | + * 6.4 GHASH Function | |
| 44 | + * | |
| 45 | + * @param {number[]} H - The hash sub key block of 128bit. | |
| 46 | + * @param {number[]} X - X.length must be multiple of 4. (multiple of 128bit) | |
| 47 | + * @returns 128bit block | |
| 48 | + */ | |
| 49 | + static GHASH(H: number[], X: number[]): number[]; | |
| 50 | + /** | |
| 51 | + * https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf | |
| 52 | + * 6.5 GCTR Function | |
| 53 | + * | |
| 54 | + * @param {BlockCipher} cipher | |
| 55 | + * @param {number[]} ICB - Initial Code Block. Required to be 128bit(4word). | |
| 56 | + * @param {Word32Array} X - Arbitrary length block | |
| 57 | + */ | |
| 58 | + static GCTR(cipher: BlockCipher, ICB: number[], X: Word32Array): Word32Array; | |
| 59 | + /** | |
| 60 | + * Calculate Message Authentication Code with GCM | |
| 61 | + * | |
| 62 | + * @param {typeof BlockCipher} Cipher - 128 bit block Cipher i.e. AES | |
| 63 | + * @param {Word32Array} key - key | |
| 64 | + * @param {Word32Array} iv - iv should be 12byte length. i.e. `new Word32Array([0x11223344, 0x55667788, 0x99aabbcc], 12);` | |
| 65 | + * @param {Word32Array?} aad - Additional Authenticated Data | |
| 66 | + * @param {Word32Array?} cipherText - encrypted text | |
| 67 | + * @param {number?} tagLength - authTag size in octet length. If omitted, tagLength will be set to 16byte. | |
| 68 | + */ | |
| 69 | + static mac(Cipher: typeof BlockCipher, key: Word32Array, iv: Word32Array, aad?: Word32Array, cipherText?: Word32Array, tagLength?: number): Word32Array; | |
| 70 | + /** | |
| 71 | + * CTR encryptor. | |
| 72 | + */ | |
| 73 | + static Encryptor: typeof GCM; | |
| 74 | + /** | |
| 75 | + * CTR decryptor. | |
| 76 | + */ | |
| 77 | + static Decryptor: typeof GCM; | |
| 78 | + /** | |
| 79 | + * Creates this mode for encryption. | |
| 80 | + * @param {BlockCipherModeProps} props | |
| 81 | + * @example | |
| 82 | + * var mode = CTR.createEncryptor(cipher, iv.words); | |
| 83 | + */ | |
| 84 | + static createEncryptor(props: BlockCipherModeProps): GCM; | |
| 85 | + /** | |
| 86 | + * Creates this mode for decryption. | |
| 87 | + * @param {BlockCipherModeProps} props | |
| 88 | + * @example | |
| 89 | + * var mode = CTR.createDecryptor(cipher, iv.words); | |
| 90 | + */ | |
| 91 | + static createDecryptor(props: BlockCipherModeProps): GCM; | |
| 92 | +} | ... | ... |
| 1 | +import { BlockCipherMode } from "./BlockCipherMode"; | |
| 2 | +import { Word32Array } from "../../../Word32Array"; | |
| 3 | +import { msb, padTo128m } from "./commonLib"; | |
| 4 | +/** | |
| 5 | + * Galois Counter Mode | |
| 6 | + */ | |
| 7 | +export class GCM extends BlockCipherMode { | |
| 8 | + constructor(props) { | |
| 9 | + super(props); | |
| 10 | + this._H = []; | |
| 11 | + this._J0 = []; | |
| 12 | + this._CB = []; // Counter Block | |
| 13 | + if (props.cipher.blockSize !== 128 / 32) { | |
| 14 | + throw new Error("In GCM block cipher mode, cipher block size must be 128bit"); | |
| 15 | + } | |
| 16 | + const { cipher, iv } = props; | |
| 17 | + const H = [0, 0, 0, 0]; | |
| 18 | + cipher.encryptBlock(H, 0); | |
| 19 | + this._H = H; | |
| 20 | + // iv should be array of 32bit int | |
| 21 | + this._J0 = GCM.getJ0(H, iv === null || iv === void 0 ? void 0 : iv.words); | |
| 22 | + this._CB = this._J0.slice(); | |
| 23 | + } | |
| 24 | + /** | |
| 25 | + * Initialize Initial Counter Block J0. | |
| 26 | + * @param {[number, number, number, number]} H - 128bit(4word) block | |
| 27 | + * @param {number[]} iv - Initializing Vector which must be multiple of 32bit(4byte) | |
| 28 | + */ | |
| 29 | + static getJ0(H, iv) { | |
| 30 | + let J0; | |
| 31 | + if (!iv || iv.length === 0) { | |
| 32 | + J0 = [0, 0, 0, 1]; | |
| 33 | + } | |
| 34 | + else if (iv.length === 3) { | |
| 35 | + J0 = [iv[0], iv[1], iv[2], 1]; | |
| 36 | + } | |
| 37 | + else { | |
| 38 | + const remainderOf4Word = (iv.length % 4) > 0 ? 4 - (iv.length % 4) : 0; | |
| 39 | + const iv2 = iv.slice(); | |
| 40 | + for (let i = 0; i < remainderOf4Word + 2; i++) { | |
| 41 | + iv2.push(0); // append 32bit 0 | |
| 42 | + } | |
| 43 | + // This should be upper 32bit of len(iv), | |
| 44 | + // But iv.length > 4294967295(0xffffffff, unsigned 32bit int max) is not supported for now. | |
| 45 | + iv2.push(0); | |
| 46 | + iv2.push(iv.length * 32); // An element of `iv` is 4byte = 32bit. | |
| 47 | + J0 = GCM.GHASH(H, iv2); | |
| 48 | + } | |
| 49 | + return J0; | |
| 50 | + } | |
| 51 | + /** | |
| 52 | + * https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf | |
| 53 | + * 6.2 Incrementing Function | |
| 54 | + * inc(s=32, X) = MSB(len(X)-s, X) || [int(LSB(s, X)+1 mod 2^s] | |
| 55 | + * | |
| 56 | + * @param {number[]} X - [32bit int, 32bit int, 32bit int, 32bit int]. | |
| 57 | + * @example | |
| 58 | + * inc32([0,0,0,0]) = [0,0,0,1] | |
| 59 | + * inc32([0,0,0,1]) = [0,0,0,2] | |
| 60 | + * inc32([0,0,0,0xffffffff]) = [0,0,1,0] | |
| 61 | + * inc32([0,0,0xffffffff,0xffffffff]) = [0,1,0,0] | |
| 62 | + * inc32([0,0xffffffff,0xffffffff,0xffffffff]) = [0,0,0,0] | |
| 63 | + */ | |
| 64 | + static inc32(X) { | |
| 65 | + const A = X.slice(); | |
| 66 | + const unsignedX3 = (A[3] >>> 0); | |
| 67 | + const carry3 = ((unsignedX3 + 1) >>> 0) < unsignedX3; | |
| 68 | + A[3] = (A[3] + 1) | 0; | |
| 69 | + if (carry3) { | |
| 70 | + const unsignedX2 = (A[2] >>> 0); | |
| 71 | + const carry2 = ((unsignedX2 + 1) >>> 0) < unsignedX2; | |
| 72 | + A[2] = (A[2] + 1) | 0; | |
| 73 | + if (carry2) { | |
| 74 | + A[1] = (A[1] + 1) | 0; | |
| 75 | + } | |
| 76 | + } | |
| 77 | + return A; | |
| 78 | + } | |
| 79 | + /** | |
| 80 | + * https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf | |
| 81 | + * 6.3 Multiplication Operation on Blocks | |
| 82 | + * | |
| 83 | + * @param {number[]} X - [32bit int, 32bit int, 32bit int, 32bit int], 128bit block. | |
| 84 | + * @param {number[]} Y - [32bit int, 32bit int, 32bit int, 32bit int], 128bit block. | |
| 85 | + * @returns 128bit block | |
| 86 | + */ | |
| 87 | + static mul(X, Y) { | |
| 88 | + const R = [0xe1000000, 0, 0, 0]; | |
| 89 | + const Z = [0, 0, 0, 0]; | |
| 90 | + const V = Y.slice(); | |
| 91 | + for (let i = 0; i < 128; i++) { | |
| 92 | + const xIndex = i >>> 5; | |
| 93 | + const xi = (X[xIndex] >>> (31 - i % 32)) & 1; | |
| 94 | + if (xi > 0) { | |
| 95 | + Z[0] = Z[0] ^ V[0]; | |
| 96 | + Z[1] = Z[1] ^ V[1]; | |
| 97 | + Z[2] = Z[2] ^ V[2]; | |
| 98 | + Z[3] = Z[3] ^ V[3]; | |
| 99 | + } | |
| 100 | + const LSBVi = (V[3] & 1) >>> 0; | |
| 101 | + const carry0 = (V[0] & 1) >>> 0; | |
| 102 | + const carry1 = (V[1] & 1) >>> 0; | |
| 103 | + const carry2 = (V[2] & 1) >>> 0; | |
| 104 | + V[0] = V[0] >>> 1; | |
| 105 | + V[1] = (V[1] >>> 1) | (carry0 ? 0x80000000 : 0); | |
| 106 | + V[2] = (V[2] >>> 1) | (carry1 ? 0x80000000 : 0); | |
| 107 | + V[3] = (V[3] >>> 1) | (carry2 ? 0x80000000 : 0); | |
| 108 | + if (LSBVi > 0) { | |
| 109 | + V[0] ^= R[0]; | |
| 110 | + V[1] ^= R[1]; | |
| 111 | + V[2] ^= R[2]; | |
| 112 | + V[3] ^= R[3]; | |
| 113 | + } | |
| 114 | + } | |
| 115 | + return Z; | |
| 116 | + } | |
| 117 | + /** | |
| 118 | + * https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf | |
| 119 | + * 6.4 GHASH Function | |
| 120 | + * | |
| 121 | + * @param {number[]} H - The hash sub key block of 128bit. | |
| 122 | + * @param {number[]} X - X.length must be multiple of 4. (multiple of 128bit) | |
| 123 | + * @returns 128bit block | |
| 124 | + */ | |
| 125 | + static GHASH(H, X) { | |
| 126 | + if (H.length % 4 !== 0) { | |
| 127 | + throw new Error("Length of 32bit word array 'H' must be multiple of 4(128bit)"); | |
| 128 | + } | |
| 129 | + else if (X.length % 4 !== 0) { | |
| 130 | + throw new Error("Length of 32bit word array 'X' must be multiple of 4(128bit)"); | |
| 131 | + } | |
| 132 | + const m = X.length; | |
| 133 | + let Y = [0, 0, 0, 0]; | |
| 134 | + for (let i = 0; i < m; i += 4) { | |
| 135 | + Y[0] = (Y[0] ^ X[i]); | |
| 136 | + Y[1] = (Y[1] ^ X[i + 1]); | |
| 137 | + Y[2] = (Y[2] ^ X[i + 2]); | |
| 138 | + Y[3] = (Y[3] ^ X[i + 3]); | |
| 139 | + Y = GCM.mul(Y, H); | |
| 140 | + } | |
| 141 | + return Y; | |
| 142 | + } | |
| 143 | + /** | |
| 144 | + * https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf | |
| 145 | + * 6.5 GCTR Function | |
| 146 | + * | |
| 147 | + * @param {BlockCipher} cipher | |
| 148 | + * @param {number[]} ICB - Initial Code Block. Required to be 128bit(4word). | |
| 149 | + * @param {Word32Array} X - Arbitrary length block | |
| 150 | + */ | |
| 151 | + static GCTR(cipher, ICB, X) { | |
| 152 | + if (X.nSigBytes === 0) { | |
| 153 | + return X.clone(); | |
| 154 | + } | |
| 155 | + if (ICB.length !== 4) { | |
| 156 | + throw new Error("Initial Counter Block size must be 128bit"); | |
| 157 | + } | |
| 158 | + const words = X.words; | |
| 159 | + const n = Math.ceil(X.nSigBytes / 16); | |
| 160 | + const CB = [ICB.slice()]; | |
| 161 | + for (let i = 1; i < n; i++) { | |
| 162 | + const CBi = GCM.inc32(CB[i - 1]); | |
| 163 | + CB.push(CBi); | |
| 164 | + } | |
| 165 | + const Y = new Word32Array(); | |
| 166 | + for (let i = 0; i < n; i++) { | |
| 167 | + cipher.encryptBlock(CB[i], 0); | |
| 168 | + const remainderOf16Bytes = X.nSigBytes % 16; | |
| 169 | + if (i < n - 1 || /* i === n-1 && */ remainderOf16Bytes === 0) { | |
| 170 | + const Yi0 = words[i * 4] ^ CB[i][0]; | |
| 171 | + const Yi1 = words[i * 4 + 1] ^ CB[i][1]; | |
| 172 | + const Yi2 = words[i * 4 + 2] ^ CB[i][2]; | |
| 173 | + const Yi3 = words[i * 4 + 3] ^ CB[i][3]; | |
| 174 | + const Yi = new Word32Array([Yi0, Yi1, Yi2, Yi3]); | |
| 175 | + Y.concat(Yi); | |
| 176 | + continue; | |
| 177 | + } | |
| 178 | + // i === n-1 | |
| 179 | + const w = []; | |
| 180 | + let nSigBytes = 0; | |
| 181 | + const nMaxAligned = Math.floor(remainderOf16Bytes / 4); | |
| 182 | + for (let k = 0; k < nMaxAligned; k++) { | |
| 183 | + const Ynk = words[i * 4 + k] ^ CB[i][k]; | |
| 184 | + w.push(Ynk); | |
| 185 | + nSigBytes += 4; | |
| 186 | + } | |
| 187 | + const remaining0to3Bytes = remainderOf16Bytes % 4; | |
| 188 | + if (remaining0to3Bytes > 0) { | |
| 189 | + const Ynr = (words[i * 4 + nMaxAligned] << (32 - 8 * remaining0to3Bytes)) ^ CB[i][nMaxAligned]; | |
| 190 | + w.push(Ynr); | |
| 191 | + nSigBytes += remaining0to3Bytes; | |
| 192 | + } | |
| 193 | + const Yn = new Word32Array(w, nSigBytes); | |
| 194 | + Y.concat(Yn); | |
| 195 | + } | |
| 196 | + Y.nSigBytes = X.nSigBytes; | |
| 197 | + Y.clamp(); | |
| 198 | + return Y; | |
| 199 | + } | |
| 200 | + /** | |
| 201 | + * Calculate Message Authentication Code with GCM | |
| 202 | + * | |
| 203 | + * @param {typeof BlockCipher} Cipher - 128 bit block Cipher i.e. AES | |
| 204 | + * @param {Word32Array} key - key | |
| 205 | + * @param {Word32Array} iv - iv should be 12byte length. i.e. `new Word32Array([0x11223344, 0x55667788, 0x99aabbcc], 12);` | |
| 206 | + * @param {Word32Array?} aad - Additional Authenticated Data | |
| 207 | + * @param {Word32Array?} cipherText - encrypted text | |
| 208 | + * @param {number?} tagLength - authTag size in octet length. If omitted, tagLength will be set to 16byte. | |
| 209 | + */ | |
| 210 | + static mac(Cipher, key, iv, aad, cipherText, tagLength) { | |
| 211 | + const cipher = new Cipher({ key, iv }); | |
| 212 | + const H = [0, 0, 0, 0]; | |
| 213 | + cipher.encryptBlock(H, 0); | |
| 214 | + const J0 = GCM.getJ0(H, iv.words); | |
| 215 | + const A = (aad === null || aad === void 0 ? void 0 : aad.clone()) || new Word32Array(); | |
| 216 | + const lenA = [0, A.nSigBytes * 8]; | |
| 217 | + const C = (cipherText === null || cipherText === void 0 ? void 0 : cipherText.clone()) || new Word32Array(); | |
| 218 | + const lenC = [0, C.nSigBytes * 8]; | |
| 219 | + const lenT = tagLength || 16; | |
| 220 | + // Pad | |
| 221 | + padTo128m(A); | |
| 222 | + padTo128m(C); | |
| 223 | + const s = A.words.concat(C.words).concat(lenA).concat(lenC); | |
| 224 | + const S = GCM.GHASH(H, s); | |
| 225 | + const MAC = GCM.GCTR(cipher, J0, new Word32Array(S)); | |
| 226 | + return msb(MAC, lenT); | |
| 227 | + } | |
| 228 | + /** | |
| 229 | + * Creates this mode for encryption. | |
| 230 | + * @param {BlockCipherModeProps} props | |
| 231 | + * @example | |
| 232 | + * var mode = CTR.createEncryptor(cipher, iv.words); | |
| 233 | + */ | |
| 234 | + static createEncryptor(props) { | |
| 235 | + return new GCM.Encryptor(props); | |
| 236 | + } | |
| 237 | + /** | |
| 238 | + * Creates this mode for decryption. | |
| 239 | + * @param {BlockCipherModeProps} props | |
| 240 | + * @example | |
| 241 | + * var mode = CTR.createDecryptor(cipher, iv.words); | |
| 242 | + */ | |
| 243 | + static createDecryptor(props) { | |
| 244 | + return new GCM.Decryptor(props); | |
| 245 | + } | |
| 246 | +} | |
| 247 | +/** | |
| 248 | + * CTR encryptor. | |
| 249 | + */ | |
| 250 | +GCM.Encryptor = class Encryptor extends GCM { | |
| 251 | + /** | |
| 252 | + * Processes the data block at offset. | |
| 253 | + * | |
| 254 | + * @param {number[]} words The data words to operate on. | |
| 255 | + * @param {number} offset The offset where the block starts. | |
| 256 | + * @example | |
| 257 | + * mode.processBlock(data.words, offset); | |
| 258 | + */ | |
| 259 | + processBlock(words, offset) { | |
| 260 | + // Shortcuts | |
| 261 | + const cipher = this._cipher; | |
| 262 | + const blockSize = cipher.blockSize; | |
| 263 | + // Encrypt with CTR mode | |
| 264 | + this._CB = GCM.inc32(this._CB); | |
| 265 | + const plainText = new Word32Array(words.slice(offset, offset + blockSize)); | |
| 266 | + const C = GCM.GCTR(this._cipher, this._CB, plainText); | |
| 267 | + for (let i = 0; i < blockSize; i++) { | |
| 268 | + words[offset + i] = C.words[i]; | |
| 269 | + } | |
| 270 | + } | |
| 271 | +}; | |
| 272 | +/** | |
| 273 | + * CTR decryptor. | |
| 274 | + */ | |
| 275 | +GCM.Decryptor = class Decryptor extends GCM { | |
| 276 | + /** | |
| 277 | + * Processes the data block at offset. | |
| 278 | + * | |
| 279 | + * @param {number[]} words The data words to operate on. | |
| 280 | + * @param {number} offset The offset where the block starts. | |
| 281 | + * @example | |
| 282 | + * mode.processBlock(data.words, offset); | |
| 283 | + */ | |
| 284 | + processBlock(words, offset) { | |
| 285 | + // Shortcuts | |
| 286 | + const cipher = this._cipher; | |
| 287 | + const blockSize = cipher.blockSize; | |
| 288 | + // Decrypt with CTR mode | |
| 289 | + this._CB = GCM.inc32(this._CB); | |
| 290 | + const C = new Word32Array(words.slice(offset, offset + blockSize)); | |
| 291 | + const P = GCM.GCTR(this._cipher, this._CB, C); | |
| 292 | + for (let i = 0; i < blockSize; i++) { | |
| 293 | + words[offset + i] = P.words[i]; | |
| 294 | + } | |
| 295 | + } | |
| 296 | +}; | ... | ... |
| 1 | +import { BlockCipherMode, BlockCipherModeProps } from "./BlockCipherMode"; | |
| 2 | +/** | |
| 3 | + * Output Feedback Block mode | |
| 4 | + */ | |
| 5 | +export declare class OFB extends BlockCipherMode { | |
| 6 | + protected _keyStream: number[]; | |
| 7 | + /** | |
| 8 | + * OFB encryptor. | |
| 9 | + */ | |
| 10 | + static Encryptor: typeof OFB; | |
| 11 | + /** | |
| 12 | + * OFB decryptor. | |
| 13 | + */ | |
| 14 | + static Decryptor: typeof OFB; | |
| 15 | + constructor(props: BlockCipherModeProps); | |
| 16 | + /** | |
| 17 | + * Creates this mode for encryption. | |
| 18 | + * @param {BlockCipherModeProps} props | |
| 19 | + * @example | |
| 20 | + * var mode = OFB.createEncryptor(cipher, iv.words); | |
| 21 | + */ | |
| 22 | + static createEncryptor(props: BlockCipherModeProps): OFB; | |
| 23 | + /** | |
| 24 | + * Creates this mode for decryption. | |
| 25 | + * @param {BlockCipherModeProps} props | |
| 26 | + * @example | |
| 27 | + * var mode = OFB.createDecryptor(cipher, iv.words); | |
| 28 | + */ | |
| 29 | + static createDecryptor(props: BlockCipherModeProps): OFB; | |
| 30 | +} | ... | ... |
| 1 | +import { BlockCipherMode } from "./BlockCipherMode"; | |
| 2 | +/** | |
| 3 | + * Output Feedback Block mode | |
| 4 | + */ | |
| 5 | +export class OFB extends BlockCipherMode { | |
| 6 | + constructor(props) { | |
| 7 | + super(props); | |
| 8 | + this._keyStream = []; | |
| 9 | + } | |
| 10 | + /** | |
| 11 | + * Creates this mode for encryption. | |
| 12 | + * @param {BlockCipherModeProps} props | |
| 13 | + * @example | |
| 14 | + * var mode = OFB.createEncryptor(cipher, iv.words); | |
| 15 | + */ | |
| 16 | + static createEncryptor(props) { | |
| 17 | + return new OFB.Encryptor(props); | |
| 18 | + } | |
| 19 | + /** | |
| 20 | + * Creates this mode for decryption. | |
| 21 | + * @param {BlockCipherModeProps} props | |
| 22 | + * @example | |
| 23 | + * var mode = OFB.createDecryptor(cipher, iv.words); | |
| 24 | + */ | |
| 25 | + static createDecryptor(props) { | |
| 26 | + return new OFB.Decryptor(props); | |
| 27 | + } | |
| 28 | +} | |
| 29 | +/** | |
| 30 | + * OFB encryptor. | |
| 31 | + */ | |
| 32 | +OFB.Encryptor = class Encryptor extends OFB { | |
| 33 | + /** | |
| 34 | + * Processes the data block at offset. | |
| 35 | + * | |
| 36 | + * @param {number[]} words The data words to operate on. | |
| 37 | + * @param {number} offset The offset where the block starts. | |
| 38 | + * @example | |
| 39 | + * mode.processBlock(data.words, offset); | |
| 40 | + */ | |
| 41 | + processBlock(words, offset) { | |
| 42 | + // Shortcuts | |
| 43 | + const cipher = this._cipher; | |
| 44 | + const blockSize = cipher.blockSize; | |
| 45 | + const iv = this._iv; | |
| 46 | + let keyStream = this._keyStream; | |
| 47 | + // Generate key stream | |
| 48 | + if (iv) { | |
| 49 | + keyStream = this._keyStream = iv.words.slice(0); | |
| 50 | + // Remove IV for subsequent blocks | |
| 51 | + this._iv = undefined; | |
| 52 | + } | |
| 53 | + cipher.encryptBlock(keyStream, 0); | |
| 54 | + // Encrypt | |
| 55 | + for (let i = 0; i < blockSize; i++) { | |
| 56 | + words[offset + i] ^= keyStream[i]; | |
| 57 | + } | |
| 58 | + } | |
| 59 | +}; | |
| 60 | +/** | |
| 61 | + * OFB decryptor. | |
| 62 | + */ | |
| 63 | +OFB.Decryptor = OFB.Encryptor; | ... | ... |
| 1 | +import { Word32Array } from "../../../Word32Array"; | |
| 2 | +/** | |
| 3 | + * Pad word array to multiple of 128bit(4byte) | |
| 4 | + * @param {Word32Array} w - Padding target. This w will be modified directly. | |
| 5 | + * @returns {void} | |
| 6 | + */ | |
| 7 | +export declare function padTo128m(w: Word32Array): void; | |
| 8 | +/** | |
| 9 | + * Extract Most Significant Bit. | |
| 10 | + * @param {Word32Array} w | |
| 11 | + * @param {number} bytes - Number of bytes to extract | |
| 12 | + * @example | |
| 13 | + * const w = new Word32Array([0x11223344, 0x55667788]); | |
| 14 | + * msb(w, 2).toString() === "1122"; // true | |
| 15 | + */ | |
| 16 | +export declare function msb(w: Word32Array, bytes: number): Word32Array; | |
| 17 | +/** | |
| 18 | + * Extract Least Significant Bit. | |
| 19 | + * @param {Word32Array} w | |
| 20 | + * @param {number} bytes - Number of bytes to extract | |
| 21 | + * @example | |
| 22 | + * const w = new Word32Array([0x11223344, 0x55667788, 0x99aabb00], 11); | |
| 23 | + * lsb(w, 5).toString() === "778899aabb"; // true | |
| 24 | + */ | |
| 25 | +export declare function lsb(w: Word32Array, bytes: number): Word32Array; | ... | ... |
| 1 | +import { Word32Array } from "../../../Word32Array"; | |
| 2 | +/** | |
| 3 | + * Pad word array to multiple of 128bit(4byte) | |
| 4 | + * @param {Word32Array} w - Padding target. This w will be modified directly. | |
| 5 | + * @returns {void} | |
| 6 | + */ | |
| 7 | +export function padTo128m(w) { | |
| 8 | + const remainder = w.nSigBytes % 16; | |
| 9 | + if (remainder === 0) { | |
| 10 | + return; | |
| 11 | + } | |
| 12 | + const nPaddingBytes = 16 - remainder; | |
| 13 | + // Pad Ciphertext | |
| 14 | + const pad = []; | |
| 15 | + const maxI = Math.floor(nPaddingBytes / 4); | |
| 16 | + for (let i = 0; i < maxI; i++) { | |
| 17 | + pad.push(0); | |
| 18 | + } | |
| 19 | + if (nPaddingBytes % 4 > 0) { | |
| 20 | + pad.push(0); | |
| 21 | + } | |
| 22 | + w.concat(new Word32Array(pad, nPaddingBytes)); | |
| 23 | +} | |
| 24 | +/** | |
| 25 | + * Extract Most Significant Bit. | |
| 26 | + * @param {Word32Array} w | |
| 27 | + * @param {number} bytes - Number of bytes to extract | |
| 28 | + * @example | |
| 29 | + * const w = new Word32Array([0x11223344, 0x55667788]); | |
| 30 | + * msb(w, 2).toString() === "1122"; // true | |
| 31 | + */ | |
| 32 | +export function msb(w, bytes) { | |
| 33 | + return new Word32Array(w.words.slice(), bytes); | |
| 34 | +} | |
| 35 | +/** | |
| 36 | + * Extract Least Significant Bit. | |
| 37 | + * @param {Word32Array} w | |
| 38 | + * @param {number} bytes - Number of bytes to extract | |
| 39 | + * @example | |
| 40 | + * const w = new Word32Array([0x11223344, 0x55667788, 0x99aabb00], 11); | |
| 41 | + * lsb(w, 5).toString() === "778899aabb"; // true | |
| 42 | + */ | |
| 43 | +export function lsb(w, bytes) { | |
| 44 | + const n = w.nSigBytes; | |
| 45 | + const nShift = n - bytes; | |
| 46 | + const lsbWords = []; | |
| 47 | + for (let i = 0; i < bytes; i++) { | |
| 48 | + const j = i >>> 2; | |
| 49 | + const byteIndex = nShift + i; | |
| 50 | + const wordIndex = byteIndex >>> 2; | |
| 51 | + const b = (w.words[wordIndex] >>> (24 - (byteIndex % 4) * 8)) & 0x000000ff; | |
| 52 | + lsbWords[j] = (lsbWords[j] | 0) | (b << (24 - (i % 4) * 8)); | |
| 53 | + } | |
| 54 | + const wLsb = new Word32Array(lsbWords, bytes); | |
| 55 | + wLsb.clamp(); | |
| 56 | + return wLsb; | |
| 57 | +} | ... | ... |
| 1 | +/** | |
| 2 | + * ANSI X.923 padding strategy | |
| 3 | + * | |
| 4 | + * @param {Word32Array} data The data to pad. | |
| 5 | + * @param {number} blockSize The multiple that the data should be padded to. | |
| 6 | + * @example | |
| 7 | + * AnsiX923.pad(wordArray, 4); | |
| 8 | + */ | |
| 9 | +function pad(data, blockSize) { | |
| 10 | + // Shortcuts | |
| 11 | + const dataSigBytes = data.nSigBytes; | |
| 12 | + const blockSizeBytes = blockSize * 4; | |
| 13 | + // Count padding bytes | |
| 14 | + const nPaddingBytes = blockSizeBytes - dataSigBytes % blockSizeBytes; | |
| 15 | + // Compute last byte position | |
| 16 | + const lastBytePos = dataSigBytes + nPaddingBytes - 1; | |
| 17 | + // Pad | |
| 18 | + data.clamp(); | |
| 19 | + data.words[lastBytePos >>> 2] |= nPaddingBytes << (24 - (lastBytePos % 4) * 8); | |
| 20 | + data.nSigBytes += nPaddingBytes; | |
| 21 | +} | |
| 22 | +/** | |
| 23 | + * Unpads data that had been padded with ANSI X.923 padding strategy | |
| 24 | + * | |
| 25 | + * @param {Word32Array} data The data to unpad. | |
| 26 | + * @example | |
| 27 | + * AnsiX923.unpad(wordArray); | |
| 28 | + */ | |
| 29 | +function unpad(data) { | |
| 30 | + // Get number of padding bytes from last byte | |
| 31 | + const nPaddingBytes = data.words[(data.nSigBytes - 1) >>> 2] & 0xff; | |
| 32 | + // Remove padding | |
| 33 | + data.nSigBytes -= nPaddingBytes; | |
| 34 | +} | |
| 35 | +export const AnsiX923 = { | |
| 36 | + pad, | |
| 37 | + unpad, | |
| 38 | +}; | ... | ... |
| 1 | +import { Word32Array } from "../../../Word32Array"; | |
| 2 | +/** | |
| 3 | + * ISO10126 padding strategy | |
| 4 | + * | |
| 5 | + * @param {Word32Array} data The data to pad. | |
| 6 | + * @param {number} blockSize The multiple that the data should be padded to. | |
| 7 | + * @example | |
| 8 | + * ISO10126.pad(wordArray, 4); | |
| 9 | + */ | |
| 10 | +function pad(data, blockSize) { | |
| 11 | + // Shortcut | |
| 12 | + const blockSizeBytes = blockSize * 4; | |
| 13 | + // Count padding bytes | |
| 14 | + const nPaddingBytes = blockSizeBytes - data.nSigBytes % blockSizeBytes; | |
| 15 | + // Pad | |
| 16 | + data | |
| 17 | + .concat(Word32Array.random(nPaddingBytes - 1)) | |
| 18 | + .concat(new Word32Array([nPaddingBytes << 24], 1)); | |
| 19 | +} | |
| 20 | +/** | |
| 21 | + * Unpads data that had been padded with ISO10126 padding strategy. | |
| 22 | + * | |
| 23 | + * @param {Word32Array} data The data to unpad. | |
| 24 | + * @example | |
| 25 | + * ISO10126.unpad(wordArray); | |
| 26 | + */ | |
| 27 | +function unpad(data) { | |
| 28 | + // Get number of padding bytes from last byte | |
| 29 | + const nPaddingBytes = data.words[(data.nSigBytes - 1) >>> 2] & 0xff; | |
| 30 | + // Remove padding | |
| 31 | + data.nSigBytes -= nPaddingBytes; | |
| 32 | +} | |
| 33 | +export const ISO10126 = { | |
| 34 | + pad, | |
| 35 | + unpad, | |
| 36 | +}; | ... | ... |
| 1 | +import { Word32Array } from "../../../Word32Array"; | |
| 2 | +import { Zero } from "./Zero"; | |
| 3 | +/** | |
| 4 | + * ISO/IEC 9797-1 Padding Method 2. padding strategy | |
| 5 | + * | |
| 6 | + * @param {Word32Array} data The data to pad. | |
| 7 | + * @param {number} blockSize The multiple that the data should be padded to. | |
| 8 | + * @example | |
| 9 | + * ISO97971.pad(wordArray, 4); | |
| 10 | + */ | |
| 11 | +function pad(data, blockSize) { | |
| 12 | + // Add 0x80 byte | |
| 13 | + data.concat(new Word32Array([0x80000000], 1)); | |
| 14 | + // Zero pad the rest | |
| 15 | + Zero.pad(data, blockSize); | |
| 16 | +} | |
| 17 | +/** | |
| 18 | + * Unpads data that had been padded with ISO/IEC 9797-1 Padding Method 2 strategy. | |
| 19 | + * | |
| 20 | + * @param {Word32Array} data The data to unpad. | |
| 21 | + * @example | |
| 22 | + * ISO97971.unpad(wordArray); | |
| 23 | + */ | |
| 24 | +function unpad(data) { | |
| 25 | + // Remove zero padding | |
| 26 | + Zero.unpad(data); | |
| 27 | + // Remove one more byte -- the 0x80 byte | |
| 28 | + data.nSigBytes -= 1; | |
| 29 | +} | |
| 30 | +export const ISO97971 = { | |
| 31 | + pad, | |
| 32 | + unpad, | |
| 33 | +}; | ... | ... |
| 1 | +/** | |
| 2 | + * A noop padding strategy | |
| 3 | + * | |
| 4 | + * @param {Word32Array} data The data to pad. | |
| 5 | + * @param {number} blockSize The multiple that the data should be padded to. | |
| 6 | + * @example | |
| 7 | + * NoPadding.pad(wordArray, 4); | |
| 8 | + */ | |
| 9 | +function pad(data, blockSize) { | |
| 10 | + // NoPadding | |
| 11 | +} | |
| 12 | +/** | |
| 13 | + * Unpads data that had been padded with NoPadding strategy. | |
| 14 | + * | |
| 15 | + * @param {Word32Array} data The data to unpad. | |
| 16 | + * @example | |
| 17 | + * NoPadding.unpad(wordArray); | |
| 18 | + */ | |
| 19 | +function unpad(data) { | |
| 20 | + // NoPadding | |
| 21 | +} | |
| 22 | +export const NoPadding = { | |
| 23 | + pad, | |
| 24 | + unpad, | |
| 25 | +}; | ... | ... |
| 1 | +import { Word32Array } from "../../../Word32Array"; | |
| 2 | +/** | |
| 3 | + * Pads data using the algorithm defined in PKCS #5/7. | |
| 4 | + * | |
| 5 | + * @param {Word32Array} data The data to pad. | |
| 6 | + * @param {number} blockSize The multiple that the data should be padded to. | |
| 7 | + * @example | |
| 8 | + * Pkcs7.pad(wordArray, 4); | |
| 9 | + */ | |
| 10 | +function pad(data, blockSize) { | |
| 11 | + // Shortcut | |
| 12 | + const blockSizeBytes = blockSize * 4; | |
| 13 | + // Count padding bytes | |
| 14 | + const nPaddingBytes = blockSizeBytes - data.nSigBytes % blockSizeBytes; | |
| 15 | + // Create padding word | |
| 16 | + const paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes; | |
| 17 | + // Create padding | |
| 18 | + const paddingWords = []; | |
| 19 | + for (let i = 0; i < nPaddingBytes; i += 4) { | |
| 20 | + paddingWords.push(paddingWord); | |
| 21 | + } | |
| 22 | + const padding = new Word32Array(paddingWords, nPaddingBytes); | |
| 23 | + // Add padding | |
| 24 | + data.concat(padding); | |
| 25 | +} | |
| 26 | +/** | |
| 27 | + * Unpads data that had been padded using the algorithm defined in PKCS #5/7. | |
| 28 | + * | |
| 29 | + * @param {Word32Array} data The data to unpad. | |
| 30 | + * @example | |
| 31 | + * Pkcs7.unpad(wordArray); | |
| 32 | + */ | |
| 33 | +function unpad(data) { | |
| 34 | + // Get number of padding bytes from last byte | |
| 35 | + const nPaddingBytes = data.words[(data.nSigBytes - 1) >>> 2] & 0xff; | |
| 36 | + // Remove padding | |
| 37 | + data.nSigBytes -= nPaddingBytes; | |
| 38 | +} | |
| 39 | +export const Pkcs7 = { | |
| 40 | + pad, | |
| 41 | + unpad, | |
| 42 | +}; | ... | ... |
| 1 | +/** | |
| 2 | + * Pads data with zero padding strategy. | |
| 3 | + * | |
| 4 | + * @param {Word32Array} data The data to pad. | |
| 5 | + * @param {number} blockSize The multiple that the data should be padded to. | |
| 6 | + * @example | |
| 7 | + * Zero.pad(wordArray, 4); | |
| 8 | + */ | |
| 9 | +function pad(data, blockSize) { | |
| 10 | + // Shortcut | |
| 11 | + const blockSizeBytes = blockSize * 4; | |
| 12 | + // Pad | |
| 13 | + data.clamp(); | |
| 14 | + data.nSigBytes += blockSizeBytes - ((data.nSigBytes % blockSizeBytes) || blockSizeBytes); | |
| 15 | +} | |
| 16 | +/** | |
| 17 | + * Unpads data that had been padded with zero padding strategy. | |
| 18 | + * | |
| 19 | + * @param {Word32Array} data The data to unpad. | |
| 20 | + * @example | |
| 21 | + * Zero.unpad(wordArray); | |
| 22 | + */ | |
| 23 | +function unpad(data) { | |
| 24 | + // Shortcut | |
| 25 | + const dataWords = data.words; | |
| 26 | + // Unpad | |
| 27 | + for (let i = data.nSigBytes - 1; i >= 0; i--) { | |
| 28 | + if ((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff) { | |
| 29 | + data.nSigBytes = i + 1; | |
| 30 | + break; | |
| 31 | + } | |
| 32 | + } | |
| 33 | +} | |
| 34 | +export const Zero = { | |
| 35 | + pad, | |
| 36 | + unpad, | |
| 37 | +}; | ... | ... |
| 1 | +export {}; | ... | ... |
| 1 | +export declare function isIE(op?: "<" | "<=" | ">" | ">=" | "=", ver?: number): boolean; | ... | ... |
| 1 | +const ua = typeof navigator !== "undefined" && navigator.userAgent ? navigator.userAgent.toLowerCase() : ""; | |
| 2 | +const IEVer = (() => { | |
| 3 | + let ver = parseInt((/msie (\d+)/.exec(ua) || [])[1], 10); | |
| 4 | + if (isNaN(ver)) { | |
| 5 | + ver = parseInt((/trident\/.*; rv:(\d+)/.exec(ua) || [])[1], 10); | |
| 6 | + if (isNaN(ver)) { | |
| 7 | + return false; | |
| 8 | + } | |
| 9 | + return ver; | |
| 10 | + } | |
| 11 | + return ver; | |
| 12 | +})(); | |
| 13 | +export function isIE(op, ver) { | |
| 14 | + if (IEVer === false) | |
| 15 | + return false; | |
| 16 | + if (!ver) | |
| 17 | + return true; | |
| 18 | + if (op === "<") | |
| 19 | + return IEVer < ver; | |
| 20 | + if (op === "<=") | |
| 21 | + return IEVer <= ver; | |
| 22 | + if (op === ">") | |
| 23 | + return IEVer > ver; | |
| 24 | + if (op === ">=") | |
| 25 | + return IEVer >= ver; | |
| 26 | + if (op === "=") | |
| 27 | + return IEVer === ver; | |
| 28 | + return IEVer === ver; | |
| 29 | +} | ... | ... |
| 1 | +import { Word32Array } from "../Word32Array"; | |
| 2 | +const map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; | |
| 3 | +const reverseMap = []; | |
| 4 | +for (let i = 0; i < map.length; i++) { | |
| 5 | + reverseMap[map.charCodeAt(i)] = i; | |
| 6 | +} | |
| 7 | +export const Base64 = { | |
| 8 | + /** | |
| 9 | + * Converts a word array to a base64 string. | |
| 10 | + * | |
| 11 | + * @param {Word32Array} w An array of 32-bit words. | |
| 12 | + * @return {string} The base64 string. | |
| 13 | + * @example | |
| 14 | + * var hexString = Base64.stringify(new Word32Array([0x293892], 6)); | |
| 15 | + */ | |
| 16 | + stringify(w) { | |
| 17 | + // Shortcuts | |
| 18 | + const words = w.words; | |
| 19 | + const sigBytes = w.nSigBytes; | |
| 20 | + // Clamp excess bits | |
| 21 | + w.clamp(); | |
| 22 | + // Convert | |
| 23 | + const base64Chars = []; | |
| 24 | + for (let i = 0; i < sigBytes; i += 3) { | |
| 25 | + const byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; | |
| 26 | + const byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff; | |
| 27 | + const byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff; | |
| 28 | + const triplet = (byte1 << 16) | (byte2 << 8) | byte3; | |
| 29 | + for (let j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) { | |
| 30 | + base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f)); | |
| 31 | + } | |
| 32 | + } | |
| 33 | + // Add padding | |
| 34 | + const paddingChar = map.charAt(64); | |
| 35 | + if (paddingChar) { | |
| 36 | + while (base64Chars.length % 4) { | |
| 37 | + base64Chars.push(paddingChar); | |
| 38 | + } | |
| 39 | + } | |
| 40 | + return base64Chars.join(""); | |
| 41 | + }, | |
| 42 | + /** | |
| 43 | + * Converts a base64 string to a word array. | |
| 44 | + * | |
| 45 | + * @param {string} base64Str The base64 string. | |
| 46 | + * @return {Word32Array} The word array. | |
| 47 | + * @example | |
| 48 | + * var wordArray = Base64.parse(base64String); | |
| 49 | + */ | |
| 50 | + parse(base64Str) { | |
| 51 | + let base64StrLength = base64Str.length; | |
| 52 | + // Ignore padding | |
| 53 | + const paddingChar = map.charAt(64); | |
| 54 | + if (paddingChar) { | |
| 55 | + const paddingIndex = base64Str.indexOf(paddingChar); | |
| 56 | + if (paddingIndex !== -1) { | |
| 57 | + base64StrLength = paddingIndex; | |
| 58 | + } | |
| 59 | + } | |
| 60 | + const words = []; | |
| 61 | + let nBytes = 0; | |
| 62 | + for (let i = 0; i < base64StrLength; i++) { | |
| 63 | + if (i % 4) { | |
| 64 | + const bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2); | |
| 65 | + const bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2); | |
| 66 | + const bitsCombined = bits1 | bits2; | |
| 67 | + words[nBytes >>> 2] |= bitsCombined << (24 - (nBytes % 4) * 8); | |
| 68 | + nBytes++; | |
| 69 | + } | |
| 70 | + } | |
| 71 | + return new Word32Array(words, nBytes); | |
| 72 | + } | |
| 73 | +}; | ... | ... |
| 1 | +import { Word32Array } from "../Word32Array"; | |
| 2 | +export const Hex = { | |
| 3 | + /** | |
| 4 | + * Converts a word array to a hex string. | |
| 5 | + * | |
| 6 | + * @param {Word32Array} w An array of 32-bit words. | |
| 7 | + * @return {string} The hex string. | |
| 8 | + * @example | |
| 9 | + * var hexString = Hex.stringify(new Word32Array([0x293892], 6)); | |
| 10 | + */ | |
| 11 | + stringify(w) { | |
| 12 | + const nSig = w.nSigBytes; | |
| 13 | + const words = w.words; | |
| 14 | + const hexChars = []; | |
| 15 | + for (let i = 0; i < nSig; i++) { | |
| 16 | + const byte = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; | |
| 17 | + hexChars.push((byte >>> 4).toString(16)); | |
| 18 | + hexChars.push((byte & 0x0f).toString(16)); | |
| 19 | + } | |
| 20 | + return hexChars.join(""); | |
| 21 | + }, | |
| 22 | + /** | |
| 23 | + * Converts a hex string to a word array. | |
| 24 | + * | |
| 25 | + * @param {string} hexStr The hex string. | |
| 26 | + * @return {Word32Array} The word array. | |
| 27 | + * @example | |
| 28 | + * var wordArray = Hex.parse(hexString); | |
| 29 | + */ | |
| 30 | + parse(hexStr) { | |
| 31 | + const Len = hexStr.length; | |
| 32 | + if (Len % 2 !== 0) { | |
| 33 | + throw new Error("Hex string count must be even"); | |
| 34 | + } | |
| 35 | + else if (!/^[a-fA-F0-9]+$/.test(hexStr)) { | |
| 36 | + throw new Error(`Invalid Hex string: ${hexStr}`); | |
| 37 | + } | |
| 38 | + const words = []; | |
| 39 | + for (let i = 0; i < Len; i += 2) { | |
| 40 | + words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4); | |
| 41 | + } | |
| 42 | + return new Word32Array(words, Len / 2); | |
| 43 | + } | |
| 44 | +}; | ... | ... |
| 1 | +import { Word32Array } from "../Word32Array"; | |
| 2 | +export const Latin1 = { | |
| 3 | + /** | |
| 4 | + * Converts a word array to a Latin1 string. | |
| 5 | + * | |
| 6 | + * @param {Word32Array} w An array of 32-bit words. | |
| 7 | + * @return {string} The Latin1 string. | |
| 8 | + * @example | |
| 9 | + * var latin1String = Latin1.stringify(new Word32Array([0x293892], 6)); | |
| 10 | + */ | |
| 11 | + stringify(w) { | |
| 12 | + const nSig = w.nSigBytes; | |
| 13 | + const words = w.words; | |
| 14 | + const latin1Chars = []; | |
| 15 | + for (let i = 0; i < nSig; i++) { | |
| 16 | + const byte = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; | |
| 17 | + latin1Chars.push(String.fromCharCode(byte)); | |
| 18 | + } | |
| 19 | + return latin1Chars.join(""); | |
| 20 | + }, | |
| 21 | + /** | |
| 22 | + * Converts a latin1 string to a word array. | |
| 23 | + * | |
| 24 | + * @param {string} latin1Str The latin1 string. | |
| 25 | + * @return {Word32Array} The word array. | |
| 26 | + * @example | |
| 27 | + * var wordArray = Latin1.parse(latin1Str); | |
| 28 | + */ | |
| 29 | + parse(latin1Str) { | |
| 30 | + const Len = latin1Str.length; | |
| 31 | + const words = []; | |
| 32 | + for (let i = 0; i < Len; i++) { | |
| 33 | + words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8); | |
| 34 | + } | |
| 35 | + return new Word32Array(words, Len); | |
| 36 | + } | |
| 37 | +}; | ... | ... |
| 1 | +import { Word32Array } from "../Word32Array"; | |
| 2 | +/** | |
| 3 | + * UTF-16 BE encoding strategy. | |
| 4 | + */ | |
| 5 | +export const Utf16BE = { | |
| 6 | + /** | |
| 7 | + * Converts a word array to a UTF-16 BE string. | |
| 8 | + * | |
| 9 | + * @param {Word32Array} w An array of 32-bit words. | |
| 10 | + * @return {string} The UTF-16 BE string. | |
| 11 | + * @example | |
| 12 | + * var utf16String = Utf16.stringify(new Word32Array([0x293892])); | |
| 13 | + */ | |
| 14 | + stringify(w) { | |
| 15 | + // Shortcuts | |
| 16 | + const words = w.words; | |
| 17 | + const sigBytes = w.nSigBytes; | |
| 18 | + // Convert | |
| 19 | + const utf16Chars = []; | |
| 20 | + for (let i = 0; i < sigBytes; i += 2) { | |
| 21 | + const codePoint = (words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff; | |
| 22 | + utf16Chars.push(String.fromCharCode(codePoint)); | |
| 23 | + } | |
| 24 | + return utf16Chars.join(""); | |
| 25 | + }, | |
| 26 | + /** | |
| 27 | + * Converts a UTF-16 BE string to a word array. | |
| 28 | + * @param {string} utf16Str The UTF-16 BE string. | |
| 29 | + * @return {Word32Array} The word array. | |
| 30 | + * @example | |
| 31 | + * const wordArray = Utf16.parse(utf16String); | |
| 32 | + */ | |
| 33 | + parse(utf16Str) { | |
| 34 | + // Shortcut | |
| 35 | + const utf16StrLength = utf16Str.length; | |
| 36 | + // Convert | |
| 37 | + const words = []; | |
| 38 | + for (let i = 0; i < utf16StrLength; i++) { | |
| 39 | + words[i >>> 1] |= utf16Str.charCodeAt(i) << (16 - (i % 2) * 16); | |
| 40 | + } | |
| 41 | + return new Word32Array(words, utf16StrLength * 2); | |
| 42 | + } | |
| 43 | +}; | |
| 44 | +function swapEndian(word) { | |
| 45 | + return ((word << 8) & 0xff00ff00) | ((word >>> 8) & 0x00ff00ff); | |
| 46 | +} | |
| 47 | +/** | |
| 48 | + * UTF-16 LE encoding strategy. | |
| 49 | + */ | |
| 50 | +export const Utf16LE = { | |
| 51 | + /** | |
| 52 | + * Converts a word array to a UTF-16 LE string. | |
| 53 | + * | |
| 54 | + * @param {Word32Array} w An array of 32-bit words. | |
| 55 | + * @return {string} The UTF-16 LE string. | |
| 56 | + * @example | |
| 57 | + * var utf16String = Utf16.stringify(new Word32Array([0x293892])); | |
| 58 | + */ | |
| 59 | + stringify(w) { | |
| 60 | + // Shortcuts | |
| 61 | + const words = w.words; | |
| 62 | + const sigBytes = w.nSigBytes; | |
| 63 | + // Convert | |
| 64 | + const utf16Chars = []; | |
| 65 | + for (let i = 0; i < sigBytes; i += 2) { | |
| 66 | + const codePoint = swapEndian((words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff); | |
| 67 | + utf16Chars.push(String.fromCharCode(codePoint)); | |
| 68 | + } | |
| 69 | + return utf16Chars.join(""); | |
| 70 | + }, | |
| 71 | + /** | |
| 72 | + * Converts a UTF-16 LE string to a word array. | |
| 73 | + * @param {string} utf16Str The UTF-16 LE string. | |
| 74 | + * @return {Word32Array} The word array. | |
| 75 | + * @example | |
| 76 | + * const wordArray = Utf16.parse(utf16String); | |
| 77 | + */ | |
| 78 | + parse(utf16Str) { | |
| 79 | + // Shortcut | |
| 80 | + const utf16StrLength = utf16Str.length; | |
| 81 | + // Convert | |
| 82 | + const words = []; | |
| 83 | + for (let i = 0; i < utf16StrLength; i++) { | |
| 84 | + words[i >>> 1] |= swapEndian(utf16Str.charCodeAt(i) << (16 - (i % 2) * 16)); | |
| 85 | + } | |
| 86 | + return new Word32Array(words, utf16StrLength * 2); | |
| 87 | + } | |
| 88 | +}; | |
| 89 | +export const Utf16 = Utf16BE; | ... | ... |
| 1 | +import { Latin1 } from "./Latin1"; | |
| 2 | +export const Utf8 = { | |
| 3 | + /** | |
| 4 | + * Converts a word array to a UTF-8 string. | |
| 5 | + * | |
| 6 | + * @param {Word32Array} w An array of 32-bit words. | |
| 7 | + * @return {string} The UTF-8 string. | |
| 8 | + * @example | |
| 9 | + * var utf8String = Utf8.stringify(new Word32Array([0x293892])); | |
| 10 | + */ | |
| 11 | + stringify(w) { | |
| 12 | + try { | |
| 13 | + return decodeURIComponent(escape(Latin1.stringify(w))); | |
| 14 | + } | |
| 15 | + catch (e) { | |
| 16 | + throw new Error("Malformed UTF-8 data"); | |
| 17 | + } | |
| 18 | + }, | |
| 19 | + /** | |
| 20 | + * Converts a UTF-8 string to a word array. | |
| 21 | + * | |
| 22 | + * @param {string} utf8Str The UTF-8 string. | |
| 23 | + * @return {Word32Array} The word array. | |
| 24 | + * @example | |
| 25 | + * var wordArray = Utf8.parse(utf8Str); | |
| 26 | + */ | |
| 27 | + parse(utf8Str) { | |
| 28 | + return Latin1.parse(unescape(encodeURIComponent(utf8Str))); | |
| 29 | + } | |
| 30 | +}; | ... | ... |
| 1 | +export { random } from "./random"; | |
| 2 | +export { Word32Array } from "./Word32Array"; | |
| 3 | +export { Word64, Word64Array } from "./Word64Array"; | |
| 4 | +export { isIE } from "./browser"; | |
| 5 | +export { Base64 } from "./encoder/Base64"; | |
| 6 | +export { Utf8 } from "./encoder/Utf8"; | |
| 7 | +export { Latin1 } from "./encoder/Latin1"; | |
| 8 | +export { Hex } from "./encoder/Hex"; | |
| 9 | +export { Utf16BE, Utf16LE, Utf16 } from "./encoder/Utf16"; | |
| 10 | +export { OpenSSLKDF } from "./algorithm/cipher/kdf/OpenSSLKDF"; | |
| 11 | +export { PBKDF2 } from "./algorithm/cipher/kdf/module/PBKDF2"; | |
| 12 | +export { EvpKDF } from "./algorithm/cipher/kdf/module/EvpKDF"; | ... | ... |
app/static/content/jscrypto/es6/lib/index.js
0 → 100644
| 1 | +export { random } from "./random"; | |
| 2 | +export { Word32Array } from "./Word32Array"; | |
| 3 | +export { Word64, Word64Array } from "./Word64Array"; | |
| 4 | +export { isIE } from "./browser"; | |
| 5 | +export { Base64 } from "./encoder/Base64"; | |
| 6 | +export { Utf8 } from "./encoder/Utf8"; | |
| 7 | +export { Latin1 } from "./encoder/Latin1"; | |
| 8 | +export { Hex } from "./encoder/Hex"; | |
| 9 | +export { Utf16BE, Utf16LE, Utf16 } from "./encoder/Utf16"; | |
| 10 | +export { OpenSSLKDF } from "./algorithm/cipher/kdf/OpenSSLKDF"; | |
| 11 | +export { PBKDF2 } from "./algorithm/cipher/kdf/module/PBKDF2"; | |
| 12 | +export { EvpKDF } from "./algorithm/cipher/kdf/module/EvpKDF"; | ... | ... |
| 1 | +export declare const random: () => number; | ... | ... |
| 1 | +import { isIE } from "./browser"; | |
| 2 | +function makeRandFunction() { | |
| 3 | + if (typeof window !== "undefined") { | |
| 4 | + const c = window.crypto || window.msCrypto; | |
| 5 | + if (!c) { | |
| 6 | + if (isIE("<", 11)) { | |
| 7 | + console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"); | |
| 8 | + return function rand() { | |
| 9 | + return Math.floor(Math.random() * 512) % 256; | |
| 10 | + }; | |
| 11 | + } | |
| 12 | + throw new Error("Crypto module not found"); | |
| 13 | + } | |
| 14 | + return function rand() { | |
| 15 | + return c.getRandomValues(new Uint32Array(1))[0]; | |
| 16 | + }; | |
| 17 | + } | |
| 18 | + else if (typeof global !== "undefined" && global.crypto) { | |
| 19 | + return function rand() { | |
| 20 | + return global.crypto.randomBytes(4).readInt32LE(); | |
| 21 | + }; | |
| 22 | + } | |
| 23 | + else if (typeof require === "function") { | |
| 24 | + return function rand() { | |
| 25 | + // Prevent webpack to automatically require("crypto"). | |
| 26 | + // eslint-disable-next-line @typescript-eslint/ban-ts-comment | |
| 27 | + // @ts-ignore | |
| 28 | + return __non_webpack_require__("crypto").randomBytes(4).readInt32LE(); | |
| 29 | + }; | |
| 30 | + } | |
| 31 | + throw new Error("Unable to find crypto module"); | |
| 32 | +} | |
| 33 | +export const random = makeRandFunction(); | ... | ... |
app/static/content/jscrypto/es6/lib/type.js
0 → 100644
| 1 | +export {}; | ... | ... |
| 1 | +export { CBC } from "../lib/algorithm/cipher/mode/CBC"; | ... | ... |
app/static/content/jscrypto/es6/mode/CBC.js
0 → 100644
| 1 | +export { CBC } from "../lib/algorithm/cipher/mode/CBC"; | ... | ... |
| 1 | +export { CCM } from "../lib/algorithm/cipher/mode/CCM"; | ... | ... |
app/static/content/jscrypto/es6/mode/CCM.js
0 → 100644
| 1 | +export { CCM } from "../lib/algorithm/cipher/mode/CCM"; | ... | ... |
| 1 | +export { CFB } from "../lib/algorithm/cipher/mode/CFB"; | ... | ... |
app/static/content/jscrypto/es6/mode/CFB.js
0 → 100644
| 1 | +export { CFB } from "../lib/algorithm/cipher/mode/CFB"; | ... | ... |
| 1 | +export { CTR } from "../lib/algorithm/cipher/mode/CTR"; | ... | ... |
app/static/content/jscrypto/es6/mode/CTR.js
0 → 100644
| 1 | +export { CTR } from "../lib/algorithm/cipher/mode/CTR"; | ... | ... |
| 1 | +export { ECB } from "../lib/algorithm/cipher/mode/ECB"; | ... | ... |
app/static/content/jscrypto/es6/mode/ECB.js
0 → 100644
| 1 | +export { ECB } from "../lib/algorithm/cipher/mode/ECB"; | ... | ... |
| 1 | +export { GCM } from "../lib/algorithm/cipher/mode/GCM"; | ... | ... |
app/static/content/jscrypto/es6/mode/GCM.js
0 → 100644
| 1 | +export { GCM } from "../lib/algorithm/cipher/mode/GCM"; | ... | ... |
| 1 | +export { OFB } from "../lib/algorithm/cipher/mode/OFB"; | ... | ... |
app/static/content/jscrypto/es6/mode/OFB.js
0 → 100644
| 1 | +export { OFB } from "../lib/algorithm/cipher/mode/OFB"; | ... | ... |
| 1 | +export { AnsiX923 } from "../lib/algorithm/cipher/pad/AnsiX923"; | ... | ... |
| 1 | +export { AnsiX923 } from "../lib/algorithm/cipher/pad/AnsiX923"; | ... | ... |
| 1 | +export { ISO10126 } from "../lib/algorithm/cipher/pad/ISO10126"; | ... | ... |
| 1 | +export { ISO10126 } from "../lib/algorithm/cipher/pad/ISO10126"; | ... | ... |
| 1 | +export { ISO97971 } from "../lib/algorithm/cipher/pad/ISO97971"; | ... | ... |
| 1 | +export { ISO97971 } from "../lib/algorithm/cipher/pad/ISO97971"; | ... | ... |
| 1 | +export { NoPadding } from "../lib/algorithm/cipher/pad/NoPadding"; | ... | ... |
| 1 | +export { NoPadding } from "../lib/algorithm/cipher/pad/NoPadding"; | ... | ... |
| 1 | +export { Pkcs7 } from "../lib/algorithm/cipher/pad/Pkcs7"; | ... | ... |
app/static/content/jscrypto/es6/pad/Pkcs7.js
0 → 100644
| 1 | +export { Pkcs7 } from "../lib/algorithm/cipher/pad/Pkcs7"; | ... | ... |
| 1 | +export { Zero } from "../lib/algorithm/cipher/pad/Zero"; | ... | ... |
app/static/content/jscrypto/es6/pad/Zero.js
0 → 100644
| 1 | +export { Zero } from "../lib/algorithm/cipher/pad/Zero"; | ... | ... |
| 1 | +export { OpenSSLFormatter } from "../lib/algorithm/cipher/formatter/OpenSSLFormatter"; | ... | ... |
| 1 | +!function(t,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else if("object"==typeof exports)exports.JsCrypto=r();else{var n=r();for(var e in t.JsCrypto=t.JsCrypto||{},t.JsCrypto.formatter=t.JsCrypto=t.JsCrypto||{},t.JsCrypto.formatter,n)t.JsCrypto=t.JsCrypto||{},t.JsCrypto.formatter[e]=n[e]}}(this,(function(){return function(){"use strict";var t={d:function(r,n){for(var e in n)t.o(n,e)&&!t.o(r,e)&&Object.defineProperty(r,e,{enumerable:!0,get:n[e]})}};t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),t.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},t.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"t",{value:!0})};var r={};t.r(r),t.d(r,{OpenSSLFormatter:function(){return y}});var n,e=function(){function t(t){this.formatter=y,t&&(this.cipherText=t.cipherText,this.key=t.key,this.iv=t.iv,this.salt=t.salt,this.Algorithm=t.Algorithm,this.mode=t.mode,this.padding=t.padding,this.blockSize=t.blockSize,this.formatter=t.formatter||y)}return t.prototype.toString=function(t){return(t||this.formatter).stringify(this)},t}(),i=function(t){for(var r=t.nSigBytes,n=t.words,e=[],i=0;i<r;i++){var o=n[i>>>2]>>>24-i%4*8&255;e.push((o>>>4).toString(16)),e.push((15&o).toString(16))}return e.join("")},o="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",f=(n=parseInt((/msie (\d+)/.exec(o)||[])[1],10),isNaN(n)?(n=parseInt((/trident\/.*; rv:(\d+)/.exec(o)||[])[1],10),!isNaN(n)&&n):n);for(var a=function(){if("undefined"!=typeof window){var r=window.crypto||window.msCrypto;if(!r){if(function(t,r){return!1!==f&&(!r||("<"===t?f<r:"<="===t?f<=r:">"===t?f>r:">="===t?f>=r:f===r))}("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return r.getRandomValues(new Uint32Array(1))[0]}}return void 0!==t.g&&t.g.crypto?function(){return t.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}(),u=function(){function t(r,n){if(Array.isArray(r)||!r)return this.i=Array.isArray(r)?r:[],void(this.u="number"==typeof n?n:4*this.i.length);if(r instanceof t)return this.i=r.words.slice(),void(this.u=r.nSigBytes);var e;try{r instanceof ArrayBuffer?e=new Uint8Array(r):(r instanceof Uint8Array||r instanceof Int8Array||r instanceof Uint8ClampedArray||r instanceof Int16Array||r instanceof Uint16Array||r instanceof Int32Array||r instanceof Uint32Array||r instanceof Float32Array||r instanceof Float64Array)&&(e=new Uint8Array(r.buffer,r.byteOffset,r.byteLength))}catch(t){throw new Error("Invalid argument")}if(!e)throw new Error("Invalid argument");for(var i=e.byteLength,o=[],f=0;f<i;f++)o[f>>>2]|=e[f]<<24-f%4*8;this.i=o,this.u=i}return Object.defineProperty(t.prototype,"nSigBytes",{get:function(){return this.u},set:function(t){this.u=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"words",{get:function(){return this.i},enumerable:!1,configurable:!0}),t.prototype.toString=function(t){return t?t.stringify(this):i(this)},t.prototype.toUint8Array=function(){for(var t=this.i,r=this.u,n=new Uint8Array(r),e=0;e<r;e++)n[e]=t[e>>>2]>>>24-e%4*8&255;return n},t.prototype.concat=function(t){var r=t.words.slice(),n=t.nSigBytes;if(this.clamp(),this.u%4)for(var e=0;e<n;e++){var i=r[e>>>2]>>>24-e%4*8&255;this.i[this.u+e>>>2]|=i<<24-(this.u+e)%4*8}else for(e=0;e<n;e+=4)this.i[this.u+e>>>2]=r[e>>>2];return this.u+=n,this},t.prototype.clamp=function(){var t=this.u;this.i[t>>>2]&=4294967295<<32-t%4*8,this.i.length=Math.ceil(t/4)},t.prototype.clone=function(){return new t(this.i.slice(),this.u)},t.random=function(r){for(var n=[],e=0;e<r;e+=4)n.push(a());return new t(n,r)},t}(),s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",c=[],h=0;h<s.length;h++)c[s.charCodeAt(h)]=h;var v={stringify:function(t){var r=t.words,n=t.nSigBytes;t.clamp();for(var e=[],i=0;i<n;i+=3)for(var o=(r[i>>>2]>>>24-i%4*8&255)<<16|(r[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|r[i+2>>>2]>>>24-(i+2)%4*8&255,f=0;f<4&&i+.75*f<n;f++)e.push(s.charAt(o>>>6*(3-f)&63));var a=s.charAt(64);if(a)for(;e.length%4;)e.push(a);return e.join("")},parse:function(t){var r=t.length,n=s.charAt(64);if(n){var e=t.indexOf(n);-1!==e&&(r=e)}for(var i=[],o=0,f=0;f<r;f++)if(f%4){var a=c[t.charCodeAt(f-1)]<<f%4*2|c[t.charCodeAt(f)]>>>6-f%4*2;i[o>>>2]|=a<<24-o%4*8,o++}return new u(i,o)}},y={stringify:function(t){var r=t.cipherText,n=t.salt;return r?n?new u([1398893684,1701076831]).concat(n).concat(r).toString(v):r.toString(v):""},parse:function(t){var r,n=v.parse(t),i=n.words;return 1398893684===i[0]&&1701076831===i[1]&&(r=new u(i.slice(2,4)),i.splice(0,4),n.nSigBytes-=16),new e({cipherText:n,salt:r})}};return r}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/index.d.ts
0 → 100644
| 1 | +export { Word32Array, Word64Array, Word64, Base64, Hex, Latin1, Utf8, Utf16, Utf16BE, Utf16LE, OpenSSLKDF, EvpKDF, PBKDF2, } from "./lib/index"; | |
| 2 | +export { SerializableCipher } from "./lib/algorithm/cipher/SerializableCipher"; | |
| 3 | +export { PasswordBasedCipher } from "./lib/algorithm/cipher/PasswordBasedCipher"; | |
| 4 | +export { CipherParams } from "./lib/algorithm/cipher/CipherParams"; | |
| 5 | +export { Hmac } from "./Hmac"; | |
| 6 | +export { HmacMD5 } from "./HmacMD5"; | |
| 7 | +export { HmacSHA1 } from "./HmacSHA1"; | |
| 8 | +export { HmacSHA224 } from "./HmacSHA224"; | |
| 9 | +export { HmacSHA256 } from "./HmacSHA256"; | |
| 10 | +export { HmacSHA384 } from "./HmacSHA384"; | |
| 11 | +export { HmacSHA512 } from "./HmacSHA512"; | |
| 12 | +export { GMAC } from "./GMAC"; | |
| 13 | +export { CBCMAC } from "./CBCMAC"; | |
| 14 | +export { MD5 } from "./MD5"; | |
| 15 | +export { SHA1 } from "./SHA1"; | |
| 16 | +export { SHA224 } from "./SHA224"; | |
| 17 | +export { SHA256 } from "./SHA256"; | |
| 18 | +export { SHA384 } from "./SHA384"; | |
| 19 | +export { SHA512 } from "./SHA512"; | |
| 20 | +export { SHA3 } from "./SHA3"; | |
| 21 | +export { AES } from "./AES"; | |
| 22 | +export { DES } from "./DES"; | |
| 23 | +export { DES3 } from "./DES3"; | |
| 24 | +export { RIPEMD160 } from "./RIPEMD160"; | |
| 25 | +export { Rabbit } from "./Rabbit"; | |
| 26 | +export { RC4 } from "./RC4"; | |
| 27 | +export { RC4Drop } from "./RC4Drop"; | |
| 28 | +import { CBC } from "./mode/CBC"; | |
| 29 | +import { CFB } from "./mode/CFB"; | |
| 30 | +import { CTR } from "./mode/CTR"; | |
| 31 | +import { ECB } from "./mode/ECB"; | |
| 32 | +import { OFB } from "./mode/OFB"; | |
| 33 | +import { GCM } from "./mode/GCM"; | |
| 34 | +import { CCM } from "./mode/CCM"; | |
| 35 | +export declare const mode: { | |
| 36 | + CBC: typeof CBC; | |
| 37 | + CFB: typeof CFB; | |
| 38 | + CTR: typeof CTR; | |
| 39 | + ECB: typeof ECB; | |
| 40 | + OFB: typeof OFB; | |
| 41 | + GCM: typeof GCM; | |
| 42 | + CCM: typeof CCM; | |
| 43 | +}; | |
| 44 | +export declare const pad: { | |
| 45 | + AnsiX923: import("./lib/algorithm/cipher/pad/type").Pad; | |
| 46 | + ISO10126: import("./lib/algorithm/cipher/pad/type").Pad; | |
| 47 | + ISO97971: import("./lib/algorithm/cipher/pad/type").Pad; | |
| 48 | + Pkcs7: import("./lib/algorithm/cipher/pad/type").Pad; | |
| 49 | + NoPadding: import("./lib/algorithm/cipher/pad/type").Pad; | |
| 50 | + Zero: import("./lib/algorithm/cipher/pad/type").Pad; | |
| 51 | +}; | |
| 52 | +export declare const formatter: { | |
| 53 | + OpenSSLFormatter: import("./lib/algorithm/cipher/formatter/type").Formatter; | |
| 54 | +}; | ... | ... |
app/static/content/jscrypto/index.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var r=t();for(var i in n.JsCrypto=n.JsCrypto||{},r)n.JsCrypto[i]=r[i]}}(this,(function(){return function(){"use strict";var n={9691:function(n,t,r){r.d(t,{AES:function(){return _}});var i,e=r(9456),o=r(787),u=r(5693),f=r(9109),c=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),s=function(){return(s=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},a=[],h=[],v=[],w=[],l=[],b=[],d=[],y=[],p=[],O=[];!function(){for(var n=[],t=0;t<256;t++)n[t]=t<128?t<<1:t<<1^283;var r=0,i=0;for(t=0;t<256;t++){var e=i^i<<1^i<<2^i<<3^i<<4;e=e>>>8^255&e^99,a[r]=e,h[e]=r;var o=n[r],u=n[o],f=n[u],c=257*n[e]^16843008*e;v[r]=c<<24|c>>>8,w[r]=c<<16|c>>>16,l[r]=c<<8|c>>>24,b[r]=c,c=16843009*f^65537*u^257*o^16843008*r,d[e]=c<<24|c>>>8,y[e]=c<<16|c>>>16,p[e]=c<<8|c>>>24,O[e]=c,r?(r=o^n[n[n[f^o]]],i^=n[n[i]]):r=i=1}}();var j=[0,1,2,4,8,16,32,64,128,27,54],_=function(n){function t(t){var r=n.call(this,t)||this;return r.u=0,r.h=[],r.v=[],r.O=t,r.A(),r}return c(t,n),t.prototype.A=function(){var n;if(!this.u||this.k!==this.H){for(var t=this.k=this.H,r=t.words,i=t.nSigBytes/4,e=4*((this.u=i+6)+1),o=this.h=[],u=0;u<e;u++)u<i?o[u]=r[u]:(n=o[u-1],u%i?i>6&&u%i==4&&(n=a[n>>>24]<<24|a[n>>>16&255]<<16|a[n>>>8&255]<<8|a[255&n]):(n=a[(n=n<<8|n>>>24)>>>24]<<24|a[n>>>16&255]<<16|a[n>>>8&255]<<8|a[255&n],n^=j[u/i|0]<<24),o[u]=o[u-i]^n);this.v=[];for(var f=0;f<e;f++){u=e-f;n=f%4?o[u]:o[u-4],this.v[f]=f<4||u<=4?n:d[a[n>>>24]]^y[a[n>>>16&255]]^p[a[n>>>8&255]]^O[a[255&n]]}}},t.prototype.encryptBlock=function(n,t){this.B(n,t,this.h,v,w,l,b,a)},t.prototype.decryptBlock=function(n,t){var r=n[t+1];n[t+1]=n[t+3],n[t+3]=r,this.B(n,t,this.v,d,y,p,O,h),r=n[t+1],n[t+1]=n[t+3],n[t+3]=r},t.prototype.B=function(n,t,r,i,e,o,u,f){for(var c=this.u,s=n[t]^r[0],a=n[t+1]^r[1],h=n[t+2]^r[2],v=n[t+3]^r[3],w=4,l=1;l<c;l++){var b=i[s>>>24]^e[a>>>16&255]^o[h>>>8&255]^u[255&v]^r[w++],d=i[a>>>24]^e[h>>>16&255]^o[v>>>8&255]^u[255&s]^r[w++],y=i[h>>>24]^e[v>>>16&255]^o[s>>>8&255]^u[255&a]^r[w++],p=i[v>>>24]^e[s>>>16&255]^o[a>>>8&255]^u[255&h]^r[w++];s=b,a=d,h=y,v=p}var O=(f[s>>>24]<<24|f[a>>>16&255]<<16|f[h>>>8&255]<<8|f[255&v])^r[w++],j=(f[a>>>24]<<24|f[h>>>16&255]<<16|f[v>>>8&255]<<8|f[255&s])^r[w++],_=(f[h>>>24]<<24|f[v>>>16&255]<<16|f[s>>>8&255]<<8|f[255&a])^r[w++],m=(f[v>>>24]<<24|f[s>>>16&255]<<16|f[a>>>8&255]<<8|f[255&h])^r[w++];n[t]=O,n[t+1]=j,n[t+2]=_,n[t+3]=m},t.createEncryptor=function(n,r){return new t(s(s({},r=void 0===r?{}:r),{key:n,transformMode:e.t.ENC_TRANSFORM_MODE}))},t.createDecryptor=function(n,r){return new t(s(s({},r=void 0===r?{}:r),{key:n,transformMode:e.t.DEC_TRANSFORM_MODE}))},t.encrypt=function(n,r,i){if("string"==typeof r)return u.E.encrypt(t,n,r,i);if(r.nSigBytes%4!=0)throw new Error("Key size must be multiple of 32bit/4byte/1word");return f.D.encrypt(t,n,r,i)},t.decrypt=function(n,r,i){if("string"==typeof r)return u.E.decrypt(t,n,r,i);if(r.nSigBytes%4!=0)throw new Error("Key size must be multiple of 32bit/4byte/1word");return f.D.decrypt(t,n,r,i)},t.keySize=8,t}(o.G)},3967:function(n,t,r){r.d(t,{CBCMAC:function(){return f}});var i=r(4768),e=r(3354),o=r(9691),u=r(3664);function f(n,t,r,f,c,s){var a=s&&s.Cipher?s.Cipher:o.AES,h="string"==typeof r?i.d.parse(r):r,v=f||new e.e([0,0]),w="string"==typeof t?i.d.parse(t):t,l="string"==typeof n?i.d.parse(n):n,b=c||16;return u.K.mac(a,h,v,w,l,b)}},9910:function(n,t,r){r.d(t,{DES:function(){return b}});var i,e=r(787),o=r(9456),u=r(5693),f=r(9109),c=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),s=function(){return(s=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},a=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],h=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],v=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],w=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],l=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],b=function(n){function t(t){var r=n.call(this,t)||this;return r.N=2,r.I=[],r.U=[],r.L=0,r.F=0,r.O=t,r.A(),r}return c(t,n),t.prototype.A=function(){for(var n=this.H.words,t=[],r=0;r<56;r++){var i=a[r]-1;t[r]=n[i>>>5]>>>31-i%32&1}for(var e=this.I=[],o=0;o<16;o++){var u=e[o]=[],f=v[o];for(r=0;r<24;r++)u[r/6|0]|=t[(h[r]-1+f)%28]<<31-r%6,u[4+(r/6|0)]|=t[28+(h[r+24]-1+f)%28]<<31-r%6;u[0]=u[0]<<1|u[0]>>>31;for(r=1;r<7;r++)u[r]=u[r]>>>4*(r-1)+3;u[7]=u[7]<<5|u[7]>>>27}this.U=[];for(r=0;r<16;r++)this.U[r]=e[15-r]},t.prototype.encryptBlock=function(n,t){this.R(n,t,this.I)},t.prototype.decryptBlock=function(n,t){this.R(n,t,this.U)},t.prototype.R=function(n,t,r){this.L=n[t],this.F=n[t+1],this.X(4,252645135),this.X(16,65535),this.Z(2,858993459),this.Z(8,16711935),this.X(1,1431655765);for(var i=0;i<16;i++){for(var e=r[i],o=this.L,u=this.F,f=0,c=0;c<8;c++){var s=(u^e[c])&l[c];f|=w[c][s>>>0]}this.L=u,this.F=o^f}var a=this.L;this.L=this.F,this.F=a,this.X(1,1431655765),this.Z(8,16711935),this.Z(2,858993459),this.X(16,65535),this.X(4,252645135),n[t]=this.L,n[t+1]=this.F},t.prototype.X=function(n,t){var r=(this.L>>>n^this.F)&t;this.F^=r,this.L^=r<<n},t.prototype.Z=function(n,t){var r=(this.F>>>n^this.L)&t;this.L^=r,this.F^=r<<n},t.createEncryptor=function(n,r){return new t(s(s({},r=void 0===r?{}:r),{key:n,transformMode:o.t.ENC_TRANSFORM_MODE}))},t.createDecryptor=function(n,r){return new t(s(s({},r=void 0===r?{}:r),{key:n,transformMode:o.t.DEC_TRANSFORM_MODE}))},t.encrypt=function(n,r,i){return"string"==typeof r?u.E.encrypt(t,n,r,i):f.D.encrypt(t,n,r,i)},t.decrypt=function(n,r,i){return"string"==typeof r?u.E.decrypt(t,n,r,i):f.D.decrypt(t,n,r,i)},t.keySize=2,t.ivSize=2,t}(e.G)},6739:function(n,t,r){r.d(t,{DES3:function(){return v}});var i,e=r(9109),o=r(787),u=r(9456),f=r(9910),c=r(3354),s=r(5693),a=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),h=function(){return(h=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},v=function(n){function t(t){var r=n.call(this,t)||this;r.N=2,r.O=t;var i=r.J();return r.Y=i[0],r.$=i[1],r.nn=i[2],r}return a(t,n),t.prototype.J=function(){var n=this.H.words;if(2!==n.length&&4!==n.length&&n.length<6)throw new Error("Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.");var t=n.slice(0,2),r=n.length<4?n.slice(0,2):n.slice(2,4),i=n.length<6?n.slice(0,2):n.slice(4,6);return[f.DES.createEncryptor(new c.e(t)),f.DES.createEncryptor(new c.e(r)),f.DES.createEncryptor(new c.e(i))]},t.prototype.A=function(){var n=this.J();this.Y=n[0],this.$=n[1],this.nn=n[2]},t.prototype.encryptBlock=function(n,t){this.Y.encryptBlock(n,t),this.$.decryptBlock(n,t),this.nn.encryptBlock(n,t)},t.prototype.decryptBlock=function(n,t){this.nn.decryptBlock(n,t),this.$.encryptBlock(n,t),this.Y.decryptBlock(n,t)},t.createEncryptor=function(n,r){return new t(h(h({},r=void 0===r?{}:r),{key:n,transformMode:u.t.ENC_TRANSFORM_MODE}))},t.createDecryptor=function(n,r){return new t(h(h({},r=void 0===r?{}:r),{key:n,transformMode:u.t.DEC_TRANSFORM_MODE}))},t.encrypt=function(n,r,i){return"string"==typeof r?s.E.encrypt(t,n,r,i):e.D.encrypt(t,n,r,i)},t.decrypt=function(n,r,i){return"string"==typeof r?s.E.decrypt(t,n,r,i):e.D.decrypt(t,n,r,i)},t.keySize=6,t.ivSize=2,t}(o.G)},7753:function(n,t,r){r.d(t,{GMAC:function(){return f}});var i=r(4768),e=r(3354),o=r(9691),u=r(5607);function f(n,t,r,f,c){var s="string"==typeof n?i.d.parse(n):n,a=r||new e.e([0,0,0,0]),h=c&&c.Cipher?c.Cipher:o.AES,v="string"==typeof t?i.d.parse(t):t,w=f||16;return u.V.mac(h,v,a,s,void 0,w)}},6367:function(n,t,r){r.d(t,{Hmac:function(){return e}});var i=r(4768),e=function(){function n(n,t){this.tn=n,"string"==typeof t&&(t=i.d.parse(t));var r=n.blockSize,e=4*r;t.nSigBytes>e&&(t=n.finalize(t)),t.clamp();for(var o=this.rn=t.clone(),u=this.en=t.clone(),f=o.words,c=u.words,s=0;s<r;s++)f[s]^=1549556828,c[s]^=909522486;u.nSigBytes=e,o.nSigBytes=e,this.reset()}return n.prototype.reset=function(){this.tn.reset(),this.tn.update(this.en)},n.prototype.update=function(n){return this.tn.update(n),this},n.prototype.finalize=function(n){var t=this.tn.finalize(n);return this.tn.reset(),this.tn.finalize(this.rn.clone().concat(t))},n}()},3027:function(n,t,r){r.d(t,{HmacMD5:function(){return o}});var i=r(6367),e=r(670);function o(n,t){return new i.Hmac(new e.MD5,t).finalize(n)}},149:function(n,t,r){r.d(t,{HmacSHA1:function(){return o}});var i=r(6367),e=r(3173);function o(n,t){return new i.Hmac(new e.SHA1,t).finalize(n)}},4105:function(n,t,r){r.d(t,{HmacSHA224:function(){return o}});var i=r(6367),e=r(766);function o(n,t){return new i.Hmac(new e.SHA224,t).finalize(n)}},980:function(n,t,r){r.d(t,{HmacSHA256:function(){return o}});var i=r(6367),e=r(5561);function o(n,t){return new i.Hmac(new e.SHA256,t).finalize(n)}},5838:function(n,t,r){r.d(t,{HmacSHA384:function(){return o}});var i=r(6367),e=r(6324);function o(n,t){return new i.Hmac(new e.SHA384,t).finalize(n)}},9902:function(n,t,r){r.d(t,{HmacSHA512:function(){return o}});var i=r(6367),e=r(7491);function o(n,t){return new i.Hmac(new e.SHA512,t).finalize(n)}},670:function(n,t,r){r.d(t,{MD5:function(){return v}});var i,e=r(3354),o=r(1868),u=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),f=[];function c(n,t,r,i,e,o,u){var f=n+(t&r|~t&i)+e+u;return(f<<o|f>>>32-o)+t}function s(n,t,r,i,e,o,u){var f=n+(t&i|r&~i)+e+u;return(f<<o|f>>>32-o)+t}function a(n,t,r,i,e,o,u){var f=n+(t^r^i)+e+u;return(f<<o|f>>>32-o)+t}function h(n,t,r,i,e,o,u){var f=n+(r^(t|~i))+e+u;return(f<<o|f>>>32-o)+t}!function(){for(var n=0;n<64;n++)f[n]=4294967296*Math.abs(Math.sin(n+1))|0}();var v=function(n){function t(t){var r=n.call(this,t)||this;return r.on=new e.e([1732584193,4023233417,2562383102,271733878]),t&&void 0!==t.hash&&(r.on=t.hash.clone()),r}return u(t,n),t.prototype.A=function(){this.on=new e.e([1732584193,4023233417,2562383102,271733878])},t.prototype.un=function(n,t){for(var r=0;r<16;r++){var i=t+r,e=n[i];n[i]=16711935&(e<<8|e>>>24)|4278255360&(e<<24|e>>>8)}var o=this.on.words,u=n[t],v=n[t+1],w=n[t+2],l=n[t+3],b=n[t+4],d=n[t+5],y=n[t+6],p=n[t+7],O=n[t+8],j=n[t+9],_=n[t+10],m=n[t+11],A=n[t+12],g=n[t+13],E=n[t+14],S=n[t+15],M=o[0],k=o[1],H=o[2],C=o[3];M=c(M,k,H,C,u,7,f[0]),C=c(C,M,k,H,v,12,f[1]),H=c(H,C,M,k,w,17,f[2]),k=c(k,H,C,M,l,22,f[3]),M=c(M,k,H,C,b,7,f[4]),C=c(C,M,k,H,d,12,f[5]),H=c(H,C,M,k,y,17,f[6]),k=c(k,H,C,M,p,22,f[7]),M=c(M,k,H,C,O,7,f[8]),C=c(C,M,k,H,j,12,f[9]),H=c(H,C,M,k,_,17,f[10]),k=c(k,H,C,M,m,22,f[11]),M=c(M,k,H,C,A,7,f[12]),C=c(C,M,k,H,g,12,f[13]),H=c(H,C,M,k,E,17,f[14]),M=s(M,k=c(k,H,C,M,S,22,f[15]),H,C,v,5,f[16]),C=s(C,M,k,H,y,9,f[17]),H=s(H,C,M,k,m,14,f[18]),k=s(k,H,C,M,u,20,f[19]),M=s(M,k,H,C,d,5,f[20]),C=s(C,M,k,H,_,9,f[21]),H=s(H,C,M,k,S,14,f[22]),k=s(k,H,C,M,b,20,f[23]),M=s(M,k,H,C,j,5,f[24]),C=s(C,M,k,H,E,9,f[25]),H=s(H,C,M,k,l,14,f[26]),k=s(k,H,C,M,O,20,f[27]),M=s(M,k,H,C,g,5,f[28]),C=s(C,M,k,H,w,9,f[29]),H=s(H,C,M,k,p,14,f[30]),M=a(M,k=s(k,H,C,M,A,20,f[31]),H,C,d,4,f[32]),C=a(C,M,k,H,O,11,f[33]),H=a(H,C,M,k,m,16,f[34]),k=a(k,H,C,M,E,23,f[35]),M=a(M,k,H,C,v,4,f[36]),C=a(C,M,k,H,b,11,f[37]),H=a(H,C,M,k,p,16,f[38]),k=a(k,H,C,M,_,23,f[39]),M=a(M,k,H,C,g,4,f[40]),C=a(C,M,k,H,u,11,f[41]),H=a(H,C,M,k,l,16,f[42]),k=a(k,H,C,M,y,23,f[43]),M=a(M,k,H,C,j,4,f[44]),C=a(C,M,k,H,A,11,f[45]),H=a(H,C,M,k,S,16,f[46]),M=h(M,k=a(k,H,C,M,w,23,f[47]),H,C,u,6,f[48]),C=h(C,M,k,H,p,10,f[49]),H=h(H,C,M,k,E,15,f[50]),k=h(k,H,C,M,d,21,f[51]),M=h(M,k,H,C,A,6,f[52]),C=h(C,M,k,H,l,10,f[53]),H=h(H,C,M,k,_,15,f[54]),k=h(k,H,C,M,v,21,f[55]),M=h(M,k,H,C,O,6,f[56]),C=h(C,M,k,H,S,10,f[57]),H=h(H,C,M,k,y,15,f[58]),k=h(k,H,C,M,g,21,f[59]),M=h(M,k,H,C,b,6,f[60]),C=h(C,M,k,H,m,10,f[61]),H=h(H,C,M,k,w,15,f[62]),k=h(k,H,C,M,j,21,f[63]),o[0]=o[0]+M|0,o[1]=o[1]+k|0,o[2]=o[2]+H|0,o[3]=o[3]+C|0},t.prototype.fn=function(){var n=this.cn,t=n.words,r=8*this.sn,i=8*n.nSigBytes;t[i>>>5]|=128<<24-i%32;var e=Math.floor(r/4294967296),o=r;t[15+(i+64>>>9<<4)]=16711935&(e<<8|e>>>24)|4278255360&(e<<24|e>>>8),t[14+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),n.nSigBytes=4*(t.length+1),this.an();for(var u=this.on,f=u.words,c=0;c<4;c++){var s=f[c];f[c]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}return u},t.prototype.clone=function(){return new t({hash:this.on,blockSize:this.N,data:this.cn,nBytes:this.sn})},t.hash=function(n){return(new t).finalize(n)},t}(o.P)},4615:function(n,t,r){r.d(t,{RC4:function(){return s}});var i,e=r(30),o=r(5693),u=r(9109),f=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),c=function(){return(c=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},s=function(n){function t(t){var r=n.call(this,t)||this;return r.S=[],r.i=0,r.j=0,r.O=t,r.A(),r}return f(t,n),t.prototype.A=function(){var n=this.H,t=n.words,r=n.nSigBytes;this.S=[];for(var i=0;i<256;i++)this.S[i]=i;i=0;for(var e=0;i<256;i++){var o=i%r,u=t[o>>>2]>>>24-o%4*8&255;e=(e+this.S[i]+u)%256;var f=this.S[i];this.S[i]=this.S[e],this.S[e]=f}this.i=this.j=0},t.prototype.un=function(n,t){n[t]^=this.generateKeyStreamWord()},t.prototype.generateKeyStreamWord=function(){for(var n=this.S,t=this.i,r=this.j,i=0,e=0;e<4;e++){r=(r+n[t=(t+1)%256])%256;var o=n[t];n[t]=n[r],n[r]=o,i|=n[(n[t]+n[r])%256]<<24-8*e}return this.i=t,this.j=r,i},t.createEncryptor=function(n,r){return new t(c(c({},r=void 0===r?{}:r),{key:n}))},t.createDecryptor=function(n,r){return new t(c(c({},r=void 0===r?{}:r),{key:n}))},t.encrypt=function(n,r,i){return"string"==typeof r?o.E.encrypt(t,n,r,i):u.D.encrypt(t,n,r,i)},t.decrypt=function(n,r,i){return"string"==typeof r?o.E.decrypt(t,n,r,i):u.D.decrypt(t,n,r,i)},t.ivSize=0,t.keySize=8,t}(e.q)},9639:function(n,t,r){r.d(t,{RC4Drop:function(){return s}});var i,e=r(5693),o=r(9109),u=r(4615),f=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),c=function(){return(c=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},s=function(n){function t(t){var r=n.call(this,t)||this;return r.drop=192,r.O=t,t&&"number"==typeof t.drop&&(r.drop=t.drop),r.A(),r}return f(t,n),t.prototype.A=function(){n.prototype.A.call(this);for(var t=this.drop;t>0;t--)this.generateKeyStreamWord()},t.createEncryptor=function(n,r){return new t(c(c({},r=void 0===r?{}:r),{key:n}))},t.createDecryptor=function(n,r){return new t(c(c({},r=void 0===r?{}:r),{key:n}))},t.encrypt=function(n,r,i){return"string"==typeof r?e.E.encrypt(t,n,r,i):o.D.encrypt(t,n,r,i)},t.decrypt=function(n,r,i){return"string"==typeof r?e.E.decrypt(t,n,r,i):o.D.decrypt(t,n,r,i)},t}(u.RC4)},7104:function(n,t,r){r.d(t,{RIPEMD160:function(){return O}});var i,e=r(1868),o=r(3354),u=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),f=new o.e([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),c=new o.e([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),s=new o.e([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),a=new o.e([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),h=new o.e([0,1518500249,1859775393,2400959708,2840853838]),v=new o.e([1352829926,1548603684,1836072691,2053994217,0]);function w(n,t,r){return n^t^r}function l(n,t,r){return n&t|~n&r}function b(n,t,r){return(n|~t)^r}function d(n,t,r){return n&r|t&~r}function y(n,t,r){return n^(t|~r)}function p(n,t){return n<<t|n>>>32-t}var O=function(n){function t(t){var r=n.call(this,t)||this;return r.on=new o.e([1732584193,4023233417,2562383102,271733878,3285377520]),r.O=t,t&&void 0!==t.hash&&(r.on=t.hash.clone()),r}return u(t,n),t.prototype.A=function(){this.on=new o.e([1732584193,4023233417,2562383102,271733878,3285377520])},t.prototype.un=function(n,t){for(var r=0;r<16;r++){var i=t+r,e=n[i];n[i]=16711935&(e<<8|e>>>24)|4278255360&(e<<24|e>>>8)}var o,u,O,j,_,m,A,g,E,S,M,k=this.on.words,H=h.words,C=v.words,B=f.words,N=c.words,I=s.words,z=a.words;m=o=k[0],A=u=k[1],g=O=k[2],E=j=k[3],S=_=k[4];for(r=0;r<80;r+=1)M=o+n[t+B[r]]|0,M+=r<16?w(u,O,j)+H[0]:r<32?l(u,O,j)+H[1]:r<48?b(u,O,j)+H[2]:r<64?d(u,O,j)+H[3]:y(u,O,j)+H[4],M=(M=p(M|=0,I[r]))+_|0,o=_,_=j,j=p(O,10),O=u,u=M,M=m+n[t+N[r]]|0,M+=r<16?y(A,g,E)+C[0]:r<32?d(A,g,E)+C[1]:r<48?b(A,g,E)+C[2]:r<64?l(A,g,E)+C[3]:w(A,g,E)+C[4],M=(M=p(M|=0,z[r]))+S|0,m=S,S=E,E=p(g,10),g=A,A=M;M=k[1]+O+E|0,k[1]=k[2]+j+S|0,k[2]=k[3]+_+m|0,k[3]=k[4]+o+A|0,k[4]=k[0]+u+g|0,k[0]=M},t.prototype.fn=function(){var n=this.cn,t=n.words,r=8*this.sn,i=8*n.nSigBytes;t[i>>>5]|=128<<24-i%32,t[14+(i+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),n.nSigBytes=4*(t.length+1),this.an();for(var e=this.on,o=e.words,u=0;u<5;u++){var f=o[u];o[u]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8)}return e},t.prototype.clone=function(){return new t({hash:this.on,blockSize:this.N,data:this.cn,nBytes:this.sn})},t.hash=function(n,r){return new t(r).finalize(n)},t}(e.P)},5187:function(n,t,r){r.d(t,{Rabbit:function(){return s}});var i,e=r(30),o=r(5693),u=r(9109),f=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),c=function(){return(c=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},s=function(n){function t(t){var r=n.call(this,t)||this;return r.N=4,r.S=[],r.C=[],r.G=[],r.hn=[],r.vn=[],r.wn=0,r.O=t,r.A(),r}return f(t,n),t.prototype.A=function(){for(var n=this.H.words,t=this.ln,r=0;r<4;r++)n[r]=16711935&(n[r]<<8|n[r]>>>24)|4278255360&(n[r]<<24|n[r]>>>8);var i=this.hn=[n[0],n[3]<<16|n[2]>>>16,n[1],n[0]<<16|n[3]>>>16,n[2],n[1]<<16|n[0]>>>16,n[3],n[2]<<16|n[1]>>>16],e=this.vn=[n[2]<<16|n[2]>>>16,4294901760&n[0]|65535&n[1],n[3]<<16|n[3]>>>16,4294901760&n[1]|65535&n[2],n[0]<<16|n[0]>>>16,4294901760&n[2]|65535&n[3],n[1]<<16|n[1]>>>16,4294901760&n[3]|65535&n[0]];this.wn=0;for(r=0;r<4;r++)this.nextState();for(r=0;r<8;r++)e[r]^=i[r+4&7];if(t){var o=t.words,u=o[0],f=o[1],c=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8),s=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8),a=c>>>16|4294901760&s,h=s<<16|65535&c;e[0]^=c,e[1]^=a,e[2]^=s,e[3]^=h,e[4]^=c,e[5]^=a,e[6]^=s,e[7]^=h;for(r=0;r<4;r++)this.nextState()}},t.prototype.un=function(n,t){var r=this.hn;this.nextState(),this.S[0]=r[0]^r[5]>>>16^r[3]<<16,this.S[1]=r[2]^r[7]>>>16^r[5]<<16,this.S[2]=r[4]^r[1]>>>16^r[7]<<16,this.S[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)this.S[i]=16711935&(this.S[i]<<8|this.S[i]>>>24)|4278255360&(this.S[i]<<24|this.S[i]>>>8),n[t+i]^=this.S[i]},t.prototype.nextState=function(){for(var n=this.hn,t=this.vn,r=0;r<8;r++)this.C[r]=t[r];t[0]=t[0]+1295307597+this.wn|0,t[1]=t[1]+3545052371+(t[0]>>>0<this.C[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<this.C[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<this.C[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<this.C[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<this.C[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<this.C[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<this.C[6]>>>0?1:0)|0,this.wn=t[7]>>>0<this.C[7]>>>0?1:0;for(r=0;r<8;r++){var i=n[r]+t[r],e=65535&i,o=i>>>16,u=((e*e>>>17)+e*o>>>15)+o*o,f=((4294901760&i)*i|0)+((65535&i)*i|0);this.G[r]=u^f}var c=this.G;n[0]=c[0]+(c[7]<<16|c[7]>>>16)+(c[6]<<16|c[6]>>>16)|0,n[1]=c[1]+(c[0]<<8|c[0]>>>24)+c[7]|0,n[2]=c[2]+(c[1]<<16|c[1]>>>16)+(c[0]<<16|c[0]>>>16)|0,n[3]=c[3]+(c[2]<<8|c[2]>>>24)+c[1]|0,n[4]=c[4]+(c[3]<<16|c[3]>>>16)+(c[2]<<16|c[2]>>>16)|0,n[5]=c[5]+(c[4]<<8|c[4]>>>24)+c[3]|0,n[6]=c[6]+(c[5]<<16|c[5]>>>16)+(c[4]<<16|c[4]>>>16)|0,n[7]=c[7]+(c[6]<<8|c[6]>>>24)+c[5]|0},t.createEncryptor=function(n,r){return new t(c(c({},r=void 0===r?{}:r),{key:n}))},t.createDecryptor=function(n,r){return new t(c(c({},r=void 0===r?{}:r),{key:n}))},t.encrypt=function(n,r,i){return"string"==typeof r?o.E.encrypt(t,n,r,i):u.D.encrypt(t,n,r,i)},t.decrypt=function(n,r,i){return"string"==typeof r?o.E.decrypt(t,n,r,i):u.D.decrypt(t,n,r,i)},t.ivSize=4,t}(e.q)},3173:function(n,t,r){r.d(t,{SHA1:function(){return c}});var i,e=r(1868),o=r(3354),u=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),f=[],c=function(n){function t(t){var r=n.call(this,t)||this;return r.on=new o.e([1732584193,4023233417,2562383102,271733878,3285377520]),r.O=t,t&&void 0!==t.hash&&(r.on=t.hash.clone()),r}return u(t,n),t.prototype.A=function(){this.on=new o.e([1732584193,4023233417,2562383102,271733878,3285377520])},t.prototype.un=function(n,t){for(var r=this.on.words,i=r[0],e=r[1],o=r[2],u=r[3],c=r[4],s=0;s<80;s++){if(s<16)f[s]=0|n[t+s];else{var a=f[s-3]^f[s-8]^f[s-14]^f[s-16];f[s]=a<<1|a>>>31}var h=(i<<5|i>>>27)+c+f[s];h+=s<20?1518500249+(e&o|~e&u):s<40?1859775393+(e^o^u):s<60?(e&o|e&u|o&u)-1894007588:(e^o^u)-899497514,c=u,u=o,o=e<<30|e>>>2,e=i,i=h}r[0]=r[0]+i|0,r[1]=r[1]+e|0,r[2]=r[2]+o|0,r[3]=r[3]+u|0,r[4]=r[4]+c|0},t.prototype.fn=function(){var n=this.cn.words,t=8*this.sn,r=8*this.cn.nSigBytes;return n[r>>>5]|=128<<24-r%32,n[14+(r+64>>>9<<4)]=Math.floor(t/4294967296),n[15+(r+64>>>9<<4)]=t,this.cn.nSigBytes=4*n.length,this.an(),this.on},t.prototype.clone=function(){return new t({hash:this.on,blockSize:this.N,data:this.cn,nBytes:this.sn})},t.hash=function(n,r){return new t(r).finalize(n)},t}(e.P)},766:function(n,t,r){r.d(t,{SHA224:function(){return f}});var i,e=r(3354),o=r(5561),u=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),f=function(n){function t(t){var r=n.call(this,t)||this;return r.on=new e.e([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),r.O=t,t&&void 0!==t.hash&&(r.on=t.hash.clone()),r}return u(t,n),t.prototype.A=function(){this.on=new e.e([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},t.prototype.fn=function(){var t=n.prototype.fn.call(this);return t.nSigBytes-=4,t},t.prototype.clone=function(){return new t({hash:this.on,blockSize:this.N,data:this.cn,nBytes:this.sn})},t.hash=function(n,r){return new t(r).finalize(n)},t}(o.SHA256)},5561:function(n,t,r){r.d(t,{SHA256:function(){return v}});var i,e=r(1868),o=r(3354),u=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),f=[],c=[];function s(n){for(var t=Math.sqrt(n),r=2;r<=t;r++)if(!(n%r))return!1;return!0}function a(n){return 4294967296*(n-(0|n))|0}!function(){for(var n=2,t=0;t<64;)s(n)&&(t<8&&(f[t]=a(Math.pow(n,.5))),c[t]=a(Math.pow(n,1/3)),t++),n++}();var h=[],v=function(n){function t(t){var r=n.call(this,t)||this;return r.on=new o.e(f.slice(0)),r.O=t,t&&void 0!==t.hash&&(r.on=t.hash.clone()),r}return u(t,n),t.prototype.A=function(){this.on=new o.e(f.slice(0))},t.prototype.un=function(n,t){for(var r=this.on.words,i=r[0],e=r[1],o=r[2],u=r[3],f=r[4],s=r[5],a=r[6],v=r[7],w=0;w<64;w++){if(w<16)h[w]=0|n[t+w];else{var l=h[w-15],b=(l<<25|l>>>7)^(l<<14|l>>>18)^l>>>3,d=h[w-2],y=(d<<15|d>>>17)^(d<<13|d>>>19)^d>>>10;h[w]=b+h[w-7]+y+h[w-16]}var p=i&e^i&o^e&o,O=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),j=v+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(f&s^~f&a)+c[w]+h[w];v=a,a=s,s=f,f=u+j|0,u=o,o=e,e=i,i=j+(O+p)|0}r[0]=r[0]+i|0,r[1]=r[1]+e|0,r[2]=r[2]+o|0,r[3]=r[3]+u|0,r[4]=r[4]+f|0,r[5]=r[5]+s|0,r[6]=r[6]+a|0,r[7]=r[7]+v|0},t.prototype.fn=function(){var n=this.cn.words,t=8*this.sn,r=8*this.cn.nSigBytes;return n[r>>>5]|=128<<24-r%32,n[14+(r+64>>>9<<4)]=Math.floor(t/4294967296),n[15+(r+64>>>9<<4)]=t,this.cn.nSigBytes=4*n.length,this.an(),this.on},t.prototype.clone=function(){return new t({hash:this.on,blockSize:this.N,data:this.cn,nBytes:this.sn})},t.hash=function(n,r){return new t(r).finalize(n)},t}(e.P)},3408:function(n,t,r){r.d(t,{SHA3:function(){return v}});var i,e=r(6957),o=r(1868),u=r(3354),f=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),c=[],s=[],a=[];!function(){for(var n=1,t=0,r=0;r<24;r++){c[n+5*t]=(r+1)*(r+2)/2%64;var i=(2*n+3*t)%5;n=t%5,t=i}for(var o=0;o<5;o++)for(var u=0;u<5;u++)s[o+5*u]=u+(2*o+3*u)%5*5;for(var f=1,h=0;h<24;h++){for(var v=0,w=0,l=0;l<7;l++){if(1&f){var b=(1<<l)-1;b<32?w^=1<<b:v^=1<<b-32}128&f?f=f<<1^113:f<<=1}a[h]=new e.r(v,w)}}();var h=[];!function(){for(var n=0;n<25;n++)h[n]=new e.r(0,0)}();var v=function(n){function t(t){var r=n.call(this,t)||this;if(r.N=32,r.bn=[],r.dn=512,r.O=t,t){if(void 0!==t.outputLength){if(![224,256,384,512].includes(t.outputLength))throw new Error("Unsupported output length.");r.dn=t.outputLength}void 0!==t.state&&(r.bn=t.state.map((function(n){return n.clone()})))}if(0===r.bn.length)for(var i=0;i<25;i++)r.bn[i]=new e.r(0,0);return r.N=(1600-2*r.dn)/32,r}return f(t,n),t.prototype.A=function(){this.bn=[];for(var n=0;n<25;n++)this.bn[n]=new e.r(0,0);this.N=(1600-2*this.dn)/32},t.prototype.un=function(n,t){for(var r=this.bn,i=this.N/2,e=0;e<i;e++){var o=n[t+2*e],u=n[t+2*e+1];o=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),u=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8),r[e].high^=u,r[e].low^=o}for(var f=0;f<24;f++){for(var v=0;v<5;v++){for(var w=0,l=0,b=0;b<5;b++){w^=(k=r[v+5*b]).high,l^=k.low}var d=h[v];d.high=w,d.low=l}for(v=0;v<5;v++){var y=h[(v+4)%5],p=h[(v+1)%5],O=p.high,j=p.low;for(w=y.high^(O<<1|j>>>31),l=y.low^(j<<1|O>>>31),b=0;b<5;b++){(k=r[v+5*b]).high^=w,k.low^=l}}for(var _=1;_<25;_++){w=void 0,l=void 0;var m=r[_].high,A=r[_].low,g=c[_];g<32?(w=m<<g|A>>>32-g,l=A<<g|m>>>32-g):(w=A<<g-32|m>>>64-g,l=m<<g-32|A>>>64-g);var E=h[s[_]];E.high=w,E.low=l}var S=h[0],M=r[0];S.high=M.high,S.low=M.low;for(v=0;v<5;v++)for(b=0;b<5;b++){var k=r[_=v+5*b],H=h[_],C=h[(v+1)%5+5*b],B=h[(v+2)%5+5*b];k.high=H.high^~C.high&B.high,k.low=H.low^~C.low&B.low}var N=r[0],I=a[f];N.high^=I.high,N.low^=I.low}},t.prototype.fn=function(){var n=this.cn,t=n.words,r=8*n.nSigBytes,i=32*this.blockSize;t[r>>>5]|=1<<24-r%32,t[(Math.ceil((r+1)/i)*i>>>5)-1]|=128,n.nSigBytes=4*t.length,this.an();for(var e=this.bn,o=this.dn/8,f=o/8,c=[],s=0;s<f;s++){var a=e[s],h=a.high,v=a.low;h=16711935&(h<<8|h>>>24)|4278255360&(h<<24|h>>>8),v=16711935&(v<<8|v>>>24)|4278255360&(v<<24|v>>>8),c.push(v),c.push(h)}return new u.e(c,o)},t.prototype.clone=function(){return new t({outputLength:this.dn,state:this.bn,blockSize:this.N,data:this.cn,nBytes:this.sn})},t.hash=function(n,r){return new t(r).finalize(n)},t}(o.P)},6324:function(n,t,r){r.d(t,{SHA384:function(){return f}});var i,e=r(6957),o=r(7491),u=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),f=function(n){function t(t){var r=n.call(this,t)||this;return r.on=new e.m([new e.r(3418070365,3238371032),new e.r(1654270250,914150663),new e.r(2438529370,812702999),new e.r(355462360,4144912697),new e.r(1731405415,4290775857),new e.r(2394180231,1750603025),new e.r(3675008525,1694076839),new e.r(1203062813,3204075428)]),r.O=t,t&&void 0!==t.hash&&(r.on=t.hash.clone()),r}return u(t,n),t.prototype.A=function(){this.on=new e.m([new e.r(3418070365,3238371032),new e.r(1654270250,914150663),new e.r(2438529370,812702999),new e.r(355462360,4144912697),new e.r(1731405415,4290775857),new e.r(2394180231,1750603025),new e.r(3675008525,1694076839),new e.r(1203062813,3204075428)])},t.prototype.fn=function(){var t=n.prototype.fn.call(this);return t.nSigBytes-=16,t},t.prototype.clone=function(){return new t({hash:this.on,blockSize:this.N,data:this.cn,nBytes:this.sn})},t.hash=function(n,r){return new t(r).finalize(n)},t}(o.SHA512)},7491:function(n,t,r){r.d(t,{SHA512:function(){return s}});var i,e=r(1868),o=r(6957),u=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),f=[new o.r(1116352408,3609767458),new o.r(1899447441,602891725),new o.r(3049323471,3964484399),new o.r(3921009573,2173295548),new o.r(961987163,4081628472),new o.r(1508970993,3053834265),new o.r(2453635748,2937671579),new o.r(2870763221,3664609560),new o.r(3624381080,2734883394),new o.r(310598401,1164996542),new o.r(607225278,1323610764),new o.r(1426881987,3590304994),new o.r(1925078388,4068182383),new o.r(2162078206,991336113),new o.r(2614888103,633803317),new o.r(3248222580,3479774868),new o.r(3835390401,2666613458),new o.r(4022224774,944711139),new o.r(264347078,2341262773),new o.r(604807628,2007800933),new o.r(770255983,1495990901),new o.r(1249150122,1856431235),new o.r(1555081692,3175218132),new o.r(1996064986,2198950837),new o.r(2554220882,3999719339),new o.r(2821834349,766784016),new o.r(2952996808,2566594879),new o.r(3210313671,3203337956),new o.r(3336571891,1034457026),new o.r(3584528711,2466948901),new o.r(113926993,3758326383),new o.r(338241895,168717936),new o.r(666307205,1188179964),new o.r(773529912,1546045734),new o.r(1294757372,1522805485),new o.r(1396182291,2643833823),new o.r(1695183700,2343527390),new o.r(1986661051,1014477480),new o.r(2177026350,1206759142),new o.r(2456956037,344077627),new o.r(2730485921,1290863460),new o.r(2820302411,3158454273),new o.r(3259730800,3505952657),new o.r(3345764771,106217008),new o.r(3516065817,3606008344),new o.r(3600352804,1432725776),new o.r(4094571909,1467031594),new o.r(275423344,851169720),new o.r(430227734,3100823752),new o.r(506948616,1363258195),new o.r(659060556,3750685593),new o.r(883997877,3785050280),new o.r(958139571,3318307427),new o.r(1322822218,3812723403),new o.r(1537002063,2003034995),new o.r(1747873779,3602036899),new o.r(1955562222,1575990012),new o.r(2024104815,1125592928),new o.r(2227730452,2716904306),new o.r(2361852424,442776044),new o.r(2428436474,593698344),new o.r(2756734187,3733110249),new o.r(3204031479,2999351573),new o.r(3329325298,3815920427),new o.r(3391569614,3928383900),new o.r(3515267271,566280711),new o.r(3940187606,3454069534),new o.r(4118630271,4000239992),new o.r(116418474,1914138554),new o.r(174292421,2731055270),new o.r(289380356,3203993006),new o.r(460393269,320620315),new o.r(685471733,587496836),new o.r(852142971,1086792851),new o.r(1017036298,365543100),new o.r(1126000580,2618297676),new o.r(1288033470,3409855158),new o.r(1501505948,4234509866),new o.r(1607167915,987167468),new o.r(1816402316,1246189591)],c=[];!function(){for(var n=0;n<80;n++)c[n]=new o.r(0,0)}();var s=function(n){function t(t){var r=n.call(this,t)||this;return r.N=32,r.on=new o.m([new o.r(1779033703,4089235720),new o.r(3144134277,2227873595),new o.r(1013904242,4271175723),new o.r(2773480762,1595750129),new o.r(1359893119,2917565137),new o.r(2600822924,725511199),new o.r(528734635,4215389547),new o.r(1541459225,327033209)]),r.O=t,t&&void 0!==t.hash&&(r.on=t.hash.clone()),r}return u(t,n),t.prototype.A=function(){this.on=new o.m([new o.r(1779033703,4089235720),new o.r(3144134277,2227873595),new o.r(1013904242,4271175723),new o.r(2773480762,1595750129),new o.r(1359893119,2917565137),new o.r(2600822924,725511199),new o.r(528734635,4215389547),new o.r(1541459225,327033209)])},t.prototype.un=function(n,t){for(var r=this.on.words,i=r[0],e=r[1],o=r[2],u=r[3],s=r[4],a=r[5],h=r[6],v=r[7],w=i.high,l=i.low,b=e.high,d=e.low,y=o.high,p=o.low,O=u.high,j=u.low,_=s.high,m=s.low,A=a.high,g=a.low,E=h.high,S=h.low,M=v.high,k=v.low,H=w,C=l,B=b,N=d,I=y,z=p,D=O,U=j,L=_,F=m,x=A,P=g,R=E,T=S,K=M,W=k,G=0;G<80;G++){var q=void 0,Q=void 0,X=c[G];if(G<16)Q=X.high=0|n[t+2*G],q=X.low=0|n[t+2*G+1];else{var V=c[G-15],Z=V.high,J=V.low,Y=(Z>>>1|J<<31)^(Z>>>8|J<<24)^Z>>>7,$=(J>>>1|Z<<31)^(J>>>8|Z<<24)^(J>>>7|Z<<25),nn=c[G-2],tn=nn.high,rn=nn.low,en=(tn>>>19|rn<<13)^(tn<<3|rn>>>29)^tn>>>6,on=(rn>>>19|tn<<13)^(rn<<3|tn>>>29)^(rn>>>6|tn<<26),un=c[G-7],fn=un.high,cn=un.low,sn=c[G-16],an=sn.high,hn=sn.low;Q=(Q=(Q=Y+fn+((q=$+cn)>>>0<$>>>0?1:0))+en+((q+=on)>>>0<on>>>0?1:0))+an+((q+=hn)>>>0<hn>>>0?1:0),X.high=Q,X.low=q}var vn=L&x^~L&R,wn=F&P^~F&T,ln=H&B^H&I^B&I,bn=C&N^C&z^N&z,dn=(H>>>28|C<<4)^(H<<30|C>>>2)^(H<<25|C>>>7),yn=(C>>>28|H<<4)^(C<<30|H>>>2)^(C<<25|H>>>7),pn=(L>>>14|F<<18)^(L>>>18|F<<14)^(L<<23|F>>>9),On=(F>>>14|L<<18)^(F>>>18|L<<14)^(F<<23|L>>>9),jn=f[G],_n=jn.high,mn=jn.low,An=W+On,gn=K+pn+(An>>>0<W>>>0?1:0),En=yn+bn;K=R,W=T,R=x,T=P,x=L,P=F,L=D+(gn=(gn=(gn=gn+vn+((An+=wn)>>>0<wn>>>0?1:0))+_n+((An+=mn)>>>0<mn>>>0?1:0))+Q+((An+=q)>>>0<q>>>0?1:0))+((F=U+An|0)>>>0<U>>>0?1:0)|0,D=I,U=z,I=B,z=N,B=H,N=C,H=gn+(dn+ln+(En>>>0<yn>>>0?1:0))+((C=An+En|0)>>>0<An>>>0?1:0)|0}l=i.low=l+C,i.high=w+H+(l>>>0<C>>>0?1:0),d=e.low=d+N,e.high=b+B+(d>>>0<N>>>0?1:0),p=o.low=p+z,o.high=y+I+(p>>>0<z>>>0?1:0),j=u.low=j+U,u.high=O+D+(j>>>0<U>>>0?1:0),m=s.low=m+F,s.high=_+L+(m>>>0<F>>>0?1:0),g=a.low=g+P,a.high=A+x+(g>>>0<P>>>0?1:0),S=h.low=S+T,h.high=E+R+(S>>>0<T>>>0?1:0),k=v.low=k+W,v.high=M+K+(k>>>0<W>>>0?1:0)},t.prototype.fn=function(){var n=this.cn,t=n.words,r=8*this.sn,i=8*n.nSigBytes;return t[i>>>5]|=128<<24-i%32,t[30+(i+128>>>10<<5)]=Math.floor(r/4294967296),t[31+(i+128>>>10<<5)]=r,n.nSigBytes=4*t.length,this.an(),this.on.to32()},t.prototype.clone=function(){return new t({hash:this.on,blockSize:this.N,data:this.cn,nBytes:this.sn})},t.hash=function(n,r){return new t(r).finalize(n)},t}(e.P)},3354:function(n,t,r){r.d(t,{e:function(){return o}});var i=r(5720),e=r(9054),o=function(){function n(t,r){if(Array.isArray(t)||!t)return this.yn=Array.isArray(t)?t:[],void(this.pn="number"==typeof r?r:4*this.yn.length);if(t instanceof n)return this.yn=t.words.slice(),void(this.pn=t.nSigBytes);var i;try{t instanceof ArrayBuffer?i=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!i)throw new Error("Invalid argument");for(var e=i.byteLength,o=[],u=0;u<e;u++)o[u>>>2]|=i[u]<<24-u%4*8;this.yn=o,this.pn=e}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.pn},set:function(n){this.pn=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.yn},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):i.p.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this.yn,t=this.pn,r=new Uint8Array(t),i=0;i<t;i++)r[i]=n[i>>>2]>>>24-i%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.pn%4)for(var i=0;i<r;i++){var e=t[i>>>2]>>>24-i%4*8&255;this.yn[this.pn+i>>>2]|=e<<24-(this.pn+i)%4*8}else for(i=0;i<r;i+=4)this.yn[this.pn+i>>>2]=t[i>>>2];return this.pn+=r,this},n.prototype.clamp=function(){var n=this.pn;this.yn[n>>>2]&=4294967295<<32-n%4*8,this.yn.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.yn.slice(),this.pn)},n.random=function(t){for(var r=[],i=0;i<t;i+=4)r.push((0,e.M)());return new n(r,t)},n}()},6957:function(n,t,r){r.d(t,{r:function(){return o},m:function(){return u}});var i=r(5720),e=r(3354),o=function(){function n(n,t){this.high=n,this.low=t}return n.prototype.clone=function(){return new n(this.high,this.low)},n}(),u=function(){function n(n,t){this.yn=n||[],this.pn="number"==typeof t?t:8*this.yn.length}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.pn},set:function(n){this.pn=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.yn},enumerable:!1,configurable:!0}),n.prototype.to32=function(){for(var n=[],t=0;t<this.yn.length;t++){var r=this.yn[t];n.push(r.high),n.push(r.low)}return new e.e(n,this.pn)},n.prototype.toString=function(n){return n?n.stringify(this.to32()):i.p.stringify(this.to32())},n.prototype.clone=function(){for(var t=this.yn.slice(),r=0;r<t.length;r++)t[r]=t[r].clone();return new n(t,this.pn)},n}()},7211:function(n,t,r){r.d(t,{C:function(){return o}});var i=r(3354),e=r(4768),o=function(){function n(n){this.On=0,this.N=0,this.O=n,this.cn=n&&void 0!==n.data?n.data.clone():new i.e,this.sn=n&&"number"==typeof n.nBytes?n.nBytes:0}return Object.defineProperty(n.prototype,"blockSize",{get:function(){return this.N},enumerable:!1,configurable:!0}),n.prototype.reset=function(n,t){this.cn=void 0!==n?n.clone():new i.e,this.sn="number"==typeof t?t:0},n.prototype.jn=function(n){var t="string"==typeof n?e.d.parse(n):n;this.cn.concat(t),this.sn+=t.nSigBytes},n.prototype.an=function(n){var t,r=this.cn.words,e=this.cn.nSigBytes,o=this.N,u=e/(4*this.N),f=(u=n?Math.ceil(u):Math.max((0|u)-this.On,0))*o,c=Math.min(4*f,e);if(f){for(var s=0;s<f;s+=o)this.un(r,s);t=r.splice(0,f),this.cn.nSigBytes-=c}return new i.e(t,c)},n.prototype.un=function(n,t){throw new Error("Not implemented")},n}()},1868:function(n,t,r){r.d(t,{P:function(){return u}});var i,e=r(7211),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.N=16,r.O=t,t&&"number"==typeof t.blockSize&&(r.N=t.blockSize),r.reset(t?t.data:void 0,t?t.nBytes:void 0),r}return o(t,n),Object.defineProperty(t.prototype,"blockSize",{get:function(){return this.N},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.A()},t.prototype.update=function(n){return this.jn(n),this.an(),this},t.prototype.finalize=function(n){return n&&this.jn(n),this.fn()},t.prototype.A=function(){throw new Error("Not implemented")},t.prototype.fn=function(){throw new Error("Not implemented")},t}(e.C)},787:function(n,t,r){r.d(t,{G:function(){return s}});var i,e=r(9456),o=r(4344),u=r(7919),f=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),c=function(){return(c=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},s=function(n){function t(t){var r=n.call(this,t)||this;return r.N=4,r._n=o.n,r.mn=u.l,r.O=t,r._n=void 0!==t.mode?t.mode:r._n,r.mn=void 0!==t.padding?t.padding:r.mn,r.reset(null==t?void 0:t.data,null==t?void 0:t.nBytes),r}return f(t,n),Object.defineProperty(t.prototype,"mode",{get:function(){return this.An},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"padding",{get:function(){return this.mn},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){var i;n.prototype.reset.call(this,t,r),this.gn===e.t.ENC_TRANSFORM_MODE?i=this._n.createEncryptor:(i=this._n.createDecryptor,this.On=1),this._n&&this.En===i?this.An=new this._n({cipher:this,iv:this.ln}):(this.An=i.call(this._n,{cipher:this,iv:this.ln}),this.En=i)},t.prototype.un=function(n,t){var r;null===(r=this.An)||void 0===r||r.processBlock(n,t)},t.prototype.fn=function(){var n,t=this.mn;return this.gn===e.t.ENC_TRANSFORM_MODE?(t.pad(this.cn,this.blockSize),n=this.an(!0)):(n=this.an(!0),t.unpad(n)),n},t.prototype.encryptBlock=function(n,t){throw new Error("Not implemented")},t.prototype.decryptBlock=function(n,t){throw new Error("Not implemented")},t.createEncryptor=function(n,r){return new t(c(c({},r=void 0===r?{}:r),{key:n,transformMode:e.t.ENC_TRANSFORM_MODE}))},t.createDecryptor=function(n,r){return new t(c(c({},r=void 0===r?{}:r),{key:n,transformMode:e.t.DEC_TRANSFORM_MODE}))},t}(e.t)},9456:function(n,t,r){r.d(t,{t:function(){return f}});var i,e=r(7211),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(){return(u=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},f=function(n){function t(t){var r=n.call(this,t)||this;return r.gn=1,r.O=t,r.H=t.key,r.ln=void 0!==t.iv?t.iv:r.ln,r.gn=void 0!==t.transformMode?t.transformMode:r.gn,r}return o(t,n),Object.defineProperty(t.prototype,"iv",{get:function(){return this.ln},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.A()},t.prototype.process=function(n){return this.jn(n),this.an()},t.prototype.finalize=function(n){return n&&this.jn(n),this.fn()},t.prototype.A=function(){throw new Error("Not implemented")},t.prototype.un=function(n,t){throw new Error("Not implemented")},t.prototype.fn=function(){throw new Error("Not implemented")},t.createEncryptor=function(n,r){return new t(u(u({},r=void 0===r?{}:r),{key:n,transformMode:t.ENC_TRANSFORM_MODE}))},t.createDecryptor=function(n,r){return new t(u(u({},r=void 0===r?{}:r),{key:n,transformMode:t.DEC_TRANSFORM_MODE}))},t.ENC_TRANSFORM_MODE=1,t.DEC_TRANSFORM_MODE=2,t.keySize=4,t.ivSize=4,t}(e.C)},2505:function(n,t,r){r.d(t,{Q:function(){return e}});var i=r(1232),e=function(){function n(n){this.formatter=i.w,n&&(this.cipherText=n.cipherText,this.key=n.key,this.iv=n.iv,this.salt=n.salt,this.Algorithm=n.Algorithm,this.mode=n.mode,this.padding=n.padding,this.blockSize=n.blockSize,this.formatter=n.formatter||i.w)}return n.prototype.toString=function(n){return(n||this.formatter).stringify(this)},n}()},5693:function(n,t,r){r.d(t,{E:function(){return c}});var i=r(9109),e=r(2214),o=r(2505),u=r(1232),f=function(){return(f=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},c={encrypt:function(n,t,r,u){var c=u?f({},u):{},s=u&&u.KDF?u.KDF:e.s,a={};u&&u.kdfHasher&&(a.kdfHasher=u.kdfHasher),u&&u.kdfIterations&&(a.kdfIterations=u.kdfIterations),u&&u.kdfModule&&(a.kdfModule=u.kdfModule);var h=s.execute(r,n.keySize,n.ivSize,c.kdfSalt,a);c.iv=h.iv;var v=i.D.encrypt(n,t,h.key,c);return new o.Q(f(f({},v),{key:h.key,iv:h.iv,salt:h.salt}))},decrypt:function(n,t,r,o){var c=o?f({},o):{},s=c.KDF?c.KDF:e.s,a=c.formatter?c.formatter:u.w,h=(0,i.W)(t,a),v={};o&&o.kdfHasher&&(v.kdfHasher=o.kdfHasher),o&&o.kdfIterations&&(v.kdfIterations=o.kdfIterations),o&&o.kdfModule&&(v.kdfModule=o.kdfModule);var w=s.execute(r,n.keySize,n.ivSize,h.salt,v);return c.iv=w.iv,i.D.decrypt(n,h,w.key,c)}}},9109:function(n,t,r){r.d(t,{W:function(){return o},D:function(){return u}});var i=r(1232),e=r(2505);function o(n,t){return"string"==typeof n?t.parse(n):n}var u={encrypt:function(n,t,r,o){var u=n.createEncryptor(r,o),f=u.finalize(t);return new e.Q({cipherText:f,key:r,iv:u.iv,Algorithm:n,mode:u.mode,padding:u.padding,blockSize:u.blockSize,formatter:(null==o?void 0:o.formatter)||i.w})},decrypt:function(n,t,r,e){var u=n.createDecryptor(r,e),f=o(t,(null==e?void 0:e.formatter)||i.w);return u.finalize(f.cipherText||"")}}},30:function(n,t,r){r.d(t,{q:function(){return u}});var i,e=r(9456),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.N=1,r}return o(t,n),t.prototype.fn=function(){return this.an(!0)},t}(e.t)},1232:function(n,t,r){r.d(t,{w:function(){return u}});var i=r(2505),e=r(3354),o=r(1773),u={stringify:function(n){var t=n.cipherText,r=n.salt;return t?r?new e.e([1398893684,1701076831]).concat(r).concat(t).toString(o.D):t.toString(o.D):""},parse:function(n){var t,r=o.D.parse(n),u=r.words;return 1398893684===u[0]&&1701076831===u[1]&&(t=new e.e(u.slice(2,4)),u.splice(0,4),r.nSigBytes-=16),new i.Q({cipherText:r,salt:t})}}},2214:function(n,t,r){r.d(t,{s:function(){return f}});var i=r(3354),e=r(2505),o=r(7008),u=function(){return(u=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},f={execute:function(n,t,r,f,c){f||(f=i.e.random(8));var s=c&&c.kdfModule||o.E,a=c?{Hasher:c.kdfHasher,iterations:c.kdfIterations}:{},h=s.getKey(n,f,u(u({},a),{keySize:t+r})),v=new i.e(h.words.slice(t),4*r);return h.nSigBytes=4*t,new e.Q({key:h,iv:v,salt:f})}}},7008:function(n,t,r){r.d(t,{E:function(){return s}});var i,e=r(5561),o=r(6367),u=r(3354),f=r(9541),c=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),s=function(n){function t(t){var r=n.call(this,t)||this;return r.Sn=4,r.Mn=e.SHA256,r.kn=1e4,t&&(r.Sn=void 0!==t.keySize?t.keySize:r.Sn,r.Mn=void 0!==t.Hasher?t.Hasher:r.Mn,r.kn=void 0!==t.iterations?t.iterations:r.kn),r}return c(t,n),t.prototype.compute=function(n,t){for(var r=new o.Hmac(new this.Mn,n),i=new u.e,e=new u.e([1]),f=i.words,c=e.words,s=this.Sn,a=this.kn;f.length<s;){var h=r.update(t).finalize(e);r.reset();for(var v=h.words,w=v.length,l=h,b=1;b<a;b++){l=r.finalize(l),r.reset();for(var d=l.words,y=0;y<w;y++)v[y]^=d[y]}i.concat(h),c[0]++}return i.nSigBytes=4*s,i},t.getKey=function(n,r,i){return new t(i).compute(n,r)},t}(f._)},9541:function(n,t,r){r.d(t,{_:function(){return i}});var i=function(){function n(n){this.O=n}return n.prototype.compute=function(n,t){throw new Error("Not implemented")},n.getKey=function(n,t,r){throw new Error("Not implemented")},n}()},1863:function(n,t,r){r.d(t,{T:function(){return i}});var i=function(){function n(n){this.O=n,this.Hn=n.cipher,this.ln=n.iv}return n.prototype.processBlock=function(n,t){},n.createEncryptor=function(n){throw new Error("Not implemented yet")},n.createDecryptor=function(n){throw new Error("Not implemented yet")},n}()},4344:function(n,t,r){r.d(t,{n:function(){return u}});var i,e=r(1863),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.Cn=[],r}return o(t,n),t.prototype.xorBlock=function(n,t,r){var i,e=this.ln;e?(i=e.words,this.ln=void 0):i=this.Cn;for(var o=0;o<r;o++)n[t+o]^=i[o]},t.createEncryptor=function(n){return new t.Encryptor(n)},t.createDecryptor=function(n){return new t.Decryptor(n)},t.Encryptor=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return o(t,n),t.prototype.processBlock=function(n,t){var r=this.Hn,i=r.blockSize;this.xorBlock(n,t,i),r.encryptBlock(n,t),this.Cn=n.slice(t,t+i)},t}(t),t.Decryptor=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return o(t,n),t.prototype.processBlock=function(n,t){var r=this.Hn,i=r.blockSize,e=n.slice(t,t+i);r.decryptBlock(n,t),this.xorBlock(n,t,i),this.Cn=e},t}(t),t}(e.T)},4055:function(n,t,r){r.d(t,{I4:function(){return e},z6:function(){return o},ur:function(){return u}});var i=r(3354);function e(n){var t=n.nSigBytes%16;if(0!==t){for(var r=16-t,e=[],o=Math.floor(r/4),u=0;u<o;u++)e.push(0);r%4>0&&e.push(0),n.concat(new i.e(e,r))}}function o(n,t){return new i.e(n.words.slice(),t)}function u(n,t){for(var r=n.nSigBytes-t,e=[],o=0;o<t;o++){var u=o>>>2,f=r+o,c=f>>>2,s=n.words[c]>>>24-f%4*8&255;e[u]=0|e[u]|s<<24-o%4*8}var a=new i.e(e,t);return a.clamp(),a}},7919:function(n,t,r){r.d(t,{l:function(){return e}});var i=r(3354);var e={pad:function(n,t){for(var r=4*t,e=r-n.nSigBytes%r,o=e<<24|e<<16|e<<8|e,u=[],f=0;f<e;f+=4)u.push(o);var c=new i.e(u,e);n.concat(c)},unpad:function(n){var t=255&n.words[n.nSigBytes-1>>>2];n.nSigBytes-=t}}},1756:function(n,t,r){r.d(t,{w:function(){return u}});var i,e="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(i=parseInt((/msie (\d+)/.exec(e)||[])[1],10),isNaN(i)?(i=parseInt((/trident\/.*; rv:(\d+)/.exec(e)||[])[1],10),!isNaN(i)&&i):i);function u(n,t){return!1!==o&&(!t||("<"===n?o<t:"<="===n?o<=t:">"===n?o>t:">="===n?o>=t:o===t))}},1773:function(n,t,r){r.d(t,{D:function(){return f}});for(var i=r(3354),e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=[],u=0;u<e.length;u++)o[e.charCodeAt(u)]=u;var f={stringify:function(n){var t=n.words,r=n.nSigBytes;n.clamp();for(var i=[],o=0;o<r;o+=3)for(var u=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,f=0;f<4&&o+.75*f<r;f++)i.push(e.charAt(u>>>6*(3-f)&63));var c=e.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(n){var t=n.length,r=e.charAt(64);if(r){var u=n.indexOf(r);-1!==u&&(t=u)}for(var f=[],c=0,s=0;s<t;s++)if(s%4){var a=o[n.charCodeAt(s-1)]<<s%4*2|o[n.charCodeAt(s)]>>>6-s%4*2;f[c>>>2]|=a<<24-c%4*8,c++}return new i.e(f,c)}}},5720:function(n,t,r){r.d(t,{p:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var r=[],e=0;e<t;e+=2)r[e>>>3]|=parseInt(n.substr(e,2),16)<<24-e%8*4;return new i.e(r,t/2)}}},8702:function(n,t,r){r.d(t,{m:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push(String.fromCharCode(o))}return i.join("")},parse:function(n){for(var t=n.length,r=[],e=0;e<t;e++)r[e>>>2]|=(255&n.charCodeAt(e))<<24-e%4*8;return new i.e(r,t)}}},4768:function(n,t,r){r.d(t,{d:function(){return e}});var i=r(8702),e={stringify:function(n){try{return decodeURIComponent(escape(i.m.stringify(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return i.m.parse(unescape(encodeURIComponent(n)))}}},2688:function(n,t,r){r.d(t,{Base64:function(){return o.D},EvpKDF:function(){return O},Hex:function(){return c.p},Latin1:function(){return f.m},OpenSSLKDF:function(){return l.s},PBKDF2:function(){return b.E},Utf16:function(){return w},Utf16BE:function(){return s},Utf16LE:function(){return v},Utf8:function(){return u.d},Word32Array:function(){return i.e},Word64:function(){return e.r},Word64Array:function(){return e.m}});r(9054);var i=r(3354),e=r(6957),o=(r(1756),r(1773)),u=r(4768),f=r(8702),c=r(5720),s={stringify:function(n){for(var t=n.words,r=n.nSigBytes,i=[],e=0;e<r;e+=2){var o=t[e>>>2]>>>16-e%4*8&65535;i.push(String.fromCharCode(o))}return i.join("")},parse:function(n){for(var t=n.length,r=[],e=0;e<t;e++)r[e>>>1]|=n.charCodeAt(e)<<16-e%2*16;return new i.e(r,2*t)}};function a(n){return n<<8&4278255360|n>>>8&16711935}var h,v={stringify:function(n){for(var t=n.words,r=n.nSigBytes,i=[],e=0;e<r;e+=2){var o=a(t[e>>>2]>>>16-e%4*8&65535);i.push(String.fromCharCode(o))}return i.join("")},parse:function(n){for(var t=n.length,r=[],e=0;e<t;e++)r[e>>>1]|=a(n.charCodeAt(e)<<16-e%2*16);return new i.e(r,2*t)}},w=s,l=r(2214),b=r(7008),d=r(670),y=r(9541),p=(h=function(n,t){return(h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}h(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),O=function(n){function t(t){var r=n.call(this,t)||this;return r.Sn=4,r.Mn=d.MD5,r.kn=1,t&&(r.Sn=void 0!==t.keySize?t.keySize:r.Sn,r.Mn=void 0!==t.Hasher?t.Hasher:r.Mn,r.kn=void 0!==t.iterations?t.iterations:r.kn),r}return p(t,n),t.prototype.compute=function(n,t){for(var r,e=new this.Mn,o=new i.e,u=o.words,f=this.Sn,c=this.kn;u.length<f;){r&&e.update(r),r=e.update(n).finalize(t),e.reset();for(var s=1;s<c;s++)r=e.finalize(r),e.reset();o.concat(r)}return o.nSigBytes=4*f,o},t.getKey=function(n,r,i){return new t(i).compute(n,r)},t}(y._)},9054:function(n,t,r){r.d(t,{M:function(){return e}});var i=r(1756);var e=function(){if("undefined"!=typeof window){var n=window.crypto||window.msCrypto;if(!n){if((0,i.w)("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return n.getRandomValues(new Uint32Array(1))[0]}}return void 0!==r.g&&r.g.crypto?function(){return r.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}()},3664:function(n,t,r){r.d(t,{K:function(){return c}});var i,e=r(1863),o=r(3354),u=r(4055),f=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),c=function(n){function t(t){var r=n.call(this,t)||this;r.Bn=1;var i=t.cipher,e=t.iv;if(4!==i.blockSize)throw new Error("In CCM, cipher block size must be 128bit");if(e&&(e.nSigBytes>13||e.nSigBytes<7))throw new Error("Byte size of iv must be between 7 and 13");return r.Nn=e||new o.e([0,0],8),r.In=15-r.Nn.nSigBytes,r}return f(t,n),t.getB0=function(n,t,r,i){if(r.nSigBytes+i.nSigBytes!==15)throw new Error("LEN(Q)+LEN(N) must be 15");var e=255&(0|(n?1:0)<<6|(t-2)/2<<3|r.nSigBytes-1),u=i.clone().concat(r);return new o.e([e<<24],1).concat(u)},t.formatAssociatedDataAndPayload=function(n,t){var r,i=n.nSigBytes;if(0===i)r=new o.e([0],0);else if(i<Math.pow(2,16)-Math.pow(2,8))r=new o.e([i<<16],2);else{if(!(i<Math.pow(2,32)))throw new Error("LEN(A) larger than 2**32-1 is not supported");r=new o.e([4294836224],2).concat(new o.e([i],4))}for(var e=Math.floor(n.nSigBytes/4),u=0;u<e;u++)r.concat(new o.e([n.words[u]],4));n.nSigBytes%4&&(r.concat(new o.e([n.words[e]],n.nSigBytes%4)),r.concat(new o.e([0],4-n.nSigBytes%4))),r.nSigBytes%16&&r.concat(new o.e([0],16-r.nSigBytes%16));var f=Math.floor(t.nSigBytes/4);for(u=0;u<f;u++)r.concat(new o.e([t.words[u]],4));return t.nSigBytes%4&&(r.concat(new o.e([t.words[f]],t.nSigBytes%4)),r.concat(new o.e([0],4-t.nSigBytes%4))),r.nSigBytes%16&&r.concat(new o.e([0],16-r.nSigBytes%16)),r},t.genCtr=function(n,t,r){if(t.nSigBytes+n!==15)throw new Error("LEN(Q)+LEN(N) must be 15");for(var i=new o.e([(n-1&7)<<24],1),e=new o.e([],0),u=Math.floor(n/4),f=0;f<u-1;f++)e.concat(new o.e([0],4));return n%4?n>4?(e.concat(new o.e([0],n%4)),e.concat(new o.e([r],4))):e.concat(new o.e([r<<32-8*n],n)):e.concat(new o.e([r],4)),i.concat(t).concat(e)},t.mac=function(n,r,i,e,f,c){var s=new n({key:r,iv:i});if(4!==s.blockSize)throw new Error("In CCM, cipher block size must be 128bit");if(i&&(i.nSigBytes>13||i.nSigBytes<7))throw new Error("Byte size of iv must be between 7 and 13");var a=i||new o.e([0,0],8),h=(null==e?void 0:e.clone())||new o.e,v=h.nSigBytes,w=(null==f?void 0:f.clone())||new o.e,l=w.nSigBytes;if(l>>>0>4294967295)throw new Error("Byte length of Payload(plainText) larger than 2^32-1 (4,294,967,295byte) is not supported at this time.");var b=15-a.nSigBytes,d=(0,u.ur)(new o.e([0,l],8),b),y=c||16,p=t.getB0(Boolean(v),y,d,a),O=t.formatAssociatedDataAndPayload(h,w),j=p.words.slice();s.encryptBlock(j,0);for(var _=O.nSigBytes/16,m=O.words,A=j,g=0;g<_;g++){var E=[m[4*g]^A[0],m[4*g+1]^A[1],m[4*g+2]^A[2],m[4*g+3]^A[3]];s.encryptBlock(E,0),A=E}var S=new o.e(A,y),M=t.genCtr(b,a,0);s.encryptBlock(M.words,0);for(g=0;g<4;g++)S.words[g]^=M.words[g];return S.clamp(),S},t.combineCipherTextAndAuthTag=function(n,t){return n.clone().concat(t)},t.splitCipherTextAndAuthTag=function(n,t){var r=t||16;return{cipherText:(0,u.z6)(n,n.nSigBytes-r),authTag:(0,u.ur)(n,r)}},t.createEncryptor=function(n){return new t.Encryptor(n)},t.createDecryptor=function(n){return new t.Decryptor(n)},t.Encryptor=function(n){function r(){return null!==n&&n.apply(this,arguments)||this}return f(r,n),r.prototype.processBlock=function(n,r){var i=this.Hn,e=i.blockSize,o=t.genCtr(this.In,this.Nn,this.Bn);i.encryptBlock(o.words,0);for(var u=0;u<e;u++)n[r+u]^=o.words[u];this.Bn++},r}(t),t.Decryptor=function(n){function r(){return null!==n&&n.apply(this,arguments)||this}return f(r,n),r.prototype.processBlock=function(n,r){var i=this.Hn,e=i.blockSize,o=t.genCtr(this.In,this.Nn,this.Bn);i.encryptBlock(o.words,0);for(var u=0;u<e;u++)n[r+u]^=o.words[u];this.Bn++},r}(t),t}(e.T)},5607:function(n,t,r){r.d(t,{V:function(){return c}});var i,e=r(1863),o=r(3354),u=r(4055),f=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),c=function(n){function t(r){var i=n.call(this,r)||this;if(i.zn=[],i.Dn=[],i.Un=[],4!==r.cipher.blockSize)throw new Error("In GCM block cipher mode, cipher block size must be 128bit");var e=r.cipher,o=r.iv,u=[0,0,0,0];return e.encryptBlock(u,0),i.zn=u,i.Dn=t.getJ0(u,null==o?void 0:o.words),i.Un=i.Dn.slice(),i}return f(t,n),t.getJ0=function(n,r){var i;if(r&&0!==r.length)if(3===r.length)i=[r[0],r[1],r[2],1];else{for(var e=r.length%4>0?4-r.length%4:0,o=r.slice(),u=0;u<e+2;u++)o.push(0);o.push(0),o.push(32*r.length),i=t.GHASH(n,o)}else i=[0,0,0,1];return i},t.inc32=function(n){var t=n.slice(),r=t[3]>>>0,i=r+1>>>0<r;if(t[3]=t[3]+1|0,i){var e=t[2]>>>0,o=e+1>>>0<e;t[2]=t[2]+1|0,o&&(t[1]=t[1]+1|0)}return t},t.mul=function(n,t){for(var r=[3774873600,0,0,0],i=[0,0,0,0],e=t.slice(),o=0;o<128;o++){(n[o>>>5]>>>31-o%32&1)>0&&(i[0]=i[0]^e[0],i[1]=i[1]^e[1],i[2]=i[2]^e[2],i[3]=i[3]^e[3]);var u=(1&e[3])>>>0,f=(1&e[0])>>>0,c=(1&e[1])>>>0,s=(1&e[2])>>>0;e[0]=e[0]>>>1,e[1]=e[1]>>>1|(f?2147483648:0),e[2]=e[2]>>>1|(c?2147483648:0),e[3]=e[3]>>>1|(s?2147483648:0),u>0&&(e[0]^=r[0],e[1]^=r[1],e[2]^=r[2],e[3]^=r[3])}return i},t.GHASH=function(n,r){if(n.length%4!=0)throw new Error("Length of 32bit word array 'H' must be multiple of 4(128bit)");if(r.length%4!=0)throw new Error("Length of 32bit word array 'X' must be multiple of 4(128bit)");for(var i=r.length,e=[0,0,0,0],o=0;o<i;o+=4)e[0]=e[0]^r[o],e[1]=e[1]^r[o+1],e[2]=e[2]^r[o+2],e[3]=e[3]^r[o+3],e=t.mul(e,n);return e},t.GCTR=function(n,r,i){if(0===i.nSigBytes)return i.clone();if(4!==r.length)throw new Error("Initial Counter Block size must be 128bit");for(var e=i.words,u=Math.ceil(i.nSigBytes/16),f=[r.slice()],c=1;c<u;c++){var s=t.inc32(f[c-1]);f.push(s)}var a=new o.e;for(c=0;c<u;c++){n.encryptBlock(f[c],0);var h=i.nSigBytes%16;if(c<u-1||0===h){var v=e[4*c]^f[c][0],w=e[4*c+1]^f[c][1],l=e[4*c+2]^f[c][2],b=e[4*c+3]^f[c][3],d=new o.e([v,w,l,b]);a.concat(d)}else{for(var y=[],p=0,O=Math.floor(h/4),j=0;j<O;j++){var _=e[4*c+j]^f[c][j];y.push(_),p+=4}var m=h%4;if(m>0){var A=e[4*c+O]<<32-8*m^f[c][O];y.push(A),p+=m}var g=new o.e(y,p);a.concat(g)}}return a.nSigBytes=i.nSigBytes,a.clamp(),a},t.mac=function(n,r,i,e,f,c){var s=new n({key:r,iv:i}),a=[0,0,0,0];s.encryptBlock(a,0);var h=t.getJ0(a,i.words),v=(null==e?void 0:e.clone())||new o.e,w=[0,8*v.nSigBytes],l=(null==f?void 0:f.clone())||new o.e,b=[0,8*l.nSigBytes],d=c||16;(0,u.I4)(v),(0,u.I4)(l);var y=v.words.concat(l.words).concat(w).concat(b),p=t.GHASH(a,y),O=t.GCTR(s,h,new o.e(p));return(0,u.z6)(O,d)},t.createEncryptor=function(n){return new t.Encryptor(n)},t.createDecryptor=function(n){return new t.Decryptor(n)},t.Encryptor=function(n){function r(){return null!==n&&n.apply(this,arguments)||this}return f(r,n),r.prototype.processBlock=function(n,r){var i=this.Hn.blockSize;this.Un=t.inc32(this.Un);for(var e=new o.e(n.slice(r,r+i)),u=t.GCTR(this.Hn,this.Un,e),f=0;f<i;f++)n[r+f]=u.words[f]},r}(t),t.Decryptor=function(n){function r(){return null!==n&&n.apply(this,arguments)||this}return f(r,n),r.prototype.processBlock=function(n,r){var i=this.Hn.blockSize;this.Un=t.inc32(this.Un);for(var e=new o.e(n.slice(r,r+i)),u=t.GCTR(this.Hn,this.Un,e),f=0;f<i;f++)n[r+f]=u.words[f]},r}(t),t}(e.T)}},t={};function r(i){var e=t[i];if(void 0!==e)return e.exports;var o=t[i]={exports:{}};return n[i](o,o.exports,r),o.exports}r.d=function(n,t){for(var i in t)r.o(t,i)&&!r.o(n,i)&&Object.defineProperty(n,i,{enumerable:!0,get:t[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"Ln",{value:!0})};var i={};return function(){r.r(i),r.d(i,{AES:function(){return A.AES},Base64:function(){return t.Base64},CBCMAC:function(){return b.CBCMAC},CipherParams:function(){return u.Q},DES:function(){return g.DES},DES3:function(){return E.DES3},EvpKDF:function(){return t.EvpKDF},GMAC:function(){return l.GMAC},Hex:function(){return t.Hex},Hmac:function(){return f.Hmac},HmacMD5:function(){return c.HmacMD5},HmacSHA1:function(){return s.HmacSHA1},HmacSHA224:function(){return a.HmacSHA224},HmacSHA256:function(){return h.HmacSHA256},HmacSHA384:function(){return v.HmacSHA384},HmacSHA512:function(){return w.HmacSHA512},Latin1:function(){return t.Latin1},MD5:function(){return d.MD5},OpenSSLKDF:function(){return t.OpenSSLKDF},PBKDF2:function(){return t.PBKDF2},PasswordBasedCipher:function(){return o.E},RC4:function(){return k.RC4},RC4Drop:function(){return H.RC4Drop},RIPEMD160:function(){return S.RIPEMD160},Rabbit:function(){return M.Rabbit},SHA1:function(){return y.SHA1},SHA224:function(){return p.SHA224},SHA256:function(){return O.SHA256},SHA3:function(){return m.SHA3},SHA384:function(){return j.SHA384},SHA512:function(){return _.SHA512},SerializableCipher:function(){return e.D},Utf16:function(){return t.Utf16},Utf16BE:function(){return t.Utf16BE},Utf16LE:function(){return t.Utf16LE},Utf8:function(){return t.Utf8},Word32Array:function(){return t.Word32Array},Word64:function(){return t.Word64},Word64Array:function(){return t.Word64Array},formatter:function(){return Y},mode:function(){return Z},pad:function(){return J}});var n,t=r(2688),e=r(9109),o=r(5693),u=r(2505),f=r(6367),c=r(3027),s=r(149),a=r(4105),h=r(980),v=r(5838),w=r(9902),l=r(7753),b=r(3967),d=r(670),y=r(3173),p=r(766),O=r(5561),j=r(6324),_=r(7491),m=r(3408),A=r(9691),g=r(9910),E=r(6739),S=r(7104),M=r(5187),k=r(4615),H=r(9639),C=r(4344),B=r(1863),N=(n=function(t,r){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(t,r)},function(t,r){function i(){this.constructor=t}n(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}),I=function(n){function t(t){var r=n.call(this,t)||this;return r.Cn=[],r}return N(t,n),t.prototype.generateKeyStreamAndEncrypt=function(n,t,r,i){var e,o=this.ln;o?(e=o.words.slice(0),this.ln=void 0):e=this.Cn,i.encryptBlock(e,0);for(var u=0;u<r;u++)n[t+u]^=e[u]},t.createEncryptor=function(n){return new t.Encryptor(n)},t.createDecryptor=function(n){return new t.Decryptor(n)},t.Encryptor=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return N(t,n),t.prototype.processBlock=function(n,t){this.generateKeyStreamAndEncrypt(n,t,this.Hn.blockSize,this.Hn),this.Cn=n.slice(t,t+this.Hn.blockSize)},t}(t),t.Decryptor=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return N(t,n),t.prototype.processBlock=function(n,t){var r=n.slice(t,t+this.Hn.blockSize);this.generateKeyStreamAndEncrypt(n,t,this.Hn.blockSize,this.Hn),this.Cn=r},t}(t),t}(B.T),z=function(){var n=function(t,r){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(t,r)};return function(t,r){function i(){this.constructor=t}n(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),D=function(n){function t(t){var r=n.call(this,t)||this;return r.Fn=[],r}return z(t,n),t.createEncryptor=function(n){return new t.Encryptor(n)},t.createDecryptor=function(n){return new t.Decryptor(n)},t.Encryptor=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return z(t,n),t.prototype.processBlock=function(n,t){var r=this.Hn,i=r.blockSize,e=this.ln,o=this.Fn;e&&(o=this.Fn=e.words.slice(0),this.ln=void 0);var u=o.slice(0);r.encryptBlock(u,0),o[i-1]=o[i-1]+1|0;for(var f=0;f<i;f++)n[t+f]^=u[f]},t}(t),t.Decryptor=t.Encryptor,t}(B.T),U=function(){var n=function(t,r){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(t,r)};return function(t,r){function i(){this.constructor=t}n(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),L=function(n){function t(t){return n.call(this,t)||this}return U(t,n),t.createEncryptor=function(n){return new t.Encryptor(n)},t.createDecryptor=function(n){return new t.Decryptor(n)},t.Encryptor=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return U(t,n),t.prototype.processBlock=function(n,t){this.Hn.encryptBlock(n,t)},t}(t),t.Decryptor=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return U(t,n),t.prototype.processBlock=function(n,t){this.Hn.decryptBlock(n,t)},t}(t),t}(B.T),F=function(){var n=function(t,r){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(t,r)};return function(t,r){function i(){this.constructor=t}n(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),x=function(n){function t(t){var r=n.call(this,t)||this;return r.xn=[],r}return F(t,n),t.createEncryptor=function(n){return new t.Encryptor(n)},t.createDecryptor=function(n){return new t.Decryptor(n)},t.Encryptor=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return F(t,n),t.prototype.processBlock=function(n,t){var r=this.Hn,i=r.blockSize,e=this.ln,o=this.xn;e&&(o=this.xn=e.words.slice(0),this.ln=void 0),r.encryptBlock(o,0);for(var u=0;u<i;u++)n[t+u]^=o[u]},t}(t),t.Decryptor=t.Encryptor,t}(B.T),P=r(5607),R=r(3664);var T={pad:function(n,t){var r=n.nSigBytes,i=4*t,e=i-r%i,o=r+e-1;n.clamp(),n.words[o>>>2]|=e<<24-o%4*8,n.nSigBytes+=e},unpad:function(n){var t=255&n.words[n.nSigBytes-1>>>2];n.nSigBytes-=t}},K=r(3354);var W={pad:function(n,t){var r=4*t,i=r-n.nSigBytes%r;n.concat(K.e.random(i-1)).concat(new K.e([i<<24],1))},unpad:function(n){var t=255&n.words[n.nSigBytes-1>>>2];n.nSigBytes-=t}};var G={pad:function(n,t){var r=4*t;n.clamp(),n.nSigBytes+=r-(n.nSigBytes%r||r)},unpad:function(n){for(var t=n.words,r=n.nSigBytes-1;r>=0;r--)if(t[r>>>2]>>>24-r%4*8&255){n.nSigBytes=r+1;break}}};var q={pad:function(n,t){n.concat(new K.e([2147483648],1)),G.pad(n,t)},unpad:function(n){G.unpad(n),n.nSigBytes-=1}},Q=r(7919);var X={pad:function(n,t){},unpad:function(n){}},V=r(1232),Z={CBC:C.n,CFB:I,CTR:D,ECB:L,OFB:x,GCM:P.V,CCM:R.K},J={AnsiX923:T,ISO10126:W,ISO97971:q,Pkcs7:Q.l,NoPadding:X,Zero:G},Y={OpenSSLFormatter:V.w}}(),i}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/lib.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var r=t();for(var i in n.JsCrypto=n.JsCrypto||{},r)n.JsCrypto[i]=r[i]}}(this,(function(){return function(){"use strict";var n={6367:function(n,t,r){r.d(t,{Hmac:function(){return e}});var i=r(4768),e=function(){function n(n,t){this.t=n,"string"==typeof t&&(t=i.d.parse(t));var r=n.blockSize,e=4*r;t.nSigBytes>e&&(t=n.finalize(t)),t.clamp();for(var o=this.i=t.clone(),u=this.u=t.clone(),f=o.words,c=u.words,a=0;a<r;a++)f[a]^=1549556828,c[a]^=909522486;u.nSigBytes=e,o.nSigBytes=e,this.reset()}return n.prototype.reset=function(){this.t.reset(),this.t.update(this.u)},n.prototype.update=function(n){return this.t.update(n),this},n.prototype.finalize=function(n){var t=this.t.finalize(n);return this.t.reset(),this.t.finalize(this.i.clone().concat(t))},n}()},670:function(n,t,r){r.d(t,{MD5:function(){return v}});var i,e=r(3354),o=r(1868),u=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),f=[];function c(n,t,r,i,e,o,u){var f=n+(t&r|~t&i)+e+u;return(f<<o|f>>>32-o)+t}function a(n,t,r,i,e,o,u){var f=n+(t&i|r&~i)+e+u;return(f<<o|f>>>32-o)+t}function s(n,t,r,i,e,o,u){var f=n+(t^r^i)+e+u;return(f<<o|f>>>32-o)+t}function h(n,t,r,i,e,o,u){var f=n+(r^(t|~i))+e+u;return(f<<o|f>>>32-o)+t}!function(){for(var n=0;n<64;n++)f[n]=4294967296*Math.abs(Math.sin(n+1))|0}();var v=function(n){function t(t){var r=n.call(this,t)||this;return r.h=new e.e([1732584193,4023233417,2562383102,271733878]),t&&void 0!==t.hash&&(r.h=t.hash.clone()),r}return u(t,n),t.prototype.v=function(){this.h=new e.e([1732584193,4023233417,2562383102,271733878])},t.prototype.l=function(n,t){for(var r=0;r<16;r++){var i=t+r,e=n[i];n[i]=16711935&(e<<8|e>>>24)|4278255360&(e<<24|e>>>8)}var o=this.h.words,u=n[t],v=n[t+1],w=n[t+2],d=n[t+3],l=n[t+4],b=n[t+5],y=n[t+6],p=n[t+7],m=n[t+8],g=n[t+9],j=n[t+10],O=n[t+11],A=n[t+12],_=n[t+13],E=n[t+14],M=n[t+15],S=o[0],U=o[1],I=o[2],x=o[3];S=c(S,U,I,x,u,7,f[0]),x=c(x,S,U,I,v,12,f[1]),I=c(I,x,S,U,w,17,f[2]),U=c(U,I,x,S,d,22,f[3]),S=c(S,U,I,x,l,7,f[4]),x=c(x,S,U,I,b,12,f[5]),I=c(I,x,S,U,y,17,f[6]),U=c(U,I,x,S,p,22,f[7]),S=c(S,U,I,x,m,7,f[8]),x=c(x,S,U,I,g,12,f[9]),I=c(I,x,S,U,j,17,f[10]),U=c(U,I,x,S,O,22,f[11]),S=c(S,U,I,x,A,7,f[12]),x=c(x,S,U,I,_,12,f[13]),I=c(I,x,S,U,E,17,f[14]),S=a(S,U=c(U,I,x,S,M,22,f[15]),I,x,v,5,f[16]),x=a(x,S,U,I,y,9,f[17]),I=a(I,x,S,U,O,14,f[18]),U=a(U,I,x,S,u,20,f[19]),S=a(S,U,I,x,b,5,f[20]),x=a(x,S,U,I,j,9,f[21]),I=a(I,x,S,U,M,14,f[22]),U=a(U,I,x,S,l,20,f[23]),S=a(S,U,I,x,g,5,f[24]),x=a(x,S,U,I,E,9,f[25]),I=a(I,x,S,U,d,14,f[26]),U=a(U,I,x,S,m,20,f[27]),S=a(S,U,I,x,_,5,f[28]),x=a(x,S,U,I,w,9,f[29]),I=a(I,x,S,U,p,14,f[30]),S=s(S,U=a(U,I,x,S,A,20,f[31]),I,x,b,4,f[32]),x=s(x,S,U,I,m,11,f[33]),I=s(I,x,S,U,O,16,f[34]),U=s(U,I,x,S,E,23,f[35]),S=s(S,U,I,x,v,4,f[36]),x=s(x,S,U,I,l,11,f[37]),I=s(I,x,S,U,p,16,f[38]),U=s(U,I,x,S,j,23,f[39]),S=s(S,U,I,x,_,4,f[40]),x=s(x,S,U,I,u,11,f[41]),I=s(I,x,S,U,d,16,f[42]),U=s(U,I,x,S,y,23,f[43]),S=s(S,U,I,x,g,4,f[44]),x=s(x,S,U,I,A,11,f[45]),I=s(I,x,S,U,M,16,f[46]),S=h(S,U=s(U,I,x,S,w,23,f[47]),I,x,u,6,f[48]),x=h(x,S,U,I,p,10,f[49]),I=h(I,x,S,U,E,15,f[50]),U=h(U,I,x,S,b,21,f[51]),S=h(S,U,I,x,A,6,f[52]),x=h(x,S,U,I,d,10,f[53]),I=h(I,x,S,U,j,15,f[54]),U=h(U,I,x,S,v,21,f[55]),S=h(S,U,I,x,m,6,f[56]),x=h(x,S,U,I,M,10,f[57]),I=h(I,x,S,U,y,15,f[58]),U=h(U,I,x,S,_,21,f[59]),S=h(S,U,I,x,l,6,f[60]),x=h(x,S,U,I,O,10,f[61]),I=h(I,x,S,U,w,15,f[62]),U=h(U,I,x,S,g,21,f[63]),o[0]=o[0]+S|0,o[1]=o[1]+U|0,o[2]=o[2]+I|0,o[3]=o[3]+x|0},t.prototype.j=function(){var n=this.O,t=n.words,r=8*this.A,i=8*n.nSigBytes;t[i>>>5]|=128<<24-i%32;var e=Math.floor(r/4294967296),o=r;t[15+(i+64>>>9<<4)]=16711935&(e<<8|e>>>24)|4278255360&(e<<24|e>>>8),t[14+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),n.nSigBytes=4*(t.length+1),this.S();for(var u=this.h,f=u.words,c=0;c<4;c++){var a=f[c];f[c]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}return u},t.prototype.clone=function(){return new t({hash:this.h,blockSize:this.U,data:this.O,nBytes:this.A})},t.hash=function(n){return(new t).finalize(n)},t}(o.P)},5561:function(n,t,r){r.d(t,{SHA256:function(){return v}});var i,e=r(1868),o=r(3354),u=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),f=[],c=[];function a(n){for(var t=Math.sqrt(n),r=2;r<=t;r++)if(!(n%r))return!1;return!0}function s(n){return 4294967296*(n-(0|n))|0}!function(){for(var n=2,t=0;t<64;)a(n)&&(t<8&&(f[t]=s(Math.pow(n,.5))),c[t]=s(Math.pow(n,1/3)),t++),n++}();var h=[],v=function(n){function t(t){var r=n.call(this,t)||this;return r.h=new o.e(f.slice(0)),r.I=t,t&&void 0!==t.hash&&(r.h=t.hash.clone()),r}return u(t,n),t.prototype.v=function(){this.h=new o.e(f.slice(0))},t.prototype.l=function(n,t){for(var r=this.h.words,i=r[0],e=r[1],o=r[2],u=r[3],f=r[4],a=r[5],s=r[6],v=r[7],w=0;w<64;w++){if(w<16)h[w]=0|n[t+w];else{var d=h[w-15],l=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,b=h[w-2],y=(b<<15|b>>>17)^(b<<13|b>>>19)^b>>>10;h[w]=l+h[w-7]+y+h[w-16]}var p=i&e^i&o^e&o,m=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),g=v+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(f&a^~f&s)+c[w]+h[w];v=s,s=a,a=f,f=u+g|0,u=o,o=e,e=i,i=g+(m+p)|0}r[0]=r[0]+i|0,r[1]=r[1]+e|0,r[2]=r[2]+o|0,r[3]=r[3]+u|0,r[4]=r[4]+f|0,r[5]=r[5]+a|0,r[6]=r[6]+s|0,r[7]=r[7]+v|0},t.prototype.j=function(){var n=this.O.words,t=8*this.A,r=8*this.O.nSigBytes;return n[r>>>5]|=128<<24-r%32,n[14+(r+64>>>9<<4)]=Math.floor(t/4294967296),n[15+(r+64>>>9<<4)]=t,this.O.nSigBytes=4*n.length,this.S(),this.h},t.prototype.clone=function(){return new t({hash:this.h,blockSize:this.U,data:this.O,nBytes:this.A})},t.hash=function(n,r){return new t(r).finalize(n)},t}(e.P)},3354:function(n,t,r){r.d(t,{e:function(){return o}});var i=r(5720),e=r(9054),o=function(){function n(t,r){if(Array.isArray(t)||!t)return this.N=Array.isArray(t)?t:[],void(this.B="number"==typeof r?r:4*this.N.length);if(t instanceof n)return this.N=t.words.slice(),void(this.B=t.nSigBytes);var i;try{t instanceof ArrayBuffer?i=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!i)throw new Error("Invalid argument");for(var e=i.byteLength,o=[],u=0;u<e;u++)o[u>>>2]|=i[u]<<24-u%4*8;this.N=o,this.B=e}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.B},set:function(n){this.B=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.N},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):i.p.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this.N,t=this.B,r=new Uint8Array(t),i=0;i<t;i++)r[i]=n[i>>>2]>>>24-i%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.B%4)for(var i=0;i<r;i++){var e=t[i>>>2]>>>24-i%4*8&255;this.N[this.B+i>>>2]|=e<<24-(this.B+i)%4*8}else for(i=0;i<r;i+=4)this.N[this.B+i>>>2]=t[i>>>2];return this.B+=r,this},n.prototype.clamp=function(){var n=this.B;this.N[n>>>2]&=4294967295<<32-n%4*8,this.N.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.N.slice(),this.B)},n.random=function(t){for(var r=[],i=0;i<t;i+=4)r.push((0,e.M)());return new n(r,t)},n}()},6957:function(n,t,r){r.d(t,{r:function(){return o},m:function(){return u}});var i=r(5720),e=r(3354),o=function(){function n(n,t){this.high=n,this.low=t}return n.prototype.clone=function(){return new n(this.high,this.low)},n}(),u=function(){function n(n,t){this.N=n||[],this.B="number"==typeof t?t:8*this.N.length}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.B},set:function(n){this.B=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.N},enumerable:!1,configurable:!0}),n.prototype.to32=function(){for(var n=[],t=0;t<this.N.length;t++){var r=this.N[t];n.push(r.high),n.push(r.low)}return new e.e(n,this.B)},n.prototype.toString=function(n){return n?n.stringify(this.to32()):i.p.stringify(this.to32())},n.prototype.clone=function(){for(var t=this.N.slice(),r=0;r<t.length;r++)t[r]=t[r].clone();return new n(t,this.B)},n}()},7211:function(n,t,r){r.d(t,{C:function(){return o}});var i=r(3354),e=r(4768),o=function(){function n(n){this.F=0,this.U=0,this.I=n,this.O=n&&void 0!==n.data?n.data.clone():new i.e,this.A=n&&"number"==typeof n.nBytes?n.nBytes:0}return Object.defineProperty(n.prototype,"blockSize",{get:function(){return this.U},enumerable:!1,configurable:!0}),n.prototype.reset=function(n,t){this.O=void 0!==n?n.clone():new i.e,this.A="number"==typeof t?t:0},n.prototype.k=function(n){var t="string"==typeof n?e.d.parse(n):n;this.O.concat(t),this.A+=t.nSigBytes},n.prototype.S=function(n){var t,r=this.O.words,e=this.O.nSigBytes,o=this.U,u=e/(4*this.U),f=(u=n?Math.ceil(u):Math.max((0|u)-this.F,0))*o,c=Math.min(4*f,e);if(f){for(var a=0;a<f;a+=o)this.l(r,a);t=r.splice(0,f),this.O.nSigBytes-=c}return new i.e(t,c)},n.prototype.l=function(n,t){throw new Error("Not implemented")},n}()},1868:function(n,t,r){r.d(t,{P:function(){return u}});var i,e=r(7211),o=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),u=function(n){function t(t){var r=n.call(this,t)||this;return r.U=16,r.I=t,t&&"number"==typeof t.blockSize&&(r.U=t.blockSize),r.reset(t?t.data:void 0,t?t.nBytes:void 0),r}return o(t,n),Object.defineProperty(t.prototype,"blockSize",{get:function(){return this.U},enumerable:!1,configurable:!0}),t.prototype.reset=function(t,r){n.prototype.reset.call(this,t,r),this.v()},t.prototype.update=function(n){return this.k(n),this.S(),this},t.prototype.finalize=function(n){return n&&this.k(n),this.j()},t.prototype.v=function(){throw new Error("Not implemented")},t.prototype.j=function(){throw new Error("Not implemented")},t}(e.C)},2505:function(n,t,r){r.d(t,{Q:function(){return e}});var i=r(1232),e=function(){function n(n){this.formatter=i.w,n&&(this.cipherText=n.cipherText,this.key=n.key,this.iv=n.iv,this.salt=n.salt,this.Algorithm=n.Algorithm,this.mode=n.mode,this.padding=n.padding,this.blockSize=n.blockSize,this.formatter=n.formatter||i.w)}return n.prototype.toString=function(n){return(n||this.formatter).stringify(this)},n}()},1232:function(n,t,r){r.d(t,{w:function(){return u}});var i=r(2505),e=r(3354),o=r(1773),u={stringify:function(n){var t=n.cipherText,r=n.salt;return t?r?new e.e([1398893684,1701076831]).concat(r).concat(t).toString(o.D):t.toString(o.D):""},parse:function(n){var t,r=o.D.parse(n),u=r.words;return 1398893684===u[0]&&1701076831===u[1]&&(t=new e.e(u.slice(2,4)),u.splice(0,4),r.nSigBytes-=16),new i.Q({cipherText:r,salt:t})}}},2214:function(n,t,r){r.d(t,{s:function(){return f}});var i=r(3354),e=r(2505),o=r(7008),u=function(){return(u=Object.assign||function(n){for(var t,r=1,i=arguments.length;r<i;r++)for(var e in t=arguments[r])Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}).apply(this,arguments)},f={execute:function(n,t,r,f,c){f||(f=i.e.random(8));var a=c&&c.kdfModule||o.E,s=c?{Hasher:c.kdfHasher,iterations:c.kdfIterations}:{},h=a.getKey(n,f,u(u({},s),{keySize:t+r})),v=new i.e(h.words.slice(t),4*r);return h.nSigBytes=4*t,new e.Q({key:h,iv:v,salt:f})}}},7008:function(n,t,r){r.d(t,{E:function(){return a}});var i,e=r(5561),o=r(6367),u=r(3354),f=r(9541),c=(i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),a=function(n){function t(t){var r=n.call(this,t)||this;return r.H=4,r.T=e.SHA256,r.K=1e4,t&&(r.H=void 0!==t.keySize?t.keySize:r.H,r.T=void 0!==t.Hasher?t.Hasher:r.T,r.K=void 0!==t.iterations?t.iterations:r.K),r}return c(t,n),t.prototype.compute=function(n,t){for(var r=new o.Hmac(new this.T,n),i=new u.e,e=new u.e([1]),f=i.words,c=e.words,a=this.H,s=this.K;f.length<a;){var h=r.update(t).finalize(e);r.reset();for(var v=h.words,w=v.length,d=h,l=1;l<s;l++){d=r.finalize(d),r.reset();for(var b=d.words,y=0;y<w;y++)v[y]^=b[y]}i.concat(h),c[0]++}return i.nSigBytes=4*a,i},t.getKey=function(n,r,i){return new t(i).compute(n,r)},t}(f._)},9541:function(n,t,r){r.d(t,{_:function(){return i}});var i=function(){function n(n){this.I=n}return n.prototype.compute=function(n,t){throw new Error("Not implemented")},n.getKey=function(n,t,r){throw new Error("Not implemented")},n}()},1756:function(n,t,r){r.d(t,{w:function(){return u}});var i,e="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(i=parseInt((/msie (\d+)/.exec(e)||[])[1],10),isNaN(i)?(i=parseInt((/trident\/.*; rv:(\d+)/.exec(e)||[])[1],10),!isNaN(i)&&i):i);function u(n,t){return!1!==o&&(!t||("<"===n?o<t:"<="===n?o<=t:">"===n?o>t:">="===n?o>=t:o===t))}},1773:function(n,t,r){r.d(t,{D:function(){return f}});for(var i=r(3354),e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=[],u=0;u<e.length;u++)o[e.charCodeAt(u)]=u;var f={stringify:function(n){var t=n.words,r=n.nSigBytes;n.clamp();for(var i=[],o=0;o<r;o+=3)for(var u=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,f=0;f<4&&o+.75*f<r;f++)i.push(e.charAt(u>>>6*(3-f)&63));var c=e.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(n){var t=n.length,r=e.charAt(64);if(r){var u=n.indexOf(r);-1!==u&&(t=u)}for(var f=[],c=0,a=0;a<t;a++)if(a%4){var s=o[n.charCodeAt(a-1)]<<a%4*2|o[n.charCodeAt(a)]>>>6-a%4*2;f[c>>>2]|=s<<24-c%4*8,c++}return new i.e(f,c)}}},5720:function(n,t,r){r.d(t,{p:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var r=[],e=0;e<t;e+=2)r[e>>>3]|=parseInt(n.substr(e,2),16)<<24-e%8*4;return new i.e(r,t/2)}}},8702:function(n,t,r){r.d(t,{m:function(){return e}});var i=r(3354),e={stringify:function(n){for(var t=n.nSigBytes,r=n.words,i=[],e=0;e<t;e++){var o=r[e>>>2]>>>24-e%4*8&255;i.push(String.fromCharCode(o))}return i.join("")},parse:function(n){for(var t=n.length,r=[],e=0;e<t;e++)r[e>>>2]|=(255&n.charCodeAt(e))<<24-e%4*8;return new i.e(r,t)}}},4768:function(n,t,r){r.d(t,{d:function(){return e}});var i=r(8702),e={stringify:function(n){try{return decodeURIComponent(escape(i.m.stringify(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return i.m.parse(unescape(encodeURIComponent(n)))}}},9054:function(n,t,r){r.d(t,{M:function(){return e}});var i=r(1756);var e=function(){if("undefined"!=typeof window){var n=window.crypto||window.msCrypto;if(!n){if((0,i.w)("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return n.getRandomValues(new Uint32Array(1))[0]}}return void 0!==r.g&&r.g.crypto?function(){return r.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}()}},t={};function r(i){var e=t[i];if(void 0!==e)return e.exports;var o=t[i]={exports:{}};return n[i](o,o.exports,r),o.exports}r.d=function(n,t){for(var i in t)r.o(t,i)&&!r.o(n,i)&&Object.defineProperty(n,i,{enumerable:!0,get:t[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"L",{value:!0})};var i={};return function(){r.r(i),r.d(i,{Base64:function(){return u.D},EvpKDF:function(){return g},Hex:function(){return a.p},Latin1:function(){return c.m},OpenSSLKDF:function(){return l.s},PBKDF2:function(){return b.E},Utf16:function(){return d},Utf16BE:function(){return s},Utf16LE:function(){return w},Utf8:function(){return f.d},Word32Array:function(){return t.e},Word64:function(){return e.r},Word64Array:function(){return e.m},isIE:function(){return o.w},random:function(){return n.M}});var n=r(9054),t=r(3354),e=r(6957),o=r(1756),u=r(1773),f=r(4768),c=r(8702),a=r(5720),s={stringify:function(n){for(var t=n.words,r=n.nSigBytes,i=[],e=0;e<r;e+=2){var o=t[e>>>2]>>>16-e%4*8&65535;i.push(String.fromCharCode(o))}return i.join("")},parse:function(n){for(var r=n.length,i=[],e=0;e<r;e++)i[e>>>1]|=n.charCodeAt(e)<<16-e%2*16;return new t.e(i,2*r)}};function h(n){return n<<8&4278255360|n>>>8&16711935}var v,w={stringify:function(n){for(var t=n.words,r=n.nSigBytes,i=[],e=0;e<r;e+=2){var o=h(t[e>>>2]>>>16-e%4*8&65535);i.push(String.fromCharCode(o))}return i.join("")},parse:function(n){for(var r=n.length,i=[],e=0;e<r;e++)i[e>>>1]|=h(n.charCodeAt(e)<<16-e%2*16);return new t.e(i,2*r)}},d=s,l=r(2214),b=r(7008),y=r(670),p=r(9541),m=(v=function(n,t){return(v=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}v(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),g=function(n){function r(t){var r=n.call(this,t)||this;return r.H=4,r.T=y.MD5,r.K=1,t&&(r.H=void 0!==t.keySize?t.keySize:r.H,r.T=void 0!==t.Hasher?t.Hasher:r.T,r.K=void 0!==t.iterations?t.iterations:r.K),r}return m(r,n),r.prototype.compute=function(n,r){for(var i,e=new this.T,o=new t.e,u=o.words,f=this.H,c=this.K;u.length<f;){i&&e.update(i),i=e.update(n).finalize(r),e.reset();for(var a=1;a<c;a++)i=e.finalize(i),e.reset();o.concat(i)}return o.nSigBytes=4*f,o},r.getKey=function(n,t,i){return new r(i).compute(n,t)},r}(p._)}(),i}()})); | |
| \ No newline at end of file | ... | ... |
| 1 | +import type { IEncoder } from "./type"; | |
| 2 | +declare type ByteArray = ArrayBuffer | Uint8Array | Int8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array; | |
| 3 | +/** | |
| 4 | + * An array of 32bit words | |
| 5 | + */ | |
| 6 | +export declare class Word32Array { | |
| 7 | + private readonly _words; | |
| 8 | + private _nSignificantBytes; | |
| 9 | + /** | |
| 10 | + * Initializes a newly created word array. | |
| 11 | + * | |
| 12 | + * ByteArray Support thanks to | |
| 13 | + * https://github.com/entronad/crypto-es/blob/master/lib/core.js | |
| 14 | + * MIT License Copyright(c) LIN Chen | |
| 15 | + * | |
| 16 | + * @param {Array} words (Optional) An array of 32-bit words. | |
| 17 | + * @param {number} nSignificantBytes (Optional) The number of significant bytes in the words. | |
| 18 | + * @example | |
| 19 | + * var words = new Word32Array(); | |
| 20 | + * var words = new Word32Array([0x00010203, 0x04050607]); | |
| 21 | + * var words = new Word32Array([0x00010203, 0x04050607], 6); | |
| 22 | + * // Cloning wordArray can be done like below. | |
| 23 | + * var clone = (new Word32Array([0x00010203, 0x04050607])).clone(); | |
| 24 | + * // or | |
| 25 | + * var clone = new Word32Array(new Word32Array([0x00010203, 0x04050607])); | |
| 26 | + */ | |
| 27 | + constructor(words?: number[] | Word32Array | ByteArray | unknown, nSignificantBytes?: number); | |
| 28 | + get nSigBytes(): number; | |
| 29 | + /** | |
| 30 | + * Set significant bytes | |
| 31 | + * @param {number} n - significant bytes | |
| 32 | + */ | |
| 33 | + set nSigBytes(n: number); | |
| 34 | + /** | |
| 35 | + * Get raw reference of internal words. | |
| 36 | + * Modification of this raw array will affect internal words. | |
| 37 | + */ | |
| 38 | + get words(): number[]; | |
| 39 | + /** | |
| 40 | + * Converts this word array to a string. | |
| 41 | + * | |
| 42 | + * @param {IEncoder?} encoder The encoding strategy to use. Default: CryptoJS.enc.Hex | |
| 43 | + * @return {string} The stringified word array. | |
| 44 | + * @example | |
| 45 | + * var string = wordArray + ''; | |
| 46 | + * var string = wordArray.toString(); | |
| 47 | + * var string = wordArray.toString(Utf8); | |
| 48 | + */ | |
| 49 | + toString(encoder?: IEncoder): string; | |
| 50 | + /** | |
| 51 | + * Converts this 32bit word array to Uint8Array | |
| 52 | + * | |
| 53 | + * @return {Uint8Array} Unsigned int 8bit array | |
| 54 | + * @example | |
| 55 | + * var word = new Word32Array([0x00102030]); | |
| 56 | + * var uint8 = word.toUint8Array(); // Uint8Array(4) [ 0, 16, 32, 48 ] | |
| 57 | + */ | |
| 58 | + toUint8Array(): Uint8Array; | |
| 59 | + /** | |
| 60 | + * Concatenates a word array to this word array. | |
| 61 | + * | |
| 62 | + * @param {Word32Array} w The word array to append. | |
| 63 | + * @return {Word32Array} This word array. | |
| 64 | + * @example | |
| 65 | + * wordArray1.concat(wordArray2); | |
| 66 | + */ | |
| 67 | + concat(w: Word32Array): this; | |
| 68 | + /** | |
| 69 | + * Removes insignificant bits. | |
| 70 | + * | |
| 71 | + * @example | |
| 72 | + * wordArray.clamp(); | |
| 73 | + */ | |
| 74 | + clamp(): void; | |
| 75 | + /** | |
| 76 | + * Creates a copy of this word array. | |
| 77 | + * | |
| 78 | + * @return {Word32Array} The clone. | |
| 79 | + * @example | |
| 80 | + * var clone = word32Array.clone(); | |
| 81 | + */ | |
| 82 | + clone(): Word32Array; | |
| 83 | + /** | |
| 84 | + * Creates a word array filled with random bytes. | |
| 85 | + * | |
| 86 | + * @param {number} nBytes The number of random bytes to generate. | |
| 87 | + * @return {Word32Array} The random word array. | |
| 88 | + * @static | |
| 89 | + * @example | |
| 90 | + * var wordArray = Word32Array.random(16); | |
| 91 | + */ | |
| 92 | + static random(nBytes: number): Word32Array; | |
| 93 | +} | |
| 94 | +export {}; | ... | ... |
| 1 | +import type { IEncoder } from "./type"; | |
| 2 | +import { Word32Array } from "./Word32Array"; | |
| 3 | +export declare class Word64 { | |
| 4 | + high: number; | |
| 5 | + low: number; | |
| 6 | + constructor(high: number, low: number); | |
| 7 | + clone(): Word64; | |
| 8 | +} | |
| 9 | +/** | |
| 10 | + * An array of 64bit words | |
| 11 | + */ | |
| 12 | +export declare class Word64Array { | |
| 13 | + private readonly _words; | |
| 14 | + private _nSignificantBytes; | |
| 15 | + /** | |
| 16 | + * Initializes a newly created word array. | |
| 17 | + * | |
| 18 | + * @param {Array} words (Optional) An array of 64-bit words. | |
| 19 | + * @param {number} nSignificantBytes (Optional) The number of significant bytes in the words. | |
| 20 | + * | |
| 21 | + * @example | |
| 22 | + * var wordArray = new Word64Array(); | |
| 23 | + * var wordArray = new Word64Array([new Word64(0x00010203, 0x04050607)]); | |
| 24 | + * var wordArray = new Word46Array([new Word64(0x00010203, 0x04050607)], 6); | |
| 25 | + */ | |
| 26 | + constructor(words?: Word64[], nSignificantBytes?: number); | |
| 27 | + get nSigBytes(): number; | |
| 28 | + /** | |
| 29 | + * Set significant bytes | |
| 30 | + * @param {number} n - significant bytes | |
| 31 | + */ | |
| 32 | + set nSigBytes(n: number); | |
| 33 | + /** | |
| 34 | + * Get raw reference of internal words. | |
| 35 | + * Modification of this raw array will affect internal words. | |
| 36 | + */ | |
| 37 | + get words(): Word64[]; | |
| 38 | + /** | |
| 39 | + * Converts this 64-bit word array to a 32-bit word array. | |
| 40 | + * | |
| 41 | + * @return {Word32Array} This word array's data as a 32-bit word array. | |
| 42 | + * | |
| 43 | + * @example | |
| 44 | + * | |
| 45 | + * var x32WordArray = x64WordArray.toX32(); | |
| 46 | + */ | |
| 47 | + to32(): Word32Array; | |
| 48 | + /** | |
| 49 | + * Converts this word array to a string. | |
| 50 | + * | |
| 51 | + * @param {IEncoder?} encoder The encoding strategy to use. Default: CryptoJS.enc.Hex | |
| 52 | + * @return {string} The stringified word array. | |
| 53 | + * @example | |
| 54 | + * var string = wordArray + ''; | |
| 55 | + * var string = wordArray.toString(); | |
| 56 | + * var string = wordArray.toString(Utf8); | |
| 57 | + */ | |
| 58 | + toString(encoder?: IEncoder): string; | |
| 59 | + /** | |
| 60 | + * Creates a copy of this word array. | |
| 61 | + * | |
| 62 | + * @return {Word64Array} The clone. | |
| 63 | + * @example | |
| 64 | + * var clone = wordArray.clone(); | |
| 65 | + */ | |
| 66 | + clone(): Word64Array; | |
| 67 | +} | ... | ... |
| 1 | +import { Word32Array } from "../Word32Array"; | |
| 2 | +export interface BufferedBlockAlgorithmProps { | |
| 3 | + data: Word32Array; | |
| 4 | + nBytes: number; | |
| 5 | +} | |
| 6 | +export declare class BufferedBlockAlgorithm { | |
| 7 | + protected _props?: Partial<BufferedBlockAlgorithmProps>; | |
| 8 | + protected _data: Word32Array; | |
| 9 | + protected _nBytes: number; | |
| 10 | + protected _minBufferSize: number; | |
| 11 | + protected _blockSize: number; | |
| 12 | + constructor(props?: Partial<BufferedBlockAlgorithmProps>); | |
| 13 | + get blockSize(): number; | |
| 14 | + /** | |
| 15 | + * Resets this block algorithm's data buffer to its initial state. | |
| 16 | + * | |
| 17 | + * @example | |
| 18 | + * bufferedBlockAlgorithm.reset(); | |
| 19 | + */ | |
| 20 | + reset(data?: Word32Array, nBytes?: number): void; | |
| 21 | + /** | |
| 22 | + * Adds new data to this block algorithm's buffer. | |
| 23 | + * | |
| 24 | + * @param {Word32Array|string} data The data to append. Strings are converted to a WordArray using UTF-8. | |
| 25 | + * @example | |
| 26 | + * bufferedBlockAlgorithm.append('data'); | |
| 27 | + * bufferedBlockAlgorithm.append(wordArray); | |
| 28 | + */ | |
| 29 | + protected _append(data: Word32Array | string): void; | |
| 30 | + /** | |
| 31 | + * Processes available data blocks. | |
| 32 | + * This method invokes doProcessBlock(offset), which must be implemented by a concrete subtype. | |
| 33 | + * | |
| 34 | + * @param {boolean?} doFlush Whether all blocks and partial blocks should be processed. | |
| 35 | + * @return {Word32Array} The processed data. | |
| 36 | + * @example | |
| 37 | + * var processedData = bufferedBlockAlgorithm.process(); | |
| 38 | + * var processedData = bufferedBlockAlgorithm.process(!!'flush'); | |
| 39 | + */ | |
| 40 | + protected _process(doFlush?: boolean): Word32Array; | |
| 41 | + /** | |
| 42 | + * @abstract | |
| 43 | + */ | |
| 44 | + protected _doProcessBlock(words: number[], offset: number): void; | |
| 45 | +} | ... | ... |
| 1 | +import { BufferedBlockAlgorithm, BufferedBlockAlgorithmProps } from "./BufferedBlockAlgorithm"; | |
| 2 | +import type { Word32Array } from "../Word32Array"; | |
| 3 | +export interface HasherProps extends BufferedBlockAlgorithmProps { | |
| 4 | + blockSize: number; | |
| 5 | +} | |
| 6 | +export declare class Hasher extends BufferedBlockAlgorithm { | |
| 7 | + protected _props?: Partial<HasherProps>; | |
| 8 | + protected _blockSize: number; | |
| 9 | + constructor(props?: Partial<HasherProps>); | |
| 10 | + get blockSize(): number; | |
| 11 | + /** | |
| 12 | + * Resets this hasher to its initial state. | |
| 13 | + * | |
| 14 | + * @example | |
| 15 | + * hasher.reset(); | |
| 16 | + */ | |
| 17 | + reset(data?: Word32Array, nBytes?: number): void; | |
| 18 | + /** | |
| 19 | + * Updates this hasher with a message. | |
| 20 | + * | |
| 21 | + * @param {Word32Array|string} messageUpdate The message to append. | |
| 22 | + * @return {Hasher} This hasher. | |
| 23 | + * @example | |
| 24 | + * hasher.update('message'); | |
| 25 | + * hasher.update(wordArray); | |
| 26 | + */ | |
| 27 | + update(messageUpdate: Word32Array | string): this; | |
| 28 | + /** | |
| 29 | + * Finalizes the hash computation. | |
| 30 | + * Note that the finalize operation is effectively a destructive, read-once operation. | |
| 31 | + * | |
| 32 | + * @param {Word32Array|string?} messageUpdate (Optional) A final message update. | |
| 33 | + * @return {Word32Array} The hash. | |
| 34 | + * @example | |
| 35 | + * var hash = hasher.finalize(); | |
| 36 | + * var hash = hasher.finalize('message'); | |
| 37 | + * var hash = hasher.finalize(wordArray); | |
| 38 | + */ | |
| 39 | + finalize(messageUpdate?: Word32Array | string): Word32Array; | |
| 40 | + /** | |
| 41 | + * @abstract | |
| 42 | + */ | |
| 43 | + protected _doReset(): void; | |
| 44 | + /** | |
| 45 | + * @abstract | |
| 46 | + */ | |
| 47 | + protected _doFinalize(): Word32Array; | |
| 48 | +} | ... | ... |
| 1 | +import { Cipher, CipherProps, PropsWithKey } from "./Cipher"; | |
| 2 | +import type { BlockCipherMode, BlockCipherModeProps } from "./mode/BlockCipherMode"; | |
| 3 | +import type { Pad } from "./pad/type"; | |
| 4 | +import type { Word32Array } from "../../Word32Array"; | |
| 5 | +import type { BaseKDFModule } from "./kdf/type"; | |
| 6 | +import type { Hasher } from "../Hasher"; | |
| 7 | +export interface BlockCipherProps extends CipherProps { | |
| 8 | + mode: typeof BlockCipherMode; | |
| 9 | + padding: Pad; | |
| 10 | + kdfSalt: Word32Array; | |
| 11 | + kdfModule: typeof BaseKDFModule; | |
| 12 | + kdfHasher: typeof Hasher; | |
| 13 | + kdfIterations: number; | |
| 14 | +} | |
| 15 | +export declare class BlockCipher extends Cipher { | |
| 16 | + protected _props: PropsWithKey<BlockCipherProps>; | |
| 17 | + protected _blockSize: number; | |
| 18 | + protected _Mode: typeof BlockCipherMode; | |
| 19 | + protected _mode?: BlockCipherMode; | |
| 20 | + protected _padding: Pad; | |
| 21 | + protected _modeCreator?: (props: BlockCipherModeProps) => BlockCipherMode; | |
| 22 | + /** | |
| 23 | + * @see https://github.com/Microsoft/TypeScript/issues/3841#issuecomment-337560146 | |
| 24 | + */ | |
| 25 | + ["constructor"]: typeof BlockCipher; | |
| 26 | + constructor(props: PropsWithKey<BlockCipherProps>); | |
| 27 | + get mode(): BlockCipherMode | undefined; | |
| 28 | + get padding(): Pad; | |
| 29 | + reset(data?: Word32Array, nBytes?: number): void; | |
| 30 | + protected _doProcessBlock(words: number[], offset: number): void; | |
| 31 | + protected _doFinalize(): Word32Array; | |
| 32 | + /** | |
| 33 | + * @abstract | |
| 34 | + */ | |
| 35 | + encryptBlock(words: number[], offset: number): void; | |
| 36 | + /** | |
| 37 | + * @abstract | |
| 38 | + */ | |
| 39 | + decryptBlock(words: number[], offset: number): void; | |
| 40 | + /** | |
| 41 | + * Creates this cipher in encryption mode. | |
| 42 | + * | |
| 43 | + * @param {Word32Array} key The key. | |
| 44 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 45 | + * @return {Cipher} A cipher instance. | |
| 46 | + * @example | |
| 47 | + * var cipher = AES.createEncryptor(keyWordArray, { iv: ivWordArray }); | |
| 48 | + */ | |
| 49 | + static createEncryptor(key: Word32Array, props?: Partial<BlockCipherProps>): BlockCipher; | |
| 50 | + /** | |
| 51 | + * Creates this cipher in decryption mode. | |
| 52 | + * @param {Word32Array} key The key. | |
| 53 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 54 | + * @return {Cipher} A cipher instance. | |
| 55 | + * @example | |
| 56 | + * var cipher = AES.createDecryptor(keyWordArray, { iv: ivWordArray }); | |
| 57 | + */ | |
| 58 | + static createDecryptor(key: Word32Array, props?: Partial<BlockCipherProps>): BlockCipher; | |
| 59 | +} | ... | ... |
| 1 | +import { BufferedBlockAlgorithm, BufferedBlockAlgorithmProps } from "../BufferedBlockAlgorithm"; | |
| 2 | +import type { Word32Array } from "../../Word32Array"; | |
| 3 | +export interface CipherProps extends BufferedBlockAlgorithmProps { | |
| 4 | + key: Word32Array; | |
| 5 | + iv: Word32Array; | |
| 6 | + transformMode: number; | |
| 7 | +} | |
| 8 | +export declare type PropsWithKey<T extends CipherProps> = Partial<T> & Pick<T, "key">; | |
| 9 | +export declare class Cipher extends BufferedBlockAlgorithm { | |
| 10 | + static readonly ENC_TRANSFORM_MODE = 1; | |
| 11 | + static readonly DEC_TRANSFORM_MODE = 2; | |
| 12 | + static readonly keySize: number; | |
| 13 | + static readonly ivSize: number; | |
| 14 | + protected _props: PropsWithKey<CipherProps>; | |
| 15 | + protected _transformMode: number; | |
| 16 | + protected _key: Word32Array; | |
| 17 | + protected _iv?: Word32Array; | |
| 18 | + constructor(props: PropsWithKey<CipherProps>); | |
| 19 | + get iv(): Word32Array | undefined; | |
| 20 | + /** | |
| 21 | + * Resets this cipher to its initial state. | |
| 22 | + * @example | |
| 23 | + * cipher.reset(); | |
| 24 | + */ | |
| 25 | + reset(data?: Word32Array, nBytes?: number): void; | |
| 26 | + /** | |
| 27 | + * Adds data to be encrypted or decrypted. | |
| 28 | + * @param {Word32Array|string} dataUpdate The data to encrypt or decrypt. | |
| 29 | + * @return {Word32Array} The data after processing. | |
| 30 | + * @example | |
| 31 | + * var encrypted = cipher.process('data'); | |
| 32 | + * var encrypted = cipher.process(wordArray); | |
| 33 | + */ | |
| 34 | + process(dataUpdate: Word32Array | string): Word32Array; | |
| 35 | + /** | |
| 36 | + * Finalizes the encryption or decryption process. | |
| 37 | + * Note that the finalize operation is effectively a destructive, read-once operation. | |
| 38 | + * @param {Word32Array|string?} dataUpdate The final data to encrypt or decrypt. | |
| 39 | + * @return {Word32Array} The data after final processing. | |
| 40 | + * @example | |
| 41 | + * var encrypted = cipher.finalize(); | |
| 42 | + * var encrypted = cipher.finalize('data'); | |
| 43 | + * var encrypted = cipher.finalize(wordArray); | |
| 44 | + */ | |
| 45 | + finalize(dataUpdate?: Word32Array | string): Word32Array; | |
| 46 | + /** | |
| 47 | + * @abstract | |
| 48 | + */ | |
| 49 | + protected _doReset(): void; | |
| 50 | + /** | |
| 51 | + * @abstract | |
| 52 | + */ | |
| 53 | + protected _doProcessBlock(words: number[], offset: number): void; | |
| 54 | + /** | |
| 55 | + * @abstract | |
| 56 | + */ | |
| 57 | + protected _doFinalize(): Word32Array; | |
| 58 | + /** | |
| 59 | + * Creates this cipher in encryption mode. | |
| 60 | + * | |
| 61 | + * @param {Word32Array} key The key. | |
| 62 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 63 | + * @return {Cipher} A cipher instance. | |
| 64 | + * @example | |
| 65 | + * var cipher = AES.createEncryptor(keyWordArray, { iv: ivWordArray }); | |
| 66 | + */ | |
| 67 | + static createEncryptor(key: Word32Array, props?: Partial<CipherProps>): Cipher; | |
| 68 | + /** | |
| 69 | + * Creates this cipher in decryption mode. | |
| 70 | + * @param {Word32Array} key The key. | |
| 71 | + * @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation. | |
| 72 | + * @return {Cipher} A cipher instance. | |
| 73 | + * @example | |
| 74 | + * var cipher = AES.createDecryptor(keyWordArray, { iv: ivWordArray }); | |
| 75 | + */ | |
| 76 | + static createDecryptor(key: Word32Array, props?: Partial<CipherProps>): Cipher; | |
| 77 | +} | ... | ... |
| 1 | +import type { Word32Array } from "../../Word32Array"; | |
| 2 | +import type { BlockCipherMode } from "./mode/BlockCipherMode"; | |
| 3 | +import type { Pad } from "./pad/type"; | |
| 4 | +import type { Formatter } from "./formatter/type"; | |
| 5 | +import type { Cipher } from "./Cipher"; | |
| 6 | +/** | |
| 7 | + * A collection of cipher parameters. | |
| 8 | + * | |
| 9 | + * @property {Word32Array} ciphertext The raw ciphertext. | |
| 10 | + * @property {Word32Array} key The key to this ciphertext. | |
| 11 | + * @property {Word32Array} iv The IV used in the ciphering operation. | |
| 12 | + * @property {Word32Array} salt The salt used with a key derivation function. | |
| 13 | + * @property {typeof Cipher} algorithm The cipher algorithm. | |
| 14 | + * @property {BlockCipherMode} mode The block mode used in the ciphering operation. | |
| 15 | + * @property {Pad} padding The padding scheme used in the ciphering operation. | |
| 16 | + * @property {number} blockSize The block size of the cipher. | |
| 17 | + * @property {Formatter} formatter The default formatting strategy to convert this cipher params object to a string. | |
| 18 | + */ | |
| 19 | +export declare class CipherParams { | |
| 20 | + cipherText?: Word32Array; | |
| 21 | + key?: Word32Array; | |
| 22 | + iv?: Word32Array; | |
| 23 | + salt?: Word32Array; | |
| 24 | + Algorithm?: typeof Cipher; | |
| 25 | + mode?: BlockCipherMode; | |
| 26 | + padding?: Pad; | |
| 27 | + blockSize?: number; | |
| 28 | + formatter: Formatter; | |
| 29 | + /** | |
| 30 | + * Initializes a newly created cipher params object. | |
| 31 | + * | |
| 32 | + * @param {Partial<CipherParams>} cp An object with any of the possible cipher parameters. | |
| 33 | + * @example | |
| 34 | + * var cipherParams = new CipherParams({ | |
| 35 | + * ciphertext: ciphertextWordArray, | |
| 36 | + * key: keyWordArray, | |
| 37 | + * iv: ivWordArray, | |
| 38 | + * salt: saltWordArray, | |
| 39 | + * algorithm: AES, | |
| 40 | + * mode: CBC, | |
| 41 | + * padding: PKCS7, | |
| 42 | + * blockSize: 4, | |
| 43 | + * formatter: OpenSSLFormatter | |
| 44 | + * }); | |
| 45 | + */ | |
| 46 | + constructor(cp?: Partial<CipherParams>); | |
| 47 | + /** | |
| 48 | + * Converts this cipher params object to a string. | |
| 49 | + * | |
| 50 | + * @param {Formatter?} formatter (Optional) The formatting strategy to use. | |
| 51 | + * @return {string} The stringified cipher params. | |
| 52 | + * @throws Error If neither the formatter nor the default formatter is set. | |
| 53 | + * @example | |
| 54 | + * var string = cipherParams + ''; | |
| 55 | + * var string = cipherParams.toString(); | |
| 56 | + * var string = cipherParams.toString(OpenSSLFormatter); | |
| 57 | + */ | |
| 58 | + toString(formatter?: Formatter): string; | |
| 59 | +} | ... | ... |
| 1 | +import { ISerializableCipher, SerializableCipherProps } from "./SerializableCipher"; | |
| 2 | +import type { KDF as KDFType, BaseKDFModule } from "./kdf/type"; | |
| 3 | +import type { Word32Array } from "../../Word32Array"; | |
| 4 | +import type { Hasher } from "../Hasher"; | |
| 5 | +export interface PasswordBasedCipherProps extends SerializableCipherProps { | |
| 6 | + KDF: KDFType; | |
| 7 | + kdfSalt: Word32Array; | |
| 8 | + kdfModule: typeof BaseKDFModule; | |
| 9 | + kdfHasher: typeof Hasher; | |
| 10 | + kdfIterations: number; | |
| 11 | +} | |
| 12 | +export declare const PasswordBasedCipher: ISerializableCipher<string>; | ... | ... |
| 1 | +import type { Formatter } from "./formatter/type"; | |
| 2 | +import type { Word32Array } from "../../Word32Array"; | |
| 3 | +import type { BlockCipherProps } from "./BlockCipher"; | |
| 4 | +import { CipherParams } from "./CipherParams"; | |
| 5 | +import { Cipher as BaseCipher } from "./Cipher"; | |
| 6 | +export interface SerializableCipherProps extends BlockCipherProps { | |
| 7 | + formatter: Formatter; | |
| 8 | +} | |
| 9 | +export interface ISerializableCipher<K extends Word32Array | string> { | |
| 10 | + encrypt: (cipher: typeof BaseCipher, message: Word32Array | string, key: K, props?: Partial<SerializableCipherProps>) => CipherParams; | |
| 11 | + decrypt: (cipher: typeof BaseCipher, cipherParams: CipherParams | string, key: K, props?: Partial<SerializableCipherProps>) => Word32Array; | |
| 12 | +} | |
| 13 | +/** | |
| 14 | + * Converts serialized ciphertext to CipherParams, | |
| 15 | + * else assumed CipherParams already and returns ciphertext unchanged. | |
| 16 | + * @param {CipherParams|string} cipherTextParams The ciphertext. | |
| 17 | + * @param {Formatter} formatter The formatting strategy to use to parse serialized ciphertext. | |
| 18 | + * @return {CipherParams} The un-serialized ciphertext. | |
| 19 | + * @example | |
| 20 | + * var ciphertextParams = SerializableCipher.parse(ciphertextStringOrParams, format); | |
| 21 | + */ | |
| 22 | +export declare function parseCipherText(cipherTextParams: CipherParams | string, formatter: Formatter): CipherParams; | |
| 23 | +export declare const SerializableCipher: ISerializableCipher<Word32Array>; | ... | ... |
| 1 | +import { Cipher, CipherProps, PropsWithKey } from "./Cipher"; | |
| 2 | +export interface StreamCipherProps extends CipherProps { | |
| 3 | +} | |
| 4 | +export declare abstract class StreamCipher extends Cipher { | |
| 5 | + protected _blockSize: number; | |
| 6 | + protected constructor(props: PropsWithKey<StreamCipherProps>); | |
| 7 | + protected _doFinalize(): import("../../Word32Array").Word32Array; | |
| 8 | +} | ... | ... |
| 1 | +import type { KDF } from "./type"; | |
| 2 | +/** | |
| 3 | + * Derives a key and IV from a password. | |
| 4 | + * | |
| 5 | + * @param {string} password The password to derive from. | |
| 6 | + * @param {number} keySize The size in words of the key to generate. | |
| 7 | + * @param {number} ivSize The size in words of the IV to generate. | |
| 8 | + * @param {Word32Array?} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly. | |
| 9 | + * @return {CipherParams} A cipher params object with the key, IV, and salt. | |
| 10 | + * @example | |
| 11 | + * var derivedParams = OpenSSLKDF.execute('Password', 256/32, 128/32); | |
| 12 | + * var derivedParams = OpenSSLKDF.execute('Password', 256/32, 128/32, 'saltsalt'); | |
| 13 | + */ | |
| 14 | +export declare const OpenSSLKDF: KDF; | ... | ... |
| 1 | +import type { Hasher } from "../../../Hasher"; | |
| 2 | +import { Word32Array } from "../../../../Word32Array"; | |
| 3 | +import { BaseKDFModule, BaseKDFModuleProps } from "../type"; | |
| 4 | +export interface EvpKDFProps extends BaseKDFModuleProps { | |
| 5 | +} | |
| 6 | +/** | |
| 7 | + * This key derivation function is meant to conform with EVP_BytesToKey. | |
| 8 | + * https://www.openssl.org/docs/man1.1.1/man3/EVP_BytesToKey.html | |
| 9 | + * | |
| 10 | + * @property {number} keySize The key size in words to generate. Default: 4 (128 bits) | |
| 11 | + * @property {Hasher} hasher The hash algorithm to use. Default: MD5 | |
| 12 | + * @property {number} iterations The number of iterations to perform. Default: 1 | |
| 13 | + */ | |
| 14 | +export declare class EvpKDF extends BaseKDFModule<EvpKDFProps> { | |
| 15 | + protected _keySize: number; | |
| 16 | + protected _Hasher: typeof Hasher; | |
| 17 | + protected _iterations: number; | |
| 18 | + constructor(props?: Partial<EvpKDFProps>); | |
| 19 | + /** | |
| 20 | + * Derives a key from a password. | |
| 21 | + * | |
| 22 | + * @param {Word32Array|string} password The password. | |
| 23 | + * @param {Word32Array|string} salt A salt. | |
| 24 | + * @return {Word32Array} The derived key. | |
| 25 | + * @example | |
| 26 | + * var kdf = new EvpKDF(); | |
| 27 | + * var key = kdf.compute(password, salt); | |
| 28 | + */ | |
| 29 | + compute(password: Word32Array | string, salt: Word32Array | string): Word32Array; | |
| 30 | + /** | |
| 31 | + * Derives a key from a password. | |
| 32 | + * | |
| 33 | + * @param {Word32Array|string} password The password. | |
| 34 | + * @param {Word32Array|string} salt A salt. | |
| 35 | + * @param {Partial<EvpKDFProps>?} props (Optional) The configuration options to use for this computation. | |
| 36 | + * @return {Word32Array} The derived key. | |
| 37 | + * @static | |
| 38 | + * @example | |
| 39 | + * | |
| 40 | + * var key = EvpKDF.getKey(password, salt); | |
| 41 | + * var key = EvpKDF.getKey(password, salt, { keySize: 8 }); | |
| 42 | + * var key = EvpKDF.getKey(password, salt, { keySize: 8, iterations: 1000 }); | |
| 43 | + */ | |
| 44 | + static getKey(password: Word32Array | string, salt: Word32Array | string, props?: Partial<EvpKDFProps>): Word32Array; | |
| 45 | +} | ... | ... |
| 1 | +import type { Hasher } from "../../../Hasher"; | |
| 2 | +import { Word32Array } from "../../../../Word32Array"; | |
| 3 | +import { BaseKDFModule, BaseKDFModuleProps } from "../type"; | |
| 4 | +export interface PBKDF2Props extends BaseKDFModuleProps { | |
| 5 | +} | |
| 6 | +/** | |
| 7 | + * Password-Based Key Derivation Function 2 algorithm. | |
| 8 | + * | |
| 9 | + * @property {number} keySize The key size in words to generate. Default: 4 (128 bits) | |
| 10 | + * @property {Hasher} hasher The hash algorithm to use. Default: SHA1 | |
| 11 | + * @property {number} iterations The number of iterations to perform. Default: 1 | |
| 12 | + */ | |
| 13 | +export declare class PBKDF2 extends BaseKDFModule<PBKDF2Props> { | |
| 14 | + protected _keySize: number; | |
| 15 | + protected _Hasher: typeof Hasher; | |
| 16 | + protected _iterations: number; | |
| 17 | + constructor(props?: Partial<PBKDF2Props>); | |
| 18 | + /** | |
| 19 | + * Derives a key from a password. | |
| 20 | + * | |
| 21 | + * @param {Word32Array|string} password The password. | |
| 22 | + * @param {Word32Array|string} salt A salt. | |
| 23 | + * @return {Word32Array} The derived key. | |
| 24 | + * @example | |
| 25 | + * var kdf = new PBKDF2(); | |
| 26 | + * var key = kdf.compute(password, salt); | |
| 27 | + */ | |
| 28 | + compute(password: Word32Array | string, salt: Word32Array | string): Word32Array; | |
| 29 | + /** | |
| 30 | + * Derives a key from a password. | |
| 31 | + * | |
| 32 | + * @param {Word32Array|string} password The password. | |
| 33 | + * @param {Word32Array|string} salt A salt. | |
| 34 | + * @param {Partial<PBKDF2Props>?} props (Optional) The configuration options to use for this computation. | |
| 35 | + * @return {Word32Array} The derived key. | |
| 36 | + * @static | |
| 37 | + * @example | |
| 38 | + * var key = PBKDF2.getKey(password, salt); | |
| 39 | + * var key = PBKDF2.getKey(password, salt, { keySize: 8 }); | |
| 40 | + * var key = PBKDF2.getKey(password, salt, { keySize: 8, iterations: 1000 }); | |
| 41 | + */ | |
| 42 | + static getKey(password: Word32Array | string, salt: Word32Array | string, props?: Partial<PBKDF2Props>): Word32Array; | |
| 43 | +} | ... | ... |
| 1 | +import type { Hasher } from "../../Hasher"; | |
| 2 | +import type { CipherParams } from "../CipherParams"; | |
| 3 | +import type { Word32Array } from "../../../Word32Array"; | |
| 4 | +export interface KDFParams extends Pick<CipherParams, "toString"> { | |
| 5 | + key: Word32Array; | |
| 6 | + iv: Word32Array; | |
| 7 | + salt: Word32Array; | |
| 8 | +} | |
| 9 | +export interface KDFProps { | |
| 10 | + kdfModule: typeof BaseKDFModule; | |
| 11 | + kdfHasher: typeof Hasher; | |
| 12 | + kdfIterations: number; | |
| 13 | +} | |
| 14 | +export interface KDF { | |
| 15 | + execute: (password: Word32Array | string, keySize: number, ivSize: number, salt?: Word32Array, props?: Partial<KDFProps>) => KDFParams; | |
| 16 | +} | |
| 17 | +export interface BaseKDFModuleProps { | |
| 18 | + keySize: number; | |
| 19 | + Hasher: typeof Hasher; | |
| 20 | + iterations: number; | |
| 21 | +} | |
| 22 | +export declare class BaseKDFModule<P extends BaseKDFModuleProps = BaseKDFModuleProps> { | |
| 23 | + protected _props?: Partial<P>; | |
| 24 | + constructor(props?: Partial<P>); | |
| 25 | + compute(password: Word32Array | string, salt: Word32Array | string): Word32Array; | |
| 26 | + static getKey<P2 extends BaseKDFModuleProps>(password: Word32Array | string, salt: Word32Array | string, props?: Partial<P2>): Word32Array; | |
| 27 | +} | ... | ... |
| 1 | +import type { BlockCipher } from "../BlockCipher"; | |
| 2 | +import type { Word32Array } from "../../../Word32Array"; | |
| 3 | +export interface BlockCipherModeProps { | |
| 4 | + cipher: BlockCipher; | |
| 5 | + iv: Word32Array | undefined; | |
| 6 | +} | |
| 7 | +/** | |
| 8 | + * Abstract base block cipher mode template. | |
| 9 | + * @abstract | |
| 10 | + */ | |
| 11 | +export declare class BlockCipherMode { | |
| 12 | + protected _props: BlockCipherModeProps; | |
| 13 | + protected _cipher: BlockCipher; | |
| 14 | + protected _iv?: Word32Array; | |
| 15 | + constructor(props: BlockCipherModeProps); | |
| 16 | + /** | |
| 17 | + * @abstract | |
| 18 | + */ | |
| 19 | + processBlock(words: number[], offset: number): void; | |
| 20 | + /** | |
| 21 | + * Creates this mode for encryption. | |
| 22 | + * @param {BlockCipherModeProps} props | |
| 23 | + * @abstract | |
| 24 | + * @example | |
| 25 | + * var mode = CBC.createEncryptor(cipher, iv.words); | |
| 26 | + */ | |
| 27 | + static createEncryptor(props: BlockCipherModeProps): BlockCipherMode; | |
| 28 | + /** | |
| 29 | + * Creates this mode for decryption. | |
| 30 | + * @param {BlockCipherModeProps} props | |
| 31 | + * @abstract | |
| 32 | + * @example | |
| 33 | + * var mode = CBC.createDecryptor(cipher, iv.words); | |
| 34 | + */ | |
| 35 | + static createDecryptor(props: BlockCipherModeProps): BlockCipherMode; | |
| 36 | +} | ... | ... |
| 1 | +import { BlockCipherMode, BlockCipherModeProps } from "./BlockCipherMode"; | |
| 2 | +export interface CBCProps extends BlockCipherModeProps { | |
| 3 | +} | |
| 4 | +export declare class CBC extends BlockCipherMode { | |
| 5 | + protected _prevBlock: number[]; | |
| 6 | + /** | |
| 7 | + * CBC encryptor. | |
| 8 | + */ | |
| 9 | + static Encryptor: typeof CBC; | |
| 10 | + /** | |
| 11 | + * CBC decryptor. | |
| 12 | + */ | |
| 13 | + static Decryptor: typeof CBC; | |
| 14 | + constructor(props: CBCProps); | |
| 15 | + xorBlock(words: number[], offset: number, blockSize: number): void; | |
| 16 | + /** | |
| 17 | + * Creates this mode for encryption. | |
| 18 | + * @param {BlockCipherModeProps} props | |
| 19 | + * @example | |
| 20 | + * var mode = CBC.createEncryptor(cipher, iv.words); | |
| 21 | + */ | |
| 22 | + static createEncryptor(props: CBCProps): CBC; | |
| 23 | + /** | |
| 24 | + * Creates this mode for decryption. | |
| 25 | + * @param {BlockCipherModeProps} props | |
| 26 | + * @example | |
| 27 | + * var mode = CBC.createDecryptor(cipher, iv.words); | |
| 28 | + */ | |
| 29 | + static createDecryptor(props: CBCProps): CBC; | |
| 30 | +} | ... | ... |
| 1 | +import { BlockCipherMode, BlockCipherModeProps } from "./BlockCipherMode"; | |
| 2 | +import { Word32Array } from "../../../Word32Array"; | |
| 3 | +import type { BlockCipher } from "../BlockCipher"; | |
| 4 | +/** | |
| 5 | + * Counter/CBC-MAC | |
| 6 | + */ | |
| 7 | +export declare class CCM extends BlockCipherMode { | |
| 8 | + protected _N: Word32Array; | |
| 9 | + protected _CBIndex: number; | |
| 10 | + protected readonly _q: number; | |
| 11 | + constructor(props: BlockCipherModeProps); | |
| 12 | + /** | |
| 13 | + * Generate first block of B. | |
| 14 | + * | |
| 15 | + * @param {boolean} hasAData - If payload has AData, true. | |
| 16 | + * @param {number} t - Octet length of T(Auth tag) | |
| 17 | + * @param {Word32Array} Q - Octet length of payload. | |
| 18 | + * @param {Word32Array} N - Nonce. | |
| 19 | + */ | |
| 20 | + static getB0(hasAData: boolean, t: number, Q: Word32Array, N: Word32Array): Word32Array; | |
| 21 | + /** | |
| 22 | + * Format associated data | |
| 23 | + * @param {Word32Array} A - Associated data | |
| 24 | + * @param {Word32Array} P - Payload | |
| 25 | + */ | |
| 26 | + static formatAssociatedDataAndPayload(A: Word32Array, P: Word32Array): Word32Array; | |
| 27 | + /** | |
| 28 | + * Generate Counter Block | |
| 29 | + * @param {number} q - LEN(Q) | |
| 30 | + * @param {Word32Array} N - Nonce | |
| 31 | + * @param {number} index - Block index of 32bit integer | |
| 32 | + */ | |
| 33 | + static genCtr(q: number, N: Word32Array, index: number): Word32Array; | |
| 34 | + /** | |
| 35 | + * Generate Message Authentication Code | |
| 36 | + * | |
| 37 | + * @param {typeof BlockCipher} Cipher - 128 bit block Cipher i.e. AES | |
| 38 | + * @param {Word32Array} key - Key | |
| 39 | + * @param {Word32Array} iv - Nonce. iv less than or equal to 8byte(64bit) is supported. | |
| 40 | + * @param {Word32Array?} authData - Associated data | |
| 41 | + * @param {Word32Array?} plainText - Payload | |
| 42 | + * @param {number?} tagLength - authTag size in octet length. If omitted, tagLength will be set to 16byte. | |
| 43 | + */ | |
| 44 | + static mac(Cipher: typeof BlockCipher, key: Word32Array, iv: Word32Array, authData?: Word32Array, plainText?: Word32Array, tagLength?: number): Word32Array; | |
| 45 | + static combineCipherTextAndAuthTag(cipherText: Word32Array, authTag: Word32Array): Word32Array; | |
| 46 | + static splitCipherTextAndAuthTag(cipherTextWithAuthTag: Word32Array, tLen?: number): { | |
| 47 | + cipherText: Word32Array; | |
| 48 | + authTag: Word32Array; | |
| 49 | + }; | |
| 50 | + /** | |
| 51 | + * CTR encryptor. | |
| 52 | + */ | |
| 53 | + static Encryptor: typeof CCM; | |
| 54 | + /** | |
| 55 | + * CTR decryptor. | |
| 56 | + */ | |
| 57 | + static Decryptor: typeof CCM; | |
| 58 | + /** | |
| 59 | + * Creates this mode for encryption. | |
| 60 | + * @param {BlockCipherModeProps} props | |
| 61 | + * @example | |
| 62 | + * var mode = CTR.createEncryptor(cipher, iv.words); | |
| 63 | + */ | |
| 64 | + static createEncryptor(props: BlockCipherModeProps): CCM; | |
| 65 | + /** | |
| 66 | + * Creates this mode for decryption. | |
| 67 | + * @param {BlockCipherModeProps} props | |
| 68 | + * @example | |
| 69 | + * var mode = CTR.createDecryptor(cipher, iv.words); | |
| 70 | + */ | |
| 71 | + static createDecryptor(props: BlockCipherModeProps): CCM; | |
| 72 | +} | ... | ... |
| 1 | +import { BlockCipherMode, BlockCipherModeProps } from "./BlockCipherMode"; | |
| 2 | +import type { BlockCipher } from "../BlockCipher"; | |
| 3 | +/** | |
| 4 | + * Cipher Feedback Block mode | |
| 5 | + */ | |
| 6 | +export declare class CFB extends BlockCipherMode { | |
| 7 | + protected _prevBlock: number[]; | |
| 8 | + /** | |
| 9 | + * CFB encryptor. | |
| 10 | + */ | |
| 11 | + static Encryptor: typeof CFB; | |
| 12 | + /** | |
| 13 | + * CFB decryptor. | |
| 14 | + */ | |
| 15 | + static Decryptor: typeof CFB; | |
| 16 | + constructor(props: BlockCipherModeProps); | |
| 17 | + generateKeyStreamAndEncrypt(words: number[], offset: number, blockSize: number, cipher: BlockCipher): void; | |
| 18 | + /** | |
| 19 | + * Creates this mode for encryption. | |
| 20 | + * @param {BlockCipherModeProps} props | |
| 21 | + * @example | |
| 22 | + * var mode = CFB.createEncryptor(cipher, iv.words); | |
| 23 | + */ | |
| 24 | + static createEncryptor(props: BlockCipherModeProps): CFB; | |
| 25 | + /** | |
| 26 | + * Creates this mode for decryption. | |
| 27 | + * @param {BlockCipherModeProps} props | |
| 28 | + * @example | |
| 29 | + * var mode = CFB.createDecryptor(cipher, iv.words); | |
| 30 | + */ | |
| 31 | + static createDecryptor(props: BlockCipherModeProps): CFB; | |
| 32 | +} | ... | ... |
| 1 | +import { BlockCipherMode, BlockCipherModeProps } from "./BlockCipherMode"; | |
| 2 | +/** | |
| 3 | + * Output Feedback Block mode | |
| 4 | + */ | |
| 5 | +export declare class CTR extends BlockCipherMode { | |
| 6 | + protected _counter: number[]; | |
| 7 | + /** | |
| 8 | + * CTR encryptor. | |
| 9 | + */ | |
| 10 | + static Encryptor: typeof CTR; | |
| 11 | + /** | |
| 12 | + * CTR decryptor. | |
| 13 | + */ | |
| 14 | + static Decryptor: typeof CTR; | |
| 15 | + constructor(props: BlockCipherModeProps); | |
| 16 | + /** | |
| 17 | + * Creates this mode for encryption. | |
| 18 | + * @param {BlockCipherModeProps} props | |
| 19 | + * @example | |
| 20 | + * var mode = CTR.createEncryptor(cipher, iv.words); | |
| 21 | + */ | |
| 22 | + static createEncryptor(props: BlockCipherModeProps): CTR; | |
| 23 | + /** | |
| 24 | + * Creates this mode for decryption. | |
| 25 | + * @param {BlockCipherModeProps} props | |
| 26 | + * @example | |
| 27 | + * var mode = CTR.createDecryptor(cipher, iv.words); | |
| 28 | + */ | |
| 29 | + static createDecryptor(props: BlockCipherModeProps): CTR; | |
| 30 | +} | ... | ... |
| 1 | +import { BlockCipherMode, BlockCipherModeProps } from "./BlockCipherMode"; | |
| 2 | +/** | |
| 3 | + * Electronic Codebook block mode. | |
| 4 | + */ | |
| 5 | +export declare class ECB extends BlockCipherMode { | |
| 6 | + /** | |
| 7 | + * ECB encryptor. | |
| 8 | + */ | |
| 9 | + static Encryptor: typeof ECB; | |
| 10 | + /** | |
| 11 | + * ECB decryptor. | |
| 12 | + */ | |
| 13 | + static Decryptor: typeof ECB; | |
| 14 | + constructor(props: BlockCipherModeProps); | |
| 15 | + /** | |
| 16 | + * Creates this mode for encryption. | |
| 17 | + * @param {BlockCipherModeProps} props | |
| 18 | + * @example | |
| 19 | + * var mode = ECB.createEncryptor(cipher, iv.words); | |
| 20 | + */ | |
| 21 | + static createEncryptor(props: BlockCipherModeProps): ECB; | |
| 22 | + /** | |
| 23 | + * Creates this mode for decryption. | |
| 24 | + * @param {BlockCipherModeProps} props | |
| 25 | + * @example | |
| 26 | + * var mode = ECB.createDecryptor(cipher, iv.words); | |
| 27 | + */ | |
| 28 | + static createDecryptor(props: BlockCipherModeProps): ECB; | |
| 29 | +} | ... | ... |
| 1 | +import { BlockCipherMode, BlockCipherModeProps } from "./BlockCipherMode"; | |
| 2 | +import { Word32Array } from "../../../Word32Array"; | |
| 3 | +import type { BlockCipher } from "../BlockCipher"; | |
| 4 | +/** | |
| 5 | + * Galois Counter Mode | |
| 6 | + */ | |
| 7 | +export declare class GCM extends BlockCipherMode { | |
| 8 | + protected _H: number[]; | |
| 9 | + protected _J0: number[]; | |
| 10 | + protected _CB: number[]; | |
| 11 | + constructor(props: BlockCipherModeProps); | |
| 12 | + /** | |
| 13 | + * Initialize Initial Counter Block J0. | |
| 14 | + * @param {[number, number, number, number]} H - 128bit(4word) block | |
| 15 | + * @param {number[]} iv - Initializing Vector which must be multiple of 32bit(4byte) | |
| 16 | + */ | |
| 17 | + static getJ0(H: number[], iv?: number[]): number[]; | |
| 18 | + /** | |
| 19 | + * https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf | |
| 20 | + * 6.2 Incrementing Function | |
| 21 | + * inc(s=32, X) = MSB(len(X)-s, X) || [int(LSB(s, X)+1 mod 2^s] | |
| 22 | + * | |
| 23 | + * @param {number[]} X - [32bit int, 32bit int, 32bit int, 32bit int]. | |
| 24 | + * @example | |
| 25 | + * inc32([0,0,0,0]) = [0,0,0,1] | |
| 26 | + * inc32([0,0,0,1]) = [0,0,0,2] | |
| 27 | + * inc32([0,0,0,0xffffffff]) = [0,0,1,0] | |
| 28 | + * inc32([0,0,0xffffffff,0xffffffff]) = [0,1,0,0] | |
| 29 | + * inc32([0,0xffffffff,0xffffffff,0xffffffff]) = [0,0,0,0] | |
| 30 | + */ | |
| 31 | + static inc32(X: number[]): number[]; | |
| 32 | + /** | |
| 33 | + * https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf | |
| 34 | + * 6.3 Multiplication Operation on Blocks | |
| 35 | + * | |
| 36 | + * @param {number[]} X - [32bit int, 32bit int, 32bit int, 32bit int], 128bit block. | |
| 37 | + * @param {number[]} Y - [32bit int, 32bit int, 32bit int, 32bit int], 128bit block. | |
| 38 | + * @returns 128bit block | |
| 39 | + */ | |
| 40 | + static mul(X: number[], Y: number[]): number[]; | |
| 41 | + /** | |
| 42 | + * https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf | |
| 43 | + * 6.4 GHASH Function | |
| 44 | + * | |
| 45 | + * @param {number[]} H - The hash sub key block of 128bit. | |
| 46 | + * @param {number[]} X - X.length must be multiple of 4. (multiple of 128bit) | |
| 47 | + * @returns 128bit block | |
| 48 | + */ | |
| 49 | + static GHASH(H: number[], X: number[]): number[]; | |
| 50 | + /** | |
| 51 | + * https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf | |
| 52 | + * 6.5 GCTR Function | |
| 53 | + * | |
| 54 | + * @param {BlockCipher} cipher | |
| 55 | + * @param {number[]} ICB - Initial Code Block. Required to be 128bit(4word). | |
| 56 | + * @param {Word32Array} X - Arbitrary length block | |
| 57 | + */ | |
| 58 | + static GCTR(cipher: BlockCipher, ICB: number[], X: Word32Array): Word32Array; | |
| 59 | + /** | |
| 60 | + * Calculate Message Authentication Code with GCM | |
| 61 | + * | |
| 62 | + * @param {typeof BlockCipher} Cipher - 128 bit block Cipher i.e. AES | |
| 63 | + * @param {Word32Array} key - key | |
| 64 | + * @param {Word32Array} iv - iv should be 12byte length. i.e. `new Word32Array([0x11223344, 0x55667788, 0x99aabbcc], 12);` | |
| 65 | + * @param {Word32Array?} aad - Additional Authenticated Data | |
| 66 | + * @param {Word32Array?} cipherText - encrypted text | |
| 67 | + * @param {number?} tagLength - authTag size in octet length. If omitted, tagLength will be set to 16byte. | |
| 68 | + */ | |
| 69 | + static mac(Cipher: typeof BlockCipher, key: Word32Array, iv: Word32Array, aad?: Word32Array, cipherText?: Word32Array, tagLength?: number): Word32Array; | |
| 70 | + /** | |
| 71 | + * CTR encryptor. | |
| 72 | + */ | |
| 73 | + static Encryptor: typeof GCM; | |
| 74 | + /** | |
| 75 | + * CTR decryptor. | |
| 76 | + */ | |
| 77 | + static Decryptor: typeof GCM; | |
| 78 | + /** | |
| 79 | + * Creates this mode for encryption. | |
| 80 | + * @param {BlockCipherModeProps} props | |
| 81 | + * @example | |
| 82 | + * var mode = CTR.createEncryptor(cipher, iv.words); | |
| 83 | + */ | |
| 84 | + static createEncryptor(props: BlockCipherModeProps): GCM; | |
| 85 | + /** | |
| 86 | + * Creates this mode for decryption. | |
| 87 | + * @param {BlockCipherModeProps} props | |
| 88 | + * @example | |
| 89 | + * var mode = CTR.createDecryptor(cipher, iv.words); | |
| 90 | + */ | |
| 91 | + static createDecryptor(props: BlockCipherModeProps): GCM; | |
| 92 | +} | ... | ... |
| 1 | +import { BlockCipherMode, BlockCipherModeProps } from "./BlockCipherMode"; | |
| 2 | +/** | |
| 3 | + * Output Feedback Block mode | |
| 4 | + */ | |
| 5 | +export declare class OFB extends BlockCipherMode { | |
| 6 | + protected _keyStream: number[]; | |
| 7 | + /** | |
| 8 | + * OFB encryptor. | |
| 9 | + */ | |
| 10 | + static Encryptor: typeof OFB; | |
| 11 | + /** | |
| 12 | + * OFB decryptor. | |
| 13 | + */ | |
| 14 | + static Decryptor: typeof OFB; | |
| 15 | + constructor(props: BlockCipherModeProps); | |
| 16 | + /** | |
| 17 | + * Creates this mode for encryption. | |
| 18 | + * @param {BlockCipherModeProps} props | |
| 19 | + * @example | |
| 20 | + * var mode = OFB.createEncryptor(cipher, iv.words); | |
| 21 | + */ | |
| 22 | + static createEncryptor(props: BlockCipherModeProps): OFB; | |
| 23 | + /** | |
| 24 | + * Creates this mode for decryption. | |
| 25 | + * @param {BlockCipherModeProps} props | |
| 26 | + * @example | |
| 27 | + * var mode = OFB.createDecryptor(cipher, iv.words); | |
| 28 | + */ | |
| 29 | + static createDecryptor(props: BlockCipherModeProps): OFB; | |
| 30 | +} | ... | ... |
| 1 | +import { Word32Array } from "../../../Word32Array"; | |
| 2 | +/** | |
| 3 | + * Pad word array to multiple of 128bit(4byte) | |
| 4 | + * @param {Word32Array} w - Padding target. This w will be modified directly. | |
| 5 | + * @returns {void} | |
| 6 | + */ | |
| 7 | +export declare function padTo128m(w: Word32Array): void; | |
| 8 | +/** | |
| 9 | + * Extract Most Significant Bit. | |
| 10 | + * @param {Word32Array} w | |
| 11 | + * @param {number} bytes - Number of bytes to extract | |
| 12 | + * @example | |
| 13 | + * const w = new Word32Array([0x11223344, 0x55667788]); | |
| 14 | + * msb(w, 2).toString() === "1122"; // true | |
| 15 | + */ | |
| 16 | +export declare function msb(w: Word32Array, bytes: number): Word32Array; | |
| 17 | +/** | |
| 18 | + * Extract Least Significant Bit. | |
| 19 | + * @param {Word32Array} w | |
| 20 | + * @param {number} bytes - Number of bytes to extract | |
| 21 | + * @example | |
| 22 | + * const w = new Word32Array([0x11223344, 0x55667788, 0x99aabb00], 11); | |
| 23 | + * lsb(w, 5).toString() === "778899aabb"; // true | |
| 24 | + */ | |
| 25 | +export declare function lsb(w: Word32Array, bytes: number): Word32Array; | ... | ... |
app/static/content/jscrypto/lib/browser.d.ts
0 → 100644
| 1 | +export declare function isIE(op?: "<" | "<=" | ">" | ">=" | "=", ver?: number): boolean; | ... | ... |
app/static/content/jscrypto/lib/index.d.ts
0 → 100644
| 1 | +export { random } from "./random"; | |
| 2 | +export { Word32Array } from "./Word32Array"; | |
| 3 | +export { Word64, Word64Array } from "./Word64Array"; | |
| 4 | +export { isIE } from "./browser"; | |
| 5 | +export { Base64 } from "./encoder/Base64"; | |
| 6 | +export { Utf8 } from "./encoder/Utf8"; | |
| 7 | +export { Latin1 } from "./encoder/Latin1"; | |
| 8 | +export { Hex } from "./encoder/Hex"; | |
| 9 | +export { Utf16BE, Utf16LE, Utf16 } from "./encoder/Utf16"; | |
| 10 | +export { OpenSSLKDF } from "./algorithm/cipher/kdf/OpenSSLKDF"; | |
| 11 | +export { PBKDF2 } from "./algorithm/cipher/kdf/module/PBKDF2"; | |
| 12 | +export { EvpKDF } from "./algorithm/cipher/kdf/module/EvpKDF"; | ... | ... |
app/static/content/jscrypto/lib/random.d.ts
0 → 100644
| 1 | +export declare const random: () => number; | ... | ... |
app/static/content/jscrypto/lib/type.d.ts
0 → 100644
app/static/content/jscrypto/mode/CBC.d.ts
0 → 100644
| 1 | +export { CBC } from "../lib/algorithm/cipher/mode/CBC"; | ... | ... |
app/static/content/jscrypto/mode/CBC.js
0 → 100644
| 1 | +!function(t,n){if("object"==typeof exports&&"object"==typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else if("object"==typeof exports)exports.JsCrypto=n();else{var e=n();for(var i in t.JsCrypto=t.JsCrypto||{},t.JsCrypto.mode=t.JsCrypto=t.JsCrypto||{},t.JsCrypto.mode,e)t.JsCrypto=t.JsCrypto||{},t.JsCrypto.mode[i]=e[i]}}(this,(function(){return function(){"use strict";var t={d:function(n,e){for(var i in e)t.o(e,i)&&!t.o(n,i)&&Object.defineProperty(n,i,{enumerable:!0,get:e[i]})},o:function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},r:function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"t",{value:!0})}},n={};t.r(n),t.d(n,{CBC:function(){return r}});var e,i=function(){function t(t){this.i=t,this.u=t.cipher,this.h=t.iv}return t.prototype.processBlock=function(t,n){},t.createEncryptor=function(t){throw new Error("Not implemented yet")},t.createDecryptor=function(t){throw new Error("Not implemented yet")},t}(),o=(e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])})(t,n)},function(t,n){function i(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}),r=function(t){function n(n){var e=t.call(this,n)||this;return e.l=[],e}return o(n,t),n.prototype.xorBlock=function(t,n,e){var i,o=this.h;o?(i=o.words,this.h=void 0):i=this.l;for(var r=0;r<e;r++)t[n+r]^=i[r]},n.createEncryptor=function(t){return new n.Encryptor(t)},n.createDecryptor=function(t){return new n.Decryptor(t)},n.Encryptor=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return o(n,t),n.prototype.processBlock=function(t,n){var e=this.u,i=e.blockSize;this.xorBlock(t,n,i),e.encryptBlock(t,n),this.l=t.slice(n,n+i)},n}(n),n.Decryptor=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return o(n,t),n.prototype.processBlock=function(t,n){var e=this.u,i=e.blockSize,o=t.slice(n,n+i);e.decryptBlock(t,n),this.xorBlock(t,n,i),this.l=o},n}(n),n}(i);return n}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/mode/CCM.d.ts
0 → 100644
| 1 | +export { CCM } from "../lib/algorithm/cipher/mode/CCM"; | ... | ... |
app/static/content/jscrypto/mode/CCM.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var r=t();for(var e in n.JsCrypto=n.JsCrypto||{},n.JsCrypto.mode=n.JsCrypto=n.JsCrypto||{},n.JsCrypto.mode,r)n.JsCrypto=n.JsCrypto||{},n.JsCrypto.mode[e]=r[e]}}(this,(function(){return function(){"use strict";var n={d:function(t,r){for(var e in r)n.o(r,e)&&!n.o(t,e)&&Object.defineProperty(t,e,{enumerable:!0,get:r[e]})}};n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),n.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},n.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"t",{value:!0})};var t={};n.r(t),n.d(t,{CCM:function(){return w}});var r,e=function(){function n(n){this.i=n,this.u=n.cipher,this.h=n.iv}return n.prototype.processBlock=function(n,t){},n.createEncryptor=function(n){throw new Error("Not implemented yet")},n.createDecryptor=function(n){throw new Error("Not implemented yet")},n}(),i=function(n){for(var t=n.nSigBytes,r=n.words,e=[],i=0;i<t;i++){var o=r[i>>>2]>>>24-i%4*8&255;e.push((o>>>4).toString(16)),e.push((15&o).toString(16))}return e.join("")},o="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",u=(r=parseInt((/msie (\d+)/.exec(o)||[])[1],10),isNaN(r)?(r=parseInt((/trident\/.*; rv:(\d+)/.exec(o)||[])[1],10),!isNaN(r)&&r):r);var f=function(){if("undefined"!=typeof window){var t=window.crypto||window.msCrypto;if(!t){if(function(n,t){return!1!==u&&(!t||("<"===n?u<t:"<="===n?u<=t:">"===n?u>t:">="===n?u>=t:u===t))}("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return t.getRandomValues(new Uint32Array(1))[0]}}return void 0!==n.g&&n.g.crypto?function(){return n.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}(),a=function(){function n(t,r){if(Array.isArray(t)||!t)return this.v=Array.isArray(t)?t:[],void(this.l="number"==typeof r?r:4*this.v.length);if(t instanceof n)return this.v=t.words.slice(),void(this.l=t.nSigBytes);var e;try{t instanceof ArrayBuffer?e=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(e=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!e)throw new Error("Invalid argument");for(var i=e.byteLength,o=[],u=0;u<i;u++)o[u>>>2]|=e[u]<<24-u%4*8;this.v=o,this.l=i}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.l},set:function(n){this.l=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.v},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):i(this)},n.prototype.toUint8Array=function(){for(var n=this.v,t=this.l,r=new Uint8Array(t),e=0;e<t;e++)r[e]=n[e>>>2]>>>24-e%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.l%4)for(var e=0;e<r;e++){var i=t[e>>>2]>>>24-e%4*8&255;this.v[this.l+e>>>2]|=i<<24-(this.l+e)%4*8}else for(e=0;e<r;e+=4)this.v[this.l+e>>>2]=t[e>>>2];return this.l+=r,this},n.prototype.clamp=function(){var n=this.l;this.v[n>>>2]&=4294967295<<32-n%4*8,this.v.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.v.slice(),this.l)},n.random=function(t){for(var r=[],e=0;e<t;e+=4)r.push(f());return new n(r,t)},n}();function s(n,t){for(var r=n.nSigBytes-t,e=[],i=0;i<t;i++){var o=i>>>2,u=r+i,f=u>>>2,s=n.words[f]>>>24-u%4*8&255;e[o]=0|e[o]|s<<24-i%4*8}var c=new a(e,t);return c.clamp(),c}var c,h=(c=function(n,t){return(c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(n,t)},function(n,t){function r(){this.constructor=n}c(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),w=function(n){function t(t){var r=n.call(this,t)||this;r.p=1;var e=t.cipher,i=t.iv;if(4!==e.blockSize)throw new Error("In CCM, cipher block size must be 128bit");if(i&&(i.nSigBytes>13||i.nSigBytes<7))throw new Error("Byte size of iv must be between 7 and 13");return r.m=i||new a([0,0],8),r.A=15-r.m.nSigBytes,r}return h(t,n),t.getB0=function(n,t,r,e){if(r.nSigBytes+e.nSigBytes!==15)throw new Error("LEN(Q)+LEN(N) must be 15");var i=255&(0|(n?1:0)<<6|(t-2)/2<<3|r.nSigBytes-1),o=e.clone().concat(r);return new a([i<<24],1).concat(o)},t.formatAssociatedDataAndPayload=function(n,t){var r,e=n.nSigBytes;if(0===e)r=new a([0],0);else if(e<Math.pow(2,16)-Math.pow(2,8))r=new a([e<<16],2);else{if(!(e<Math.pow(2,32)))throw new Error("LEN(A) larger than 2**32-1 is not supported");r=new a([4294836224],2).concat(new a([e],4))}for(var i=Math.floor(n.nSigBytes/4),o=0;o<i;o++)r.concat(new a([n.words[o]],4));n.nSigBytes%4&&(r.concat(new a([n.words[i]],n.nSigBytes%4)),r.concat(new a([0],4-n.nSigBytes%4))),r.nSigBytes%16&&r.concat(new a([0],16-r.nSigBytes%16));var u=Math.floor(t.nSigBytes/4);for(o=0;o<u;o++)r.concat(new a([t.words[o]],4));return t.nSigBytes%4&&(r.concat(new a([t.words[u]],t.nSigBytes%4)),r.concat(new a([0],4-t.nSigBytes%4))),r.nSigBytes%16&&r.concat(new a([0],16-r.nSigBytes%16)),r},t.genCtr=function(n,t,r){if(t.nSigBytes+n!==15)throw new Error("LEN(Q)+LEN(N) must be 15");for(var e=new a([(n-1&7)<<24],1),i=new a([],0),o=Math.floor(n/4),u=0;u<o-1;u++)i.concat(new a([0],4));return n%4?n>4?(i.concat(new a([0],n%4)),i.concat(new a([r],4))):i.concat(new a([r<<32-8*n],n)):i.concat(new a([r],4)),e.concat(t).concat(i)},t.mac=function(n,r,e,i,o,u){var f=new n({key:r,iv:e});if(4!==f.blockSize)throw new Error("In CCM, cipher block size must be 128bit");if(e&&(e.nSigBytes>13||e.nSigBytes<7))throw new Error("Byte size of iv must be between 7 and 13");var c=e||new a([0,0],8),h=(null==i?void 0:i.clone())||new a,w=h.nSigBytes,v=(null==o?void 0:o.clone())||new a,l=v.nSigBytes;if(l>>>0>4294967295)throw new Error("Byte length of Payload(plainText) larger than 2^32-1 (4,294,967,295byte) is not supported at this time.");var d=15-c.nSigBytes,y=s(new a([0,l],8),d),b=u||16,p=t.getB0(Boolean(w),b,y,c),m=t.formatAssociatedDataAndPayload(h,v),E=p.words.slice();f.encryptBlock(E,0);for(var g=m.nSigBytes/16,A=m.words,j=E,M=0;M<g;M++){var N=[A[4*M]^j[0],A[4*M+1]^j[1],A[4*M+2]^j[2],A[4*M+3]^j[3]];f.encryptBlock(N,0),j=N}var I=new a(j,b),O=t.genCtr(d,c,0);f.encryptBlock(O.words,0);for(M=0;M<4;M++)I.words[M]^=O.words[M];return I.clamp(),I},t.combineCipherTextAndAuthTag=function(n,t){return n.clone().concat(t)},t.splitCipherTextAndAuthTag=function(n,t){var r,e,i=t||16;return{cipherText:(r=n,e=n.nSigBytes-i,new a(r.words.slice(),e)),authTag:s(n,i)}},t.createEncryptor=function(n){return new t.Encryptor(n)},t.createDecryptor=function(n){return new t.Decryptor(n)},t.Encryptor=function(n){function r(){return null!==n&&n.apply(this,arguments)||this}return h(r,n),r.prototype.processBlock=function(n,r){var e=this.u,i=e.blockSize,o=t.genCtr(this.A,this.m,this.p);e.encryptBlock(o.words,0);for(var u=0;u<i;u++)n[r+u]^=o.words[u];this.p++},r}(t),t.Decryptor=function(n){function r(){return null!==n&&n.apply(this,arguments)||this}return h(r,n),r.prototype.processBlock=function(n,r){var e=this.u,i=e.blockSize,o=t.genCtr(this.A,this.m,this.p);e.encryptBlock(o.words,0);for(var u=0;u<i;u++)n[r+u]^=o.words[u];this.p++},r}(t),t}(e);return t}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/mode/CFB.d.ts
0 → 100644
| 1 | +export { CFB } from "../lib/algorithm/cipher/mode/CFB"; | ... | ... |
app/static/content/jscrypto/mode/CFB.js
0 → 100644
| 1 | +!function(t,n){if("object"==typeof exports&&"object"==typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else if("object"==typeof exports)exports.JsCrypto=n();else{var e=n();for(var i in t.JsCrypto=t.JsCrypto||{},t.JsCrypto.mode=t.JsCrypto=t.JsCrypto||{},t.JsCrypto.mode,e)t.JsCrypto=t.JsCrypto||{},t.JsCrypto.mode[i]=e[i]}}(this,(function(){return function(){"use strict";var t={d:function(n,e){for(var i in e)t.o(e,i)&&!t.o(n,i)&&Object.defineProperty(n,i,{enumerable:!0,get:e[i]})},o:function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},r:function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"t",{value:!0})}},n={};t.r(n),t.d(n,{CFB:function(){return r}});var e,i=function(){function t(t){this.i=t,this.u=t.cipher,this.h=t.iv}return t.prototype.processBlock=function(t,n){},t.createEncryptor=function(t){throw new Error("Not implemented yet")},t.createDecryptor=function(t){throw new Error("Not implemented yet")},t}(),o=(e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])})(t,n)},function(t,n){function i(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}),r=function(t){function n(n){var e=t.call(this,n)||this;return e.l=[],e}return o(n,t),n.prototype.generateKeyStreamAndEncrypt=function(t,n,e,i){var o,r=this.h;r?(o=r.words.slice(0),this.h=void 0):o=this.l,i.encryptBlock(o,0);for(var u=0;u<e;u++)t[n+u]^=o[u]},n.createEncryptor=function(t){return new n.Encryptor(t)},n.createDecryptor=function(t){return new n.Decryptor(t)},n.Encryptor=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return o(n,t),n.prototype.processBlock=function(t,n){this.generateKeyStreamAndEncrypt(t,n,this.u.blockSize,this.u),this.l=t.slice(n,n+this.u.blockSize)},n}(n),n.Decryptor=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return o(n,t),n.prototype.processBlock=function(t,n){var e=t.slice(n,n+this.u.blockSize);this.generateKeyStreamAndEncrypt(t,n,this.u.blockSize,this.u),this.l=e},n}(n),n}(i);return n}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/mode/CTR.d.ts
0 → 100644
| 1 | +export { CTR } from "../lib/algorithm/cipher/mode/CTR"; | ... | ... |
app/static/content/jscrypto/mode/CTR.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var e=t();for(var o in n.JsCrypto=n.JsCrypto||{},n.JsCrypto.mode=n.JsCrypto=n.JsCrypto||{},n.JsCrypto.mode,e)n.JsCrypto=n.JsCrypto||{},n.JsCrypto.mode[o]=e[o]}}(this,(function(){return function(){"use strict";var n={d:function(t,e){for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},o:function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r:function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"t",{value:!0})}},t={};n.r(t),n.d(t,{CTR:function(){return i}});var e,o=function(){function n(n){this.i=n,this.u=n.cipher,this.l=n.iv}return n.prototype.processBlock=function(n,t){},n.createEncryptor=function(n){throw new Error("Not implemented yet")},n.createDecryptor=function(n){throw new Error("Not implemented yet")},n}(),r=(e=function(n,t){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e])})(n,t)},function(n,t){function o(){this.constructor=n}e(n,t),n.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}),i=function(n){function t(t){var e=n.call(this,t)||this;return e.h=[],e}return r(t,n),t.createEncryptor=function(n){return new t.Encryptor(n)},t.createDecryptor=function(n){return new t.Decryptor(n)},t.Encryptor=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return r(t,n),t.prototype.processBlock=function(n,t){var e=this.u,o=e.blockSize,r=this.l,i=this.h;r&&(i=this.h=r.words.slice(0),this.l=void 0);var u=i.slice(0);e.encryptBlock(u,0),i[o-1]=i[o-1]+1|0;for(var f=0;f<o;f++)n[t+f]^=u[f]},t}(t),t.Decryptor=t.Encryptor,t}(o);return t}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/mode/ECB.d.ts
0 → 100644
| 1 | +export { ECB } from "../lib/algorithm/cipher/mode/ECB"; | ... | ... |
app/static/content/jscrypto/mode/ECB.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var e=t();for(var o in n.JsCrypto=n.JsCrypto||{},n.JsCrypto.mode=n.JsCrypto=n.JsCrypto||{},n.JsCrypto.mode,e)n.JsCrypto=n.JsCrypto||{},n.JsCrypto.mode[o]=e[o]}}(this,(function(){return function(){"use strict";var n={d:function(t,e){for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},o:function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r:function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"t",{value:!0})}},t={};n.r(t),n.d(t,{ECB:function(){return r}});var e,o=function(){function n(n){this.i=n,this.u=n.cipher,this.l=n.iv}return n.prototype.processBlock=function(n,t){},n.createEncryptor=function(n){throw new Error("Not implemented yet")},n.createDecryptor=function(n){throw new Error("Not implemented yet")},n}(),i=(e=function(n,t){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e])})(n,t)},function(n,t){function o(){this.constructor=n}e(n,t),n.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}),r=function(n){function t(t){return n.call(this,t)||this}return i(t,n),t.createEncryptor=function(n){return new t.Encryptor(n)},t.createDecryptor=function(n){return new t.Decryptor(n)},t.Encryptor=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return i(t,n),t.prototype.processBlock=function(n,t){this.u.encryptBlock(n,t)},t}(t),t.Decryptor=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return i(t,n),t.prototype.processBlock=function(n,t){this.u.decryptBlock(n,t)},t}(t),t}(o);return t}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/mode/GCM.d.ts
0 → 100644
| 1 | +export { GCM } from "../lib/algorithm/cipher/mode/GCM"; | ... | ... |
app/static/content/jscrypto/mode/GCM.js
0 → 100644
| 1 | +!function(n,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else if("object"==typeof exports)exports.JsCrypto=r();else{var t=r();for(var e in n.JsCrypto=n.JsCrypto||{},n.JsCrypto.mode=n.JsCrypto=n.JsCrypto||{},n.JsCrypto.mode,t)n.JsCrypto=n.JsCrypto||{},n.JsCrypto.mode[e]=t[e]}}(this,(function(){return function(){"use strict";var n={d:function(r,t){for(var e in t)n.o(t,e)&&!n.o(r,e)&&Object.defineProperty(r,e,{enumerable:!0,get:t[e]})}};n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),n.o=function(n,r){return Object.prototype.hasOwnProperty.call(n,r)},n.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"t",{value:!0})};var r={};n.r(r),n.d(r,{GCM:function(){return v}});var t,e=function(){function n(n){this.i=n,this.u=n.cipher,this.h=n.iv}return n.prototype.processBlock=function(n,r){},n.createEncryptor=function(n){throw new Error("Not implemented yet")},n.createDecryptor=function(n){throw new Error("Not implemented yet")},n}(),i=function(n){for(var r=n.nSigBytes,t=n.words,e=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;e.push((o>>>4).toString(16)),e.push((15&o).toString(16))}return e.join("")},o="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",u=(t=parseInt((/msie (\d+)/.exec(o)||[])[1],10),isNaN(t)?(t=parseInt((/trident\/.*; rv:(\d+)/.exec(o)||[])[1],10),!isNaN(t)&&t):t);var f=function(){if("undefined"!=typeof window){var r=window.crypto||window.msCrypto;if(!r){if(function(n,r){return!1!==u&&(!r||("<"===n?u<r:"<="===n?u<=r:">"===n?u>r:">="===n?u>=r:u===r))}("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return r.getRandomValues(new Uint32Array(1))[0]}}return void 0!==n.g&&n.g.crypto?function(){return n.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}(),a=function(){function n(r,t){if(Array.isArray(r)||!r)return this.v=Array.isArray(r)?r:[],void(this.l="number"==typeof t?t:4*this.v.length);if(r instanceof n)return this.v=r.words.slice(),void(this.l=r.nSigBytes);var e;try{r instanceof ArrayBuffer?e=new Uint8Array(r):(r instanceof Uint8Array||r instanceof Int8Array||r instanceof Uint8ClampedArray||r instanceof Int16Array||r instanceof Uint16Array||r instanceof Int32Array||r instanceof Uint32Array||r instanceof Float32Array||r instanceof Float64Array)&&(e=new Uint8Array(r.buffer,r.byteOffset,r.byteLength))}catch(n){throw new Error("Invalid argument")}if(!e)throw new Error("Invalid argument");for(var i=e.byteLength,o=[],u=0;u<i;u++)o[u>>>2]|=e[u]<<24-u%4*8;this.v=o,this.l=i}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.l},set:function(n){this.l=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.v},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):i(this)},n.prototype.toUint8Array=function(){for(var n=this.v,r=this.l,t=new Uint8Array(r),e=0;e<r;e++)t[e]=n[e>>>2]>>>24-e%4*8&255;return t},n.prototype.concat=function(n){var r=n.words.slice(),t=n.nSigBytes;if(this.clamp(),this.l%4)for(var e=0;e<t;e++){var i=r[e>>>2]>>>24-e%4*8&255;this.v[this.l+e>>>2]|=i<<24-(this.l+e)%4*8}else for(e=0;e<t;e+=4)this.v[this.l+e>>>2]=r[e>>>2];return this.l+=t,this},n.prototype.clamp=function(){var n=this.l;this.v[n>>>2]&=4294967295<<32-n%4*8,this.v.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.v.slice(),this.l)},n.random=function(r){for(var t=[],e=0;e<r;e+=4)t.push(f());return new n(t,r)},n}();function s(n){var r=n.nSigBytes%16;if(0!==r){for(var t=16-r,e=[],i=Math.floor(t/4),o=0;o<i;o++)e.push(0);t%4>0&&e.push(0),n.concat(new a(e,t))}}var c,h=(c=function(n,r){return(c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(n[t]=r[t])})(n,r)},function(n,r){function t(){this.constructor=n}c(n,r),n.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t)}),v=function(n){function r(t){var e=n.call(this,t)||this;if(e.m=[],e.p=[],e.A=[],4!==t.cipher.blockSize)throw new Error("In GCM block cipher mode, cipher block size must be 128bit");var i=t.cipher,o=t.iv,u=[0,0,0,0];return i.encryptBlock(u,0),e.m=u,e.p=r.getJ0(u,null==o?void 0:o.words),e.A=e.p.slice(),e}return h(r,n),r.getJ0=function(n,t){var e;if(t&&0!==t.length)if(3===t.length)e=[t[0],t[1],t[2],1];else{for(var i=t.length%4>0?4-t.length%4:0,o=t.slice(),u=0;u<i+2;u++)o.push(0);o.push(0),o.push(32*t.length),e=r.GHASH(n,o)}else e=[0,0,0,1];return e},r.inc32=function(n){var r=n.slice(),t=r[3]>>>0,e=t+1>>>0<t;if(r[3]=r[3]+1|0,e){var i=r[2]>>>0,o=i+1>>>0<i;r[2]=r[2]+1|0,o&&(r[1]=r[1]+1|0)}return r},r.mul=function(n,r){for(var t=[3774873600,0,0,0],e=[0,0,0,0],i=r.slice(),o=0;o<128;o++){(n[o>>>5]>>>31-o%32&1)>0&&(e[0]=e[0]^i[0],e[1]=e[1]^i[1],e[2]=e[2]^i[2],e[3]=e[3]^i[3]);var u=(1&i[3])>>>0,f=(1&i[0])>>>0,a=(1&i[1])>>>0,s=(1&i[2])>>>0;i[0]=i[0]>>>1,i[1]=i[1]>>>1|(f?2147483648:0),i[2]=i[2]>>>1|(a?2147483648:0),i[3]=i[3]>>>1|(s?2147483648:0),u>0&&(i[0]^=t[0],i[1]^=t[1],i[2]^=t[2],i[3]^=t[3])}return e},r.GHASH=function(n,t){if(n.length%4!=0)throw new Error("Length of 32bit word array 'H' must be multiple of 4(128bit)");if(t.length%4!=0)throw new Error("Length of 32bit word array 'X' must be multiple of 4(128bit)");for(var e=t.length,i=[0,0,0,0],o=0;o<e;o+=4)i[0]=i[0]^t[o],i[1]=i[1]^t[o+1],i[2]=i[2]^t[o+2],i[3]=i[3]^t[o+3],i=r.mul(i,n);return i},r.GCTR=function(n,t,e){if(0===e.nSigBytes)return e.clone();if(4!==t.length)throw new Error("Initial Counter Block size must be 128bit");for(var i=e.words,o=Math.ceil(e.nSigBytes/16),u=[t.slice()],f=1;f<o;f++){var s=r.inc32(u[f-1]);u.push(s)}var c=new a;for(f=0;f<o;f++){n.encryptBlock(u[f],0);var h=e.nSigBytes%16;if(f<o-1||0===h){var v=i[4*f]^u[f][0],l=i[4*f+1]^u[f][1],w=i[4*f+2]^u[f][2],d=i[4*f+3]^u[f][3],y=new a([v,l,w,d]);c.concat(y)}else{for(var b=[],m=0,p=Math.floor(h/4),A=0;A<p;A++){var g=i[4*f+A]^u[f][A];b.push(g),m+=4}var j=h%4;if(j>0){var E=i[4*f+p]<<32-8*j^u[f][p];b.push(E),m+=j}var I=new a(b,m);c.concat(I)}}return c.nSigBytes=e.nSigBytes,c.clamp(),c},r.mac=function(n,t,e,i,o,u){var f=new n({key:t,iv:e}),c=[0,0,0,0];f.encryptBlock(c,0);var h=r.getJ0(c,e.words),v=(null==i?void 0:i.clone())||new a,l=[0,8*v.nSigBytes],w=(null==o?void 0:o.clone())||new a,d=[0,8*w.nSigBytes],y=u||16;s(v),s(w);var b,m=v.words.concat(w.words).concat(l).concat(d),p=r.GHASH(c,m),A=r.GCTR(f,h,new a(p));return b=y,new a(A.words.slice(),b)},r.createEncryptor=function(n){return new r.Encryptor(n)},r.createDecryptor=function(n){return new r.Decryptor(n)},r.Encryptor=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return h(t,n),t.prototype.processBlock=function(n,t){var e=this.u.blockSize;this.A=r.inc32(this.A);for(var i=new a(n.slice(t,t+e)),o=r.GCTR(this.u,this.A,i),u=0;u<e;u++)n[t+u]=o.words[u]},t}(r),r.Decryptor=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return h(t,n),t.prototype.processBlock=function(n,t){var e=this.u.blockSize;this.A=r.inc32(this.A);for(var i=new a(n.slice(t,t+e)),o=r.GCTR(this.u,this.A,i),u=0;u<e;u++)n[t+u]=o.words[u]},t}(r),r}(e);return r}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/mode/OFB.d.ts
0 → 100644
| 1 | +export { OFB } from "../lib/algorithm/cipher/mode/OFB"; | ... | ... |
app/static/content/jscrypto/mode/OFB.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var e=t();for(var o in n.JsCrypto=n.JsCrypto||{},n.JsCrypto.mode=n.JsCrypto=n.JsCrypto||{},n.JsCrypto.mode,e)n.JsCrypto=n.JsCrypto||{},n.JsCrypto.mode[o]=e[o]}}(this,(function(){return function(){"use strict";var n={d:function(t,e){for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},o:function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r:function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"t",{value:!0})}},t={};n.r(t),n.d(t,{OFB:function(){return r}});var e,o=function(){function n(n){this.i=n,this.u=n.cipher,this.l=n.iv}return n.prototype.processBlock=function(n,t){},n.createEncryptor=function(n){throw new Error("Not implemented yet")},n.createDecryptor=function(n){throw new Error("Not implemented yet")},n}(),i=(e=function(n,t){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e])})(n,t)},function(n,t){function o(){this.constructor=n}e(n,t),n.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}),r=function(n){function t(t){var e=n.call(this,t)||this;return e.h=[],e}return i(t,n),t.createEncryptor=function(n){return new t.Encryptor(n)},t.createDecryptor=function(n){return new t.Decryptor(n)},t.Encryptor=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return i(t,n),t.prototype.processBlock=function(n,t){var e=this.u,o=e.blockSize,i=this.l,r=this.h;i&&(r=this.h=i.words.slice(0),this.l=void 0),e.encryptBlock(r,0);for(var u=0;u<o;u++)n[t+u]^=r[u]},t}(t),t.Decryptor=t.Encryptor,t}(o);return t}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/package.json
0 → 100644
| 1 | +{ | |
| 2 | + "name": "jscrypto", | |
| 3 | + "version": "1.0.3", | |
| 4 | + "main": "./index.js", | |
| 5 | + "author": "Izumi Hoshino <rindo.hinase@gmail.com>", | |
| 6 | + "license": "MIT", | |
| 7 | + "description": "crypto-js enhancement for modern js environment", | |
| 8 | + "homepage": "https://github.com/Hinaser/jscrypto/blob/master/API.md", | |
| 9 | + "keywords": [ | |
| 10 | + "crypt", | |
| 11 | + "crypto", | |
| 12 | + "cipher", | |
| 13 | + "hash", | |
| 14 | + "MD5", | |
| 15 | + "SHA1", | |
| 16 | + "SHA256", | |
| 17 | + "SHA512", | |
| 18 | + "HMAC-SHA1", | |
| 19 | + "HMAC-SHA256", | |
| 20 | + "AES", | |
| 21 | + "DES", | |
| 22 | + "Triple-DES", | |
| 23 | + "OpenSSL", | |
| 24 | + "GCM", | |
| 25 | + "GMAC", | |
| 26 | + "CCM", | |
| 27 | + "CBC-MAC" | |
| 28 | + ], | |
| 29 | + "repository": { | |
| 30 | + "type": "git", | |
| 31 | + "url": "https://github.com/Hinaser/jscrypto.git" | |
| 32 | + }, | |
| 33 | + "bugs": "https://github.com/Hinaser/jscrypto/issues", | |
| 34 | + "bin": { | |
| 35 | + "jscrypto": "bin/cli.js" | |
| 36 | + }, | |
| 37 | + "browser": { | |
| 38 | + "crypto": false | |
| 39 | + } | |
| 40 | +} | |
| \ No newline at end of file | ... | ... |
| 1 | +export { AnsiX923 } from "../lib/algorithm/cipher/pad/AnsiX923"; | ... | ... |
app/static/content/jscrypto/pad/AnsiX923.js
0 → 100644
| 1 | +!function(e,n){if("object"==typeof exports&&"object"==typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else if("object"==typeof exports)exports.JsCrypto=n();else{var t=n();for(var o in e.JsCrypto=e.JsCrypto||{},e.JsCrypto.pad=e.JsCrypto=e.JsCrypto||{},e.JsCrypto.pad,t)e.JsCrypto=e.JsCrypto||{},e.JsCrypto.pad[o]=t[o]}}(this,(function(){return function(){"use strict";var e={d:function(n,t){for(var o in t)e.o(t,o)&&!e.o(n,o)&&Object.defineProperty(n,o,{enumerable:!0,get:t[o]})},o:function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"t",{value:!0})}},n={};e.r(n),e.d(n,{AnsiX923:function(){return t}});var t={pad:function(e,n){var t=e.nSigBytes,o=4*n,f=o-t%o,u=t+f-1;e.clamp(),e.words[u>>>2]|=f<<24-u%4*8,e.nSigBytes+=f},unpad:function(e){var n=255&e.words[e.nSigBytes-1>>>2];e.nSigBytes-=n}};return n}()})); | |
| \ No newline at end of file | ... | ... |
| 1 | +export { ISO10126 } from "../lib/algorithm/cipher/pad/ISO10126"; | ... | ... |
app/static/content/jscrypto/pad/ISO10126.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var r=t();for(var e in n.JsCrypto=n.JsCrypto||{},n.JsCrypto.pad=n.JsCrypto=n.JsCrypto||{},n.JsCrypto.pad,r)n.JsCrypto=n.JsCrypto||{},n.JsCrypto.pad[e]=r[e]}}(this,(function(){return function(){"use strict";var n={d:function(t,r){for(var e in r)n.o(r,e)&&!n.o(t,e)&&Object.defineProperty(t,e,{enumerable:!0,get:r[e]})}};n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),n.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},n.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"t",{value:!0})};var t={};n.r(t),n.d(t,{ISO10126:function(){return f}});var r,e=function(n){for(var t=n.nSigBytes,r=n.words,e=[],i=0;i<t;i++){var o=r[i>>>2]>>>24-i%4*8&255;e.push((o>>>4).toString(16)),e.push((15&o).toString(16))}return e.join("")},i="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(r=parseInt((/msie (\d+)/.exec(i)||[])[1],10),isNaN(r)?(r=parseInt((/trident\/.*; rv:(\d+)/.exec(i)||[])[1],10),!isNaN(r)&&r):r);var a=function(){if("undefined"!=typeof window){var t=window.crypto||window.msCrypto;if(!t){if(function(n,t){return!1!==o&&(!t||("<"===n?o<t:"<="===n?o<=t:">"===n?o>t:">="===n?o>=t:o===t))}("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return t.getRandomValues(new Uint32Array(1))[0]}}return void 0!==n.g&&n.g.crypto?function(){return n.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}(),u=function(){function n(t,r){if(Array.isArray(t)||!t)return this.i=Array.isArray(t)?t:[],void(this.u="number"==typeof r?r:4*this.i.length);if(t instanceof n)return this.i=t.words.slice(),void(this.u=t.nSigBytes);var e;try{t instanceof ArrayBuffer?e=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(e=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!e)throw new Error("Invalid argument");for(var i=e.byteLength,o=[],a=0;a<i;a++)o[a>>>2]|=e[a]<<24-a%4*8;this.i=o,this.u=i}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.u},set:function(n){this.u=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.i},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):e(this)},n.prototype.toUint8Array=function(){for(var n=this.i,t=this.u,r=new Uint8Array(t),e=0;e<t;e++)r[e]=n[e>>>2]>>>24-e%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.u%4)for(var e=0;e<r;e++){var i=t[e>>>2]>>>24-e%4*8&255;this.i[this.u+e>>>2]|=i<<24-(this.u+e)%4*8}else for(e=0;e<r;e+=4)this.i[this.u+e>>>2]=t[e>>>2];return this.u+=r,this},n.prototype.clamp=function(){var n=this.u;this.i[n>>>2]&=4294967295<<32-n%4*8,this.i.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.i.slice(),this.u)},n.random=function(t){for(var r=[],e=0;e<t;e+=4)r.push(a());return new n(r,t)},n}();var f={pad:function(n,t){var r=4*t,e=r-n.nSigBytes%r;n.concat(u.random(e-1)).concat(new u([e<<24],1))},unpad:function(n){var t=255&n.words[n.nSigBytes-1>>>2];n.nSigBytes-=t}};return t}()})); | |
| \ No newline at end of file | ... | ... |
| 1 | +export { ISO97971 } from "../lib/algorithm/cipher/pad/ISO97971"; | ... | ... |
app/static/content/jscrypto/pad/ISO97971.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var r=t();for(var e in n.JsCrypto=n.JsCrypto||{},n.JsCrypto.pad=n.JsCrypto=n.JsCrypto||{},n.JsCrypto.pad,r)n.JsCrypto=n.JsCrypto||{},n.JsCrypto.pad[e]=r[e]}}(this,(function(){return function(){"use strict";var n={d:function(t,r){for(var e in r)n.o(r,e)&&!n.o(t,e)&&Object.defineProperty(t,e,{enumerable:!0,get:r[e]})}};n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),n.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},n.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"t",{value:!0})};var t={};n.r(t),n.d(t,{ISO97971:function(){return s}});var r,e=function(n){for(var t=n.nSigBytes,r=n.words,e=[],i=0;i<t;i++){var o=r[i>>>2]>>>24-i%4*8&255;e.push((o>>>4).toString(16)),e.push((15&o).toString(16))}return e.join("")},i="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(r=parseInt((/msie (\d+)/.exec(i)||[])[1],10),isNaN(r)?(r=parseInt((/trident\/.*; rv:(\d+)/.exec(i)||[])[1],10),!isNaN(r)&&r):r);var a=function(){if("undefined"!=typeof window){var t=window.crypto||window.msCrypto;if(!t){if(function(n,t){return!1!==o&&(!t||("<"===n?o<t:"<="===n?o<=t:">"===n?o>t:">="===n?o>=t:o===t))}("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return t.getRandomValues(new Uint32Array(1))[0]}}return void 0!==n.g&&n.g.crypto?function(){return n.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}(),u=function(){function n(t,r){if(Array.isArray(t)||!t)return this.i=Array.isArray(t)?t:[],void(this.u="number"==typeof r?r:4*this.i.length);if(t instanceof n)return this.i=t.words.slice(),void(this.u=t.nSigBytes);var e;try{t instanceof ArrayBuffer?e=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(e=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!e)throw new Error("Invalid argument");for(var i=e.byteLength,o=[],a=0;a<i;a++)o[a>>>2]|=e[a]<<24-a%4*8;this.i=o,this.u=i}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.u},set:function(n){this.u=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.i},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):e(this)},n.prototype.toUint8Array=function(){for(var n=this.i,t=this.u,r=new Uint8Array(t),e=0;e<t;e++)r[e]=n[e>>>2]>>>24-e%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.u%4)for(var e=0;e<r;e++){var i=t[e>>>2]>>>24-e%4*8&255;this.i[this.u+e>>>2]|=i<<24-(this.u+e)%4*8}else for(e=0;e<r;e+=4)this.i[this.u+e>>>2]=t[e>>>2];return this.u+=r,this},n.prototype.clamp=function(){var n=this.u;this.i[n>>>2]&=4294967295<<32-n%4*8,this.i.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.i.slice(),this.u)},n.random=function(t){for(var r=[],e=0;e<t;e+=4)r.push(a());return new n(r,t)},n}();var f={pad:function(n,t){var r=4*t;n.clamp(),n.nSigBytes+=r-(n.nSigBytes%r||r)},unpad:function(n){for(var t=n.words,r=n.nSigBytes-1;r>=0;r--)if(t[r>>>2]>>>24-r%4*8&255){n.nSigBytes=r+1;break}}};var s={pad:function(n,t){n.concat(new u([2147483648],1)),f.pad(n,t)},unpad:function(n){f.unpad(n),n.nSigBytes-=1}};return t}()})); | |
| \ No newline at end of file | ... | ... |
| 1 | +export { NoPadding } from "../lib/algorithm/cipher/pad/NoPadding"; | ... | ... |
app/static/content/jscrypto/pad/NoPadding.js
0 → 100644
| 1 | +!function(e,n){if("object"==typeof exports&&"object"==typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else if("object"==typeof exports)exports.JsCrypto=n();else{var t=n();for(var o in e.JsCrypto=e.JsCrypto||{},e.JsCrypto.pad=e.JsCrypto=e.JsCrypto||{},e.JsCrypto.pad,t)e.JsCrypto=e.JsCrypto||{},e.JsCrypto.pad[o]=t[o]}}(this,(function(){return function(){"use strict";var e={d:function(n,t){for(var o in t)e.o(t,o)&&!e.o(n,o)&&Object.defineProperty(n,o,{enumerable:!0,get:t[o]})},o:function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"t",{value:!0})}},n={};e.r(n),e.d(n,{NoPadding:function(){return t}});var t={pad:function(e,n){},unpad:function(e){}};return n}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/pad/Pkcs7.d.ts
0 → 100644
| 1 | +export { Pkcs7 } from "../lib/algorithm/cipher/pad/Pkcs7"; | ... | ... |
app/static/content/jscrypto/pad/Pkcs7.js
0 → 100644
| 1 | +!function(n,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else if("object"==typeof exports)exports.JsCrypto=t();else{var r=t();for(var e in n.JsCrypto=n.JsCrypto||{},n.JsCrypto.pad=n.JsCrypto=n.JsCrypto||{},n.JsCrypto.pad,r)n.JsCrypto=n.JsCrypto||{},n.JsCrypto.pad[e]=r[e]}}(this,(function(){return function(){"use strict";var n={d:function(t,r){for(var e in r)n.o(r,e)&&!n.o(t,e)&&Object.defineProperty(t,e,{enumerable:!0,get:r[e]})}};n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),n.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},n.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"t",{value:!0})};var t={};n.r(t),n.d(t,{Pkcs7:function(){return f}});var r,e=function(n){for(var t=n.nSigBytes,r=n.words,e=[],i=0;i<t;i++){var o=r[i>>>2]>>>24-i%4*8&255;e.push((o>>>4).toString(16)),e.push((15&o).toString(16))}return e.join("")},i="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",o=(r=parseInt((/msie (\d+)/.exec(i)||[])[1],10),isNaN(r)?(r=parseInt((/trident\/.*; rv:(\d+)/.exec(i)||[])[1],10),!isNaN(r)&&r):r);var a=function(){if("undefined"!=typeof window){var t=window.crypto||window.msCrypto;if(!t){if(function(n,t){return!1!==o&&(!t||("<"===n?o<t:"<="===n?o<=t:">"===n?o>t:">="===n?o>=t:o===t))}("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return t.getRandomValues(new Uint32Array(1))[0]}}return void 0!==n.g&&n.g.crypto?function(){return n.g.crypto.randomBytes(4).readInt32LE()}:function(){return require("crypto").randomBytes(4).readInt32LE()}}(),u=function(){function n(t,r){if(Array.isArray(t)||!t)return this.i=Array.isArray(t)?t:[],void(this.u="number"==typeof r?r:4*this.i.length);if(t instanceof n)return this.i=t.words.slice(),void(this.u=t.nSigBytes);var e;try{t instanceof ArrayBuffer?e=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(e=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!e)throw new Error("Invalid argument");for(var i=e.byteLength,o=[],a=0;a<i;a++)o[a>>>2]|=e[a]<<24-a%4*8;this.i=o,this.u=i}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.u},set:function(n){this.u=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.i},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):e(this)},n.prototype.toUint8Array=function(){for(var n=this.i,t=this.u,r=new Uint8Array(t),e=0;e<t;e++)r[e]=n[e>>>2]>>>24-e%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.u%4)for(var e=0;e<r;e++){var i=t[e>>>2]>>>24-e%4*8&255;this.i[this.u+e>>>2]|=i<<24-(this.u+e)%4*8}else for(e=0;e<r;e+=4)this.i[this.u+e>>>2]=t[e>>>2];return this.u+=r,this},n.prototype.clamp=function(){var n=this.u;this.i[n>>>2]&=4294967295<<32-n%4*8,this.i.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.i.slice(),this.u)},n.random=function(t){for(var r=[],e=0;e<t;e+=4)r.push(a());return new n(r,t)},n}();var f={pad:function(n,t){for(var r=4*t,e=r-n.nSigBytes%r,i=e<<24|e<<16|e<<8|e,o=[],a=0;a<e;a+=4)o.push(i);var f=new u(o,e);n.concat(f)},unpad:function(n){var t=255&n.words[n.nSigBytes-1>>>2];n.nSigBytes-=t}};return t}()})); | |
| \ No newline at end of file | ... | ... |
app/static/content/jscrypto/pad/Zero.d.ts
0 → 100644
| 1 | +export { Zero } from "../lib/algorithm/cipher/pad/Zero"; | ... | ... |
app/static/content/jscrypto/pad/Zero.js
0 → 100644
| 1 | +!function(e,n){if("object"==typeof exports&&"object"==typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else if("object"==typeof exports)exports.JsCrypto=n();else{var o=n();for(var t in e.JsCrypto=e.JsCrypto||{},e.JsCrypto.pad=e.JsCrypto=e.JsCrypto||{},e.JsCrypto.pad,o)e.JsCrypto=e.JsCrypto||{},e.JsCrypto.pad[t]=o[t]}}(this,(function(){return function(){"use strict";var e={d:function(n,o){for(var t in o)e.o(o,t)&&!e.o(n,t)&&Object.defineProperty(n,t,{enumerable:!0,get:o[t]})},o:function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"t",{value:!0})}},n={};e.r(n),e.d(n,{Zero:function(){return o}});var o={pad:function(e,n){var o=4*n;e.clamp(),e.nSigBytes+=o-(e.nSigBytes%o||o)},unpad:function(e){for(var n=e.words,o=e.nSigBytes-1;o>=0;o--)if(n[o>>>2]>>>24-o%4*8&255){e.nSigBytes=o+1;break}}};return n}()})); | |
| \ No newline at end of file | ... | ... |
| ... | ... | @@ -21,6 +21,10 @@ |
| 21 | 21 | <script src="{{ url_for('static',filename='content/js/bootstrap-notify.min.js') }}"></script> |
| 22 | 22 | <script src="{{ url_for('static',filename='content/js/tips.js') }}"></script> |
| 23 | 23 | <script src="{{ url_for('static',filename='content/js/login.js') }}"></script> |
| 24 | + <script src="{{ url_for('static',filename='content/jscrypto/index.js') }}"></script> | |
| 25 | + <script src="{{ url_for('static',filename='content/jscrypto/Utf8.js') }}"></script> | |
| 26 | + <script src="{{ url_for('static',filename='content/jscrypto/mode/CBC.js') }}"></script> | |
| 27 | + <script src="{{ url_for('static',filename='content/jscrypto/pad/Pkcs7.js') }}"></script> | |
| 24 | 28 | </head> |
| 25 | 29 | </html> |
| 26 | 30 | |
| ... | ... | @@ -28,9 +32,10 @@ |
| 28 | 32 | <div class="login-container"> |
| 29 | 33 | <p class="login-container-logo"></p> |
| 30 | 34 | <div class="login-container-form"> |
| 31 | - | |
| 32 | 35 | {%if error%} |
| 33 | - <p class="login-container-header-small login-container-header">广州城市信息研究所有限公司</p> | |
| 36 | + <p class="login-container-header-small login-container-header"> | |
| 37 | + 广州城市信息研究所有限公司 | |
| 38 | + </p> | |
| 34 | 39 | <div class="form-tip"> |
| 35 | 40 | <span class="stop"></span> |
| 36 | 41 | <p>{{error}}</p> |
| ... | ... | @@ -39,7 +44,7 @@ |
| 39 | 44 | <p class="login-container-header">广州城市信息研究所有限公司</p> |
| 40 | 45 | {% endif %} |
| 41 | 46 | |
| 42 | - <form action="" method="post"> | |
| 47 | + <form> | |
| 43 | 48 | <div class="form-group has-feedback feedback-left"> |
| 44 | 49 | <input |
| 45 | 50 | type="text" |
| ... | ... | @@ -77,5 +82,11 @@ |
| 77 | 82 | </div> |
| 78 | 83 | </div> |
| 79 | 84 | <script> |
| 80 | - $(function () {}) | |
| 85 | + $(function () { | |
| 86 | + var form = document.getElementsByTagName('form')[0] | |
| 87 | + form.addEventListener('submit', function (e) { | |
| 88 | + e.preventDefault() | |
| 89 | + }) | |
| 90 | + dmap.login.init() | |
| 91 | + }) | |
| 81 | 92 | </script> | ... | ... |
| ... | ... | @@ -7,4 +7,4 @@ os.environ['AUTHLIB_INSECURE_TRANSPORT'] = '1' |
| 7 | 7 | app: Flask = create_app() |
| 8 | 8 | if __name__ == '__main__': |
| 9 | 9 | app.run(host="0.0.0.0", port="8841", threaded=True, debug=True) |
| 10 | - # app.run(host="0.0.0.0", port="8840", threaded=True) | |
| 10 | + # app.run(host="0.0.0.0", port="8840", threaded=True) | |
| \ No newline at end of file | ... | ... |
请
注册
或
登录
后发表评论