Files
bun.sh/bench/crypto/asymmetricCipher.js
Michael H b54137174b Bench updates (#15029)
Co-authored-by: RiskyMH <RiskyMH@users.noreply.github.com>
2024-11-08 23:15:24 -08:00

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();