vibornoff/webcrypto-shim

Passing DataView as encrypt data in Internet Explorer fails with error

aduth opened this issue · 0 comments

aduth commented

When passing an instance of DataView as the data argument of encrypt in Internet Explorer, an error "Error: Invalid argument" is thrown.

Example snippet:

crypto.subtle.generateKey( { name: 'AES-GCM', length: 256 }, true, [ 'encrypt', 'decrypt' ] )
  .then( function ( key ) {
    return crypto.subtle.encrypt( { name: 'AES-GCM', iv: new Uint8Array(12), tagLength: 128 }, key, new DataView(new Uint8Array(16).buffer) )
  }).then( function() { console.log('Done'); }).catch(function( err ) { console.log('Error', err); });

This works in other browsers, and is at least documented by TypeScript built-in DOM types as a supported type for the data argument (source). I assume this is based on specifications, though I've not yet tracked those down.