How to use the pkijs.ContentInfo function in pkijs

To help you get started, we’ve selected a few pkijs 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(() =>
	{
		const tspResponse = new TimeStampResp({
			status: new PKIStatusInfo({
				status: 0 // granted
			}),
			timeStampToken: new ContentInfo({
				contentType: "1.2.840.113549.1.7.2",
				content: cmsSignedSimpl.toSchema(false)
			})
		});
		
		return tspResponse.toSchema().toBER(false);
	});
github PeculiarVentures / CAdES.js / examples / CAdESComplexExample / es6.js View on Github external
document.getElementById("cms-certs").style.display = "none";
	document.getElementById("cms-crls").style.display = "none";
	
	const certificatesTable = document.getElementById("cms-certificates");
	while(certificatesTable.rows.length > 1)
		certificatesTable.deleteRow(certificatesTable.rows.length - 1);
	
	const crlsTable = document.getElementById("cms-rev-lists");
	while(crlsTable.rows.length > 1)
		crlsTable.deleteRow(crlsTable.rows.length - 1);
	//endregion
	
	//region Decode existing CMS Signed Data
	const asn1 = asn1js.fromBER(cmsSignedBuffer);
	const cmsContentSimpl = new ContentInfo({ schema: asn1.result });
	const cmsSignedSimpl = new SignedData({ schema: cmsContentSimpl.content });
	
	for(const signerInfo of cmsSignedSimpl.signerInfos)
	{
		if("signedAttrs" in signerInfo)
			signerInfo.signedAttrs.attributes = Array.from(signerInfo.signedAttrs.attributes, element => new AttributeCAdES(element));
		
		if("unsignedAttrs" in signerInfo)
			signerInfo.unsignedAttrs.attributes = Array.from(signerInfo.unsignedAttrs.attributes, element => new AttributeCAdES(element));
	}
	//endregion
	
	//region Put information about digest algorithms in the CMS Signed Data
	const dgstmap = {
		"1.3.14.3.2.26": "SHA-1",
		"2.16.840.1.101.3.4.2.1": "SHA-256",
github PeculiarVentures / CAdES.js / examples / CAdESComplexExample / es6.js View on Github external
sequence = sequence.then(() =>
	{
		const cmsContent = new ContentInfo({
			contentType: "1.2.840.113549.1.7.2",
			content: cmsSignedSimpl.toSchema(true)
		});
		
		cmsSignedBuffer = cmsContent.toSchema().toBER(false);
	});
	//endregion
github PeculiarVentures / tl-create / src / formats / cisco.ts View on Github external
if(!data) {
                let res = request('GET', this.fetchurl, { 'timeout': 10000, 'retry': true, 'headers': { 'user-agent': 'nodejs' } });
                databuf = res.body.buffer;
            } else {
                databuf = Pvutils.stringToArrayBuffer(data);
            }

            let asn1obj = Asn1js.fromBER(databuf);
            let contentInfo = new Pkijs.ContentInfo({schema: asn1obj.result});

            if(contentInfo.contentType !== "1.2.840.113549.1.7.2")
                throw new Error(`Unknown content type '${contentInfo.contentType}' for contentInfo`);

            this.signedData = new Pkijs.SignedData({schema: contentInfo.content});
            let asn1obj2 = Asn1js.fromBER(this.signedData.encapContentInfo.eContent.valueBlock.valueHex);
            let contentInfo2 = new Pkijs.ContentInfo({schema: asn1obj2.result});

            if(contentInfo.contentType !== "1.2.840.113549.1.7.2")
                throw new Error(`Unknown content type '${contentInfo.contentType}' for contentInfo`);

            let signedData2 = new Pkijs.SignedData({schema: contentInfo2.content});

            for(let cert of signedData2.certificates) {
                let operator = "Unknown";
                for(let rdn of cert.subject.typesAndValues) {
                    if(rdn.type === "2.5.4.10") {
                        operator = rdn.value.valueBlock.value;
                        break;
                    }
                }
                tl.AddCertificate({
                    raw: Pvutils.toBase64(Pvutils.arrayBufferToString(cert.toSchema(true).toBER())),
github PeculiarVentures / tl-create / src / formats / cisco.ts View on Github external
getTrusted(data?: string): TrustedList {
            let tl = new TrustedList();
            let databuf: Buffer;

            if(!data) {
                let res = request('GET', this.fetchurl, { 'timeout': 10000, 'retry': true, 'headers': { 'user-agent': 'nodejs' } });
                databuf = res.body.buffer;
            } else {
                databuf = Pvutils.stringToArrayBuffer(data);
            }

            let asn1obj = Asn1js.fromBER(databuf);
            let contentInfo = new Pkijs.ContentInfo({schema: asn1obj.result});

            if(contentInfo.contentType !== "1.2.840.113549.1.7.2")
                throw new Error(`Unknown content type '${contentInfo.contentType}' for contentInfo`);

            this.signedData = new Pkijs.SignedData({schema: contentInfo.content});
            let asn1obj2 = Asn1js.fromBER(this.signedData.encapContentInfo.eContent.valueBlock.valueHex);
            let contentInfo2 = new Pkijs.ContentInfo({schema: asn1obj2.result});

            if(contentInfo.contentType !== "1.2.840.113549.1.7.2")
                throw new Error(`Unknown content type '${contentInfo.contentType}' for contentInfo`);

            let signedData2 = new Pkijs.SignedData({schema: contentInfo2.content});

            for(let cert of signedData2.certificates) {
                let operator = "Unknown";
                for(let rdn of cert.subject.typesAndValues) {
github PeculiarVentures / tl-create / built / tl-create.js View on Github external
Cisco.prototype.getTrusted = function (data) {
            var tl = new tl_create.TrustedList();
            var databuf;
            if (!data) {
                var res = request('GET', this.fetchurl, { 'timeout': 10000, 'retry': true, 'headers': { 'user-agent': 'nodejs' } });
                databuf = res.body.buffer;
            }
            else {
                databuf = Pvutils.stringToArrayBuffer(data);
            }
            var asn1obj = Asn1js.fromBER(databuf);
            var contentInfo = new Pkijs.ContentInfo({ schema: asn1obj.result });
            if (contentInfo.contentType !== "1.2.840.113549.1.7.2")
                throw new Error("Unknown content type '" + contentInfo.contentType + "' for contentInfo");
            this.signedData = new Pkijs.SignedData({ schema: contentInfo.content });
            var asn1obj2 = Asn1js.fromBER(this.signedData.encapContentInfo.eContent.valueBlock.valueHex);
            var contentInfo2 = new Pkijs.ContentInfo({ schema: asn1obj2.result });
            if (contentInfo.contentType !== "1.2.840.113549.1.7.2")
                throw new Error("Unknown content type '" + contentInfo.contentType + "' for contentInfo");
            var signedData2 = new Pkijs.SignedData({ schema: contentInfo2.content });
            for (var _i = 0, _a = signedData2.certificates; _i < _a.length; _i++) {
                var cert = _a[_i];
                var operator = "Unknown";
                for (var _b = 0, _c = cert.subject.typesAndValues; _b < _c.length; _b++) {
                    var rdn = _c[_b];
                    if (rdn.type === "2.5.4.10") {
                        operator = rdn.value.valueBlock.value;
                        break;
github PeculiarVentures / tl-create / built / tl-create.js View on Github external
var tl = new tl_create.TrustedList();
            var databuf;
            if (!data) {
                var res = request('GET', this.fetchurl, { 'timeout': 10000, 'retry': true, 'headers': { 'user-agent': 'nodejs' } });
                databuf = res.body.buffer;
            }
            else {
                databuf = Pvutils.stringToArrayBuffer(data);
            }
            var asn1obj = Asn1js.fromBER(databuf);
            var contentInfo = new Pkijs.ContentInfo({ schema: asn1obj.result });
            if (contentInfo.contentType !== "1.2.840.113549.1.7.2")
                throw new Error("Unknown content type '" + contentInfo.contentType + "' for contentInfo");
            this.signedData = new Pkijs.SignedData({ schema: contentInfo.content });
            var asn1obj2 = Asn1js.fromBER(this.signedData.encapContentInfo.eContent.valueBlock.valueHex);
            var contentInfo2 = new Pkijs.ContentInfo({ schema: asn1obj2.result });
            if (contentInfo.contentType !== "1.2.840.113549.1.7.2")
                throw new Error("Unknown content type '" + contentInfo.contentType + "' for contentInfo");
            var signedData2 = new Pkijs.SignedData({ schema: contentInfo2.content });
            for (var _i = 0, _a = signedData2.certificates; _i < _a.length; _i++) {
                var cert = _a[_i];
                var operator = "Unknown";
                for (var _b = 0, _c = cert.subject.typesAndValues; _b < _c.length; _b++) {
                    var rdn = _c[_b];
                    if (rdn.type === "2.5.4.10") {
                        operator = rdn.value.valueBlock.value;
                        break;
                    }
                }
                tl.AddCertificate({
                    raw: Pvutils.toBase64(Pvutils.arrayBufferToString(cert.toSchema(true).toBER())),
                    trust: ["ANY"],

pkijs

Public Key Infrastructure (PKI) is the basis of how identity and key management is performed on the web today. PKIjs is a pure JavaScript library implementing the formats that are used in PKI applications. It is built on WebCrypto and aspires to make it p

BSD-3-Clause
Latest version published 5 days ago

Package Health Score

81 / 100
Full package analysis