fix: Define missing crypto.constants defined on Node (#9511)

* define crypto.constants

* requested changes

* fix: missing jsNumber wrap

---------

Co-authored-by: Georgijs <48869301+gvilums@users.noreply.github.com>
This commit is contained in:
saklani
2024-03-30 10:23:52 +05:30
committed by GitHub
parent d712254128
commit d433a1ada0

View File

@@ -907,18 +907,26 @@ static JSValue processBindingConstantsGetCrypto(VM& vm, JSObject* bindingObject)
#endif
#ifdef RSA_X931_PADDING
object->putDirect(vm, PropertyName(Identifier::fromString(vm, "RSA_X931_PADDING"_s)), jsNumber(RSA_X931_PADDING));
#else
object->putDirect(vm, PropertyName(Identifier::fromString(vm, "RSA_X931_PADDING"_s)), jsNumber(5));
#endif
#ifdef RSA_PKCS1_PSS_PADDING
object->putDirect(vm, PropertyName(Identifier::fromString(vm, "RSA_PKCS1_PSS_PADDING"_s)), jsNumber(RSA_PKCS1_PSS_PADDING));
#endif
#ifdef RSA_PSS_SALTLEN_DIGEST
object->putDirect(vm, PropertyName(Identifier::fromString(vm, "RSA_PSS_SALTLEN_DIGEST"_s)), jsNumber(RSA_PSS_SALTLEN_DIGEST));
#else
object->putDirect(vm, PropertyName(Identifier::fromString(vm, "RSA_PSS_SALTLEN_DIGEST"_s)), jsNumber(-1));
#endif
#ifdef RSA_PSS_SALTLEN_MAX_SIGN
object->putDirect(vm, PropertyName(Identifier::fromString(vm, "RSA_PSS_SALTLEN_MAX_SIGN"_s)), jsNumber(RSA_PSS_SALTLEN_MAX_SIGN));
#else
object->putDirect(vm, PropertyName(Identifier::fromString(vm, "RSA_PSS_SALTLEN_MAX_SIGN"_s)), jsNumber(-2));
#endif
#ifdef RSA_PSS_SALTLEN_AUTO
object->putDirect(vm, PropertyName(Identifier::fromString(vm, "RSA_PSS_SALTLEN_AUTO"_s)), jsNumber(RSA_PSS_SALTLEN_AUTO));
#else
object->putDirect(vm, PropertyName(Identifier::fromString(vm, "RSA_PSS_SALTLEN_AUTO"_s)), jsNumber(-2));
#endif
auto cipherList = String("TLS_AES_256_GCM_SHA384:"
"TLS_CHACHA20_POLY1305_SHA256:"