forked from kjur/jsrsasign
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasn1ocsp-1.0.min.js
3 lines (3 loc) · 4.99 KB
/
asn1ocsp-1.0.min.js
1
2
3
/*! asn1ocsp-1.0.1.js (c) 2016 Kenji Urushima | kjur.github.com/jsrsasign/license
*/
if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.asn1=="undefined"||!KJUR.asn1){KJUR.asn1={}}if(typeof KJUR.asn1.ocsp=="undefined"||!KJUR.asn1.ocsp){KJUR.asn1.ocsp={}}KJUR.asn1.ocsp.DEFAULT_HASH="sha1";KJUR.asn1.ocsp.CertID=function(c){KJUR.asn1.ocsp.CertID.superclass.constructor.call(this);var a=KJUR.asn1;var e=KJUR.asn1.x509;this.dHashAlg=null;this.dIssuerNameHash=null;this.dIssuerKeyHash=null;this.dSerialNumber=null;this.setByValue=function(i,h,f,g){if(g===undefined){g=KJUR.asn1.ocsp.DEFAULT_HASH}this.dHashAlg=new e.AlgorithmIdentifier({name:g});this.dIssuerNameHash=new a.DEROctetString({hex:i});this.dIssuerKeyHash=new a.DEROctetString({hex:h});this.dSerialNumber=new a.DERInteger({hex:f})};this.setByCert=function(m,i,k){if(k===undefined){k=KJUR.asn1.ocsp.DEFAULT_HASH}var f=new X509();f.readCertPEM(i);var n=new X509();n.readCertPEM(m);var o=X509.getPublicKeyInfoPropOfCertPEM(m);var l=o.keyhex;var g=f.getSerialNumberHex();var h=KJUR.crypto.Util.hashHex(n.getSubjectHex(),k);var j=KJUR.crypto.Util.hashHex(l,k);this.setByValue(h,j,g,k);this.hoge=f.getSerialNumberHex()};this.getEncodedHex=function(){if(this.dHashAlg===null&&this.dIssuerNameHash===null&&this.dIssuerKeyHash===null&&this.dSerialNumber===null){throw"not yet set values"}var f=[this.dHashAlg,this.dIssuerNameHash,this.dIssuerKeyHash,this.dSerialNumber];var g=new a.DERSequence({array:f});this.hTLV=g.getEncodedHex();return this.hTLV};if(typeof c!=="undefined"){var b=c;if(typeof b.issuerCert!=="undefined"&&typeof b.subjectCert!=="undefined"){var d=KJUR.asn1.ocsp.DEFAULT_HASH;if(typeof b.alg==="undefined"){d=undefined}this.setByCert(b.issuerCert,b.subjectCert,d)}else{if(typeof b.namehash!=="undefined"&&typeof b.keyhash!=="undefined"&&typeof b.serial!=="undefined"){var d=KJUR.asn1.ocsp.DEFAULT_HASH;if(typeof b.alg==="undefined"){d=undefined}this.setByValue(b.namehash,b.keyhash,b.serial,d)}else{throw"invalid constructor arguments"}}}};YAHOO.lang.extend(KJUR.asn1.ocsp.CertID,KJUR.asn1.ASN1Object);KJUR.asn1.ocsp.Request=function(b){KJUR.asn1.ocsp.Request.superclass.constructor.call(this);this.dReqCert=null;this.dExt=null;this.getEncodedHex=function(){var c=[];if(this.dReqCert===null){throw"reqCert not set"}c.push(this.dReqCert);var d=new KJUR.asn1.DERSequence({array:c});this.hTLV=d.getEncodedHex();return this.hTLV};if(typeof b!=="undefined"){var a=new KJUR.asn1.ocsp.CertID(b);this.dReqCert=a}};YAHOO.lang.extend(KJUR.asn1.ocsp.Request,KJUR.asn1.ASN1Object);KJUR.asn1.ocsp.TBSRequest=function(a){KJUR.asn1.ocsp.TBSRequest.superclass.constructor.call(this);this.version=0;this.dRequestorName=null;this.dRequestList=[];this.dRequestExt=null;this.setRequestListByParam=function(d){var b=[];for(var c=0;c<d.length;c++){var e=new KJUR.asn1.ocsp.Request(d[0]);b.push(e)}this.dRequestList=b};this.getEncodedHex=function(){var b=[];if(this.version!==0){throw"not supported version: "+this.version}if(this.dRequestorName!==null){throw"requestorName not supported"}var d=new KJUR.asn1.DERSequence({array:this.dRequestList});b.push(d);if(this.dRequestExt!==null){throw"requestExtensions not supported"}var c=new KJUR.asn1.DERSequence({array:b});this.hTLV=c.getEncodedHex();return this.hTLV};if(typeof a!=="undefined"){if(typeof a.reqList!=="undefined"){this.setRequestListByParam(a.reqList)}}};YAHOO.lang.extend(KJUR.asn1.ocsp.TBSRequest,KJUR.asn1.ASN1Object);KJUR.asn1.ocsp.OCSPRequest=function(b){KJUR.asn1.ocsp.OCSPRequest.superclass.constructor.call(this);this.dTbsRequest=null;this.dOptionalSignature=null;this.getEncodedHex=function(){var c=[];if(this.dTbsRequest!==null){c.push(this.dTbsRequest)}else{throw"tbsRequest not set"}if(this.dOptionalSignature!==null){throw"optionalSignature not supported"}var d=new KJUR.asn1.DERSequence({array:c});this.hTLV=d.getEncodedHex();return this.hTLV};if(typeof b!=="undefined"){if(typeof b.reqList!=="undefined"){var a=new KJUR.asn1.ocsp.TBSRequest(b);this.dTbsRequest=a}}};YAHOO.lang.extend(KJUR.asn1.ocsp.OCSPRequest,KJUR.asn1.ASN1Object);KJUR.asn1.ocsp.OCSPUtil={};KJUR.asn1.ocsp.OCSPUtil.getRequestHex=function(a,b,e){if(e===undefined){e=KJUR.asn1.ocsp.DEFAULT_HASH}var d={alg:e,issuerCert:a,subjectCert:b};var c=new KJUR.asn1.ocsp.OCSPRequest({reqList:[d]});return c.getEncodedHex()};KJUR.asn1.ocsp.OCSPUtil.getOCSPResponseInfo=function(f){var a={};try{var b=ASN1HEX.getVbyList(f,0,[0],"0a");a.responseStatus=parseInt(b,16)}catch(d){}if(a.responseStatus!==0){return a}try{var e=ASN1HEX.getDecendantIndexByNthList(f,0,[1,0,1,0,0,2,0,1]);if(f.substr(e,2)==="80"){a.certStatus="good"}else{if(f.substr(e,2)==="a1"){a.certStatus="revoked";a.revocationTime=hextoutf8(ASN1HEX.getDecendantHexVByNthList(f,e,[0]))}else{if(f.substr(e,2)==="82"){a.certStatus="unknown"}}}}catch(d){}try{var c=ASN1HEX.getDecendantIndexByNthList(f,0,[1,0,1,0,0,2,0,2]);a.thisUpdate=hextoutf8(ASN1HEX.getHexOfV_AtObj(f,c))}catch(d){}try{var g=ASN1HEX.getDecendantIndexByNthList(f,0,[1,0,1,0,0,2,0,3]);if(f.substr(g,2)==="a0"){a.nextUpdate=hextoutf8(ASN1HEX.getDecendantHexVByNthList(f,g,[0]))}}catch(d){}return a};