mirror of
https://github.com/denoland/deno.git
synced 2024-11-28 16:20:57 -05:00
fix(ext/crypto): missing Aes key typings (#12307)
This commit is contained in:
parent
c9b0aaa8f0
commit
aeab471bea
2 changed files with 30 additions and 1 deletions
|
@ -499,3 +499,24 @@ unitTest(async function testHkdfDeriveBits() {
|
||||||
);
|
);
|
||||||
assertEquals(result.byteLength, 128 / 8);
|
assertEquals(result.byteLength, 128 / 8);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Doesn't need to cover all cases.
|
||||||
|
// Only for testing types.
|
||||||
|
unitTest(async function testAesKeyGen() {
|
||||||
|
const key = await crypto.subtle.generateKey(
|
||||||
|
{
|
||||||
|
name: "AES-GCM",
|
||||||
|
length: 256,
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
["encrypt", "decrypt"],
|
||||||
|
);
|
||||||
|
|
||||||
|
assert(key);
|
||||||
|
assertEquals(key.type, "secret");
|
||||||
|
assertEquals(key.extractable, true);
|
||||||
|
assertEquals(key.usages, ["encrypt", "decrypt"]);
|
||||||
|
const algorithm = key.algorithm as AesKeyAlgorithm;
|
||||||
|
assertEquals(algorithm.name, "AES-GCM");
|
||||||
|
assertEquals(algorithm.length, 256);
|
||||||
|
});
|
||||||
|
|
10
ext/crypto/lib.deno_crypto.d.ts
vendored
10
ext/crypto/lib.deno_crypto.d.ts
vendored
|
@ -125,6 +125,14 @@ interface Pbkdf2Params extends Algorithm {
|
||||||
salt: BufferSource;
|
salt: BufferSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface AesKeyGenParams extends Algorithm {
|
||||||
|
length: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AesKeyAlgorithm extends KeyAlgorithm {
|
||||||
|
length: number;
|
||||||
|
}
|
||||||
|
|
||||||
/** The CryptoKey dictionary of the Web Crypto API represents a cryptographic key. */
|
/** The CryptoKey dictionary of the Web Crypto API represents a cryptographic key. */
|
||||||
interface CryptoKey {
|
interface CryptoKey {
|
||||||
readonly algorithm: KeyAlgorithm;
|
readonly algorithm: KeyAlgorithm;
|
||||||
|
@ -157,7 +165,7 @@ interface SubtleCrypto {
|
||||||
keyUsages: KeyUsage[],
|
keyUsages: KeyUsage[],
|
||||||
): Promise<CryptoKeyPair>;
|
): Promise<CryptoKeyPair>;
|
||||||
generateKey(
|
generateKey(
|
||||||
algorithm: HmacKeyGenParams,
|
algorithm: AesKeyGenParams | HmacKeyGenParams,
|
||||||
extractable: boolean,
|
extractable: boolean,
|
||||||
keyUsages: KeyUsage[],
|
keyUsages: KeyUsage[],
|
||||||
): Promise<CryptoKey>;
|
): Promise<CryptoKey>;
|
||||||
|
|
Loading…
Reference in a new issue