How to use the asn1js.Utf8String 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 / CertificateComplexExample / es6.js View on Github external
"1.3.6.1.4.1.311.10.3.1", // Microsoft Certificate Trust List signing
			"1.3.6.1.4.1.311.10.3.4"  // Microsoft Encrypted File System
		]
	});
	
	certificate.extensions.push(new Extension({
		extnID: "2.5.29.37",
		critical: false,
		extnValue: extKeyUsage.toSchema().toBER(false),
		parsedValue: extKeyUsage // Parsed value for well-known extensions
	}));
	//endregion


	//region Microsoft-specific extensions
	const certType = new asn1js.Utf8String({ value: "certType" });

	certificate.extensions.push(new Extension({
		extnID: "1.3.6.1.4.1.311.20.2",
		critical: false,
		extnValue: certType.toBER(false),
		parsedValue: certType // Parsed value for well-known extensions
	}));


	const prevHash = new asn1js.OctetString({ valueHex: (new Uint8Array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])).buffer });

	certificate.extensions.push(new Extension({
		extnID: "1.3.6.1.4.1.311.21.2",
		critical: false,
		extnValue: prevHash.toBER(false),
		parsedValue: prevHash // Parsed value for well-known extensions
github PeculiarVentures / CAdES.js / src / ContentHints.js View on Github external
// ContentHints ::= SEQUENCE {
		//    contentDescription UTF8String (SIZE (1..MAX)) OPTIONAL,
		//    contentType ContentType }
		
		/**
		 * @type {Object}
		 * @property {string} [blockName]
		 * @property {string} [contentDescription]
		 * @property {string} [contentType]
		 */
		const names = getParametersValue(parameters, "names", {});
		
		return (new asn1js.Sequence({
			name: (names.blockName || ""),
			value: [
				new asn1js.Utf8String({
					name: (names.contentDescription || ""),
					optinal: true
				}),
				new asn1js.ObjectIdentifier({ name: (names.contentType || "") })
			]
		}));
	}
	//**********************************************************************************
github PeculiarVentures / CAdES.js / src / SignerLocation.js View on Github external
]
				}),
				new asn1js.Constructed({
					name: (names.localityName || ""),
					optional: true,
					idBlock: {
						tagClass: 3, // CONTEXT-SPECIFIC
						tagNumber: 1 // [1]
					},
					value: [
						new asn1js.Choice({
							value: [
								new asn1js.TeletexString({ name: (names.localityName || "") }),
								new asn1js.PrintableString({ name: (names.localityName || "") }),
								new asn1js.UniversalString({ name: (names.localityName || "") }),
								new asn1js.Utf8String({ name: (names.localityName || "") }),
								new asn1js.BmpString({ name: (names.localityName || "") })
							]
						})
					]
				}),
				new asn1js.Constructed({
					optional: true,
					idBlock: {
						tagClass: 3, // CONTEXT-SPECIFIC
						tagNumber: 2 // [2]
					},
					value: [
						new asn1js.Repeated({
							name: (names.postalAdddress || ""),
							value: new asn1js.Choice({
								value: [
github PeculiarVentures / PKI.js / examples / PKCS10ComplexExample / es6.js View on Github external
//region Get a "crypto" extension
	const crypto = getCrypto();
	if(typeof crypto === "undefined")
		return Promise.reject("No WebCrypto extension found");
	//endregion
	
	//region Put a static values
	pkcs10.version = 0;
	pkcs10.subject.typesAndValues.push(new AttributeTypeAndValue({
		type: "2.5.4.6",
		value: new asn1js.PrintableString({ value: "RU" })
	}));
	pkcs10.subject.typesAndValues.push(new AttributeTypeAndValue({
		type: "2.5.4.3",
		value: new asn1js.Utf8String({ value: "Simple test (простой тест)" })
	}));
	
	const altNames = new GeneralNames({
		names: [
			new GeneralName({
				type: 1, // rfc822Name
				value: "email@address.com"
			}),
			new GeneralName({
				type: 2, // dNSName
				value: "www.domain.com"
			}),
			new GeneralName({
				type: 2, // dNSName
				value: "www.anotherdomain.com"
			}),
github PeculiarVentures / CAdES.js / src / SPUserNotice.js View on Github external
const names = getParametersValue(parameters, "names", {});
		
		return (new asn1js.Sequence({
			name: (names.blockName || ""),
			value: [
				NoticeReference.schema(names.sPUserNotice || {
					names: {
						blockName: "",
						optional: true
					}
				}),
				new asn1js.Choice({
					value: [
						new asn1js.VisibleString({ name: (names.explicitText || "") }),
						new asn1js.BmpString({ name: (names.explicitText || "") }),
						new asn1js.Utf8String({ name: (names.explicitText || "") })
					]
				})
			]
		}));
	}
	//**********************************************************************************
github PeculiarVentures / PKI.js / src / PKIStatusInfo.js View on Github external
* @property {string} [status]
		 * @property {string} [statusStrings]
		 * @property {string} [failInfo]
		 */
		const names = getParametersValue(parameters, "names", {});

		return (new asn1js.Sequence({
			name: (names.blockName || ""),
			value: [
				new asn1js.Integer({ name: (names.status || "") }),
				new asn1js.Sequence({
					optional: true,
					value: [
						new asn1js.Repeated({
							name: (names.statusStrings || ""),
							value: new asn1js.Utf8String()
						})
					]
				}),
				new asn1js.BitString({
					name: (names.failInfo || ""),
					optional: true
				})
			]
		}));
	}
	//**********************************************************************************
github PeculiarVentures / CAdES.js / src / NoticeReference.js View on Github external
toSchema()
	{
		//region Create array for output sequence
		const outputArray = [];
		
		switch(this._organizationType)
		{
			case 0:
				outputArray.push(new asn1js.VisibleString({ value: this.organization }));
				break;
			case 1:
				outputArray.push(new asn1js.BmpString({ value: this.organization }));
				break;
			case 2:
				outputArray.push(new asn1js.Utf8String({ value: this.organization }));
				break;
			default:
				throw new Error("Non-initialized \"organization\" value");
		}
		
		outputArray.push(new asn1js.Sequence({
			value: Array.from(this.noticeNumbers)
		}));
		//endregion
		
		//region Construct and return new ASN.1 schema for this object
		return (new asn1js.Sequence({
			value: outputArray
		}));
		//endregion
	}
github PeculiarVentures / CAdES.js / src / ContentHints.js View on Github external
toSchema()
	{
		//region Construct and return new ASN.1 schema for this object
		return (new asn1js.Sequence({
			value: [
				new asn1js.Utf8String({ value: this.contentType }),
				new asn1js.ObjectIdentifier({ value: this.contentType })
			]
		}));
		//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 2 years ago

Package Health Score

76 / 100
Full package analysis