How to use graphene-pk11 - 10 common examples

To help you get started, we’ve selected a few graphene-pk11 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 / graphene / test / graphene-pk11-tests.ts View on Github external
token: false,
            derive: true
        });

    // derive algorithm
    let alg = {
        name: "ECDH1_DERIVE",
        params: new graphene.EcdhParams(
            graphene.EcKdf.SHA1,
            null,
            keys.publicKey.getAttribute({ pointEC: null }).pointEC)
    };

    // Template for derived key
    let template = {
        "class": graphene.ObjectClass.SECRET_KEY,
        "token": false,
        "keyType": graphene.KeyType.AES,
        "valueLen": 256 / 8,
        "encrypt": true,
        "decrypt": true
    };

    // Key derivation
    let dKey = session.deriveKey(alg, keys.privateKey, template);
    console.log("Derived key handle:", dKey.handle);

    session.logout();
    session.close();
}
else {
    console.error("Slot is not initialized");
github PeculiarVentures / graphene / test / graphene-pk11-tests.ts View on Github external
});

    // derive algorithm
    let alg = {
        name: "ECDH1_DERIVE",
        params: new graphene.EcdhParams(
            graphene.EcKdf.SHA1,
            null,
            keys.publicKey.getAttribute({ pointEC: null }).pointEC)
    };

    // Template for derived key
    let template = {
        "class": graphene.ObjectClass.SECRET_KEY,
        "token": false,
        "keyType": graphene.KeyType.AES,
        "valueLen": 256 / 8,
        "encrypt": true,
        "decrypt": true
    };

    // Key derivation
    let dKey = session.deriveKey(alg, keys.privateKey, template);
    console.log("Derived key handle:", dKey.handle);

    session.logout();
    session.close();
}
else {
    console.error("Slot is not initialized");
}
github PeculiarVentures / node-webcrypto-p11 / test / rsa.js View on Github external
context("RSA_PKCS Sign/Verify", () => {
        const SHA256_RSA_PKCS = graphene.MechanismEnum["SHA256_RSA_PKCS"];

        before(() => {
            // delete SHA256_RSA_PKCS
            delete graphene.MechanismEnum["SHA256_RSA_PKCS"];
            delete graphene.MechanismEnum[SHA256_RSA_PKCS];
        })

        after(() => {
            // recover SHA256_RSA_PKCS
            graphene.MechanismEnum["SHA256_RSA_PKCS"] = SHA256_RSA_PKCS;
            graphene.MechanismEnum[SHA256_RSA_PKCS] = "SHA256_RSA_PKCS";
        })

        it("remove SHA256_RSA_PKCS mechanism", (done) => {
            const algorithm = {
                name: "RSASSA-PKCS1-v1_5",
github PeculiarVentures / graphene / test / graphene-pk11-tests.ts View on Github external
import * as graphene from "graphene-pk11";
let Module = graphene.Module;

let lib = "/usr/local/lib/softhsm/libsofthsm2.so";

let mod = Module.load(lib, "SoftHSM");
mod.initialize();

let slot = mod.getSlots(0);
if (slot.flags & graphene.SlotFlag.TOKEN_PRESENT) {
    let session = slot.open();
    session.login("12345");

    // generate EC key
    let keys = session.generateKeyPair(graphene.KeyGenMechanism.ECDSA, {
        keyType: graphene.KeyType.ECDSA,
        token: false,
        derive: true,
        paramsECDSA: graphene.NamedCurve.getByName("secp192r1").value
    }, {
            keyType: graphene.KeyType.ECDSA,
            token: false,
            derive: true
        });

    // derive algorithm
    let alg = {
        name: "ECDH1_DERIVE",
        params: new graphene.EcdhParams(
            graphene.EcKdf.SHA1,
            null,
            keys.publicKey.getAttribute({ pointEC: null }).pointEC)
github PeculiarVentures / graphene / test / graphene-pk11-tests.ts View on Github external
import * as graphene from "graphene-pk11";
let Module = graphene.Module;

let lib = "/usr/local/lib/softhsm/libsofthsm2.so";

let mod = Module.load(lib, "SoftHSM");
mod.initialize();

let slot = mod.getSlots(0);
if (slot.flags & graphene.SlotFlag.TOKEN_PRESENT) {
    let session = slot.open();
    session.login("12345");

    // generate EC key
    let keys = session.generateKeyPair(graphene.KeyGenMechanism.ECDSA, {
        keyType: graphene.KeyType.ECDSA,
        token: false,
        derive: true,
        paramsECDSA: graphene.NamedCurve.getByName("secp192r1").value
    }, {
            keyType: graphene.KeyType.ECDSA,
            token: false,
            derive: true
        });

    // derive algorithm
    let alg = {
        name: "ECDH1_DERIVE",
        params: new graphene.EcdhParams(
            graphene.EcKdf.SHA1,
            null,
github PeculiarVentures / node-webcrypto-p11 / test / rsa.js View on Github external
after(() => {
            // recover SHA256_RSA_PKCS
            graphene.MechanismEnum["SHA256_RSA_PKCS"] = SHA256_RSA_PKCS;
            graphene.MechanismEnum[SHA256_RSA_PKCS] = "SHA256_RSA_PKCS";
        })
github PeculiarVentures / node-webcrypto-p11 / test / rsa.js View on Github external
after(() => {
            // recover SHA256_RSA_PKCS
            graphene.MechanismEnum["SHA256_RSA_PKCS"] = SHA256_RSA_PKCS;
            graphene.MechanismEnum[SHA256_RSA_PKCS] = "SHA256_RSA_PKCS";
        })
github PeculiarVentures / graphene / test / graphene-pk11-tests.ts View on Github external
// generate EC key
    let keys = session.generateKeyPair(graphene.KeyGenMechanism.ECDSA, {
        keyType: graphene.KeyType.ECDSA,
        token: false,
        derive: true,
        paramsECDSA: graphene.NamedCurve.getByName("secp192r1").value
    }, {
            keyType: graphene.KeyType.ECDSA,
            token: false,
            derive: true
        });

    // derive algorithm
    let alg = {
        name: "ECDH1_DERIVE",
        params: new graphene.EcdhParams(
            graphene.EcKdf.SHA1,
            null,
            keys.publicKey.getAttribute({ pointEC: null }).pointEC)
    };

    // Template for derived key
    let template = {
        "class": graphene.ObjectClass.SECRET_KEY,
        "token": false,
        "keyType": graphene.KeyType.AES,
        "valueLen": 256 / 8,
        "encrypt": true,
        "decrypt": true
    };

    // Key derivation
github PeculiarVentures / graphene / test / graphene-pk11-tests.ts View on Github external
let keys = session.generateKeyPair(graphene.KeyGenMechanism.ECDSA, {
        keyType: graphene.KeyType.ECDSA,
        token: false,
        derive: true,
        paramsECDSA: graphene.NamedCurve.getByName("secp192r1").value
    }, {
            keyType: graphene.KeyType.ECDSA,
            token: false,
            derive: true
        });

    // derive algorithm
    let alg = {
        name: "ECDH1_DERIVE",
        params: new graphene.EcdhParams(
            graphene.EcKdf.SHA1,
            null,
            keys.publicKey.getAttribute({ pointEC: null }).pointEC)
    };

    // Template for derived key
    let template = {
        "class": graphene.ObjectClass.SECRET_KEY,
        "token": false,
        "keyType": graphene.KeyType.AES,
        "valueLen": 256 / 8,
        "encrypt": true,
        "decrypt": true
    };

    // Key derivation
    let dKey = session.deriveKey(alg, keys.privateKey, template);
github PeculiarVentures / graphene / test / graphene-pk11-tests.ts View on Github external
/// 

import * as graphene from "graphene-pk11";
let Module = graphene.Module;

let lib = "/usr/local/lib/softhsm/libsofthsm2.so";

let mod = Module.load(lib, "SoftHSM");
mod.initialize();

let slot = mod.getSlots(0);
if (slot.flags & graphene.SlotFlag.TOKEN_PRESENT) {
    let session = slot.open();
    session.login("12345");

    // generate EC key
    let keys = session.generateKeyPair(graphene.KeyGenMechanism.ECDSA, {
        keyType: graphene.KeyType.ECDSA,
        token: false,
        derive: true,