From e9662976f2e53d78b912daf87198ac260b319851 Mon Sep 17 00:00:00 2001 From: Ustimenko Alexander Date: Sat, 10 Dec 2016 01:47:37 +0700 Subject: [PATCH 01/21] Remove dist/min from tree --- dist/gostCrypto.dist.js | 360 ---------------------------------------- dist/gostEngine.dist.js | 139 ---------------- min/gostASN1.min.js | 90 ---------- min/gostCMS.min.js | 33 ---- min/gostCert.min.js | 30 ---- min/gostCipher.min.js | 49 ------ min/gostCoding.min.js | 29 ---- min/gostCrypto.min.js | 38 ----- min/gostDigest.min.js | 27 --- min/gostEngine.min.js | 8 - min/gostKeys.min.js | 60 ------- min/gostRandom.min.js | 6 - min/gostSecurity.min.js | 74 --------- min/gostSign.min.js | 49 ------ 14 files changed, 992 deletions(-) delete mode 100644 dist/gostCrypto.dist.js delete mode 100644 dist/gostEngine.dist.js delete mode 100644 min/gostASN1.min.js delete mode 100644 min/gostCMS.min.js delete mode 100644 min/gostCert.min.js delete mode 100644 min/gostCipher.min.js delete mode 100644 min/gostCoding.min.js delete mode 100644 min/gostCrypto.min.js delete mode 100644 min/gostDigest.min.js delete mode 100644 min/gostEngine.min.js delete mode 100644 min/gostKeys.min.js delete mode 100644 min/gostRandom.min.js delete mode 100644 min/gostSecurity.min.js delete mode 100644 min/gostSign.min.js diff --git a/dist/gostCrypto.dist.js b/dist/gostCrypto.dist.js deleted file mode 100644 index b36f196..0000000 --- a/dist/gostCrypto.dist.js +++ /dev/null @@ -1,360 +0,0 @@ -/* - 2014-2016, Rudolf Nickolaev. All rights reserved. -*/ -(function(b,d){"function"===typeof define&&define.amd?define(d):"object"===typeof exports?module.exports=d():b.GostRandom=d()})(this,function(){function b(){}var d=this.crypto||this.msCrypto,g=this.TypeMismatchError||Error,h=this.QuotaExceededError||Error,f={seed:new Uint8Array(1024),getIndex:0,setIndex:0,set:function(a){1024<=this.setIndex&&(this.setIndex=0);this.seed[this.setIndex++]=a},get:function(){1024<=this.getIndex&&(this.getIndex=0);return this.seed[this.getIndex++]}};if("undefiend"!==typeof document){try{document.addEventListener("mousemove", -function(a){f.set((new Date).getTime()&255^(a.clientX||a.pageX)&255^(a.clientY||a.pageY)&255)},!1)}catch(k){}try{document.addEventListener("keydown",function(a){f.set((new Date).getTime()&255^a.keyCode&255)},!1)}catch(l){}}b.prototype.getRandomValues=function(a){if(!a.byteLength)throw new g("Array is not of an integer type (Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, or Uint32Array)");if(65536a?80>a?2E3+a:1900+a:a):0<=["1"].indexOf(a)&&"SHA"===b.name?(b.version=1,b.length=160):0<=["256","384","512"].indexOf(a)&&"SHA"===b.name?(b.version=2,b.length=parseInt(a)):0<=["40","128"].indexOf(a)&&"RC2"===b.name?(b.version=1,b.length=parseInt(a)):0<=["64","128","256","512"].indexOf(a)?b.length=parseInt(a): -0<=["1000","2000"].indexOf(a)&&(b.iterations=parseInt(a));else if(0<="E-TEST E-A E-B E-C E-D E-SC E-Z D-TEST D-A D-SC".split(" ").indexOf(a))b.sBox=a;else if(0<="S-TEST S-A S-B S-C S-D X-A X-B X-C".split(" ").indexOf(a))b.namedParam=a;else if(0<="S-256-TEST S-256-A S-256-B S-256-C P-256 T-512-TEST T-512-A T-512-B X-256-A X-256-B T-256-TEST T-256-A T-256-B S-256-B T-256-C S-256-C".split(" ").indexOf(a))b.namedCurve=a;else if(0<=["SC","CP","VN"].indexOf(a))b.procreator=a;else if("GOST 28147"===b.name|| -"GOST R 34.12"===b.name||"RC2"===b.name)if(0<=["ES","MAC","KW","MASK"].indexOf(a))b.mode=a;else if(0<=["ECB","CFB","OFB","CTR","CBC"].indexOf(a))b.mode="ES",b.block=a;else if(0<=["CPKW","NOKW","SCKW"].indexOf(a))b.mode="KW",b.keyWrapping=a.replace("KW","");else if(0<=["ZEROPADDING","PKCS5PADDING","NOPADDING","RANDOMPADDING","BITPADDING"].indexOf(a))b.padding=a.replace("PADDING","");else if(0<=["NOKM","CPKM"].indexOf(a))b.keyMeshing=a.replace("KM","");else throw new s("Algorithm "+b.name+" mode "+ -a+" not supported");else if("GOST R 34.11"===b.name||"SHA"===b.name)if(0<="HASH KDF HMAC PBKDF2 PFXKDF CPKDF".split(" ").indexOf(a))b.mode=a;else throw new s("Algorithm "+b.name+" mode "+a+" not supported");else if("GOST R 34.10"===b.name){var c=a.replace(/[\.\s]/g,"");if(0<=c.indexOf("GOST")&&0<=c.indexOf("3411"))b.hash=a;else if(["SIGN","DH","MASK"].indexOf(a))b.mode=a;else throw new s("Algorithm "+b.name+" mode "+a+" not supported");}});b.procreator=a.procreator||b.procreator||"CP";switch(b.name){case "GOST R 34.10":b.keySize= -b.length/(1994===b.version?4:8);break;case "GOST R 34.11":b.keySize=32;break;case "GOST 28147":case "GOST R 34.12":b.keySize=32;break;case "RC2":b.keySize=Math.ceil(b.length/8);break;case "SHA":b.keySize=b.length/8}if("ES"===b.mode&&(a.block&&(b.block=a.block),b.block&&(b.block=b.block.toUpperCase()),a.padding&&(b.padding=a.padding),b.padding&&(b.padding=b.padding.toUpperCase()),a.shiftBits&&(b.shiftBits=a.shiftBits),a.keyMeshing&&(b.keyMeshing=a.keyMeshing),b.keyMeshing&&(b.keyMeshing=b.keyMeshing.toUpperCase()), -"importKey"!==c&&"generateKey"!==c)){b.block=b.block||"ECB";b.padding=b.padding||("CBC"===b.block||"ECB"===b.block?"ZERO":"NO");if("CFB"===b.block||"OFB"===b.block)b.shiftBits=b.shiftBits||b.length;b.keyMeshing=b.keyMeshing||"NO"}"KW"===b.mode&&(a.keyWrapping&&(b.keyWrapping=a.keyWrapping),b.keyWrapping&&(b.keyWrapping=b.keyWrapping.toUpperCase()),"importKey"!==c&&"generateKey"!==c&&(b.keyWrapping=b.keyWrapping||"NO"));"sBox namedParam namedCurve curve param modulusLength".split(" ").forEach(function(c){a[c]&& -(b[c]=a[c])});"importKey"!==c&&"generateKey"!==c&&("GOST 28147"===b.name?b.sBox=b.sBox||("SC"===b.procreator?"E-SC":"E-A"):"GOST R 34.12"===b.name&&64===b.length?b.sBox="E-Z":"GOST R 34.11"===b.name&&1994===b.version?b.sBox=b.sBox||("SC"===b.procreator?"D-SC":"D-A"):"GOST R 34.10"===b.name&&1994===b.version?b.namedParam=b.namedParam||("DH"===b.mode?"X-A":"S-A"):"GOST R 34.10"===b.name&&2001===b.version?b.namedCurve=b.namedCurve||(256===b.length?"SC"===b.procreator?"P-256":"DH"===b.mode?"X-256-A": -"S-256-A":"T-512-A"===b.mode):"GOST R 34.10"===b.name&&2012===b.version&&(b.namedCurve=b.namedCurve||(256===b.length?"SC"===b.procreator?"P-256":"DH"===b.mode?"X-256-A":"S-256-A":"T-512-A"===b.mode)));switch(b.mode){case "DH":a.ukm&&(b.ukm=a.ukm);a["public"]&&(b["public"]=a["public"]);break;case "SIGN":case "KW":a.ukm&&(b.ukm=a.ukm);break;case "ES":case "MAC":a.iv&&(b.iv=a.iv);break;case "KDF":a.label&&(b.label=a.label);a.contex&&(b.context=a.contex);break;case "PBKDF2":a.salt&&(b.salt=a.salt);a.iterations&& -(b.iterations=a.iterations);a.diversifier&&(b.diversifier=a.diversifier);break;case "PFXKDF":a.salt&&(b.salt=a.salt);a.iterations&&(b.iterations=a.iterations);a.diversifier&&(b.diversifier=a.diversifier);break;case "CPKDF":a.salt&&(b.salt=a.salt),a.iterations&&(b.iterations=a.iterations)}if(c&&("ES"!==b.mode&&"SIGN"!==b.mode&&"MAC"!==b.mode&&"HMAC"!==b.mode&&"KW"!==b.mode&&"DH"!==b.mode&&"MASK"!==b.mode&&"generateKey"===c||"ES"!==b.mode&&("encrypt"===c||"decrypt"===c)||"SIGN"!==b.mode&&"MAC"!==b.mode&& -"HMAC"!==b.mode&&("sign"===c||"verify"===c)||"HASH"!==b.mode&&"digest"===c||"KW"!==b.mode&&"MASK"!==b.mode&&("wrapKey"===c||"unwrapKey"===c)||"DH"!==b.mode&&"PBKDF2"!==b.mode&&"PFXKDF"!==b.mode&&"CPKDF"!==b.mode&&"KDF"!==b.mode&&("deriveKey"===c||"deriveBits"===c)))throw new s("Algorithm mode "+b.mode+" not valid for method "+c);a.hash&&(b.hash=a.hash);b.hash&&(("string"===typeof b.hash||b.hash instanceof String)&&b.procreator&&(b.hash=b.hash+"/"+b.procreator),b.hash=g(b.hash,"digest"));a.id&&(b.id= -a.id);return b}function q(a){if(!k||!k.subtle||!a)return!1;var c="string"===typeof a||a instanceof String?c=a:a.name;if(!c)return!1;c=c.toUpperCase();return(0<=c.indexOf("KDF")||0<=c.indexOf("HMAC"))&&a.hash?q(a.hash):-1===c.indexOf("GOST")&&-1===c.indexOf("SHA-1")&&-1===c.indexOf("RC2")&&-1===c.indexOf("?DES")}function F(a,c){if(!a.algorithm)throw new v("Key algorithm not defined");if(!a.algorithm.name)throw new v("Key algorithm name not defined");var d=a.algorithm.name,e="GOST 28147"===d||"GOST R 34.12"=== -d||"RC2"===d,b="GOST R 34.11"===d||"SHA"===d,h="GOST R 34.10"===d;if(!e&&!h&&!b)throw new s("Key algorithm "+d+" is unsupproted");if(!a.type)throw new v("Key type not defined");if((e||b)&&"secret"!==a.type||h&&"public"!==a.type&&"private"!==a.type)throw new B("Key type "+a.type+" is not valid for algorithm "+d);if(!a.usages||!a.usages.indexOf)throw new v("Key usages not defined");d=0;for(e=a.usages.length;dr.usages.indexOf(b[f]))throw B("Key usage not valid for this key");}else b=r.usages;r=r.buffer;var p=d.keySize,l=r.byteLength;if("public"===h||p===l)return r;if(0>2,p=new Uint8Array(c),d,a=0,r=0,g=0;gh?h-65:96h?h-71:47h?h+4:43===h?62:47===h?63:0,a=a|h<<18-6*d;if(3===d||1===l-g){for(d=0;3>d&&r>>(16>>>d&24)&255;a=0}}return p.buffer},encode:function(e){e=new Uint8Array(t(e));for(var l=2,c="",p=e.length,d=0,a=0;a>>l&24),2===l||1===p-a){for(var r=18;0<=r;r-=6)var g=d>>>r&63,g=26>g?g+65:52>g?g+71:62>g?g-4:62===g?43:63===g?47:65,c=c+String.fromCharCode(g);d=0}return c.substr(0,c.length-2+l)+(2===l?"":1===l?"=":"==")}};s.prototype.Base64=C;var w=function(){var e={1026:128,1027:129,8218:130,1107:131,8222:132,8230:133,8224:134,8225:135,8364:136,8240:137,1033:138,8249:139,1034:140,1036:141,1035:142,1039:143,1106:144,8216:145,8217:146,8220:147,8221:148,8226:149,8211:150,8212:151,8482:153,1113:154,8250:155,1114:156, -1116:157,1115:158,1119:159,160:160,1038:161,1118:162,1032:163,164:164,1168:165,166:166,167:167,1025:168,169:169,1028:170,171:171,172:172,173:173,174:174,1031:175,176:176,177:177,1030:178,1110:179,1169:180,181:181,182:182,183:183,1105:184,8470:185,1108:186,187:187,1112:188,1029:189,1109:190,1111:191},l={},c;for(c in e)l[e[c]]=c;return{decode:function(c,d){d=(d||"win1251").toLowerCase().replace("-","");for(var a=[],r=0,g=c.length;rh?a.push(h):(2048>h? -a.push(192+(h>>>6)):(65536>h?a.push(224+(h>>>12)):(2097152>h?a.push(240+(h>>>18)):(67108864>h?a.push(248+(h>>>24)):(a.push(252+(h>>>30)),a.push(128+(h>>>24&63))),a.push(128+(h>>>18&63))),a.push(128+(h>>>12&63))),a.push(128+(h>>>6&63))),a.push(128+(h&63)));else if("unicode"===d||"ucs2"===d||"utf16"===d)if(55296>h||57344<=h&&65536>=h)a.push(h>>>8),a.push(h&255);else{if(65536<=h&&1114112>h){var h=h-65536,b=((1047552&h)>>10)+55296,h=(1023&h)+56320;a.push(b>>>8);a.push(b&255);a.push(h>>>8);a.push(h&255)}}else"utf32"=== -d||"ucs4"===d?(a.push(h>>>24&255),a.push(h>>>16&255),a.push(h>>>8&255),a.push(h&255)):"win1251"===d?(128<=h&&(h=1040<=h&&1104>h?h-848:e[h]||0),a.push(h)):a.push(h&255)}return(new Uint8Array(a)).buffer},encode:function(e,d){d=(d||"win1251").toLowerCase().replace("-","");for(var a=[],c=new Uint8Array(t(e)),g=0,h=c.length;gb&&g+5>248&&252>b&&g+4>240&&248>b&&g+3b&&g+2b&&g+1b)var n=b-55296<<10,b=c[++g],b=(b<<8)+c[++g],b=n+(b-56320)+65536}else"utf32"===d||"ucs4"===d?(b=(b<<8)+c[++g],b=(b<<8)+c[++g],b=(b<<8)+c[++g]):"win1251"===d&&128<=b&&(b=192<= -b&&256>b?b+848:l[b]||0);a.push(String.fromCharCode(b))}return a.join("")}}}();s.prototype.Chars=w;var F={decode:function(e,l){e=e.replace(/[^A-fa-f0-9]/g,"");var c=Math.ceil(e.length/2),p=new Uint8Array(c);e=(0l.toLowerCase().indexOf("little")))for(var d=0;dl.toLowerCase().indexOf("little")))for(var a=0;an;n++)var z=8*m+n,k=(k<<1)+(z>>=7;while(f);for(n=k.length-1;0<=n;--n)b.push(k[n]+(0===n?0:128))}b=new Uint8Array(b);break;case 12:b=w.decode(a,"utf8");break;case 18:case 22:case 19:case 20:case 21:case 25:case 26:case 27:m=0;for(f=a.length;mg)d.push(l|g&31);else{l|=31;d.push(l);f=g;g=[];do g.push(f&127),f>>>=7;while(f);for(n=g.length-1;0<=n;--n)d.push(g[n]+(0===n?0:128))}if(h&&"CER"===p)d.push(128);else if(p=b.length,127>>=8;while(h);d.push(p.length+128);for(n=p.length-1;0<=n;--n)d.push(p[n])}else d.push(p);c=c.header=new Uint8Array(d);p=new Uint8Array(c.length+b.length);p.set(c,0);p.set(b,c.length); -return p}function l(c,e){var d=e||0,a=d,r,g,h,b,n,k,q;if(c.object)r=c.tagNumber,g=c.tagClass,h=c.tagConstructed,d=c.content,b=c.header,n=c.object instanceof y?new Uint8Array(c.object):null,k=c.object instanceof Array?c.object:null,q=n&&n.length||null;else{b=c[d++];r=b&31;g=b>>6;h=0!==(b&32);if(31===r){r=0;do{if(9007199254740864s;++s)f.push(q>>s&1?"1":"0");a=0}f= -f.reverse().join("")}break;case 4:f=(new Uint8Array(n)).buffer;break;case 6:f="";for(m=v=x=0;mx?40>x?0:1:2,f=k+"."+(x-40*k)):f+="."+x.toString(),v=x=0);if(0k[1]?2E3:1900);q=new B(k[1],+k[2]-1,+k[3],+(k[4]||0),+(k[5]||0),+(k[6]||0),+(k[7]|| -0));a=q.getTimezoneOffset();if(k[8]||23===r)"Z"!==k[8].toUpperCase()&&k[9]&&(a+=parseInt(k[9])),q.setMinutes(q.getMinutes()-a);q.original=f;f=q}else f=(new Uint8Array(n)).buffer}else f=k;return{tagConstructed:h,tagClass:g,tagNumber:r,header:b,content:d,object:f}}return{encode:function(c,l,d){return e(c,l,d).buffer},decode:function(c){return l(c.object?c:new Uint8Array(t(c)),0)}}}();s.prototype.BER=E;s.prototype.PEM={encode:function(e,l){return(l?"-----BEGIN "+l.toUpperCase()+"-----\r\n":"")+C.encode(e instanceof -y?e:E.encode(e))+(l?"\r\n-----END "+l.toUpperCase()+"-----":"")},decode:function(e,l,c,p){var d=/([A-Za-z0-9\+\/\s\=]+)/g.exec(e);d[1].length!==e.length&&(d=!1);!d&&l&&(d=(new RegExp("-----\\s?BEGIN "+l.toUpperCase()+"-----([A-Za-z0-9\\+\\/\\s\\=]+)-----\\s?END "+l.toUpperCase()+"-----","g")).exec(e));d||(d=/-----\s?BEGIN [A-Z0-9\s]+-----([A-Za-z0-9\+\/\s\=]+)-----\s?END [A-Z0-9\s]+-----/g.exec(e));e=d&&d[1+(p||0)];if(!e)throw new u("Not valid PEM format");e=C.decode(e);c&&(e=E.decode(e));return e}}; -A&&(A.coding=new s);return s}); -/* - 2014-2016, Rudolf Nickolaev. All rights reserved. -*/ -(function(x,w){"function"===typeof define&&define.amd?define(["gostCrypto","gostCoding","gostSecurity"],w):"object"===typeof exports?module.exports=w(require("gostCrypto"),require("gostCoding"),require("gostSecurity")):x.GostASN1=w(x.gostCrypto,x.GostCoding,x.GostSecurity)})(this,function(x){function w(){for(var a={},c=0,b=arguments.length;c=c?a:Array(c-a.length+1).join("0")+a}function Ja(a){return 2>=a?a:4>=a?4:8>=a?8:16>=a?16:32>=a?32:64>=a?64:128>=a?128:256>=a?256:512>a?512:1024>a?1024:void 0}function P(a){if(a)throw Error("Invalid format");}function ha(a,c,b,d){"object"!==typeof b&&(b={value:b});void 0!==d&&(b.enumerable=d);Object.defineProperty(a,c,b)}function Ka(a,c,b){for(var d in c)ha(a, -d,c[d],b)}function T(a,c,b,d,e,f){P(void 0===c);c={tagNumber:b,tagClass:d||0,tagConstructed:e||!1,object:c};a=a||"DER";if("DER"===a||"CER"===a)c=ia.encode(c,a);"PEM"===a&&(c=xa.encode(c,f));return c}function Y(a,c,b,d,e){P(void 0===a);"string"===typeof a&&(a=xa.decode(a,e,!1));if(a instanceof O)try{a=xa.decode(lc.encode(a),e,!0)}catch(f){a=ia.decode(a)}b=b||0;d=d||!1;void 0===a.tagNumber&&(a=T(!0,a.object,c,b,a.object instanceof Array),a=ia.decode(a));P(a.tagClass!==b||a.tagNumber!==c||a.tagConstructed!== -d);return 0===b&&5===c?null:a.object}function t(a,c,b,d){"function"!==typeof c&&(d=b,b=c,c=function(){a.apply(this,arguments)});c.prototype=Object.create(a.prototype,{constructor:{value:c},superclass:{value:a.prototype}});b&&Ka(c.prototype,b);if(a!==Object)for(var e in a)c[e]=a[e];c.super=a;d&&Ka(c,d,!0);return c}function La(){}var O=this.ArrayBuffer,I=x.security.algorithms,hb=x.security.names,ib=x.security.identifiers,ba=x.security.attributes,ca=x.security.parameters,ia=x.coding.BER,xa=x.coding.PEM, -lc=x.coding.Chars,jb=x.coding.Hex,kb=x.coding.Int16,U={encode:function(a,c){return"0x"+jb.encode(a,c)},decode:function(a,c,b){"number"===typeof a&&(a=a.toString(16));a=a.replace("0x","");b=b||Ja(a.length);return jb.decode(kc(a,b),c)}},k=t(Object,function(a){this.object=a},{_set:function(a,c,b){a.property(c).set.call(this,b)},_get:function(a,c){return a.property(c).get.call(this)},_call:function(a,c,b){return a.method(c).apply(this,b)},hasProperty:function(a){return this.hasOwnProperty(a)||!!this.constructor.property(a)}, -encode:function(){return this.object}},{decode:function(a){return new this(a)},property:function(a){for(var c=this.prototype;c;){var b=Object.getOwnPropertyDescriptor(c,a);if(b)return b;c=c.superclass}},method:function(a){for(var c=this.prototype;c;){if(c[a])return c[a];c=c.superclass}}}),y=function(a){return t(k,{encode:function(c){return T(c,this.object,a)}},{decode:function(c){return new this(Y(c,a))}})},da=y(1),ea=y(22),ya=y(18),za=y(19),mc=y(20),z=y(12),nc=y(23),A=y(24),oc=y(28),Ma=y(30),pa= -t(y(5),{object:{get:function(){return null},set:function(a){P(null!==a)}}}),lb=function(a){function c(c){return t(y(a),function(a){b.super.call(this,a)},{encode:function(b){return T(b,c[this.object],a)}},{decode:function(b){b=Y(b,a);for(var d in c)if(b===c[d])return new this(d);P(!0)}})}var b=t(y(a),function(a){if(this instanceof b)b.super.apply(this,arguments);else return c(a)});return b},h=lb(2),mb=lb(10),g=function(){function a(a){return a?t(a,{encode:function(c){return T(c,a.method("encode").call(this, -!0),4)}},{decode:function(c){return a.decode.call(this,Y(c,4))}}):c}var c=t(y(4),function(b){if(this instanceof c)c.super.apply(this,arguments);else return a(b)});return c}(),q=function(){function a(a){return a?t(a,{encode:function(c){return T(c,a.method("encode").call(this,!0),3)}},{decode:function(c){return a.decode.call(this,Y(c,3))}}):b}function c(a){return t(k,function(a,c){k.call(this,a);this.numbits=c||0},{encode:function(c){var b=this.object,d=[];if(b instanceof Array){for(var e=0,f=b.length;e< -f;e++){var S=a[b[e]];void 0!==S&&(d[S]="1")}e=0;for(f=Math.max(d.length,this.numbits);e\<\|\~]*$/.test(a)?"printableString":"utf8String"}),fa=r({utcTime:nc,generalTime:A},function(a){return 2050<= -a.getYear()?"generalTime":"utcTime"}),Na=J({type:l,value:k}),Oa={typeName:"type",valueName:"value"},ob=C(Na({serialName:za,countryName:za,dnQualifier:za,emailAddress:ea,domainComponent:ea,SNILS:ya,OGRN:ya,INN:ya},ja)),pc=m(ob,Oa)(),W=r({rdnSequence:pc},"rdnSequence"),pb=F(e({notBefore:fa,notAfter:fa})),qb=J({type:l,value:k}),G=B(qb,Oa),Pa=m(qb,Oa),qc=e({a:h,b:h,seed:d(q)}),rc=g(t(k,{encode:function(){var a=this.object,c=Math.max(Ja(a.x.length-2),Ja(a.y.length-2))/2,b=new Uint8Array(2*c+1);b[0]=4; -b.set(new Uint8Array(U.decode(a.x,!1,c)),1);b.set(new Uint8Array(U.decode(a.y,!1,c)),c+1);return b.buffer}},{decode:function(a){var c=(a.byteLength-1)/2;return new this({x:U.encode(new Uint8Array(a,1,c)),y:U.encode(new Uint8Array(a,c+1,c))})}})),sc=e({fieldType:l,parameters:h}),tc=e({version:h,fieldID:sc,curve:qc,base:rc,order:h,cofactor:d(h)}),uc=e({publicKeyParamSet:l,digestParamSet:l,encryptionParamSet:d(l)}),vc=function(a,c){a=a||k;return t(a,{encode:function(b){return this.object===c?(new pa(null)).encode(b): -a.method("encode").call(this,b)}},{decode:function(b){if(void 0!==b){if(null===b||5===b.tagNumber&&0===b.tagClass)return new this(c);try{return a.decode.call(this,b)}catch(d){}}}})}(l,"id-GostR3411-94-CryptoProParamSet"),wc=r({namedParameters:l,ecParameters:tc,implicitly:d(pa)},function(a){return"string"===typeof a||a instanceof String?"namedParameters":"ecParameters"}),H=function(a,c){return Q(e({algorithm:l,parameters:d(a)}),c)},s=function(){var a=H(k),c=t(k,function(a){if(this instanceof c)c.super.apply(this, -arguments);else return b(a)},{encode:function(c){return(new a(this.object)).encode(c)}},{decode:function(c){return new this(a.decode(c).object)}}),b=function(a){return t(k,{object:{get:function(){if(this.item)return this.item.object},set:function(c){if(c){var b=a[c.id];if(!b)throw Error("Algorithm not supported");this.item=new b(c)}else delete this.item}},encode:function(a){return this.item.encode(a)}},{decode:function(c){"string"===typeof c&&(c=xa.decode(c,void 0,!1));c instanceof O&&(c=ia.decode(c)); -var b=a[hb[c.object[0].object]];if(b){var d=new this;d.item=b.decode(c);return d}throw Error("Algorithm not supported");}})};return c}(),Aa=H(wc,{encode:function(a){return{algorithm:a.id,parameters:"string"===typeof a.namedCurve?ba.namedCurve[a.namedCurve]:{version:1,fieldID:{fieldType:"id-prime-Field",parameters:a.curve.p},curve:{a:a.curve.a,b:a.curve.b},base:{x:a.curve.x,y:a.curve.y},order:a.curve.q,cofactor:1}}},decode:function(a){var c=a.parameters;a=I[a.algorithm];if("string"===typeof c||c instanceof -String)a=w(a,ca[c]);else if("object"===typeof c)a=w(a,{curve:{p:c.fieldID.parameters,a:c.curve.a,b:c.curve.b,x:c.base.x,y:c.base.y,q:c.order}});else throw new DataError("Invalid key paramters");return a}}),L=H(uc,{encode:function(a){var c=a.namedCurve?"namedCurve":"namedParam",b=0<=a.name.indexOf("-94")||0<=a.name.indexOf("-2001")||1994===a.version||2001===a.version?a.sBox||"D-A":0<=a.name.indexOf("-512")||512===a.length?"D-512":"D-256";return{algorithm:a.id,parameters:{publicKeyParamSet:ba[c][a[c]], -digestParamSet:ba.sBox[b],encryptionParamSet:a.encParams&&a.encParams.sBox?ba.sBox[a.encParams.sBox]:void 0}}},decode:function(a){var c=a.parameters;a=w(I[a.algorithm],ca[c.publicKeyParamSet],ca[c.digestParamSet]);c.encryptionParamSet&&(a.encParams=ca[c.encryptionParamSet]);return a}}),u=H(k,{encode:function(a){return{algorithm:a.id}},decode:function(a){return I[a.algorithm]}}),v=H(pa,{encode:function(a){return{algorithm:a.id,parameters:null}},decode:function(a){return I[a.algorithm]}}),qa=H(vc,{encode:function(a){return{algorithm:a.id, -parameters:ba.sBox[a.sBox||a.hash&&a.hash.sBox||"D-A"]}},decode:function(a){var c=w(I[a.algorithm]);a=ca[a.parameters];c.hash?c.hash=w(c.hash,a):c=w(c,a);return c}}),$=s({ecdsa:Aa,noSignature:v,rsaEncryption:v,"id-sc-gostR3410-2001":Aa,"id-GostR3410-2001":L,"id-GostR3410-94":L,"id-GostR3410-2001DH":L,"id-GostR3410-94DH":L,"id-tc26-gost3410-12-256":L,"id-tc26-gost3410-12-512":L,"id-tc26-agreement-gost-3410-12-256":L,"id-tc26-agreement-gost-3410-12-512":L,"id-sc-gost28147-gfb":u,"id-Gost28147-89":u}), -R=s({noSignature:v,rsaEncryption:v,sha1withRSAEncryption:v,sha256withRSAEncryption:v,sha384withRSAEncryption:v,sha512withRSAEncryption:v,ecdsa:u,"ecdsa-with-SHA1":u,"ecdsa-with-SHA256":u,"ecdsa-with-SHA384":u,"ecdsa-with-SHA512":u,"id-GostR3410-94":v,"id-GostR3410-2001":v,"id-GostR3411-94-with-GostR3410-2001":u,"id-GostR3411-94-with-GostR3410-94":u,"id-tc26-gost3410-12-256":v,"id-tc26-gost3410-12-512":v,"id-tc26-signwithdigest-gost3410-12-94":u,"id-tc26-signwithdigest-gost3410-12-256":u,"id-tc26-signwithdigest-gost3410-12-512":u, -"id-sc-gostR3410-94":v,"id-sc-gostR3410-2001":v,"id-sc-gostR3411-94-with-gostR3410-94":v,"id-sc-gostR3411-94-with-gostR3410-2001":v}),la=s({sha1:u,sha256:v,sha384:v,sha512:v,"id-GostR3411-94":qa,"id-tc26-gost3411-94":qa,"id-tc26-gost3411-12-256":v,"id-tc26-gost3411-12-512":v,"id-sc-gostR3411-94":u}),rb=e({iv:g,encryptionParamSet:l}),xc=e({encryptionParamSet:l,ukm:d(g)}),Qa=H(rb,{encode:function(a){return{algorithm:a.id,parameters:{iv:a.iv,encryptionParamSet:ba.sBox[a.sBox||"E-A"]}}},decode:function(a){var c= -w(I[a.algorithm],ca[a.parameters.encryptionParamSet]);c.iv=a.parameters.iv;return c}}),Ra=H(g,{encode:function(a){return{algorithm:a.id,parameters:a.iv}},decode:function(a){var c=w(I[a.algorithm]);c.iv=a.parameters||new Uint8Array([0,0,0,0,0,0,0,0]);return c}}),Ba=H(xc,{encode:function(a){return{algorithm:a.id,parameters:{encryptionParamSet:ba.sBox[a.sBox||"E-A"],ukm:a.ukm}}},decode:function(a){var c=w(I[a.algorithm],ca[a.parameters.encryptionParamSet]);a.parameters.ukm&&(c.ukm=a.parameters.ukm); -return c}}),sb=s({"id-Gost28147-89-None-KeyWrap":Ba,"id-Gost28147-89-CryptoPro-KeyWrap":Ba}),Ca=H(sb,{encode:function(a){return{algorithm:a.id,parameters:a.wrapping}},decode:function(a){var c=w(I[a.algorithm]);c.wrapping=a.parameters;return c}}),yc=s({"id-sc-gost28147-gfb":Ra,"id-Gost28147-89":Qa}),Sa=s({"id-Gost28147-89-MAC":rb,"id-HMACGostR3411-94":qa,"id-tc26-hmac-gost-3411-12-256":qa,"id-tc26-hmac-gost-3411-12-512":qa,hmacWithSHA1:u,hmacWithSHA224:u,hmacWithSHA256:u,hmacWithSHA384:u,hmacWithSHA512:u, -"id-sc-gost28147-mac":u,"id-sc-hmacWithGostR3411":u}),zc=e({salt:r({specified:g,otherSource:s},function(a){return X(a)?"specified":"otherSource"}),iterationCount:h,keyLength:d(h),prf:Sa}),Ac=H(zc,{encode:function(a){return{algorithm:a.id,parameters:{salt:a.salt,iterationCount:a.iterations,prf:a.hmac}}},decode:function(a){var c=w(I[a.algorithm]);c.salt=a.parameters.salt;c.iterations=a.parameters.iterationCount;c.hmac=a.parameters.prf;c.hash=c.hmac.hash;return c}}),Ta=s({PBKDF2:Ac}),tb=e({salt:g,iterationCount:h}), -n=H(tb,{paramType:tb,encode:function(a){return{algorithm:a.id,parameters:{salt:a.derivation.salt,iterationCount:a.derivation.iterations}}},decode:function(a){var c=w(I[a.algorithm]);c.derivation=w(c.derivation,{salt:a.parameters.salt,iterations:a.parameters.iterationCount});return c}}),Bc=e({keyDerivationFunc:Ta,encryptionScheme:yc}),Ua=H(Bc,{encode:function(a){return{algorithm:a.id,parameters:{keyDerivationFunc:a.derivation,encryptionScheme:a.encryption}}},decode:function(a){var c=w(I[a.algorithm]); -c.derivation=a.parameters.keyDerivationFunc;c.encryption=a.parameters.encryptionScheme;return c}});s({"pbeWithSHAAndAES128-CBC":n,"pbeWithSHAAndAES192-CBC":n,"pbeWithSHAAndAES256-CBC":n,"pbeWithSHA256AndAES128-CBC":n,"pbeWithSHA256AndAES192-CBC":n,"pbeWithSHA256AndAES256-CBC":n,"id-sc-pbeWithGost3411AndGost28147":n,"id-sc-pbeWithGost3411AndGost28147CFB":n,"pbeWithSHAAnd3-KeyTripleDES-CBC":n,"pbeWithSHAAnd2-KeyTripleDES-CBC":n,"pbeWithSHAAnd128BitRC2-CBC":n,"pbeWithSHAAnd40BitRC2-CBC":n,pbeUnknownGost:n, -PBES2:Ua});var ra=s({ecdsa:Aa,rsaEncryption:v,"id-sc-gost28147-gfb":Ra,"id-Gost28147-89":Qa,"id-sc-gostR3410-2001":Aa,"id-GostR3410-2001":L,"id-GostR3410-94":L,"id-tc26-gost3410-12-256":L,"id-tc26-gost3410-12-512":L,"id-GostR3410-94-CryptoPro-ESDH":Ca,"id-GostR3410-2001-CryptoPro-ESDH":Ca,"id-tc26-agreement-gost-3410-12-256":Ca,"id-tc26-agreement-gost-3410-12-512":Ca,"id-sc-r3410-ESDH-r3411kdf":v,"id-Gost28147-89-None-KeyWrap":Ba,"id-Gost28147-89-CryptoPro-KeyWrap":Ba,"id-sc-cmsGostWrap":u,"id-sc-cmsGost28147Wrap":u, -"pbeWithSHAAndAES128-CBC":n,"pbeWithSHAAndAES192-CBC":n,"pbeWithSHAAndAES256-CBC":n,"pbeWithSHA256AndAES128-CBC":n,"pbeWithSHA256AndAES192-CBC":n,"pbeWithSHA256AndAES256-CBC":n,"id-sc-pbeWithGost3411AndGost28147":n,"id-sc-pbeWithGost3411AndGost28147CFB":n,"pbeWithSHAAnd3-KeyTripleDES-CBC":n,"pbeWithSHAAnd2-KeyTripleDES-CBC":n,"pbeWithSHAAnd128BitRC2-CBC":n,"pbeWithSHAAnd40BitRC2-CBC":n,pbeUnknownGost:n,PBES2:Ua}),Cc=e({keyDerivationFunc:Ta,messageAuthScheme:Sa}),Dc=H(Cc,{encode:function(a){return{algorithm:a.id, -parameters:{keyDerivationFunc:a.derivation,messageAuthScheme:a.hmac}}},decode:function(a){var c=w(I[a.algorithm]);c.derivation=a.parameters.keyDerivationFunc;c.hmac=a.parameters.messageAuthScheme;return c}});s({PBMAC1:Dc});var Ec=s({"id-sc-gost28147-gfb":Ra,"id-Gost28147-89":Qa,"pbeWithSHAAndAES128-CBC":n,"pbeWithSHAAndAES192-CBC":n,"pbeWithSHAAndAES256-CBC":n,"pbeWithSHA256AndAES128-CBC":n,"pbeWithSHA256AndAES192-CBC":n,"pbeWithSHA256AndAES256-CBC":n,"id-sc-pbeWithGost3411AndGost28147":n,"id-sc-pbeWithGost3411AndGost28147CFB":n, -"pbeWithSHAAnd3-KeyTripleDES-CBC":n,"pbeWithSHAAnd2-KeyTripleDES-CBC":n,"pbeWithSHAAnd128BitRC2-CBC":n,"pbeWithSHAAnd40BitRC2-CBC":n,pbeUnknownGost:n,PBES2:Ua}),ub=Q(q(K(h)),{encode:function(a){return kb.encode(wa(a))},decode:function(a){return wa(kb.decode(a))}}),vb=Q(q(K(g)),{encode:function(a){var c=new Uint8Array(a.byteLength+1),b=wa(a);a=a.byteLength/2;c[0]=4;c.set(new Uint8Array(b,a,a),1);c.set(new Uint8Array(b,0,a),a+1);return c.buffer},decode:function(a){P(0===(a.byteLength&1));var c=new Uint8Array(a.byteLength- -1),b=c.byteLength/2;c.set(new Uint8Array(a,b+1,b),0);c.set(new Uint8Array(a,1,b),b);return wa(c)}}),M=q(K(g)),ma=e({algorithm:$,subjectPublicKey:q},"PUBLIC KEY"),Va=function(a){return Q(J({algorithm:$,subjectPublicKey:k},"algorithm","subjectPublicKey")(function(c){return a[c.id]}),{encode:function(a){return{algorithm:a.algorithm,subjectPublicKey:a.buffer}},decode:function(a){return{algorithm:a.algorithm,type:"public",extractable:!0,usages:["verify","deriveKey","deriveBits"],buffer:a.subjectPublicKey}}})}({"id-sc-gostR3410-2001":vb, -"id-sc-gostR3410-94":ub,"id-GostR3410-2001":M,"id-GostR3410-94":M,"id-tc26-gost3410-12-256":M,"id-tc26-gost3410-12-512":M}),wb=Q(g(K(h)),{encode:function(a){return U.encode(a,!0)},decode:function(a){return U.decode(a,!0)}}),Fc=e({keyValueMask:g,keyValyePublicKey:g}),ga=r({privateKey:g(K(r({keyValueMask:g,keyValueInfo:Fc},function(a){return X(a)?"keyValueMask":"keyValueInfo"}))),keyValueMask:g},function(a){return a.enclosed?"keyValueMask":"privateKey"}),Gc=function(a){return J({version:h,privateKeyAlgorithm:$, -privateKeyWrapped:Q(g(K(e({keyData:h,keyMac:h}))),{encode:function(a){var b=a.byteLength-4;return{keyData:U.encode(new Uint8Array(a,0,b)),keyMac:U.encode(new Uint8Array(a,b,4))}},decode:function(a){var b=U.decode(a.keyData);a=U.decode(a.keyMac);var d=new Uint8Array(b.byteLength+a.byteLength);d.set(new Uint8Array(b));d.set(new Uint8Array(a),b.byteLength);return d}}),attributes:k},"privateKeyAlgorithm","attributes")(function(c){return d(b(0,f(G({"id-sc-gostR3410-2001-publicKey":C(a[c.id])}))))})}({"id-sc-gostR3410-2001":vb, -"id-sc-gostR3410-94":ub,"id-GostR3410-2001":M,"id-GostR3410-94":M,"id-GostR3410-2001DH":M,"id-GostR3410-94DH":M,"id-tc26-gost3410-12-256":M,"id-tc26-gost3410-12-512":M,"id-tc26-agreement-gost-3410-12-256":M,"id-tc26-agreement-gost-3410-12-512":M}),Wa=e({version:h,privateKeyAlgorithm:$,privateKey:g,attributes:d(b(0,f(G)))},"PRIVATE KEY"),Hc=e({version:h,privateKeyAlgorithm:$,privateKey:g,attributes:d(b(0,f(G))),publicKey:d(b(1,f(q)))}),Ic=m(Hc),Jc=function(a){return Q(J({version:h,privateKeyAlgorithm:$, -privateKey:k,attributes:d(b(0,f(G)))},"privateKeyAlgorithm","privateKey")(function(c){return a[c.id]}),{encode:function(a){return{version:0,privateKeyAlgorithm:a.algorithm,privateKey:a.buffer}},decode:function(a){return{algorithm:a.privateKeyAlgorithm,type:"private",extractable:!0,usages:["sign","deriveKey","deriveBits"],buffer:X(a.privateKey)?a.privateKey:a.privateKey.keyValueMask}}})}({"id-sc-gostR3410-2001":wb,"id-sc-gostR3410-94":wb,"id-GostR3410-2001":ga,"id-GostR3410-94":ga,"id-GostR3410-2001DH":ga, -"id-GostR3410-94DH":ga,"id-tc26-gost3410-12-256":ga,"id-tc26-gost3410-12-512":ga,"id-tc26-agreement-gost-3410-12-256":ga,"id-tc26-agreement-gost-3410-12-512":ga}),xb=e({encryptionAlgorithm:ra,encryptedData:g},"ENCRYPTED PRIVATE KEY"),Kc=e({cA:V(da,!1),pathLenConstraint:d(h)}),Lc=q({digitalSignature:0,nonRepudiation:1,keyEncipherment:2,dataEncipherment:3,keyAgreement:4,keyCertSign:5,cRLSign:6,encipherOnly:7,decipherOnly:8}),Mc=m(l),Nc=e({type:l,value:b(0,p(k))}),Oc=e({nameAssigner:d(b(0,f(ja))),partyName:d(b(1, -f(ja)))}),Pc=e({}),D=r({otherName:b(0,f(Nc)),rfc822Name:b(1,f(ja)),dNSName:b(2,f(ja)),x400Address:b(3,f(Pc)),directoryName:b(4,p(W)),ediPartyName:b(5,f(Oc)),uniformResourceIdentifier:b(6,f(ja)),iPAddress:b(7,f(g)),registeredID:b(8,f(l))},function(a){return"string"===typeof a||a instanceof String?0<=a.indexOf("@")?"rfc822Name":"dNSName":X(a)?"iPAddress":"directoryName"}),E=m(D),Xa=e({keyIdentifier:d(b(0,f(g))),authorityCertIssuer:d(b(1,f(E))),authorityCertSerialNumber:d(b(2,f(h)))}),Qc=e({notBefore:d(b(0, -f(A))),notAfter:d(b(1,f(A)))}),Rc=e({policyQualifierId:l,qualifier:k}),Sc=e({policyIdentifier:l,policyQualifiers:d(m(Rc))}),Tc=e({issuerDomainPolicy:l,subjectDomainPolicy:l}),Uc=e({base:D,minimum:V(b(0,f(h)),0),maximum:d(b(1,f(h)))}),yb=m(Uc),Vc=e({permittedSubtrees:d(b(0,f(yb))),excludedSubtrees:d(b(1,f(yb)))}),Wc=e({requireExplicitPolicy:d(b(0,f(h))),inhibitPolicyMapping:d(b(1,f(h)))}),Ya=q({unused:0,keyCompromise:1,cACompromise:2,affiliationChanged:3,superseded:4,cessationOfOperation:5,certificateHold:6, -privilegeWithdrawn:7,aACompromise:8}),zb=r({fullName:b(0,f(E)),nameRelativeToCRLIssuer:b(1,f(ob))},function(a){return a instanceof Array?"fullName":"nameRelativeToCRLIssuer"}),Xc=e({distributionPoint:d(b(0,p(zb))),reasons:d(b(1,f(Ya))),cRLIssuer:d(b(2,f(E)))}),Da=m(Xc),Za=e({accessMethod:l,accessLocation:D}),Ab=function(a,b){var d=J({extnID:l,critical:V(da,!1),extnValue:function(a){return g(K(a))}},"extnID","extnValue"),e=t(d(a),{object:{get:function(){var a=this._get(e.super,"object");a&&"object"=== -typeof a.extnValue&&this.defineValue(a.extnValue);return a},set:function(a){this._set(e.super,"object",a);a&&a.extnValue&&(void 0!==a.extnValue.critical?this.critical=a.extnValue.critical:void 0===this.critical&&b&&(this.critical=b(this.extnID,a.extnValue)))}},extnValue:{get:function(){var a=this._get(e.super,"extnValue");"object"===typeof a&&this.defineValue(a);return a},set:function(a){this._set(e.super,"extnValue",a);a&&(void 0!==a.critical?this.critical=a.critical:void 0===this.critical&&b&&(this.critical= -b(this.extnID,a)))}},defineValue:function(a){if("object"===typeof a&&!Object.getOwnPropertyDescriptor(a,"critical")){var b=this;ha(a,"critical",{get:function(){return b.critical},set:function(a){b.critical=a},enumerable:!0,configurable:!1})}}});return e},Yc=e({signTool:z,cATool:z,signToolCert:z,cAToolCert:z}),na=m(Ab,{typeName:"extnID",valueName:"extnValue"}),Ea=na({authorityKeyIdentifier:Xa,subjectKeyIdentifier:g,keyUsage:Lc,privateKeyUsagePeriod:Qc,certificatePolicies:m(Sc),policyMappings:m(Tc), -subjectAltName:E,issuerAltName:E,subjectDirectoryAttributes:Pa,basicConstraints:Kc,nameConstraints:Vc,policyConstraints:Wc,extKeyUsage:Mc,cRLDistributionPoints:Da,inhibitAnyPolicy:h,freshestCRL:Da,authorityInfoAccess:m(Za),subjectInfoAccess:m(Za),subjectSignTool:z,issuerSignTool:Yc},function(a,b){return"keyUsage"===a||"basicConstraints"===a&&void 0===b.pathLenConstraint}),Zc=e({r:h,s:h}),Bb=F(e({version:b(0,p(h)),serialNumber:h,signature:R,issuer:W,validity:pb,subject:W,subjectPublicKeyInfo:ma,issuerUniqueID:d(b(1, -f(q))),subjectUniqueID:d(b(2,f(q))),extensions:d(b(3,p(Ea)))})),ka=e({tbsCertificate:Bb,signatureAlgorithm:R,signatureValue:q},"CERTIFICATE"),$c=G({challengePassword:C(ja),extensionRequest:C(Ea),msCertExtensions:C(Ea),extendedCertificateAttributes:C(G)}),Cb=F(e({version:h,subject:W,subjectPublicKeyInfo:ma,attributes:b(0,f($c))})),Db=e({requestInfo:Cb,signatureAlgorithm:R,signatureValue:q},"CERTIFICATE REQUEST"),Eb=mb({unspecified:0,keyCompromise:1,cACompromise:2,affiliationChanged:3,superseded:4, -cessationOfOperation:5,certificateHold:6,removeFromCRL:8,privilegeWithdrawn:9,aACompromise:10}),ad=e({distributionPoint:d(b(0,p(zb))),onlyContainsUserCerts:V(b(1,f(da)),!1),onlyContainsCACerts:V(b(2,f(da)),!1),onlySomeReasons:d(b(3,f(Ya))),indirectCRL:V(b(4,f(da)),!1),onlyContainsAttributeCerts:V(b(5,f(da)),!1)}),bd=na({authorityKeyIdentifier:Xa,issuerAltName:E,cRLNumber:h,deltaCRLIndicator:h,issuingDistributionPoint:ad,freshestCRL:Da},function(a){return"cRLNumber"===a}),cd=na({cRLReason:Eb,instructionCode:l, -invalidityDate:A,certificateIssuer:E}),Fb=F(e({version:d(h),signature:R,issuer:W,thisUpdate:fa,nextUpdate:d(fa),revokedCertificates:d(m(e({userCertificate:h,revocationDate:fa,crlEntryExtensions:d(cd)}))),crlExtensions:d(b(0,p(bd)))})),$a=e({tbsCertList:Fb,signatureAlgorithm:R,signatureValue:q},"CRL"),ab=e({digestedObjectType:mb({publicKey:0,publicKeyCert:1,otherObjectTypes:2}),otherObjectTypeID:d(l),digestAlgorithm:la,objectDigest:q}),Fa=e({issuer:E,serial:h,issuerUID:d(q)}),dd=e({issuerName:d(E), -baseCertificateID:d(b(0,f(Fa))),objectDigestInfo:d(b(1,f(ab)))}),ed=e({targetCertificate:Fa,targetName:d(D),certDigestInfo:d(ab)}),fd=r({targetName:b(0,p(D)),targetGroup:b(1,p(D)),targetCert:b(2,f(ed))}),gd=m(fd),hd=na({auditIdentity:g,targetInformation:gd,authorityKeyIdentifier:Xa,authorityInfoAccess:m(Za),cRLDistributionPoints:Da,noRevAvail:pa},function(a){return"auditIdentity"===a||"targetInformation"===a}),id=e({baseCertificateID:d(b(0,f(Fa))),entityName:d(b(1,f(E))),objectDigestInfo:d(b(2,f(ab)))}), -jd=r({v1Form:E,v2Form:b(0,f(dd))},"v2Form"),Gb=e({notBeforeTime:A,notAfterTime:A}),Hb=e({service:D,ident:D,authInfo:d(g)}),kd=e({roleAuthority:d(b(0,f(E))),roleName:b(1,p(D))}),ld=q({unmarked:0,unclassified:1,restricted:2,confidential:3,secret:4,topSecret:5}),md=e({type:b(0,f(l)),value:b(1,f(k))}),nd=e({policyId:b(0,f(l)),classList:V(b(1,f(ld)),["unclassified"]),securityCategories:d(b(2,f(B(md))))}),Ib=e({policyAuthority:d(b(0,f(E))),values:m(r({octets:g,oid:l,string:z},function(a){return X?"octets": -getIdentifier(a)?"oid":"string"}))}),Jb=F(e({version:h,holder:id,issuer:jd,signature:R,serialNumber:h,attrCertValidityPeriod:Gb,attributes:Pa({authenticationInfo:B(Hb),accessIdentity:B(Hb),chargingIdentity:C(Ib),group:C(Ib),role:B(kd),clearance:B(nd)}),issuerUniqueID:d(q),extensions:d(hd)})),Kb=e({acinfo:Jb,signatureAlgorithm:R,signatureValue:q},"ATTRIBUTE CERTIFICATE"),oa=g,sa=g;e({keyInfo:sb,entityUInfo:d(b(0,p(g))),suppPubInfo:b(2,p(g))});var N=Q(e({encryptedKey:g,maskKey:d(b(0,f(g))),macKey:g}), -{encode:function(a){var b=(new Uint8Array(new Uint8Array(a,0,32))).buffer;a=(new Uint8Array(new Uint8Array(a,32,4))).buffer;return{encryptedKey:b,macKey:a}},decode:function(a){var b=a.encryptedKey,d=a.maskKey;a=a.macKey;if(d)for(var d=new Int32Array(d),e=new Int32Array(b),f=0,g=d.length/e.length;fb.date.getTime())}function C(a,b,c){a={subject:a.issuer,date:c};if(b=b&&b.authorityKeyIdentifier)a.subjectKeyIdentifier=b.keyIdentifier,b.authorityCertIssuer&&b.authorityCertIssuer[0]&&b.authorityCertSerialNumber&& -(a.issuer=b.authorityCertIssuer[0],a.serialNumber=b.authorityCertSerialNumber);return a}function A(a,b){for(var c=[],d=0,e=a.length;dc.getTime()||d.notAfter.getTime()<=c.getTime())throw Error("The certificate has not yet started or expired");for(var b in e)if(e[b].critical&&0>"authorityKeyIdentifier subjectKeyIdentifier keyUsage certificatePolicies policyMappings basicConstraints nameConstraints policyConstraints extKeyUsage".split(" ").indexOf(b))throw Error("The critical extension '"+ -b+"' is unrecognized");b=C(d,e,d.notBefore);!a&&x(d,b)&&(a=d);if(a){if(!x(a,b)||!a.checkUsage("keyCertSign",d.notBefore))throw Error("The issuer's certificate is not valid");return a.verifySignature(d.tbsCertificate.encode(),d.signatureValue,d.signatureAlgorithm)}return!0}).then(function(a){if(!a)throw Error("The certificate has invalid signature");if(b){if(!H(b,{issuer:d.issuer,date:c}))throw Error("The issuer's CRL is not valid");if(b.isRevoked(d.serialNumber))throw Error("The certificate is revoked"); -}return d})},verifySignature:function(a,b,c){return this.getPublicKey().then(function(d){return k.verify(c,d,b,a)})},checkUsage:function(a,b){var c=this.extensions;b=b||w();return this.notBefore.getTime()<=b.getTime()&&this.notAfter.getTime()>b.getTime()&&(!c||!(0<["keyCertSign","cRLSign"].indexOf(a)&&c.basicConstraints&&!c.basicConstraints.cA||c.keyUsage&&0>c.keyUsage.indexOf(a)&&c.extKeyUsage&&0>c.extKeyUsage.indexOf(a)))}});r.prototype.X509=u;var z=function(a){z.super.call(this,a);this.version|| -(this.version=1);this.revokedCertificates||(this.revokedCertificates=[]);this.thisUpdate||(this.thisUpdate=w())};t(h.CertificateList,z,{sign:function(a,b){var c=this;return(new n(q)).then(function(){if(!a)throw Error("The issuer's private key is not defined");if(!b)throw Error("The issuer's certificate is not defined");if(!c.issuer)c.issuer=b.issuer;else if(!B(c.issuer,b.issuer))throw Error("The CRL prototype and authority certificate have different issuers");if(!b.checkUsage("cRLSign",c.thisUpdate))throw Error("The issuer's certificate is not valid for signing a CRL"); -var d=b.getProvider()||s[l.providerName];c.signature||(c.signature=d.signature);c.signatureAlgorithm=c.signature;c.issuer=b.subject;c.crlExtensions||(c.crlExtensions={});var d=c.crlExtensions,e=b.extensions;e&&e.subjectKeyIdentifier&&(d.authorityKeyIdentifier={keyIdentifier:e.subjectKeyIdentifier,authorityCertIssuer:[b.issuer],authorityCertSerialNumber:b.serialNumber});d.cRLNumber=d.cRLNumber||0;return k.importKey("pkcs8",a.encode(),a.privateKeyAlgorithm,!1,["sign"])}).then(function(a){return k.sign(c.signatureAlgorithm, -a,c.tbsCertList.encode())}).then(function(a){c.signatureValue=a;return c})},verify:function(a,b){var c=this,d=c.crlExtensions;return(new n(q)).then(function(){b=b||w();if(!c.thisUpdate.getTime()>b.getTime())throw Error("The CRL has not yet started");if(a){if(!x(a,C(c,d,c.thisUpdate))||!a.checkUsage("cRLSign",c.thisUpdate))throw Error("The issuer's certificate is not valid");if(!c.signatureValue||!c.signatureAlgorithm)throw Error("The has no signature");return a.verifySignature(c.tbsCertList.encode(), -c.signatureValue,c.signatureAlgorithm)}}).then(function(a){if(!a)throw Error("The CRL has invalid signature");return c})},isRevoked:function(a,b){var c=this.revokedCertificates;b=b||w();for(var d=0;d=c[d].revocationDate.getTime()&&G(c[d].userCertificate,a))return!0;return!1}});r.prototype.CRL=z;t(h.CertificationRequest,K,{generate:function(a){var b=this,c,d;(d=a?s[a]:this.getProvider()||s[l.providerName])&&(a=v(d.publicKey,{privateKey:d.privateKey}));return(new n(q)).then(function(){return k.generateKey(a, -"true",["sign","verify"])}).then(function(a){c=a.privateKey;return k.exportKey("spki",a.publicKey)}).then(function(a){b.subjectPublicKeyInfo=new h.SubjectPublicKeyInfo(a);return k.exportKey("pkcs8",c)}).then(function(a){c=new h.PrivateKeyInfo(a);return b.sign(c)}).then(function(){return c})},getProvider:function(){return E(this.subjectPublicKeyInfo.algorithm)},sign:function(a){var b=this,c=b.subjectPublicKeyInfo;return(new n(q)).then(function(){if(!c||!c.algorithm||"noSignature"===c.algorithm)throw Error("Key pair was not generated for the certificate"); -if(!a)throw Error("The private key is not defined");var d=E(c.algorithm)||s[l.providerName];b.signatureAlgorithm=d.signature;return k.importKey("pkcs8",a.encode(),a.privateKeyAlgorithm,!1,["sign"])}).then(function(a){return k.sign(b.signatureAlgorithm,a,b.requestInfo.encode())}).then(function(a){b.signatureValue=a;return b})},verify:function(){var a=this,b=a.subjectPublicKeyInfo;return(new n(q)).then(function(){return k.importKey("spki",b.encode(),b.algorithm,"false",["verify"])}).then(function(b){return k.verify(a.signatureAlgorithm, -b,a.signatureValue,a.requestInfo.encode())}).then(function(b){if(!b)throw Error("The certification request has invalid signature");return a})}});r.prototype.Request=K;t(y,L,{getCertificates:function(a){return A(this.certificates,a)},getCRLs:function(a){return I(this.certificates,a)},load:function(a){var b=new h.ContentInfo(a);a=b.certificates;for(var b=b.crls,c=0;c>>8&255);c.push(0);c.push(0)}return(new Uint8Array(c)).buffer}return 0<=a.name.indexOf("PFXKDF")?A.Chars.decode(b+"\x00","unicode"):A.Chars.decode(b,"utf8")}function x(){}function q(a,b){t.ContentInfo.call(this,a||b||{contentType:"data"});if(b&&this.contentType!==(b.contentType||"data"))throw Error("Invalid content type");}function J(a){q.call(this,a,{contentType:"digestedData",version:0,digestAlgorithm:v[r.providerName].digest, -encapContentInfo:{eContentType:"data"},digest:new w(0)})}function K(a){q.call(this,a,{contentType:"signedData",version:1,digestAlgorithms:[],encapContentInfo:{eContentType:"data"},signerInfos:[]})}function L(a){q.call(this,a,{contentType:"encryptedData",version:0,encryptedContentInfo:{contentType:"data",contentEncryptionAlgorithm:v[r.providerName].encryption}})}function M(a){q.call(this,a,{contentType:"envelopedData",version:0,recipientInfos:[],encryptedContentInfo:{contentType:"data",contentEncryptionAlgorithm:v[r.providerName].encryption}})} -var m=this.Promise,D=this.Object,w=this.ArrayBuffer,U=this.Date,h=p.subtle,t=p.asn1,A=p.coding,V=p.cert,v=p.security.providers,N=function(){var a=function(a){var b=typeof a;return"undefined"===b||""===a?"0":"number"===b||a instanceof Number?a.toString(16).toLowerCase():a.replace("0x","").toLowerCase()},b=function(a,b){return(Array(b+1).join("0")+a).slice(-b)};return function(c,d){c=a(c);d=a(d);var e=Math.max(c.length,d.length);return b(c,e)===b(d,e)}}(),r={providerName:"CP-01",autoAddCert:!1,useKeyIdentifier:!1}; -x.prototype.options=r;y(t.ContentInfo,q,{isDetached:{value:!1,enumerable:!0,writable:!0},writeDetached:function(a){this.isDetached=a},encode:function(a){if(this.isDetached){var b=Q(this);H(this,{contentType:b.contentType});a=t.ContentInfo.method("encode").call(this,a);H(this,b);return a}return t.ContentInfo.method("encode").call(this,a)},encloseContent:function(a){var b=this;return(new m(l)).then(function(){b.setEnclosed(a);return b})},setEnclosed:function(a){H(this,I(a))},getEnclosed:function(){return z(Q(this))}}); -x.prototype.DataContentInfo=q;y(q,J,{encloseContent:function(a,b){var c=this;return(new m(l)).then(function(){c.setEnclosed(a);if(b){var d=v[b];c.digestAlgorithm=d&&d.digest||b}return h.digest(c.digestAlgorithm,c.encapContentInfo.eContent)}).then(function(a){c.digest=a})},verify:function(a){var b=this;return(new m(l)).then(function(){a&&b.setEnclosed(a);if(!b.encapContentInfo||!b.encapContentInfo.eContent)throw Error("Detached content is not found");return h.digest(b.digestAlgorithm,b.encapContentInfo.eContent)}).then(function(a){if(!E(a, -b.digest))throw Error("Message digest is not verified");return z({contentType:b.encapContentInfo.eContentType,content:b.encapContentInfo.eContent})})}});x.prototype.DigestedDataContentInfo=J;y(q,K,{addSignature:function(a,b,c,d){var e=this,f,g,n;return(new m(l)).then(function(){if(!a||!b)throw Error("Signer key or certificate is not defined");b instanceof Array?(n=b,b=n[0]):n=[b];var s=b.getProvider()||v[r.providerName],S=r.useKeyIdentifier&&b.extensions&&b.extensions.subjectKeyIdentifier;g=e.encapContentInfo.eContent; -f={version:S?2:0,sid:S?b.extensions.subjectKeyIdentifier:{issuer:b.issuer,serialNumber:b.serialNumber},digestAlgorithm:s.digest,signatureAlgorithm:b.subjectPublicKeyInfo.algorithm};d&&(f.unsignedAttrs=d);if(c)return"object"!==typeof c&&(c={}),h.digest(f.digestAlgorithm,g)}).then(function(b){b&&(c.contentType=e.encapContentInfo.eContentType,c.messageDigest=b,c.signingTime=new U,f.signedAttrs=c,g=t.SignedAttributes.encode(f.signedAttrs));return h.importKey("pkcs8",t.PrivateKeyInfo.encode(a),a.privateKeyAlgorithm, -!1,["sign"])}).then(function(a){var b=k(f.signatureAlgorithm,{hash:f.digestAlgorithm});return h.sign(b,a,g)}).then(function(a){f.signatureValue=a;G(e.digestAlgorithms,f.digestAlgorithm,function(a,b){return a.id===b.id});if(r.autoAddCert){e.certificates||(e.certificates=[]);a=0;for(var b=n.length;a>>24;a[2]=c>>>16&255;a[1]=c>>>8&255;a[0]=c&255;return a}function V(a){switch(a.id){case "pbeWithSHAAnd40BitRC2-CBC":case "pbeWithSHAAnd128BitRC2-CBC":return 8;case "pbeUnknownGost":return 16;case "sha1":return 20;default:return 32}}function R(a,b){if(!b)return new E(0);if(0<=a.name.indexOf("CPKDF")){for(var c=[],d=0;d>>8&255);c.push(0);c.push(0)}return(new Uint8Array(c)).buffer}return 0<=a.name.indexOf("PFXKDF")?w.Chars.decode(b+"\x00","unicode"):w.Chars.decode(b,"utf8")}function x(){}function v(a){m.PrivateKeyInfo.call(this,a)}function F(a){m.EncryptedPrivateKeyInfo.call(this,a)}function J(a){if(a){var b=this;["mk.db3","masks.db3","kek.opq","rand.opq"].forEach(function(c){b[c]=a[c]})}}function O(a,b){m.GostWrappedPrivateKey.call(this,a);J.call(this,b)}function S(a){a&&(this.header=m.GostKeyContainer.decode(a.header), -this.name=m.GostKeyContainerName.decode(a.name),this.primary=m.GostPrivateKeys.decode(a.primary),this.masks=m.GostPrivateMasks.decode(a.masks),a.primary2&&a.masks2&&(this.primary2=m.GostPrivateKeys.decode(a.primary2),this.masks2=m.GostPrivateMasks.decode(a.masks2)))}function H(a){m.ViPNetInfo.call(this,a||{version:3,keyInfo:{keyClass:1,keyType:43556,flags:1},defenceKeyInfo:{keyClass:1024,keyType:24622,keyUID:B(32),flags:-2147483648}})}function P(a){a&&(a instanceof E||a.buffer instanceof E||"string"=== -typeof a)?this.decode(a):(a=a||{},this.fileType=a.fileType||"ITCS",this.fileVersion=a.fileVersion||16,a.applicationHeader&&(this.applicationHeader=a.applicationHeader),this.entries=a.entries||[])}function K(a){m.PFX.call(this,a||{version:3,authSafe:{contentType:"data"}})}function T(a){this.entries={};if(a)for(var b in a)this.setEntry(b,a[b])}var k=this.Promise,D=this.Object,E=this.ArrayBuffer,U=this.Date,g=u.subtle,m=u.asn1,w=u.coding,s=u.security.providers,q=u.cert,z=u.cms,C={providerName:"CP-01", -days:7305};x.prototype.options=C;A(m.PrivateKeyInfo,v,{getPrivateKey:function(){var a="rsaEncryption"===this.privateKeyAlgorithm.id?["sign"]:["sign","deriveKey","deriveBits"];return g.importKey("pkcs8",this.encode(),this.privateKeyAlgorithm,"true",a)},setPrivateKey:function(a){var b=this;return g.exportKey("pkcs8",a).then(function(a){m.PrivateKeyInfo.call(b,a);return b})},generate:function(a,b){var c=this;return(new k(p)).then(function(){a instanceof q.Request||(a=new q.Request(a));return a.generate(b)}).then(function(b){m.PrivateKeyInfo.call(c, -b);return a})}});x.prototype.PKCS8=v;A(m.EncryptedPrivateKeyInfo,F,{getKey:function(a){var b=this,c;return(new k(p)).then(function(){c=new z.EncryptedDataContentInfo({contentType:"encryptedData",version:0,encryptedContentInfo:{contentType:"data",contentEncryptionAlgorithm:b.encryptionAlgorithm,encryptedContent:b.encryptedData}});return c.getEnclosed(a)}).then(function(a){return v.decode(a.content)})},getPrivateKey:function(a){return this.getKey(a).then(function(a){return a.getPrivateKey()})},setKey:function(a, -b,c){var d=this,e;return(new k(p)).then(function(){a=new v(a);e=new z.EncryptedDataContentInfo;return e.encloseContent(a.encode(),b,c||C.providerName)}).then(function(){d.encryptionAlgorithm=e.encryptedContentInfo.contentEncryptionAlgorithm;d.encryptedData=e.encryptedContentInfo.encryptedContent;return d})},setPrivateKey:function(a,b,c){var d=this;return(new v).setPrivateKey(a).then(function(a){return d.setKey(a,b,c)})},generate:function(a,b,c,d){var e=this;return(new k(p)).then(function(){a instanceof -q.Request||(a=new q.Request(a));return a.generate(c)}).then(function(a){return e.setKey(a,b,d)}).then(function(){return a})}});x.prototype.PKCS8Encrypted=F;A(D,J,{getEncryptionKey:function(a){var b=s["SC-01"].wrapping,c=s["SC-01"].encryption,d=s["SC-01"].derivation,e=this["masks.db3"],h=this["mk.db3"],f=this["kek.opq"];return(new k(p)).then(function(){if(!e||!h||!f)throw Error("Not enougth key container files");if(32d.randomStatus.byteLength)throw Error("Invalid random status length");return e(g,d.mask,d.randomStatus)}).then(function(a){if(!y(a,d.hmacRandom))throw Error("Imita for mask is invalid");return b(g,f,new Uint8Array(d.randomStatus,0,12))}).then(function(b){return h&&c.secondaryKey?l(a.secondaryPrivateKeyParameters.privateKeyAlgorithm, -b,c.secondaryKey,d.mask,a.secondaryFP):l(g,b,c.primaryKey,d.mask,a.primaryFP)})}function W(a,c,d,e,f,h){return b(a,e,new Uint8Array(d.randomStatus,0,12)).then(function(c){return t(a,c,h,d.mask)}).then(function(a){c||(c=new m.GostPrivateKeys);f?c.secondaryKey=a:c.primaryKey=a;return c})}return{getKey:function(a,c){return this.getPrivateKey(a,c).then(function(a){return(new v).setPrivateKey(a)})},getPrivateKey:function(a,c){var b=this,d=b.header.keyContainerContent;return n(d,b.primary,b.masks,a,c)["catch"](function(e){if(b.primary2&& -b.masks2)return n(d,b.primary2,b.masks2,a,c);throw e;})},getCertificate:function(a){var c=this.header.keyContainerContent;return(new k(p)).then(function(){return a?new q.X509(c.secondaryCertificate):new q.X509(c.primaryCertificate)})},getContainerName:function(){return this.name.containerName},setKey:function(a,c,b,d){var e=this;return(new v(a)).getPrivateKey().then(function(a){return e.setPrivateKey(a,c,b,d)})},setPrivateKey:function(a,b,e,l){var g=this,n,t;return(new k(p)).then(function(){g.header= -g.header||new m.GostKeyContainer({keyContainerContent:{containerAlgoritmIdentifier:{algorithm:"id-CryptoPro-GostPrivateKeys-V2-Full"},attributes:["kccaReservePrimary","kccaPrimaryKeyAbsent"],extensions:{keyValidity:{notAfter:N(l||C.days)}}}});n=g.header.keyContainerContent;var c=e?n.secondaryPrivateKeyParameters:n.primaryPrivateKeyParameters;if(c)t=c.privateKeyAlgorithm;else if(t=r(a.algorithm,{sBox:"D-A",encParams:{block:"CFB",sBox:"E-A",keyMeshing:"CP"}}),c={attributes:["pkaExportable","pkaExchange", -"pkaDhAllowed"],privateKeyAlgorithm:t},e){if(!n.primaryPrivateKeyParameters)throw Error("Primary key must be defined first");n.secondaryPrivateKeyParameters=c}else n.primaryPrivateKeyParameters=c,c=n.attributes.indexOf("kccaPrimaryKeyAbsent"),0<=c&&n.attributes.splice(c,1);var b=[];[0,1].forEach(function(a){var c="masks"+(0a&&n.attributes.push("kccaSoftPassword"),c(t,b,n.primaryFP);0<=a&&n.attributes.splice(a,1)}).then(function(a){a&&(n.hmacPassword=a);return d(t,n)}).then(function(a){g.header.hmacKeyContainerContent=a;return g})},setCertificate:function(a,c,b){var e=this,f,h;return(new k(p)).then(function(){e.header= -e.header||new m.GostKeyContainer({keyContainerContent:{containerAlgoritmIdentifier:{algorithm:"id-CryptoPro-GostPrivateKeys-V2-Full"},attributes:["kccaReservePrimary","kccaPrimaryKeyAbsent"],extensions:{keyValidity:{notAfter:N(b||C.days)}}}});f=e.header.keyContainerContent;a=new q.X509(a);h=f.primaryPrivateKeyParameters&&f.primaryPrivateKeyParameters.privateKeyAlgorithm||r(a.subjectPublicKeyInfo.algorithm,{sBox:"D-A",encParams:{block:"CFB",sBox:"E-A",keyMeshing:"CP"}});return a.getPublicKey()}).then(function(b){if(c){if(f.secondaryFP&& -!y(f.secondaryFP,new Uint8Array(b.buffer,0,f.secondaryFP.byteLength)))throw Error("The public key of the certificate does not match the private key");f.secondaryCertificate=a}else{if(f.primaryFP&&!y(f.primaryFP,new Uint8Array(b.buffer,0,f.primaryFP.byteLength)))throw Error("The public key of the certificate does not match the private key");f.primaryCertificate=a}return d(h,f)}).then(function(a){e.header.hmacKeyContainerContent=a;return e})},setContainerName:function(a){this.name=new m.GostKeyContainerName({containerName:a})}, -verify:function(a){var b=this,e,f;return(new k(p)).then(function(){e=b.header.keyContainerContent;f=e.primaryPrivateKeyParameters.privateKeyAlgorithm;return d(f,e)}).then(function(d){if(!y(d,b.header.hmacKeyContainerContent))throw Error("Container is not valid.");d=0<=e.attributes.indexOf("kccaSoftPassword");if(!a&&d)throw Error("Password is required");if(a&&!d)throw Error("Password is not reqiured.");return a?c(f,a,e.primaryFP).then(function(a){if(!y(a,e.hmacPassword))throw Error("Password is not valid."); -return b}):b})},changePassword:function(a,c){var b=this,d;return(new k(p)).then(function(){d=b.header.keyContainerContent;if(!d.primaryPrivateKeyParameters)throw Error("Private key not yet defined");return b.getPrivateKey(a).then(function(a){return b.setPrivateKey(a,c)})}).then(function(){return d.secondaryPrivateKeyParameters?b.getPrivateKey(a,!0).then(function(a){return b.setPrivateKey(a,c,!0)}):b})},generate:function(a,c,b){var d=this,e,f;return(new k(p)).then(function(){a instanceof q.Request|| -(a=new q.Request(a));return a.generate(b)}).then(function(a){f=a;return d.setKey(f,c)}).then(function(){e=new q.X509(a);return e.sign(f)}).then(function(){return d.setCertificate(e)}).then(function(){return a})},encode:function(a){return{header:this.header.encode(a),name:this.name.encode(a),masks:this.masks.encode(a),primary:this.primary.encode(a),masks2:this.masks2.encode(a),primary2:this.primary2.encode(a)}}}}());x.prototype.CryptoProKeyContainer=S;A(m.ViPNetInfo,H,function(){function a(a){void 0=== -a&&(a="");var c=w.Chars.decode(a,"win1251"),d;return g.digest("GOST R 34.11-94",c).then(function(a){d=a;a=new Uint8Array(c.byteLength+d.byteLength);a.set(new Uint8Array(c),0);a.set(new Uint8Array(d),c.byteLength);return g.digest("GOST R 34.11-94",a)}).then(function(a){return g.importKey("raw",a,"GOST 28147",!1,["unwrapKey"])}).then(function(a){return g.unwrapKey("raw",d,a,"GOST 28147-MASK/VN","GOST 28147-89","false",["encrypt","decrypt","sign","verify"])})}return{getPrivateKey:function(b){var c=this, -d,e;return(new k(p)).then(function(){return b&&"string"!==typeof b?b:a(b)}).then(function(a){b=a;d=c.keyPart;e=new Uint8Array(d,0,d.byteLength-4-8);a=new Uint8Array(d,e.byteLength,4);var f=c.keyInfo.encode(),l=new Uint8Array(e.byteLength+f.byteLength);l.set(new Uint8Array(e),0);l.set(new Uint8Array(f),e.byteLength);return g.verify({name:"GOST 28147-89-MAC"},b,a,l)}).then(function(a){if(!a)throw Error("Invalid key password");a=new Uint8Array(d,d.byteLength-8,8);return g.decrypt({name:"GOST 28147-89-CFB", -iv:a},b,e)}).then(function(a){var b=a.byteLength/2;if(c.keyInfo.keyClass&0)return g.importKey("raw",new Int32Array(a,b,b),"GOST 28147",!1,["unwrapKey"]).then(function(c){return g.unwrapKey("raw",new Int32Array(a,0,b),c,"GOST 28147-MASK/VN","GOST 28147-89","false",["encrypt","decrypt","sign","verify"])});var d=c.keyInfo.algorithm||c.certificate&&c.certificate.subjectPublicKeyInfo.algorithm;if(!d)throw Error("Algorithm is not specified");var e=r(d,{mode:"MASK",procreator:"VN"});e.name=e.name.replace("-DH", -"");var n=new Uint8Array(a,0,b),k=new Uint8Array(a,b,b);return g.importKey("raw",k,e,"false",["sign","unwrapKey"]).then(function(a){return g.unwrapKey("raw",n,a,e,d,"true",["sign","deriveBits","deriveKey"])}).then(function(a){return c.publicKey?g.generateKey(r(a.algorithm,{ukm:a.buffer}),a.extractable,a.usages):{privateKey:a}}).then(function(a){if(c.publicKey&&!y(a.publicKey.buffer,c.publicKey))throw Error("Check public key failed");return a.privateKey})})},setPrivateKey:function(b,c,d){var e=this, -h,f,l,t;return(new k(p)).then(function(){return c&&"string"!==typeof c?c:a(c)}).then(function(a){c=a;a=b.algorithm;e.keyInfo.algorithm=a;e.keyInfo.serialNumber=B(16);e.keyInfo.keyUID=B(8);e.keyInfo.validity={notBefore:Q(),notAfter:Q(d||C.days)};if("private"===b.type)return h=r(a,{mode:"MASK",procreator:"VN"}),h.name=h.name.replace("-DH",""),e.keyInfo.keyClass=1,e.keyInfo.keyType=43556,g.generateKey(r(a,{ukm:b.buffer}),!0,["sign","verify"]).then(function(a){e.publicKey=a.publicKey.buffer;if(e.certificate)return a= -e.certificate.subjectPublicKeyInfo,g.importKey("spki",a.encode(),a.algorithm,!0,["verify"])}).then(function(a){a&&!y(a.buffer,e.publicKey)&&delete e.certificate});if("secret"===b.type)h="GOST 28147/MASK/VN",delete e.certificate,delete e.publicKey,e.keyInfo.keyClass=64,e.keyInfo.keyType=24622;else throw Error("Invalid key type");}).then(function(){return g.generateKey(h,!0,["wrapKey","unwrapKey"])}).then(function(a){f=a;return g.wrapKey("raw",b,f,h)}).then(function(a){l=new Uint8Array(2*a.byteLength); -l.set(new Uint8Array(a));return g.exportKey("raw",f)}).then(function(a){l.set(new Uint8Array(a),a.byteLength);t=new Uint8Array(l.byteLength+12);a={name:"GOST 28147-CFB",iv:B(8)};t.set(new Uint8Array(a.iv),t.byteLength-8);return g.encrypt(a,c,l)}).then(function(a){t.set(new Uint8Array(a));var b=e.keyInfo.encode(),d=new Uint8Array(a.byteLength+b.byteLength);d.set(new Uint8Array(a),0);d.set(new Uint8Array(b),a.byteLength);return g.sign({name:"GOST 28147-89-MAC"},c,d)}).then(function(a){t.set(new Uint8Array(a), -t.byteLength-12);e.keyPart=t.buffer;return e})},encode:function(a){var c=m.ViPNetInfo.method("encode").call(this),d=new Uint8Array(8+c.byteLength+this.keyPart.byteLength);I(d.buffer,0,4+c.byteLength+this.keyPart.byteLength);d.set(new Uint8Array(c),4);I(d.buffer,4+c.byteLength,this.keyPart.byteLength);d.set(new Uint8Array(this.keyPart),8+c.byteLength);return"PEM"===a?w.Base64.encode(d.buffer):d.buffer}}}(),{decode:function(a){"string"===typeof a&&(a=w.Base64.decode(a));a=M(a);var b=G(a,0);if(a.byteLength!== -b+4)throw Error("Invalid container entry size");var c=w.BER.decode(new Uint8Array(a,4,b)),b=m.ViPNetInfo.decode.call(this,c),c=c.header.byteLength+c.content.byteLength,d=G(a,4+c);if(a.byteLength!==c+d+8)throw Error("Invalid container key part size");b.keyPart=(new Uint8Array(new Uint8Array(a,c+8,d))).buffer;return b}});x.prototype.ViPNetContainerEntry=H;A(D,P,{getCertificate:function(a){var b=this;return(new k(p)).then(function(){var c=b.entries[a||0];if(!c)throw Error("Entry not defined");if(c.certificate)return new q.X509(c.certificate)})}, -getKey:function(a,b){return this.getPrivateKey(a,b).then(function(a){return(new v).setPrivateKey(a)})},getPrivateKey:function(a,b){var c=this;return(new k(p)).then(function(){var d=c.entries[b||0];if(!d)throw Error("Entry not defined");return d.getPrivateKey(a)})},setCertificate:function(a,b){var c=this,d;return(new k(p)).then(function(){d=c.entries[b||0]||(c.entries[b||0]=new H);a=new q.X509(a);if(d.publicKey)return a.getPublicKey()}).then(function(b){if(b&&!y(d.publicKey,b.buffer))throw Error("Invalid certificate for private key"); -d.certificate=a;return c})},setKey:function(a,b,c,d){var e=this;return(new v(a)).getPrivateKey().then(function(a){return e.setPrivateKey(a,b,c,d)})},setPrivateKey:function(a,b,c,d){var e=this;return(new k(p)).then(function(){return(e.entries[c||0]||(e.entries[c||0]=new H)).setPrivateKey(a,b,d)}).then(function(){return e})},changePassword:function(a,b){var c=this;return(new k(p)).then(function(){return c.getPrivateKey(a).then(function(a){return c.setPrivateKey(a,b)})})},generate:function(a,b,c){var d= -this,e,h;return(new k(p)).then(function(){a instanceof q.Request||(a=new q.Request(a));return a.generate(c)}).then(function(a){h=a;return d.setKey(h,b)}).then(function(){e=new q.X509(a);return e.sign(h)}).then(function(){return d.setCertificate(e)}).then(function(){return a})},encode:function(a){var b=[],c=0;this.entries.forEach(function(a){a=a.encode();c+=a.byteLength;b.push(a)});var d=this.applicationHeader?this.applicationHeader.byteLength:0,e=new Uint8Array(12+d+c);e.set(new Uint8Array(w.Chars.decode(this.fileType, -"ascii")));I(e.buffer,4,this.fileVersion);I(e.buffer,8,d);0>>16;if(0!==d&&1!==d||255<(c&65535))throw Error("Unsupported ViPNet container version");var d=G(a,8),e;0k;k++)g+=("00"+d[k].toString(16)).slice(-2);d=g.substr(0,8)+"-"+g.substr(8,4)+ -"-4"+g.substr(13,3)+"-9"+g.substr(17,3)+"-"+g.substr(20,12);b[d]=a}});return c})},store:function(a,b,c){var d=this,e=[],g=[],f=[];return(new k(p)).then(function(){c=c?s[c]?s[c].pbes:c:b?s[b]?s[b].pbes:s[C.providerName].pbes:s[C.providerName].pbes;for(var f in d.entries){var m=new Uint32Array([1]),n=d.entries[f];n.key&&function(b,d){b instanceof E?g.push({bagId:"secretBag",bagValue:{secretTypeId:"secret",secretValue:b,bagAttributes:d}}):b instanceof v?c&&a?e.push((new F).setKey(b,a,c).then(function(a){return{bagId:"pkcs8ShroudedKeyBag", -bagValue:a,bagAttributes:d}})):e.push({bagId:"keyBag",bagValue:b,bagAttributes:d}):b instanceof F&&e.push({bagId:"pkcs8ShroudedKeyBag",bagValue:b,bagAttributes:d})}(n.key,{localKeyId:m,friendlyName:f});n.certs&&n.certs.forEach(function(a){var b={localKeyId:m};a instanceof q.X509&&g.push({bagId:"certBag",bagValue:{certId:"x509Certificate",certValue:a},bagAttributes:b})});n.crls&&n.crls.forEach(function(a){var b={localKeyId:m};a instanceof q.CRL&&g.push({bagId:"crlBag",bagValue:{crlId:"x509CRL",crlValue:a}, -bagAttributes:b})})}if(0b?b+4294967296:b}function H(b){var c=(v=v||r.GostRandom)?new (v||r.GostRandom):$;if(c.getRandomValues)c.getRandomValues(b);else throw new C("Random generator not found");}function q(b){if(b instanceof I)return b;if(b&&b.buffer&&b.buffer instanceof -I)return 0===b.byteOffset&&b.byteLength===b.buffer.byteLength?b.buffer:(new Uint8Array(new Uint8Array(b,b.byteOffset,b.byteLength))).buffer;throw new p("CryptoOperationData required");}function s(b){return new Uint8Array(q(b))}function t(b){return new Uint8Array(s(b))}function D(b){return(b&255)<<24|(b&65280)<<8|b>>8&65280|b>>24&255}function E(b,c){for(var a=0;16>a;++a)b[a]^=c[a]}function O(b){for(var c=0;16>c;++c){for(var a=b,d=0,e=0;16>e;e++)d^=P[Q[e]][a[e]];for(e=16;0a;++a)b[a]=J[b[a]];O(b)}function aa(b){var c=new Uint8Array(160),a=new Uint8Array(16);c.set(s(b));for(b=0;4>b;b++){var d=32*(b+1);c.set(new Uint8Array(c.buffer,32*b,32),d);for(var e=1;9>e;e++){for(var f=8*b+e,g=a,h=0;15>h;h++)g[h]=0;g[15]=f;O(g);var f=new Uint8Array(c.buffer,d,16),g=new Uint8Array(c.buffer,d+16,16),h=a,l=new Uint8Array(f);R(f,h);E(f,g);g.set(l)}}return c}function ba(b,c,a,d){a=a||c.byteOffset;c=new Uint8Array(c.buffer,a,16);if(d){for(d=0;9>d;d++){a= -c;var e=new Uint8Array(b.buffer,16*(9-d),16);E(a,e);for(var e=a,f=0;16>f;++f){for(var g=e,h=g[0],l=0;15>l;l++)g[l]=g[l+1];g[15]=h;for(l=h=0;16>l;l++)h^=P[Q[l]][g[l]];g[15]=h}for(e=0;16>e;++e)a[e]=ca[a[e]]}E(c,new Uint8Array(b.buffer,0,16))}else{for(d=0;9>d;d++)R(c,new Uint8Array(b.buffer,16*d,16));E(c,new Uint8Array(b.buffer,144,16))}}function K(b,c,a){a=c[0]+a&4294967295;var d=b[0+(a>>0&15)]<<0,d=d|b[16+(a>>4&15)]<<4,d=d|b[32+(a>>8&15)]<<8,d=d|b[48+(a>>12&15)]<<12,d=d|b[64+(a>>16&15)]<<16,d=d|b[80+ -(a>>20&15)]<<20,d=d|b[96+(a>>24&15)]<<24,d=d|b[112+(a>>28&15)]<<28;a=(d<<11|d>>>21)^c[1];c[1]=c[0];c[0]=a}function da(b,c,a){a=a||c.byteOffset;var d=this.sBox;c=new Int32Array(c.buffer,a,2);for(a=0;32>a;a++)K(d,c,b[a]);b=c[0];c[0]=c[1];c[1]=b}function ea(b,c,a){a=a||c.byteOffset;var d=this.sBox;c=new Int32Array(c.buffer,a,2);a=D(c[0]);c[0]=D(c[1]);c[1]=a;for(a=0;32>a;a++)K(d,c,b[a]);c[0]=D(c[0]);c[1]=D(c[1])}function fa(b,c){for(var a=new Int32Array(32),d=new Int32Array(q(b)),e=0;8>e;e++)a[e]=d[e]; -if(c){for(e=0;8>e;e++)a[e+8]=a[7-e];for(e=0;8>e;e++)a[e+16]=a[7-e]}else{for(e=0;8>e;e++)a[e+8]=a[e];for(e=0;8>e;e++)a[e+16]=a[e]}for(e=0;8>e;e++)a[e+24]=a[7-e];return a}function ga(b,c){for(var a=new Int32Array(32),d=new Int32Array(q(b)),e=0;8>e;e++)a[e]=D(d[e]);if(c){for(e=0;8>e;e++)a[e+8]=a[7-e];for(e=0;8>e;e++)a[e+16]=a[7-e]}else{for(e=0;8>e;e++)a[e+8]=a[e];for(e=0;8>e;e++)a[e+16]=a[e]}for(e=0;8>e;e++)a[e+24]=a[7-e];return a}function x(b,c){for(var a=this.pad(s(c)),d=this.blockSize,e=a.byteLength/ -d,f=this.keySchedule(b),g=0;g>3,g=c.length,h=g%f,g=(g-h)/f,l=this.keySchedule(b),k=0;k>3,g=c.length,h=g%f,g=(g-h)/f,l=this.keySchedule(b),k=0;k>3,g=new Uint8Array(f),h=c.length,l=h%f,h=(h-l)/f,k=this.keySchedule(b),m=0;mm?m:m-4294967295);for(m=0;mm?m:m-4294967295),this.process(h,l),k=0;k>3,f=c.length,g=f%e,f=(f-g)/e,h=new Uint8Array(d),l=new Int32Array(d);b=this.keySchedule(b);h.set(a||this.iv);for(a=0;al;l++)K(f,g,b[l])}} -function V(b){for(var c=0,a=b.length,d=a-1;0<=d;--d){var e=b[d]>>>7;b[d]=b[d]<<1&255|c;c=e}0!==c&&(16===a?b[15]^=135:b[7]^=27)}function ma(b,c,a){var d=this.blockSize,e=s(a),f=new Uint8Array(d);this.process(b,f);V(f);0!==a.byteLength%d&&(e=W.call(this,s(a)),V(f));a=0;for(var g=e.length/d;a>3)||this.blockSize>> -1;this.processMAC(b,a,c);c=new Uint8Array(d);c.set(new Uint8Array(a.buffer,0,d));return c.buffer}function A(b,c,a,d){b=new Uint8Array(z.call(this,b,a,d));c=s(c);if(b.length!==c.length)return!1;a=0;for(d=b.length;a>1);if(!this.ukm)throw new p("UKM must be defined");var e=new Uint8Array(this.ukm),e=z.call(this,b,c,e),f=x.call(this,b,c),d=new Uint8Array(d);d.set(new Uint8Array(f),0);d.set(new Uint8Array(e), -a);return d.buffer}function oa(b,c){var a=this.blockSize,d=this.keySize,e=d+(a>>1),f=q(c);if(f.byteLength!==e)throw new p("Wrapping key size must be "+e+" bytes");if(!this.ukm)throw new p("UKM must be defined");var e=new Uint8Array(this.ukm),g=new Uint8Array(f,0,d),a=new Uint8Array(f,d,a>>1),d=F.call(this,b,g);if(!A.call(this,b,a,d,e))throw new p("Error verify MAC of wrapping key");return d}function X(b,c){for(var a=this.blockSize,d=new Int32Array(q(b)),e=[],f=0;fg;g++)e[f][g]= -c[f]>>>g&1}for(f=0;fg;g++)e[f][g]?h[0]=h[0]+d[g]&4294967295:h[1]=h[1]+d[g]&4294967295;g=new Uint8Array(h.buffer);d=new Int32Array(S.call(this,d,d,g))}return d}function pa(b,c){var a=this.keySize,d=a+(this.blockSize>>1);if(!this.ukm)throw new p("UKM must be defined");var e=new Uint8Array(this.ukm),f=X.call(this,b,e),e=z.call(this,f,c,e),f=x.call(this,f,c),d=new Uint8Array(d);d.set(new Uint8Array(f),0);d.set(new Uint8Array(e),a);return d.buffer}function qa(b, -c){var a=this.blockSize,d=this.keySize,e=d+(a>>1),f=q(c);if(f.byteLength!==e)throw new p("Wrapping key size must be "+e+" bytes");if(!this.ukm)throw new p("UKM must be defined");var e=new Uint8Array(this.ukm),g=new Uint8Array(f,0,d),a=new Uint8Array(f,d,a>>1),d=X.call(this,b,e),g=F.call(this,d,g);if(!A.call(this,d,a,g,e))throw new p("Error verify MAC of wrapping key");return g}function Y(b){var c=this.blockSize>>1,a=this.keySize,d=q(b);if(34!==(new Uint8Array(d,0,1))[0])throw new p("Invalid magic number"); -var e=(new Uint8Array(d,1,1))[0];b=new Uint8Array(d,2,c);for(var f=new Uint8Array(a),g=0;g>1,d=this.keySize,e=q(b),f=q(c);e.byteLength!==d&&(e=Y.call(this,e));var g=x.call(this,e,f),e= -z.call(this,e,f),a=new Uint8Array(a+d);a.set(new Uint8Array(g),0);a.set(new Uint8Array(e),d);return a.buffer}function sa(b,c){var a=this.blockSize>>1,d=this.keySize,e=q(b),f=q(c);e.byteLength!==d&&(e=Y.call(this,e));var g=new Uint8Array(f,0,d),a=new Uint8Array(f,d,a),g=F.call(this,e,g);if(!A.call(this,e,a,g))throw new p("Invalid key MAC");return g}function ta(){var b=y.call(this),c=void 0,a=this.blockSize>>1,d=this.keySize,e=8,b=new Uint8Array(q(b));if(b.byteLength!==d)throw new p("Wrong cleartext size "+ -b.byteLength+" bytes");if(c=c||this.ukm)if(c=new Uint8Array(q(c)),0this.blockSize)throw p("Invalid padding");a=new Uint8Array(c);0a;a++){c[a]=[];for(var d=0;256>d;d++){for(var e=c[a],f=d,g=b[a],h=d,l=0,k=void 0,m=void 0,k=0;8>k;k++)h&1&&(l^=g),m=g&128,g=g<<1&255,m&&(g^=195),h>>=1;e[f]=l&255}}return c}(),Q=[4,2,3,1,6,5,0,7,0,5,6,1,3,2,4,0],J=[252,238,221,17,207,110,49,22,251,196,250,218,35,197,4,77,233,119,240,219,147,46,153,186,23,54,241,187,20,205,95,193,249,24,101,90,226,92,239,33,129,28,60,66,139,1,142,79,5,132,2,174,227,106,143,160,6,11,237,152,127,212,211,31,235,52,44,81,234,200, -72,171,242,42,104,162,253,58,206,204,181,112,14,86,8,12,118,18,191,114,19,71,156,183,93,135,21,161,150,41,16,123,154,199,243,145,120,111,157,158,178,177,50,117,25,61,255,53,138,126,109,84,198,128,195,189,13,87,223,245,36,169,62,168,67,201,215,121,214,246,124,34,185,3,224,15,236,222,122,148,176,188,220,232,40,80,78,51,10,74,167,151,96,115,30,0,98,68,26,184,56,130,100,159,38,65,173,69,70,146,39,94,85,47,140,163,165,125,105,213,149,59,7,88,179,64,134,172,29,247,48,55,107,228,136,217,231,137,225,27,131, -73,76,63,248,254,141,83,170,144,202,216,133,97,32,113,103,164,45,43,9,91,203,155,37,208,190,229,108,82,89,166,116,210,230,244,180,192,209,102,175,194,57,75,99,182],ca=function(){for(var b=[],c=0,a=J.length;ch;h++)f[h]=b[(f[h-1]+f[h-a])%256];f[128-e]=b[f[128-e]&d];for(h=127-e;0<=h;--h)f[h]=b[f[h+1]^ -f[h+e]];return g}}(),Ga=function(){function b(a){if(h){var b=f[a],c=g[a];f[a]=(b>>>c|b<<16-c)&65535;f[a]=f[a]-d[e]-(f[(a+3)%4]&f[(a+2)%4])-(~f[(a+3)%4]&f[(a+1)%4]);--e}else f[a]=f[a]+d[e]+(f[(a+3)%4]&f[(a+2)%4])+(~f[(a+3)%4]&f[(a+1)%4]),e+=1,b=f[a],c=g[a],f[a]=(b<>>16-c)&65535}function c(a){f[a]=h?f[a]-d[f[(a+3)%4]&63]:f[a]+d[f[(a+3)%4]&63]}function a(a,b){b=b||1;for(var c=0;cd;d++)a(d)}var d,e,f=new Uint16Array(4),g=new Uint16Array([1,2,3, -5]),h;return function(g,k,m,n){h=n;f=new Uint16Array(k.buffer,m||k.byteOffset,4);d=g;e=n?63:0;a(b,5);a(c);a(b,6);a(c);a(b,5)}}();return function(b){if(!Ca)throw new C("Big endian platform not supported");b=b||{};this.keySize=32;this.blockLength=b.length||64;this.blockSize=this.blockLength>>3;this.name=(b.name||(1===b.version?"RC2":1989===b.version?"GOST 28147":"GOST R 34.12"))+(4>1):"KW"===b.mode||b.keyWrapping?("NO"!==(b.keyWrapping||"NO")?b.keyWrapping:"")+"KW":(b.block||"ECB")+(("CFB"===b.block||"OFB"===b.block||"CTR"===b.block&&2015===b.version)&&b.shiftBits&&b.shiftBits!==this.blockLength?"-"+b.shiftBits:"")+(b.padding?"-"+(b.padding||("CTR"===b.block||"CFB"===b.block||"OFB"===b.block?"NO":"ZERO"))+"PADDING":"")+("NO"!==(b.keyMeshing||"NO")?"-CPKEYMESHING":""))+(b.procreator?"/"+b.procreator:"")+("string"===typeof b.sBox?"/"+b.sBox:"");this.procreator= -b.procreator;switch(b.version||1989){case 1:this.process=Ga;this.keySchedule=Fa;this.blockLength=64;this.effectiveLength=b.length||32;this.keySize=8*Math.ceil(this.effectiveLength/8);this.blockSize=this.blockLength>>3;break;case 2015:this.version=2015;if(64===this.blockLength)this.process=ea,this.keySchedule=ga;else if(128===this.blockLength)this.process=ba,this.keySchedule=aa;else throw new p("Invalid block length");this.processMAC=ma;break;case 1989:this.version=1989;this.process=da;this.processMAC= -la;this.keySchedule=fa;if(64!==this.blockLength)throw new p("Invalid block length");break;default:throw new C("Algorithm version "+b.version+" not supported");}switch(b.mode||b.keyWrapping&&"KW"||"ES"){case "ES":switch(b.block||"ECB"){case "ECB":this.encrypt=x;this.decrypt=F;break;case "CTR":1989===this.version?this.decrypt=this.encrypt=ja:(this.decrypt=this.encrypt=L,this.shiftBits=b.shiftBits||this.blockLength);break;case "CBC":this.encrypt=T;this.decrypt=ka;break;case "CFB":this.encrypt=S;this.decrypt= -ha;this.shiftBits=b.shiftBits||this.blockLength;break;case "OFB":this.decrypt=this.encrypt=ia;this.shiftBits=b.shiftBits||this.blockLength;break;default:throw new C("Block mode "+b.block+" not supported");}switch(b.keyMeshing){case "CP":this.keyMeshing=wa;break;default:this.keyMeshing=M}if(this.encrypt===x||this.encrypt===T)switch(b.padding){case "PKCS5P":this.pad=ya;this.unpad=za;break;case "RANDOM":this.pad=Ba;this.unpad=G;break;case "BIT":this.pad=W;this.unpad=Aa;break;default:this.pad=U,this.unpad= -G}else this.unpad=this.pad=G;this.generateKey=y;break;case "MAC":this.sign=z;this.verify=A;this.generateKey=y;this.macLength=b.macLength||this.blockLength>>1;this.unpad=this.pad=G;this.keyMeshing=M;break;case "KW":this.unpad=this.pad=G;this.keyMeshing=M;switch(b.keyWrapping){case "CP":this.wrapKey=pa;this.unwrapKey=qa;this.generateKey=y;this.shiftBits=b.shiftBits||this.blockLength;break;case "SC":this.wrapKey=ra;this.unwrapKey=sa;this.generateKey=ta;break;default:this.wrapKey=na,this.unwrapKey=oa, -this.generateKey=y}break;case "MASK":this.wrapKey=ua;this.unwrapKey=va;this.generateKey=y;break;default:throw new C("Mode "+b.mode+" not supported");}var c=b.sBox;if(!c)c=2015===this.version?u["E-Z"]:"SC"===this.procreator?u["E-SC"]:u["E-A"];else if("string"===typeof c){if(c=c.toUpperCase(),c=u[c],!c)throw new B("Unknown sBox name: "+b.sBox);}else if(!c.length||c.length!==u["E-Z"].length)throw new B("Length of sBox must be "+u["E-Z"].length);this.sBox=c;if(b.iv){this.iv=new Uint8Array(b.iv);if(this.iv.byteLength!== -this.blockSize&&1989===this.version)throw new B("Length of iv must be "+this.blockLength+" bits");if(this.iv.byteLength!==this.blockSize>>1&&this.encrypt===L)throw new B("Length of iv must be "+this.blockLength>>NaN);if(0!==this.iv.byteLength%this.blockSize&&this.encrypt!==L)throw new B("Length of iv must be a multiple of "+this.blockLength+" bits");}else this.iv=128===this.blockLength?Ea:Da;if(b.ukm&&(this.ukm=new Uint8Array(b.ukm),8*this.ukm.byteLength!==this.blockLength))throw new B("Length of ukm must be "+ -this.blockLength+" bits");}}); -/* - 2014-2016, Rudolf Nickolaev. All rights reserved. -*/ -(function(A,y){"function"===typeof define&&define.amd?define(["gostRandom","gostCipher"],y):"object"===typeof exports?module.exports=y(require("gostRandom"),require("gostCipher")):A.GostDigest=y(A.GostRandom,A.GostCipher)})(this,function(A,y){function q(a,m,f,d,k){for(var r=0;r>2,d=new Uint8Array(f),k,r=0,l=0,s=0;s< -m;s++){k=s&3;var e=a.charCodeAt(s),e=64e?e-65:96e?e-71:47e?e+4:43===e?62:47===e?63:0,r=r|e<<18-6*k;if(3===k||1===m-s){for(k=0;3>k&&l>>(16>>>k&24)&255;r=0}}return d.buffer}function w(a){if(a instanceof ArrayBuffer)return a;if(a&&a.buffer&&a.buffer instanceof ArrayBuffer)return 0===a.byteOffset&&a.byteLength===a.buffer.byteLength?a.buffer:(new Uint8Array(new Uint8Array(a,a.byteOffset,a.byteLength))).buffer;throw new B("ArrayBuffer or ArrayBufferView required"); -}function C(a,m){var f=this.digest===D?32:64,d=this.bitLength/8,k=w(a),r=w(m),l;k.byteLength===f?l=new Uint8Array(k):(l=new Uint8Array(f),k.byteLength>f?l.set(new Uint8Array(this.digest(k))):l.set(new Uint8Array(k)));for(var k=new Uint8Array(f+r.byteLength),d=new Uint8Array(f+d),s=0;s>>8,b[d*c+u]=v&255}f=new Uint8Array(k);q(h,0,f,0,k);return f.buffer}function M(a,m){if(0>>8;g[g.length-1]=m&255; -s.set(new Uint8Array(C.call(this,a,g),0,e>>24&255;g[e+1]=h>>>16&255;g[e+2]=h>>>8&255;g[e+3]=h&255;for(var c=new Uint8Array(C.call(this,l,g)),p=c,n=1;nthis.bitLength||0n;n++)h[n]="DENEFH028.760246785.IUEFHWUIO.EF".charCodeAt(n);for(var g=new Uint8Array(2*(f+d)),x=0;xe;e++)c=(b[e]&65535)+(a[e]&65535)+(c||0),h=(b[e]>>>16)+(a[e]>>>16)+(c>>> -16),b[e]=c&65535|h<<16,c=h>>>16}function m(b,c){for(var a=0;16>a;a++)b[a]=c[a]}function f(b,a){for(var c=0;16>c;c++)b[c]^=a[c]}function d(b,a){m(c,b);f(c,a);for(var h=0;8>h;h++){var d,g,l=(c[h>>2]>>((h&3)<<3)&255)<<1;d=e[l];g=e[l+1];for(var p=1;8>p;p++)l=(p<<3)+h,l=(p<<9)+((c[l>>2]>>((l&3)<<3)&255)<<1),d^=e[l],g^=e[l+1];b[h<<1]=d;b[(h<<1)+1]=g}}function k(b,c,a){m(p,b);d(p,c);m(n,p);d(p,a);for(c=0;11>c;c++)d(n,s[c]),d(p,n);d(n,s[11]);f(p,n);f(b,p);f(b,a)}var r=new Int32Array(16),l=new Int32Array(16); -l[0]=512;var s=function(b){b=new Int32Array(I(b));for(var c=Array(12),a=0;12>a;a++)c[a]=new Int32Array(b.buffer,64*a,16);return c}("B0Wm8lllgN0jTXTMNnR2BRXTYKQIKkKiAWlnkpHgfEv8xIV1jbhOcRbQRS5DdmovH3xlwIEvy+vp2soe2lsIsbebsSFwBHnmVs3L1xui3VXKpwrbwmG1XFiZ1hJrF7WaMQG1Fg9e1WGYKyMKcur+89e1cA9GneNPGi+dqYq1o2+yCroK9ZYemTHbeoZD9LbCCdtiYDc6ycGxnjWQ5A/i03t7KbEUderyix+cUl9e8QY1hD1qKPw5Cscvzius3HT1LtHjhLy+DCLxN+iToepTNL4DUpMzE7fYddYD7YIs16k/NV5orRxynX08XDN+hY5I3eRxXaDhSPnSZhXos98f71f+bHz9WBdg9WPqqX6iVnoWGicjtwD/36P1OiVHF82/vf8PgNc1njVKEIYWHxwVf2MjqWwMQT+amUdHraxr6ktufWRGekBo+jVPkDZyxXG/tsa+wmYf8gq0t5oct6b6z8aO8Jq0mn8YbKRCUfnEZi3AOTB6O8Okb9nTOh2urk+uk9QUOk1WhojzSjyiTEUXNQQFSiiDaUcGNyyCLcWrkgnJk3oZMz5H08mHv+bHxp45VAkkv/6GrFHsxaruFg7H9B7nAr/UDX+k2ahRWTXCrDYvxKXRK43RaZAGm5LLK4n0msTbTTtEtIke3jaccfi3TkFBbgwCqucDp8mTTUJbH5vbWiODUURhcmAqH8uS3DgOVJwHppqKK3uxzrLbC0QKgIQJDeC3Vdk8JEKJJRs6fTreXxbs2JpMlJsiMRZUWo837ZxFmPvHtHTDtjsV0fqYNvRSdjswbB56SzNprwJn558DYTMbiuH/H9t4iv8c50GJ8/PkskjlKjhSbwWApt6+qxst84HNpMprXdhvwEpZot6Ybkd9Hc2678q5SOrvcR2KeWaEFCGAASBhB6vru2v62JT+WmPNxgIw+4nI79Cez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2MIJLK/s91fR09uYO76L1jGuD+y1OGEZ25F8K3zQRIHgfdR0jobq9Ypszgap+0a4dd1MZ9xuw/tHIDaMumoRVCQg/koJRcCmsAWNVV6cOp8lpRVGDHQSOZWgmBNS6ChH2UfiIKrdJ133JbvZ5PYrvJ5n1KwQtzUju8LB6hzDJIvGi7Q1Uc5JhQvHTL9CXx0pnTShq8OLhgP18yXSMvtJxfnBnr09JmpOCkKns0duziOOykzRN0XInNBWMJQ+j1g")), -g,b,h,c=new Int32Array(16),p=new Int32Array(16),n=new Int32Array(16);return function(c){g=new Int32Array(16);b=new Int32Array(16);h=new Int32Array(16);for(var e=0;16>e;e++)256===this.bitLength&&(h[e]=16843009);c=new Uint8Array(w(c));for(var e=c.length,d=e%64,f=(e-d)/64,e=0;ee;e++)c[e]=h[8+e];else for(c=new Int32Array(16),e=0;16>e;e++)c[e]=h[e];return"SC"===this.procreator||"VN"===this.procreator?H(c.buffer):c.buffer}}(),D=function(){function a(b){for(var e=new Uint8Array(32),c=0;8>c;c++)e[4*c]=b[c],e[1+4*c]=b[8+c],e[2+4*c]=b[16+c],e[3+4*c]=b[24+c];return e}function m(b){for(var e= -new Uint8Array(8),c=0;8>c;c++)e[c]=b[c]^b[c+8];q(b,8,b,0,24);q(e,0,b,24,8);return b}function f(b){b=new Uint16Array(b.buffer,0,16);var e=b[0]^b[1]^b[2]^b[3]^b[12]^b[15];q(b,1,b,0,15);b[15]=e}function d(b,e){var c=new Uint8Array(32),d=new Uint8Array(32),g=new Uint8Array(32),k=new Uint8Array(32);q(b,e,s,0,32);q(l,0,d,0,32);q(s,0,g,0,32);for(var t=0;32>t;t++)k[t]=d[t]^g[t];var v=a(k),t=l,u=new Uint8Array(8);q(t,0,u,0,8);v=new Uint8Array(this.cipher.encrypt(v,u));q(v,0,c,0,8);for(v=1;4>v;v++){u=m(d); -for(t=0;32>t;t++)d[t]=u[t]^r[v][t];g=m(m(g));for(t=0;32>t;t++)k[t]=d[t]^g[t];var w=a(k),t=c,u=8*v,y=l,A=8*v,z=new Uint8Array(8);q(y,A,z,0,8);w=new Uint8Array(this.cipher.encrypt(w,z));q(w,0,t,u,8)}for(d=0;12>d;d++)f(c);for(d=0;32>d;d++)c[d]^=s[d];f(c);for(d=0;32>d;d++)c[d]^=l[d];for(d=0;61>d;d++)f(c);q(c,0,l,0,l.length)}function k(b){for(var d=0,c=0;c>>=8}var r,l,s,e,g=new Uint8Array([0,255,0,255,0,255,0,255,255,0,255,0,255,0,255,0,0,255,255,0,255, -0,0,255,255,0,0,0,255,255,0,255]);return function(b){l=new Uint8Array(32);s=new Uint8Array(32);e=new Uint8Array(32);r=Array(4);for(var a=0;4>a;a++)r[a]=new Uint8Array(32);q(g,0,r[2],0,g.length);var c=new Uint8Array(w(b));b=c.length;for(var f=b%32,n=(b-f)/32,a=0;a>>27)>>>0}function m(a,d,e,f,b,h){return(d^e^f)+b+h+1859775393+(a<<5|a>>>27)>>>0}function f(a,d,e,f,b,h){return(d&e|f&(d|e))+b+h+2400959708+(a<<5|a>>>27)>>>0}function d(a,d,e,f,b,h){return(d^e^f)+b+h+3395469782+(a<<5|a>>>27)>>>0}var k,r=new Uint32Array(80);return function(l){l=new Uint8Array(w(l));var s=l.length, -e=s+9;e%64&&(e+=64-e%64);k=new Uint32Array(5);k[0]=1732584193;k[1]=4023233417;k[2]=2562383102;k[3]=271733878;k[4]=3285377520;for(var g=0;gb;b++){var h=0,c=g+b;cc&&(h=s<<3>>>8*c&255));r[b>>2]=0===b%4?h<<24:r[b>>2]|h<<8*(3-b%4)}for(b=16;80>b;b++)h=r[b-3]^r[b-8]^r[b-14]^r[b-16],r[b]=h<<1|h>>>31;for(var b=k,h=r,c=b[0],p=b[1],n=b[2],q=b[3],t=b[4],v=a,u=0;80>u;u+=5)20===u?v=m:40===u?v=f:60===u&&(v=d),t=v(c,p,n,q,t,h[u]),p=(p<<30|p>>>2)>>>0, -q=v(t,c,p,n,q,h[u+1]),c=(c<<30|c>>>2)>>>0,n=v(q,t,c,p,n,h[u+2]),t=(t<<30|t>>>2)>>>0,p=v(n,q,t,c,p,h[u+3]),q=(q<<30|q>>>2)>>>0,c=v(p,n,q,t,c,h[u+4]),n=(n<<30|n>>>2)>>>0;b[0]+=c;b[1]+=p;b[2]+=n;b[3]+=q;b[4]+=t}for(b=0;5>b;b++)l=k[b],k[b]=(l&255)<<24|(l&65280)<<8|l>>8&65280|l>>24&255;return k.buffer}}();return function(a){a=a||{};this.name=(a.name||"GOST R 34.10")+"-"+(a.version||2012)%100+(1<(a.version||2012)?"-"+(a.length||256):"")+("HASH"!==(a.mode||"HASH")?"-"+a.mode:"")+(a.procreator?"/"+a.procreator: -"")+("string"===typeof a.sBox?"/"+a.sBox:"");this.procreator=a.procreator;this.bitLength=a.length||256;switch(a.version||2012){case 1:this.digest=Q;this.bitLength=160;break;case 1994:this.digest=D;this.sBox=(a.sBox||("SC"===a.procreator?"D-SC":"D-A")).toUpperCase();y||(y=z.GostCipher);if(!y)throw new F("Object GostCipher not found");this.cipher=new y({name:"GOST 28147",block:"ECB",sBox:this.sBox,procreator:this.procreator});break;case 2012:this.digest=P;break;default:throw new F("Algorithm version "+ -a.version+" not supported");}this.keySize=a.keySize||(2>=a.version?this.bitLength/8:32);switch(a.mode||"HASH"){case "HASH":break;case "HMAC":this.sign=C;this.verify=J;this.generateKey=E;break;case "KDF":this.deriveKey=G;this.deriveBits=M;this.label=a.label;this.context=a.context;break;case "PBKDF2":this.deriveKey=G;this.deriveBits=N;this.generateKey=E;this.salt=a.salt;this.iterations=a.iterations||2E3;this.diversifier=a.diversifier||1;break;case "PFXKDF":this.deriveKey=G;this.deriveBits=L;this.generateKey= -E;this.salt=a.salt;this.iterations=a.iterations||2E3;this.diversifier=a.diversifier||1;break;case "CPKDF":this.deriveKey=G;this.deriveBits=O;this.generateKey=E;this.salt=a.salt;this.iterations=a.iterations||2E3;break;default:throw new F("Algorithm mode "+a.mode+" not supported");}}}); -/* - 2014-2016, Rudolf Nickolaev. All rights reserved. -*/ -(function(K,F){"function"===typeof define&&define.amd?define(["gostRandom","gostDigest"],F):"object"===typeof exports?module.exports=F(require("gostRandom"),require("gostDigest")):K.GostSign=F(K.GostRandom,K.GostDigest)})(this,function(K,F){function B(a,b,c,d,e,f,g){var h=c&16383;for(c>>=14;0<=--g;){var k=a[b]&16383,l=a[b++]>>14,n=c*k+l*h,k=h*k+((n&16383)<<14)+d[e]+f;f=(k>>28)+(n>>14)+c*l;d[e++]=k&268435455}return f}function n(a){a=Array(Math.ceil(a));a.s=0;a.t=0;return a}function G(a,b){for(var c= -a.t-1;0<=c;--c)b[c]=a[c];b.t=a.t;b.s=a.s;return b}function ua(a,b){a.t=1;a.s=0>b?-1:0;0b?a[0]=b+268435456:a.t=0;return a}function C(a){var b=n(1);ua(b,a);return b}function u(a){for(var b=a.s&268435455;0>=28;if(b.t>=28;e+=a.s}else{for(e+=a.s;d>=28;e-=b.s}c.s=0>e?-1:0;-1>e? -c[d++]=268435456+e:0>=28;if(b.t>=28;e+=a.s}else{for(e+=a.s;d>=28;e+=b.s}c.s=0>e?-1:0;0e&&(c[d++]=268435456+e);c.t=d;return u(c)}function M(a){if(0>a.s){var b=n(a.t);a=p(t,a,b)}return a}function s(a,b){var c=a.s-b.s;if(0!==c)return c;var d= -a.t,c=d-b.t;if(0!==c)return 0>a.s?-c:c;for(;0<=--d;)if(0!==(c=a[d]-b[d]))return c;return 0}function ga(a){var b=1,c;0!==(c=a>>>16)&&(a=c,b+=16);0!==(c=a>>8)&&(a=c,b+=8);0!==(c=a>>4)&&(a=c,b+=4);0!==(c=a>>2)&&(a=c,b+=2);0!==a>>1&&(b+=1);return b}function U(a,b,c){var d;for(d=a.t-1;0<=d;--d)c[d+b]=a[d];for(d=b-1;0<=d;--d)c[d]=0;c.t=a.t+b;c.s=a.s;return c}function Y(a,b,c){for(var d=b;d>e|g,g=(a[h]&f)<=a.t)c.t=0;else{b%=28;var e=28-b,f=(1<>b;for(var g=d+1;g>b;0=a.t?0:28*(a.t-1)+ga(a[a.t-1]^a.s&268435455)}function Z(a,b,c){var d=M(a),e=M(b),f=d.t;for(c.t=f+e.t;0<=--f;)c[f]= -0;for(f=0;f=c.DV&&(b[d+c.t]-=c.DV,b[d+c.t+1]=1)}0=e.t)throw new Ea("Division by zero");var f=M(a);if(f.t>4:0),q=Fa/m,m=16777216/m,N=d.t,r=N-e;a=c?c:n(Math.max(a.t-b.t,1));U(g,r,a);0<=s(d,a)&&(d[d.t++]=1,p(d,a,d));U(R,e,a);for(p(a,g,g);g.th&&p(t,d,d);return c}function va(a,b,c){ia(M(a),b,null,c);0>a.s&&0a.s?-1:0>=a.t||1===a.t&&0>=a[0]?0:1}function aa(a,b){var c=y(b);if(y(a)&&c||0===S(b))return t;for(var d=G(b,n(b.t)),e=G(a,n(a.t)),f=C(1),g=C(0),h=C(0),k=C(1);0!==S(d);){for(;y(d);)H(d,1,d),c?(y(f)&&y(g)||(L(f,a,f),p(g,b,g)),H(f,1,f)):y(g)||p(g,b,g),H(g,1,g);for(;y(e);)H(e, -1,e),c?(y(h)&&y(k)||(L(h,a,h),p(k,b,k)),H(h,1,h)):y(k)||p(k,b,k),H(k,1,k);0<=s(d,e)?(p(d,e,d),c&&p(f,h,f),p(g,k,g)):(p(e,d,e),c&&p(h,f,h),p(k,g,k))}if(0!==s(e,R))return t;if(0<=s(k,b))return subtract(k,b);if(0>S(k))L(k,b,k);else return k;return 0>S(k)?L(k,b,n(k.t)):k}function V(a,b){var c=Math.floor(b/28);return c>=a.t?0!==a.s:0!==(a[c]&1<=d)return f;e=18>d?1:48>d?3:144>d?4:768>d?5:6;g=8>d?new wa(c):y(c)?new ka(c):new xa(c);var h=[],k=3,l=e-1,m=(1<=l?c=b[a]>>d-l&m:(c=(b[a]&(1<>28+d-l));for(k=e;0==(c&1);)c>>=1,--k;0>(d-=k)&&(d+=28,--a);if(p)G(h[c],f),p=!1;else{for(;1--d&&(d=27,--a)}return g.revert(f)}function w(a,b){a.r.reduce(b);b.q=a.q;b.r=a.r;return b}function ca(a,b){b.q=a.q;b.r=a.r;return b}function ya(a,b){var c=L(a,b,n(a.t));0c.s&&L(a.q,c,c);return ca(a,c)}function l(a,b){return w(a,v(a,b))}function O(a){return w(a,$(a,n(2*a.t)))}function T(a,b){var c=n(a.t);0>b? -H(a,-b,c):ha(a,b,c);return w(a,c)}function za(a){return ca(a,aa(a,a.q))}function P(a,b,c,d){return{curve:a,x:b,y:c,z:d||w(a,R)}}function da(a){a.zinv||(a.zinv=za(a.z));return l(a.x,a.zinv)}function Aa(a){a.zinv||(a.zinv=za(a.z));return l(a.y,a.zinv)}function W(a){return a.x||a.y?z(a.z)&&!z(a.y):!0}function X(a,b){if(W(a))return b;if(W(b))return a;var c=D(l(b.y,a.z),l(a.y,b.z)),d=D(l(b.x,a.z),l(a.x,b.z));if(z(d))return z(c)?la(a):a.curve.infinity;var e=a.x,f=a.y,g=O(d),h=l(g,d),e=l(e,g),g=l(O(c),a.z), -d=l(D(l(D(g,T(e,1)),b.z),h),d),c=ya(l(D(D(l(l(e,ea),c),l(f,h)),l(g,c)),b.z),l(c,h)),h=l(l(h,a.z),b.z);return P(a.curve,d,c,h)}function la(a){if(W(a))return a;if(0===S(a.y))return a.curve.infinity;var b=a.x,c=a.y,d=l(c,a.z),e=l(d,c),c=a.curve.a,f=l(O(b),ea);z(c)||(f=ya(f,l(O(a.z),c)));c=l(T(D(O(f),l(T(b,3),e)),1),d);b=D(l(T(D(l(l(f,ea),b),T(e,1)),2),e),l(O(f),f));d=T(l(O(d),d),3);return P(a.curve,c,b,d)}function ma(a,b){if(W(a))return a;if(0===S(b))return a.curve.infinity;var c=v(b,ea),d;d=a.curve; -var e=a.x,f;f=a.y;f=ca(f,fa(f.q,f));d=P(d,e,f,a.z);e=a;for(f=I(c)-2;0>28-c):b[b.t-1]|=f<g&&0<(c=a[f]>>g)&&(d=!0,e.push(c));0<=f;)8>g?(c=(a[f]&(1<>(g+=20)):(c=a[f]>>(g-=8)&255,0>=g&&(g+=28,--f)),0>28-e):b[b.t-1]|=f<a.s){var b=n(a.t);a=p(t,a,b);return"-"+na(a)}var c=!1,d="",e=a.t,f=28-28*e%4;if(0f&&0<(b=a[e]>>f)&&(c=!0,d=b.toString(16));0<=e;)4>f?(b=(a[e]&(1<>(f+=24)):(b=a[e]>>(f-=4)&15,0>=f&&(f+=28,--e)),0I(c)?I(b)-1:I(c)-1,h=a.curve.infinity,k=X(a,f);0<=g;)h=la(h),V(b,g)?h=V(c,g)?X(h,k):X(h,a):V(c,g)&&(h=X(h,f)),--g;d=m(da(h),d)}else g=this.p,h=this.a,f=q(a),d=m(m(v(ba(h,b,g),ba(f,c,g)),g),d);return 0===s(d,e)}function Ca(){var a=this.curve;if(a){for(a=a.infinity;W(a);){var b=t;if(this.ukm)b=q(this.ukm); -else for(;z(b);)b=m(q(ta(this.bitLength)),this.q);var a=ma(this.P,b),c=da(a),d=Aa(a)}return{privateKey:Q(b,this.bitLength),publicKey:sa(c,d,this.bitLength)}}throw new J("Key generation for GOST R 34.10-94 not supported");}function Ja(){if(this.curve){for(var a=t;z(a);)a=m(q(ta(this.bitLength)),this.q);return Q(a,this.bitLength)}throw new J("Key generation for GOST R 34.10-94 not supported");}function Ka(a,b){if(this.curve){var c=this.q,d=m(q(E(b)),c),e=m(q(E(a)),c),c="VN"===this.procreator?m(v(d, -e),c):m(v(d,aa(e,c)),c);return Q(c)}throw new J("Key wrapping GOST R 34.10-94 not supported");}function La(a,b){if(this.curve){var c=this.q,d=m(q(E(b)),c),e=m(q(E(a)),c),c="VN"===this.procreator?m(v(d,aa(e,c)),c):m(v(d,e),c);return Q(c)}throw new J("Key wrapping GOST R 34.10-94 not supported");}function Da(a){var b;b=q(this.ukm);var c=this.q;a=m(q(E(a)),c);this.curve?(b=ma(this.peer_Q,m(v(b,a),c)),b=sa(da(b),Aa(b),this.bitLength)):b=Q(ba(this.peer_y,a,this.p));return pa.call(this,b)}function Ma(a, -b){if(8>b||b>this.bitLength||0a.s||0<=s(a,this.m)?m(a,this.m):a},revert:function(a){return a}, -reduce:function(a){va(a,this.m,a)},sqrTo:function(a,b){$(a,b);this.reduce(b)},mulTo:function(a,b,c){Z(a,b,c);this.reduce(c)}});var xa=function(a){this.m=a;var b;if(1>a.t)b=0;else if(b=a[0],0===(b&1))b=0;else{var c=b&3,c=c*(2-(b&15)*c)&15,c=c*(2-(b&255)*c)&255,c=c*(2-((b&65535)*c&65535))&65535,c=c*(2-b*c%268435456)%268435456;b=0>15;this.um=8191;this.mt2=2*a.t};ja(xa,{convert:function(a){var b=n(a.t);U(M(a),this.m.t,b);ia(b,this.m, -null,b);0>a.s&&0>15)*this.mpl&this.um)<<15)&268435455,c=b+this.m.t;for(a[c]+=B(this.m,0,d,a,b,0,this.m.t);268435456<=a[c];)a[c]-=268435456,a[++c]++}u(a);Y(a,this.m.t,a);0<=s(a,this.m)&&p(a,this.m,a)},sqrTo:function(a,b){$(a,b);this.reduce(b)},mulTo:function(a,b,c){Z(a,b,c);this.reduce(c)}}); -ja(ka,{convert:function(a){if(0>a.s||a.t>2*this.m.t)return m(a,this.m);if(0>s(a,this.m))return a;var b=n(a.t);G(a,b);this.reduce(b);return b},revert:function(a){return a},reduce:function(a){Y(a,this.m.t-1,this.r2);a.t>this.m.t+1&&(a.t=this.m.t+1,u(a));var b=this.mu,c=this.r2,d=this.m.t+1,e=this.q3;--d;var f=e.t=b.t+c.t-d;for(e.s=0;0<=--f;)e[f]=0;for(f=Math.max(d-b.t,0);fs(a,this.r2);){b=a;for(c=this.m.t+1;b.t<=c;)b[b.t++]=0;for(b[c]+=1;268435456<=b[c];)b[c]-=268435456,++c>=b.t&&(b[b.t++]=0),++b[c]}for(p(a,this.r2,a);0<=s(a,this.m);)p(a,this.m,a)},sqrTo:function(a,b){$(a,b);this.reduce(b)},mulTo:function(a,b,c){Z(a,b,c);this.reduce(c)}});return function(a){a=a||{};this.name=(a.name||"GOST R 34.10")+"-"+(a.version||2012)% -100+"-"+(a.length||256)+("SIGN"!==(a.mode||"SIGN")?"-"+a.mode:"")+("string"===typeof a.namedParam?"/"+a.namedParam:"")+("string"===typeof a.namedCurve?"/"+a.namedCurve:"")+("string"===typeof a.sBox?"/"+a.sBox:"");var b=a.version||2012;switch(a.mode||"SIGN"){case "SIGN":this.sign=Ha;this.verify=Ia;this.generateKey=Ca;break;case "DH":this.deriveBits=Ma;this.deriveKey=Na;this.generateKey=Ca;break;case "MASK":this.wrapKey=La,this.unwrapKey=Ka,this.generateKey=Ja}if(1994===b)b=a.param,b||(b=Oa[this.namedParam= -(a.namedParam||"S-A").toUpperCase()]),this.modulusLength=a.modulusLength||b.modulusLength||1024,this.p=A(b.p),this.q=A(b.q),this.a=A(b.a),a["public"]&&(this.peer_y=q(a["public"]));else{b=a.curve;b||(b=r[this.namedCurve=(a.namedCurve||"S-256-A").toUpperCase()]);var c=A(b.p),d=A(b.a),e=A(b.b),f={};f.q=c;f.r=new ka(c);f.a=w(f,d);f.b=w(f,e);f.infinity=P(f);c=this.curve=f;this.P=P(c,w(c,A(b.x)),w(c,A(b.y)));this.q=A(b.q);a["public"]&&(b=ra(a["public"]),this.peer_Q=new P(this.curve,w(this.curve,b[0]),w(this.curve, -b[1])))}if(this.curve){c=a.length||I(this.q);if(508=c)c=512;else if(254=c)c=256;else throw new J("Support keys only 256 or 512 bits length");b=c}else{c=a.modulusLength||I(this.p);if(1016=c)c=1024;else if(508=c)c=512;else throw new J("Support keys only 512 or 1024 bits length");b=256}this.bitLength=b;this.keyLength=c;this.procreator=a.procreator;if(c=a.hash){if("string"===typeof c||c instanceof String)c={name:c};1994===a.version||2001===a.version?(c.version=1994,c.length= -256,c.sBox=a.sBox||c.sBox):(c.version=2012,c.length=b);c.procreator=c.procreator||a.procreator;F||(F=x.GostDigest);if(!F)throw new J("Object GostDigest not found");this.hash=new F(c)}a.ukm&&(this.ukm=a.ukm)}}); -/* - 2014-2016, Rudolf Nickolaev. All rights reserved. -*/ -(function(c,g){"function"===typeof define&&define.amd?define(["gostRandom","gostCipher","gostDigest","gostSign"],g):"object"===typeof exports?module.exports=g(require("gostRandom"),require("gostCipher"),require("gostDigest"),require("gostSign")):("undefined"!==typeof importScripts&&(c.GostRandom&&c.GostCipher&&c.GostDigest&&c.GostSign||importScripts("gostRandom.js","gostCipher.js","gostDigest.js","gostSign.js")),c.gostEngine=g(c.GostRandom,c.GostCipher,c.GostDigest,c.GostSign))})(this,function(c, -g,k,l){var f=this,m={execute:function(b,a,c){var e;if(!b)throw new (f.SyntaxError||Error)("Algorithm not defined");if(!b.name)throw new (f.SyntaxError||Error)("Algorithm name not defined");e=b.name;var d=b.mode;if("GOST 28147"!==e&&"GOST R 34.12"!==e&&"RC2"!==e||"generateKey"!==a&&("MAC"!==d||"sign"!==a&&"verify"!==a)&&("KW"!==d&&"MASK"!==d||"wrapKey"!==a&&"unwrapKey"!==a)&&(d&&"ES"!==d||"encrypt"!==a&&"decrypt"!==a))if("GOST R 34.11"!==e&&"SHA"!==e||"digest"!==a&&("HMAC"!==d||"sign"!==a&&"verify"!== -a&&"generateKey"!==a)&&("KDF"!==d&&"PBKDF2"!==d&&"PFXKDF"!==d&&"CPKDF"!==d||"deriveKey"!==a&&"deriveBits"!==a&&"generateKey"!==a)){if("GOST R 34.10"!==e||"generateKey"!==a&&(d&&"SIGN"!==d||"sign"!==a&&"verify"!==a)&&("MASK"!==d||"wrapKey"!==a&&"unwrapKey"!==a)&&("DH"!==d||"deriveKey"!==a&&"deriveBits"!==a))throw new (f.NotSupportedError||Error)("Algorithm "+e+"-"+d+" is not valid for "+a);e="GostSign"}else e="GostDigest";else e="GostCipher";b=this["get"+e](b);return b[a].apply(b,c)},getGostCipher:function(b){return new (g|| -(g=f.GostCipher))(b)},getGostDigest:function(b){return new (k||(k=f.GostDigest))(b)},getGostSign:function(b){return new (l||(l=f.GostSign))(b)}};if(f.importScripts)f.onmessage=function(b){try{postMessage({id:b.data.id,result:m.execute(b.data.algorithm,b.data.method,b.data.args)})}catch(a){postMessage({id:b.data.id,error:a.message})}};else{var n="",p="";"undefined"!==typeof document&&function(){for(var b=/^(.*)gostCrypto(.*)\.js$/i,a=document.querySelectorAll("script"),c=0,e=a.length;c=c?a:Array(c-a.length+1).join("0")+a}function Ja(a){return 2>=a?a:4>=a?4:8>=a?8:16>=a?16:32>=a?32:64>=a?64:128>=a?128:256>=a?256:512>a?512:1024>a?1024:void 0}function P(a){if(a)throw Error("Invalid format");}function ha(a,c,b,d){"object"!==typeof b&&(b={value:b});void 0!==d&&(b.enumerable=d);Object.defineProperty(a,c,b)}function Ka(a,c,b){for(var d in c)ha(a, -d,c[d],b)}function T(a,c,b,d,e,f){P(void 0===c);c={tagNumber:b,tagClass:d||0,tagConstructed:e||!1,object:c};a=a||"DER";if("DER"===a||"CER"===a)c=ia.encode(c,a);"PEM"===a&&(c=xa.encode(c,f));return c}function Y(a,c,b,d,e){P(void 0===a);"string"===typeof a&&(a=xa.decode(a,e,!1));if(a instanceof O)try{a=xa.decode(lc.encode(a),e,!0)}catch(f){a=ia.decode(a)}b=b||0;d=d||!1;void 0===a.tagNumber&&(a=T(!0,a.object,c,b,a.object instanceof Array),a=ia.decode(a));P(a.tagClass!==b||a.tagNumber!==c||a.tagConstructed!== -d);return 0===b&&5===c?null:a.object}function t(a,c,b,d){"function"!==typeof c&&(d=b,b=c,c=function(){a.apply(this,arguments)});c.prototype=Object.create(a.prototype,{constructor:{value:c},superclass:{value:a.prototype}});b&&Ka(c.prototype,b);if(a!==Object)for(var e in a)c[e]=a[e];c.super=a;d&&Ka(c,d,!0);return c}function La(){}var O=this.ArrayBuffer,I=x.security.algorithms,hb=x.security.names,ib=x.security.identifiers,ba=x.security.attributes,ca=x.security.parameters,ia=x.coding.BER,xa=x.coding.PEM, -lc=x.coding.Chars,jb=x.coding.Hex,kb=x.coding.Int16,U={encode:function(a,c){return"0x"+jb.encode(a,c)},decode:function(a,c,b){"number"===typeof a&&(a=a.toString(16));a=a.replace("0x","");b=b||Ja(a.length);return jb.decode(kc(a,b),c)}},k=t(Object,function(a){this.object=a},{_set:function(a,c,b){a.property(c).set.call(this,b)},_get:function(a,c){return a.property(c).get.call(this)},_call:function(a,c,b){return a.method(c).apply(this,b)},hasProperty:function(a){return this.hasOwnProperty(a)||!!this.constructor.property(a)}, -encode:function(){return this.object}},{decode:function(a){return new this(a)},property:function(a){for(var c=this.prototype;c;){var b=Object.getOwnPropertyDescriptor(c,a);if(b)return b;c=c.superclass}},method:function(a){for(var c=this.prototype;c;){if(c[a])return c[a];c=c.superclass}}}),y=function(a){return t(k,{encode:function(c){return T(c,this.object,a)}},{decode:function(c){return new this(Y(c,a))}})},da=y(1),ea=y(22),ya=y(18),za=y(19),mc=y(20),z=y(12),nc=y(23),A=y(24),oc=y(28),Ma=y(30),pa= -t(y(5),{object:{get:function(){return null},set:function(a){P(null!==a)}}}),lb=function(a){function c(c){return t(y(a),function(a){b.super.call(this,a)},{encode:function(b){return T(b,c[this.object],a)}},{decode:function(b){b=Y(b,a);for(var d in c)if(b===c[d])return new this(d);P(!0)}})}var b=t(y(a),function(a){if(this instanceof b)b.super.apply(this,arguments);else return c(a)});return b},h=lb(2),mb=lb(10),g=function(){function a(a){return a?t(a,{encode:function(c){return T(c,a.method("encode").call(this, -!0),4)}},{decode:function(c){return a.decode.call(this,Y(c,4))}}):c}var c=t(y(4),function(b){if(this instanceof c)c.super.apply(this,arguments);else return a(b)});return c}(),q=function(){function a(a){return a?t(a,{encode:function(c){return T(c,a.method("encode").call(this,!0),3)}},{decode:function(c){return a.decode.call(this,Y(c,3))}}):b}function c(a){return t(k,function(a,c){k.call(this,a);this.numbits=c||0},{encode:function(c){var b=this.object,d=[];if(b instanceof Array){for(var e=0,f=b.length;e< -f;e++){var S=a[b[e]];void 0!==S&&(d[S]="1")}e=0;for(f=Math.max(d.length,this.numbits);e\<\|\~]*$/.test(a)?"printableString":"utf8String"}),fa=r({utcTime:nc,generalTime:A},function(a){return 2050<= -a.getYear()?"generalTime":"utcTime"}),Na=J({type:l,value:k}),Oa={typeName:"type",valueName:"value"},ob=C(Na({serialName:za,countryName:za,dnQualifier:za,emailAddress:ea,domainComponent:ea,SNILS:ya,OGRN:ya,INN:ya},ja)),pc=m(ob,Oa)(),W=r({rdnSequence:pc},"rdnSequence"),pb=F(e({notBefore:fa,notAfter:fa})),qb=J({type:l,value:k}),G=B(qb,Oa),Pa=m(qb,Oa),qc=e({a:h,b:h,seed:d(q)}),rc=g(t(k,{encode:function(){var a=this.object,c=Math.max(Ja(a.x.length-2),Ja(a.y.length-2))/2,b=new Uint8Array(2*c+1);b[0]=4; -b.set(new Uint8Array(U.decode(a.x,!1,c)),1);b.set(new Uint8Array(U.decode(a.y,!1,c)),c+1);return b.buffer}},{decode:function(a){var c=(a.byteLength-1)/2;return new this({x:U.encode(new Uint8Array(a,1,c)),y:U.encode(new Uint8Array(a,c+1,c))})}})),sc=e({fieldType:l,parameters:h}),tc=e({version:h,fieldID:sc,curve:qc,base:rc,order:h,cofactor:d(h)}),uc=e({publicKeyParamSet:l,digestParamSet:l,encryptionParamSet:d(l)}),vc=function(a,c){a=a||k;return t(a,{encode:function(b){return this.object===c?(new pa(null)).encode(b): -a.method("encode").call(this,b)}},{decode:function(b){if(void 0!==b){if(null===b||5===b.tagNumber&&0===b.tagClass)return new this(c);try{return a.decode.call(this,b)}catch(d){}}}})}(l,"id-GostR3411-94-CryptoProParamSet"),wc=r({namedParameters:l,ecParameters:tc,implicitly:d(pa)},function(a){return"string"===typeof a||a instanceof String?"namedParameters":"ecParameters"}),H=function(a,c){return Q(e({algorithm:l,parameters:d(a)}),c)},s=function(){var a=H(k),c=t(k,function(a){if(this instanceof c)c.super.apply(this, -arguments);else return b(a)},{encode:function(c){return(new a(this.object)).encode(c)}},{decode:function(c){return new this(a.decode(c).object)}}),b=function(a){return t(k,{object:{get:function(){if(this.item)return this.item.object},set:function(c){if(c){var b=a[c.id];if(!b)throw Error("Algorithm not supported");this.item=new b(c)}else delete this.item}},encode:function(a){return this.item.encode(a)}},{decode:function(c){"string"===typeof c&&(c=xa.decode(c,void 0,!1));c instanceof O&&(c=ia.decode(c)); -var b=a[hb[c.object[0].object]];if(b){var d=new this;d.item=b.decode(c);return d}throw Error("Algorithm not supported");}})};return c}(),Aa=H(wc,{encode:function(a){return{algorithm:a.id,parameters:"string"===typeof a.namedCurve?ba.namedCurve[a.namedCurve]:{version:1,fieldID:{fieldType:"id-prime-Field",parameters:a.curve.p},curve:{a:a.curve.a,b:a.curve.b},base:{x:a.curve.x,y:a.curve.y},order:a.curve.q,cofactor:1}}},decode:function(a){var c=a.parameters;a=I[a.algorithm];if("string"===typeof c||c instanceof -String)a=w(a,ca[c]);else if("object"===typeof c)a=w(a,{curve:{p:c.fieldID.parameters,a:c.curve.a,b:c.curve.b,x:c.base.x,y:c.base.y,q:c.order}});else throw new DataError("Invalid key paramters");return a}}),L=H(uc,{encode:function(a){var c=a.namedCurve?"namedCurve":"namedParam",b=0<=a.name.indexOf("-94")||0<=a.name.indexOf("-2001")||1994===a.version||2001===a.version?a.sBox||"D-A":0<=a.name.indexOf("-512")||512===a.length?"D-512":"D-256";return{algorithm:a.id,parameters:{publicKeyParamSet:ba[c][a[c]], -digestParamSet:ba.sBox[b],encryptionParamSet:a.encParams&&a.encParams.sBox?ba.sBox[a.encParams.sBox]:void 0}}},decode:function(a){var c=a.parameters;a=w(I[a.algorithm],ca[c.publicKeyParamSet],ca[c.digestParamSet]);c.encryptionParamSet&&(a.encParams=ca[c.encryptionParamSet]);return a}}),u=H(k,{encode:function(a){return{algorithm:a.id}},decode:function(a){return I[a.algorithm]}}),v=H(pa,{encode:function(a){return{algorithm:a.id,parameters:null}},decode:function(a){return I[a.algorithm]}}),qa=H(vc,{encode:function(a){return{algorithm:a.id, -parameters:ba.sBox[a.sBox||a.hash&&a.hash.sBox||"D-A"]}},decode:function(a){var c=w(I[a.algorithm]);a=ca[a.parameters];c.hash?c.hash=w(c.hash,a):c=w(c,a);return c}}),$=s({ecdsa:Aa,noSignature:v,rsaEncryption:v,"id-sc-gostR3410-2001":Aa,"id-GostR3410-2001":L,"id-GostR3410-94":L,"id-GostR3410-2001DH":L,"id-GostR3410-94DH":L,"id-tc26-gost3410-12-256":L,"id-tc26-gost3410-12-512":L,"id-tc26-agreement-gost-3410-12-256":L,"id-tc26-agreement-gost-3410-12-512":L,"id-sc-gost28147-gfb":u,"id-Gost28147-89":u}), -R=s({noSignature:v,rsaEncryption:v,sha1withRSAEncryption:v,sha256withRSAEncryption:v,sha384withRSAEncryption:v,sha512withRSAEncryption:v,ecdsa:u,"ecdsa-with-SHA1":u,"ecdsa-with-SHA256":u,"ecdsa-with-SHA384":u,"ecdsa-with-SHA512":u,"id-GostR3410-94":v,"id-GostR3410-2001":v,"id-GostR3411-94-with-GostR3410-2001":u,"id-GostR3411-94-with-GostR3410-94":u,"id-tc26-gost3410-12-256":v,"id-tc26-gost3410-12-512":v,"id-tc26-signwithdigest-gost3410-12-94":u,"id-tc26-signwithdigest-gost3410-12-256":u,"id-tc26-signwithdigest-gost3410-12-512":u, -"id-sc-gostR3410-94":v,"id-sc-gostR3410-2001":v,"id-sc-gostR3411-94-with-gostR3410-94":v,"id-sc-gostR3411-94-with-gostR3410-2001":v}),la=s({sha1:u,sha256:v,sha384:v,sha512:v,"id-GostR3411-94":qa,"id-tc26-gost3411-94":qa,"id-tc26-gost3411-12-256":v,"id-tc26-gost3411-12-512":v,"id-sc-gostR3411-94":u}),rb=e({iv:g,encryptionParamSet:l}),xc=e({encryptionParamSet:l,ukm:d(g)}),Qa=H(rb,{encode:function(a){return{algorithm:a.id,parameters:{iv:a.iv,encryptionParamSet:ba.sBox[a.sBox||"E-A"]}}},decode:function(a){var c= -w(I[a.algorithm],ca[a.parameters.encryptionParamSet]);c.iv=a.parameters.iv;return c}}),Ra=H(g,{encode:function(a){return{algorithm:a.id,parameters:a.iv}},decode:function(a){var c=w(I[a.algorithm]);c.iv=a.parameters||new Uint8Array([0,0,0,0,0,0,0,0]);return c}}),Ba=H(xc,{encode:function(a){return{algorithm:a.id,parameters:{encryptionParamSet:ba.sBox[a.sBox||"E-A"],ukm:a.ukm}}},decode:function(a){var c=w(I[a.algorithm],ca[a.parameters.encryptionParamSet]);a.parameters.ukm&&(c.ukm=a.parameters.ukm); -return c}}),sb=s({"id-Gost28147-89-None-KeyWrap":Ba,"id-Gost28147-89-CryptoPro-KeyWrap":Ba}),Ca=H(sb,{encode:function(a){return{algorithm:a.id,parameters:a.wrapping}},decode:function(a){var c=w(I[a.algorithm]);c.wrapping=a.parameters;return c}}),yc=s({"id-sc-gost28147-gfb":Ra,"id-Gost28147-89":Qa}),Sa=s({"id-Gost28147-89-MAC":rb,"id-HMACGostR3411-94":qa,"id-tc26-hmac-gost-3411-12-256":qa,"id-tc26-hmac-gost-3411-12-512":qa,hmacWithSHA1:u,hmacWithSHA224:u,hmacWithSHA256:u,hmacWithSHA384:u,hmacWithSHA512:u, -"id-sc-gost28147-mac":u,"id-sc-hmacWithGostR3411":u}),zc=e({salt:r({specified:g,otherSource:s},function(a){return X(a)?"specified":"otherSource"}),iterationCount:h,keyLength:d(h),prf:Sa}),Ac=H(zc,{encode:function(a){return{algorithm:a.id,parameters:{salt:a.salt,iterationCount:a.iterations,prf:a.hmac}}},decode:function(a){var c=w(I[a.algorithm]);c.salt=a.parameters.salt;c.iterations=a.parameters.iterationCount;c.hmac=a.parameters.prf;c.hash=c.hmac.hash;return c}}),Ta=s({PBKDF2:Ac}),tb=e({salt:g,iterationCount:h}), -n=H(tb,{paramType:tb,encode:function(a){return{algorithm:a.id,parameters:{salt:a.derivation.salt,iterationCount:a.derivation.iterations}}},decode:function(a){var c=w(I[a.algorithm]);c.derivation=w(c.derivation,{salt:a.parameters.salt,iterations:a.parameters.iterationCount});return c}}),Bc=e({keyDerivationFunc:Ta,encryptionScheme:yc}),Ua=H(Bc,{encode:function(a){return{algorithm:a.id,parameters:{keyDerivationFunc:a.derivation,encryptionScheme:a.encryption}}},decode:function(a){var c=w(I[a.algorithm]); -c.derivation=a.parameters.keyDerivationFunc;c.encryption=a.parameters.encryptionScheme;return c}});s({"pbeWithSHAAndAES128-CBC":n,"pbeWithSHAAndAES192-CBC":n,"pbeWithSHAAndAES256-CBC":n,"pbeWithSHA256AndAES128-CBC":n,"pbeWithSHA256AndAES192-CBC":n,"pbeWithSHA256AndAES256-CBC":n,"id-sc-pbeWithGost3411AndGost28147":n,"id-sc-pbeWithGost3411AndGost28147CFB":n,"pbeWithSHAAnd3-KeyTripleDES-CBC":n,"pbeWithSHAAnd2-KeyTripleDES-CBC":n,"pbeWithSHAAnd128BitRC2-CBC":n,"pbeWithSHAAnd40BitRC2-CBC":n,pbeUnknownGost:n, -PBES2:Ua});var ra=s({ecdsa:Aa,rsaEncryption:v,"id-sc-gost28147-gfb":Ra,"id-Gost28147-89":Qa,"id-sc-gostR3410-2001":Aa,"id-GostR3410-2001":L,"id-GostR3410-94":L,"id-tc26-gost3410-12-256":L,"id-tc26-gost3410-12-512":L,"id-GostR3410-94-CryptoPro-ESDH":Ca,"id-GostR3410-2001-CryptoPro-ESDH":Ca,"id-tc26-agreement-gost-3410-12-256":Ca,"id-tc26-agreement-gost-3410-12-512":Ca,"id-sc-r3410-ESDH-r3411kdf":v,"id-Gost28147-89-None-KeyWrap":Ba,"id-Gost28147-89-CryptoPro-KeyWrap":Ba,"id-sc-cmsGostWrap":u,"id-sc-cmsGost28147Wrap":u, -"pbeWithSHAAndAES128-CBC":n,"pbeWithSHAAndAES192-CBC":n,"pbeWithSHAAndAES256-CBC":n,"pbeWithSHA256AndAES128-CBC":n,"pbeWithSHA256AndAES192-CBC":n,"pbeWithSHA256AndAES256-CBC":n,"id-sc-pbeWithGost3411AndGost28147":n,"id-sc-pbeWithGost3411AndGost28147CFB":n,"pbeWithSHAAnd3-KeyTripleDES-CBC":n,"pbeWithSHAAnd2-KeyTripleDES-CBC":n,"pbeWithSHAAnd128BitRC2-CBC":n,"pbeWithSHAAnd40BitRC2-CBC":n,pbeUnknownGost:n,PBES2:Ua}),Cc=e({keyDerivationFunc:Ta,messageAuthScheme:Sa}),Dc=H(Cc,{encode:function(a){return{algorithm:a.id, -parameters:{keyDerivationFunc:a.derivation,messageAuthScheme:a.hmac}}},decode:function(a){var c=w(I[a.algorithm]);c.derivation=a.parameters.keyDerivationFunc;c.hmac=a.parameters.messageAuthScheme;return c}});s({PBMAC1:Dc});var Ec=s({"id-sc-gost28147-gfb":Ra,"id-Gost28147-89":Qa,"pbeWithSHAAndAES128-CBC":n,"pbeWithSHAAndAES192-CBC":n,"pbeWithSHAAndAES256-CBC":n,"pbeWithSHA256AndAES128-CBC":n,"pbeWithSHA256AndAES192-CBC":n,"pbeWithSHA256AndAES256-CBC":n,"id-sc-pbeWithGost3411AndGost28147":n,"id-sc-pbeWithGost3411AndGost28147CFB":n, -"pbeWithSHAAnd3-KeyTripleDES-CBC":n,"pbeWithSHAAnd2-KeyTripleDES-CBC":n,"pbeWithSHAAnd128BitRC2-CBC":n,"pbeWithSHAAnd40BitRC2-CBC":n,pbeUnknownGost:n,PBES2:Ua}),ub=Q(q(K(h)),{encode:function(a){return kb.encode(wa(a))},decode:function(a){return wa(kb.decode(a))}}),vb=Q(q(K(g)),{encode:function(a){var c=new Uint8Array(a.byteLength+1),b=wa(a);a=a.byteLength/2;c[0]=4;c.set(new Uint8Array(b,a,a),1);c.set(new Uint8Array(b,0,a),a+1);return c.buffer},decode:function(a){P(0===(a.byteLength&1));var c=new Uint8Array(a.byteLength- -1),b=c.byteLength/2;c.set(new Uint8Array(a,b+1,b),0);c.set(new Uint8Array(a,1,b),b);return wa(c)}}),M=q(K(g)),ma=e({algorithm:$,subjectPublicKey:q},"PUBLIC KEY"),Va=function(a){return Q(J({algorithm:$,subjectPublicKey:k},"algorithm","subjectPublicKey")(function(c){return a[c.id]}),{encode:function(a){return{algorithm:a.algorithm,subjectPublicKey:a.buffer}},decode:function(a){return{algorithm:a.algorithm,type:"public",extractable:!0,usages:["verify","deriveKey","deriveBits"],buffer:a.subjectPublicKey}}})}({"id-sc-gostR3410-2001":vb, -"id-sc-gostR3410-94":ub,"id-GostR3410-2001":M,"id-GostR3410-94":M,"id-tc26-gost3410-12-256":M,"id-tc26-gost3410-12-512":M}),wb=Q(g(K(h)),{encode:function(a){return U.encode(a,!0)},decode:function(a){return U.decode(a,!0)}}),Fc=e({keyValueMask:g,keyValyePublicKey:g}),ga=r({privateKey:g(K(r({keyValueMask:g,keyValueInfo:Fc},function(a){return X(a)?"keyValueMask":"keyValueInfo"}))),keyValueMask:g},function(a){return a.enclosed?"keyValueMask":"privateKey"}),Gc=function(a){return J({version:h,privateKeyAlgorithm:$, -privateKeyWrapped:Q(g(K(e({keyData:h,keyMac:h}))),{encode:function(a){var b=a.byteLength-4;return{keyData:U.encode(new Uint8Array(a,0,b)),keyMac:U.encode(new Uint8Array(a,b,4))}},decode:function(a){var b=U.decode(a.keyData);a=U.decode(a.keyMac);var d=new Uint8Array(b.byteLength+a.byteLength);d.set(new Uint8Array(b));d.set(new Uint8Array(a),b.byteLength);return d}}),attributes:k},"privateKeyAlgorithm","attributes")(function(c){return d(b(0,f(G({"id-sc-gostR3410-2001-publicKey":C(a[c.id])}))))})}({"id-sc-gostR3410-2001":vb, -"id-sc-gostR3410-94":ub,"id-GostR3410-2001":M,"id-GostR3410-94":M,"id-GostR3410-2001DH":M,"id-GostR3410-94DH":M,"id-tc26-gost3410-12-256":M,"id-tc26-gost3410-12-512":M,"id-tc26-agreement-gost-3410-12-256":M,"id-tc26-agreement-gost-3410-12-512":M}),Wa=e({version:h,privateKeyAlgorithm:$,privateKey:g,attributes:d(b(0,f(G)))},"PRIVATE KEY"),Hc=e({version:h,privateKeyAlgorithm:$,privateKey:g,attributes:d(b(0,f(G))),publicKey:d(b(1,f(q)))}),Ic=m(Hc),Jc=function(a){return Q(J({version:h,privateKeyAlgorithm:$, -privateKey:k,attributes:d(b(0,f(G)))},"privateKeyAlgorithm","privateKey")(function(c){return a[c.id]}),{encode:function(a){return{version:0,privateKeyAlgorithm:a.algorithm,privateKey:a.buffer}},decode:function(a){return{algorithm:a.privateKeyAlgorithm,type:"private",extractable:!0,usages:["sign","deriveKey","deriveBits"],buffer:X(a.privateKey)?a.privateKey:a.privateKey.keyValueMask}}})}({"id-sc-gostR3410-2001":wb,"id-sc-gostR3410-94":wb,"id-GostR3410-2001":ga,"id-GostR3410-94":ga,"id-GostR3410-2001DH":ga, -"id-GostR3410-94DH":ga,"id-tc26-gost3410-12-256":ga,"id-tc26-gost3410-12-512":ga,"id-tc26-agreement-gost-3410-12-256":ga,"id-tc26-agreement-gost-3410-12-512":ga}),xb=e({encryptionAlgorithm:ra,encryptedData:g},"ENCRYPTED PRIVATE KEY"),Kc=e({cA:V(da,!1),pathLenConstraint:d(h)}),Lc=q({digitalSignature:0,nonRepudiation:1,keyEncipherment:2,dataEncipherment:3,keyAgreement:4,keyCertSign:5,cRLSign:6,encipherOnly:7,decipherOnly:8}),Mc=m(l),Nc=e({type:l,value:b(0,p(k))}),Oc=e({nameAssigner:d(b(0,f(ja))),partyName:d(b(1, -f(ja)))}),Pc=e({}),D=r({otherName:b(0,f(Nc)),rfc822Name:b(1,f(ja)),dNSName:b(2,f(ja)),x400Address:b(3,f(Pc)),directoryName:b(4,p(W)),ediPartyName:b(5,f(Oc)),uniformResourceIdentifier:b(6,f(ja)),iPAddress:b(7,f(g)),registeredID:b(8,f(l))},function(a){return"string"===typeof a||a instanceof String?0<=a.indexOf("@")?"rfc822Name":"dNSName":X(a)?"iPAddress":"directoryName"}),E=m(D),Xa=e({keyIdentifier:d(b(0,f(g))),authorityCertIssuer:d(b(1,f(E))),authorityCertSerialNumber:d(b(2,f(h)))}),Qc=e({notBefore:d(b(0, -f(A))),notAfter:d(b(1,f(A)))}),Rc=e({policyQualifierId:l,qualifier:k}),Sc=e({policyIdentifier:l,policyQualifiers:d(m(Rc))}),Tc=e({issuerDomainPolicy:l,subjectDomainPolicy:l}),Uc=e({base:D,minimum:V(b(0,f(h)),0),maximum:d(b(1,f(h)))}),yb=m(Uc),Vc=e({permittedSubtrees:d(b(0,f(yb))),excludedSubtrees:d(b(1,f(yb)))}),Wc=e({requireExplicitPolicy:d(b(0,f(h))),inhibitPolicyMapping:d(b(1,f(h)))}),Ya=q({unused:0,keyCompromise:1,cACompromise:2,affiliationChanged:3,superseded:4,cessationOfOperation:5,certificateHold:6, -privilegeWithdrawn:7,aACompromise:8}),zb=r({fullName:b(0,f(E)),nameRelativeToCRLIssuer:b(1,f(ob))},function(a){return a instanceof Array?"fullName":"nameRelativeToCRLIssuer"}),Xc=e({distributionPoint:d(b(0,p(zb))),reasons:d(b(1,f(Ya))),cRLIssuer:d(b(2,f(E)))}),Da=m(Xc),Za=e({accessMethod:l,accessLocation:D}),Ab=function(a,b){var d=J({extnID:l,critical:V(da,!1),extnValue:function(a){return g(K(a))}},"extnID","extnValue"),e=t(d(a),{object:{get:function(){var a=this._get(e.super,"object");a&&"object"=== -typeof a.extnValue&&this.defineValue(a.extnValue);return a},set:function(a){this._set(e.super,"object",a);a&&a.extnValue&&(void 0!==a.extnValue.critical?this.critical=a.extnValue.critical:void 0===this.critical&&b&&(this.critical=b(this.extnID,a.extnValue)))}},extnValue:{get:function(){var a=this._get(e.super,"extnValue");"object"===typeof a&&this.defineValue(a);return a},set:function(a){this._set(e.super,"extnValue",a);a&&(void 0!==a.critical?this.critical=a.critical:void 0===this.critical&&b&&(this.critical= -b(this.extnID,a)))}},defineValue:function(a){if("object"===typeof a&&!Object.getOwnPropertyDescriptor(a,"critical")){var b=this;ha(a,"critical",{get:function(){return b.critical},set:function(a){b.critical=a},enumerable:!0,configurable:!1})}}});return e},Yc=e({signTool:z,cATool:z,signToolCert:z,cAToolCert:z}),na=m(Ab,{typeName:"extnID",valueName:"extnValue"}),Ea=na({authorityKeyIdentifier:Xa,subjectKeyIdentifier:g,keyUsage:Lc,privateKeyUsagePeriod:Qc,certificatePolicies:m(Sc),policyMappings:m(Tc), -subjectAltName:E,issuerAltName:E,subjectDirectoryAttributes:Pa,basicConstraints:Kc,nameConstraints:Vc,policyConstraints:Wc,extKeyUsage:Mc,cRLDistributionPoints:Da,inhibitAnyPolicy:h,freshestCRL:Da,authorityInfoAccess:m(Za),subjectInfoAccess:m(Za),subjectSignTool:z,issuerSignTool:Yc},function(a,b){return"keyUsage"===a||"basicConstraints"===a&&void 0===b.pathLenConstraint}),Zc=e({r:h,s:h}),Bb=F(e({version:b(0,p(h)),serialNumber:h,signature:R,issuer:W,validity:pb,subject:W,subjectPublicKeyInfo:ma,issuerUniqueID:d(b(1, -f(q))),subjectUniqueID:d(b(2,f(q))),extensions:d(b(3,p(Ea)))})),ka=e({tbsCertificate:Bb,signatureAlgorithm:R,signatureValue:q},"CERTIFICATE"),$c=G({challengePassword:C(ja),extensionRequest:C(Ea),msCertExtensions:C(Ea),extendedCertificateAttributes:C(G)}),Cb=F(e({version:h,subject:W,subjectPublicKeyInfo:ma,attributes:b(0,f($c))})),Db=e({requestInfo:Cb,signatureAlgorithm:R,signatureValue:q},"CERTIFICATE REQUEST"),Eb=mb({unspecified:0,keyCompromise:1,cACompromise:2,affiliationChanged:3,superseded:4, -cessationOfOperation:5,certificateHold:6,removeFromCRL:8,privilegeWithdrawn:9,aACompromise:10}),ad=e({distributionPoint:d(b(0,p(zb))),onlyContainsUserCerts:V(b(1,f(da)),!1),onlyContainsCACerts:V(b(2,f(da)),!1),onlySomeReasons:d(b(3,f(Ya))),indirectCRL:V(b(4,f(da)),!1),onlyContainsAttributeCerts:V(b(5,f(da)),!1)}),bd=na({authorityKeyIdentifier:Xa,issuerAltName:E,cRLNumber:h,deltaCRLIndicator:h,issuingDistributionPoint:ad,freshestCRL:Da},function(a){return"cRLNumber"===a}),cd=na({cRLReason:Eb,instructionCode:l, -invalidityDate:A,certificateIssuer:E}),Fb=F(e({version:d(h),signature:R,issuer:W,thisUpdate:fa,nextUpdate:d(fa),revokedCertificates:d(m(e({userCertificate:h,revocationDate:fa,crlEntryExtensions:d(cd)}))),crlExtensions:d(b(0,p(bd)))})),$a=e({tbsCertList:Fb,signatureAlgorithm:R,signatureValue:q},"CRL"),ab=e({digestedObjectType:mb({publicKey:0,publicKeyCert:1,otherObjectTypes:2}),otherObjectTypeID:d(l),digestAlgorithm:la,objectDigest:q}),Fa=e({issuer:E,serial:h,issuerUID:d(q)}),dd=e({issuerName:d(E), -baseCertificateID:d(b(0,f(Fa))),objectDigestInfo:d(b(1,f(ab)))}),ed=e({targetCertificate:Fa,targetName:d(D),certDigestInfo:d(ab)}),fd=r({targetName:b(0,p(D)),targetGroup:b(1,p(D)),targetCert:b(2,f(ed))}),gd=m(fd),hd=na({auditIdentity:g,targetInformation:gd,authorityKeyIdentifier:Xa,authorityInfoAccess:m(Za),cRLDistributionPoints:Da,noRevAvail:pa},function(a){return"auditIdentity"===a||"targetInformation"===a}),id=e({baseCertificateID:d(b(0,f(Fa))),entityName:d(b(1,f(E))),objectDigestInfo:d(b(2,f(ab)))}), -jd=r({v1Form:E,v2Form:b(0,f(dd))},"v2Form"),Gb=e({notBeforeTime:A,notAfterTime:A}),Hb=e({service:D,ident:D,authInfo:d(g)}),kd=e({roleAuthority:d(b(0,f(E))),roleName:b(1,p(D))}),ld=q({unmarked:0,unclassified:1,restricted:2,confidential:3,secret:4,topSecret:5}),md=e({type:b(0,f(l)),value:b(1,f(k))}),nd=e({policyId:b(0,f(l)),classList:V(b(1,f(ld)),["unclassified"]),securityCategories:d(b(2,f(B(md))))}),Ib=e({policyAuthority:d(b(0,f(E))),values:m(r({octets:g,oid:l,string:z},function(a){return X?"octets": -getIdentifier(a)?"oid":"string"}))}),Jb=F(e({version:h,holder:id,issuer:jd,signature:R,serialNumber:h,attrCertValidityPeriod:Gb,attributes:Pa({authenticationInfo:B(Hb),accessIdentity:B(Hb),chargingIdentity:C(Ib),group:C(Ib),role:B(kd),clearance:B(nd)}),issuerUniqueID:d(q),extensions:d(hd)})),Kb=e({acinfo:Jb,signatureAlgorithm:R,signatureValue:q},"ATTRIBUTE CERTIFICATE"),oa=g,sa=g;e({keyInfo:sb,entityUInfo:d(b(0,p(g))),suppPubInfo:b(2,p(g))});var N=Q(e({encryptedKey:g,maskKey:d(b(0,f(g))),macKey:g}), -{encode:function(a){var b=(new Uint8Array(new Uint8Array(a,0,32))).buffer;a=(new Uint8Array(new Uint8Array(a,32,4))).buffer;return{encryptedKey:b,macKey:a}},decode:function(a){var b=a.encryptedKey,d=a.maskKey;a=a.macKey;if(d)for(var d=new Int32Array(d),e=new Int32Array(b),f=0,g=d.length/e.length;f>>8&255);c.push(0);c.push(0)}return(new Uint8Array(c)).buffer}return 0<=a.name.indexOf("PFXKDF")?A.Chars.decode(b+"\x00","unicode"):A.Chars.decode(b,"utf8")}function x(){}function q(a,b){t.ContentInfo.call(this,a||b||{contentType:"data"});if(b&&this.contentType!==(b.contentType||"data"))throw Error("Invalid content type");}function J(a){q.call(this,a,{contentType:"digestedData",version:0,digestAlgorithm:v[r.providerName].digest, -encapContentInfo:{eContentType:"data"},digest:new w(0)})}function K(a){q.call(this,a,{contentType:"signedData",version:1,digestAlgorithms:[],encapContentInfo:{eContentType:"data"},signerInfos:[]})}function L(a){q.call(this,a,{contentType:"encryptedData",version:0,encryptedContentInfo:{contentType:"data",contentEncryptionAlgorithm:v[r.providerName].encryption}})}function M(a){q.call(this,a,{contentType:"envelopedData",version:0,recipientInfos:[],encryptedContentInfo:{contentType:"data",contentEncryptionAlgorithm:v[r.providerName].encryption}})} -var m=this.Promise,D=this.Object,w=this.ArrayBuffer,U=this.Date,h=p.subtle,t=p.asn1,A=p.coding,V=p.cert,v=p.security.providers,N=function(){var a=function(a){var b=typeof a;return"undefined"===b||""===a?"0":"number"===b||a instanceof Number?a.toString(16).toLowerCase():a.replace("0x","").toLowerCase()},b=function(a,b){return(Array(b+1).join("0")+a).slice(-b)};return function(c,d){c=a(c);d=a(d);var e=Math.max(c.length,d.length);return b(c,e)===b(d,e)}}(),r={providerName:"CP-01",autoAddCert:!1,useKeyIdentifier:!1}; -x.prototype.options=r;y(t.ContentInfo,q,{isDetached:{value:!1,enumerable:!0,writable:!0},writeDetached:function(a){this.isDetached=a},encode:function(a){if(this.isDetached){var b=Q(this);H(this,{contentType:b.contentType});a=t.ContentInfo.method("encode").call(this,a);H(this,b);return a}return t.ContentInfo.method("encode").call(this,a)},encloseContent:function(a){var b=this;return(new m(l)).then(function(){b.setEnclosed(a);return b})},setEnclosed:function(a){H(this,I(a))},getEnclosed:function(){return z(Q(this))}}); -x.prototype.DataContentInfo=q;y(q,J,{encloseContent:function(a,b){var c=this;return(new m(l)).then(function(){c.setEnclosed(a);if(b){var d=v[b];c.digestAlgorithm=d&&d.digest||b}return h.digest(c.digestAlgorithm,c.encapContentInfo.eContent)}).then(function(a){c.digest=a})},verify:function(a){var b=this;return(new m(l)).then(function(){a&&b.setEnclosed(a);if(!b.encapContentInfo||!b.encapContentInfo.eContent)throw Error("Detached content is not found");return h.digest(b.digestAlgorithm,b.encapContentInfo.eContent)}).then(function(a){if(!E(a, -b.digest))throw Error("Message digest is not verified");return z({contentType:b.encapContentInfo.eContentType,content:b.encapContentInfo.eContent})})}});x.prototype.DigestedDataContentInfo=J;y(q,K,{addSignature:function(a,b,c,d){var e=this,f,g,n;return(new m(l)).then(function(){if(!a||!b)throw Error("Signer key or certificate is not defined");b instanceof Array?(n=b,b=n[0]):n=[b];var s=b.getProvider()||v[r.providerName],S=r.useKeyIdentifier&&b.extensions&&b.extensions.subjectKeyIdentifier;g=e.encapContentInfo.eContent; -f={version:S?2:0,sid:S?b.extensions.subjectKeyIdentifier:{issuer:b.issuer,serialNumber:b.serialNumber},digestAlgorithm:s.digest,signatureAlgorithm:b.subjectPublicKeyInfo.algorithm};d&&(f.unsignedAttrs=d);if(c)return"object"!==typeof c&&(c={}),h.digest(f.digestAlgorithm,g)}).then(function(b){b&&(c.contentType=e.encapContentInfo.eContentType,c.messageDigest=b,c.signingTime=new U,f.signedAttrs=c,g=t.SignedAttributes.encode(f.signedAttrs));return h.importKey("pkcs8",t.PrivateKeyInfo.encode(a),a.privateKeyAlgorithm, -!1,["sign"])}).then(function(a){var b=k(f.signatureAlgorithm,{hash:f.digestAlgorithm});return h.sign(b,a,g)}).then(function(a){f.signatureValue=a;G(e.digestAlgorithms,f.digestAlgorithm,function(a,b){return a.id===b.id});if(r.autoAddCert){e.certificates||(e.certificates=[]);a=0;for(var b=n.length;ab.date.getTime())}function C(a,b,c){a={subject:a.issuer,date:c};if(b=b&&b.authorityKeyIdentifier)a.subjectKeyIdentifier=b.keyIdentifier,b.authorityCertIssuer&&b.authorityCertIssuer[0]&&b.authorityCertSerialNumber&& -(a.issuer=b.authorityCertIssuer[0],a.serialNumber=b.authorityCertSerialNumber);return a}function A(a,b){for(var c=[],d=0,e=a.length;dc.getTime()||d.notAfter.getTime()<=c.getTime())throw Error("The certificate has not yet started or expired");for(var b in e)if(e[b].critical&&0>"authorityKeyIdentifier subjectKeyIdentifier keyUsage certificatePolicies policyMappings basicConstraints nameConstraints policyConstraints extKeyUsage".split(" ").indexOf(b))throw Error("The critical extension '"+ -b+"' is unrecognized");b=C(d,e,d.notBefore);!a&&x(d,b)&&(a=d);if(a){if(!x(a,b)||!a.checkUsage("keyCertSign",d.notBefore))throw Error("The issuer's certificate is not valid");return a.verifySignature(d.tbsCertificate.encode(),d.signatureValue,d.signatureAlgorithm)}return!0}).then(function(a){if(!a)throw Error("The certificate has invalid signature");if(b){if(!H(b,{issuer:d.issuer,date:c}))throw Error("The issuer's CRL is not valid");if(b.isRevoked(d.serialNumber))throw Error("The certificate is revoked"); -}return d})},verifySignature:function(a,b,c){return this.getPublicKey().then(function(d){return k.verify(c,d,b,a)})},checkUsage:function(a,b){var c=this.extensions;b=b||w();return this.notBefore.getTime()<=b.getTime()&&this.notAfter.getTime()>b.getTime()&&(!c||!(0<["keyCertSign","cRLSign"].indexOf(a)&&c.basicConstraints&&!c.basicConstraints.cA||c.keyUsage&&0>c.keyUsage.indexOf(a)&&c.extKeyUsage&&0>c.extKeyUsage.indexOf(a)))}});r.prototype.X509=u;var z=function(a){z.super.call(this,a);this.version|| -(this.version=1);this.revokedCertificates||(this.revokedCertificates=[]);this.thisUpdate||(this.thisUpdate=w())};t(h.CertificateList,z,{sign:function(a,b){var c=this;return(new n(q)).then(function(){if(!a)throw Error("The issuer's private key is not defined");if(!b)throw Error("The issuer's certificate is not defined");if(!c.issuer)c.issuer=b.issuer;else if(!B(c.issuer,b.issuer))throw Error("The CRL prototype and authority certificate have different issuers");if(!b.checkUsage("cRLSign",c.thisUpdate))throw Error("The issuer's certificate is not valid for signing a CRL"); -var d=b.getProvider()||s[l.providerName];c.signature||(c.signature=d.signature);c.signatureAlgorithm=c.signature;c.issuer=b.subject;c.crlExtensions||(c.crlExtensions={});var d=c.crlExtensions,e=b.extensions;e&&e.subjectKeyIdentifier&&(d.authorityKeyIdentifier={keyIdentifier:e.subjectKeyIdentifier,authorityCertIssuer:[b.issuer],authorityCertSerialNumber:b.serialNumber});d.cRLNumber=d.cRLNumber||0;return k.importKey("pkcs8",a.encode(),a.privateKeyAlgorithm,!1,["sign"])}).then(function(a){return k.sign(c.signatureAlgorithm, -a,c.tbsCertList.encode())}).then(function(a){c.signatureValue=a;return c})},verify:function(a,b){var c=this,d=c.crlExtensions;return(new n(q)).then(function(){b=b||w();if(!c.thisUpdate.getTime()>b.getTime())throw Error("The CRL has not yet started");if(a){if(!x(a,C(c,d,c.thisUpdate))||!a.checkUsage("cRLSign",c.thisUpdate))throw Error("The issuer's certificate is not valid");if(!c.signatureValue||!c.signatureAlgorithm)throw Error("The has no signature");return a.verifySignature(c.tbsCertList.encode(), -c.signatureValue,c.signatureAlgorithm)}}).then(function(a){if(!a)throw Error("The CRL has invalid signature");return c})},isRevoked:function(a,b){var c=this.revokedCertificates;b=b||w();for(var d=0;d=c[d].revocationDate.getTime()&&G(c[d].userCertificate,a))return!0;return!1}});r.prototype.CRL=z;t(h.CertificationRequest,K,{generate:function(a){var b=this,c,d;(d=a?s[a]:this.getProvider()||s[l.providerName])&&(a=v(d.publicKey,{privateKey:d.privateKey}));return(new n(q)).then(function(){return k.generateKey(a, -"true",["sign","verify"])}).then(function(a){c=a.privateKey;return k.exportKey("spki",a.publicKey)}).then(function(a){b.subjectPublicKeyInfo=new h.SubjectPublicKeyInfo(a);return k.exportKey("pkcs8",c)}).then(function(a){c=new h.PrivateKeyInfo(a);return b.sign(c)}).then(function(){return c})},getProvider:function(){return E(this.subjectPublicKeyInfo.algorithm)},sign:function(a){var b=this,c=b.subjectPublicKeyInfo;return(new n(q)).then(function(){if(!c||!c.algorithm||"noSignature"===c.algorithm)throw Error("Key pair was not generated for the certificate"); -if(!a)throw Error("The private key is not defined");var d=E(c.algorithm)||s[l.providerName];b.signatureAlgorithm=d.signature;return k.importKey("pkcs8",a.encode(),a.privateKeyAlgorithm,!1,["sign"])}).then(function(a){return k.sign(b.signatureAlgorithm,a,b.requestInfo.encode())}).then(function(a){b.signatureValue=a;return b})},verify:function(){var a=this,b=a.subjectPublicKeyInfo;return(new n(q)).then(function(){return k.importKey("spki",b.encode(),b.algorithm,"false",["verify"])}).then(function(b){return k.verify(a.signatureAlgorithm, -b,a.signatureValue,a.requestInfo.encode())}).then(function(b){if(!b)throw Error("The certification request has invalid signature");return a})}});r.prototype.Request=K;t(y,L,{getCertificates:function(a){return A(this.certificates,a)},getCRLs:function(a){return I(this.certificates,a)},load:function(a){var b=new h.ContentInfo(a);a=b.certificates;for(var b=b.crls,c=0;cb?b+4294967296:b}function H(b){var c=(v=v||r.GostRandom)?new (v||r.GostRandom):$;if(c.getRandomValues)c.getRandomValues(b);else throw new C("Random generator not found");}function q(b){if(b instanceof I)return b;if(b&&b.buffer&&b.buffer instanceof -I)return 0===b.byteOffset&&b.byteLength===b.buffer.byteLength?b.buffer:(new Uint8Array(new Uint8Array(b,b.byteOffset,b.byteLength))).buffer;throw new p("CryptoOperationData required");}function s(b){return new Uint8Array(q(b))}function t(b){return new Uint8Array(s(b))}function D(b){return(b&255)<<24|(b&65280)<<8|b>>8&65280|b>>24&255}function E(b,c){for(var a=0;16>a;++a)b[a]^=c[a]}function O(b){for(var c=0;16>c;++c){for(var a=b,d=0,e=0;16>e;e++)d^=P[Q[e]][a[e]];for(e=16;0a;++a)b[a]=J[b[a]];O(b)}function aa(b){var c=new Uint8Array(160),a=new Uint8Array(16);c.set(s(b));for(b=0;4>b;b++){var d=32*(b+1);c.set(new Uint8Array(c.buffer,32*b,32),d);for(var e=1;9>e;e++){for(var f=8*b+e,g=a,h=0;15>h;h++)g[h]=0;g[15]=f;O(g);var f=new Uint8Array(c.buffer,d,16),g=new Uint8Array(c.buffer,d+16,16),h=a,l=new Uint8Array(f);R(f,h);E(f,g);g.set(l)}}return c}function ba(b,c,a,d){a=a||c.byteOffset;c=new Uint8Array(c.buffer,a,16);if(d){for(d=0;9>d;d++){a= -c;var e=new Uint8Array(b.buffer,16*(9-d),16);E(a,e);for(var e=a,f=0;16>f;++f){for(var g=e,h=g[0],l=0;15>l;l++)g[l]=g[l+1];g[15]=h;for(l=h=0;16>l;l++)h^=P[Q[l]][g[l]];g[15]=h}for(e=0;16>e;++e)a[e]=ca[a[e]]}E(c,new Uint8Array(b.buffer,0,16))}else{for(d=0;9>d;d++)R(c,new Uint8Array(b.buffer,16*d,16));E(c,new Uint8Array(b.buffer,144,16))}}function K(b,c,a){a=c[0]+a&4294967295;var d=b[0+(a>>0&15)]<<0,d=d|b[16+(a>>4&15)]<<4,d=d|b[32+(a>>8&15)]<<8,d=d|b[48+(a>>12&15)]<<12,d=d|b[64+(a>>16&15)]<<16,d=d|b[80+ -(a>>20&15)]<<20,d=d|b[96+(a>>24&15)]<<24,d=d|b[112+(a>>28&15)]<<28;a=(d<<11|d>>>21)^c[1];c[1]=c[0];c[0]=a}function da(b,c,a){a=a||c.byteOffset;var d=this.sBox;c=new Int32Array(c.buffer,a,2);for(a=0;32>a;a++)K(d,c,b[a]);b=c[0];c[0]=c[1];c[1]=b}function ea(b,c,a){a=a||c.byteOffset;var d=this.sBox;c=new Int32Array(c.buffer,a,2);a=D(c[0]);c[0]=D(c[1]);c[1]=a;for(a=0;32>a;a++)K(d,c,b[a]);c[0]=D(c[0]);c[1]=D(c[1])}function fa(b,c){for(var a=new Int32Array(32),d=new Int32Array(q(b)),e=0;8>e;e++)a[e]=d[e]; -if(c){for(e=0;8>e;e++)a[e+8]=a[7-e];for(e=0;8>e;e++)a[e+16]=a[7-e]}else{for(e=0;8>e;e++)a[e+8]=a[e];for(e=0;8>e;e++)a[e+16]=a[e]}for(e=0;8>e;e++)a[e+24]=a[7-e];return a}function ga(b,c){for(var a=new Int32Array(32),d=new Int32Array(q(b)),e=0;8>e;e++)a[e]=D(d[e]);if(c){for(e=0;8>e;e++)a[e+8]=a[7-e];for(e=0;8>e;e++)a[e+16]=a[7-e]}else{for(e=0;8>e;e++)a[e+8]=a[e];for(e=0;8>e;e++)a[e+16]=a[e]}for(e=0;8>e;e++)a[e+24]=a[7-e];return a}function x(b,c){for(var a=this.pad(s(c)),d=this.blockSize,e=a.byteLength/ -d,f=this.keySchedule(b),g=0;g>3,g=c.length,h=g%f,g=(g-h)/f,l=this.keySchedule(b),k=0;k>3,g=c.length,h=g%f,g=(g-h)/f,l=this.keySchedule(b),k=0;k>3,g=new Uint8Array(f),h=c.length,l=h%f,h=(h-l)/f,k=this.keySchedule(b),m=0;mm?m:m-4294967295);for(m=0;mm?m:m-4294967295),this.process(h,l),k=0;k>3,f=c.length,g=f%e,f=(f-g)/e,h=new Uint8Array(d),l=new Int32Array(d);b=this.keySchedule(b);h.set(a||this.iv);for(a=0;al;l++)K(f,g,b[l])}} -function V(b){for(var c=0,a=b.length,d=a-1;0<=d;--d){var e=b[d]>>>7;b[d]=b[d]<<1&255|c;c=e}0!==c&&(16===a?b[15]^=135:b[7]^=27)}function ma(b,c,a){var d=this.blockSize,e=s(a),f=new Uint8Array(d);this.process(b,f);V(f);0!==a.byteLength%d&&(e=W.call(this,s(a)),V(f));a=0;for(var g=e.length/d;a>3)||this.blockSize>> -1;this.processMAC(b,a,c);c=new Uint8Array(d);c.set(new Uint8Array(a.buffer,0,d));return c.buffer}function A(b,c,a,d){b=new Uint8Array(z.call(this,b,a,d));c=s(c);if(b.length!==c.length)return!1;a=0;for(d=b.length;a>1);if(!this.ukm)throw new p("UKM must be defined");var e=new Uint8Array(this.ukm),e=z.call(this,b,c,e),f=x.call(this,b,c),d=new Uint8Array(d);d.set(new Uint8Array(f),0);d.set(new Uint8Array(e), -a);return d.buffer}function oa(b,c){var a=this.blockSize,d=this.keySize,e=d+(a>>1),f=q(c);if(f.byteLength!==e)throw new p("Wrapping key size must be "+e+" bytes");if(!this.ukm)throw new p("UKM must be defined");var e=new Uint8Array(this.ukm),g=new Uint8Array(f,0,d),a=new Uint8Array(f,d,a>>1),d=F.call(this,b,g);if(!A.call(this,b,a,d,e))throw new p("Error verify MAC of wrapping key");return d}function X(b,c){for(var a=this.blockSize,d=new Int32Array(q(b)),e=[],f=0;fg;g++)e[f][g]= -c[f]>>>g&1}for(f=0;fg;g++)e[f][g]?h[0]=h[0]+d[g]&4294967295:h[1]=h[1]+d[g]&4294967295;g=new Uint8Array(h.buffer);d=new Int32Array(S.call(this,d,d,g))}return d}function pa(b,c){var a=this.keySize,d=a+(this.blockSize>>1);if(!this.ukm)throw new p("UKM must be defined");var e=new Uint8Array(this.ukm),f=X.call(this,b,e),e=z.call(this,f,c,e),f=x.call(this,f,c),d=new Uint8Array(d);d.set(new Uint8Array(f),0);d.set(new Uint8Array(e),a);return d.buffer}function qa(b, -c){var a=this.blockSize,d=this.keySize,e=d+(a>>1),f=q(c);if(f.byteLength!==e)throw new p("Wrapping key size must be "+e+" bytes");if(!this.ukm)throw new p("UKM must be defined");var e=new Uint8Array(this.ukm),g=new Uint8Array(f,0,d),a=new Uint8Array(f,d,a>>1),d=X.call(this,b,e),g=F.call(this,d,g);if(!A.call(this,d,a,g,e))throw new p("Error verify MAC of wrapping key");return g}function Y(b){var c=this.blockSize>>1,a=this.keySize,d=q(b);if(34!==(new Uint8Array(d,0,1))[0])throw new p("Invalid magic number"); -var e=(new Uint8Array(d,1,1))[0];b=new Uint8Array(d,2,c);for(var f=new Uint8Array(a),g=0;g>1,d=this.keySize,e=q(b),f=q(c);e.byteLength!==d&&(e=Y.call(this,e));var g=x.call(this,e,f),e= -z.call(this,e,f),a=new Uint8Array(a+d);a.set(new Uint8Array(g),0);a.set(new Uint8Array(e),d);return a.buffer}function sa(b,c){var a=this.blockSize>>1,d=this.keySize,e=q(b),f=q(c);e.byteLength!==d&&(e=Y.call(this,e));var g=new Uint8Array(f,0,d),a=new Uint8Array(f,d,a),g=F.call(this,e,g);if(!A.call(this,e,a,g))throw new p("Invalid key MAC");return g}function ta(){var b=y.call(this),c=void 0,a=this.blockSize>>1,d=this.keySize,e=8,b=new Uint8Array(q(b));if(b.byteLength!==d)throw new p("Wrong cleartext size "+ -b.byteLength+" bytes");if(c=c||this.ukm)if(c=new Uint8Array(q(c)),0this.blockSize)throw p("Invalid padding");a=new Uint8Array(c);0a;a++){c[a]=[];for(var d=0;256>d;d++){for(var e=c[a],f=d,g=b[a],h=d,l=0,k=void 0,m=void 0,k=0;8>k;k++)h&1&&(l^=g),m=g&128,g=g<<1&255,m&&(g^=195),h>>=1;e[f]=l&255}}return c}(),Q=[4,2,3,1,6,5,0,7,0,5,6,1,3,2,4,0],J=[252,238,221,17,207,110,49,22,251,196,250,218,35,197,4,77,233,119,240,219,147,46,153,186,23,54,241,187,20,205,95,193,249,24,101,90,226,92,239,33,129,28,60,66,139,1,142,79,5,132,2,174,227,106,143,160,6,11,237,152,127,212,211,31,235,52,44,81,234,200, -72,171,242,42,104,162,253,58,206,204,181,112,14,86,8,12,118,18,191,114,19,71,156,183,93,135,21,161,150,41,16,123,154,199,243,145,120,111,157,158,178,177,50,117,25,61,255,53,138,126,109,84,198,128,195,189,13,87,223,245,36,169,62,168,67,201,215,121,214,246,124,34,185,3,224,15,236,222,122,148,176,188,220,232,40,80,78,51,10,74,167,151,96,115,30,0,98,68,26,184,56,130,100,159,38,65,173,69,70,146,39,94,85,47,140,163,165,125,105,213,149,59,7,88,179,64,134,172,29,247,48,55,107,228,136,217,231,137,225,27,131, -73,76,63,248,254,141,83,170,144,202,216,133,97,32,113,103,164,45,43,9,91,203,155,37,208,190,229,108,82,89,166,116,210,230,244,180,192,209,102,175,194,57,75,99,182],ca=function(){for(var b=[],c=0,a=J.length;ch;h++)f[h]=b[(f[h-1]+f[h-a])%256];f[128-e]=b[f[128-e]&d];for(h=127-e;0<=h;--h)f[h]=b[f[h+1]^ -f[h+e]];return g}}(),Ga=function(){function b(a){if(h){var b=f[a],c=g[a];f[a]=(b>>>c|b<<16-c)&65535;f[a]=f[a]-d[e]-(f[(a+3)%4]&f[(a+2)%4])-(~f[(a+3)%4]&f[(a+1)%4]);--e}else f[a]=f[a]+d[e]+(f[(a+3)%4]&f[(a+2)%4])+(~f[(a+3)%4]&f[(a+1)%4]),e+=1,b=f[a],c=g[a],f[a]=(b<>>16-c)&65535}function c(a){f[a]=h?f[a]-d[f[(a+3)%4]&63]:f[a]+d[f[(a+3)%4]&63]}function a(a,b){b=b||1;for(var c=0;cd;d++)a(d)}var d,e,f=new Uint16Array(4),g=new Uint16Array([1,2,3, -5]),h;return function(g,k,m,n){h=n;f=new Uint16Array(k.buffer,m||k.byteOffset,4);d=g;e=n?63:0;a(b,5);a(c);a(b,6);a(c);a(b,5)}}();return function(b){if(!Ca)throw new C("Big endian platform not supported");b=b||{};this.keySize=32;this.blockLength=b.length||64;this.blockSize=this.blockLength>>3;this.name=(b.name||(1===b.version?"RC2":1989===b.version?"GOST 28147":"GOST R 34.12"))+(4>1):"KW"===b.mode||b.keyWrapping?("NO"!==(b.keyWrapping||"NO")?b.keyWrapping:"")+"KW":(b.block||"ECB")+(("CFB"===b.block||"OFB"===b.block||"CTR"===b.block&&2015===b.version)&&b.shiftBits&&b.shiftBits!==this.blockLength?"-"+b.shiftBits:"")+(b.padding?"-"+(b.padding||("CTR"===b.block||"CFB"===b.block||"OFB"===b.block?"NO":"ZERO"))+"PADDING":"")+("NO"!==(b.keyMeshing||"NO")?"-CPKEYMESHING":""))+(b.procreator?"/"+b.procreator:"")+("string"===typeof b.sBox?"/"+b.sBox:"");this.procreator= -b.procreator;switch(b.version||1989){case 1:this.process=Ga;this.keySchedule=Fa;this.blockLength=64;this.effectiveLength=b.length||32;this.keySize=8*Math.ceil(this.effectiveLength/8);this.blockSize=this.blockLength>>3;break;case 2015:this.version=2015;if(64===this.blockLength)this.process=ea,this.keySchedule=ga;else if(128===this.blockLength)this.process=ba,this.keySchedule=aa;else throw new p("Invalid block length");this.processMAC=ma;break;case 1989:this.version=1989;this.process=da;this.processMAC= -la;this.keySchedule=fa;if(64!==this.blockLength)throw new p("Invalid block length");break;default:throw new C("Algorithm version "+b.version+" not supported");}switch(b.mode||b.keyWrapping&&"KW"||"ES"){case "ES":switch(b.block||"ECB"){case "ECB":this.encrypt=x;this.decrypt=F;break;case "CTR":1989===this.version?this.decrypt=this.encrypt=ja:(this.decrypt=this.encrypt=L,this.shiftBits=b.shiftBits||this.blockLength);break;case "CBC":this.encrypt=T;this.decrypt=ka;break;case "CFB":this.encrypt=S;this.decrypt= -ha;this.shiftBits=b.shiftBits||this.blockLength;break;case "OFB":this.decrypt=this.encrypt=ia;this.shiftBits=b.shiftBits||this.blockLength;break;default:throw new C("Block mode "+b.block+" not supported");}switch(b.keyMeshing){case "CP":this.keyMeshing=wa;break;default:this.keyMeshing=M}if(this.encrypt===x||this.encrypt===T)switch(b.padding){case "PKCS5P":this.pad=ya;this.unpad=za;break;case "RANDOM":this.pad=Ba;this.unpad=G;break;case "BIT":this.pad=W;this.unpad=Aa;break;default:this.pad=U,this.unpad= -G}else this.unpad=this.pad=G;this.generateKey=y;break;case "MAC":this.sign=z;this.verify=A;this.generateKey=y;this.macLength=b.macLength||this.blockLength>>1;this.unpad=this.pad=G;this.keyMeshing=M;break;case "KW":this.unpad=this.pad=G;this.keyMeshing=M;switch(b.keyWrapping){case "CP":this.wrapKey=pa;this.unwrapKey=qa;this.generateKey=y;this.shiftBits=b.shiftBits||this.blockLength;break;case "SC":this.wrapKey=ra;this.unwrapKey=sa;this.generateKey=ta;break;default:this.wrapKey=na,this.unwrapKey=oa, -this.generateKey=y}break;case "MASK":this.wrapKey=ua;this.unwrapKey=va;this.generateKey=y;break;default:throw new C("Mode "+b.mode+" not supported");}var c=b.sBox;if(!c)c=2015===this.version?u["E-Z"]:"SC"===this.procreator?u["E-SC"]:u["E-A"];else if("string"===typeof c){if(c=c.toUpperCase(),c=u[c],!c)throw new B("Unknown sBox name: "+b.sBox);}else if(!c.length||c.length!==u["E-Z"].length)throw new B("Length of sBox must be "+u["E-Z"].length);this.sBox=c;if(b.iv){this.iv=new Uint8Array(b.iv);if(this.iv.byteLength!== -this.blockSize&&1989===this.version)throw new B("Length of iv must be "+this.blockLength+" bits");if(this.iv.byteLength!==this.blockSize>>1&&this.encrypt===L)throw new B("Length of iv must be "+this.blockLength>>NaN);if(0!==this.iv.byteLength%this.blockSize&&this.encrypt!==L)throw new B("Length of iv must be a multiple of "+this.blockLength+" bits");}else this.iv=128===this.blockLength?Ea:Da;if(b.ukm&&(this.ukm=new Uint8Array(b.ukm),8*this.ukm.byteLength!==this.blockLength))throw new B("Length of ukm must be "+ -this.blockLength+" bits");}}); diff --git a/min/gostCoding.min.js b/min/gostCoding.min.js deleted file mode 100644 index f02aac6..0000000 --- a/min/gostCoding.min.js +++ /dev/null @@ -1,29 +0,0 @@ -/* - 2014-2016, Rudolf Nickolaev. All rights reserved. -*/ -(function(A,t){"function"===typeof define&&define.amd?define(["gostCrypto"],t):"object"===typeof exports?module.exports=t(require("gostCrypto")):A.GostCoding=t(A.gostCrypto)})(this,function(A){function t(e){if(e instanceof y)return e;if(e&&e.buffer&&e.buffer instanceof y)return 0===e.byteOffset&&e.byteLength===e.buffer.byteLength?e.buffer:(new Uint8Array(new Uint8Array(e,e.byteOffset,e.byteLength))).buffer;throw new u("CryptoOperationData required");}function s(){}var u=this.DataError||this.Error, -y=this.ArrayBuffer,B=this.Date,C={decode:function(e){e=e.replace(/[^A-Za-z0-9\+\/]/g,"");for(var l=e.length,c=3*l+1>>2,p=new Uint8Array(c),d,a=0,r=0,g=0;gh?h-65:96h?h-71:47h?h+4:43===h?62:47===h?63:0,a=a|h<<18-6*d;if(3===d||1===l-g){for(d=0;3>d&&r>>(16>>>d&24)&255;a=0}}return p.buffer},encode:function(e){e=new Uint8Array(t(e));for(var l=2,c="",p=e.length,d=0,a=0;a>>l&24),2===l||1===p-a){for(var r=18;0<=r;r-=6)var g=d>>>r&63,g=26>g?g+65:52>g?g+71:62>g?g-4:62===g?43:63===g?47:65,c=c+String.fromCharCode(g);d=0}return c.substr(0,c.length-2+l)+(2===l?"":1===l?"=":"==")}};s.prototype.Base64=C;var w=function(){var e={1026:128,1027:129,8218:130,1107:131,8222:132,8230:133,8224:134,8225:135,8364:136,8240:137,1033:138,8249:139,1034:140,1036:141,1035:142,1039:143,1106:144,8216:145,8217:146,8220:147,8221:148,8226:149,8211:150,8212:151,8482:153,1113:154,8250:155,1114:156, -1116:157,1115:158,1119:159,160:160,1038:161,1118:162,1032:163,164:164,1168:165,166:166,167:167,1025:168,169:169,1028:170,171:171,172:172,173:173,174:174,1031:175,176:176,177:177,1030:178,1110:179,1169:180,181:181,182:182,183:183,1105:184,8470:185,1108:186,187:187,1112:188,1029:189,1109:190,1111:191},l={},c;for(c in e)l[e[c]]=c;return{decode:function(c,d){d=(d||"win1251").toLowerCase().replace("-","");for(var a=[],r=0,g=c.length;rh?a.push(h):(2048>h? -a.push(192+(h>>>6)):(65536>h?a.push(224+(h>>>12)):(2097152>h?a.push(240+(h>>>18)):(67108864>h?a.push(248+(h>>>24)):(a.push(252+(h>>>30)),a.push(128+(h>>>24&63))),a.push(128+(h>>>18&63))),a.push(128+(h>>>12&63))),a.push(128+(h>>>6&63))),a.push(128+(h&63)));else if("unicode"===d||"ucs2"===d||"utf16"===d)if(55296>h||57344<=h&&65536>=h)a.push(h>>>8),a.push(h&255);else{if(65536<=h&&1114112>h){var h=h-65536,b=((1047552&h)>>10)+55296,h=(1023&h)+56320;a.push(b>>>8);a.push(b&255);a.push(h>>>8);a.push(h&255)}}else"utf32"=== -d||"ucs4"===d?(a.push(h>>>24&255),a.push(h>>>16&255),a.push(h>>>8&255),a.push(h&255)):"win1251"===d?(128<=h&&(h=1040<=h&&1104>h?h-848:e[h]||0),a.push(h)):a.push(h&255)}return(new Uint8Array(a)).buffer},encode:function(e,d){d=(d||"win1251").toLowerCase().replace("-","");for(var a=[],c=new Uint8Array(t(e)),g=0,h=c.length;gb&&g+5>248&&252>b&&g+4>240&&248>b&&g+3b&&g+2b&&g+1b)var n=b-55296<<10,b=c[++g],b=(b<<8)+c[++g],b=n+(b-56320)+65536}else"utf32"===d||"ucs4"===d?(b=(b<<8)+c[++g],b=(b<<8)+c[++g],b=(b<<8)+c[++g]):"win1251"===d&&128<=b&&(b=192<= -b&&256>b?b+848:l[b]||0);a.push(String.fromCharCode(b))}return a.join("")}}}();s.prototype.Chars=w;var F={decode:function(e,l){e=e.replace(/[^A-fa-f0-9]/g,"");var c=Math.ceil(e.length/2),p=new Uint8Array(c);e=(0l.toLowerCase().indexOf("little")))for(var d=0;dl.toLowerCase().indexOf("little")))for(var a=0;an;n++)var z=8*m+n,k=(k<<1)+(z>>=7;while(f);for(n=k.length-1;0<=n;--n)b.push(k[n]+(0===n?0:128))}b=new Uint8Array(b);break;case 12:b=w.decode(a,"utf8");break;case 18:case 22:case 19:case 20:case 21:case 25:case 26:case 27:m=0;for(f=a.length;mg)d.push(l|g&31);else{l|=31;d.push(l);f=g;g=[];do g.push(f&127),f>>>=7;while(f);for(n=g.length-1;0<=n;--n)d.push(g[n]+(0===n?0:128))}if(h&&"CER"===p)d.push(128);else if(p=b.length,127>>=8;while(h);d.push(p.length+128);for(n=p.length-1;0<=n;--n)d.push(p[n])}else d.push(p);c=c.header=new Uint8Array(d);p=new Uint8Array(c.length+b.length);p.set(c,0);p.set(b,c.length); -return p}function l(c,e){var d=e||0,a=d,r,g,h,b,n,k,q;if(c.object)r=c.tagNumber,g=c.tagClass,h=c.tagConstructed,d=c.content,b=c.header,n=c.object instanceof y?new Uint8Array(c.object):null,k=c.object instanceof Array?c.object:null,q=n&&n.length||null;else{b=c[d++];r=b&31;g=b>>6;h=0!==(b&32);if(31===r){r=0;do{if(9007199254740864s;++s)f.push(q>>s&1?"1":"0");a=0}f= -f.reverse().join("")}break;case 4:f=(new Uint8Array(n)).buffer;break;case 6:f="";for(m=v=x=0;mx?40>x?0:1:2,f=k+"."+(x-40*k)):f+="."+x.toString(),v=x=0);if(0k[1]?2E3:1900);q=new B(k[1],+k[2]-1,+k[3],+(k[4]||0),+(k[5]||0),+(k[6]||0),+(k[7]|| -0));a=q.getTimezoneOffset();if(k[8]||23===r)"Z"!==k[8].toUpperCase()&&k[9]&&(a+=parseInt(k[9])),q.setMinutes(q.getMinutes()-a);q.original=f;f=q}else f=(new Uint8Array(n)).buffer}else f=k;return{tagConstructed:h,tagClass:g,tagNumber:r,header:b,content:d,object:f}}return{encode:function(c,l,d){return e(c,l,d).buffer},decode:function(c){return l(c.object?c:new Uint8Array(t(c)),0)}}}();s.prototype.BER=E;s.prototype.PEM={encode:function(e,l){return(l?"-----BEGIN "+l.toUpperCase()+"-----\r\n":"")+C.encode(e instanceof -y?e:E.encode(e))+(l?"\r\n-----END "+l.toUpperCase()+"-----":"")},decode:function(e,l,c,p){var d=/([A-Za-z0-9\+\/\s\=]+)/g.exec(e);d[1].length!==e.length&&(d=!1);!d&&l&&(d=(new RegExp("-----\\s?BEGIN "+l.toUpperCase()+"-----([A-Za-z0-9\\+\\/\\s\\=]+)-----\\s?END "+l.toUpperCase()+"-----","g")).exec(e));d||(d=/-----\s?BEGIN [A-Z0-9\s]+-----([A-Za-z0-9\+\/\s\=]+)-----\s?END [A-Z0-9\s]+-----/g.exec(e));e=d&&d[1+(p||0)];if(!e)throw new u("Not valid PEM format");e=C.decode(e);c&&(e=E.decode(e));return e}}; -A&&(A.coding=new s);return s}); diff --git a/min/gostCrypto.min.js b/min/gostCrypto.min.js deleted file mode 100644 index 222d500..0000000 --- a/min/gostCrypto.min.js +++ /dev/null @@ -1,38 +0,0 @@ -/* - 2014-2016, Rudolf Nickolaev. All rights reserved. -*/ -(function(y,g){"function"===typeof define&&define.amd?define(["gostRandom"],g):"object"===typeof exports?module.exports=g(require("gostRandom")):y.gostCrypto=g(y.GostRandom)})(this,function(y){function g(a,c){if("string"===typeof a||a instanceof String)a={name:a};var d=a.name;if(!d)throw new v("Algorithm name not defined");var e=d.split("/"),e=e[0].split("-").concat(e.slice(1)),b={},d=e[0].replace(/[\.\s]/g,""),e=e.slice(1);if(0<=d.indexOf("28147"))b={name:"GOST 28147",version:1989,mode:(a.mode|| -("sign"===c||"verify"===c?"MAC":"wrapKey"===c||"unwrapKey"===c?"KW":"ES")).toUpperCase(),length:a.length||64};else if(0<=d.indexOf("3412"))b={name:"GOST R 34.12",version:2015,mode:(a.mode||("sign"===c||"verify"===c?"MAC":"wrapKey"===c||"unwrapKey"===c?"KW":"ES")).toUpperCase(),length:a.length||64};else if(0<=d.indexOf("3411"))b={name:"GOST R 34.11",version:2012,mode:(a.mode||("deriveKey"===c||"deriveBits"===c?"KDF":"sign"===c||"verify"===c?"HMAC":"HASH")).toUpperCase(),length:a.length||256};else if(0<= -d.indexOf("3410"))b={name:"GOST R 34.10",version:2012,mode:(a.mode||("deriveKey"===c||"deriveBits"===c?"DH":"SIGN")).toUpperCase(),length:a.length||256};else if(0<=d.indexOf("SHA"))b={name:"SHA",version:160===(a.length||160)?1:2,mode:(a.mode||("deriveKey"===c||"deriveBits"===c?"KDF":"sign"===c||"verify"===c?"HMAC":"HASH")).toUpperCase(),length:a.length||160};else if(0<=d.indexOf("RC2"))b={name:"RC2",version:1,mode:(a.mode||("sign"===c||"verify"===c?"MAC":"wrapKey"===c||"unwrapKey"===c?"KW":"ES")).toUpperCase(), -length:a.length||32};else if(0<=d.indexOf("PBKDF2"))b=g(a.hash,"digest"),b.mode="PBKDF2";else if(0<=d.indexOf("PFXKDF"))b=g(a.hash,"digest"),b.mode="PFXKDF";else if(0<=d.indexOf("CPKDF"))b=g(a.hash,"digest"),b.mode="CPKDF";else if(0<=d.indexOf("HMAC"))b=g(a.hash,"digest"),b.mode="HMAC";else throw new s("Algorithm not supported");e.forEach(function(a){a=a.toUpperCase();if(/^[0-9]+$/.test(a))if(0<=["8","16","32"].indexOf(a)||"128"===b.length&&"64"===a)if("ES"===b.mode)b.shiftBits=parseInt(a);else if("MAC"=== -b.mode)b.macLength=parseInt(a);else throw new s("Algorithm "+b.name+" mode "+a+" not supported");else 0<="89 94 01 12 15 1989 1994 2001 2012 2015".split(" ").indexOf(a)?(a=parseInt(a),b.version=1900>a?80>a?2E3+a:1900+a:a):0<=["1"].indexOf(a)&&"SHA"===b.name?(b.version=1,b.length=160):0<=["256","384","512"].indexOf(a)&&"SHA"===b.name?(b.version=2,b.length=parseInt(a)):0<=["40","128"].indexOf(a)&&"RC2"===b.name?(b.version=1,b.length=parseInt(a)):0<=["64","128","256","512"].indexOf(a)?b.length=parseInt(a): -0<=["1000","2000"].indexOf(a)&&(b.iterations=parseInt(a));else if(0<="E-TEST E-A E-B E-C E-D E-SC E-Z D-TEST D-A D-SC".split(" ").indexOf(a))b.sBox=a;else if(0<="S-TEST S-A S-B S-C S-D X-A X-B X-C".split(" ").indexOf(a))b.namedParam=a;else if(0<="S-256-TEST S-256-A S-256-B S-256-C P-256 T-512-TEST T-512-A T-512-B X-256-A X-256-B T-256-TEST T-256-A T-256-B S-256-B T-256-C S-256-C".split(" ").indexOf(a))b.namedCurve=a;else if(0<=["SC","CP","VN"].indexOf(a))b.procreator=a;else if("GOST 28147"===b.name|| -"GOST R 34.12"===b.name||"RC2"===b.name)if(0<=["ES","MAC","KW","MASK"].indexOf(a))b.mode=a;else if(0<=["ECB","CFB","OFB","CTR","CBC"].indexOf(a))b.mode="ES",b.block=a;else if(0<=["CPKW","NOKW","SCKW"].indexOf(a))b.mode="KW",b.keyWrapping=a.replace("KW","");else if(0<=["ZEROPADDING","PKCS5PADDING","NOPADDING","RANDOMPADDING","BITPADDING"].indexOf(a))b.padding=a.replace("PADDING","");else if(0<=["NOKM","CPKM"].indexOf(a))b.keyMeshing=a.replace("KM","");else throw new s("Algorithm "+b.name+" mode "+ -a+" not supported");else if("GOST R 34.11"===b.name||"SHA"===b.name)if(0<="HASH KDF HMAC PBKDF2 PFXKDF CPKDF".split(" ").indexOf(a))b.mode=a;else throw new s("Algorithm "+b.name+" mode "+a+" not supported");else if("GOST R 34.10"===b.name){var c=a.replace(/[\.\s]/g,"");if(0<=c.indexOf("GOST")&&0<=c.indexOf("3411"))b.hash=a;else if(["SIGN","DH","MASK"].indexOf(a))b.mode=a;else throw new s("Algorithm "+b.name+" mode "+a+" not supported");}});b.procreator=a.procreator||b.procreator||"CP";switch(b.name){case "GOST R 34.10":b.keySize= -b.length/(1994===b.version?4:8);break;case "GOST R 34.11":b.keySize=32;break;case "GOST 28147":case "GOST R 34.12":b.keySize=32;break;case "RC2":b.keySize=Math.ceil(b.length/8);break;case "SHA":b.keySize=b.length/8}if("ES"===b.mode&&(a.block&&(b.block=a.block),b.block&&(b.block=b.block.toUpperCase()),a.padding&&(b.padding=a.padding),b.padding&&(b.padding=b.padding.toUpperCase()),a.shiftBits&&(b.shiftBits=a.shiftBits),a.keyMeshing&&(b.keyMeshing=a.keyMeshing),b.keyMeshing&&(b.keyMeshing=b.keyMeshing.toUpperCase()), -"importKey"!==c&&"generateKey"!==c)){b.block=b.block||"ECB";b.padding=b.padding||("CBC"===b.block||"ECB"===b.block?"ZERO":"NO");if("CFB"===b.block||"OFB"===b.block)b.shiftBits=b.shiftBits||b.length;b.keyMeshing=b.keyMeshing||"NO"}"KW"===b.mode&&(a.keyWrapping&&(b.keyWrapping=a.keyWrapping),b.keyWrapping&&(b.keyWrapping=b.keyWrapping.toUpperCase()),"importKey"!==c&&"generateKey"!==c&&(b.keyWrapping=b.keyWrapping||"NO"));"sBox namedParam namedCurve curve param modulusLength".split(" ").forEach(function(c){a[c]&& -(b[c]=a[c])});"importKey"!==c&&"generateKey"!==c&&("GOST 28147"===b.name?b.sBox=b.sBox||("SC"===b.procreator?"E-SC":"E-A"):"GOST R 34.12"===b.name&&64===b.length?b.sBox="E-Z":"GOST R 34.11"===b.name&&1994===b.version?b.sBox=b.sBox||("SC"===b.procreator?"D-SC":"D-A"):"GOST R 34.10"===b.name&&1994===b.version?b.namedParam=b.namedParam||("DH"===b.mode?"X-A":"S-A"):"GOST R 34.10"===b.name&&2001===b.version?b.namedCurve=b.namedCurve||(256===b.length?"SC"===b.procreator?"P-256":"DH"===b.mode?"X-256-A": -"S-256-A":"T-512-A"===b.mode):"GOST R 34.10"===b.name&&2012===b.version&&(b.namedCurve=b.namedCurve||(256===b.length?"SC"===b.procreator?"P-256":"DH"===b.mode?"X-256-A":"S-256-A":"T-512-A"===b.mode)));switch(b.mode){case "DH":a.ukm&&(b.ukm=a.ukm);a["public"]&&(b["public"]=a["public"]);break;case "SIGN":case "KW":a.ukm&&(b.ukm=a.ukm);break;case "ES":case "MAC":a.iv&&(b.iv=a.iv);break;case "KDF":a.label&&(b.label=a.label);a.contex&&(b.context=a.contex);break;case "PBKDF2":a.salt&&(b.salt=a.salt);a.iterations&& -(b.iterations=a.iterations);a.diversifier&&(b.diversifier=a.diversifier);break;case "PFXKDF":a.salt&&(b.salt=a.salt);a.iterations&&(b.iterations=a.iterations);a.diversifier&&(b.diversifier=a.diversifier);break;case "CPKDF":a.salt&&(b.salt=a.salt),a.iterations&&(b.iterations=a.iterations)}if(c&&("ES"!==b.mode&&"SIGN"!==b.mode&&"MAC"!==b.mode&&"HMAC"!==b.mode&&"KW"!==b.mode&&"DH"!==b.mode&&"MASK"!==b.mode&&"generateKey"===c||"ES"!==b.mode&&("encrypt"===c||"decrypt"===c)||"SIGN"!==b.mode&&"MAC"!==b.mode&& -"HMAC"!==b.mode&&("sign"===c||"verify"===c)||"HASH"!==b.mode&&"digest"===c||"KW"!==b.mode&&"MASK"!==b.mode&&("wrapKey"===c||"unwrapKey"===c)||"DH"!==b.mode&&"PBKDF2"!==b.mode&&"PFXKDF"!==b.mode&&"CPKDF"!==b.mode&&"KDF"!==b.mode&&("deriveKey"===c||"deriveBits"===c)))throw new s("Algorithm mode "+b.mode+" not valid for method "+c);a.hash&&(b.hash=a.hash);b.hash&&(("string"===typeof b.hash||b.hash instanceof String)&&b.procreator&&(b.hash=b.hash+"/"+b.procreator),b.hash=g(b.hash,"digest"));a.id&&(b.id= -a.id);return b}function q(a){if(!k||!k.subtle||!a)return!1;var c="string"===typeof a||a instanceof String?c=a:a.name;if(!c)return!1;c=c.toUpperCase();return(0<=c.indexOf("KDF")||0<=c.indexOf("HMAC"))&&a.hash?q(a.hash):-1===c.indexOf("GOST")&&-1===c.indexOf("SHA-1")&&-1===c.indexOf("RC2")&&-1===c.indexOf("?DES")}function F(a,c){if(!a.algorithm)throw new v("Key algorithm not defined");if(!a.algorithm.name)throw new v("Key algorithm name not defined");var d=a.algorithm.name,e="GOST 28147"===d||"GOST R 34.12"=== -d||"RC2"===d,b="GOST R 34.11"===d||"SHA"===d,h="GOST R 34.10"===d;if(!e&&!h&&!b)throw new s("Key algorithm "+d+" is unsupproted");if(!a.type)throw new v("Key type not defined");if((e||b)&&"secret"!==a.type||h&&"public"!==a.type&&"private"!==a.type)throw new B("Key type "+a.type+" is not valid for algorithm "+d);if(!a.usages||!a.usages.indexOf)throw new v("Key usages not defined");d=0;for(e=a.usages.length;dr.usages.indexOf(b[f]))throw B("Key usage not valid for this key");}else b=r.usages;r=r.buffer;var p=d.keySize,l=r.byteLength;if("public"===h||p===l)return r;if(0>2,d=new Uint8Array(f),k,r=0,l=0,s=0;s< -m;s++){k=s&3;var e=a.charCodeAt(s),e=64e?e-65:96e?e-71:47e?e+4:43===e?62:47===e?63:0,r=r|e<<18-6*k;if(3===k||1===m-s){for(k=0;3>k&&l>>(16>>>k&24)&255;r=0}}return d.buffer}function w(a){if(a instanceof ArrayBuffer)return a;if(a&&a.buffer&&a.buffer instanceof ArrayBuffer)return 0===a.byteOffset&&a.byteLength===a.buffer.byteLength?a.buffer:(new Uint8Array(new Uint8Array(a,a.byteOffset,a.byteLength))).buffer;throw new B("ArrayBuffer or ArrayBufferView required"); -}function C(a,m){var f=this.digest===D?32:64,d=this.bitLength/8,k=w(a),r=w(m),l;k.byteLength===f?l=new Uint8Array(k):(l=new Uint8Array(f),k.byteLength>f?l.set(new Uint8Array(this.digest(k))):l.set(new Uint8Array(k)));for(var k=new Uint8Array(f+r.byteLength),d=new Uint8Array(f+d),s=0;s>>8,b[d*c+u]=v&255}f=new Uint8Array(k);q(h,0,f,0,k);return f.buffer}function M(a,m){if(0>>8;g[g.length-1]=m&255; -s.set(new Uint8Array(C.call(this,a,g),0,e>>24&255;g[e+1]=h>>>16&255;g[e+2]=h>>>8&255;g[e+3]=h&255;for(var c=new Uint8Array(C.call(this,l,g)),p=c,n=1;nthis.bitLength||0n;n++)h[n]="DENEFH028.760246785.IUEFHWUIO.EF".charCodeAt(n);for(var g=new Uint8Array(2*(f+d)),x=0;xe;e++)c=(b[e]&65535)+(a[e]&65535)+(c||0),h=(b[e]>>>16)+(a[e]>>>16)+(c>>> -16),b[e]=c&65535|h<<16,c=h>>>16}function m(b,c){for(var a=0;16>a;a++)b[a]=c[a]}function f(b,a){for(var c=0;16>c;c++)b[c]^=a[c]}function d(b,a){m(c,b);f(c,a);for(var h=0;8>h;h++){var d,g,l=(c[h>>2]>>((h&3)<<3)&255)<<1;d=e[l];g=e[l+1];for(var p=1;8>p;p++)l=(p<<3)+h,l=(p<<9)+((c[l>>2]>>((l&3)<<3)&255)<<1),d^=e[l],g^=e[l+1];b[h<<1]=d;b[(h<<1)+1]=g}}function k(b,c,a){m(p,b);d(p,c);m(n,p);d(p,a);for(c=0;11>c;c++)d(n,s[c]),d(p,n);d(n,s[11]);f(p,n);f(b,p);f(b,a)}var r=new Int32Array(16),l=new Int32Array(16); -l[0]=512;var s=function(b){b=new Int32Array(I(b));for(var c=Array(12),a=0;12>a;a++)c[a]=new Int32Array(b.buffer,64*a,16);return c}("B0Wm8lllgN0jTXTMNnR2BRXTYKQIKkKiAWlnkpHgfEv8xIV1jbhOcRbQRS5DdmovH3xlwIEvy+vp2soe2lsIsbebsSFwBHnmVs3L1xui3VXKpwrbwmG1XFiZ1hJrF7WaMQG1Fg9e1WGYKyMKcur+89e1cA9GneNPGi+dqYq1o2+yCroK9ZYemTHbeoZD9LbCCdtiYDc6ycGxnjWQ5A/i03t7KbEUderyix+cUl9e8QY1hD1qKPw5Cscvzius3HT1LtHjhLy+DCLxN+iToepTNL4DUpMzE7fYddYD7YIs16k/NV5orRxynX08XDN+hY5I3eRxXaDhSPnSZhXos98f71f+bHz9WBdg9WPqqX6iVnoWGicjtwD/36P1OiVHF82/vf8PgNc1njVKEIYWHxwVf2MjqWwMQT+amUdHraxr6ktufWRGekBo+jVPkDZyxXG/tsa+wmYf8gq0t5oct6b6z8aO8Jq0mn8YbKRCUfnEZi3AOTB6O8Okb9nTOh2urk+uk9QUOk1WhojzSjyiTEUXNQQFSiiDaUcGNyyCLcWrkgnJk3oZMz5H08mHv+bHxp45VAkkv/6GrFHsxaruFg7H9B7nAr/UDX+k2ahRWTXCrDYvxKXRK43RaZAGm5LLK4n0msTbTTtEtIke3jaccfi3TkFBbgwCqucDp8mTTUJbH5vbWiODUURhcmAqH8uS3DgOVJwHppqKK3uxzrLbC0QKgIQJDeC3Vdk8JEKJJRs6fTreXxbs2JpMlJsiMRZUWo837ZxFmPvHtHTDtjsV0fqYNvRSdjswbB56SzNprwJn558DYTMbiuH/H9t4iv8c50GJ8/PkskjlKjhSbwWApt6+qxst84HNpMprXdhvwEpZot6Ybkd9Hc2678q5SOrvcR2KeWaEFCGAASBhB6vru2v62JT+WmPNxgIw+4nI79CezXsg1xvxSpK8SJkbstnVF/T6UijhiKqkHeeGzJEYne+AXZufITDUEiD4dx3fvDI8pM16sUkEsIAT0roxFvFn5443"), -e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g/koJRcCmsAWNVV6cOp8lpRVGDHQSOZWgmBNS6ChH2UfiIKrdJ133JbvZ5PYrvJ5n1KwQtzUju8LB6hzDJIvGi7Q1Uc5JhQvHTL9CXx0pnTShq8OLhgP18yXSMvtJxfnBnr09JmpOCkKns0duziOOykzRN0XInNBWMJQ+j1g")), -g,b,h,c=new Int32Array(16),p=new Int32Array(16),n=new Int32Array(16);return function(c){g=new Int32Array(16);b=new Int32Array(16);h=new Int32Array(16);for(var e=0;16>e;e++)256===this.bitLength&&(h[e]=16843009);c=new Uint8Array(w(c));for(var e=c.length,d=e%64,f=(e-d)/64,e=0;ee;e++)c[e]=h[8+e];else for(c=new Int32Array(16),e=0;16>e;e++)c[e]=h[e];return"SC"===this.procreator||"VN"===this.procreator?H(c.buffer):c.buffer}}(),D=function(){function a(b){for(var e=new Uint8Array(32),c=0;8>c;c++)e[4*c]=b[c],e[1+4*c]=b[8+c],e[2+4*c]=b[16+c],e[3+4*c]=b[24+c];return e}function m(b){for(var e= -new Uint8Array(8),c=0;8>c;c++)e[c]=b[c]^b[c+8];q(b,8,b,0,24);q(e,0,b,24,8);return b}function f(b){b=new Uint16Array(b.buffer,0,16);var e=b[0]^b[1]^b[2]^b[3]^b[12]^b[15];q(b,1,b,0,15);b[15]=e}function d(b,e){var c=new Uint8Array(32),d=new Uint8Array(32),g=new Uint8Array(32),k=new Uint8Array(32);q(b,e,s,0,32);q(l,0,d,0,32);q(s,0,g,0,32);for(var t=0;32>t;t++)k[t]=d[t]^g[t];var v=a(k),t=l,u=new Uint8Array(8);q(t,0,u,0,8);v=new Uint8Array(this.cipher.encrypt(v,u));q(v,0,c,0,8);for(v=1;4>v;v++){u=m(d); -for(t=0;32>t;t++)d[t]=u[t]^r[v][t];g=m(m(g));for(t=0;32>t;t++)k[t]=d[t]^g[t];var w=a(k),t=c,u=8*v,y=l,A=8*v,z=new Uint8Array(8);q(y,A,z,0,8);w=new Uint8Array(this.cipher.encrypt(w,z));q(w,0,t,u,8)}for(d=0;12>d;d++)f(c);for(d=0;32>d;d++)c[d]^=s[d];f(c);for(d=0;32>d;d++)c[d]^=l[d];for(d=0;61>d;d++)f(c);q(c,0,l,0,l.length)}function k(b){for(var d=0,c=0;c>>=8}var r,l,s,e,g=new Uint8Array([0,255,0,255,0,255,0,255,255,0,255,0,255,0,255,0,0,255,255,0,255, -0,0,255,255,0,0,0,255,255,0,255]);return function(b){l=new Uint8Array(32);s=new Uint8Array(32);e=new Uint8Array(32);r=Array(4);for(var a=0;4>a;a++)r[a]=new Uint8Array(32);q(g,0,r[2],0,g.length);var c=new Uint8Array(w(b));b=c.length;for(var f=b%32,n=(b-f)/32,a=0;a>>27)>>>0}function m(a,d,e,f,b,h){return(d^e^f)+b+h+1859775393+(a<<5|a>>>27)>>>0}function f(a,d,e,f,b,h){return(d&e|f&(d|e))+b+h+2400959708+(a<<5|a>>>27)>>>0}function d(a,d,e,f,b,h){return(d^e^f)+b+h+3395469782+(a<<5|a>>>27)>>>0}var k,r=new Uint32Array(80);return function(l){l=new Uint8Array(w(l));var s=l.length, -e=s+9;e%64&&(e+=64-e%64);k=new Uint32Array(5);k[0]=1732584193;k[1]=4023233417;k[2]=2562383102;k[3]=271733878;k[4]=3285377520;for(var g=0;gb;b++){var h=0,c=g+b;cc&&(h=s<<3>>>8*c&255));r[b>>2]=0===b%4?h<<24:r[b>>2]|h<<8*(3-b%4)}for(b=16;80>b;b++)h=r[b-3]^r[b-8]^r[b-14]^r[b-16],r[b]=h<<1|h>>>31;for(var b=k,h=r,c=b[0],p=b[1],n=b[2],q=b[3],t=b[4],v=a,u=0;80>u;u+=5)20===u?v=m:40===u?v=f:60===u&&(v=d),t=v(c,p,n,q,t,h[u]),p=(p<<30|p>>>2)>>>0, -q=v(t,c,p,n,q,h[u+1]),c=(c<<30|c>>>2)>>>0,n=v(q,t,c,p,n,h[u+2]),t=(t<<30|t>>>2)>>>0,p=v(n,q,t,c,p,h[u+3]),q=(q<<30|q>>>2)>>>0,c=v(p,n,q,t,c,h[u+4]),n=(n<<30|n>>>2)>>>0;b[0]+=c;b[1]+=p;b[2]+=n;b[3]+=q;b[4]+=t}for(b=0;5>b;b++)l=k[b],k[b]=(l&255)<<24|(l&65280)<<8|l>>8&65280|l>>24&255;return k.buffer}}();return function(a){a=a||{};this.name=(a.name||"GOST R 34.10")+"-"+(a.version||2012)%100+(1<(a.version||2012)?"-"+(a.length||256):"")+("HASH"!==(a.mode||"HASH")?"-"+a.mode:"")+(a.procreator?"/"+a.procreator: -"")+("string"===typeof a.sBox?"/"+a.sBox:"");this.procreator=a.procreator;this.bitLength=a.length||256;switch(a.version||2012){case 1:this.digest=Q;this.bitLength=160;break;case 1994:this.digest=D;this.sBox=(a.sBox||("SC"===a.procreator?"D-SC":"D-A")).toUpperCase();y||(y=z.GostCipher);if(!y)throw new F("Object GostCipher not found");this.cipher=new y({name:"GOST 28147",block:"ECB",sBox:this.sBox,procreator:this.procreator});break;case 2012:this.digest=P;break;default:throw new F("Algorithm version "+ -a.version+" not supported");}this.keySize=a.keySize||(2>=a.version?this.bitLength/8:32);switch(a.mode||"HASH"){case "HASH":break;case "HMAC":this.sign=C;this.verify=J;this.generateKey=E;break;case "KDF":this.deriveKey=G;this.deriveBits=M;this.label=a.label;this.context=a.context;break;case "PBKDF2":this.deriveKey=G;this.deriveBits=N;this.generateKey=E;this.salt=a.salt;this.iterations=a.iterations||2E3;this.diversifier=a.diversifier||1;break;case "PFXKDF":this.deriveKey=G;this.deriveBits=L;this.generateKey= -E;this.salt=a.salt;this.iterations=a.iterations||2E3;this.diversifier=a.diversifier||1;break;case "CPKDF":this.deriveKey=G;this.deriveBits=O;this.generateKey=E;this.salt=a.salt;this.iterations=a.iterations||2E3;break;default:throw new F("Algorithm mode "+a.mode+" not supported");}}}); diff --git a/min/gostEngine.min.js b/min/gostEngine.min.js deleted file mode 100644 index 4189652..0000000 --- a/min/gostEngine.min.js +++ /dev/null @@ -1,8 +0,0 @@ -/* - 2014-2016, Rudolf Nickolaev. All rights reserved. -*/ -(function(c,g){"function"===typeof define&&define.amd?define(["gostRandom","gostCipher","gostDigest","gostSign"],g):"object"===typeof exports?module.exports=g(require("gostRandom"),require("gostCipher"),require("gostDigest"),require("gostSign")):("undefined"!==typeof importScripts&&(c.GostRandom&&c.GostCipher&&c.GostDigest&&c.GostSign||importScripts("gostRandom.js","gostCipher.js","gostDigest.js","gostSign.js")),c.gostEngine=g(c.GostRandom,c.GostCipher,c.GostDigest,c.GostSign))})(this,function(c, -g,k,l){var f=this,m={execute:function(b,a,c){var e;if(!b)throw new (f.SyntaxError||Error)("Algorithm not defined");if(!b.name)throw new (f.SyntaxError||Error)("Algorithm name not defined");e=b.name;var d=b.mode;if("GOST 28147"!==e&&"GOST R 34.12"!==e&&"RC2"!==e||"generateKey"!==a&&("MAC"!==d||"sign"!==a&&"verify"!==a)&&("KW"!==d&&"MASK"!==d||"wrapKey"!==a&&"unwrapKey"!==a)&&(d&&"ES"!==d||"encrypt"!==a&&"decrypt"!==a))if("GOST R 34.11"!==e&&"SHA"!==e||"digest"!==a&&("HMAC"!==d||"sign"!==a&&"verify"!== -a&&"generateKey"!==a)&&("KDF"!==d&&"PBKDF2"!==d&&"PFXKDF"!==d&&"CPKDF"!==d||"deriveKey"!==a&&"deriveBits"!==a&&"generateKey"!==a)){if("GOST R 34.10"!==e||"generateKey"!==a&&(d&&"SIGN"!==d||"sign"!==a&&"verify"!==a)&&("MASK"!==d||"wrapKey"!==a&&"unwrapKey"!==a)&&("DH"!==d||"deriveKey"!==a&&"deriveBits"!==a))throw new (f.NotSupportedError||Error)("Algorithm "+e+"-"+d+" is not valid for "+a);e="GostSign"}else e="GostDigest";else e="GostCipher";b=this["get"+e](b);return b[a].apply(b,c)},getGostCipher:function(b){return new (g|| -(g=f.GostCipher))(b)},getGostDigest:function(b){return new (k||(k=f.GostDigest))(b)},getGostSign:function(b){return new (l||(l=f.GostSign))(b)}};if(f.importScripts)f.onmessage=function(b){try{postMessage({id:b.data.id,result:m.execute(b.data.algorithm,b.data.method,b.data.args)})}catch(a){postMessage({id:b.data.id,error:a.message})}};else{var n="",p="";"undefined"!==typeof document&&function(){for(var b=/^(.*)gostCrypto(.*)\.js$/i,a=document.querySelectorAll("script"),c=0,e=a.length;c>>24;a[2]=c>>>16&255;a[1]=c>>>8&255;a[0]=c&255;return a}function V(a){switch(a.id){case "pbeWithSHAAnd40BitRC2-CBC":case "pbeWithSHAAnd128BitRC2-CBC":return 8;case "pbeUnknownGost":return 16;case "sha1":return 20;default:return 32}}function R(a,b){if(!b)return new E(0);if(0<=a.name.indexOf("CPKDF")){for(var c=[],d=0;d>>8&255);c.push(0);c.push(0)}return(new Uint8Array(c)).buffer}return 0<=a.name.indexOf("PFXKDF")?w.Chars.decode(b+"\x00","unicode"):w.Chars.decode(b,"utf8")}function x(){}function v(a){m.PrivateKeyInfo.call(this,a)}function F(a){m.EncryptedPrivateKeyInfo.call(this,a)}function J(a){if(a){var b=this;["mk.db3","masks.db3","kek.opq","rand.opq"].forEach(function(c){b[c]=a[c]})}}function O(a,b){m.GostWrappedPrivateKey.call(this,a);J.call(this,b)}function S(a){a&&(this.header=m.GostKeyContainer.decode(a.header), -this.name=m.GostKeyContainerName.decode(a.name),this.primary=m.GostPrivateKeys.decode(a.primary),this.masks=m.GostPrivateMasks.decode(a.masks),a.primary2&&a.masks2&&(this.primary2=m.GostPrivateKeys.decode(a.primary2),this.masks2=m.GostPrivateMasks.decode(a.masks2)))}function H(a){m.ViPNetInfo.call(this,a||{version:3,keyInfo:{keyClass:1,keyType:43556,flags:1},defenceKeyInfo:{keyClass:1024,keyType:24622,keyUID:B(32),flags:-2147483648}})}function P(a){a&&(a instanceof E||a.buffer instanceof E||"string"=== -typeof a)?this.decode(a):(a=a||{},this.fileType=a.fileType||"ITCS",this.fileVersion=a.fileVersion||16,a.applicationHeader&&(this.applicationHeader=a.applicationHeader),this.entries=a.entries||[])}function K(a){m.PFX.call(this,a||{version:3,authSafe:{contentType:"data"}})}function T(a){this.entries={};if(a)for(var b in a)this.setEntry(b,a[b])}var k=this.Promise,D=this.Object,E=this.ArrayBuffer,U=this.Date,g=u.subtle,m=u.asn1,w=u.coding,s=u.security.providers,q=u.cert,z=u.cms,C={providerName:"CP-01", -days:7305};x.prototype.options=C;A(m.PrivateKeyInfo,v,{getPrivateKey:function(){var a="rsaEncryption"===this.privateKeyAlgorithm.id?["sign"]:["sign","deriveKey","deriveBits"];return g.importKey("pkcs8",this.encode(),this.privateKeyAlgorithm,"true",a)},setPrivateKey:function(a){var b=this;return g.exportKey("pkcs8",a).then(function(a){m.PrivateKeyInfo.call(b,a);return b})},generate:function(a,b){var c=this;return(new k(p)).then(function(){a instanceof q.Request||(a=new q.Request(a));return a.generate(b)}).then(function(b){m.PrivateKeyInfo.call(c, -b);return a})}});x.prototype.PKCS8=v;A(m.EncryptedPrivateKeyInfo,F,{getKey:function(a){var b=this,c;return(new k(p)).then(function(){c=new z.EncryptedDataContentInfo({contentType:"encryptedData",version:0,encryptedContentInfo:{contentType:"data",contentEncryptionAlgorithm:b.encryptionAlgorithm,encryptedContent:b.encryptedData}});return c.getEnclosed(a)}).then(function(a){return v.decode(a.content)})},getPrivateKey:function(a){return this.getKey(a).then(function(a){return a.getPrivateKey()})},setKey:function(a, -b,c){var d=this,e;return(new k(p)).then(function(){a=new v(a);e=new z.EncryptedDataContentInfo;return e.encloseContent(a.encode(),b,c||C.providerName)}).then(function(){d.encryptionAlgorithm=e.encryptedContentInfo.contentEncryptionAlgorithm;d.encryptedData=e.encryptedContentInfo.encryptedContent;return d})},setPrivateKey:function(a,b,c){var d=this;return(new v).setPrivateKey(a).then(function(a){return d.setKey(a,b,c)})},generate:function(a,b,c,d){var e=this;return(new k(p)).then(function(){a instanceof -q.Request||(a=new q.Request(a));return a.generate(c)}).then(function(a){return e.setKey(a,b,d)}).then(function(){return a})}});x.prototype.PKCS8Encrypted=F;A(D,J,{getEncryptionKey:function(a){var b=s["SC-01"].wrapping,c=s["SC-01"].encryption,d=s["SC-01"].derivation,e=this["masks.db3"],h=this["mk.db3"],f=this["kek.opq"];return(new k(p)).then(function(){if(!e||!h||!f)throw Error("Not enougth key container files");if(32d.randomStatus.byteLength)throw Error("Invalid random status length");return e(g,d.mask,d.randomStatus)}).then(function(a){if(!y(a,d.hmacRandom))throw Error("Imita for mask is invalid");return b(g,f,new Uint8Array(d.randomStatus,0,12))}).then(function(b){return h&&c.secondaryKey?l(a.secondaryPrivateKeyParameters.privateKeyAlgorithm, -b,c.secondaryKey,d.mask,a.secondaryFP):l(g,b,c.primaryKey,d.mask,a.primaryFP)})}function W(a,c,d,e,f,h){return b(a,e,new Uint8Array(d.randomStatus,0,12)).then(function(c){return t(a,c,h,d.mask)}).then(function(a){c||(c=new m.GostPrivateKeys);f?c.secondaryKey=a:c.primaryKey=a;return c})}return{getKey:function(a,c){return this.getPrivateKey(a,c).then(function(a){return(new v).setPrivateKey(a)})},getPrivateKey:function(a,c){var b=this,d=b.header.keyContainerContent;return n(d,b.primary,b.masks,a,c)["catch"](function(e){if(b.primary2&& -b.masks2)return n(d,b.primary2,b.masks2,a,c);throw e;})},getCertificate:function(a){var c=this.header.keyContainerContent;return(new k(p)).then(function(){return a?new q.X509(c.secondaryCertificate):new q.X509(c.primaryCertificate)})},getContainerName:function(){return this.name.containerName},setKey:function(a,c,b,d){var e=this;return(new v(a)).getPrivateKey().then(function(a){return e.setPrivateKey(a,c,b,d)})},setPrivateKey:function(a,b,e,l){var g=this,n,t;return(new k(p)).then(function(){g.header= -g.header||new m.GostKeyContainer({keyContainerContent:{containerAlgoritmIdentifier:{algorithm:"id-CryptoPro-GostPrivateKeys-V2-Full"},attributes:["kccaReservePrimary","kccaPrimaryKeyAbsent"],extensions:{keyValidity:{notAfter:N(l||C.days)}}}});n=g.header.keyContainerContent;var c=e?n.secondaryPrivateKeyParameters:n.primaryPrivateKeyParameters;if(c)t=c.privateKeyAlgorithm;else if(t=r(a.algorithm,{sBox:"D-A",encParams:{block:"CFB",sBox:"E-A",keyMeshing:"CP"}}),c={attributes:["pkaExportable","pkaExchange", -"pkaDhAllowed"],privateKeyAlgorithm:t},e){if(!n.primaryPrivateKeyParameters)throw Error("Primary key must be defined first");n.secondaryPrivateKeyParameters=c}else n.primaryPrivateKeyParameters=c,c=n.attributes.indexOf("kccaPrimaryKeyAbsent"),0<=c&&n.attributes.splice(c,1);var b=[];[0,1].forEach(function(a){var c="masks"+(0a&&n.attributes.push("kccaSoftPassword"),c(t,b,n.primaryFP);0<=a&&n.attributes.splice(a,1)}).then(function(a){a&&(n.hmacPassword=a);return d(t,n)}).then(function(a){g.header.hmacKeyContainerContent=a;return g})},setCertificate:function(a,c,b){var e=this,f,h;return(new k(p)).then(function(){e.header= -e.header||new m.GostKeyContainer({keyContainerContent:{containerAlgoritmIdentifier:{algorithm:"id-CryptoPro-GostPrivateKeys-V2-Full"},attributes:["kccaReservePrimary","kccaPrimaryKeyAbsent"],extensions:{keyValidity:{notAfter:N(b||C.days)}}}});f=e.header.keyContainerContent;a=new q.X509(a);h=f.primaryPrivateKeyParameters&&f.primaryPrivateKeyParameters.privateKeyAlgorithm||r(a.subjectPublicKeyInfo.algorithm,{sBox:"D-A",encParams:{block:"CFB",sBox:"E-A",keyMeshing:"CP"}});return a.getPublicKey()}).then(function(b){if(c){if(f.secondaryFP&& -!y(f.secondaryFP,new Uint8Array(b.buffer,0,f.secondaryFP.byteLength)))throw Error("The public key of the certificate does not match the private key");f.secondaryCertificate=a}else{if(f.primaryFP&&!y(f.primaryFP,new Uint8Array(b.buffer,0,f.primaryFP.byteLength)))throw Error("The public key of the certificate does not match the private key");f.primaryCertificate=a}return d(h,f)}).then(function(a){e.header.hmacKeyContainerContent=a;return e})},setContainerName:function(a){this.name=new m.GostKeyContainerName({containerName:a})}, -verify:function(a){var b=this,e,f;return(new k(p)).then(function(){e=b.header.keyContainerContent;f=e.primaryPrivateKeyParameters.privateKeyAlgorithm;return d(f,e)}).then(function(d){if(!y(d,b.header.hmacKeyContainerContent))throw Error("Container is not valid.");d=0<=e.attributes.indexOf("kccaSoftPassword");if(!a&&d)throw Error("Password is required");if(a&&!d)throw Error("Password is not reqiured.");return a?c(f,a,e.primaryFP).then(function(a){if(!y(a,e.hmacPassword))throw Error("Password is not valid."); -return b}):b})},changePassword:function(a,c){var b=this,d;return(new k(p)).then(function(){d=b.header.keyContainerContent;if(!d.primaryPrivateKeyParameters)throw Error("Private key not yet defined");return b.getPrivateKey(a).then(function(a){return b.setPrivateKey(a,c)})}).then(function(){return d.secondaryPrivateKeyParameters?b.getPrivateKey(a,!0).then(function(a){return b.setPrivateKey(a,c,!0)}):b})},generate:function(a,c,b){var d=this,e,f;return(new k(p)).then(function(){a instanceof q.Request|| -(a=new q.Request(a));return a.generate(b)}).then(function(a){f=a;return d.setKey(f,c)}).then(function(){e=new q.X509(a);return e.sign(f)}).then(function(){return d.setCertificate(e)}).then(function(){return a})},encode:function(a){return{header:this.header.encode(a),name:this.name.encode(a),masks:this.masks.encode(a),primary:this.primary.encode(a),masks2:this.masks2.encode(a),primary2:this.primary2.encode(a)}}}}());x.prototype.CryptoProKeyContainer=S;A(m.ViPNetInfo,H,function(){function a(a){void 0=== -a&&(a="");var c=w.Chars.decode(a,"win1251"),d;return g.digest("GOST R 34.11-94",c).then(function(a){d=a;a=new Uint8Array(c.byteLength+d.byteLength);a.set(new Uint8Array(c),0);a.set(new Uint8Array(d),c.byteLength);return g.digest("GOST R 34.11-94",a)}).then(function(a){return g.importKey("raw",a,"GOST 28147",!1,["unwrapKey"])}).then(function(a){return g.unwrapKey("raw",d,a,"GOST 28147-MASK/VN","GOST 28147-89","false",["encrypt","decrypt","sign","verify"])})}return{getPrivateKey:function(b){var c=this, -d,e;return(new k(p)).then(function(){return b&&"string"!==typeof b?b:a(b)}).then(function(a){b=a;d=c.keyPart;e=new Uint8Array(d,0,d.byteLength-4-8);a=new Uint8Array(d,e.byteLength,4);var f=c.keyInfo.encode(),l=new Uint8Array(e.byteLength+f.byteLength);l.set(new Uint8Array(e),0);l.set(new Uint8Array(f),e.byteLength);return g.verify({name:"GOST 28147-89-MAC"},b,a,l)}).then(function(a){if(!a)throw Error("Invalid key password");a=new Uint8Array(d,d.byteLength-8,8);return g.decrypt({name:"GOST 28147-89-CFB", -iv:a},b,e)}).then(function(a){var b=a.byteLength/2;if(c.keyInfo.keyClass&0)return g.importKey("raw",new Int32Array(a,b,b),"GOST 28147",!1,["unwrapKey"]).then(function(c){return g.unwrapKey("raw",new Int32Array(a,0,b),c,"GOST 28147-MASK/VN","GOST 28147-89","false",["encrypt","decrypt","sign","verify"])});var d=c.keyInfo.algorithm||c.certificate&&c.certificate.subjectPublicKeyInfo.algorithm;if(!d)throw Error("Algorithm is not specified");var e=r(d,{mode:"MASK",procreator:"VN"});e.name=e.name.replace("-DH", -"");var n=new Uint8Array(a,0,b),k=new Uint8Array(a,b,b);return g.importKey("raw",k,e,"false",["sign","unwrapKey"]).then(function(a){return g.unwrapKey("raw",n,a,e,d,"true",["sign","deriveBits","deriveKey"])}).then(function(a){return c.publicKey?g.generateKey(r(a.algorithm,{ukm:a.buffer}),a.extractable,a.usages):{privateKey:a}}).then(function(a){if(c.publicKey&&!y(a.publicKey.buffer,c.publicKey))throw Error("Check public key failed");return a.privateKey})})},setPrivateKey:function(b,c,d){var e=this, -h,f,l,t;return(new k(p)).then(function(){return c&&"string"!==typeof c?c:a(c)}).then(function(a){c=a;a=b.algorithm;e.keyInfo.algorithm=a;e.keyInfo.serialNumber=B(16);e.keyInfo.keyUID=B(8);e.keyInfo.validity={notBefore:Q(),notAfter:Q(d||C.days)};if("private"===b.type)return h=r(a,{mode:"MASK",procreator:"VN"}),h.name=h.name.replace("-DH",""),e.keyInfo.keyClass=1,e.keyInfo.keyType=43556,g.generateKey(r(a,{ukm:b.buffer}),!0,["sign","verify"]).then(function(a){e.publicKey=a.publicKey.buffer;if(e.certificate)return a= -e.certificate.subjectPublicKeyInfo,g.importKey("spki",a.encode(),a.algorithm,!0,["verify"])}).then(function(a){a&&!y(a.buffer,e.publicKey)&&delete e.certificate});if("secret"===b.type)h="GOST 28147/MASK/VN",delete e.certificate,delete e.publicKey,e.keyInfo.keyClass=64,e.keyInfo.keyType=24622;else throw Error("Invalid key type");}).then(function(){return g.generateKey(h,!0,["wrapKey","unwrapKey"])}).then(function(a){f=a;return g.wrapKey("raw",b,f,h)}).then(function(a){l=new Uint8Array(2*a.byteLength); -l.set(new Uint8Array(a));return g.exportKey("raw",f)}).then(function(a){l.set(new Uint8Array(a),a.byteLength);t=new Uint8Array(l.byteLength+12);a={name:"GOST 28147-CFB",iv:B(8)};t.set(new Uint8Array(a.iv),t.byteLength-8);return g.encrypt(a,c,l)}).then(function(a){t.set(new Uint8Array(a));var b=e.keyInfo.encode(),d=new Uint8Array(a.byteLength+b.byteLength);d.set(new Uint8Array(a),0);d.set(new Uint8Array(b),a.byteLength);return g.sign({name:"GOST 28147-89-MAC"},c,d)}).then(function(a){t.set(new Uint8Array(a), -t.byteLength-12);e.keyPart=t.buffer;return e})},encode:function(a){var c=m.ViPNetInfo.method("encode").call(this),d=new Uint8Array(8+c.byteLength+this.keyPart.byteLength);I(d.buffer,0,4+c.byteLength+this.keyPart.byteLength);d.set(new Uint8Array(c),4);I(d.buffer,4+c.byteLength,this.keyPart.byteLength);d.set(new Uint8Array(this.keyPart),8+c.byteLength);return"PEM"===a?w.Base64.encode(d.buffer):d.buffer}}}(),{decode:function(a){"string"===typeof a&&(a=w.Base64.decode(a));a=M(a);var b=G(a,0);if(a.byteLength!== -b+4)throw Error("Invalid container entry size");var c=w.BER.decode(new Uint8Array(a,4,b)),b=m.ViPNetInfo.decode.call(this,c),c=c.header.byteLength+c.content.byteLength,d=G(a,4+c);if(a.byteLength!==c+d+8)throw Error("Invalid container key part size");b.keyPart=(new Uint8Array(new Uint8Array(a,c+8,d))).buffer;return b}});x.prototype.ViPNetContainerEntry=H;A(D,P,{getCertificate:function(a){var b=this;return(new k(p)).then(function(){var c=b.entries[a||0];if(!c)throw Error("Entry not defined");if(c.certificate)return new q.X509(c.certificate)})}, -getKey:function(a,b){return this.getPrivateKey(a,b).then(function(a){return(new v).setPrivateKey(a)})},getPrivateKey:function(a,b){var c=this;return(new k(p)).then(function(){var d=c.entries[b||0];if(!d)throw Error("Entry not defined");return d.getPrivateKey(a)})},setCertificate:function(a,b){var c=this,d;return(new k(p)).then(function(){d=c.entries[b||0]||(c.entries[b||0]=new H);a=new q.X509(a);if(d.publicKey)return a.getPublicKey()}).then(function(b){if(b&&!y(d.publicKey,b.buffer))throw Error("Invalid certificate for private key"); -d.certificate=a;return c})},setKey:function(a,b,c,d){var e=this;return(new v(a)).getPrivateKey().then(function(a){return e.setPrivateKey(a,b,c,d)})},setPrivateKey:function(a,b,c,d){var e=this;return(new k(p)).then(function(){return(e.entries[c||0]||(e.entries[c||0]=new H)).setPrivateKey(a,b,d)}).then(function(){return e})},changePassword:function(a,b){var c=this;return(new k(p)).then(function(){return c.getPrivateKey(a).then(function(a){return c.setPrivateKey(a,b)})})},generate:function(a,b,c){var d= -this,e,h;return(new k(p)).then(function(){a instanceof q.Request||(a=new q.Request(a));return a.generate(c)}).then(function(a){h=a;return d.setKey(h,b)}).then(function(){e=new q.X509(a);return e.sign(h)}).then(function(){return d.setCertificate(e)}).then(function(){return a})},encode:function(a){var b=[],c=0;this.entries.forEach(function(a){a=a.encode();c+=a.byteLength;b.push(a)});var d=this.applicationHeader?this.applicationHeader.byteLength:0,e=new Uint8Array(12+d+c);e.set(new Uint8Array(w.Chars.decode(this.fileType, -"ascii")));I(e.buffer,4,this.fileVersion);I(e.buffer,8,d);0>>16;if(0!==d&&1!==d||255<(c&65535))throw Error("Unsupported ViPNet container version");var d=G(a,8),e;0k;k++)g+=("00"+d[k].toString(16)).slice(-2);d=g.substr(0,8)+"-"+g.substr(8,4)+ -"-4"+g.substr(13,3)+"-9"+g.substr(17,3)+"-"+g.substr(20,12);b[d]=a}});return c})},store:function(a,b,c){var d=this,e=[],g=[],f=[];return(new k(p)).then(function(){c=c?s[c]?s[c].pbes:c:b?s[b]?s[b].pbes:s[C.providerName].pbes:s[C.providerName].pbes;for(var f in d.entries){var m=new Uint32Array([1]),n=d.entries[f];n.key&&function(b,d){b instanceof E?g.push({bagId:"secretBag",bagValue:{secretTypeId:"secret",secretValue:b,bagAttributes:d}}):b instanceof v?c&&a?e.push((new F).setKey(b,a,c).then(function(a){return{bagId:"pkcs8ShroudedKeyBag", -bagValue:a,bagAttributes:d}})):e.push({bagId:"keyBag",bagValue:b,bagAttributes:d}):b instanceof F&&e.push({bagId:"pkcs8ShroudedKeyBag",bagValue:b,bagAttributes:d})}(n.key,{localKeyId:m,friendlyName:f});n.certs&&n.certs.forEach(function(a){var b={localKeyId:m};a instanceof q.X509&&g.push({bagId:"certBag",bagValue:{certId:"x509Certificate",certValue:a},bagAttributes:b})});n.crls&&n.crls.forEach(function(a){var b={localKeyId:m};a instanceof q.CRL&&g.push({bagId:"crlBag",bagValue:{crlId:"x509CRL",crlValue:a}, -bagAttributes:b})})}if(0>=14;0<=--g;){var k=a[b]&16383,l=a[b++]>>14,n=c*k+l*h,k=h*k+((n&16383)<<14)+d[e]+f;f=(k>>28)+(n>>14)+c*l;d[e++]=k&268435455}return f}function n(a){a=Array(Math.ceil(a));a.s=0;a.t=0;return a}function G(a,b){for(var c= -a.t-1;0<=c;--c)b[c]=a[c];b.t=a.t;b.s=a.s;return b}function ua(a,b){a.t=1;a.s=0>b?-1:0;0b?a[0]=b+268435456:a.t=0;return a}function C(a){var b=n(1);ua(b,a);return b}function u(a){for(var b=a.s&268435455;0>=28;if(b.t>=28;e+=a.s}else{for(e+=a.s;d>=28;e-=b.s}c.s=0>e?-1:0;-1>e? -c[d++]=268435456+e:0>=28;if(b.t>=28;e+=a.s}else{for(e+=a.s;d>=28;e+=b.s}c.s=0>e?-1:0;0e&&(c[d++]=268435456+e);c.t=d;return u(c)}function M(a){if(0>a.s){var b=n(a.t);a=p(t,a,b)}return a}function s(a,b){var c=a.s-b.s;if(0!==c)return c;var d= -a.t,c=d-b.t;if(0!==c)return 0>a.s?-c:c;for(;0<=--d;)if(0!==(c=a[d]-b[d]))return c;return 0}function ga(a){var b=1,c;0!==(c=a>>>16)&&(a=c,b+=16);0!==(c=a>>8)&&(a=c,b+=8);0!==(c=a>>4)&&(a=c,b+=4);0!==(c=a>>2)&&(a=c,b+=2);0!==a>>1&&(b+=1);return b}function U(a,b,c){var d;for(d=a.t-1;0<=d;--d)c[d+b]=a[d];for(d=b-1;0<=d;--d)c[d]=0;c.t=a.t+b;c.s=a.s;return c}function Y(a,b,c){for(var d=b;d>e|g,g=(a[h]&f)<=a.t)c.t=0;else{b%=28;var e=28-b,f=(1<>b;for(var g=d+1;g>b;0=a.t?0:28*(a.t-1)+ga(a[a.t-1]^a.s&268435455)}function Z(a,b,c){var d=M(a),e=M(b),f=d.t;for(c.t=f+e.t;0<=--f;)c[f]= -0;for(f=0;f=c.DV&&(b[d+c.t]-=c.DV,b[d+c.t+1]=1)}0=e.t)throw new Ea("Division by zero");var f=M(a);if(f.t>4:0),q=Fa/m,m=16777216/m,N=d.t,r=N-e;a=c?c:n(Math.max(a.t-b.t,1));U(g,r,a);0<=s(d,a)&&(d[d.t++]=1,p(d,a,d));U(R,e,a);for(p(a,g,g);g.th&&p(t,d,d);return c}function va(a,b,c){ia(M(a),b,null,c);0>a.s&&0a.s?-1:0>=a.t||1===a.t&&0>=a[0]?0:1}function aa(a,b){var c=y(b);if(y(a)&&c||0===S(b))return t;for(var d=G(b,n(b.t)),e=G(a,n(a.t)),f=C(1),g=C(0),h=C(0),k=C(1);0!==S(d);){for(;y(d);)H(d,1,d),c?(y(f)&&y(g)||(L(f,a,f),p(g,b,g)),H(f,1,f)):y(g)||p(g,b,g),H(g,1,g);for(;y(e);)H(e, -1,e),c?(y(h)&&y(k)||(L(h,a,h),p(k,b,k)),H(h,1,h)):y(k)||p(k,b,k),H(k,1,k);0<=s(d,e)?(p(d,e,d),c&&p(f,h,f),p(g,k,g)):(p(e,d,e),c&&p(h,f,h),p(k,g,k))}if(0!==s(e,R))return t;if(0<=s(k,b))return subtract(k,b);if(0>S(k))L(k,b,k);else return k;return 0>S(k)?L(k,b,n(k.t)):k}function V(a,b){var c=Math.floor(b/28);return c>=a.t?0!==a.s:0!==(a[c]&1<=d)return f;e=18>d?1:48>d?3:144>d?4:768>d?5:6;g=8>d?new wa(c):y(c)?new ka(c):new xa(c);var h=[],k=3,l=e-1,m=(1<=l?c=b[a]>>d-l&m:(c=(b[a]&(1<>28+d-l));for(k=e;0==(c&1);)c>>=1,--k;0>(d-=k)&&(d+=28,--a);if(p)G(h[c],f),p=!1;else{for(;1--d&&(d=27,--a)}return g.revert(f)}function w(a,b){a.r.reduce(b);b.q=a.q;b.r=a.r;return b}function ca(a,b){b.q=a.q;b.r=a.r;return b}function ya(a,b){var c=L(a,b,n(a.t));0c.s&&L(a.q,c,c);return ca(a,c)}function l(a,b){return w(a,v(a,b))}function O(a){return w(a,$(a,n(2*a.t)))}function T(a,b){var c=n(a.t);0>b? -H(a,-b,c):ha(a,b,c);return w(a,c)}function za(a){return ca(a,aa(a,a.q))}function P(a,b,c,d){return{curve:a,x:b,y:c,z:d||w(a,R)}}function da(a){a.zinv||(a.zinv=za(a.z));return l(a.x,a.zinv)}function Aa(a){a.zinv||(a.zinv=za(a.z));return l(a.y,a.zinv)}function W(a){return a.x||a.y?z(a.z)&&!z(a.y):!0}function X(a,b){if(W(a))return b;if(W(b))return a;var c=D(l(b.y,a.z),l(a.y,b.z)),d=D(l(b.x,a.z),l(a.x,b.z));if(z(d))return z(c)?la(a):a.curve.infinity;var e=a.x,f=a.y,g=O(d),h=l(g,d),e=l(e,g),g=l(O(c),a.z), -d=l(D(l(D(g,T(e,1)),b.z),h),d),c=ya(l(D(D(l(l(e,ea),c),l(f,h)),l(g,c)),b.z),l(c,h)),h=l(l(h,a.z),b.z);return P(a.curve,d,c,h)}function la(a){if(W(a))return a;if(0===S(a.y))return a.curve.infinity;var b=a.x,c=a.y,d=l(c,a.z),e=l(d,c),c=a.curve.a,f=l(O(b),ea);z(c)||(f=ya(f,l(O(a.z),c)));c=l(T(D(O(f),l(T(b,3),e)),1),d);b=D(l(T(D(l(l(f,ea),b),T(e,1)),2),e),l(O(f),f));d=T(l(O(d),d),3);return P(a.curve,c,b,d)}function ma(a,b){if(W(a))return a;if(0===S(b))return a.curve.infinity;var c=v(b,ea),d;d=a.curve; -var e=a.x,f;f=a.y;f=ca(f,fa(f.q,f));d=P(d,e,f,a.z);e=a;for(f=I(c)-2;0>28-c):b[b.t-1]|=f<g&&0<(c=a[f]>>g)&&(d=!0,e.push(c));0<=f;)8>g?(c=(a[f]&(1<>(g+=20)):(c=a[f]>>(g-=8)&255,0>=g&&(g+=28,--f)),0>28-e):b[b.t-1]|=f<a.s){var b=n(a.t);a=p(t,a,b);return"-"+na(a)}var c=!1,d="",e=a.t,f=28-28*e%4;if(0f&&0<(b=a[e]>>f)&&(c=!0,d=b.toString(16));0<=e;)4>f?(b=(a[e]&(1<>(f+=24)):(b=a[e]>>(f-=4)&15,0>=f&&(f+=28,--e)),0I(c)?I(b)-1:I(c)-1,h=a.curve.infinity,k=X(a,f);0<=g;)h=la(h),V(b,g)?h=V(c,g)?X(h,k):X(h,a):V(c,g)&&(h=X(h,f)),--g;d=m(da(h),d)}else g=this.p,h=this.a,f=q(a),d=m(m(v(ba(h,b,g),ba(f,c,g)),g),d);return 0===s(d,e)}function Ca(){var a=this.curve;if(a){for(a=a.infinity;W(a);){var b=t;if(this.ukm)b=q(this.ukm); -else for(;z(b);)b=m(q(ta(this.bitLength)),this.q);var a=ma(this.P,b),c=da(a),d=Aa(a)}return{privateKey:Q(b,this.bitLength),publicKey:sa(c,d,this.bitLength)}}throw new J("Key generation for GOST R 34.10-94 not supported");}function Ja(){if(this.curve){for(var a=t;z(a);)a=m(q(ta(this.bitLength)),this.q);return Q(a,this.bitLength)}throw new J("Key generation for GOST R 34.10-94 not supported");}function Ka(a,b){if(this.curve){var c=this.q,d=m(q(E(b)),c),e=m(q(E(a)),c),c="VN"===this.procreator?m(v(d, -e),c):m(v(d,aa(e,c)),c);return Q(c)}throw new J("Key wrapping GOST R 34.10-94 not supported");}function La(a,b){if(this.curve){var c=this.q,d=m(q(E(b)),c),e=m(q(E(a)),c),c="VN"===this.procreator?m(v(d,aa(e,c)),c):m(v(d,e),c);return Q(c)}throw new J("Key wrapping GOST R 34.10-94 not supported");}function Da(a){var b;b=q(this.ukm);var c=this.q;a=m(q(E(a)),c);this.curve?(b=ma(this.peer_Q,m(v(b,a),c)),b=sa(da(b),Aa(b),this.bitLength)):b=Q(ba(this.peer_y,a,this.p));return pa.call(this,b)}function Ma(a, -b){if(8>b||b>this.bitLength||0a.s||0<=s(a,this.m)?m(a,this.m):a},revert:function(a){return a}, -reduce:function(a){va(a,this.m,a)},sqrTo:function(a,b){$(a,b);this.reduce(b)},mulTo:function(a,b,c){Z(a,b,c);this.reduce(c)}});var xa=function(a){this.m=a;var b;if(1>a.t)b=0;else if(b=a[0],0===(b&1))b=0;else{var c=b&3,c=c*(2-(b&15)*c)&15,c=c*(2-(b&255)*c)&255,c=c*(2-((b&65535)*c&65535))&65535,c=c*(2-b*c%268435456)%268435456;b=0>15;this.um=8191;this.mt2=2*a.t};ja(xa,{convert:function(a){var b=n(a.t);U(M(a),this.m.t,b);ia(b,this.m, -null,b);0>a.s&&0>15)*this.mpl&this.um)<<15)&268435455,c=b+this.m.t;for(a[c]+=B(this.m,0,d,a,b,0,this.m.t);268435456<=a[c];)a[c]-=268435456,a[++c]++}u(a);Y(a,this.m.t,a);0<=s(a,this.m)&&p(a,this.m,a)},sqrTo:function(a,b){$(a,b);this.reduce(b)},mulTo:function(a,b,c){Z(a,b,c);this.reduce(c)}}); -ja(ka,{convert:function(a){if(0>a.s||a.t>2*this.m.t)return m(a,this.m);if(0>s(a,this.m))return a;var b=n(a.t);G(a,b);this.reduce(b);return b},revert:function(a){return a},reduce:function(a){Y(a,this.m.t-1,this.r2);a.t>this.m.t+1&&(a.t=this.m.t+1,u(a));var b=this.mu,c=this.r2,d=this.m.t+1,e=this.q3;--d;var f=e.t=b.t+c.t-d;for(e.s=0;0<=--f;)e[f]=0;for(f=Math.max(d-b.t,0);fs(a,this.r2);){b=a;for(c=this.m.t+1;b.t<=c;)b[b.t++]=0;for(b[c]+=1;268435456<=b[c];)b[c]-=268435456,++c>=b.t&&(b[b.t++]=0),++b[c]}for(p(a,this.r2,a);0<=s(a,this.m);)p(a,this.m,a)},sqrTo:function(a,b){$(a,b);this.reduce(b)},mulTo:function(a,b,c){Z(a,b,c);this.reduce(c)}});return function(a){a=a||{};this.name=(a.name||"GOST R 34.10")+"-"+(a.version||2012)% -100+"-"+(a.length||256)+("SIGN"!==(a.mode||"SIGN")?"-"+a.mode:"")+("string"===typeof a.namedParam?"/"+a.namedParam:"")+("string"===typeof a.namedCurve?"/"+a.namedCurve:"")+("string"===typeof a.sBox?"/"+a.sBox:"");var b=a.version||2012;switch(a.mode||"SIGN"){case "SIGN":this.sign=Ha;this.verify=Ia;this.generateKey=Ca;break;case "DH":this.deriveBits=Ma;this.deriveKey=Na;this.generateKey=Ca;break;case "MASK":this.wrapKey=La,this.unwrapKey=Ka,this.generateKey=Ja}if(1994===b)b=a.param,b||(b=Oa[this.namedParam= -(a.namedParam||"S-A").toUpperCase()]),this.modulusLength=a.modulusLength||b.modulusLength||1024,this.p=A(b.p),this.q=A(b.q),this.a=A(b.a),a["public"]&&(this.peer_y=q(a["public"]));else{b=a.curve;b||(b=r[this.namedCurve=(a.namedCurve||"S-256-A").toUpperCase()]);var c=A(b.p),d=A(b.a),e=A(b.b),f={};f.q=c;f.r=new ka(c);f.a=w(f,d);f.b=w(f,e);f.infinity=P(f);c=this.curve=f;this.P=P(c,w(c,A(b.x)),w(c,A(b.y)));this.q=A(b.q);a["public"]&&(b=ra(a["public"]),this.peer_Q=new P(this.curve,w(this.curve,b[0]),w(this.curve, -b[1])))}if(this.curve){c=a.length||I(this.q);if(508=c)c=512;else if(254=c)c=256;else throw new J("Support keys only 256 or 512 bits length");b=c}else{c=a.modulusLength||I(this.p);if(1016=c)c=1024;else if(508=c)c=512;else throw new J("Support keys only 512 or 1024 bits length");b=256}this.bitLength=b;this.keyLength=c;this.procreator=a.procreator;if(c=a.hash){if("string"===typeof c||c instanceof String)c={name:c};1994===a.version||2001===a.version?(c.version=1994,c.length= -256,c.sBox=a.sBox||c.sBox):(c.version=2012,c.length=b);c.procreator=c.procreator||a.procreator;F||(F=x.GostDigest);if(!F)throw new J("Object GostDigest not found");this.hash=new F(c)}a.ukm&&(this.ukm=a.ukm)}}); From 7ee35bac601e5ec5fdad63833b1a915ec5b2d977 Mon Sep 17 00:00:00 2001 From: Ustimenko Alexander Date: Sat, 10 Dec 2016 01:48:25 +0700 Subject: [PATCH 02/21] Move all to lib --- gostASN1.js => lib/gostASN1.js | 0 gostCMS.js => lib/gostCMS.js | 0 gostCert.js => lib/gostCert.js | 0 gostCipher.js => lib/gostCipher.js | 0 gostCipher.test.js => lib/gostCipher.test.js | 0 gostCoding.js => lib/gostCoding.js | 0 gostCrypto.js => lib/gostCrypto.js | 0 gostDigest.js => lib/gostDigest.js | 0 gostDigest.test.js => lib/gostDigest.test.js | 0 gostEngine.js => lib/gostEngine.js | 0 gostKeys.js => lib/gostKeys.js | 0 gostRandom.js => lib/gostRandom.js | 0 gostSecurity.js => lib/gostSecurity.js | 0 gostSign.js => lib/gostSign.js | 0 gostSign.test.js => lib/gostSign.test.js | 0 gostViewer.js => lib/gostViewer.js | 0 16 files changed, 0 insertions(+), 0 deletions(-) rename gostASN1.js => lib/gostASN1.js (100%) rename gostCMS.js => lib/gostCMS.js (100%) rename gostCert.js => lib/gostCert.js (100%) rename gostCipher.js => lib/gostCipher.js (100%) rename gostCipher.test.js => lib/gostCipher.test.js (100%) rename gostCoding.js => lib/gostCoding.js (100%) rename gostCrypto.js => lib/gostCrypto.js (100%) rename gostDigest.js => lib/gostDigest.js (100%) rename gostDigest.test.js => lib/gostDigest.test.js (100%) rename gostEngine.js => lib/gostEngine.js (100%) rename gostKeys.js => lib/gostKeys.js (100%) rename gostRandom.js => lib/gostRandom.js (100%) rename gostSecurity.js => lib/gostSecurity.js (100%) rename gostSign.js => lib/gostSign.js (100%) rename gostSign.test.js => lib/gostSign.test.js (100%) rename gostViewer.js => lib/gostViewer.js (100%) diff --git a/gostASN1.js b/lib/gostASN1.js similarity index 100% rename from gostASN1.js rename to lib/gostASN1.js diff --git a/gostCMS.js b/lib/gostCMS.js similarity index 100% rename from gostCMS.js rename to lib/gostCMS.js diff --git a/gostCert.js b/lib/gostCert.js similarity index 100% rename from gostCert.js rename to lib/gostCert.js diff --git a/gostCipher.js b/lib/gostCipher.js similarity index 100% rename from gostCipher.js rename to lib/gostCipher.js diff --git a/gostCipher.test.js b/lib/gostCipher.test.js similarity index 100% rename from gostCipher.test.js rename to lib/gostCipher.test.js diff --git a/gostCoding.js b/lib/gostCoding.js similarity index 100% rename from gostCoding.js rename to lib/gostCoding.js diff --git a/gostCrypto.js b/lib/gostCrypto.js similarity index 100% rename from gostCrypto.js rename to lib/gostCrypto.js diff --git a/gostDigest.js b/lib/gostDigest.js similarity index 100% rename from gostDigest.js rename to lib/gostDigest.js diff --git a/gostDigest.test.js b/lib/gostDigest.test.js similarity index 100% rename from gostDigest.test.js rename to lib/gostDigest.test.js diff --git a/gostEngine.js b/lib/gostEngine.js similarity index 100% rename from gostEngine.js rename to lib/gostEngine.js diff --git a/gostKeys.js b/lib/gostKeys.js similarity index 100% rename from gostKeys.js rename to lib/gostKeys.js diff --git a/gostRandom.js b/lib/gostRandom.js similarity index 100% rename from gostRandom.js rename to lib/gostRandom.js diff --git a/gostSecurity.js b/lib/gostSecurity.js similarity index 100% rename from gostSecurity.js rename to lib/gostSecurity.js diff --git a/gostSign.js b/lib/gostSign.js similarity index 100% rename from gostSign.js rename to lib/gostSign.js diff --git a/gostSign.test.js b/lib/gostSign.test.js similarity index 100% rename from gostSign.test.js rename to lib/gostSign.test.js diff --git a/gostViewer.js b/lib/gostViewer.js similarity index 100% rename from gostViewer.js rename to lib/gostViewer.js From e63071aa05134008495b64748c7f1460625ff986 Mon Sep 17 00:00:00 2001 From: Ustimenko Alexander Date: Sat, 10 Dec 2016 02:24:19 +0700 Subject: [PATCH 03/21] Make requires/defines relative --- lib/gostASN1.js | 4 ++-- lib/gostCMS.js | 4 ++-- lib/gostCert.js | 4 ++-- lib/gostCipher.js | 4 ++-- lib/gostCipher.test.js | 4 ++-- lib/gostCoding.js | 4 ++-- lib/gostCrypto.js | 4 ++-- lib/gostDigest.js | 4 ++-- lib/gostDigest.test.js | 4 ++-- lib/gostEngine.js | 4 ++-- lib/gostKeys.js | 4 ++-- lib/gostSecurity.js | 4 ++-- lib/gostSign.js | 4 ++-- lib/gostSign.test.js | 4 ++-- lib/gostViewer.js | 4 ++-- 15 files changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/gostASN1.js b/lib/gostASN1.js index c9f4cc0..a48359f 100644 --- a/lib/gostASN1.js +++ b/lib/gostASN1.js @@ -47,9 +47,9 @@ * */ // if (typeof define === 'function' && define.amd) { - define(['gostCrypto', 'gostCoding', 'gostSecurity'], factory); + define(['./gostCrypto', './gostCoding', './gostSecurity'], factory); } else if (typeof exports === 'object') { - module.exports = factory(require('gostCrypto'), require('gostCoding'), require('gostSecurity')); + module.exports = factory(require('./gostCrypto'), require('./gostCoding'), require('./gostSecurity')); } else { root.GostASN1 = factory(root.gostCrypto, root.GostCoding, root.GostSecurity); } diff --git a/lib/gostCMS.js b/lib/gostCMS.js index 2cf97e3..2a0c5e9 100644 --- a/lib/gostCMS.js +++ b/lib/gostCMS.js @@ -47,9 +47,9 @@ * */ // if (typeof define === 'function' && define.amd) { - define(['gostCrypto', 'gostASN1', 'gostCert'], factory); + define(['./gostCrypto', './gostASN1', './gostCert'], factory); } else if (typeof exports === 'object') { - module.exports = factory(require('gostCrypto'), require('gostASN1'), require('gostCert')); + module.exports = factory(require('./gostCrypto'), require('./gostASN1'), require('./gostCert')); } else { root.GostCMS = factory(root.gostCrypto, root.GostASN1, root.GostCert); } diff --git a/lib/gostCert.js b/lib/gostCert.js index 7c68af2..a614303 100644 --- a/lib/gostCert.js +++ b/lib/gostCert.js @@ -47,9 +47,9 @@ * */ // if (typeof define === 'function' && define.amd) { - define(['gostCrypto', 'gostASN1'], factory); + define(['./gostCrypto', './gostASN1'], factory); } else if (typeof exports === 'object') { - module.exports = factory(require('gostCrypto'), require('gostASN1')); + module.exports = factory(require('./gostCrypto'), require('./gostASN1')); } else { root.GostCert = factory(root.gostCrypto, root.GostASN1); } diff --git a/lib/gostCipher.js b/lib/gostCipher.js index 64d3f88..8f6ac6b 100644 --- a/lib/gostCipher.js +++ b/lib/gostCipher.js @@ -37,9 +37,9 @@ * */ // if (typeof define === 'function' && define.amd) { - define(['gostRandom'], factory); + define(['./gostRandom'], factory); } else if (typeof exports === 'object') { - module.exports = factory(require('gostRandom')); + module.exports = factory(require('./gostRandom')); } else { root.GostCipher = factory(root.GostRandom); } diff --git a/lib/gostCipher.test.js b/lib/gostCipher.test.js index 8eb2d6c..4fa2efb 100644 --- a/lib/gostCipher.test.js +++ b/lib/gostCipher.test.js @@ -35,9 +35,9 @@ (function (root, factory) { if (typeof define === 'function' && define.amd) { - define(['gostCoding', 'gostCipher'], factory); + define(['./gostCoding', './gostCipher'], factory); } else if (typeof exports === 'object') { - module.exports = factory(require('gostCoding'), require('gostCipher')); + module.exports = factory(require('./gostCoding'), require('./gostCipher')); } else { if (typeof importScripts !== 'undefined') { if (!root.onmessage) diff --git a/lib/gostCoding.js b/lib/gostCoding.js index e1c30cb..a131a83 100644 --- a/lib/gostCoding.js +++ b/lib/gostCoding.js @@ -37,9 +37,9 @@ * */ // if (typeof define === 'function' && define.amd) { - define(['gostCrypto'], factory); + define(['./gostCrypto'], factory); } else if (typeof exports === 'object') { - module.exports = factory(require('gostCrypto')); + module.exports = factory(require('./gostCrypto')); } else { root.GostCoding = factory(root.gostCrypto); } diff --git a/lib/gostCrypto.js b/lib/gostCrypto.js index 9fcd628..41e09dc 100644 --- a/lib/gostCrypto.js +++ b/lib/gostCrypto.js @@ -37,9 +37,9 @@ * */ // if (typeof define === 'function' && define.amd) { - define(['gostRandom'], factory); + define(['./gostRandom'], factory); } else if (typeof exports === 'object') { - module.exports = factory(require('gostRandom')); + module.exports = factory(require('./gostRandom')); } else { root.gostCrypto = factory(root.GostRandom); } diff --git a/lib/gostDigest.js b/lib/gostDigest.js index f4d6dae..99cd732 100644 --- a/lib/gostDigest.js +++ b/lib/gostDigest.js @@ -41,9 +41,9 @@ * */ // if (typeof define === 'function' && define.amd) { - define(['gostRandom', 'gostCipher'], factory); + define(['./gostRandom', './gostCipher'], factory); } else if (typeof exports === 'object') { - module.exports = factory(require('gostRandom'), require('gostCipher')); + module.exports = factory(require('./gostRandom'), require('./gostCipher')); } else { root.GostDigest = factory(root.GostRandom, root.GostCipher); } diff --git a/lib/gostDigest.test.js b/lib/gostDigest.test.js index 168fac9..8792c77 100644 --- a/lib/gostDigest.test.js +++ b/lib/gostDigest.test.js @@ -34,9 +34,9 @@ (function (root, factory) { if (typeof define === 'function' && define.amd) { - define(['gostCoding', 'gostDigest'], factory); + define(['./gostCoding', './gostDigest'], factory); } else if (typeof exports === 'object') { - module.exports = factory(require('gostCoding'), require('gostCipher'), require('gostDigest')); + module.exports = factory(require('./gostCoding'), require('./gostCipher'), require('./gostDigest')); } else { if (typeof importScripts !== 'undefined') { if (!root.onmessage) diff --git a/lib/gostEngine.js b/lib/gostEngine.js index 0cef3e3..931209b 100644 --- a/lib/gostEngine.js +++ b/lib/gostEngine.js @@ -37,9 +37,9 @@ * */ // if (typeof define === 'function' && define.amd) { - define(['gostRandom', 'gostCipher', 'gostDigest', 'gostSign'], factory); + define(['./gostRandom', './gostCipher', './gostDigest', './gostSign'], factory); } else if (typeof exports === 'object') { - module.exports = factory(require('gostRandom'), require('gostCipher'), require('gostDigest'), require('gostSign')); + module.exports = factory(require('./gostRandom'), require('./gostCipher'), require('./gostDigest'), require('./gostSign')); } else { if (typeof importScripts !== 'undefined') { if (!(root.GostRandom && root.GostCipher && root.GostDigest && root.GostSign)) diff --git a/lib/gostKeys.js b/lib/gostKeys.js index de01351..7c06039 100644 --- a/lib/gostKeys.js +++ b/lib/gostKeys.js @@ -37,9 +37,9 @@ * */ // if (typeof define === 'function' && define.amd) { - define(['gostCrypto', 'gostASN1', 'gostCert', 'gostCMS'], factory); + define(['./gostCrypto', './gostASN1', './gostCert', './gostCMS'], factory); } else if (typeof exports === 'object') { - module.exports = factory(require('gostCrypto'), require('gostASN1'), require('gostCert'), require('gostCMS')); + module.exports = factory(require('./gostCrypto'), require('./gostASN1'), require('./gostCert'), require('./gostCMS')); } else { root.GostKeys = factory(root.gostCrypto, root.GostASN1, root.GostCert, root.GostCMS); } diff --git a/lib/gostSecurity.js b/lib/gostSecurity.js index 60dc12b..64d8ac0 100644 --- a/lib/gostSecurity.js +++ b/lib/gostSecurity.js @@ -37,9 +37,9 @@ * */ // if (typeof define === 'function' && define.amd) { - define(['gostCrypto'], factory); + define(['./gostCrypto'], factory); } else if (typeof exports === 'object') { - module.exports = factory(require('gostCrypto')); + module.exports = factory(require('./gostCrypto')); } else { root.GostSecurity = factory(root.gostCrypto); } diff --git a/lib/gostSign.js b/lib/gostSign.js index fbe2f09..a87b848 100644 --- a/lib/gostSign.js +++ b/lib/gostSign.js @@ -40,9 +40,9 @@ * */ // if (typeof define === 'function' && define.amd) { - define(['gostRandom', 'gostDigest'], factory); + define(['./gostRandom', './gostDigest'], factory); } else if (typeof exports === 'object') { - module.exports = factory(require('gostRandom'), require('gostDigest')); + module.exports = factory(require('./gostRandom'), require('./gostDigest')); } else { root.GostSign = factory(root.GostRandom, root.GostDigest); } diff --git a/lib/gostSign.test.js b/lib/gostSign.test.js index e89ed4c..1088ee0 100644 --- a/lib/gostSign.test.js +++ b/lib/gostSign.test.js @@ -34,9 +34,9 @@ (function(root, factory) { if (typeof define === 'function' && define.amd) { - define(['gostCoding', 'gostSign'], factory); + define(['./gostCoding', './gostSign'], factory); } else if (typeof exports === 'object') { - module.exports = factory(require('gostCoding'), require('gostCipher'), require('gostDigest'), require('gostSign')); + module.exports = factory(require('./gostCoding'), require('./gostCipher'), require('./gostDigest'), require('./gostSign')); } else { if (typeof importScripts !== 'undefined') { if (!root.onmessage) diff --git a/lib/gostViewer.js b/lib/gostViewer.js index f37e114..7aa195e 100644 --- a/lib/gostViewer.js +++ b/lib/gostViewer.js @@ -34,9 +34,9 @@ (function (root, factory) { if (typeof define === 'function' && define.amd) { - define(['gostCrypto', 'gostCoding', 'gostSecurity', 'gostASN1'], factory); + define(['./gostCrypto', './gostCoding', './gostSecurity', './gostASN1'], factory); } else if (typeof exports === 'object') { - module.exports = factory(require('gostCrypto'), require('gostCoding'), require('gostSecurity'), require('gostASN1')); + module.exports = factory(require('./gostCrypto'), require('./gostCoding'), require('./gostSecurity'), require('./gostASN1')); } else { root.gostViewer = factory(root.gostCrypto, root.gostCoding, root.gostSecurity, root.gostASN1); } From 3fb5d1dd3b953db52969cafee393a253dc14eb59 Mon Sep 17 00:00:00 2001 From: Ustimenko Alexander Date: Sat, 10 Dec 2016 02:26:07 +0700 Subject: [PATCH 04/21] Fix misspell in 'undefined' --- lib/gostRandom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gostRandom.js b/lib/gostRandom.js index a8b8041..a9a19b7 100644 --- a/lib/gostRandom.js +++ b/lib/gostRandom.js @@ -79,7 +79,7 @@ } }; - if (typeof document !== 'undefiend') { + if (typeof document !== 'undefined') { try { // Mouse move event to fill random array document.addEventListener('mousemove', function (e) { From fa74a7a62fd7e61dc084f829294aac3a14c3dd59 Mon Sep 17 00:00:00 2001 From: Ustimenko Alexander Date: Sat, 10 Dec 2016 02:46:16 +0700 Subject: [PATCH 05/21] Fix classes' names case * Fix GostASN1 case --- lib/gostViewer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gostViewer.js b/lib/gostViewer.js index 7aa195e..00fb25a 100644 --- a/lib/gostViewer.js +++ b/lib/gostViewer.js @@ -38,7 +38,7 @@ } else if (typeof exports === 'object') { module.exports = factory(require('./gostCrypto'), require('./gostCoding'), require('./gostSecurity'), require('./gostASN1')); } else { - root.gostViewer = factory(root.gostCrypto, root.gostCoding, root.gostSecurity, root.gostASN1); + root.gostViewer = factory(root.gostCrypto, root.GostCoding, root.GostSecurity, root.GostASN1); } }(this, function (gostCrypto) { From 6a951d939dab3e51e021548a69eb7bba34738076 Mon Sep 17 00:00:00 2001 From: Ustimenko Alexander Date: Sat, 10 Dec 2016 03:21:43 +0700 Subject: [PATCH 06/21] Remove local imports as they already imported at top --- lib/gostEngine.js | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/lib/gostEngine.js b/lib/gostEngine.js index 931209b..e1dd3f7 100644 --- a/lib/gostEngine.js +++ b/lib/gostEngine.js @@ -437,30 +437,6 @@ } })(); } - - // Local importScripts procedure for include dependens - var importScripts = function () { - for (var i = 0, n = arguments.length; i < n; i++) { - var name = arguments[i].split('.'), - src = baseUrl + name[0] + nameSuffix + '.' + name[1]; - var el = document.querySelector('script[src="' + src + '"]'); - if (!el) { - el = document.createElement('script'); - el.setAttribute('src', src); - document.head.appendChild(el); - } - } - }; - - // Import engines - if (!GostRandom) - importScripts('gostRandom.js'); - if (!GostCipher) - importScripts('gostCipher.js'); - if (!GostDigest) - importScripts('gostDigest.js'); - if (!GostSign) - importScripts('gostSign.js'); } // return gostEngine; From 70d18744cd1ebbb4dca2626d1ca971960c8cefa0 Mon Sep 17 00:00:00 2001 From: Ustimenko Alexander Date: Sat, 10 Dec 2016 03:43:22 +0700 Subject: [PATCH 07/21] Import gostEngine to gostCrypto --- lib/gostCrypto.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/gostCrypto.js b/lib/gostCrypto.js index 41e09dc..c8a543c 100644 --- a/lib/gostCrypto.js +++ b/lib/gostCrypto.js @@ -37,15 +37,15 @@ * */ // if (typeof define === 'function' && define.amd) { - define(['./gostRandom'], factory); + define(['./gostRandom', './gostEngine'], factory); } else if (typeof exports === 'object') { - module.exports = factory(require('./gostRandom')); + module.exports = factory(require('./gostRandom'), require('./gostEngine')); } else { - root.gostCrypto = factory(root.GostRandom); + root.gostCrypto = factory(root.GostRandom, root.gostEngine); } // -}(this, function (GostRandom) { +}(this, function (GostRandom, gostEngine) { /* * Algorithm normalization @@ -803,6 +803,10 @@ } + if (!root.gostEngine) { + root.gostEngine = gostEngine; + } + if (!worker) { // Import main module // Reason: we are already in worker process or Worker interface is not From 5749bb398dcd6b0ccc14dec6a330d6c82bb9a039 Mon Sep 17 00:00:00 2001 From: Ustimenko Alexander Date: Sat, 10 Dec 2016 14:57:46 +0700 Subject: [PATCH 08/21] Make Base64 encode PEM compatible * PEM requires that all encoded lines consist of exactly 64 printable characters, with the exception of the last line --- lib/gostCoding.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gostCoding.js b/lib/gostCoding.js index a131a83..450682a 100644 --- a/lib/gostCoding.js +++ b/lib/gostCoding.js @@ -123,7 +123,7 @@ var m3 = 2, s = ''; for (var n = d.length, u24 = 0, i = 0; i < n; i++) { m3 = i % 3; - if (i > 0 && (i * 4 / 3) % (12 * slen) === 0) + if (i > 0 && (i * 4 / 3) % (8 * slen) === 0) s += '\r\n'; u24 |= d[i] << (16 >>> m3 & 24); if (m3 === 2 || n - i === 1) { From ff63703358986c8260fa28d2fd3e584fe521fbfc Mon Sep 17 00:00:00 2001 From: Ustimenko Alexander Date: Sat, 10 Dec 2016 14:39:59 +0700 Subject: [PATCH 09/21] Test export signal com key --- test/export-signal-com-key.js | 44 +++++++++++++++++++++ test/fixtures/signal-com-keys/00000001.key | Bin 0 -> 168 bytes test/fixtures/signal-com-keys/kek.opq | 1 + test/fixtures/signal-com-keys/masks.db3 | 1 + test/fixtures/signal-com-keys/mk.db3 | Bin 0 -> 230 bytes test/fixtures/signal-com-keys/rand.opq | 2 + 6 files changed, 48 insertions(+) create mode 100755 test/export-signal-com-key.js create mode 100644 test/fixtures/signal-com-keys/00000001.key create mode 100644 test/fixtures/signal-com-keys/kek.opq create mode 100644 test/fixtures/signal-com-keys/masks.db3 create mode 100644 test/fixtures/signal-com-keys/mk.db3 create mode 100644 test/fixtures/signal-com-keys/rand.opq diff --git a/test/export-signal-com-key.js b/test/export-signal-com-key.js new file mode 100755 index 0000000..50e5b2b --- /dev/null +++ b/test/export-signal-com-key.js @@ -0,0 +1,44 @@ +#!/usr/bin/env node + +const fs = require('fs'); + +var expectedPrivateKeyInPem = [ + '-----BEGIN PRIVATE KEY-----', + 'MEYCAQAwHQYGKoUDAgITMBMGByqFAwICIwEGCCqFAwcBAQICBCIEIG0GEmE3dhrH', + 'zm1KfFDpKBWEmMydwcmP0hNKvXXbEbLO', + '-----END PRIVATE KEY-----', +].join('\r\n'), + actualPrivateKeyInPem = null; + +require('../lib/gostKeys'); +var gostCrypto = require('../lib/gostCrypto'); + +var keysPrefix = __dirname + '/fixtures/signal-com-keys/'; +function readCryptoOperationData(path) { + return new Uint8Array(fs.readFileSync(path)).buffer; +} + +var keyContainer = new gostCrypto.keys.SignalComPrivateKeyInfo( + readCryptoOperationData(keysPrefix + '00000001.key'), + { + 'mk.db3' : readCryptoOperationData(keysPrefix + 'mk.db3'), + 'masks.db3' : readCryptoOperationData(keysPrefix + 'masks.db3'), + 'kek.opq' : readCryptoOperationData(keysPrefix + 'kek.opq'), + 'rand.opq' : readCryptoOperationData(keysPrefix + 'rand.opq') + } +); + +keyContainer.getKey().then(function (key) { + actualPrivateKeyInPem = key.encode('PEM'); +}).catch(function (e) { + console.error(e.message); + console.error(e.trace); +}); + +if (expectedPrivateKeyInPem == actualPrivateKeyInPem) { + console.log('Success'); +} else { + console.error('Actual private key is not equals to expected:'); + console.error('expectedPrivateKeyInPem: ' + expectedPrivateKeyInPem); + console.error('actualPrivateKeyInPem: ' + actualPrivateKeyInPem); +} \ No newline at end of file diff --git a/test/fixtures/signal-com-keys/00000001.key b/test/fixtures/signal-com-keys/00000001.key new file mode 100644 index 0000000000000000000000000000000000000000..b78e0f9934fbe562ac32893e30d341800a806fca GIT binary patch literal 168 zcmXqLT*}1AU?9WBrq#;K#3XDW#KsP0DKkPDa*Qn62AWI?ww!N7_SJV>Ni})&y@bKy z`^E#O!XJhQugiID8XhzIe-9HY!=-m~MHhq`1ha8zvoW$Tu8m}3Vl;GRc4lC4`2A_c zn(u3Tk6fC1On#3<|FPYDQpU%5=OnM)ox&N*dL;Y&r2aSi{|g$*+sO7zR$7t$OHRJZ R=y$Hp$y*N>?EAs|835;fKED6} literal 0 HcmV?d00001 diff --git a/test/fixtures/signal-com-keys/kek.opq b/test/fixtures/signal-com-keys/kek.opq new file mode 100644 index 0000000..8a31e09 --- /dev/null +++ b/test/fixtures/signal-com-keys/kek.opq @@ -0,0 +1 @@ +8"6jʬ*1K{TTQ,~Sr \ No newline at end of file diff --git a/test/fixtures/signal-com-keys/masks.db3 b/test/fixtures/signal-com-keys/masks.db3 new file mode 100644 index 0000000..7853893 --- /dev/null +++ b/test/fixtures/signal-com-keys/masks.db3 @@ -0,0 +1 @@ +f63e <Vݔ3ib \ No newline at end of file diff --git a/test/fixtures/signal-com-keys/mk.db3 b/test/fixtures/signal-com-keys/mk.db3 new file mode 100644 index 0000000000000000000000000000000000000000..e8cf007691a4304fcad7962264b7c3da7b470f7d GIT binary patch literal 230 zcmVj9bSfO2WU?eo#6!fs5n7T0>70i=QCxYPohW=wl~sminyYPe<63uTu}|S zzKZ24R173s$q9)Lpk`f=^V!{}cqkkVQ)ZsrydP5D7I2X2*?mCUj1yCo7qlxwN=;Wg grwL^-04ypX|FJndL6WJgqTsn8vM~0oXqq4gcqXuIApigX literal 0 HcmV?d00001 diff --git a/test/fixtures/signal-com-keys/rand.opq b/test/fixtures/signal-com-keys/rand.opq new file mode 100644 index 0000000..4b46f97 --- /dev/null +++ b/test/fixtures/signal-com-keys/rand.opq @@ -0,0 +1,2 @@ +QN +ori9U=i)5K \ No newline at end of file From 4af04bb48314f8046964436fc648e7b2d8afab4d Mon Sep 17 00:00:00 2001 From: Alexander Ustimenko Date: Mon, 12 Dec 2016 13:17:08 +0700 Subject: [PATCH 10/21] Add package.json --- package.json | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 package.json diff --git a/package.json b/package.json new file mode 100644 index 0000000..fd44574 --- /dev/null +++ b/package.json @@ -0,0 +1,35 @@ +{ + "name": "gostcrypto", + "version": "2.0.0", + "homepage": "http://gostcrypto.com/", + "bugs": "https://github.com/rudonick/crypto/issues", + "license": "Apache-2.0", + "author": "Rudolf Nickolaev ", + "contributors": [ + "Alexander Ustimenko (http://ustimen.co/)" + ], + "description": "Pure Javascript implementation of WebCrypto API interfaces and Public Key Infrastructure for GOST algorithms (Russian Cryptographic Standards)", + "main": "./lib", + "bin": { + "gost-export-signalcom-key": "./bin/export-signalcom-key.js" + }, + "repository": "rudonick/crypto", + "keywords": [ + "WebCrypto", + "Public Key Infrastructure", + "PKI", + "Russian Cryptographic Standards", + "GOST", + "SignalCom", + "private key", + "export", + "ASN1", + "cipher", + "digest", + "security", + "viewer" + ], + "dependencies": { + "cli": "^0.4.5" + } +} \ No newline at end of file From 2e5181e0bc6a0741c302b7e80557e989b04d0e9c Mon Sep 17 00:00:00 2001 From: Alexander Ustimenko Date: Mon, 12 Dec 2016 13:22:30 +0700 Subject: [PATCH 11/21] Default ignores --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0c0aa04 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/node_modules/ +/npm-debug.log From 6806e48f89b08a02bd2715a189420244473362ad Mon Sep 17 00:00:00 2001 From: Alexander Ustimenko Date: Mon, 12 Dec 2016 14:17:24 +0700 Subject: [PATCH 12/21] Fix misspell in Uint8Array --- lib/gostCoding.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gostCoding.js b/lib/gostCoding.js index 450682a..b1e5c3e 100644 --- a/lib/gostCoding.js +++ b/lib/gostCoding.js @@ -677,7 +677,7 @@ var bytelen = 0, ba = [], offset = 0; for (var i = k, n = content.length; i < n; i += size - k) { ba[i] = encodeBER({ - object: new Unit8Array(content.buffer, i, Math.min(size - k, n - i)), + object: new Uint8Array(content.buffer, i, Math.min(size - k, n - i)), tagNumber: tagNumber, tagClass: 0, tagConstructed: false From 0f5738a111a69e4edd8a18b30321ed0e92875ca2 Mon Sep 17 00:00:00 2001 From: Alexander Ustimenko Date: Mon, 12 Dec 2016 14:23:10 +0700 Subject: [PATCH 13/21] Add export-signalcom-key utility --- bin/export-signalcom-key.js | 50 +++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 bin/export-signalcom-key.js diff --git a/bin/export-signalcom-key.js b/bin/export-signalcom-key.js new file mode 100755 index 0000000..dd390b1 --- /dev/null +++ b/bin/export-signalcom-key.js @@ -0,0 +1,50 @@ +#!/usr/bin/env node + +const cli = require('cli') + .enable('version') + .setApp(__dirname + '/../package.json') + .setUsage([ + 'gost-export-signalcom-key [OPTIONS]', + ].join('\n')); + +cli.parse({ + pse: ['pse', 'Path to PSE directory, which contains all container files "mk.db3", "masks.db3", "kek.opq", "rand.opq"', 'directory'], + key: ['key', 'Relative to PSE path of private key file like "keys/00000001.key"', 'path', 'keys/00000001.key'], + password: ['password', 'Private key`s password in case if encypted', 'string'] +}); + +if (null == cli.options.pse) { + cli.getUsage(); + cli.exit(2); +} + +const fs = require('fs'), + path = require('path'), + root = path.normalize(cli.options.pse); + +function readCryptoOperationData(relativePath) { + var resultPath = path.join(root, relativePath); + return new Uint8Array(fs.readFileSync(resultPath)).buffer; +} + +require('../lib/gostKeys'); +var gostCrypto = require('../lib/gostCrypto'); + +var keyContainer = new gostCrypto.keys.SignalComPrivateKeyInfo( + readCryptoOperationData(cli.options.key), + { + 'mk.db3': readCryptoOperationData('mk.db3'), + 'masks.db3': readCryptoOperationData('masks.db3'), + 'kek.opq': readCryptoOperationData('kek.opq'), + 'rand.opq': readCryptoOperationData('rand.opq') + } +); + +keyContainer.getKey(cli.options.password).then(function (key) { + encodedKey = key.encode('PEM'); + process.stdout.write(encodedKey + '\n'); + cli.ok('Private SignalCom key successfully exported in STDOUT in "PEM" format.'); +}).catch(function (e) { + console.error(e.message); + console.error(e.trace); +}); From b5533c3b2708d2a74260fa3d56032d2247b629be Mon Sep 17 00:00:00 2001 From: Alexander Ustimenko Date: Fri, 24 Aug 2018 15:01:00 +0700 Subject: [PATCH 14/21] Fix unwrapKeySC splitting of wrapped key from mac --- lib/gostCipher.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/gostCipher.js b/lib/gostCipher.js index 8f6ac6b..e4823b6 100644 --- a/lib/gostCipher.js +++ b/lib/gostCipher.js @@ -1700,10 +1700,10 @@ */ function unwrapKeySC(kek, cek) // { - var m = this.blockSize >> 1, n = this.keySize; + var m = this.blockSize >> 1, n = new Uint8Array(cek).length - m; var k = buffer(kek); var c = buffer(cek); - if (k.byteLength !== n) + if (k.byteLength !== this.keySize) k = unpackKeySC.call(this, k); var enc = new Uint8Array(c, 0, n); // Encrypted kek var mac = new Uint8Array(c, n, m); // MAC for clear kek From 888f94c638decc921f1202b2a461462bc03cb211 Mon Sep 17 00:00:00 2001 From: Alexander Ustimenko Date: Thu, 23 Aug 2018 18:12:16 +0700 Subject: [PATCH 15/21] Extract verifyMACSC and reuse it in unwrapKeySC --- lib/gostCipher.js | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/lib/gostCipher.js b/lib/gostCipher.js index e4823b6..59b50de 100644 --- a/lib/gostCipher.js +++ b/lib/gostCipher.js @@ -1642,23 +1642,28 @@ key[j] ^= mask[j]; } // Test MAC for packKey with default sBox on zero 32 bytes array - var zero32 = new Uint8Array(k); - var test = verifyMAC.call(this, key, mac, zero32); - if (!test) { - // Try to use different sBoxes - var names = ['E-A', 'E-B', 'E-C', 'E-D', 'E-SC']; - for (var i = 0, n = names.length; i < n; i++) { - this.sBox = sBoxes[names[i]]; - test = verifyMAC.call(this, key, mac, zero32); - if (test) - break; - } - } + var test = verifyMACSC.call(this, key, mac, function () { return new Uint8Array(k) }); if (!test) throw new DataError('Invalid main key MAC'); return key.buffer; } // + function verifyMACSC(key, mac, dataCallable) + { + // Use default and then try to use different sBoxes + var names = ['default', 'E-A', 'E-B', 'E-C', 'E-D', 'E-SC']; + for (var i = 0, n = names.length; i < n; i++) { + if (typeof sBoxes[names[i]] !== 'undefined') { + this.sBox = sBoxes[names[i]]; + } + if (verifyMAC.call(this, key, mac, dataCallable.call(this))) { + return true; + } + } + + return false; + } + /** * Algorithm name GOST 28147-SCKW

* @@ -1707,9 +1712,15 @@ k = unpackKeySC.call(this, k); var enc = new Uint8Array(c, 0, n); // Encrypted kek var mac = new Uint8Array(c, n, m); // MAC for clear kek - var d = decryptECB.call(this, k, enc); - if (!verifyMAC.call(this, k, mac, d)) + + var d; + var test = verifyMACSC.call(this, k, mac, function () { + d = decryptECB.call(this, k, enc); + return d; + }); + if (!test) throw new DataError('Invalid key MAC'); + return d; } //
From 1a783b4c8c23a84e8ff72f49da05f64569f9f4d0 Mon Sep 17 00:00:00 2001 From: Alexander Ustimenko Date: Tue, 28 Aug 2018 16:10:13 +0700 Subject: [PATCH 16/21] Upgrade tests and add 2012 keys * Always use promises * Remove rand.opq as it's not used in export * Store actual keys in fixtures also * Add keys prefix to output * Loop over keysPrefixes: 2001 and 2012 --- test/export-signal-com-key.js | 60 +++++++++--------- .../signal-com-keys/{ => 2001}/kek.opq | 0 .../{ => 2001/keys}/00000001.key | Bin .../2001/keys/00000001.key.pem | 4 ++ .../signal-com-keys/{ => 2001}/masks.db3 | 0 .../signal-com-keys/{ => 2001}/mk.db3 | Bin test/fixtures/signal-com-keys/2012/kek.opq | 1 + .../signal-com-keys/2012/keys/00000001.key | Bin 0 -> 116 bytes .../2012/keys/00000001.key.pem | 5 ++ test/fixtures/signal-com-keys/2012/masks.db3 | Bin 0 -> 32 bytes test/fixtures/signal-com-keys/2012/mk.db3 | 1 + test/fixtures/signal-com-keys/rand.opq | 2 - 12 files changed, 40 insertions(+), 33 deletions(-) rename test/fixtures/signal-com-keys/{ => 2001}/kek.opq (100%) rename test/fixtures/signal-com-keys/{ => 2001/keys}/00000001.key (100%) create mode 100644 test/fixtures/signal-com-keys/2001/keys/00000001.key.pem rename test/fixtures/signal-com-keys/{ => 2001}/masks.db3 (100%) rename test/fixtures/signal-com-keys/{ => 2001}/mk.db3 (100%) create mode 100644 test/fixtures/signal-com-keys/2012/kek.opq create mode 100644 test/fixtures/signal-com-keys/2012/keys/00000001.key create mode 100644 test/fixtures/signal-com-keys/2012/keys/00000001.key.pem create mode 100644 test/fixtures/signal-com-keys/2012/masks.db3 create mode 100644 test/fixtures/signal-com-keys/2012/mk.db3 delete mode 100644 test/fixtures/signal-com-keys/rand.opq diff --git a/test/export-signal-com-key.js b/test/export-signal-com-key.js index 50e5b2b..d2d0222 100755 --- a/test/export-signal-com-key.js +++ b/test/export-signal-com-key.js @@ -2,43 +2,41 @@ const fs = require('fs'); -var expectedPrivateKeyInPem = [ - '-----BEGIN PRIVATE KEY-----', - 'MEYCAQAwHQYGKoUDAgITMBMGByqFAwICIwEGCCqFAwcBAQICBCIEIG0GEmE3dhrH', - 'zm1KfFDpKBWEmMydwcmP0hNKvXXbEbLO', - '-----END PRIVATE KEY-----', -].join('\r\n'), - actualPrivateKeyInPem = null; - require('../lib/gostKeys'); var gostCrypto = require('../lib/gostCrypto'); -var keysPrefix = __dirname + '/fixtures/signal-com-keys/'; function readCryptoOperationData(path) { return new Uint8Array(fs.readFileSync(path)).buffer; } -var keyContainer = new gostCrypto.keys.SignalComPrivateKeyInfo( - readCryptoOperationData(keysPrefix + '00000001.key'), - { - 'mk.db3' : readCryptoOperationData(keysPrefix + 'mk.db3'), - 'masks.db3' : readCryptoOperationData(keysPrefix + 'masks.db3'), - 'kek.opq' : readCryptoOperationData(keysPrefix + 'kek.opq'), - 'rand.opq' : readCryptoOperationData(keysPrefix + 'rand.opq') - } -); +[ + __dirname + '/fixtures/signal-com-keys/2001/', + __dirname + '/fixtures/signal-com-keys/2012/', +].forEach(function (keysPrefix) { + var keyContainer = new gostCrypto.keys.SignalComPrivateKeyInfo( + readCryptoOperationData(keysPrefix + 'keys/00000001.key'), + { + 'mk.db3' : readCryptoOperationData(keysPrefix + 'mk.db3'), + 'masks.db3' : readCryptoOperationData(keysPrefix + 'masks.db3'), + 'kek.opq' : readCryptoOperationData(keysPrefix + 'kek.opq') + } + ); -keyContainer.getKey().then(function (key) { - actualPrivateKeyInPem = key.encode('PEM'); -}).catch(function (e) { - console.error(e.message); - console.error(e.trace); -}); + keyContainer.getKey().then(function (key) { + var expectedPrivateKeyInPem = fs.readFileSync(keysPrefix + 'keys/00000001.key.pem'); + var actualPrivateKeyInPem = key.encode('PEM').replace(/\r/g, ''); -if (expectedPrivateKeyInPem == actualPrivateKeyInPem) { - console.log('Success'); -} else { - console.error('Actual private key is not equals to expected:'); - console.error('expectedPrivateKeyInPem: ' + expectedPrivateKeyInPem); - console.error('actualPrivateKeyInPem: ' + actualPrivateKeyInPem); -} \ No newline at end of file + console.log('Keys prefix is', keysPrefix); + if (expectedPrivateKeyInPem == actualPrivateKeyInPem) { + console.log('Success'); + } else { + console.error('Actual private key is not equals to expected:'); + console.error('expectedPrivateKeyInPem: ' + expectedPrivateKeyInPem); + console.error('actualPrivateKeyInPem: ' + actualPrivateKeyInPem); + } + console.log(); + }).catch(function (e) { + console.error(e.message); + console.error(e.trace); + }); +}); diff --git a/test/fixtures/signal-com-keys/kek.opq b/test/fixtures/signal-com-keys/2001/kek.opq similarity index 100% rename from test/fixtures/signal-com-keys/kek.opq rename to test/fixtures/signal-com-keys/2001/kek.opq diff --git a/test/fixtures/signal-com-keys/00000001.key b/test/fixtures/signal-com-keys/2001/keys/00000001.key similarity index 100% rename from test/fixtures/signal-com-keys/00000001.key rename to test/fixtures/signal-com-keys/2001/keys/00000001.key diff --git a/test/fixtures/signal-com-keys/2001/keys/00000001.key.pem b/test/fixtures/signal-com-keys/2001/keys/00000001.key.pem new file mode 100644 index 0000000..5fccf5c --- /dev/null +++ b/test/fixtures/signal-com-keys/2001/keys/00000001.key.pem @@ -0,0 +1,4 @@ +-----BEGIN PRIVATE KEY----- +MEYCAQAwHQYGKoUDAgITMBMGByqFAwICIwEGCCqFAwcBAQICBCIEIG0GEmE3dhrH +zm1KfFDpKBWEmMydwcmP0hNKvXXbEbLO +-----END PRIVATE KEY----- \ No newline at end of file diff --git a/test/fixtures/signal-com-keys/masks.db3 b/test/fixtures/signal-com-keys/2001/masks.db3 similarity index 100% rename from test/fixtures/signal-com-keys/masks.db3 rename to test/fixtures/signal-com-keys/2001/masks.db3 diff --git a/test/fixtures/signal-com-keys/mk.db3 b/test/fixtures/signal-com-keys/2001/mk.db3 similarity index 100% rename from test/fixtures/signal-com-keys/mk.db3 rename to test/fixtures/signal-com-keys/2001/mk.db3 diff --git a/test/fixtures/signal-com-keys/2012/kek.opq b/test/fixtures/signal-com-keys/2012/kek.opq new file mode 100644 index 0000000..286fdc3 --- /dev/null +++ b/test/fixtures/signal-com-keys/2012/kek.opq @@ -0,0 +1 @@ +ަ> 3$t t#T#R$ \ No newline at end of file diff --git a/test/fixtures/signal-com-keys/2012/keys/00000001.key b/test/fixtures/signal-com-keys/2012/keys/00000001.key new file mode 100644 index 0000000000000000000000000000000000000000..6e035df1e60305d2c99ffb3c837dcd42458e5461 GIT binary patch literal 116 zcmXpgVq#=4P-NrKYGr0;WMpJA5M|>8vzZu~7-7Op%q(689!w5wQ@r^-e&?q9d+77( z&3-9*GW5i0mcoT|t`=_5Fxwa;;HIg*?bBqg7q`#HAAPre>k{WTA+x5G&k37+{Dw-q N*KPqOmK60o3jiH0B Date: Tue, 4 Sep 2018 00:24:34 +0700 Subject: [PATCH 17/21] Add export cryptopro key tool (similar to signalcom) * Default of current dir to keys param * Add secondary option * Describe in package.json --- bin/export-cryptopro-key.js | 50 +++++++++++++++++++++++++++++++++++++ package.json | 2 ++ 2 files changed, 52 insertions(+) create mode 100755 bin/export-cryptopro-key.js diff --git a/bin/export-cryptopro-key.js b/bin/export-cryptopro-key.js new file mode 100755 index 0000000..666ea99 --- /dev/null +++ b/bin/export-cryptopro-key.js @@ -0,0 +1,50 @@ +#!/usr/bin/env node + +const cli = require('cli') + .enable('version') + .setApp(__dirname + '/../package.json') + .setUsage([ + 'gost-export-cryptopro-key [OPTIONS]', + ].join('\n')); + +cli.parse({ + keys: ['keys', 'Path to directory with *.key files: header.key masks2.key masks.key name.key primary2.key primary.key', 'directory', '.'], + password: ['password', 'Private key`s password in case if encypted', 'string'], + secondary: ['secondary', 'Extract from secondary keys', 'boolean', false] +}); + +if (null == cli.options.keys) { + cli.getUsage(); + cli.exit(2); +} + +const fs = require('fs'), + path = require('path'), + root = path.normalize(cli.options.keys); + +function readCryptoOperationData(relativePath) { + var resultPath = path.join(root, relativePath); + return new Uint8Array(fs.readFileSync(resultPath)).buffer; +} + +require('../lib/gostKeys'); +var gostCrypto = require('../lib/gostCrypto'); + +var keyContainer = new gostCrypto.keys.CryptoProKeyContainer({ + header: readCryptoOperationData('header.key'), + name: readCryptoOperationData('name.key'), + primary: readCryptoOperationData('primary.key'), + masks: readCryptoOperationData('masks.key'), + primary2: readCryptoOperationData('primary2.key'), + masks2: readCryptoOperationData('masks2.key') +}); + +// Verify key container and password +keyContainer.getKey(cli.options.password, cli.options.secondary).then(function (key) { + process.stdout.write(key.encode('PEM') + '\n'); + + cli.ok('Success: The private key has been exported.'); +}).catch(function (e) { + console.error(e.message); + console.error(e.trace); +}); diff --git a/package.json b/package.json index fd44574..1b7feae 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "description": "Pure Javascript implementation of WebCrypto API interfaces and Public Key Infrastructure for GOST algorithms (Russian Cryptographic Standards)", "main": "./lib", "bin": { + "gost-export-cryptopro-key": "./bin/export-cryptopro-key.js", "gost-export-signalcom-key": "./bin/export-signalcom-key.js" }, "repository": "rudonick/crypto", @@ -21,6 +22,7 @@ "Russian Cryptographic Standards", "GOST", "SignalCom", + "CryptoPro", "private key", "export", "ASN1", From 0640d39a2bd97bbbb8775da99b316522aa2e1cd3 Mon Sep 17 00:00:00 2001 From: Ustimenko Alexander Date: Tue, 4 Sep 2018 03:00:26 +0700 Subject: [PATCH 18/21] Switch default sBox to E-Z when we see modern tc26 algo --- lib/gostKeys.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/gostKeys.js b/lib/gostKeys.js index 7c06039..9b90868 100644 --- a/lib/gostKeys.js +++ b/lib/gostKeys.js @@ -975,6 +975,9 @@ // Decrypt private key function decryptKey(content, primary, masks, keyPassword, secondary) { var algorithm = content.primaryPrivateKeyParameters.privateKeyAlgorithm; + if (algorithm.id.indexOf('tc26') > 0) { + algorithm.encParams = expand({sBox: 'E-Z'}, algorithm.encParams); + } return new Promise(call).then(function () { // Check format if (primary.hmacKey) From c94ce6f3ca7cee056cd1a39043a92182868c2f3f Mon Sep 17 00:00:00 2001 From: Ustimenko Alexander Date: Tue, 4 Sep 2018 22:53:32 +0700 Subject: [PATCH 19/21] Decide which algorithm unwraped key will have by looking into providers --- lib/gostKeys.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/gostKeys.js b/lib/gostKeys.js index 9b90868..0c93116 100644 --- a/lib/gostKeys.js +++ b/lib/gostKeys.js @@ -938,10 +938,18 @@ // Import mask key return subtle.importKey('raw', mask, unwrapAlgorithm, 'false', ['sign', 'unwrapKey']); }).then(function (unwrappingKey) { + // Decide which algorithm unwraped key will have by looking into providers + var unwrappedAlgorithm = algorithm; + for (var p in providers) { + if (providers[p].privateKey.id == algorithm.id) { + unwrappedAlgorithm = expand({}, providers[p].publicKey); + break; + } + } // Unwrap private key return subtle.unwrapKey('raw', wrappedKey, unwrappingKey, - unwrapAlgorithm, algorithm, 'true', ['sign']); + unwrapAlgorithm, unwrappedAlgorithm, 'true', ['sign']); }).then(function (key) { privateKey = key; return computeFP(privateKey); From 042e206a915410d834f70b1668be80208400be2d Mon Sep 17 00:00:00 2001 From: Alexander Ustimenko Date: Wed, 5 Sep 2018 10:47:48 +0700 Subject: [PATCH 20/21] Unify export key tools * Output whole error and exit with code * Add default current directory as container param * Avoid rand.opq when exporting (signalcom) * Optimize cli width and options width look * Use short opts * Output in PEM/DER formats * Make node 0.10.x compatible --- bin/export-cryptopro-key.js | 65 ++++++++++------------------ bin/export-key.js | 84 +++++++++++++++++++++++++++++++++++++ bin/export-signalcom-key.js | 63 +++++++++------------------- 3 files changed, 124 insertions(+), 88 deletions(-) create mode 100644 bin/export-key.js diff --git a/bin/export-cryptopro-key.js b/bin/export-cryptopro-key.js index 666ea99..f16935c 100755 --- a/bin/export-cryptopro-key.js +++ b/bin/export-cryptopro-key.js @@ -1,50 +1,27 @@ #!/usr/bin/env node -const cli = require('cli') - .enable('version') - .setApp(__dirname + '/../package.json') - .setUsage([ - 'gost-export-cryptopro-key [OPTIONS]', - ].join('\n')); - -cli.parse({ - keys: ['keys', 'Path to directory with *.key files: header.key masks2.key masks.key name.key primary2.key primary.key', 'directory', '.'], - password: ['password', 'Private key`s password in case if encypted', 'string'], - secondary: ['secondary', 'Extract from secondary keys', 'boolean', false] -}); - -if (null == cli.options.keys) { - cli.getUsage(); - cli.exit(2); +const ExportKey = require('./export-key'); + +function ExportCryptoProKey() { + ExportKey.call(this); + + this.toolName = 'gost-export-cryptopro-key'; + this.containerKeysFiles = { + 'header': 'header.key', + 'name': 'name.key', + 'primary': 'primary.key', + 'masks': 'masks.key', + 'primary2': 'primary2.key', + 'masks2': 'masks2.key' + }; + this.definedOptions.secondary = ['s', 'Extract from secondary keys', 'boolean', false]; } +require('util').inherits(ExportCryptoProKey, ExportKey); -const fs = require('fs'), - path = require('path'), - root = path.normalize(cli.options.keys); - -function readCryptoOperationData(relativePath) { - var resultPath = path.join(root, relativePath); - return new Uint8Array(fs.readFileSync(resultPath)).buffer; +ExportCryptoProKey.prototype.keyPromise = function keyPromise() { + return new this.gostCrypto.keys.CryptoProKeyContainer( + this.containerKeys() + ).getKey(this.parsedOptions.password, this.parsedOptions.secondary); } -require('../lib/gostKeys'); -var gostCrypto = require('../lib/gostCrypto'); - -var keyContainer = new gostCrypto.keys.CryptoProKeyContainer({ - header: readCryptoOperationData('header.key'), - name: readCryptoOperationData('name.key'), - primary: readCryptoOperationData('primary.key'), - masks: readCryptoOperationData('masks.key'), - primary2: readCryptoOperationData('primary2.key'), - masks2: readCryptoOperationData('masks2.key') -}); - -// Verify key container and password -keyContainer.getKey(cli.options.password, cli.options.secondary).then(function (key) { - process.stdout.write(key.encode('PEM') + '\n'); - - cli.ok('Success: The private key has been exported.'); -}).catch(function (e) { - console.error(e.message); - console.error(e.trace); -}); +new ExportCryptoProKey().run(); diff --git a/bin/export-key.js b/bin/export-key.js new file mode 100644 index 0000000..1f3f2ce --- /dev/null +++ b/bin/export-key.js @@ -0,0 +1,84 @@ +module.exports = ExportKey + +require('../lib/gostKeys'); +const gostCrypto = require('../lib/gostCrypto'); + +function ExportKey() { + this.toolName = undefined; + this.containerKeysFiles = undefined; + this.definedOptions = { + container: ['c', 'Path to directory with container files', 'directory', '.'], + password: ['p', 'Private key`s password in case if encypted', 'string'], + format: ['f', 'Export format', ['PEM', 'DER'], 'PEM'] + }; + this.gostCrypto = gostCrypto; + this.parsedOptions = {}; +} + +ExportKey.prototype.run = function run() { + const cli = this.createCli(); + + this.parsedOptions = cli.options; + + const format = this.parsedOptions.format; + this.keyPromise().then(function (key) { + var encodedKey = key.encode(format); + if ('PEM' == format) { + encodedKey += '\n'; + } else if ('DER' == format) { + encodedKey = new Buffer(new Uint8Array(encodedKey)); + } + process.stdout.write(encodedKey); + + cli.ok('Private key successfully exported in STDOUT in "'+format+'" format.'); + }).catch(function (e) { + cli.fatal(e.stack); + }); +} + +ExportKey.prototype.createCli = function createCli() { + const cli = require('cli') + .enable('version') + .setApp(__dirname + '/../package.json') + .setUsage(this.toolName+' [OPTIONS]'); + + var containerFiles = []; + for (var key in this.containerKeysFiles) { + containerFiles.push('"'+this.containerKeysFiles[key]+'"'); + } + this.definedOptions.container[1] += ' '+containerFiles.join(', '); + + cli.width = 120; + cli.option_width = 30; + cli.parse(this.definedOptions); + + if (null == cli.options.container) { + cli.getUsage(); + cli.exit(2); + } + + return cli; +} + +ExportKey.prototype.keyPromise = function keyPromise() { + throw new Error('Unimplemented method keyPromise') +} + +ExportKey.prototype.containerKeys = function containerKeys() { + var result = {}; + for (var key in this.containerKeysFiles) { + result[key] = this.readKey(this.containerKeysFiles[key]); + } + + return result; +} + +const fs = require('fs'), + path = require('path'); + +ExportKey.prototype.readKey = function readKey(relativePath) { + const root = path.normalize(this.parsedOptions.container), + resultPath = path.join(root, relativePath); + + return new Uint8Array(fs.readFileSync(resultPath)).buffer; +} diff --git a/bin/export-signalcom-key.js b/bin/export-signalcom-key.js index dd390b1..f8795f5 100755 --- a/bin/export-signalcom-key.js +++ b/bin/export-signalcom-key.js @@ -1,50 +1,25 @@ #!/usr/bin/env node -const cli = require('cli') - .enable('version') - .setApp(__dirname + '/../package.json') - .setUsage([ - 'gost-export-signalcom-key [OPTIONS]', - ].join('\n')); - -cli.parse({ - pse: ['pse', 'Path to PSE directory, which contains all container files "mk.db3", "masks.db3", "kek.opq", "rand.opq"', 'directory'], - key: ['key', 'Relative to PSE path of private key file like "keys/00000001.key"', 'path', 'keys/00000001.key'], - password: ['password', 'Private key`s password in case if encypted', 'string'] -}); - -if (null == cli.options.pse) { - cli.getUsage(); - cli.exit(2); +const ExportKey = require('./export-key'); + +function ExportSignalComKey() { + ExportKey.call(this); + + this.toolName = 'gost-export-signalcom-key'; + this.containerKeysFiles = { + 'mk.db3': 'mk.db3', + 'masks.db3': 'masks.db3', + 'kek.opq': 'kek.opq' + }; + this.definedOptions.key = ['k', 'Path to private key (relative to container)', 'path', 'keys/00000001.key']; } +require('util').inherits(ExportSignalComKey, ExportKey); -const fs = require('fs'), - path = require('path'), - root = path.normalize(cli.options.pse); - -function readCryptoOperationData(relativePath) { - var resultPath = path.join(root, relativePath); - return new Uint8Array(fs.readFileSync(resultPath)).buffer; +ExportSignalComKey.prototype.keyPromise = function keyPromise() { + return new this.gostCrypto.keys.SignalComPrivateKeyInfo( + this.readKey(this.parsedOptions.key), + this.containerKeys() + ).getKey(this.parsedOptions.password); } -require('../lib/gostKeys'); -var gostCrypto = require('../lib/gostCrypto'); - -var keyContainer = new gostCrypto.keys.SignalComPrivateKeyInfo( - readCryptoOperationData(cli.options.key), - { - 'mk.db3': readCryptoOperationData('mk.db3'), - 'masks.db3': readCryptoOperationData('masks.db3'), - 'kek.opq': readCryptoOperationData('kek.opq'), - 'rand.opq': readCryptoOperationData('rand.opq') - } -); - -keyContainer.getKey(cli.options.password).then(function (key) { - encodedKey = key.encode('PEM'); - process.stdout.write(encodedKey + '\n'); - cli.ok('Private SignalCom key successfully exported in STDOUT in "PEM" format.'); -}).catch(function (e) { - console.error(e.message); - console.error(e.trace); -}); +new ExportSignalComKey().run(); From 442a972e7d432a267a99be6ff2a34d4432a2b3b4 Mon Sep 17 00:00:00 2001 From: Alexander Ustimenko Date: Thu, 6 Sep 2018 11:58:20 +0700 Subject: [PATCH 21/21] Bump version to 2.1.0 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 1b7feae..7db1a3f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gostcrypto", - "version": "2.0.0", + "version": "2.1.0", "homepage": "http://gostcrypto.com/", "bugs": "https://github.com/rudonick/crypto/issues", "license": "Apache-2.0", @@ -34,4 +34,4 @@ "dependencies": { "cli": "^0.4.5" } -} \ No newline at end of file +}