node_modules/hybrid-crypto-js/web/hybrid-crypto.js
/**
 * Converts a certification request's attributes to an ASN.1 set of
 * CRIAttributes.
 *
 * @param csr certification request.
 *
 * @return the ASN.1 set of CRIAttributes.
 */
Converts a certification request's attributes to an ASN.1 set of
CRIAttributes.

@param csr certification request.

@return the ASN.1 set of CRIAttributes.
Converts a certification request ' s attributes to an ASN . 1 set of CRIAttributes . @param csr certification request . @return the ASN . 1 set of CRIAttributes .
function _CRIAttributesToAsn1(csr) {
  var rval = asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, []);
  if(csr.attributes.length === 0) {
    return rval;
  }
  var attrs = csr.attributes;
  for(var i = 0; i < attrs.length; ++i) {
    var attr = attrs[i];
    var value = attr.value;
    var valueTagClass = asn1.Type.UTF8;
    if('valueTagClass' in attr) {
      valueTagClass = attr.valueTagClass;
    }
    if(valueTagClass === asn1.Type.UTF8) {
      value = forge.util.encodeUtf8(value);
    }
    var valueConstructed = false;
    if('valueConstructed' in attr) {
      valueConstructed = attr.valueConstructed;
    }
    var seq = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
      asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
        asn1.oidToDer(attr.type).getBytes()),
      asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true, [
        asn1.create(
          asn1.Class.UNIVERSAL, valueTagClass, valueConstructed, value)
      ])
    ]);
    rval.value.push(seq);
  }
  return rval;
}
function _CRIAttributesToAsn1 ( csr ) { var rval = asn1 . create ( asn1 . Class . CONTEXT_SPECIFIC , 0 , true , [ ] ) ; if ( csr . attributes . length === 0 ) { return rval ; } var attrs = csr . attributes ; for ( var i = 0 ; i < attrs . length ; ++ i ) { var attr = attrs [ i ] ; var value = attr . value ; var valueTagClass = asn1 . Type . UTF8 ; if ( 'valueTagClass' in attr ) { valueTagClass = attr . valueTagClass ; } if ( valueTagClass === asn1 . Type . UTF8 ) { value = forge . util . encodeUtf8 ( value ) ; } var valueConstructed = false ; if ( 'valueConstructed' in attr ) { valueConstructed = attr . valueConstructed ; } var seq = asn1 . create ( asn1 . Class . UNIVERSAL , asn1 . Type . SEQUENCE , true , [ asn1 . create ( asn1 . Class . UNIVERSAL , asn1 . Type . OID , false , asn1 . oidToDer ( attr . type ) . getBytes ( ) ) , asn1 . create ( asn1 . Class . UNIVERSAL , asn1 . Type . SET , true , [ asn1 . create ( asn1 . Class . UNIVERSAL , valueTagClass , valueConstructed , value ) ] ) ] ) ; rval . value . push ( seq ) ; } return rval ; }
Converts a certification request's attributes to an ASN.1 set of
 CRIAttributes.
Converts a certification request ' s attributes to an ASN . 1 set of CRIAttributes .
// create an empty context-specific container // no attributes, return empty container // each attribute has a sequence with a type and a set of values // reuse tag class for attribute value if available // FIXME: handle more encodings // create a RelativeDistinguishedName set // each value in the set is an AttributeTypeAndValue first // containing the type (an OID) and second the value // AttributeType // AttributeValue