feat: add xsalsa20 cipher from libsodium#689
Conversation
…pt, C++ 20, test passes
I need to use |
mrousavy
left a comment
There was a problem hiding this comment.
Honestly great code, I couldn't find any real problems. Nice work Brad 👍
(keep in mind I only looked at C++ code, no JS)
| if (result != 0) { | ||
| throw std::runtime_error("XSalsa20Cipher: Failed to update"); | ||
| } | ||
| return std::make_shared<NativeArrayBuffer>(output, native_data->size(), [=]() { delete[] output; }); |
There was a problem hiding this comment.
| return std::make_shared<NativeArrayBuffer>(output, native_data->size(), [=]() { delete[] output; }); | |
| return ArrayBuffer::wrap(output, native_data->size(), [=]() { delete[] output; }); |
use the initializer functions instead of the constructor, kinda more explicit.
| * xsalsa20 does not have a final step, returns empty buffer | ||
| */ | ||
| std::shared_ptr<ArrayBuffer> XSalsa20Cipher::final() { | ||
| return std::make_shared<NativeArrayBuffer>(nullptr, 0, nullptr); |
There was a problem hiding this comment.
Does that deallocate fine? Not sure if this calls delete[] at some point but maybe it's fine.
Adds
xsalsa20cipher to the library@noble/ciphers/salsa