6/18/ds/daozhang/drpy_libs/node-rsa.js

2 lines
164 KiB
JavaScript
Raw Normal View History

2024-07-12 09:44:07 +03:00
/*! For license information please see node-rsa.bundle.js.LICENSE.txt */
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.NODERSA=e():t.NODERSA=e()}(globalThis,(()=>(()=>{var t={6395:t=>{t.exports={newInvalidAsn1Error:function(t){var e=new Error;return e.name="InvalidAsn1Error",e.message=t||"",e}}},5670:(t,e,r)=>{var n=r(6395),i=r(6299),o=r(3319),s=r(1431);for(var a in t.exports={Reader:o,Writer:s},i)i.hasOwnProperty(a)&&(t.exports[a]=i[a]);for(var f in n)n.hasOwnProperty(f)&&(t.exports[f]=n[f])},3319:(t,e,r)=>{var n=r(4529),i=r(4774).Buffer,o=r(6299),s=r(6395).newInvalidAsn1Error;function a(t){if(!t||!i.isBuffer(t))throw new TypeError("data must be a node Buffer");this._buf=t,this._size=t.length,this._len=0,this._offset=0}Object.defineProperty(a.prototype,"length",{enumerable:!0,get:function(){return this._len}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){return this._offset}}),Object.defineProperty(a.prototype,"remain",{get:function(){return this._size-this._offset}}),Object.defineProperty(a.prototype,"buffer",{get:function(){return this._buf.slice(this._offset)}}),a.prototype.readByte=function(t){if(this._size-this._offset<1)return null;var e=255&this._buf[this._offset];return t||(this._offset+=1),e},a.prototype.peek=function(){return this.readByte(!0)},a.prototype.readLength=function(t){if(void 0===t&&(t=this._offset),t>=this._size)return null;var e=255&this._buf[t++];if(null===e)return null;if(128&~e)this._len=e;else{if(0==(e&=127))throw s("Indefinite length not supported");if(e>4)throw s("encoding too long");if(this._size-t<e)return null;this._len=0;for(var r=0;r<e;r++)this._len=(this._len<<8)+(255&this._buf[t++])}return t},a.prototype.readSequence=function(t){var e=this.peek();if(null===e)return null;if(void 0!==t&&t!==e)throw s("Expected 0x"+t.toString(16)+": got 0x"+e.toString(16));var r=this.readLength(this._offset+1);return null===r?null:(this._offset=r,e)},a.prototype.readInt=function(){return this._readTag(o.Integer)},a.prototype.readBoolean=function(){return 0!==this._readTag(o.Boolean)},a.prototype.readEnumeration=function(){return this._readTag(o.Enumeration)},a.prototype.readString=function(t,e){t||(t=o.OctetString);var r=this.peek();if(null===r)return null;if(r!==t)throw s("Expected 0x"+t.toString(16)+": got 0x"+r.toString(16));var n=this.readLength(this._offset+1);if(null===n)return null;if(this.length>this._size-n)return null;if(this._offset=n,0===this.length)return e?i.alloc(0):"";var a=this._buf.slice(this._offset,this._offset+this.length);return this._offset+=this.length,e?a:a.toString("utf8")},a.prototype.readOID=function(t){t||(t=o.OID);var e=this.readString(t,!0);if(null===e)return null;for(var r=[],n=0,i=0;i<e.length;i++){var s=255&e[i];n<<=7,n+=127&s,128&s||(r.push(n),n=0)}return n=r.shift(),r.unshift(n%40),r.unshift(n/40|0),r.join(".")},a.prototype._readTag=function(t){n.ok(void 0!==t);var e=this.peek();if(null===e)return null;if(e!==t)throw s("Expected 0x"+t.toString(16)+": got 0x"+e.toString(16));var r=this.readLength(this._offset+1);if(null===r)return null;if(this.length>4)throw s("Integer too long: "+this.length);if(this.length>this._size-r)return null;this._offset=r;for(var i=this._buf[this._offset],o=0,a=0;a<this.length;a++)o<<=8,o|=255&this._buf[this._offset++];return 128&~i||4===a||(o-=1<<8*a),0|o},t.exports=a},6299:t=>{t.exports={EOC:0,Boolean:1,Integer:2,BitString:3,OctetString:4,Null:5,OID:6,ObjectDescriptor:7,External:8,Real:9,Enumeration:10,PDV:11,Utf8String:12,RelativeOID:13,Sequence:16,Set:17,NumericString:18,PrintableString:19,T61String:20,VideotexString:21,IA5String:22,UTCTime:23,GeneralizedTime:24,GraphicString:25,VisibleString:26,GeneralString:28,UniversalString:29,CharacterString:30,BMPString:31,Constructor:32,Context:128}},1431:(t,e,r)=>{var n=r(4529),i=r(4774).Buffer,o=r(6299),s=r(6395).newInvalidAsn1Error,a={size:1024,growthFactor:8};function f(t){var e,r;e=a,r=t||{},n.ok(e),n.equal(typeof e,"object"),n.ok(r),n.equal(typeof r,"object"),Object.getOwnPropertyNames(e).forEach((function(t){if(!r[t]