How to use the graphene-pk11.NamedCurve 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
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)
    };

    // Template for derived key
github PeculiarVentures / node-webcrypto-p11 / built / algs / ec.js View on Github external
case "P-192":
                namedCurve = "secp192r1";
                break;
            case "P-256":
                namedCurve = "secp256r1";
                break;
            case "P-384":
                namedCurve = "secp384r1";
                break;
            case "P-521":
                namedCurve = "secp521r1";
                break;
            default:
                throw new Error("Unsupported namedCurve in use " + namedCurve);
        }
        return graphene_pk11_1.NamedCurve.getByName(namedCurve);
    };
    Ec.generateKey = function (session, alg, extractable, keyUsages, callback) {
github PeculiarVentures / node-webcrypto-p11 / src / mechs / ec / crypto.ts View on Github external
public static getNamedCurve(name: string): graphene.INamedCurve {
    let namedCurve: string;
    switch (name) {
      case "P-192":
        namedCurve = "secp192r1";
        break;
      case "K-256":
        const p256 = graphene.NamedCurve.getByName("secp256r1");
        return {
          name: "secp256k1",
          oid: "1.3.132.0.10",
          value: Buffer.from("06052b8104000A", "hex"),
          size: p256.size,
        };
      case "P-256":
        namedCurve = "secp256r1";
        break;
      case "P-384":
        namedCurve = "secp384r1";
        break;
      case "P-521":
        namedCurve = "secp521r1";
        break;
      case "X25519":