How to use the asn1js.Choice 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 / GeneralName.js View on Github external
* @property {string} [organizational_unit_names]
	 */
	const names = getParametersValue(parameters, "names", {});

	return (new asn1js.Sequence({
		optional,
		value: [
			new asn1js.Constructed({
				optional: true,
				idBlock: {
					tagClass: 2, // APPLICATION-SPECIFIC
					tagNumber: 1 // [1]
				},
				name: (names.country_name || ""),
				value: [
					new asn1js.Choice({
						value: [
							new asn1js.NumericString(),
							new asn1js.PrintableString()
						]
					})
				]
			}),
			new asn1js.Constructed({
				optional: true,
				idBlock: {
					tagClass: 2, // APPLICATION-SPECIFIC
					tagNumber: 2 // [2]
				},
				name: (names.administration_domain_name || ""),
				value: [
					new asn1js.Choice({
github PeculiarVentures / PKI.js / src / AttributeCertificateV2.js View on Github external
static schema(parameters = {})
	{
		/**
		 * @type {Object}
		 * @property {string} [blockName]
		 * @property {string} [issuer]
		 * @property {string} [serialNumber]
		 */
		const names = getParametersValue(parameters, "names", {});
		
		return (new asn1js.Sequence({
			name: (names.blockName || ""),
			value: [
				new asn1js.Integer({ name: (names.version || "") }),
				Holder.schema(names.holder || {}),
				new asn1js.Choice({
					value: [
						GeneralNames.schema({
							names: {
								blockName: (names.issuer || "")
							}
						}),
						new asn1js.Constructed({
							name: (names.issuer || ""),
							idBlock: {
								tagClass: 3, // CONTEXT-SPECIFIC
								tagNumber: 0 // [0]
							},
							value: V2Form.schema().valueBlock.value
						})
					]
				}),
github PeculiarVentures / PKI.js / src / RevocationInfoChoices.js View on Github external
static schema(parameters = {})
	{
		/**
		 * @type {Object}
		 * @property {string} [blockName]
		 * @property {string} [crls]
		 */
		const names = getParametersValue(parameters, "names", {});
		
		return (new asn1js.Set({
			name: (names.blockName || ""),
			value: [
				new asn1js.Repeated({
					name: (names.crls || ""),
					value: new asn1js.Choice({
						value: [
							CertificateRevocationList.schema(),
							new asn1js.Constructed({
								idBlock: {
									tagClass: 3, // CONTEXT-SPECIFIC
									tagNumber: 1 // [1]
								},
								value: [
									new asn1js.ObjectIdentifier(),
									new asn1js.Any()
								]
							})
						]
					})
				})
			]
github PeculiarVentures / PKI.js / src / OriginatorIdentifierOrKey.js View on Github external
static schema(parameters = {})
	{
		/**
		 * @type {Object}
		 * @property {string} [blockName]
		 */
		const names = getParametersValue(parameters, "names", {});
		
		return (new asn1js.Choice({
			value: [
				IssuerAndSerialNumber.schema({
					names: {
						blockName: (names.blockName || "")
					}
				}),
				new asn1js.Primitive({
					idBlock: {
						tagClass: 3, // CONTEXT-SPECIFIC
						tagNumber: 0 // [0]
					},
					name: (names.blockName || "")
				}),
				new asn1js.Constructed({
					idBlock: {
						tagClass: 3, // CONTEXT-SPECIFIC
github PeculiarVentures / PKI.js / src / DistributionPoint.js View on Github external
* @property {string} [cRLIssuer]
		 * @property {string} [cRLIssuerNames]
		 */
		const names = getParametersValue(parameters, "names", {});

		return (new asn1js.Sequence({
			name: (names.blockName || ""),
			value: [
				new asn1js.Constructed({
					optional: true,
					idBlock: {
						tagClass: 3, // CONTEXT-SPECIFIC
						tagNumber: 0 // [0]
					},
					value: [
						new asn1js.Choice({
							value: [
								new asn1js.Constructed({
									name: (names.distributionPoint || ""),
									optional: true,
									idBlock: {
										tagClass: 3, // CONTEXT-SPECIFIC
										tagNumber: 0 // [0]
									},
									value: [
										new asn1js.Repeated({
											name: (names.distributionPointNames || ""),
											value: GeneralName.schema()
										})
									]
								}),
								new asn1js.Constructed({
github PeculiarVentures / PKI.js / src / GeneralName.js View on Github external
}),
				new asn1js.Constructed({
					idBlock: {
						tagClass: 3, // CONTEXT-SPECIFIC
						tagNumber: 5 // [5]
					},
					name: (names.blockName || ""),
					value: [
						new asn1js.Constructed({
							optional: true,
							idBlock: {
								tagClass: 3, // CONTEXT-SPECIFIC
								tagNumber: 0 // [0]
							},
							value: [
								new asn1js.Choice({
									value: [
										new asn1js.TeletexString(),
										new asn1js.PrintableString(),
										new asn1js.UniversalString(),
										new asn1js.Utf8String(),
										new asn1js.BmpString()
									]
								})
							]
						}),
						new asn1js.Constructed({
							idBlock: {
								tagClass: 3, // CONTEXT-SPECIFIC
								tagNumber: 1 // [1]
							},
							value: [
github PeculiarVentures / PKI.js / src / RecipientInfo.js View on Github external
static schema(parameters = {})
	{
		/**
		 * @type {Object}
		 * @property {string} [blockName]
		 * @property {string} [type]
		 * @property {string} [setName]
		 * @property {string} [values]
		 */
		const names = getParametersValue(parameters, "names", {});
		
		return (new asn1js.Choice({
			value: [
				KeyTransRecipientInfo.schema({
					names: {
						blockName: (names.blockName || "")
					}
				}),
				new asn1js.Constructed({
					name: (names.blockName || ""),
					idBlock: {
						tagClass: 3, // CONTEXT-SPECIFIC
						tagNumber: 1 // [1]
					},
					value: KeyAgreeRecipientInfo.schema().valueBlock.value
				}),
				new asn1js.Constructed({
					name: (names.blockName || ""),
github PeculiarVentures / PKI.js / src / PBKDF2Params.js View on Github external
{
		/**
		 * @type {Object}
		 * @property {string} [blockName]
		 * @property {string} [saltPrimitive]
		 * @property {string} [saltConstructed]
		 * @property {string} [iterationCount]
		 * @property {string} [keyLength]
		 * @property {string} [prf]
		 */
		const names = getParametersValue(parameters, "names", {});

		return (new asn1js.Sequence({
			name: (names.blockName || ""),
			value: [
				new asn1js.Choice({
					value: [
						new asn1js.OctetString({ name: (names.saltPrimitive || "") }),
						AlgorithmIdentifier.schema(names.saltConstructed || {})
					]
				}),
				new asn1js.Integer({ name: (names.iterationCount || "") }),
				new asn1js.Integer({
					name: (names.keyLength || ""),
					optional: true
				}),
				AlgorithmIdentifier.schema(names.prf || {
					names: {
						optional: true
					}
				})
			]
github PeculiarVentures / CAdES.js / src / OcspResponsesID.js View on Github external
* @property {string} [ocspIdentifier]
		 * @property {string} [ocspRepHashSimple]
		 * @property {string} [ocspRepHashComplex]
		 */
		const names = getParametersValue(parameters, "names", {});
		
		return (new asn1js.Sequence({
			name: (names.blockName || ""),
			optional: (names.optional || false),
			value: [
				OcspIdentifier.schema(names.ocspIdentifier || {
					names: {
						blockName: ""
					}
				}),
				new asn1js.Choice({
					optional: true,
					value: [
						new asn1js.OctetString({ name: (names.ocspRepHashSimple || "") }),
						OtherHashAlgAndValue.schema(names.ocspRepHashComplex || {
							names: {
								blockName: ""
							}
						})
					]
				})
			]
		}));
	}
	//**********************************************************************************
github PeculiarVentures / PKI.js / src / PKCS8ShroudedKeyBag.js View on Github external
* @type {Object}
		 * @property {string} [blockName]
		 * @property {string} [encryptionAlgorithm]
		 * @property {string} [encryptedData]
		 */
		const names = getParametersValue(parameters, "names", {});
		
		return (new asn1js.Sequence({
			name: (names.blockName || ""),
			value: [
				AlgorithmIdentifier.schema(names.encryptionAlgorithm || {
					names: {
						blockName: "encryptionAlgorithm"
					}
				}),
				new asn1js.Choice({
					value: [
						new asn1js.OctetString({ name: (names.encryptedData || "encryptedData") }),
						new asn1js.OctetString({
							idBlock: {
								isConstructed: true
							},
							name: (names.encryptedData || "encryptedData")
						})
					]
				})
			]
		}));
	}
	//**********************************************************************************

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