mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
25 lines
599 B
JavaScript
25 lines
599 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(214));
|
|
|
|
bench("RSA_PKCS1_OAEP_PADDING round-trip", () => {
|
|
const ciphertext = crypto.publicEncrypt(keyPair.publicKey, plaintext);
|
|
crypto.privateDecrypt(keyPair.privateKey, ciphertext);
|
|
});
|
|
|
|
await run();
|