import { Ciphers, CipherTagLengths } from './ciphers.js';
/**
 * Decrypt plaintext buffer to plaintext buffer
 *
 * Only supports AES-GCM
 * @see https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/encrypt
 *
 * @param key Encryption key
 * @param ciphertext Encrypted buffer
 * @param iv Initialization vector
 * @param tagLength Size (bits) of authentication tag
 * @returns Resolves plaintext buffer
 */
export default async function decrypt(key, ciphertext, iv, tagLength) {
    return crypto.subtle.decrypt({
        name: Ciphers.AesGcm,
        iv,
        tagLength: tagLength || CipherTagLengths.AesGcm,
    }, key, ciphertext);
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVjcnlwdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9uYW5vdGRmLWNyeXB0by9kZWNyeXB0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxPQUFPLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxXQUFXLENBQUM7QUFFdEQ7Ozs7Ozs7Ozs7O0dBV0c7QUFDSCxNQUFNLENBQUMsT0FBTyxDQUFDLEtBQUssVUFBVSxPQUFPLENBQ25DLEdBQWMsRUFDZCxVQUFzQixFQUN0QixFQUFjLEVBQ2QsU0FBa0I7SUFFbEIsT0FBTyxNQUFNLENBQUMsTUFBTSxDQUFDLE9BQU8sQ0FDMUI7UUFDRSxJQUFJLEVBQUUsT0FBTyxDQUFDLE1BQU07UUFDcEIsRUFBRTtRQUNGLFNBQVMsRUFBRSxTQUFTLElBQUksZ0JBQWdCLENBQUMsTUFBTTtLQUNoRCxFQUNELEdBQUcsRUFDSCxVQUFVLENBQ1gsQ0FBQztBQUNKLENBQUMifQ==