1'use strict'; 2 3const common = require('../common'); 4 5if (!common.hasCrypto) 6 common.skip('missing crypto'); 7 8const assert = require('assert'); 9const crypto = require('crypto').webcrypto; 10 11crypto.subtle.importKey( 12 'raw', 13 new Uint8Array(32), 14 { 15 name: 'AES-GCM' 16 }, 17 false, 18 [ 'encrypt', 'decrypt' ]) 19 .then((k) => { 20 assert.rejects(() => { 21 return crypto.subtle.decrypt({ 22 name: 'AES-GCM', 23 iv: new Uint8Array(12), 24 }, k, new Uint8Array(0)); 25 }, { 26 name: 'OperationError', 27 message: /The provided data is too small/, 28 }); 29 }); 30