From 9ae90a406587d6b0fa98e2c33c8dfce1faf2324f Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Mon, 21 Nov 2022 08:39:45 -0800 Subject: Make mapCoseAlgToWebCryptoAlg more readable --- .../server/src/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'packages/server/src') diff --git a/packages/server/src/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.ts b/packages/server/src/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.ts index 78876f8..a5bd921 100644 --- a/packages/server/src/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.ts +++ b/packages/server/src/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.ts @@ -6,13 +6,13 @@ import { COSEALG } from "../../cose"; * Convert a COSE alg ID into a corresponding string value that WebCrypto APIs expect */ export function mapCoseAlgToWebCryptoAlg(alg: COSEALG): SubtleCryptoAlg { - if ([-65535].indexOf(alg) >= 0) { + if ([COSEALG.RS1].indexOf(alg) >= 0) { return 'SHA-1'; - } else if ([-7, -37, -257].indexOf(alg) >= 0) { + } else if ([COSEALG.ES256, COSEALG.PS256, COSEALG.RS256].indexOf(alg) >= 0) { return 'SHA-256'; - } else if ([-35, -38, -258].indexOf(alg) >= 0) { + } else if ([COSEALG.ES384, COSEALG.PS384, COSEALG.RS384].indexOf(alg) >= 0) { return 'SHA-384' - } else if ([-8, -36, -39, -259].indexOf(alg) >= 0) { + } else if ([COSEALG.ES512, COSEALG.PS512, COSEALG.RS512, COSEALG.EdDSA,].indexOf(alg) >= 0) { return 'SHA-512'; } -- cgit v1.2.3