mirror of
https://github.com/moparisthebest/mailiverse
synced 2024-11-06 17:35:04 -05:00
3 lines
2.7 KiB
JavaScript
3 lines
2.7 KiB
JavaScript
/*! asn1hex-1.1.js (c) 2012 Kenji Urushima | kjur.github.com/jsrsasign/license
|
|
*/
|
|
function _asnhex_getByteLengthOfL_AtObj(b,c){if(b.substring(c+2,c+3)!="8"){return 1}var a=parseInt(b.substring(c+3,c+4));if(a==0){return -1}if(0<a&&a<10){return a+1}return -2}function _asnhex_getHexOfL_AtObj(b,c){var a=_asnhex_getByteLengthOfL_AtObj(b,c);if(a<1){return""}return b.substring(c+2,c+2+a*2)}function _asnhex_getIntOfL_AtObj(c,d){var b=_asnhex_getHexOfL_AtObj(c,d);if(b==""){return -1}var a;if(parseInt(b.substring(0,1))<8){a=parseBigInt(b,16)}else{a=parseBigInt(b.substring(2),16)}return a.intValue()}function _asnhex_getStartPosOfV_AtObj(b,c){var a=_asnhex_getByteLengthOfL_AtObj(b,c);if(a<0){return a}return c+(a+1)*2}function _asnhex_getHexOfV_AtObj(c,d){var b=_asnhex_getStartPosOfV_AtObj(c,d);var a=_asnhex_getIntOfL_AtObj(c,d);return c.substring(b,b+a*2)}function _asnhex_getHexOfTLV_AtObj(c,e){var b=c.substr(e,2);var d=_asnhex_getHexOfL_AtObj(c,e);var a=_asnhex_getHexOfV_AtObj(c,e);return b+d+a}function _asnhex_getPosOfNextSibling_AtObj(c,d){var b=_asnhex_getStartPosOfV_AtObj(c,d);var a=_asnhex_getIntOfL_AtObj(c,d);return b+a*2}function _asnhex_getPosArrayOfChildren_AtObj(f,j){var c=new Array();var i=_asnhex_getStartPosOfV_AtObj(f,j);c.push(i);var b=_asnhex_getIntOfL_AtObj(f,j);var g=i;var d=0;while(1){var e=_asnhex_getPosOfNextSibling_AtObj(f,g);if(e==null||(e-i>=(b*2))){break}if(d>=200){break}c.push(e);g=e;d++}return c}function _asnhex_getNthChildIndex_AtObj(d,b,e){var c=_asnhex_getPosArrayOfChildren_AtObj(d,b);return c[e]}function _asnhex_getDecendantIndexByNthList(e,d,c){if(c.length==0){return d}var f=c.shift();var b=_asnhex_getPosArrayOfChildren_AtObj(e,d);return _asnhex_getDecendantIndexByNthList(e,b[f],c)}function _asnhex_getDecendantHexTLVByNthList(d,c,b){var a=_asnhex_getDecendantIndexByNthList(d,c,b);return _asnhex_getHexOfTLV_AtObj(d,a)}function _asnhex_getDecendantHexVByNthList(d,c,b){var a=_asnhex_getDecendantIndexByNthList(d,c,b);return _asnhex_getHexOfV_AtObj(d,a)}function ASN1HEX(){return ASN1HEX}ASN1HEX.getByteLengthOfL_AtObj=_asnhex_getByteLengthOfL_AtObj;ASN1HEX.getHexOfL_AtObj=_asnhex_getHexOfL_AtObj;ASN1HEX.getIntOfL_AtObj=_asnhex_getIntOfL_AtObj;ASN1HEX.getStartPosOfV_AtObj=_asnhex_getStartPosOfV_AtObj;ASN1HEX.getHexOfV_AtObj=_asnhex_getHexOfV_AtObj;ASN1HEX.getHexOfTLV_AtObj=_asnhex_getHexOfTLV_AtObj;ASN1HEX.getPosOfNextSibling_AtObj=_asnhex_getPosOfNextSibling_AtObj;ASN1HEX.getPosArrayOfChildren_AtObj=_asnhex_getPosArrayOfChildren_AtObj;ASN1HEX.getNthChildIndex_AtObj=_asnhex_getNthChildIndex_AtObj;ASN1HEX.getDecendantIndexByNthList=_asnhex_getDecendantIndexByNthList;ASN1HEX.getDecendantHexVByNthList=_asnhex_getDecendantHexVByNthList;ASN1HEX.getDecendantHexTLVByNthList=_asnhex_getDecendantHexTLVByNthList; |