@credo-ts/core
Version:
<p align="center"> <br /> <img alt="Credo Logo" src="https://github.com/openwallet-foundation/credo-ts/blob/c7886cb8377ceb8ee4efe8d264211e561a75072d/images/credo-logo.png" height="250px" /> </p> <h1 align="center"><b>Credo - Core</b></h1
25 lines (22 loc) • 842 B
JavaScript
//#region src/modules/x509/utils/signatureAlgorithm.ts
/**
* Converts an x509 signatureAlgorithm (HashedAlgorithm) to a JWA algorithm string.
* Returns undefined for non-RSA algorithms.
*/
function x509SignatureAlgorithmToJwa(signatureAlgorithm) {
const hash = signatureAlgorithm.hash?.name;
if (signatureAlgorithm.name === "RSASSA-PKCS1-v1_5") switch (hash) {
case "SHA-256": return "RS256";
case "SHA-384": return "RS384";
case "SHA-512": return "RS512";
}
else if (signatureAlgorithm.name === "RSA-PSS") switch (hash) {
case "SHA-256": return "PS256";
case "SHA-384": return "PS384";
case "SHA-512": return "PS512";
}
throw new Error(`Unsupported signature algorithm: ${signatureAlgorithm.name} with hash ${hash}`);
}
//#endregion
export { x509SignatureAlgorithmToJwa };
//# sourceMappingURL=signatureAlgorithm.mjs.map