How to use the pkcs11js.PKCS11 function in pkcs11js

To help you get started, we’ve selected a few pkcs11js 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 DefinitelyTyped / DefinitelyTyped / pkcs11js / pkcs11js-tests.ts View on Github external
import * as pkcs11js from "pkcs11js";

const libPath = "C:\\tmp\\rtpkcs11ecp.dll";

let pkcs11 = new pkcs11js.PKCS11();
pkcs11.load(libPath);

pkcs11.C_Initialize();

try {
    // Getting info about PKCS11 Module
    let module_info = pkcs11.C_GetInfo();

    // Getting list of slots
    let slots = pkcs11.C_GetSlotList(true);
    let slot = slots[0];

    // Getting info about slot
    let slot_info = pkcs11.C_GetSlotInfo(slot);
    // Getting info about token
    let token_info = pkcs11.C_GetTokenInfo(slot);
github PeculiarVentures / pvpkcs11 / test / slot.js View on Github external
context("Slot", () => {

    let mod = new pkcs11.PKCS11();;
    let slot;

    before(() => {
        mod.load(config.lib);
        mod.C_Initialize();
        const slots = mod.C_GetSlotList();
        slot = slots[0];
    });

    after(() => {
        mod.C_Finalize();
    });

    it("Info", () => {
        const info = mod.C_GetSlotInfo(slot);
github PeculiarVentures / pvpkcs11 / test / rsa.js View on Github external
context("RSA", () => {

    let mod = new pkcs11.PKCS11();;
    let slot, session;

    before(() => {
        mod.load(config.lib);
        mod.C_Initialize();
        const slots = mod.C_GetSlotList();
        slot = slots[0];
        session = mod.C_OpenSession(slot, pkcs11.CKF_RW_SESSION | pkcs11.CKF_SERIAL_SESSION);
    });

    after(() => {
        mod.C_CloseAllSessions(slot);
        mod.C_Finalize();
    });

    context("GenerateKeyPair", () => {
github PeculiarVentures / pvpkcs11 / test / ec.js View on Github external
context("EC", () => {

    let mod = new pkcs11.PKCS11();;
    let slot, session;

    before(() => {
        mod.load(config.lib);
        mod.C_Initialize();
        const slots = mod.C_GetSlotList();
        slot = slots[0];
        session = mod.C_OpenSession(slot, pkcs11.CKF_RW_SESSION | pkcs11.CKF_SERIAL_SESSION);
    });

    after(() => {
        mod.C_CloseAllSessions(slot);
        mod.C_Finalize();
    });

    context("GenerateKeyPair", () => {
github PeculiarVentures / graphene / build / module.js View on Github external
Module.load = function (libFile, libName) {
        var lib = new pkcs11.PKCS11();
        lib.load(libFile);
        var module = new Module(lib);
        module.libFile = libFile;
        module.libName = libName || libFile;
        return module;
    };
    return Module;
github hyperledger / fabric-sdk-node / fabric-common / lib / impl / bccsp_pkcs11.js View on Github external
super();

		this._keySize = keySize;

		this._curveName = `secp${this._keySize}r1`;
		this._ecdsaCurve = elliptic.curves[`p${this._keySize}`];

		this._hashAlgo = hashAlgo;

		this._hashFunction = HashPrimitives[hashPair];

		/*
		 * Load native PKCS11 library, open PKCS11 session and login.
		 */
		if (_pkcs11 === null) {
			_pkcs11 = new pkcs11js.PKCS11();
		}
		this._pkcs11 = _pkcs11;

		this._pkcs11OpenSession(this._pkcs11, pkcs11Lib, pkcs11Slot, pkcs11Pin, pkcs11UserType, pkcs11ReadWrite);

		/*
		 * SKI to key cache for getKey(ski) function.
		 */
		this._skiToKey = {};
		this.keyToSki = new Map();
	}