How to use the asn1js.OctetString 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 / CAdES.js / examples / CAdESComplexExample / es6.js View on Github external
sequence = sequence.then(() =>
	{
		cmsSignedSimpl = new SignedData({
			version: 3,
			encapContentInfo: new EncapsulatedContentInfo({
				eContentType: "1.2.840.113549.1.9.16.1.4" // "tSTInfo" content type
				//eContentType: "1.2.840.113549.1.7.1" // "data" content type
			}),
			signerInfos: [signerInfo],
			certificates: [certSimpl]
		});
		
		cmsSignedSimpl.encapContentInfo.eContent = new asn1js.OctetString({ valueHex: tstInfo.toSchema().toBER(false) });
		
		const parameters = getAlgorithmParameters(tspPublicKey.algorithm.name, "sign");
		
		return cmsSignedSimpl.sign(tspKey, 0, parameters.algorithm.hash.name || {});
	});
github PeculiarVentures / PKI.js / src / Extension.js View on Github external
* @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 / CAdES.js / src / OcspResponsesID.js View on Github external
result => {
				if(this.ocspRepHash instanceof OtherHashAlgAndValue)
					this.ocspRepHash.hashValue = new asn1js.OctetString({ valueHex: result });
				else
					this.ocspRepHash = new asn1js.OctetString({ valueHex: result });
				
				this.ocspIdentifier = new OcspIdentifier();
				this.ocspIdentifier.fillValues({
					ocspResponse
				});
			},
			error => Promise.reject(error)
github PeculiarVentures / CAdES.js / src / ATSHashIndex.js View on Github external
result => {
				for(let i = 0; i < result.length; i++)
					_this.certificatesHashIndex.push(new asn1js.OctetString({ valueHex: result[i] }));
			},
			error => Promise.reject(error)
github PeculiarVentures / CAdES.js / src / CrlValidatedID.js View on Github external
result => {
				if(_this._crlHashType === 0)
					_this.crlHash = new asn1js.OctetString({ valueHex: result });
				else
					_this.crlHash.hashValue = new asn1js.OctetString({ valueHex: result });
				
				_this.crlIdentifier = new CrlIdentifier();
				_this.crlIdentifier.fillValues({
					crl
				});
			},
			error => Promise.reject(error)
github PeculiarVentures / PKI.js / src / RecipientKeyIdentifier.js View on Github external
static defaultValues(memberName)
	{
		switch(memberName)
		{
			case "subjectKeyIdentifier":
				return new asn1js.OctetString();
			case "date":
				return new asn1js.GeneralizedTime();
			case "other":
				return new OtherKeyAttribute();
			default:
				throw new Error(`Invalid member name for RecipientKeyIdentifier class: ${memberName}`);
		}
	}
	//**********************************************************************************
github PeculiarVentures / PKI.js / examples / TSPResponseComplexExample / es6.js View on Github external
result =>
		{
			const hashedBuffer = new ArrayBuffer(4);
			const hashedView = new Uint8Array(hashedBuffer);
			hashedView[0] = 0x7F;
			hashedView[1] = 0x02;
			hashedView[2] = 0x03;
			hashedView[3] = 0x04;
			
			const tstInfoSimpl = new TSTInfo({
				version: 1,
				policy: "1.1.1",
				messageImprint: new MessageImprint({
					hashAlgorithm: new AlgorithmIdentifier({ algorithmId: getOIDByAlgorithm({ name: hashAlg }) }),
					hashedMessage: new asn1js.OctetString({ valueHex: result })
				}),
				serialNumber: new asn1js.Integer({ valueHex: hashedBuffer }),
				genTime: new Date(),
				ordering: true,
				accuracy: new Accuracy({
					seconds: 1,
					millis: 1,
					micros: 10
				}),
				nonce: new asn1js.Integer({ valueHex: hashedBuffer })
			});
			
			return tstInfoSimpl.toSchema().toBER(false);
		}
	);
github PeculiarVentures / PKI.js / src / PrivateKeyInfo.js View on Github external
algorithmParams: new asn1js.ObjectIdentifier({ value: this.parsedKey.namedCurve })
					});
					break;
				case "RSA":
					this.parsedKey = new RSAPrivateKey({ json });

					this.privateKeyAlgorithm = 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.privateKey = new asn1js.OctetString({ valueHex: this.parsedKey.toSchema().toBER(false) });
		}
	}
	//**********************************************************************************
github PeculiarVentures / CAdES.js / src / OtherCertID.js View on Github external
result => {
				if(_this.otherCertHash instanceof asn1js.OctetString)
					_this.otherCertHash.valueBlock.valueHex = result;
				else
					_this.otherCertHash.hashValue = new asn1js.OctetString({ valueHex: result });
				
				_this.issuerSerial = new IssuerSerial({
					issuer: new GeneralNames({
						names: [
							new GeneralName({
								type: 4,
								value: certificate.issuer
							})
						]
					}),
					serialNumber: certificate.serialNumber
				});
			},
			error => Promise.reject(error)
github PeculiarVentures / PKI.js / src / MessageImprint.js View on Github external
static schema(parameters = {})
	{
		/**
		 * @type {Object}
		 * @property {string} [blockName]
		 * @property {string} [hashAlgorithm]
		 * @property {string} [hashedMessage]
		 */
		const names = getParametersValue(parameters, "names", {});

		return (new asn1js.Sequence({
			name: (names.blockName || ""),
			value: [
				AlgorithmIdentifier.schema(names.hashAlgorithm || {}),
				new asn1js.OctetString({ name: (names.hashedMessage || "") })
			]
		}));
	}
	//**********************************************************************************

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