summaryrefslogtreecommitdiff
path: root/src/node_crypto.h
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-02-18 22:58:27 +0100
committerAnna Henningsen <anna@addaleax.net>2019-02-25 02:01:11 +0100
commit84e02b178ad14fae0df2a514e8a39bfa50ffdc2d (patch)
treeddc0435b6bd0b7811e0bf47687777c56b2857fd0 /src/node_crypto.h
parent6c257cdf271384555d0ced77104a1d6b0480e246 (diff)
downloadandroid-node-v8-84e02b178ad14fae0df2a514e8a39bfa50ffdc2d.tar.gz
android-node-v8-84e02b178ad14fae0df2a514e8a39bfa50ffdc2d.tar.bz2
android-node-v8-84e02b178ad14fae0df2a514e8a39bfa50ffdc2d.zip
src: allocate Buffer memory using ArrayBuffer allocator
Always use the right allocator for memory that is turned into an `ArrayBuffer` at a later point. This enables embedders to use their own `ArrayBuffer::Allocator`s, and is inspired by Electron’s electron/node@f61bae3440e. It should render their downstream patch unnecessary. Refs: https://github.com/electron/node/commit/f61bae3440e1bfcc83bba6ff0785adfb89b4045e PR-URL: https://github.com/nodejs/node/pull/26207 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'src/node_crypto.h')
-rw-r--r--src/node_crypto.h15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/node_crypto.h b/src/node_crypto.h
index e9862ff1bc..78293e70f1 100644
--- a/src/node_crypto.h
+++ b/src/node_crypto.h
@@ -544,9 +544,8 @@ class CipherBase : public BaseObject {
bool InitAuthenticated(const char* cipher_type, int iv_len,
unsigned int auth_tag_len);
bool CheckCCMMessageLength(int message_len);
- UpdateResult Update(const char* data, int len, unsigned char** out,
- int* out_len);
- bool Final(unsigned char** out, int* out_len);
+ UpdateResult Update(const char* data, int len, AllocatedBuffer* out);
+ bool Final(AllocatedBuffer* out);
bool SetAutoPadding(bool auto_padding);
bool IsAuthenticatedMode() const;
@@ -677,11 +676,11 @@ class Sign : public SignBase {
struct SignResult {
Error error;
- MallocedBuffer<unsigned char> signature;
+ AllocatedBuffer signature;
explicit SignResult(
Error err,
- MallocedBuffer<unsigned char>&& sig = MallocedBuffer<unsigned char>())
+ AllocatedBuffer&& sig = AllocatedBuffer())
: error(err), signature(std::move(sig)) {}
};
@@ -738,12 +737,12 @@ class PublicKeyCipher {
template <Operation operation,
EVP_PKEY_cipher_init_t EVP_PKEY_cipher_init,
EVP_PKEY_cipher_t EVP_PKEY_cipher>
- static bool Cipher(const ManagedEVPPKey& pkey,
+ static bool Cipher(Environment* env,
+ const ManagedEVPPKey& pkey,
int padding,
const unsigned char* data,
int len,
- unsigned char** out,
- size_t* out_len);
+ AllocatedBuffer* out);
template <Operation operation,
EVP_PKEY_cipher_init_t EVP_PKEY_cipher_init,