export async function supportsZeroByteGCM()

in packages/supports-web-crypto/src/supportsWebCrypto.ts [54:76]


export async function supportsZeroByteGCM(subtle: SubtleCrypto) {
  if (!supportsSubtleCrypto(subtle)) return false;
  try {
    const key = await subtle.generateKey(
      { name: "AES-GCM", length: 128 },
      false,
      ["encrypt"]
    );
    const zeroByteAuthTag = await subtle.encrypt(
      {
        name: "AES-GCM",
        iv: new Uint8Array(Array(12)),
        additionalData: new Uint8Array(Array(16)),
        tagLength: 128
      },
      key,
      new Uint8Array(0)
    );
    return zeroByteAuthTag.byteLength === 16;
  } catch {
    return false;
  }
}