How to use the asn1js.Enumerated 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 / examples / CRLComplexExample / es6.js View on Github external
crlSimpl.thisUpdate = new Time({
		type: 0,
		value: new Date()
	});
	
	const revokedCertificate = new RevokedCertificate({
		userCertificate: new asn1js.Integer({
			value: 999
		}),
		revocationDate: new Time({
			value: new Date()
		}),
		crlEntryExtensions: new Extensions({
			extensions: [new Extension({
				extnID: "2.5.29.21", // cRLReason
				extnValue: (new asn1js.Enumerated({
					value: 1
				})).toBER(false)
			})]
		})
	});
	
	crlSimpl.revokedCertificates = [];
	crlSimpl.revokedCertificates.push(revokedCertificate);
	crlSimpl.crlExtensions = new Extensions({
		extensions: [new Extension({
			extnID: "2.5.29.20", // cRLNumber
			extnValue: (new asn1js.Integer({
				value: 2
			})).toBER(false)
		})]
	});
github PeculiarVentures / CAdES.js / examples / CAdESComplexExample / es6.js View on Github external
}
		//endregion 
		
		//region Making final OCSP response object 
		basicResponse = new BasicOCSPResponse({
			tbsResponseData: new ResponseData({
				responderID: certSimpl.subject,
				producedAt: getUTCDate(new Date()),
				responses: responses
			}),
			signatureAlgorithm: certSimpl.signatureAlgorithm,
			certs: [certSimpl]
		});
		
		ocspResponse = new OCSPResponse({
			responseStatus: new asn1js.Enumerated({ value: 0 }) // successful
		});
		//endregion 
	});
github PeculiarVentures / PKI.js / src / SingleResponse.js View on Github external
}), // IMPLICIT NULL (no "valueBlock")
						new asn1js.Constructed({
							name: (names.certStatus || ""),
							idBlock: {
								tagClass: 3, // CONTEXT-SPECIFIC
								tagNumber: 1 // [1]
							},
							value: [
								new asn1js.GeneralizedTime(),
								new asn1js.Constructed({
									optional: true,
									idBlock: {
										tagClass: 3, // CONTEXT-SPECIFIC
										tagNumber: 0 // [0]
									},
									value: [new asn1js.Enumerated()]
								})
							]
						}),
						new asn1js.Primitive({
							name: (names.certStatus || ""),
							idBlock: {
								tagClass: 3, // CONTEXT-SPECIFIC
								tagNumber: 2 // [2]
							},
							lenBlock: { length: 1 }
						}) // IMPLICIT NULL (no "valueBlock")
					]
				}),
				new asn1js.GeneralizedTime({ name: (names.thisUpdate || "") }),
				new asn1js.Constructed({
					optional: true,
github PeculiarVentures / PKI.js / src / OCSPResponse.js View on Github external
static schema(parameters = {})
	{
		/**
		 * @type {Object}
		 * @property {string} [blockName]
		 * @property {string} [responseStatus]
		 * @property {string} [responseBytes]
		 */
		const names = getParametersValue(parameters, "names", {});

		return (new asn1js.Sequence({
			name: (names.blockName || "OCSPResponse"),
			value: [
				new asn1js.Enumerated({ name: (names.responseStatus || "responseStatus") }),
				new asn1js.Constructed({
					optional: true,
					idBlock: {
						tagClass: 3, // CONTEXT-SPECIFIC
						tagNumber: 0 // [0]
					},
					value: [
						ResponseBytes.schema(names.responseBytes || {
							names: {
								blockName: "responseBytes"
							}
						})
					]
				})
			]
		}));
github PeculiarVentures / PKI.js / src / AttributeCertificateV2.js View on Github external
static schema(parameters = {})
	{
		/**
		 * @type {Object}
		 * @property {string} [blockName]
		 * @property {string} [digestedObjectType]
		 * @property {string} [otherObjectTypeID]
		 * @property {string} [digestAlgorithm]
		 * @property {string} [objectDigest]
		 */
		const names = getParametersValue(parameters, "names", {});
		
		return (new asn1js.Sequence({
			name: (names.blockName || ""),
			value: [
				new asn1js.Enumerated({ name: (names.digestedObjectType || "") }),
				new asn1js.ObjectIdentifier({
					optional: true,
					name: (names.otherObjectTypeID || "")
				}),
				AlgorithmIdentifier.schema(names.digestAlgorithm || {}),
				new asn1js.BitString({ name: (names.objectDigest || "") }),
			]
		}));
	}
	//**********************************************************************************
github PeculiarVentures / PKI.js / src / OCSPResponse.js View on Github external
static defaultValues(memberName)
	{
		switch(memberName)
		{
			case "responseStatus":
				return new asn1js.Enumerated();
			case "responseBytes":
				return new ResponseBytes();
			default:
				throw new Error(`Invalid member name for OCSPResponse class: ${memberName}`);
		}
	}
	//**********************************************************************************
github PeculiarVentures / PKI.js / src / AttributeCertificateV2.js View on Github external
static defaultValues(memberName)
	{
		switch(memberName)
		{
			case "digestedObjectType":
				return new asn1js.Enumerated();
			case "otherObjectTypeID":
				return new asn1js.ObjectIdentifier();
			case "digestAlgorithm":
				return new AlgorithmIdentifier();
			case "objectDigest":
				return new asn1js.BitString();
			default:
				throw new Error(`Invalid member name for ObjectDigestInfo class: ${memberName}`);
		}
	}
	//**********************************************************************************

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 2 years ago

Package Health Score

79 / 100
Full package analysis