-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch from node-webcrypto-ossl to @peculiar/webcrypto #27
Conversation
Due to PeculiarVentures/node-webcrypto-ossl#138 @peculiar/webcrypto is the replacement which doesn't need C code (uses Node crypto from JS only).
Note: published as @davedoesdev/fido2-lib and will install on Node 11.9.0 |
Looks like the issue with node-webcrypto-ossl was fixed in PeculiarVentures/node-webcrypto-ossl@fecc26f @microshine which do you recommend - node-webcrypto-ossl or webcrypto? |
@davedoesdev Installationnode-webcrypto-ossl
@peculiar/webcrypto
Speed testimport * as assert from "assert";
import { Crypto } from "@peculiar/webcrypto";
const CryptoOSSL: typeof Crypto = require("node-webcrypto-ossl");
async function main() {
const providers = [
{ name: "@peculiar/webcrypto", crypto: new Crypto() },
{ name: "node-webcrypto-ossl", crypto: new CryptoOSSL() },
]
const iterations = 1000;
const data = Buffer.from("Test message");
const alg: RsaHashedKeyGenParams = {
name: "RSASSA-PKCS1-v1_5",
hash: "SHA-256",
publicExponent: new Uint8Array([1, 0, 1]),
modulusLength: 2048,
};
for (const provider of providers) {
const testName = `Speed test for ${provider.name} ${iterations} iterations`;
console.time(testName);
const keys = await provider.crypto.subtle.generateKey(alg, false, ["sign", "verify"]);
let it = iterations;
while (it--) {
const signature = await provider.crypto.subtle.sign(alg, keys.privateKey, data);
const ok = await provider.crypto.subtle.verify(alg, keys.publicKey, signature, data);
assert.equal(ok, true);
}
console.timeEnd(testName);
}
}
main().catch(err => console.error(err)); Output
|
@microshine many thanks. |
node-webcrypto-ossl has been installing and working for a while now, so closing this PR |
@microshine I've just done the speed test and got:
Has |
It depends on the mechanisms you are using. As I can remember |
My current speed test result is
|
@microshine thanks, appreciate it. I'll close this PR again to keep this library using the native version. In my clone I think I'll switch to |
You can use something like |
Due to PeculiarVentures/node-webcrypto-ossl#138
@peculiar/webcrypto is the replacement which doesn't need C code
(uses Node crypto from JS only).