"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.mapX509SignatureAlgToCOSEAlg = mapX509SignatureAlgToCOSEAlg; const asn1_ecc_1 = require("@peculiar/asn1-ecc"); const asn1_rsa_1 = require("@peculiar/asn1-rsa"); const asn1_x509_post_quantum_1 = require("@peculiar/asn1-x509-post-quantum"); const cose_js_1 = require("./cose.js"); /** * Map X.509 signature algorithm OIDs to COSE algorithm IDs */ function mapX509SignatureAlgToCOSEAlg(signatureAlgorithm) { let alg; if (signatureAlgorithm === asn1_ecc_1.id_ecdsaWithSHA256) { alg = cose_js_1.COSEALG.ES256; } else if (signatureAlgorithm === asn1_ecc_1.id_ecdsaWithSHA384) { alg = cose_js_1.COSEALG.ES384; } else if (signatureAlgorithm === asn1_ecc_1.id_ecdsaWithSHA512) { alg = cose_js_1.COSEALG.ES512; } else if (signatureAlgorithm === asn1_rsa_1.id_sha256WithRSAEncryption) { alg = cose_js_1.COSEALG.RS256; } else if (signatureAlgorithm === asn1_rsa_1.id_sha384WithRSAEncryption) { alg = cose_js_1.COSEALG.RS384; } else if (signatureAlgorithm === asn1_rsa_1.id_sha512WithRSAEncryption) { alg = cose_js_1.COSEALG.RS512; } else if (signatureAlgorithm === asn1_rsa_1.id_sha1WithRSAEncryption) { alg = cose_js_1.COSEALG.RS1; } else if (signatureAlgorithm === asn1_x509_post_quantum_1.id_ml_dsa_44) { alg = cose_js_1.COSEALG.ML_DSA_44; } else if (signatureAlgorithm === asn1_x509_post_quantum_1.id_ml_dsa_65) { alg = cose_js_1.COSEALG.ML_DSA_65; } else if (signatureAlgorithm === asn1_x509_post_quantum_1.id_ml_dsa_87) { alg = cose_js_1.COSEALG.ML_DSA_87; } else { throw new Error(`Unable to map X.509 signature algorithm ${signatureAlgorithm} to a COSE algorithm`); } return alg; }