Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: add GetCipherValue function #34287

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 11 additions & 15 deletions src/node_crypto_common.cc
Expand Up @@ -386,31 +386,27 @@ Local<Value> ToV8Value(Environment* env, const BIOPointer& bio) {
return ret.FromMaybe(Local<Value>());
}

MaybeLocal<Value> GetCipherName(
Environment* env,
const SSL_CIPHER* cipher) {
MaybeLocal<Value> GetCipherValue(Environment* env,
const SSL_CIPHER* cipher,
std::function<const char*(const SSL_CIPHER* cipher)> getstr) {
danbev marked this conversation as resolved.
Show resolved Hide resolved
if (cipher == nullptr)
return Undefined(env->isolate());

return OneByteString(env->isolate(), SSL_CIPHER_get_name(cipher));
return OneByteString(env->isolate(), getstr(cipher));
}

MaybeLocal<Value> GetCipherStandardName(
Environment* env,
const SSL_CIPHER* cipher) {
if (cipher == nullptr)
return Undefined(env->isolate());

return OneByteString(env->isolate(), SSL_CIPHER_standard_name(cipher));
MaybeLocal<Value> GetCipherName(Environment* env, const SSL_CIPHER* cipher) {
return GetCipherValue(env, cipher, SSL_CIPHER_get_name);
}

MaybeLocal<Value> GetCipherVersion(
MaybeLocal<Value> GetCipherStandardName(
Environment* env,
const SSL_CIPHER* cipher) {
if (cipher == nullptr)
return Undefined(env->isolate());
return GetCipherValue(env, cipher, SSL_CIPHER_standard_name);
}

return OneByteString(env->isolate(), SSL_CIPHER_get_version(cipher));
MaybeLocal<Value> GetCipherVersion(Environment* env, const SSL_CIPHER* cipher) {
return GetCipherValue(env, cipher, SSL_CIPHER_get_version);
}

StackOfX509 CloneSSLCerts(X509Pointer&& cert,
Expand Down