node_modules/node-forge/lib/pkcs7.js
/**
 * 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.
@param obj the signerInfo object.

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