How to use the asn1js.ObjectIdentifier 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} [blockName]
		 * @property {Object} [directoryName]
		 * @property {Object} [builtInStandardAttributes]
		 */
		const names = getParametersValue(parameters, "names", {});

		return (new asn1js.Choice({
			value: [
				new asn1js.Constructed({
					idBlock: {
						tagClass: 3, // CONTEXT-SPECIFIC
						tagNumber: 0 // [0]
					},
					name: (names.blockName || ""),
					value: [
						new asn1js.ObjectIdentifier(),
						new asn1js.Constructed({
							idBlock: {
								tagClass: 3, // CONTEXT-SPECIFIC
								tagNumber: 0 // [0]
							},
							value: [new asn1js.Any()]
						})
					]
				}),
				new asn1js.Primitive({
					name: (names.blockName || ""),
					idBlock: {
						tagClass: 3, // CONTEXT-SPECIFIC
						tagNumber: 1 // [1]
					}
				}),
github PeculiarVentures / PKI.js / src / TimeStampReq.js View on Github external
* @property {string} [type]
		 * @property {string} [setName]
		 * @property {string} [values]
		 */
		const names = getParametersValue(parameters, "names", {});
		
		return (new asn1js.Sequence({
			name: (names.blockName || "TimeStampReq"),
			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]
github PeculiarVentures / PKI.js / src / ResponseBytes.js View on Github external
static schema(parameters = {})
	{
		/**
		 * @type {Object}
		 * @property {string} [blockName]
		 * @property {string} [responseType]
		 * @property {string} [response]
		 */
		const names = getParametersValue(parameters, "names", {});

		return (new asn1js.Sequence({
			name: (names.blockName || ""),
			value: [
				new asn1js.ObjectIdentifier({ name: (names.responseType || "") }),
				new asn1js.OctetString({ name: (names.response || "") })
			]
		}));
	}
	//**********************************************************************************
github PeculiarVentures / CAdES.js / src / ContentHints.js View on Github external
/**
		 * @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 / PKI.js / src / PublicKeyInfo.js View on Github external
fromJSON(json)
	{
		if("kty" in json)
		{
			switch(json.kty.toUpperCase())
			{
				case "EC":
					this.parsedKey = new ECPublicKey({ json });
					
					this.algorithm = new AlgorithmIdentifier({
						algorithmId: "1.2.840.10045.2.1",
						algorithmParams: new asn1js.ObjectIdentifier({ value: this.parsedKey.namedCurve })
					});
					break;
				case "RSA":
					this.parsedKey = new RSAPublicKey({ json });
					
					this.algorithm = new AlgorithmIdentifier({
						algorithmId: "1.2.840.113549.1.1.1",
						algorithmParams: new asn1js.Null()
					});
					break;
				default:
					throw new Error(`Invalid value for "kty" parameter: ${json.kty}`);
			}
			
			this.subjectPublicKey = new asn1js.BitString({ valueHex: this.parsedKey.toSchema().toBER(false) });
		}
github PeculiarVentures / PKI.js / src / OtherRevocationInfoFormat.js View on Github external
static schema(parameters = {})
	{
		/**
		 * @type {Object}
		 * @property {string} [blockName]
		 * @property {string} [otherRevInfoFormat]
		 * @property {string} [otherRevInfo]
		 */
		const names = getParametersValue(parameters, "names", {});

		return (new asn1js.Sequence({
			name: (names.blockName || ""),
			value: [
				new asn1js.ObjectIdentifier({ name: (names.otherRevInfoFormat || "otherRevInfoFormat") }),
				new asn1js.Any({ name: (names.otherRevInfo || "otherRevInfo") })
			]
		}));
	}
	//**********************************************************************************
github PeculiarVentures / PKI.js / src / AlgorithmIdentifier.js View on Github external
static schema(parameters = {})
	{
		/**
		 * @type {Object}
		 * @property {string} algorithmIdentifier ObjectIdentifier for the algorithm
		 * @property {string} algorithmParams Any algorithm parameters
		 */
		const names = getParametersValue(parameters, "names", {});

		return (new asn1js.Sequence({
			name: (names.blockName || ""),
			optional: (names.optional || false),
			value: [
				new asn1js.ObjectIdentifier({ name: (names.algorithmIdentifier || "") }),
				new asn1js.Any({ name: (names.algorithmParams || ""), optional: true })
			]
		}));
	}
	//**********************************************************************************
github PeculiarVentures / node-webcrypto-p11 / lib / crypto / ec.ts View on Github external
} else {
        throw new Error("Absent mandatory parameter \"crv\"");
    }

    ["x", "y"].forEach((name) => {
        if (name in jwk) {
            parsedKey[name] = getCoordinate((jwk as any)[name], coordinateLength);
        } else {
            throw new Error(`Absent mandatory parameter '${name}'`);
        }
    });

    const spki = new PublicKeyInfo();
    spki.algorithm = new AlgorithmIdentifier({
        algorithmId: "1.2.840.10045.2.1",
        algorithmParams: new Asn1Js.ObjectIdentifier({ value: parsedKey.namedCurve }),
    });
    spki.subjectPublicKey = new Asn1Js.BitString({ valueHex: parsedKey.toSchema().toBER(false) });

    return spki.toSchema().toBER(false);
}
github PeculiarVentures / PKI.js / src / OtherRecipientInfo.js View on Github external
toSchema()
	{
		//region Construct and return new ASN.1 schema for this object
		return (new asn1js.Sequence({
			value: [
				new asn1js.ObjectIdentifier({ value: this.oriType }),
				this.oriValue
			]
		}));
		//endregion
	}
	//**********************************************************************************
github PeculiarVentures / PKI.js / src / AccessDescription.js View on Github external
toSchema()
	{
		//region Construct and return new ASN.1 schema for this object
		return (new asn1js.Sequence({
			value: [
				new asn1js.ObjectIdentifier({ value: this.accessMethod }),
				this.accessLocation.toSchema()
			]
		}));
		//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