Skip to content

Commit

Permalink
fixup! src: move crypto bio stuff to ncrypto
Browse files Browse the repository at this point in the history
  • Loading branch information
jasnell committed Aug 11, 2024
1 parent dd31314 commit ca3dbce
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/crypto/crypto_bio.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ BIOPointer NodeBIO::New(Environment* env) {
BIOPointer NodeBIO::NewFixed(const char* data, size_t len, Environment* env) {
BIOPointer bio = New(env);

if (!bio ||
len > INT_MAX ||
BIOPointer::Write(&bio, std::string_view(data, len)) != static_cast<int>(len) ||
if (!bio || len > INT_MAX ||
BIOPointer::Write(&bio, std::string_view(data, len)) !=
static_cast<int>(len) ||
BIO_set_mem_eof_return(bio.get(), 0) != 1) {
return BIOPointer();
}
Expand Down
3 changes: 2 additions & 1 deletion src/crypto/crypto_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,8 @@ MaybeLocal<Value> GetExponentString(
const BIOPointer& bio,
const BIGNUM* e) {
uint64_t exponent_word = static_cast<uint64_t>(BignumPointer::GetWord(e));
BIOPointer::Printf(const_cast<BIOPointer*>(&bio), "0x%" PRIx64, exponent_word);
BIOPointer::Printf(
const_cast<BIOPointer*>(&bio), "0x%" PRIx64, exponent_word);
return ToV8Value(env, bio);
}

Expand Down
3 changes: 2 additions & 1 deletion src/crypto/crypto_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ BIOPointer LoadBIO(Environment* env, Local<Value> v) {
if (!bio) return {};
ByteSource bsrc = ByteSource::FromStringOrBuffer(env, v);
if (bsrc.size() > INT_MAX) return {};
int written = BIOPointer::Write(&bio, std::string_view(bsrc.data<char>(), bsrc.size()));
int written = BIOPointer::Write(
&bio, std::string_view(bsrc.data<char>(), bsrc.size()));
if (written < 0) return {};
if (static_cast<size_t>(written) != bsrc.size()) return {};
return bio;
Expand Down
7 changes: 3 additions & 4 deletions src/crypto/crypto_keys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,9 @@ ParseKeyResult ParsePrivateKey(EVPKeyPointer* pkey,
return ParseKeyResult::kParseKeyFailed;
}

MaybeLocal<Value> BIOToStringOrBuffer(
Environment* env,
const BIOPointer& bio,
PKFormatType format) {
MaybeLocal<Value> BIOToStringOrBuffer(Environment* env,
const BIOPointer& bio,
PKFormatType format) {
BUF_MEM* bptr = bio;
if (format == kKeyFormatPEM) {
// PEM is an ASCII format, so we will return it as a string.
Expand Down
8 changes: 4 additions & 4 deletions src/crypto/crypto_tls.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@

#include "crypto/crypto_tls.h"
#include <cstdio>
#include "crypto/crypto_context.h"
#include "crypto/crypto_common.h"
#include "crypto/crypto_util.h"
#include "async_wrap-inl.h"
#include "crypto/crypto_bio.h"
#include "crypto/crypto_clienthello-inl.h"
#include "async_wrap-inl.h"
#include "crypto/crypto_common.h"
#include "crypto/crypto_context.h"
#include "crypto/crypto_util.h"
#include "debug_utils-inl.h"
#include "memory_tracker-inl.h"
#include "node_buffer.h"
Expand Down

0 comments on commit ca3dbce

Please sign in to comment.