AES-CBC with crypto.subtle

79 views Asked by At

I need to replace aes-256 JS library with native support crypto library due to performance problems.

I tried to use crypto subtle without any success.

I tried to dectrypt sequence of 0's with key that is sequence of 0's as example:

var $aesKey=await crypto.subtle.importKey('raw', new Uint8Array(32), {name: 'AES-CBC'},
         true, ['decrypt']);

var $output=await crypto.subtle.decrypt(
         {name: 'AES-CBC', iv: new Uint8Array(16)},
         $aesKey,
         new Uint8Array(16)
      );

The operation is failed. Error: Uncaught (in promise) DOMException: The operation failed for an operation-specific reason.

Why? What I do wrongly?

0

There are 0 answers