Files
NapCatQQ/.pnpm-store/v3/files/cc/2bc44f6e1923cafb3e87e99a880d692b03aff938ea0925dcf55d3b94c2c9b7f3cc4e0c4402acd1cc1b807a8036efe617db19742d7a1ffb8ca042d42204d0e3
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

36 lines
1.1 KiB
Plaintext

import { COSEALG } from './cose.js';
/**
* Map X.509 signature algorithm OIDs to COSE algorithm IDs
*
* - EC2 OIDs: https://oidref.com/1.2.840.10045.4.3
* - RSA OIDs: https://oidref.com/1.2.840.113549.1.1
*/
export function mapX509SignatureAlgToCOSEAlg(signatureAlgorithm) {
let alg;
if (signatureAlgorithm === '1.2.840.10045.4.3.2') {
alg = COSEALG.ES256;
}
else if (signatureAlgorithm === '1.2.840.10045.4.3.3') {
alg = COSEALG.ES384;
}
else if (signatureAlgorithm === '1.2.840.10045.4.3.4') {
alg = COSEALG.ES512;
}
else if (signatureAlgorithm === '1.2.840.113549.1.1.11') {
alg = COSEALG.RS256;
}
else if (signatureAlgorithm === '1.2.840.113549.1.1.12') {
alg = COSEALG.RS384;
}
else if (signatureAlgorithm === '1.2.840.113549.1.1.13') {
alg = COSEALG.RS512;
}
else if (signatureAlgorithm === '1.2.840.113549.1.1.5') {
alg = COSEALG.RS1;
}
else {
throw new Error(`Unable to map X.509 signature algorithm ${signatureAlgorithm} to a COSE algorithm`);
}
return alg;
}