@blamejs/pki 0.5.22 → 0.5.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,14 +14,24 @@
14
14
 
15
15
  var crypto = require("crypto");
16
16
  var constants = require("./constants");
17
+ var intrinsic = require("./guard-intrinsic");
18
+ // Own-key membership through an operation taken at load. Written out, the question reads two
19
+ // replaceable properties to answer one thing, and here it decides whether an auth-param repeats --
20
+ // answering false lets the second copy of a nonce overwrite the first.
21
+ var _hasOwn = intrinsic.hasOwn;
17
22
 
18
23
  // Algorithm registry, a data row and not a switch: rank orders the RFC 7616 sec. 3.7
19
24
  // "most secure the client can use" selection (SHA-512-256 > SHA-256 > MD5); an unknown algorithm ranks 0.
20
- var ALGS = {
25
+ //
26
+ // Null prototype, because the gate on an unknown algorithm is `if (!ALGS[name])`. With an ordinary
27
+ // object literal that question is asked of the prototype chain too, so an algorithm named for any
28
+ // member of Object.prototype answers with a truthy value the table never carried: the
29
+ // unsupported-algorithm refusal is skipped and the descriptor's own fields read as undefined.
30
+ var ALGS = intrinsic.assign(intrinsic.create(null), {
21
31
  "SHA-512-256": { hash: "sha512-256", rank: 3, sess: false }, "SHA-512-256-SESS": { hash: "sha512-256", rank: 3, sess: true },
22
32
  "SHA-256": { hash: "sha256", rank: 2, sess: false }, "SHA-256-SESS": { hash: "sha256", rank: 2, sess: true },
23
33
  "MD5": { hash: "md5", rank: 1, sess: false }, "MD5-SESS": { hash: "md5", rank: 1, sess: true },
24
- };
34
+ });
25
35
  var DEFAULT_CODES = {
26
36
  unsupportedAlgorithm: "digest/unsupported-algorithm", weakAlgorithm: "digest/weak-algorithm",
27
37
  noQop: "digest/no-qop", badChallenge: "digest/bad-challenge",
@@ -110,7 +120,7 @@ function _parseParams(paramText, E, code) {
110
120
  var rawVal = seg.slice(eq + 1).replace(/^\s+|\s+$/g, "");
111
121
  var quoted = rawVal.charAt(0) === "\"";
112
122
  if (quoted && !_closedQuote(rawVal)) throw E(code, "an unterminated or trailing-garbage Digest quoted-string (RFC 7230 sec. 3.2.6)");
113
- if (Object.prototype.hasOwnProperty.call(map, key)) throw E(code, "repeated Digest auth-param " + JSON.stringify(key));
123
+ if (_hasOwn(map, key)) throw E(code, "repeated Digest auth-param " + JSON.stringify(key));
114
124
  var value = quoted ? _unq(rawVal) : rawVal;
115
125
  // Reject a control octet in any value (CR / LF / NUL / ...): it is a MUST-reject per RFC 7230 qdtext AND a
116
126
  // header-injection sink -- an unescaped CR/LF reflected into the outgoing Authorization would split the header.
@@ -3081,7 +3081,7 @@ async function build(leaf, opts) {
3081
3081
  // supplied and `opts.softFail` answers for it. Own membership decides only whether a name is
3082
3082
  // build-only, which is a question about this module's own table and never about the caller.
3083
3083
  Object.keys(_VALIDATE_OPTS).forEach(function (k) {
3084
- if (Object.prototype.hasOwnProperty.call(BUILD_ONLY_OPT, k)) return;
3084
+ if (intrinsic.hasOwn(BUILD_ONLY_OPT, k)) return;
3085
3085
  if (k in opts) forwarded[k] = opts[k];
3086
3086
  });
3087
3087
  function validateOpts(anchor) {
@@ -39,6 +39,10 @@ var schema = require("./schema-engine");
39
39
  var pkix = require("./schema-pkix");
40
40
  var oid = require("./oid");
41
41
  var guard = require("./guard-all");
42
+ var intrinsic = require("./guard-intrinsic");
43
+ // Own-key membership through an operation taken at load. Written out, the question reads two
44
+ // replaceable properties to answer one thing, and here it decides which object-digest types resolve.
45
+ var _hasOwn = intrinsic.hasOwn;
42
46
  var frameworkError = require("./framework-error");
43
47
 
44
48
  var AttrCertError = frameworkError.AttrCertError;
@@ -69,7 +73,7 @@ var ODT_NAMES = constants.NAMES.OBJECT_DIGEST_TYPE;
69
73
  var DIGESTED_OBJECT_TYPE = schema.decode(function (n, ctx) {
70
74
  var v = asn1.read.enumerated(n);
71
75
  var k = v.toString();
72
- if (!Object.prototype.hasOwnProperty.call(ODT_NAMES, k)) {
76
+ if (!_hasOwn(ODT_NAMES, k)) {
73
77
  throw ctx.E("attrcert/bad-digested-object-type", "digestedObjectType " + k + " is not a defined value (RFC 5755 sec. 4.1)");
74
78
  }
75
79
  // RFC 5755 sec. 7.3 -- a conformant AC MUST NOT use otherObjectTypes(2); the digested
package/lib/schema-crl.js CHANGED
@@ -28,6 +28,10 @@ var schema = require("./schema-engine");
28
28
  var pkix = require("./schema-pkix");
29
29
  var oid = require("./oid");
30
30
  var frameworkError = require("./framework-error");
31
+ var intrinsic = require("./guard-intrinsic");
32
+ // Own-key membership through an operation taken at load. Written out, the question reads two
33
+ // replaceable properties to answer one thing, and here it decides which CRLReason values are defined.
34
+ var _hasOwn = intrinsic.hasOwn;
31
35
 
32
36
  var CrlError = frameworkError.CrlError;
33
37
  var PemError = frameworkError.PemError;
@@ -77,7 +81,7 @@ function decodeExt(ext) {
77
81
  // read.enumerated asserts the ENUMERATED tag (a bare INTEGER is rejected) --
78
82
  // the codec owns the tag check, so this reader need not repeat it.
79
83
  var reason = asn1.read.enumerated(asn1.decode(ext.value));
80
- if (!Object.prototype.hasOwnProperty.call(CRL_REASONS, reason.toString())) throw new Error("undefined CRLReason " + reason.toString());
84
+ if (!_hasOwn(CRL_REASONS, reason.toString())) throw new Error("undefined CRLReason " + reason.toString());
81
85
  value = Number(reason);
82
86
  } else if (ext.oid === OID_INVALIDITY_DATE) { // invalidityDate ::= GeneralizedTime
83
87
  var n = asn1.decode(ext.value);
@@ -39,6 +39,11 @@ var pkix = require("./schema-pkix");
39
39
  var oid = require("./oid");
40
40
  var constants = require("./constants");
41
41
  var frameworkError = require("./framework-error");
42
+ var intrinsic = require("./guard-intrinsic");
43
+ // Own-key membership through an operation taken at load. Written out, the question reads two
44
+ // replaceable properties to answer one thing, and here it decides which response statuses and
45
+ // revocation reasons are defined -- an admitted name names a status RFC 6960 never assigned.
46
+ var _hasOwn = intrinsic.hasOwn;
42
47
 
43
48
  var OcspError = frameworkError.OcspError;
44
49
  var PemError = frameworkError.PemError;
@@ -85,7 +90,7 @@ var GENERALIZED_TIME = pkix.generalizedTime(NS, { code: "ocsp/bad-time", message
85
90
  var OCSP_RESPONSE_STATUS = schema.decode(function (n, ctx) {
86
91
  var v = asn1.read.enumerated(n);
87
92
  var key = v.toString();
88
- if (!Object.prototype.hasOwnProperty.call(STATUS_NAMES, key)) throw ctx.E("ocsp/bad-response-status", "undefined OCSPResponseStatus " + key + " (RFC 6960 sec. 4.2.1)");
93
+ if (!_hasOwn(STATUS_NAMES, key)) throw ctx.E("ocsp/bad-response-status", "undefined OCSPResponseStatus " + key + " (RFC 6960 sec. 4.2.1)");
89
94
  return { code: Number(v), name: STATUS_NAMES[key] };
90
95
  });
91
96
 
@@ -93,7 +98,7 @@ var OCSP_RESPONSE_STATUS = schema.decode(function (n, ctx) {
93
98
  var CRL_REASON = schema.decode(function (n, ctx) {
94
99
  var v = asn1.read.enumerated(n);
95
100
  var key = v.toString();
96
- if (!Object.prototype.hasOwnProperty.call(CRL_REASONS, key)) throw ctx.E("ocsp/bad-revocation-reason", "undefined CRLReason " + key + " (RFC 5280 sec. 5.3.1)");
101
+ if (!_hasOwn(CRL_REASONS, key)) throw ctx.E("ocsp/bad-revocation-reason", "undefined CRLReason " + key + " (RFC 5280 sec. 5.3.1)");
97
102
  return CRL_REASONS[key];
98
103
  });
99
104