From e12c82dace86328ee521845c9e48e4a1691b1688 Mon Sep 17 00:00:00 2001 From: James Jansson Date: Thu, 10 Jan 2019 17:14:09 +1100 Subject: [PATCH] Add types to key wrapping and unwrapping Currently, it is impossible to wrap and unwrap keys in Typescript as the algorithm parameters are not possible under the current type definitions. I have used the examples of wrap and unwrap this file as reference: https://github.com/diafygi/webcrypto-examples This is the mapping between the algorithms and types, as I see them: RSA-OAEP: RsaHashedImportParams AES-CTR: AesCtrParams AES-CBC: AesCbcParams AES-GCM: AesGcmParams AES-CFB: (can use AesCbcParams) AES-KW: (can use Algorithm) --- lib/lib.dom.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/lib.dom.d.ts b/lib/lib.dom.d.ts index 464dea83926b4..d293c660e44b2 100644 --- a/lib/lib.dom.d.ts +++ b/lib/lib.dom.d.ts @@ -14691,9 +14691,9 @@ interface SubtleCrypto { importKey(format: "raw" | "pkcs8" | "spki", keyData: Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | ArrayBuffer, algorithm: string | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | DhImportKeyParams | AesKeyAlgorithm, extractable: boolean, keyUsages: string[]): PromiseLike; importKey(format: string, keyData: JsonWebKey | Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | ArrayBuffer, algorithm: string | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | DhImportKeyParams | AesKeyAlgorithm, extractable: boolean, keyUsages: string[]): PromiseLike; sign(algorithm: string | RsaPssParams | EcdsaParams | AesCmacParams, key: CryptoKey, data: Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | ArrayBuffer): PromiseLike; - unwrapKey(format: string, wrappedKey: Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | ArrayBuffer, unwrappingKey: CryptoKey, unwrapAlgorithm: string | Algorithm, unwrappedKeyAlgorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): PromiseLike; + unwrapKey(format: string, wrappedKey: Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | ArrayBuffer, unwrappingKey: CryptoKey, unwrapAlgorithm: string | Algorithm | RsaHashedImportParams | AesCbcParams | AesCtrParams | AesGcmParams, unwrappedKeyAlgorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): PromiseLike; verify(algorithm: string | RsaPssParams | EcdsaParams | AesCmacParams, key: CryptoKey, signature: Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | ArrayBuffer, data: Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | ArrayBuffer): PromiseLike; - wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string | Algorithm): PromiseLike; + wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string | Algorithm | RsaHashedImportParams | AesCbcParams | AesCtrParams | AesGcmParams): PromiseLike; } declare var SubtleCrypto: {