web_modules/forge.bundle.js
function _signerToAsn1(obj) {
  // SignerInfo
  var rval = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
    // version
    asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
      asn1.integerToDer(obj.version).getBytes()),
    // issuerAndSerialNumber
    asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
      // name
      forge.pki.distinguishedNameToAsn1({attributes: obj.issuer}),
      // serial
      asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
        forge.util.hexToBytes(obj.serialNumber))
    ]),
    // digestAlgorithm
    asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
      // algorithm
      asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
        asn1.oidToDer(obj.digestAlgorithm).getBytes()),
      // parameters (null)
      asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')
    ])
  ]);

  // authenticatedAttributes (OPTIONAL)
  if(obj.authenticatedAttributesAsn1) {
    // add ASN.1 previously generated during signing
    rval.value.push(obj.authenticatedAttributesAsn1);
  }

  // digestEncryptionAlgorithm
  rval.value.push(asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
    // algorithm
    asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
      asn1.oidToDer(obj.signatureAlgorithm).getBytes()),
    // parameters (null)
    asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')
  ]));

  // encryptedDigest
  rval.value.push(asn1.create(
    asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, obj.signature));

  // unauthenticatedAttributes (OPTIONAL)
  if(obj.unauthenticatedAttributes.length > 0) {
    // [1] IMPLICIT
    var attrsAsn1 = asn1.create(asn1.Class.CONTEXT_SPECIFIC, 1, true, []);
    for(var i = 0; i < obj.unauthenticatedAttributes.length; ++i) {
      var attr = obj.unauthenticatedAttributes[i];
      attrsAsn1.values.push(_attributeToAsn1(attr));
    }
    rval.value.push(attrsAsn1);
  }

  return rval;
}
function _signerToAsn1(obj) {
  // SignerInfo
  var rval = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
    // version
    asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
      asn1.integerToDer(obj.version).getBytes()),
    // issuerAndSerialNumber
    asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
      // name
      forge.pki.distinguishedNameToAsn1({attributes: obj.issuer}),
      // serial
      asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
        forge.util.hexToBytes(obj.serialNumber))
    ]),
    // digestAlgorithm
    asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
      // algorithm
      asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
        asn1.oidToDer(obj.digestAlgorithm).getBytes()),
      // parameters (null)
      asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')
    ])
  ]);

  // authenticatedAttributes (OPTIONAL)
  if(obj.authenticatedAttributesAsn1) {
    // add ASN.1 previously generated during signing
    rval.value.push(obj.authenticatedAttributesAsn1);
  }

  // digestEncryptionAlgorithm
  rval.value.push(asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
    // algorithm
    asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
      asn1.oidToDer(obj.signatureAlgorithm).getBytes()),
    // parameters (null)
    asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')
  ]));

  // encryptedDigest
  rval.value.push(asn1.create(
    asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, obj.signature));

  // unauthenticatedAttributes (OPTIONAL)
  if(obj.unauthenticatedAttributes.length > 0) {
    // [1] IMPLICIT
    var attrsAsn1 = asn1.create(asn1.Class.CONTEXT_SPECIFIC, 1, true, []);
    for(var i = 0; i < obj.unauthenticatedAttributes.length; ++i) {
      var attr = obj.unauthenticatedAttributes[i];
      attrsAsn1.values.push(_attributeToAsn1(attr));
    }
    rval.value.push(attrsAsn1);
  }

  return rval;
}
function _signerToAsn1 ( obj ) { // SignerInfo
 var rval = asn1 . create ( asn1 . Class . UNIVERSAL , asn1 . Type . SEQUENCE , true , [ // version
 asn1 . create ( asn1 . Class . UNIVERSAL , asn1 . Type . INTEGER , false , asn1 . integerToDer ( obj . version ) . getBytes ( ) ) , // issuerAndSerialNumber
 asn1 . create ( asn1 . Class . UNIVERSAL , asn1 . Type . SEQUENCE , true , [ // name
 forge . pki . distinguishedNameToAsn1 ( { attributes : obj . issuer } ) , // serial
 asn1 . create ( asn1 . Class . UNIVERSAL , asn1 . Type . INTEGER , false , forge . util . hexToBytes ( obj . serialNumber ) ) ] ) , // digestAlgorithm
 asn1 . create ( asn1 . Class . UNIVERSAL , asn1 . Type . SEQUENCE , true , [ // algorithm
 asn1 . create ( asn1 . Class . UNIVERSAL , asn1 . Type . OID , false , asn1 . oidToDer ( obj . digestAlgorithm ) . getBytes ( ) ) , // parameters (null)
 asn1 . create ( asn1 . Class . UNIVERSAL , asn1 . Type . NULL , false , '' ) ] ) ] ) ; // authenticatedAttributes (OPTIONAL)
 if ( obj . authenticatedAttributesAsn1 ) { // add ASN.1 previously generated during signing
 rval . value . push ( obj . authenticatedAttributesAsn1 ) ; } // digestEncryptionAlgorithm
 rval . value . push ( asn1 . create ( asn1 . Class . UNIVERSAL , asn1 . Type . SEQUENCE , true , [ // algorithm
 asn1 . create ( asn1 . Class . UNIVERSAL , asn1 . Type . OID , false , asn1 . oidToDer ( obj . signatureAlgorithm ) . getBytes ( ) ) , // parameters (null)
 asn1 . create ( asn1 . Class . UNIVERSAL , asn1 . Type . NULL , false , '' ) ] ) ) ; // encryptedDigest
 rval . value . push ( asn1 . create ( asn1 . Class . UNIVERSAL , asn1 . Type . OCTETSTRING , false , obj . signature ) ) ; // unauthenticatedAttributes (OPTIONAL)
 if ( obj . unauthenticatedAttributes . length > 0 ) { // [1] IMPLICIT
 var attrsAsn1 = asn1 . create ( asn1 . Class . CONTEXT_SPECIFIC , 1 , true , [ ] ) ; for ( var i = 0 ; i < obj . unauthenticatedAttributes . length ; ++ i ) { var attr = obj . unauthenticatedAttributes [ i ] ; attrsAsn1 . values . push ( _attributeToAsn1 ( attr ) ) ; } rval . value . push ( attrsAsn1 ) ; } return rval ; }
Converts a single signerInfo object to an ASN.1 object.

@param obj the signerInfo object.

@return the ASN.1 representation of a SignerInfo.
Converts a single signerInfo object to an ASN . 1 object .