How to use the graphene-pk11.Module function in graphene-pk11

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
/// 

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,
github PeculiarVentures / node-webcrypto-p11 / src / crypto.ts View on Github external
constructor(props: CryptoParams) {
    const mod = graphene.Module.load(props.library, props.name || props.library);
    this.name = props.name;
    try {
      if (props.libraryParameters) {
        mod.initialize({
          libraryParameters: props.libraryParameters,
        });
      } else {
        mod.initialize();
      }
    } catch (e) {
      if (!/CKR_CRYPTOKI_ALREADY_INITIALIZED/.test(e.message)) {
        throw e;
      }
    }
    this.initialized = true;
github PeculiarVentures / node-webcrypto-p11 / built / webcrypto.js View on Github external
function WebCrypto(props) {
        this.subtle = null;
        var mod = this.module = graphene_pk11_1.Module.load(props.library, props.name);
        mod.initialize();
        this.initialized = true;
        var slot = mod.getSlots(props.slot);
        if (!slot)
            throw new Error("Slot by index " + props.slot + " is not found");
        this.session = slot.open(props.sessionFlags);
        this.session.login(props.pin);
        for (var i in props.vendors) {
            graphene_pk11_1.Mechanism.vendor(props.vendors[i]);
        }
        this.subtle = new subtlecrypto_1.P11SubtleCrypto(this.session);
        this.keyStorage = new key_storage_1.KeyStorage(this.session);
    }
    WebCrypto.prototype.getRandomValues = function (array) {