vibornoff / webcrypto-shim

Web Cryptography API shim for legacy browsers

Home Page:https://vibornoff.github.io/webcrypto-shim/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Passing DataView as encrypt data in Internet Explorer fails with error

aduth opened this issue · comments

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.