(function(){function t(e){var k=e.jsustoolkitErrCode=e.jsustoolkitErrCode||{},a=e.asn1,l=e.pkcs7=e.pkcs7||{};l.messageFromPem=function(b){if(null==c||"undefined"==typeof c)throw{code:"113001",message:k["113001"]};b=e.pki.pemToDer(b);var c=a.fromDer(b);return l.messageFromAsn1(c)};l.messageToPem=function(b,c){if(null==b||"undefined"==typeof b)throw{code:"113002",message:k["113002"]};b=a.toDer(b.toAsn1());b=e.util.encode64(b.getBytes(),c||64);return"-----BEGIN PKCS7-----\r\n"+b+"\r\n-----END PKCS7-----"};l.messageFromBase64=function(b){if(null==b||"undefined"==typeof b)throw{code:"113003",message:k["113003"]};b=e.pki.base64ToDer(b);b=a.fromDer(b);return l.messageFromAsn1(b)};l.messageToBase64=function(b){if(null==b||"undefined"==typeof b)throw{code:"113004",message:k["113004"]};b=a.toDer(b.toAsn1());return e.util.encode64(b.getBytes())};l.messageFromAsn1=function(b){if(null==b||"undefined"==typeof b)throw{code:"113005",message:k["113005"]};var c={},d=[];if(!a.validate(b,l.asn1.contentInfoValidator,c,d))throw{code:"113006",message:k["113006"],errors:d};b=a.derToOid(c.contentType);switch(b){case e.pki.oids.envelopedData:b=l.createEnvelopedData();break;case e.pki.oids.encryptedData:b=l.createEncryptedData();break;case e.pki.oids.signedData:b=l.createSignedData();break;default:throw{code:"113007",message:k["113007"]+"("+b+")"};}b.fromAsn1(c.content.value[0]);return b};var p=function(b){var c={},d=[];if(!a.validate(b,l.asn1.recipientInfoValidator,c,d))throw{code:"113008",message:k["113008"],errors:d};return{version:c.version.charCodeAt(0),issuer:e.pki.RDNAttributesAsArray(c.issuer),serialNumber:e.util.createBuffer(c.serial).toHex(),encContent:{algorithm:a.derToOid(c.encAlgorithm),parameter:c.encParameter.value,content:c.encKey}}},r=function(b){return a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,String.fromCharCode(b.version)),a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[e.pki.distinguishedNameToAsn1({attributes:b.issuer}),a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,e.util.hexToBytes(b.serialNumber))]),a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.OID,!1,a.oidToDer(b.encContent.algorithm).getBytes()),a.create(a.Class.UNIVERSAL,a.Type.NULL,!1,"")]),a.create(a.Class.UNIVERSAL,a.Type.OCTETSTRING,!1,b.encContent.content)])},t=function(a){for(var b=[],d=0;d