Skip to content

Commit a466521

Browse files
authored
Update api/crypto* to use KJ_IF_SOME (#1202)
1 parent 13b505d commit a466521

File tree

5 files changed

+86
-86
lines changed

5 files changed

+86
-86
lines changed

src/workerd/api/crypto-impl-aes.c++

+14-14
Original file line numberDiff line numberDiff line change
@@ -749,10 +749,10 @@ kj::Own<CryptoKey::Impl> CryptoKey::Impl::importAes(
749749
case 128:
750750
case 192:
751751
case 256:
752-
KJ_IF_MAYBE(alg, keyDataJwk.alg) {
752+
KJ_IF_SOME(alg, keyDataJwk.alg) {
753753
auto expectedAlg = kj::str("A", keyDataArray.size() * 8, aesMode);
754-
JSG_REQUIRE(*alg == expectedAlg, DOMDataError,
755-
"Symmetric \"jwk\" key contains invalid \"alg\" value \"", *alg, "\", expected \"",
754+
JSG_REQUIRE(alg == expectedAlg, DOMDataError,
755+
"Symmetric \"jwk\" key contains invalid \"alg\" value \"", alg, "\", expected \"",
756756
expectedAlg, "\".");
757757
}
758758
break;
@@ -763,25 +763,25 @@ kj::Own<CryptoKey::Impl> CryptoKey::Impl::importAes(
763763
}
764764

765765
if (keyUsages.size() != 0) {
766-
KJ_IF_MAYBE(u, keyDataJwk.use) {
767-
JSG_REQUIRE(*u == "enc", DOMDataError,
768-
"Symmetric \"jwk\" key must have a \"use\" of \"enc\", not \"", *u, "\".");
766+
KJ_IF_SOME(u, keyDataJwk.use) {
767+
JSG_REQUIRE(u == "enc", DOMDataError,
768+
"Symmetric \"jwk\" key must have a \"use\" of \"enc\", not \"", u, "\".");
769769
}
770770
}
771771

772-
KJ_IF_MAYBE(ops, keyDataJwk.key_ops) {
773-
std::sort(ops->begin(), ops->end());
772+
KJ_IF_SOME(ops, keyDataJwk.key_ops) {
773+
std::sort(ops.begin(), ops.end());
774774
// Don't want to use the trick above to use a red-black tree because that constructs the set
775775
// once ever for the process, but this path is dependent on user input. Could write things
776776
// without the sort but it makes the enforcement from Section 4.2 below a 1-liner.
777777

778-
auto duplicate = std::adjacent_find(ops->begin(), ops->end());
779-
JSG_REQUIRE(duplicate == ops->end(), DOMDataError,
778+
auto duplicate = std::adjacent_find(ops.begin(), ops.end());
779+
JSG_REQUIRE(duplicate == ops.end(), DOMDataError,
780780
"Symmetric \"jwk\" key contains duplicate value \"", *duplicate, "\", in \"key_op\".");
781781
// https://tools.ietf.org/html/rfc7517#section-4.2 - no duplicate values in key_ops.
782782

783783
for (const auto& usage: keyUsages) {
784-
JSG_REQUIRE(std::binary_search(ops->begin(), ops->end(), usage), DOMDataError,
784+
JSG_REQUIRE(std::binary_search(ops.begin(), ops.end(), usage), DOMDataError,
785785
"\"jwk\" key missing usage \"", usage, "\", in \"key_ops\".");
786786
}
787787
}
@@ -793,9 +793,9 @@ kj::Own<CryptoKey::Impl> CryptoKey::Impl::importAes(
793793
// be interpreted? What constitutes "inconsistentcy"? Is that implicit in enforcing that "enc"
794794
// must be the value for `use'? Or is there something else?
795795

796-
KJ_IF_MAYBE(e, keyDataJwk.ext) {
797-
JSG_REQUIRE(*e || !extractable, DOMDataError,
798-
"\"jwk\" key has value \"", *e ? "true" : "false", "\", for \"ext\" that is incompatible "
796+
KJ_IF_SOME(e, keyDataJwk.ext) {
797+
JSG_REQUIRE(e || !extractable, DOMDataError,
798+
"\"jwk\" key has value \"", e ? "true" : "false", "\", for \"ext\" that is incompatible "
799799
"with import extractability value \"", extractable ? "true" : "false", "\".");
800800
}
801801
} else {

src/workerd/api/crypto-impl-asymmetric.c++

+56-56
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ public:
103103
virtual kj::Array<kj::byte> exportKeyExt(
104104
kj::StringPtr format,
105105
kj::StringPtr type,
106-
jsg::Optional<kj::String> cipher = nullptr,
107-
jsg::Optional<kj::Array<kj::byte>> passphrase = nullptr) const override final {
106+
jsg::Optional<kj::String> cipher = kj::none,
107+
jsg::Optional<kj::Array<kj::byte>> passphrase = kj::none) const override final {
108108
KJ_REQUIRE(isExtractable(), "Key is not extractable.");
109109
MarkPopErrorOnReturn mark_pop_error_on_return;
110110
KJ_REQUIRE(format != "jwk", "jwk export not supported for exportKeyExt");
@@ -119,13 +119,13 @@ public:
119119

120120
const auto getEncDetail = [&] {
121121
EncDetail detail;
122-
KJ_IF_MAYBE(pw, passphrase) {
123-
detail.pass = reinterpret_cast<char*>(pw->begin());
124-
detail.pass_len = pw->size();
122+
KJ_IF_SOME(pw, passphrase) {
123+
detail.pass = reinterpret_cast<char*>(pw.begin());
124+
detail.pass_len = pw.size();
125125
}
126-
KJ_IF_MAYBE(ciph, cipher) {
127-
detail.cipher = EVP_get_cipherbyname(ciph->cStr());
128-
JSG_REQUIRE(detail.cipher != nullptr, TypeError, "Unknown cipher ", *ciph);
126+
KJ_IF_SOME(ciph, cipher) {
127+
detail.cipher = EVP_get_cipherbyname(ciph.cStr());
128+
JSG_REQUIRE(detail.cipher != nullptr, TypeError, "Unknown cipher ", ciph);
129129
KJ_REQUIRE(detail.pass != nullptr);
130130
}
131131
return detail;
@@ -332,11 +332,11 @@ public:
332332

333333
bool equals(const CryptoKey::Impl& other) const override final {
334334
if (this == &other) return true;
335-
KJ_IF_MAYBE(otherImpl, kj::dynamicDowncastIfAvailable<const AsymmetricKey>(other)) {
335+
KJ_IF_SOME(otherImpl, kj::dynamicDowncastIfAvailable<const AsymmetricKey>(other)) {
336336
// EVP_PKEY_cmp will return 1 if the inputs match, 0 if they don't match,
337337
// -1 if the key types are different, and -2 if the operation is not supported.
338338
// We only really care about the first two cases.
339-
return EVP_PKEY_cmp(keyData.get(), otherImpl->keyData.get()) == 1;
339+
return EVP_PKEY_cmp(keyData.get(), otherImpl.keyData.get()) == 1;
340340
}
341341
return false;
342342
}
@@ -376,7 +376,7 @@ ImportAsymmetricResult importAsymmetric(jsg::Lock& js, kj::StringPtr format,
376376
DOMDataError, "JSON Web Key import requires a JSON Web Key object.");
377377

378378
kj::StringPtr keyType;
379-
if (keyDataJwk.d != nullptr) {
379+
if (keyDataJwk.d != kj::none) {
380380
// Private key (`d` is the private exponent, per RFC 7518).
381381
keyType = "private";
382382
usages =
@@ -385,7 +385,7 @@ ImportAsymmetricResult importAsymmetric(jsg::Lock& js, kj::StringPtr format,
385385

386386
// https://tools.ietf.org/html/rfc7518#section-6.3.2.7
387387
// We don't support keys with > 2 primes, so error out.
388-
JSG_REQUIRE(keyDataJwk.oth == nullptr, DOMNotSupportedError,
388+
JSG_REQUIRE(keyDataJwk.oth == kj::none, DOMNotSupportedError,
389389
"Multi-prime private keys not supported.");
390390
} else {
391391
// Public key.
@@ -411,32 +411,32 @@ ImportAsymmetricResult importAsymmetric(jsg::Lock& js, kj::StringPtr format,
411411
}();
412412

413413
if (keyUsages.size() > 0) {
414-
KJ_IF_MAYBE(use, keyDataJwk.use) {
415-
JSG_REQUIRE(*use == expectedUse, DOMDataError,
414+
KJ_IF_SOME(use, keyDataJwk.use) {
415+
JSG_REQUIRE(use == expectedUse, DOMDataError,
416416
"Asymmetric \"jwk\" key import with usages requires a JSON Web Key with "
417-
"Public Key Use parameter \"use\" (\"", *use, "\") equal to \"sig\".");
417+
"Public Key Use parameter \"use\" (\"", use, "\") equal to \"sig\".");
418418
}
419419
}
420420

421-
KJ_IF_MAYBE(ops, keyDataJwk.key_ops) {
421+
KJ_IF_SOME(ops, keyDataJwk.key_ops) {
422422
// TODO(cleanup): When we implement other JWK import functions, factor this part out into a
423423
// JWK validation function.
424424

425425
// "The key operation values are case-sensitive strings. Duplicate key operation values MUST
426426
// NOT be present in the array." -- RFC 7517, section 4.3
427-
std::sort(ops->begin(), ops->end());
428-
JSG_REQUIRE(std::adjacent_find(ops->begin(), ops->end()) == ops->end(), DOMDataError,
427+
std::sort(ops.begin(), ops.end());
428+
JSG_REQUIRE(std::adjacent_find(ops.begin(), ops.end()) == ops.end(), DOMDataError,
429429
"A JSON Web Key's Key Operations parameter (\"key_ops\") "
430430
"must not contain duplicates.");
431431

432-
KJ_IF_MAYBE(use, keyDataJwk.use) {
432+
KJ_IF_SOME(use, keyDataJwk.use) {
433433
// "The "use" and "key_ops" JWK members SHOULD NOT be used together; however, if both are
434434
// used, the information they convey MUST be consistent." -- RFC 7517, section 4.3.
435435

436-
JSG_REQUIRE(*use == expectedUse, DOMDataError, "Asymmetric \"jwk\" import requires a JSON "
437-
"Web Key with Public Key Use \"use\" (\"", *use, "\") equal to \"", expectedUse, "\".");
436+
JSG_REQUIRE(use == expectedUse, DOMDataError, "Asymmetric \"jwk\" import requires a JSON "
437+
"Web Key with Public Key Use \"use\" (\"", use, "\") equal to \"", expectedUse, "\".");
438438

439-
for (const auto& op: *ops) {
439+
for (const auto& op: ops) {
440440
JSG_REQUIRE(normalizedName != "ECDH" && normalizedName != "X25519", DOMDataError,
441441
"A JSON Web Key should have either a Public Key Use parameter (\"use\") or a Key "
442442
"Operations parameter (\"key_ops\"); otherwise, the parameters must be consistent "
@@ -460,22 +460,22 @@ ImportAsymmetricResult importAsymmetric(jsg::Lock& js, kj::StringPtr format,
460460
// and the next usages. Test the first usage and the first usage distinct from the first, if
461461
// present (i.e. the second allowed usage, even if there are duplicates).
462462
if (keyUsages.size() > 0) {
463-
JSG_REQUIRE(std::find(ops->begin(), ops->end(), keyUsages.front()) != ops->end(),
463+
JSG_REQUIRE(std::find(ops.begin(), ops.end(), keyUsages.front()) != ops.end(),
464464
DOMDataError, "All specified key usages must be present in the JSON "
465465
"Web Key's Key Operations parameter (\"key_ops\").");
466466
auto secondUsage = std::find_end(keyUsages.begin(), keyUsages.end(), keyUsages.begin(),
467467
keyUsages.begin() + 1) + 1;
468468
if (secondUsage != keyUsages.end()) {
469-
JSG_REQUIRE(std::find(ops->begin(), ops->end(), *secondUsage) != ops->end(),
469+
JSG_REQUIRE(std::find(ops.begin(), ops.end(), *secondUsage) != ops.end(),
470470
DOMDataError, "All specified key usages must be present in the JSON "
471471
"Web Key's Key Operations parameter (\"key_ops\").");
472472
}
473473
}
474474
}
475475

476-
KJ_IF_MAYBE(ext, keyDataJwk.ext) {
476+
KJ_IF_SOME(ext, keyDataJwk.ext) {
477477
// If the user requested this key to be extractable, make sure the JWK does not disallow it.
478-
JSG_REQUIRE(!extractable || *ext, DOMDataError,
478+
JSG_REQUIRE(!extractable || ext, DOMDataError,
479479
"Cannot create an extractable CryptoKey from an unextractable JSON Web Key.");
480480
}
481481

@@ -765,8 +765,8 @@ private:
765765
"Error doing RSA OAEP encrypt/decrypt (", "MGF1 digest", ")",
766766
internalDescribeOpensslErrors());
767767

768-
KJ_IF_MAYBE(l, algorithm.label) {
769-
auto labelCopy = reinterpret_cast<uint8_t*>(OPENSSL_malloc(l->size()));
768+
KJ_IF_SOME(l, algorithm.label) {
769+
auto labelCopy = reinterpret_cast<uint8_t*>(OPENSSL_malloc(l.size()));
770770
KJ_DEFER(OPENSSL_free(labelCopy));
771771
// If setting the label fails we need to remember to destroy the buffer. In practice it can't
772772
// actually happen since we set RSA_PKCS1_OAEP_PADDING above & that appears to be the only way
@@ -775,11 +775,11 @@ private:
775775
JSG_REQUIRE(labelCopy != nullptr, DOMOperationError,
776776
"Failed to allocate space for RSA-OAEP label copy",
777777
tryDescribeOpensslErrors());
778-
std::copy(l->begin(), l->end(), labelCopy);
778+
std::copy(l.begin(), l.end(), labelCopy);
779779

780780
// EVP_PKEY_CTX_set0_rsa_oaep_label below takes ownership of the buffer passed in (must have
781781
// been OPENSSL_malloc-allocated).
782-
JSG_REQUIRE(1 == EVP_PKEY_CTX_set0_rsa_oaep_label(ctx.get(), labelCopy, l->size()),
782+
JSG_REQUIRE(1 == EVP_PKEY_CTX_set0_rsa_oaep_label(ctx.get(), labelCopy, l.size()),
783783
DOMOperationError, "Failed to set RSA-OAEP label",
784784
tryDescribeOpensslErrors());
785785

@@ -933,7 +933,7 @@ kj::Maybe<T> fromBignum(kj::ArrayPtr<kj::byte> value) {
933933
size_t bitShift = value.size() - i - 1;
934934
if (bitShift >= sizeof(T) && value[i]) {
935935
// Too large for desired type.
936-
return nullptr;
936+
return kj::none;
937937
}
938938

939939
asUnsigned |= value[i] << 8 * bitShift;
@@ -963,16 +963,16 @@ void validateRsaParams(jsg::Lock& js, int modulusLength, kj::ArrayPtr<kj::byte>
963963
// doesn't have convenient APIs to do this (since these are bignums) so we have to do it by hand.
964964
// Since the problematic BIGNUMs are within the range of an unsigned int (& technicall an
965965
// unsigned short) we can treat an out-of-range issue as valid input.
966-
KJ_IF_MAYBE(v, fromBignum<unsigned>(publicExponent)) {
966+
KJ_IF_SOME(v, fromBignum<unsigned>(publicExponent)) {
967967
if (!isImport) {
968-
JSG_REQUIRE(*v == 3 || *v == 65537, DOMOperationError,
969-
"The \"publicExponent\" must be either 3 or 65537, but got ", *v, ".");
968+
JSG_REQUIRE(v == 3 || v == 65537, DOMOperationError,
969+
"The \"publicExponent\" must be either 3 or 65537, but got ", v, ".");
970970
} else if (strictCrypto) {
971971
// While we have long required the exponent to be 3 or 65537 when generating keys, handle
972972
// imported keys more permissively and allow additional exponents that are considered safe
973973
// and commonly used.
974-
JSG_REQUIRE(*v == 3 || *v == 17 || *v == 37 || *v == 65537, DOMOperationError,
975-
"Imported RSA key has invalid publicExponent ", *v, ".");
974+
JSG_REQUIRE(v == 3 || v == 17 || v == 37 || v == 65537, DOMOperationError,
975+
"Imported RSA key has invalid publicExponent ", v, ".");
976976
}
977977
} else {
978978
JSG_FAIL_REQUIRE(DOMOperationError, "The \"publicExponent\" must be either 3 or 65537, but "
@@ -1057,7 +1057,7 @@ kj::Own<EVP_PKEY> rsaJwkReader(SubtleCrypto::JsonWebKey&& keyDataJwk) {
10571057
BN_bin2bn(publicExponent.begin(), publicExponent.size(), nullptr),
10581058
nullptr));
10591059

1060-
if (keyDataJwk.d != nullptr) {
1060+
if (keyDataJwk.d != kj::none) {
10611061
// This is a private key.
10621062

10631063
auto privateExponent = UNWRAP_JWK_BIGNUM(kj::mv(keyDataJwk.d),
@@ -1067,9 +1067,9 @@ kj::Own<EVP_PKEY> rsaJwkReader(SubtleCrypto::JsonWebKey&& keyDataJwk) {
10671067
OSSLCALL(RSA_set0_key(rsaKey.get(), nullptr, nullptr,
10681068
BN_bin2bn(privateExponent.begin(), privateExponent.size(), nullptr)));
10691069

1070-
auto presence = (keyDataJwk.p != nullptr) + (keyDataJwk.q != nullptr) +
1071-
(keyDataJwk.dp != nullptr) + (keyDataJwk.dq != nullptr) +
1072-
(keyDataJwk.qi != nullptr);
1070+
auto presence = (keyDataJwk.p != kj::none) + (keyDataJwk.q != kj::none) +
1071+
(keyDataJwk.dp != kj::none) + (keyDataJwk.dq != kj::none) +
1072+
(keyDataJwk.qi != kj::none);
10731073

10741074
if (presence == 5) {
10751075
auto firstPrimeFactor = UNWRAP_JWK_BIGNUM(kj::mv(keyDataJwk.p),
@@ -1131,7 +1131,7 @@ kj::Own<CryptoKey::Impl> CryptoKey::Impl::importRsa(
11311131
"RSASSA-PKCS1-v1_5 \"jwk\" key import requires a JSON Web Key with Key Type parameter "
11321132
"\"kty\" (\"", keyDataJwk.kty, "\") equal to \"RSA\".");
11331133

1134-
KJ_IF_MAYBE(alg, keyDataJwk.alg) {
1134+
KJ_IF_SOME(alg, keyDataJwk.alg) {
11351135
// If this JWK specifies an algorithm, make sure it jives with the hash we were passed via
11361136
// importKey().
11371137
static std::map<kj::StringPtr, const EVP_MD*> rsaShaAlgorithms{
@@ -1164,13 +1164,13 @@ kj::Own<CryptoKey::Impl> CryptoKey::Impl::importRsa(
11641164
"\".");
11651165
}
11661166
}();
1167-
auto jwkHash = validAlgorithms.find(*alg);
1167+
auto jwkHash = validAlgorithms.find(alg);
11681168
JSG_REQUIRE(jwkHash != rsaPssAlgorithms.end(), DOMNotSupportedError,
1169-
"Unrecognized or unimplemented algorithm \"", *alg, "\" listed in JSON Web Key Algorithm "
1169+
"Unrecognized or unimplemented algorithm \"", alg, "\" listed in JSON Web Key Algorithm "
11701170
"parameter.");
11711171

11721172
JSG_REQUIRE(jwkHash->second == hashEvpMd, DOMDataError,
1173-
"JSON Web Key Algorithm parameter \"alg\" (\"", *alg, "\") does not match requested hash "
1173+
"JSON Web Key Algorithm parameter \"alg\" (\"", alg, "\") does not match requested hash "
11741174
"algorithm \"", jwkHash->first, "\".");
11751175
}
11761176

@@ -1232,7 +1232,7 @@ kj::Own<CryptoKey::Impl> CryptoKey::Impl::importRsaRaw(
12321232
"RSA-RAW \"jwk\" key import requires a JSON Web Key with Key Type parameter "
12331233
"\"kty\" (\"", keyDataJwk.kty, "\") equal to \"RSA\".");
12341234

1235-
KJ_IF_MAYBE(alg, keyDataJwk.alg) {
1235+
KJ_IF_SOME(alg, keyDataJwk.alg) {
12361236
// If this JWK specifies an algorithm, make sure it jives with the hash we were passed via
12371237
// importKey().
12381238
static std::map<kj::StringPtr, const EVP_MD*> rsaAlgorithms{
@@ -1241,9 +1241,9 @@ kj::Own<CryptoKey::Impl> CryptoKey::Impl::importRsaRaw(
12411241
{"RS384", EVP_sha384()},
12421242
{"RS512", EVP_sha512()},
12431243
};
1244-
auto jwkHash = rsaAlgorithms.find(*alg);
1244+
auto jwkHash = rsaAlgorithms.find(alg);
12451245
JSG_REQUIRE(jwkHash != rsaAlgorithms.end(), DOMNotSupportedError,
1246-
"Unrecognized or unimplemented algorithm \"", *alg,
1246+
"Unrecognized or unimplemented algorithm \"", alg,
12471247
"\" listed in JSON Web Key Algorithm parameter.");
12481248
}
12491249
return rsaJwkReader(kj::mv(keyDataJwk));
@@ -1740,12 +1740,12 @@ kj::Own<EVP_PKEY> ellipticJwkReader(int curveId, SubtleCrypto::JsonWebKey&& keyD
17401740
"Missing field \"crv\" for ", curveName, " key.");
17411741
JSG_REQUIRE(crv == curveName, DOMNotSupportedError,
17421742
"Only ", curveName, " is supported but \"", crv, "\" was requested.");
1743-
KJ_IF_MAYBE(alg, keyDataJwk.alg) {
1743+
KJ_IF_SOME(alg, keyDataJwk.alg) {
17441744
// If this JWK specifies an algorithm, make sure it jives with the hash we were passed via
17451745
// importKey().
17461746
if (curveId == NID_ED25519) {
1747-
JSG_REQUIRE(*alg == "EdDSA", DOMDataError,
1748-
"JSON Web Key Algorithm parameter \"alg\" (\"", *alg, "\") does not match requested "
1747+
JSG_REQUIRE(alg == "EdDSA", DOMDataError,
1748+
"JSON Web Key Algorithm parameter \"alg\" (\"", alg, "\") does not match requested "
17491749
"Ed25519 curve.");
17501750
}
17511751
}
@@ -1754,7 +1754,7 @@ kj::Own<EVP_PKEY> ellipticJwkReader(int curveId, SubtleCrypto::JsonWebKey&& keyD
17541754
"Invalid ", crv, " key in JSON WebKey; missing or invalid public key component (\"x\").");
17551755
JSG_REQUIRE(x.size() == 32, DOMDataError, "Invalid length ", x.size(), " for public key");
17561756

1757-
if (keyDataJwk.d == nullptr) {
1757+
if (keyDataJwk.d == kj::none) {
17581758
// This is a public key.
17591759
return OSSLCALL_OWN(EVP_PKEY, EVP_PKEY_new_raw_public_key(evpId, nullptr,
17601760
x.begin(), x.size()), InternalDOMOperationError,
@@ -1781,7 +1781,7 @@ kj::Own<EVP_PKEY> ellipticJwkReader(int curveId, SubtleCrypto::JsonWebKey&& keyD
17811781
"Elliptic curve \"jwk\" key import requires a JSON Web Key with Key Type parameter "
17821782
"\"kty\" (\"", keyDataJwk.kty, "\") equal to \"EC\".");
17831783

1784-
KJ_IF_MAYBE(alg, keyDataJwk.alg) {
1784+
KJ_IF_SOME(alg, keyDataJwk.alg) {
17851785
// If this JWK specifies an algorithm, make sure it jives with the hash we were passed via
17861786
// importKey().
17871787
static std::map<kj::StringPtr, int> ecdsaAlgorithms {
@@ -1790,13 +1790,13 @@ kj::Own<EVP_PKEY> ellipticJwkReader(int curveId, SubtleCrypto::JsonWebKey&& keyD
17901790
{"ES512", NID_secp521r1},
17911791
};
17921792

1793-
auto iter = ecdsaAlgorithms.find(*alg);
1793+
auto iter = ecdsaAlgorithms.find(alg);
17941794
JSG_REQUIRE(iter != ecdsaAlgorithms.end(), DOMNotSupportedError,
1795-
"Unrecognized or unimplemented algorithm \"", *alg,
1795+
"Unrecognized or unimplemented algorithm \"", alg,
17961796
"\" listed in JSON Web Key Algorithm parameter.");
17971797

17981798
JSG_REQUIRE(iter->second == curveId, DOMDataError,
1799-
"JSON Web Key Algorithm parameter \"alg\" (\"", *alg, "\") does not match requested curve.");
1799+
"JSON Web Key Algorithm parameter \"alg\" (\"", alg, "\") does not match requested curve.");
18001800
}
18011801

18021802
auto ecKey = OSSLCALL_OWN(EC_KEY, EC_KEY_new_by_curve_name(curveId), DOMOperationError,
@@ -1816,7 +1816,7 @@ kj::Own<EVP_PKEY> ellipticJwkReader(int curveId, SubtleCrypto::JsonWebKey&& keyD
18161816
OSSLCALL(EC_POINT_set_affine_coordinates_GFp(group, point, bigX, bigY, nullptr));
18171817
OSSLCALL(EC_KEY_set_public_key(ecKey, point));
18181818

1819-
if (keyDataJwk.d != nullptr) {
1819+
if (keyDataJwk.d != kj::none) {
18201820
// This is a private key.
18211821

18221822
auto d = UNWRAP_JWK_BIGNUM(kj::mv(keyDataJwk.d), DOMDataError,

0 commit comments

Comments
 (0)