themis icon indicating copy to clipboard operation
themis copied to clipboard

Add ALLOW_MEMORY_GROWTH=1

Open djaffer opened this issue 3 years ago • 2 comments

To Reproduce Steps to reproduce the behavior: Encrypt a large file like a video 20 MB using wasm-themis library. Runs out of memory buffer.

  1. Convert File to Uint8
  2. Encrypt File using Secure Cell
const bytes = new Uint8Array(file.arrayBuffer());

let symmetricKey = new themis.SymmetricKey()

let sealCell = themis.SecureCellSeal.withKey(symmetricKey)

let contextImprintCell= themis.SecureCellContextImprint.withKey(symmetricKey);

let encryptedWithSeal = sealCell.encrypt(bytes); // this line causes issue
let context = Uint8Array(...)
let encryptedWithContextImprintCelll = contextImprintCell.encrypt(bytes,context); // the same issue

See the following error: image

Expected behavior Encryption to work for files

OS: Windows Hardware: not relevant browser computer Themis version: 0.14.6 Installation way: npm

suggested fix: Add ALLOW_MEMORY_GROWTH=1 to fix the issue #928

djaffer avatar Jul 23 '22 03:07 djaffer

@radetsky here is an example ^

vixentael avatar Jul 26 '22 10:07 vixentael

Thanks for the investigation and the patch, @djaffer!

WasmThemis tests are currently failing for Node v16. I'd wait for that to be fixed first before merging this...

ilammy avatar Aug 03 '22 16:08 ilammy

'kay, master should have WasmThemis build fixed by now. If CI tests pass, this should good to merge 👍

ilammy avatar Aug 12 '22 09:08 ilammy

Thank you for your contribution, @djaffer!

ilammy avatar Aug 12 '22 10:08 ilammy

thank you @djaffer

we are releasing Themis hotfix with this patch today (hopefully, 🤞)

vixentael avatar Aug 12 '22 14:08 vixentael

Awesome guys! Thank you! If you guys have any other alternatives like breaking files into chunks etc. Please share that too in the documentation.

djaffer avatar Aug 13 '22 04:08 djaffer

Also, a humble suggestion/request, if you guys can come up with docker, nodejs alpine builds or any ubuntu alpine with workable themis binaries compiling it will be a huge help. Especially for people who are new to this, it will help with how to compile, etc. We can then be a working hand to you in cases like these. Installing the BoringSSL was a nightmare for me I am not sure if I got it.

djaffer avatar Aug 13 '22 04:08 djaffer

we do support docker image, mainly for building themis android https://docs.cossacklabs.com/themis/languages/java/installation-android/#using-docker

but it's based on ubuntu https://github.com/cossacklabs/dockerfiles/blob/master/android-build/Dockerfile

i totally agree that refreshing it + adding alpine makes sense. would you mind creating a separate issue for that? @djaffer

vixentael avatar Aug 18 '22 15:08 vixentael

Sure. Thanks @vixentael

djaffer avatar Aug 19 '22 12:08 djaffer