mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
25 lines
589 B
JavaScript
25 lines
589 B
JavaScript
import { bench, run } from "../runner.mjs";
|
|
const crypto = require("node:crypto");
|
|
|
|
const keyPair = crypto.generateKeyPairSync("rsa", {
|
|
modulusLength: 2048,
|
|
publicKeyEncoding: {
|
|
type: "spki",
|
|
format: "pem",
|
|
},
|
|
privateKeyEncoding: {
|
|
type: "pkcs8",
|
|
format: "pem",
|
|
},
|
|
});
|
|
|
|
// Max message size for 2048-bit RSA keys
|
|
const plaintext = crypto.getRandomValues(Buffer.alloc(245));
|
|
|
|
bench("RSA sign RSA_PKCS1_PADDING round-trip", () => {
|
|
const sig = crypto.privateEncrypt(keyPair.privateKey, plaintext);
|
|
crypto.publicDecrypt(keyPair.publicKey, sig);
|
|
});
|
|
|
|
await run();
|