anvilresearch / webcrypto

W3C Web Cryptography API for Node.js
MIT License
82 stars 14 forks source link

AES-GCM encrypt throws when passing an ArrayBuffer as data #58

Closed LinusU closed 6 years ago

LinusU commented 6 years ago

Seems like the length property is being read from the data, but that property only exists on typed arrays.

https://github.com/anvilresearch/webcrypto/blob/07129425f5d46f8e65f9f8c9732ad31abdc21537/src/algorithms/AES-GCM.js#L63

https://github.com/anvilresearch/webcrypto/blob/07129425f5d46f8e65f9f8c9732ad31abdc21537/src/algorithms/AES-GCM.js#L68-L71

I think that the proper approach is to read the byteLength

thelunararmy commented 6 years ago

Ah yes, slipped through the cracks when completing W3C outline It is an exclusive check for AES-GCM so your PR will fix it the mismatched object.

Thanks for the catch!