@sphereon/ssi-sdk-ext.key-utils 0.36.1-feature.SSISDK.82.and.SSISDK.70.37 → 0.36.1-feature.integration.fides.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +95 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +95 -0
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/conversion.ts +53 -0
package/src/conversion.ts
CHANGED
|
@@ -242,3 +242,56 @@ export function coseToJoseCurve(curve: ICoseCurve): JoseCurve {
|
|
|
242
242
|
throw Error(`Curve ${curve} not supported in Jose`)
|
|
243
243
|
}
|
|
244
244
|
}
|
|
245
|
+
|
|
246
|
+
export function joseSignatureAlgToWebCrypto(alg: JoseSignatureAlgorithm | JoseSignatureAlgorithmString): {
|
|
247
|
+
name: string
|
|
248
|
+
hash: string
|
|
249
|
+
saltLength?: number
|
|
250
|
+
} {
|
|
251
|
+
switch (alg) {
|
|
252
|
+
case JoseSignatureAlgorithm.RS256:
|
|
253
|
+
case 'RS256':
|
|
254
|
+
return { name: 'RSASSA-PKCS1-v1_5', hash: 'SHA-256' }
|
|
255
|
+
case JoseSignatureAlgorithm.RS384:
|
|
256
|
+
case 'RS384':
|
|
257
|
+
return { name: 'RSASSA-PKCS1-v1_5', hash: 'SHA-384' }
|
|
258
|
+
case JoseSignatureAlgorithm.RS512:
|
|
259
|
+
case 'RS512':
|
|
260
|
+
return { name: 'RSASSA-PKCS1-v1_5', hash: 'SHA-512' }
|
|
261
|
+
case JoseSignatureAlgorithm.PS256:
|
|
262
|
+
case 'PS256':
|
|
263
|
+
return { name: 'RSA-PSS', hash: 'SHA-256', saltLength: 32 }
|
|
264
|
+
case JoseSignatureAlgorithm.PS384:
|
|
265
|
+
case 'PS384':
|
|
266
|
+
return { name: 'RSA-PSS', hash: 'SHA-384', saltLength: 48 }
|
|
267
|
+
case JoseSignatureAlgorithm.PS512:
|
|
268
|
+
case 'PS512':
|
|
269
|
+
return { name: 'RSA-PSS', hash: 'SHA-512', saltLength: 64 }
|
|
270
|
+
case JoseSignatureAlgorithm.ES256:
|
|
271
|
+
case 'ES256':
|
|
272
|
+
return { name: 'ECDSA', hash: 'SHA-256' }
|
|
273
|
+
case JoseSignatureAlgorithm.ES384:
|
|
274
|
+
case 'ES384':
|
|
275
|
+
return { name: 'ECDSA', hash: 'SHA-384' }
|
|
276
|
+
case JoseSignatureAlgorithm.ES512:
|
|
277
|
+
case 'ES512':
|
|
278
|
+
return { name: 'ECDSA', hash: 'SHA-512' }
|
|
279
|
+
case JoseSignatureAlgorithm.ES256K:
|
|
280
|
+
case 'ES256K':
|
|
281
|
+
return { name: 'ECDSA', hash: 'SHA-256' }
|
|
282
|
+
case JoseSignatureAlgorithm.EdDSA:
|
|
283
|
+
case 'EdDSA':
|
|
284
|
+
return { name: 'Ed25519', hash: '' }
|
|
285
|
+
case JoseSignatureAlgorithm.HS256:
|
|
286
|
+
case 'HS256':
|
|
287
|
+
return { name: 'HMAC', hash: 'SHA-256' }
|
|
288
|
+
case JoseSignatureAlgorithm.HS384:
|
|
289
|
+
case 'HS384':
|
|
290
|
+
return { name: 'HMAC', hash: 'SHA-384' }
|
|
291
|
+
case JoseSignatureAlgorithm.HS512:
|
|
292
|
+
case 'HS512':
|
|
293
|
+
return { name: 'HMAC', hash: 'SHA-512' }
|
|
294
|
+
default:
|
|
295
|
+
throw Error(`Signature algorithm ${alg} not supported in Web Crypto API`)
|
|
296
|
+
}
|
|
297
|
+
}
|