Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
jasnell authored Jul 21, 2024
1 parent 30a2819 commit 4ab6dab
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/workerd/api/crypto/rsa.c++
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ kj::Maybe<AsymmetricKeyData> Rsa::fromJwk(KeyType keyType,

static constexpr auto kInvalidBase64Error = "Invalid RSA key in JSON Web Key; invalid base64."_kj;

// TODO(now): Use a decodeBase64Url variant
auto nDecoded = toBignumUnowned(simdutfBase64UrlDecodeChecked(n, kInvalidBase64Error));
auto eDecoded = toBignumUnowned(simdutfBase64UrlDecodeChecked(e, kInvalidBase64Error));
JSG_REQUIRE(RSA_set0_key(rsa.get(), nDecoded, eDecoded, nullptr) == 1, Error,
Expand Down Expand Up @@ -392,14 +391,14 @@ kj::Array<const kj::byte> Rsa::toDer(KeyEncoding encoding,
switch (encoding) {
case KeyEncoding::PKCS1: {
JSG_REQUIRE(i2d_RSAPublicKey_bio(bio.get(), rsa) == 1, Error,
"Failed to write RSA public key to PEM", tryDescribeOpensslErrors());
"Failed to write RSA public key to DER", tryDescribeOpensslErrors());
break;
}
case workerd::api::KeyEncoding::SPKI: {
auto evpPkey = OSSL_NEW(EVP_PKEY);
EVP_PKEY_set1_RSA(evpPkey.get(), rsa);
JSG_REQUIRE(i2d_PUBKEY_bio(bio.get(), evpPkey.get()) == 1, Error,
"Failed to write RSA public key to PEM", tryDescribeOpensslErrors());
"Failed to write RSA public key to SPKI", tryDescribeOpensslErrors());
break;
}
default: {
Expand Down

0 comments on commit 4ab6dab

Please sign in to comment.