How to use the asn1.js-rfc5280.Name function in asn1

To help you get started, we’ve selected a few asn1 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github indutny / ocsp / lib / ocsp / request.js View on Github external
issuer = rawIssuer;
  } else {
    issuer = rfc5280.Certificate.decode(
        ocsp.utils.toDER(rawIssuer, 'CERTIFICATE'),
        'der');
  }

  var tbsCert = cert.tbsCertificate;
  var tbsIssuer = issuer.tbsCertificate;

  var certID = {
    hashAlgorithm: {
      // algorithm: [ 2, 16, 840, 1, 101, 3, 4, 2, 1 ]  // sha256
      algorithm: [ 1, 3, 14, 3, 2, 26 ]  // sha1
    },
    issuerNameHash: sha1(rfc5280.Name.encode(tbsCert.issuer, 'der')),
    issuerKeyHash: sha1(
      tbsIssuer.subjectPublicKeyInfo.subjectPublicKey.data),
    serialNumber: tbsCert.serialNumber
  };

  var tbs = {
    version: 'v1',
    requestList: [ {
      reqCert: certID
    } ],
    requestExtensions: [ {
      extnID: rfc2560['id-pkix-ocsp-nonce'],
      critical: false,
      extnValue: rfc2560.Nonce.encode(crypto.randomBytes(16), 'der')
    } ]
  };
github snowflakedb / snowflake-connector-nodejs / lib / agent / cert_util.js View on Github external
}
  }
  catch (e)
  {
    return null; // if we encountered an error during decoding, return null
  }

  var tbsCert = cert.tbsCertificate;
  var tbsIssuer = issuer.tbsCertificate;

  const certID = {
    hashAlgorithm: {
      // algorithm: [ 2, 16, 840, 1, 101, 3, 4, 2, 1 ]  // sha256
      algorithm: [1, 3, 14, 3, 2, 26]  // sha1
    },
    issuerNameHash: sha1(rfc5280.Name.encode(tbsCert.issuer, 'der')),
    issuerKeyHash: sha1(
      tbsIssuer.subjectPublicKeyInfo.subjectPublicKey.data),
    serialNumber: tbsCert.serialNumber
  };
  const certIDDer = rfc2560.CertID.encode(certID, 'der');
  return encodeKey(certIDDer.toString("BASE64"));
};
github tpadjen / ng2-prism / jspm_packages / npm / asn1.js@4.5.0 / rfc / 2560 / index.js View on Github external
var ResponderID = asn1.define('ResponderId', function() {
  this.choice({
    byName: this.explicit(1).use(rfc5280.Name),
    byKey: this.explicit(2).use(KeyHash)
  });
});
exports.ResponderID = ResponderID;
github mendersoftware / gui / node_modules / asn1.js / rfc / 2560 / index.js View on Github external
var ResponderID = asn1.define('ResponderId', function() {
  this.choice({
    byName: this.explicit(1).use(rfc5280.Name),
    byKey: this.explicit(2).use(KeyHash)
  });
});
exports.ResponderID = ResponderID;
github jamesshore / automatopia / node_modules / browserify / node_modules / crypto-browserify / node_modules / browserify-sign / node_modules / parse-asn1 / node_modules / asn1.js / rfc / 2560 / index.js View on Github external
var ResponderID = asn1.define('ResponderId', function() {
  this.choice({
    byName: this.explicit(1).use(rfc5280.Name),
    byKey: this.explicit(2).use(KeyHash)
  });
});
exports.ResponderID = ResponderID;
github indutny / ocsp / lib / ocsp / server.js View on Github external
function Server(options) {
  http.Server.call(this, this.handler);

  this.options = util._extend({
    nextUpdate: 24 * 3600 * 1e3
  }, options);

  this.key = this.options.key;
  this.cert = rfc5280.Certificate.decode(
      ocsp.utils.toDER(options.cert, 'CERTIFICATE'),
      'der');
  this.cert = this.cert.tbsCertificate;

  var issuerName = rfc5280.Name.encode(this.cert.subject, 'der');
  var issuerKey = this.cert.subjectPublicKeyInfo.subjectPublicKey.data;

  this.certID = {};
  Object.keys(ocsp.utils.digestRev).forEach(function(digest) {
    this.certID[digest] = {
      issuerNameHash: crypto.createHash(digest).update(issuerName).digest(),
      issuerKeyHash: crypto.createHash(digest).update(issuerKey).digest()
    };
  }, this);

  this.certs = {};
}
util.inherits(Server, http.Server);