Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
///
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,
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;
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) {