How to use the graphene-pk11.KeyGenMechanism.RSA 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 / node-webcrypto-p11 / lib / crypto / rsa.ts View on Github external
return new Promise((resolve, reject) => {
                    const size = algorithm.modulusLength;
                    const exp = new Buffer(algorithm.publicExponent);

                    const template = create_template(session!, algorithm as any, extractable, keyUsages);

                    // RSA params
                    template.publicKey.publicExponent = exp;
                    template.publicKey.modulusBits = size;

                    // PKCS11 generation
                    session!.generateKeyPair(KeyGenMechanism.RSA, template.publicKey, template.privateKey, (err, keys) => {
                        try {
                            if (err) {
                                reject(new WebCryptoError(`Rsa: Can not generate new key\n${err.message}`));
                            } else {
                                const wcKeyPair: CryptoKeyPair = {
                                    privateKey: new RsaCryptoKey(keys.privateKey, algorithm),
                                    publicKey: new RsaCryptoKey(keys.publicKey, algorithm),
                                };
                                resolve(wcKeyPair);
                            }
                        } catch (e) {
                            reject(e);
                        }
                    });
                });
            });
github PeculiarVentures / node-webcrypto-p11 / src / mechs / rsa / crypto.ts View on Github external
return new Promise((resolve, reject) => {
      session.generateKeyPair(KeyGenMechanism.RSA, template.publicKey, template.privateKey, (err, keys) => {
        try {
          if (err) {
            reject(new core.CryptoError(`Rsa: Can not generate new key\n${err.message}`));
          } else {
            const wcKeyPair = {
              privateKey: new RsaCryptoKey(keys.privateKey, algorithm as RsaHashedKeyAlgorithm),
              publicKey: new RsaCryptoKey(keys.publicKey, algorithm  as RsaHashedKeyAlgorithm),
            };
            resolve(wcKeyPair as any);
          }
        } catch (e) {
          reject(e);
        }
      });
    });
  }