/*! asn1csr-1.0.0.js (c) 2015 Kenji Urushima | kjur.github.com/jsrsasign/license */ if(typeof KJUR.asn1.csr=="undefined"||!KJUR.asn1.csr){KJUR.asn1.csr={}}KJUR.asn1.csr.CertificationRequest=function(f){KJUR.asn1.csr.CertificationRequest.superclass.constructor.call(this);var b=null;var d=null;var e=null;var c=null;var a=null;this.sign=function(i,h){if(this.prvKey==null){this.prvKey=h}this.asn1SignatureAlg=new KJUR.asn1.x509.AlgorithmIdentifier({name:i});sig=new KJUR.crypto.Signature({alg:i});sig.initSign(this.prvKey);sig.updateHex(this.asn1CSRInfo.getEncodedHex());this.hexSig=sig.sign();this.asn1Sig=new KJUR.asn1.DERBitString({hex:"00"+this.hexSig});var g=new KJUR.asn1.DERSequence({array:[this.asn1CSRInfo,this.asn1SignatureAlg,this.asn1Sig]});this.hTLV=g.getEncodedHex();this.isModified=false};this.getPEMString=function(){var g=KJUR.asn1.ASN1Util.getPEMStringFromHex(this.getEncodedHex(),"CERTIFICATE REQUEST");return g};this.getEncodedHex=function(){if(this.isModified==false&&this.hTLV!=null){return this.hTLV}throw"not signed yet"};if(typeof f!="undefined"){if(typeof f.csrinfo!="undefined"){this.asn1CSRInfo=f.csrinfo}}};YAHOO.lang.extend(KJUR.asn1.csr.CertificationRequest,KJUR.asn1.ASN1Object);KJUR.asn1.csr.CertificationRequestInfo=function(a){KJUR.asn1.csr.CertificationRequestInfo.superclass.constructor.call(this);this._initialize=function(){this.asn1Array=new Array();this.asn1Version=new KJUR.asn1.DERInteger({"int":0});this.asn1Subject=null;this.asn1SubjPKey=null;this.extensionsArray=new Array()};this.setSubjectByParam=function(b){this.asn1Subject=new KJUR.asn1.x509.X500Name(b)};this.setSubjectPublicKeyByGetKey=function(c){var b=KEYUTIL.getKey(c);this.asn1SubjPKey=new KJUR.asn1.x509.SubjectPublicKeyInfo(b)};this.getEncodedHex=function(){this.asn1Array=new Array();this.asn1Array.push(this.asn1Version);this.asn1Array.push(this.asn1Subject);this.asn1Array.push(this.asn1SubjPKey);var c=new KJUR.asn1.DERSequence({array:this.extensionsArray});var b=new KJUR.asn1.DERTaggedObject({explicit:false,tag:"a0",obj:c});this.asn1Array.push(b);var d=new KJUR.asn1.DERSequence({array:this.asn1Array});this.hTLV=d.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize()};YAHOO.lang.extend(KJUR.asn1.csr.CertificationRequestInfo,KJUR.asn1.ASN1Object);KJUR.asn1.csr.CSRUtil=new function(){};KJUR.asn1.csr.CSRUtil.newCSRPEM=function(f){var c=KJUR.asn1.csr;if(f.subject===undefined){throw"parameter subject undefined"}if(f.sbjpubkey===undefined){throw"parameter sbjpubkey undefined"}if(f.sigalg===undefined){throw"parameter sigalg undefined"}if(f.sbjprvkey===undefined){throw"parameter sbjpubkey undefined"}var b=new c.CertificationRequestInfo();b.setSubjectByParam(f.subject);b.setSubjectPublicKeyByGetKey(f.sbjpubkey);var d=new c.CertificationRequest({csrinfo:b});var a=KEYUTIL.getKey(f.sbjprvkey);d.sign(f.sigalg,a);var e=d.getPEMString();return e};