Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2020-02-29 04:13:08 +0300
committerJames M Snell <jasnell@gmail.com>2020-03-03 03:27:19 +0300
commitdd8183632d4bc8929371ee4676ef9bb5c95f7aaa (patch)
tree328b848ed830f10ff9280bebe0caa0228f38bda9 /src/string_bytes.cc
parent96e70c4ce786f43de16a0267a92ee73abf218356 (diff)
src: add node_crypto_common and refactor
Two things in one on this commit: (a) For the QUIC implementation, we need to separate out various bits from node_crypto.cc to allow them to be reused. That's where this commit starts. (b) Quite a bit of the node_crypto.cc code was just messy in terms of it's organization and lack of error handling and use of Local vs. MaybeLocal. This cleans that up a bit and hopefully makes certain parts a bit more manageable also. Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: https://github.com/nodejs/node/pull/32016 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Diffstat (limited to 'src/string_bytes.cc')
-rw-r--r--src/string_bytes.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/string_bytes.cc b/src/string_bytes.cc
index f8d7243e5d6..7ee87a8ebe8 100644
--- a/src/string_bytes.cc
+++ b/src/string_bytes.cc
@@ -587,7 +587,11 @@ static void force_ascii(const char* src, char* dst, size_t len) {
}
-static size_t hex_encode(const char* src, size_t slen, char* dst, size_t dlen) {
+size_t StringBytes::hex_encode(
+ const char* src,
+ size_t slen,
+ char* dst,
+ size_t dlen) {
// We know how much we'll write, just make sure that there's space.
CHECK(dlen >= slen * 2 &&
"not enough space provided for hex encode");
@@ -603,6 +607,12 @@ static size_t hex_encode(const char* src, size_t slen, char* dst, size_t dlen) {
return dlen;
}
+std::string StringBytes::hex_encode(const char* src, size_t slen) {
+ size_t dlen = slen * 2;
+ std::string dst(dlen, '\0');
+ hex_encode(src, slen, &dst[0], dlen);
+ return dst;
+}
#define CHECK_BUFLEN_IN_RANGE(len) \
do { \