Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'graphene-pk11' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
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");
});
// 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");
}
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",
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)
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,
after(() => {
// recover SHA256_RSA_PKCS
graphene.MechanismEnum["SHA256_RSA_PKCS"] = SHA256_RSA_PKCS;
graphene.MechanismEnum[SHA256_RSA_PKCS] = "SHA256_RSA_PKCS";
})
after(() => {
// recover SHA256_RSA_PKCS
graphene.MechanismEnum["SHA256_RSA_PKCS"] = SHA256_RSA_PKCS;
graphene.MechanismEnum[SHA256_RSA_PKCS] = "SHA256_RSA_PKCS";
})
// 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
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);
///
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,