How to use the asn1.js-rfc2560.CertID 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 snowflakedb / snowflake-connector-nodejs / lib / agent / cert_util.js View on Github external
const keys = cacheKey.split("#");
  const issuerNameHash = Buffer.from(keys[0], 'base64');
  const issuerKeyHash = Buffer.from(keys[1], 'base64');
  const serialNumber = new bn(keys[2], 10);

  const certID = {
    hashAlgorithm: {
      // algorithm: [ 2, 16, 840, 1, 101, 3, 4, 2, 1 ]  // sha256
      algorithm: [1, 3, 14, 3, 2, 26]  // sha1
    },
    issuerNameHash: issuerNameHash,
    issuerKeyHash: issuerKeyHash,
    serialNumber: serialNumber
  };

  const certIDDer = rfc2560.CertID.encode(certID, 'der');
  return certIDDer.toString("BASE64");
};
exports.decodeKey = decodeKey;
github snowflakedb / snowflake-connector-nodejs / lib / agent / cert_util.js View on Github external
}

  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 indutny / ocsp / lib / ocsp / request.js View on Github external
requestList: [ {
      reqCert: certID
    } ],
    requestExtensions: [ {
      extnID: rfc2560['id-pkix-ocsp-nonce'],
      critical: false,
      extnValue: rfc2560.Nonce.encode(crypto.randomBytes(16), 'der')
    } ]
  };

  var req = {
    tbsRequest: tbs
  };

  return {
    id: sha1(rfc2560.CertID.encode(certID, 'der')),
    certID: certID,
    data: rfc2560.OCSPRequest.encode(req, 'der'),

    // Just to avoid re-parsing DER
    cert: cert,
    issuer: issuer
  };
};
github snowflakedb / snowflake-connector-nodejs / lib / agent / cert_util.js View on Github external
const encodeKey = function (base64Key)
{
  const buff = Buffer.from(base64Key, 'base64');
  const certID = rfc2560.CertID.decode(buff, 'der');

  return certID.issuerNameHash.toString("BASE64")
    + '#' + certID.issuerKeyHash.toString("BASE64")
    + '#' + certID.serialNumber.toString(10);
};
exports.encodeKey = encodeKey;