UNPKG

@peculiar/webcrypto

Version:
20 lines (19 loc) • 666 B
/** * Copyright (c) 2019-2026, Peculiar Ventures * SPDX-License-Identifier: MIT */ import * as core from "webcrypto-core"; // src/mechs/rsa/helper.ts function getJwkAlgorithm(algorithm) { switch (algorithm.name.toUpperCase()) { case "RSA-OAEP": { const mdSize = /(\d+)$/.exec(algorithm.hash.name)[1]; return `RSA-OAEP${mdSize !== "1" ? `-${mdSize}` : ""}`; } case "RSASSA-PKCS1-V1_5": return `RS${/(\d+)$/.exec(algorithm.hash.name)[1]}`; case "RSA-PSS": return `PS${/(\d+)$/.exec(algorithm.hash.name)[1]}`; case "RSA-PKCS1": return "RS1"; default: throw new core.OperationError("algorithm: Is not recognized"); } } export { getJwkAlgorithm };