How to use the asn1js.Boolean function in asn1js

To help you get started, we’ve selected a few asn1js 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 PeculiarVentures / PKI.js / src / TimeStampReq.js View on Github external
toSchema()
	{
		//region Create array for output sequence
		const outputArray = [];

		outputArray.push(new asn1js.Integer({ value: this.version }));
		outputArray.push(this.messageImprint.toSchema());
		if("reqPolicy" in this)
			outputArray.push(new asn1js.ObjectIdentifier({ value: this.reqPolicy }));
		if("nonce" in this)
			outputArray.push(this.nonce);
		if(("certReq" in this) && (TimeStampReq.compareWithDefault("certReq", this.certReq) === false))
			outputArray.push(new asn1js.Boolean({ value: this.certReq }));

		//region Create array of extensions
		if("extensions" in this)
		{
			outputArray.push(new asn1js.Constructed({
				idBlock: {
					tagClass: 3, // CONTEXT-SPECIFIC
					tagNumber: 0 // [0]
				},
				value: Array.from(this.extensions, element => element.toSchema())
			}));
		}
		//endregion
		//endregion

		//region Construct and return new ASN.1 schema for this object
github PeculiarVentures / PKI.js / src / TimeStampReq.js View on Github external
value: [
				new asn1js.Integer({ name: (names.version || "TimeStampReq.version") }),
				MessageImprint.schema(names.messageImprint || {
					names: {
						blockName: "TimeStampReq.messageImprint"
					}
				}),
				new asn1js.ObjectIdentifier({
					name: (names.reqPolicy || "TimeStampReq.reqPolicy"),
					optional: true
				}),
				new asn1js.Integer({
					name: (names.nonce || "TimeStampReq.nonce"),
					optional: true
				}),
				new asn1js.Boolean({
					name: (names.certReq || "TimeStampReq.certReq"),
					optional: true
				}),
				new asn1js.Constructed({
					optional: true,
					idBlock: {
						tagClass: 3, // CONTEXT-SPECIFIC
						tagNumber: 0 // [0]
					},
					value: [new asn1js.Repeated({
						name: (names.extensions || "TimeStampReq.extensions"),
						value: Extension.schema()
					})]
				}) // IMPLICIT SEQUENCE value
			]
		}));
github PeculiarVentures / PKI.js / src / TSTInfo.js View on Github external
toSchema()
	{
		//region Create array for output sequence
		const outputArray = [];

		outputArray.push(new asn1js.Integer({ value: this.version }));
		outputArray.push(new asn1js.ObjectIdentifier({ value: this.policy }));
		outputArray.push(this.messageImprint.toSchema());
		outputArray.push(this.serialNumber);
		outputArray.push(new asn1js.GeneralizedTime({ valueDate: this.genTime }));
		if("accuracy" in this)
			outputArray.push(this.accuracy.toSchema());
		if("ordering" in this)
			outputArray.push(new asn1js.Boolean({ value: this.ordering }));
		if("nonce" in this)
			outputArray.push(this.nonce);
		if("tsa" in this)
		{
			outputArray.push(new asn1js.Constructed({
				optional: true,
				idBlock: {
					tagClass: 3, // CONTEXT-SPECIFIC
					tagNumber: 0 // [0]
				},
				value: [this.tsa.toSchema()]
			}));
		}

		//region Create array of extensions
		if("extensions" in this)
github PeculiarVentures / PKI.js / src / TSTInfo.js View on Github external
value: [
				new asn1js.Integer({ name: (names.version || "TSTInfo.version") }),
				new asn1js.ObjectIdentifier({ name: (names.policy || "TSTInfo.policy") }),
				MessageImprint.schema(names.messageImprint || {
					names: {
						blockName: "TSTInfo.messageImprint"
					}
				}),
				new asn1js.Integer({ name: (names.serialNumber || "TSTInfo.serialNumber") }),
				new asn1js.GeneralizedTime({ name: (names.genTime || "TSTInfo.genTime") }),
				Accuracy.schema(names.accuracy || {
					names: {
						blockName: "TSTInfo.accuracy"
					}
				}),
				new asn1js.Boolean({
					name: (names.ordering || "TSTInfo.ordering"),
					optional: true
				}),
				new asn1js.Integer({
					name: (names.nonce || "TSTInfo.nonce"),
					optional: true
				}),
				new asn1js.Constructed({
					optional: true,
					idBlock: {
						tagClass: 3, // CONTEXT-SPECIFIC
						tagNumber: 0 // [0]
					},
					value: [GeneralName.schema(names.tsa || {
						names: {
							blockName: "TSTInfo.tsa"
github PeculiarVentures / PKI.js / src / BasicConstraints.js View on Github external
toSchema()
	{
		//region Create array for output sequence
		const outputArray = [];
		
		if(this.cA !== BasicConstraints.defaultValues("cA"))
			outputArray.push(new asn1js.Boolean({ value: this.cA }));
		
		if("pathLenConstraint" in this)
		{
			if(this.pathLenConstraint instanceof asn1js.Integer)
				outputArray.push(this.pathLenConstraint);
			else
				outputArray.push(new asn1js.Integer({ value: this.pathLenConstraint }));
		}
		//endregion
		
		//region Construct and return new ASN.1 schema for this object
		return (new asn1js.Sequence({
			value: outputArray
		}));
		//endregion
	}
github PeculiarVentures / PKI.js / src / BasicConstraints.js View on Github external
static schema(parameters = {})
	{
		/**
		 * @type {Object}
		 * @property {string} [blockName]
		 * @property {string} [cA]
		 * @property {string} [pathLenConstraint]
		 */
		const names = getParametersValue(parameters, "names", {});

		return (new asn1js.Sequence({
			name: (names.blockName || ""),
			value: [
				new asn1js.Boolean({
					optional: true,
					name: (names.cA || "")
				}),
				new asn1js.Integer({
					optional: true,
					name: (names.pathLenConstraint || "")
				})
			]
		}));
	}
	//**********************************************************************************
github PeculiarVentures / PKI.js / src / Extension.js View on Github external
static schema(parameters = {})
	{
		/**
		 * @type {Object}
		 * @property {string} [blockName]
		 * @property {string} [extnID]
		 * @property {string} [critical]
		 * @property {string} [extnValue]
		 */
		const names = getParametersValue(parameters, "names", {});

		return (new asn1js.Sequence({
			name: (names.blockName || ""),
			value: [
				new asn1js.ObjectIdentifier({ name: (names.extnID || "") }),
				new asn1js.Boolean({
					name: (names.critical || ""),
					optional: true
				}),
				new asn1js.OctetString({ name: (names.extnValue || "") })
			]
		}));
	}
	//**********************************************************************************
github PeculiarVentures / PKI.js / src / Extension.js View on Github external
toSchema()
	{
		//region Create array for output sequence
		const outputArray = [];

		outputArray.push(new asn1js.ObjectIdentifier({ value: this.extnID }));

		if(this.critical !== Extension.defaultValues("critical"))
			outputArray.push(new asn1js.Boolean({ value: this.critical }));

		outputArray.push(this.extnValue);
		//endregion

		//region Construct and return new ASN.1 schema for this object
		return (new asn1js.Sequence({
			value: outputArray
		}));
		//endregion
	}
	//**********************************************************************************

asn1js

asn1js is a pure JavaScript library implementing this standard. ASN.1 is the basis of all X.509 related data structures and numerous other protocols used on the web

BSD-3-Clause
Latest version published 3 years ago

Package Health Score

79 / 100
Full package analysis