Skip to content

Commit

Permalink
src: change SetEncodedValue to return Maybe<void>
Browse files Browse the repository at this point in the history
With recent versions of V8, it is not necessary to use Maybe<bool>
anymore. This changes SetEncodedValue to return Maybe<void> instead.

PR-URL: #54443
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
  • Loading branch information
tniessen authored and RafaelGSS committed Aug 30, 2024
1 parent 0030165 commit f7506ff
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
7 changes: 1 addition & 6 deletions src/crypto/crypto_ec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -828,12 +828,7 @@ Maybe<void> ExportJWKEcKey(

if (key->GetKeyType() == kKeyTypePrivate) {
const BIGNUM* pvt = EC_KEY_get0_private_key(ec);
return SetEncodedValue(
env,
target,
env->jwk_d_string(),
pvt,
degree_bytes).IsJust() ? JustVoid() : Nothing<void>();
return SetEncodedValue(env, target, env->jwk_d_string(), pvt, degree_bytes);
}

return JustVoid();
Expand Down
16 changes: 8 additions & 8 deletions src/crypto/crypto_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -604,22 +604,22 @@ MaybeLocal<Value> EncodeBignum(
error);
}

Maybe<bool> SetEncodedValue(
Environment* env,
Local<Object> target,
Local<String> name,
const BIGNUM* bn,
int size) {
Maybe<void> SetEncodedValue(Environment* env,
Local<Object> target,
Local<String> name,
const BIGNUM* bn,
int size) {
Local<Value> value;
Local<Value> error;
CHECK_NOT_NULL(bn);
if (size == 0) size = BignumPointer::GetByteCount(bn);
if (!EncodeBignum(env, bn, size, &error).ToLocal(&value)) {
if (!error.IsEmpty())
env->isolate()->ThrowException(error);
return Nothing<bool>();
return Nothing<void>();
}
return target->Set(env->context(), name, value);
return target->Set(env->context(), name, value).IsJust() ? JustVoid()
: Nothing<void>();
}

bool SetRsaOaepLabel(const EVPKeyCtxPointer& ctx, const ByteSource& label) {
Expand Down
11 changes: 5 additions & 6 deletions src/crypto/crypto_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -713,12 +713,11 @@ v8::MaybeLocal<v8::Value> EncodeBignum(
int size,
v8::Local<v8::Value>* error);

v8::Maybe<bool> SetEncodedValue(
Environment* env,
v8::Local<v8::Object> target,
v8::Local<v8::String> name,
const BIGNUM* bn,
int size = 0);
v8::Maybe<void> SetEncodedValue(Environment* env,
v8::Local<v8::Object> target,
v8::Local<v8::String> name,
const BIGNUM* bn,
int size = 0);

bool SetRsaOaepLabel(const EVPKeyCtxPointer& rsa, const ByteSource& label);

Expand Down

0 comments on commit f7506ff

Please sign in to comment.