How to use the pkijs.setEngine 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 / tl-create / test / cisco.js View on Github external
/// 
/// 

var xadesjs = require("xadesjs");
global.xadesjs = xadesjs;
var asn1js = require("asn1js");
global.asn1js = asn1js;
var request = require("sync-request");
global.request = request;
var Pkijs = require("pkijs");
global.Pkijs = Pkijs;
var WebCrypto = require("node-webcrypto-ossl");
webcrypto = new WebCrypto();
Pkijs.setEngine('OpenSSL', webcrypto, new Pkijs.CryptoEngine({
    name: 'OpenSSL',
    crypto: webcrypto,
    subtle: webcrypto.subtle
}));
var tl_create = require("../built/tl-create");
var assert = require("assert");

var fs = require("fs");

describe("Cisco format", function () {

    it("Parse incoming text for external root bundle", function () {
        this.timeout(15000);

        // get static file
        var ciscoText = fs.readFileSync("./test/static/ios.p7b", "binary");
github PeculiarVentures / fortify / src / main / ssl.ts View on Github external
import * as path from "path";

import * as sudo from "sudo-prompt";
import * as winston from "winston";

// PKI
import * as asn1js from "asn1js";
const pkijs = require("pkijs");

import { SRC_DIR } from "./const";
import { crypto } from "./crypto";

const CERT_NAME = `Fortify Local CA`;

// Set PKI engine
pkijs.setEngine("OpenSSL", crypto, new pkijs.CryptoEngine({ name: "OpenSSL", crypto, subtle: crypto.subtle }));

const alg = {
  name: "RSASSA-PKCS1-v1_5",
  publicExponent: new Uint8Array([1, 0, 1]),
  modulusLength: 2048,
  hash: "SHA-256",
};
const hashAlg = "SHA-256";

/**
 * Creates new certificate
 *
 * @param keyPair     Key pair for new certificate
 * @param caKey       Issuer's private key for cert TBS signing
 * @returns
 */
github PeculiarVentures / fortify / src / main / ssl.ts View on Github external
import * as fs from "fs";
import * as os from "os";
import * as path from "path";

import * as sudo from "sudo-prompt";
import * as winston from "winston";

// PKI
import * as asn1js from "asn1js";
const pkijs = require("pkijs");

import { SRC_DIR } from "./const";
import { crypto } from "./crypto";

// Set PKI engine
pkijs.setEngine("OpenSSL", crypto, new pkijs.CryptoEngine({ name: "OpenSSL", crypto, subtle: crypto.subtle }));

const alg = {
  name: "RSASSA-PKCS1-v1_5",
  publicExponent: new Uint8Array([1, 0, 1]),
  modulusLength: 2048,
  hash: "SHA-256",
};
const hashAlg = "SHA-256";

/**
 * Creates new certificate
 *
 * @param keyPair     Key pair for new certificate
 * @param caKey       Issuer's private key for cert TBS signing
 * @returns
 */
github YuryStrozhevsky / CTjs / examples / ct-monitor-auditor-example / ct-monitor-auditor-example.js View on Github external
const fetch = require("node-fetch");
const encode = require("urlencode").encode;
const assert = require("assert");

import { CryptoEngine, setEngine } from "pkijs";

// noinspection NpmUsedModulesInstalled
const WebCrypto = require("node-webcrypto-ossl");

/**
 * @type {Object}
 * @property subtle
 */
const webcrypto = new WebCrypto();

setEngine("ossl-engine", webcrypto, new CryptoEngine({ name: "", crypto: webcrypto, subtle: webcrypto.subtle }));
//*********************************************************************************
async function findIssuer(certificate, issuers)
{
	const result = issuers.slice();
	
	for(let i = 0; i < result.length; i++)
	{
		try
		{
			const verificationResult = await certificate.verify(result[i]);
			if(verificationResult)
				return result[i];
			
			result.splice(i, 1);
		}
		catch(ex)
github apowers313 / fido2-lib / lib / certUtils.js View on Github external
CryptoEngine,
    Certificate: PkijsCertificate,
    CertificateRevocationList: PkijsCertificateRevocationList,
    CertificateChainValidationEngine
} = pkijs;

const {
    printHex,
    isPem,
    pemToBase64,
    coerceToArrayBuffer,
    ab2str
} = require("./utils");

// install crypto engine in pkijs
pkijs.setEngine("newEngine", webcrypto, new CryptoEngine({
    name: "",
    crypto: webcrypto,
    subtle: webcrypto.subtle
}));

class Certificate {
    constructor(cert) {
        if (isPem(cert)) {
            cert = pemToBase64(cert);
        }

        cert = coerceToArrayBuffer(cert, "certificate");
        if (cert.byteLength === 0) {
            throw new Error("cert was empty (0 bytes)");
        }
github PeculiarVentures / xmldsigjs / src / application.ts View on Github external
public static setEngine(name: string, crypto: Crypto): void {
        engineCrypto = {
            getRandomValues: crypto.getRandomValues.bind(crypto),
            subtle: crypto.subtle,
            name,
        };
        setEngine(name, new CryptoEngine({ name, crypto, subtle: crypto.subtle }), new CryptoEngine({ name, crypto, subtle: crypto.subtle }));
    }

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 4 months ago

Package Health Score

78 / 100
Full package analysis