oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.13k stars 2.76k forks source link

WebCryptoAPI operations exit bun with 0 exit code and no logs #1448

Closed panva closed 2 years ago

panva commented 2 years ago

@Jarred-Sumner I can't get the jose universal WebCryptoAPI test suite to execute using Bun v0.2.2. The bun process is exiting with a 0 exit code and no crash logs despite it clearly crashing when entering what seems to be almost any SubtleCrypto operation.

I've set up a reproduction for you.

git clone --branch tmp-tap-bun https://github.com/panva/jose
cd jose
npm clean-install
npm run build:browser
npm run tap:bun

An output similar to npm run tap:node is expected. The script is expecting ~/.bun/bin/bun to be present.

Originally posted by @panva in https://github.com/oven-sh/bun/issues/1384#issuecomment-1300412418

panva commented 2 years ago

This is the case both on my machine (Darwin 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct 9 20:15:09 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T6000 arm64 arm) as well as ubuntu-latest in github actions.

Jarred-Sumner commented 2 years ago

Here are the test results (with some extra debug logs which only appear in bun-debug):

ok 1 aes.ts > A128GCM
ok 2 aeskw.ts > A128KW
ok 3 aeskw.ts > A192KW
ok 4 aeskw.ts > A256KW
ok 5 aeskw.ts > A128GCMKW
ok 6 aeskw.ts > A192GCMKW
ok 7 aeskw.ts > A256GCMKW
ok 8 jws cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-4.1 - RSA v1.5 Signature
ok 9 jws cookbook > [not supported] https://www.rfc-editor.org/rfc/rfc8037#appendix-A.4 - Ed25519 Signing
not ok 10 jws cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-4.2 - RSA-PSS Signature
  ---
  message: "Promise rejected during \"https://www.rfc-editor.org/rfc/rfc7520#section-4.2 - RSA-PSS Signature\": The algorithm is not supported"
  severity: failed
  actual  : null
  expected: undefined
  stack: |
    promiseReactionJob@[native code]
  ...
ok 11 jws cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-4.3 - ECDSA Signature
ok 12 jws cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-4.4 - HMAC-SHA2 Integrity Protection
ok 13 jws cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-4.6 - Protecting Specific Header Fields
ok 14 jws cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-4.7 - Protecting Content Only
ok 15 jws cookbook > https://www.rfc-editor.org/rfc/rfc7797#section-4.1 - { "b64": false } JSON only
ok 16 jwe cookbook > [not supported] https://www.rfc-editor.org/rfc/rfc7520#section-5.1 - Key Encryption using RSA v1.5 and AES-HMAC-SHA2
not ok 17 jwe cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-5.2 - Key Encryption using RSA-OAEP with AES-GCM
  ---
  message: "Promise rejected during \"https://www.rfc-editor.org/rfc/rfc7520#section-5.2 - Key Encryption using RSA-OAEP with AES-GCM\": The algorithm is not supported"
  severity: failed
  actual  : null
  expected: undefined
  stack: |
    promiseReactionJob@[native code]
  ...
ok 18 jwe cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-5.3 - Key Wrap using PBES2-AES-KeyWrap with AES-CBC-HMAC-SHA2
ok 19 jwe cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-5.4 - Key Agreement with Key Wrapping using ECDH-ES and AES-KeyWrap with AES-GCM
ok 20 jwe cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-5.5 - Key Agreement using ECDH-ES with AES-CBC-HMAC-SHA2
ok 21 jwe cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-5.6 - Direction Encryption using AES-GCM
ok 22 jwe cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-5.6 - Key Wrap using AES-GCM KeyWrap with AES-CBC-HMAC-SHA2
ok 23 jwe cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-5.8 - Key Wrap using AES-KeyWrap with AES-GCM
ok 24 jwe cookbook > [not supported] https://www.rfc-editor.org/rfc/rfc7520#section-5.9 - Compressed Content
ok 25 jwe cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-5.10 - Including Additional Authenticated Data
ok 26 jwe cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-5.11 - Protecting Specific Header Fields
ok 27 jwe cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-5.12 - Protecting Content Only
ok 28 ecdh.ts > ECDH-ES P-256
ok 29 ecdh.ts > ECDH-ES P-384
ok 30 ecdh.ts > ECDH-ES P-521
ok 31 ecdh.ts > [not supported] ECDH-ES secp256k1
ok 32 ecdh.ts > [not supported] ECDH-ES X25519
ok 33 ecdh.ts > [not supported] ECDH-ES X448
ok 34 hmac.ts > HS256
ok 35 hmac.ts > HS384
ok 36 hmac.ts > HS512
ok 37 jwk.ts > ECDH-ES P-256 Private JWK Import
ok 38 jwk.ts > ECDH-ES P-384 Private JWK Import
ok 39 jwk.ts > ECDH-ES P-521 Private JWK Import
ok 40 jwk.ts > [not supported] ECDH-ES X25519 Private JWK Import
ok 41 jwk.ts > [not supported] ECDH-ES X448 Private JWK Import
ok 42 jwk.ts > [not supported] EdDSA Ed25519 Private JWK Import
ok 43 jwk.ts > [not supported] EdDSA Ed448 Private JWK Import
ok 44 jwk.ts > ES256 Private JWK Import
ok 45 jwk.ts > [not supported] ES256K Private JWK Import
ok 46 jwk.ts > ES384 Private JWK Import
ok 47 jwk.ts > ES512 Private JWK Import
ok 48 jwk.ts > PS256 Private JWK Import
ok 49 jwk.ts > PS384 Private JWK Import
ok 50 jwk.ts > PS512 Private JWK Import
ok 51 jwk.ts > RS256 Private JWK Import
ok 52 jwk.ts > RS384 Private JWK Import
ok 53 jwk.ts > RS512 Private JWK Import
ok 54 jwk.ts > RSA-OAEP-256 Private JWK Import
ok 55 jwk.ts > RSA-OAEP-384 Private JWK Import
ok 56 jwk.ts > RSA-OAEP-512 Private JWK Import
ok 57 jwk.ts > RSA-OAEP Private JWK Import
ok 58 jwk.ts > [not supported] RSA1_5 Private JWK Import
ok 59 jwk.ts > ECDH-ES P-256 Public JWK Import
ok 60 jwk.ts > ECDH-ES P-384 Public JWK Import
ok 61 jwk.ts > ECDH-ES P-521 Public JWK Import
ok 62 jwk.ts > [not supported] ECDH-ES X25519 Public JWK Import
ok 63 jwk.ts > [not supported] ECDH-ES X448 Public JWK Import
ok 64 jwk.ts > [not supported] EdDSA Ed25519 Public JWK Import
ok 65 jwk.ts > [not supported] EdDSA Ed448 Public JWK Import
ok 66 jwk.ts > ES256 Public JWK Import
ok 67 jwk.ts > [not supported] ES256K Public JWK Import
ok 68 jwk.ts > ES384 Public JWK Import
ok 69 jwk.ts > ES512 Public JWK Import
ok 70 jwk.ts > PS256 Public JWK Import
ok 71 jwk.ts > PS384 Public JWK Import
ok 72 jwk.ts > PS512 Public JWK Import
ok 73 jwk.ts > RS256 Public JWK Import
ok 74 jwk.ts > RS384 Public JWK Import
ok 75 jwk.ts > RS512 Public JWK Import
ok 76 jwk.ts > RSA-OAEP-256 Public JWK Import
ok 77 jwk.ts > RSA-OAEP-384 Public JWK Import
ok 78 jwk.ts > RSA-OAEP-512 Public JWK Import
ok 79 jwk.ts > RSA-OAEP Public JWK Import
ok 80 jwk.ts > [not supported] RSA1_5 Public JWK Import
[PollRef] ref
[fetch] onStart: 349.583us
[fetch] Processed 1 tasks
[fetch] Connected https://www.googleapis.com/oauth2/v3/certs
[fetch] - Keep-Alive release www.googleapis.com:443
[fetch] onAsyncHTTPComplete: 59.637ms
[PollRef] unref
[PollRef] ref
[PollRef] ref
[fetch] + Keep-Alive reuse www.googleapis.com:443
[fetch] Connected https://www.googleapis.com/oauth2/v3/certs
[fetch] onStart: 61.056ms
[fetch] Processed 1 tasks
[fetch] - Keep-Alive release www.googleapis.com:443
[fetch] onAsyncHTTPComplete: 6.192ms
[PollRef] unref
[PollRef] unref
ok 81 jwks.ts > fetches the JWKSet
ok 82 jws.ts > [not supported] EdDSA, {"crv":"Ed25519"}
ok 83 jws.ts > [not supported] EdDSA, {"crv":"Ed448"}
ok 84 jws.ts > ES256
ok 85 jws.ts > [not supported] ES256K
ok 86 jws.ts > ES384
ok 87 jws.ts > ES512
not ok 88 jws.ts > PS256
  ---
  message: "Promise rejected during \"PS256\": The algorithm is not supported"
  severity: failed
  actual  : null
  expected: undefined
  stack: |
    promiseReactionJob@[native code]
  ...
not ok 89 jws.ts > PS384
  ---
  message: "Promise rejected during \"PS384\": The algorithm is not supported"
  severity: failed
  actual  : null
  expected: undefined
  stack: |
    promiseReactionJob@[native code]
  ...
not ok 90 jws.ts > PS512
  ---
  message: "Promise rejected during \"PS512\": The algorithm is not supported"
  severity: failed
  actual  : null
  expected: undefined
  stack: |
    promiseReactionJob@[native code]
  ...
ok 91 jws.ts > RS256
ok 92 jws.ts > RS384
ok 93 jws.ts > RS512
ok 94 pem.ts > ES256 PKCS8 Private Key Import
ok 95 pem.ts > ES256 SPKI Public Key Import
ok 96 pem.ts > ES256 X.509 Certificate Import
ok 97 pem.ts > [not supported] ES256K PKCS8 Private Key Import
ok 98 pem.ts > [not supported] ES256K SPKI Public Key Import
ok 99 pem.ts > [not supported] ES256K X.509 Certificate Import
ok 100 pem.ts > ES384 PKCS8 Private Key Import
ok 101 pem.ts > ES384 SPKI Public Key Import
ok 102 pem.ts > ES384 X.509 Certificate Import
ok 103 pem.ts > ES512 PKCS8 Private Key Import
ok 104 pem.ts > ES512 SPKI Public Key Import
ok 105 pem.ts > ES512 X.509 Certificate Import
ok 106 pem.ts > PS256 PKCS8 Private Key Import
ok 107 pem.ts > PS256 SPKI Public Key Import
ok 108 pem.ts > PS256 X.509 Certificate Import
ok 109 pem.ts > PS384 PKCS8 Private Key Import
ok 110 pem.ts > PS384 SPKI Public Key Import
ok 111 pem.ts > PS384 X.509 Certificate Import
ok 112 pem.ts > PS512 PKCS8 Private Key Import
ok 113 pem.ts > PS512 SPKI Public Key Import
ok 114 pem.ts > PS512 X.509 Certificate Import
ok 115 pem.ts > RS256 PKCS8 Private Key Import
ok 116 pem.ts > RS256 SPKI Public Key Import
ok 117 pem.ts > RS256 X.509 Certificate Import
ok 118 pem.ts > RS384 PKCS8 Private Key Import
ok 119 pem.ts > RS384 SPKI Public Key Import
ok 120 pem.ts > RS384 X.509 Certificate Import
ok 121 pem.ts > RS512 PKCS8 Private Key Import
ok 122 pem.ts > RS512 SPKI Public Key Import
ok 123 pem.ts > RS512 X.509 Certificate Import
ok 124 pem.ts > RSA-OAEP-256 PKCS8 Private Key Import
ok 125 pem.ts > RSA-OAEP-256 SPKI Public Key Import
ok 126 pem.ts > RSA-OAEP-256 X.509 Certificate Import
ok 127 pem.ts > RSA-OAEP-384 PKCS8 Private Key Import
ok 128 pem.ts > RSA-OAEP-384 SPKI Public Key Import
ok 129 pem.ts > RSA-OAEP-384 X.509 Certificate Import
ok 130 pem.ts > RSA-OAEP-512 PKCS8 Private Key Import
ok 131 pem.ts > RSA-OAEP-512 SPKI Public Key Import
ok 132 pem.ts > RSA-OAEP-512 X.509 Certificate Import
ok 133 pem.ts > RSA-OAEP PKCS8 Private Key Import
ok 134 pem.ts > RSA-OAEP SPKI Public Key Import
ok 135 pem.ts > RSA-OAEP X.509 Certificate Import
ok 136 pem.ts > [not supported] RSA1_5 PKCS8 Private Key Import
ok 137 pem.ts > [not supported] RSA1_5 SPKI Public Key Import
ok 138 pem.ts > [not supported] RSA1_5 X.509 Certificate Import
ok 139 pem.ts > ECDH-ES P-256 PKCS8 Private Key Import
ok 140 pem.ts > ECDH-ES P-256 SPKI Public Key Import
ok 141 pem.ts > ECDH-ES P-256 X.509 Certificate Import
ok 142 pem.ts > ECDH-ES P-384 PKCS8 Private Key Import
ok 143 pem.ts > ECDH-ES P-384 SPKI Public Key Import
ok 144 pem.ts > ECDH-ES P-384 X.509 Certificate Import
ok 145 pem.ts > ECDH-ES P-521 PKCS8 Private Key Import
ok 146 pem.ts > ECDH-ES P-521 SPKI Public Key Import
ok 147 pem.ts > ECDH-ES P-521 X.509 Certificate Import
ok 148 pem.ts > [not supported] ECDH-ES secp256k1 PKCS8 Private Key Import
ok 149 pem.ts > [not supported] ECDH-ES secp256k1 SPKI Public Key Import
ok 150 pem.ts > [not supported] ECDH-ES secp256k1 X.509 Certificate Import
ok 151 pem.ts > [not supported] ECDH-ES X25519 PKCS8 Private Key Import
ok 152 pem.ts > [not supported] ECDH-ES X25519 SPKI Public Key Import
ok 153 pem.ts > [not supported] ECDH-ES X448 PKCS8 Private Key Import
ok 154 pem.ts > [not supported] ECDH-ES X448 SPKI Public Key Import
ok 155 pem.ts > [not supported] EdDSA Ed25519 PKCS8 Private Key Import
ok 156 pem.ts > [not supported] EdDSA Ed25519 SPKI Public Key Import
ok 157 pem.ts > [not supported] EdDSA Ed25519 X.509 Certificate Import
ok 158 pem.ts > [not supported] EdDSA Ed448 PKCS8 Private Key Import
ok 159 pem.ts > [not supported] EdDSA Ed448 SPKI Public Key Import
ok 160 pem.ts > [not supported] EdDSA Ed448 X.509 Certificate Import
ok 161 pbes2.ts > PBES2-HS256+A128KW
ok 162 pbes2.ts > PBES2-HS384+A192KW
ok 163 pbes2.ts > PBES2-HS512+A256KW
ok 164 rsaes.ts > [not supported] RSA1_5
not ok 165 rsaes.ts > RSA-OAEP
  ---
  message: "Promise rejected during \"RSA-OAEP\": The algorithm is not supported"
  severity: failed
  actual  : null
  expected: undefined
  stack: |
    promiseReactionJob@[native code]
  ...
not ok 166 rsaes.ts > RSA-OAEP-256
  ---
  message: "Promise rejected during \"RSA-OAEP-256\": The algorithm is not supported"
  severity: failed
  actual  : null
  expected: undefined
  stack: |
    promiseReactionJob@[native code]
  ...
not ok 167 rsaes.ts > RSA-OAEP-384
  ---
  message: "Promise rejected during \"RSA-OAEP-384\": The algorithm is not supported"
  severity: failed
  actual  : null
  expected: undefined
  stack: |
    promiseReactionJob@[native code]
  ...
not ok 168 rsaes.ts > RSA-OAEP-512
  ---
  message: "Promise rejected during \"RSA-OAEP-512\": The algorithm is not supported"
  severity: failed
  actual  : null
  expected: undefined
  stack: |
    promiseReactionJob@[native code]
  ...
1..168
# pass 159
# skip 0
# todo 0
# fail 9
Jarred-Sumner commented 2 years ago

regarding RSA OAEP

https://github.com/oven-sh/bun/blob/ab4e6624842fe4fb18a1514ef45acd7d26f31d07/src/bun.js/bindings/webcrypto/CryptoAlgorithmRSA_OAEPOpenSSL.cpp#L39-L80

Looks like this #if defined is false when it should be true

Now there are 4 failing tests.

ok 1 aes.ts > A128GCM
ok 2 aeskw.ts > A128KW
ok 3 aeskw.ts > A192KW
ok 4 aeskw.ts > A256KW
ok 5 aeskw.ts > A128GCMKW
ok 6 aeskw.ts > A192GCMKW
ok 7 aeskw.ts > A256GCMKW
ok 8 jws cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-4.1 - RSA v1.5 Signature
ok 9 jws cookbook > [not supported] https://www.rfc-editor.org/rfc/rfc8037#appendix-A.4 - Ed25519 Signing
not ok 10 jws cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-4.2 - RSA-PSS Signature
  ---
  message: "Promise rejected during \"https://www.rfc-editor.org/rfc/rfc7520#section-4.2 - RSA-PSS Signature\": The algorithm is not supported"
  severity: failed
  actual  : null
  expected: undefined
  stack: |
    promiseReactionJob@[native code]
  ...
ok 11 jws cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-4.3 - ECDSA Signature
ok 12 jws cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-4.4 - HMAC-SHA2 Integrity Protection
ok 13 jws cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-4.6 - Protecting Specific Header Fields
ok 14 jws cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-4.7 - Protecting Content Only
ok 15 jws cookbook > https://www.rfc-editor.org/rfc/rfc7797#section-4.1 - { "b64": false } JSON only
ok 16 jwe cookbook > [not supported] https://www.rfc-editor.org/rfc/rfc7520#section-5.1 - Key Encryption using RSA v1.5 and AES-HMAC-SHA2
ok 17 jwe cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-5.2 - Key Encryption using RSA-OAEP with AES-GCM
ok 18 jwe cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-5.3 - Key Wrap using PBES2-AES-KeyWrap with AES-CBC-HMAC-SHA2
ok 19 jwe cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-5.4 - Key Agreement with Key Wrapping using ECDH-ES and AES-KeyWrap with AES-GCM
ok 20 jwe cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-5.5 - Key Agreement using ECDH-ES with AES-CBC-HMAC-SHA2
ok 21 jwe cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-5.6 - Direction Encryption using AES-GCM
ok 22 jwe cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-5.6 - Key Wrap using AES-GCM KeyWrap with AES-CBC-HMAC-SHA2
ok 23 jwe cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-5.8 - Key Wrap using AES-KeyWrap with AES-GCM
ok 24 jwe cookbook > [not supported] https://www.rfc-editor.org/rfc/rfc7520#section-5.9 - Compressed Content
ok 25 jwe cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-5.10 - Including Additional Authenticated Data
ok 26 jwe cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-5.11 - Protecting Specific Header Fields
ok 27 jwe cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-5.12 - Protecting Content Only
ok 28 ecdh.ts > ECDH-ES P-256
ok 29 ecdh.ts > ECDH-ES P-384
ok 30 ecdh.ts > ECDH-ES P-521
ok 31 ecdh.ts > [not supported] ECDH-ES secp256k1
ok 32 ecdh.ts > [not supported] ECDH-ES X25519
ok 33 ecdh.ts > [not supported] ECDH-ES X448
ok 34 hmac.ts > HS256
ok 35 hmac.ts > HS384
ok 36 hmac.ts > HS512
ok 37 jwk.ts > ECDH-ES P-256 Private JWK Import
ok 38 jwk.ts > ECDH-ES P-384 Private JWK Import
ok 39 jwk.ts > ECDH-ES P-521 Private JWK Import
ok 40 jwk.ts > [not supported] ECDH-ES X25519 Private JWK Import
ok 41 jwk.ts > [not supported] ECDH-ES X448 Private JWK Import
ok 42 jwk.ts > [not supported] EdDSA Ed25519 Private JWK Import
ok 43 jwk.ts > [not supported] EdDSA Ed448 Private JWK Import
ok 44 jwk.ts > ES256 Private JWK Import
ok 45 jwk.ts > [not supported] ES256K Private JWK Import
ok 46 jwk.ts > ES384 Private JWK Import
ok 47 jwk.ts > ES512 Private JWK Import
ok 48 jwk.ts > PS256 Private JWK Import
ok 49 jwk.ts > PS384 Private JWK Import
ok 50 jwk.ts > PS512 Private JWK Import
ok 51 jwk.ts > RS256 Private JWK Import
ok 52 jwk.ts > RS384 Private JWK Import
ok 53 jwk.ts > RS512 Private JWK Import
ok 54 jwk.ts > RSA-OAEP-256 Private JWK Import
ok 55 jwk.ts > RSA-OAEP-384 Private JWK Import
ok 56 jwk.ts > RSA-OAEP-512 Private JWK Import
ok 57 jwk.ts > RSA-OAEP Private JWK Import
ok 58 jwk.ts > [not supported] RSA1_5 Private JWK Import
ok 59 jwk.ts > ECDH-ES P-256 Public JWK Import
ok 60 jwk.ts > ECDH-ES P-384 Public JWK Import
ok 61 jwk.ts > ECDH-ES P-521 Public JWK Import
ok 62 jwk.ts > [not supported] ECDH-ES X25519 Public JWK Import
ok 63 jwk.ts > [not supported] ECDH-ES X448 Public JWK Import
ok 64 jwk.ts > [not supported] EdDSA Ed25519 Public JWK Import
ok 65 jwk.ts > [not supported] EdDSA Ed448 Public JWK Import
ok 66 jwk.ts > ES256 Public JWK Import
ok 67 jwk.ts > [not supported] ES256K Public JWK Import
ok 68 jwk.ts > ES384 Public JWK Import
ok 69 jwk.ts > ES512 Public JWK Import
ok 70 jwk.ts > PS256 Public JWK Import
ok 71 jwk.ts > PS384 Public JWK Import
ok 72 jwk.ts > PS512 Public JWK Import
ok 73 jwk.ts > RS256 Public JWK Import
ok 74 jwk.ts > RS384 Public JWK Import
ok 75 jwk.ts > RS512 Public JWK Import
ok 76 jwk.ts > RSA-OAEP-256 Public JWK Import
ok 77 jwk.ts > RSA-OAEP-384 Public JWK Import
ok 78 jwk.ts > RSA-OAEP-512 Public JWK Import
ok 79 jwk.ts > RSA-OAEP Public JWK Import
ok 80 jwk.ts > [not supported] RSA1_5 Public JWK Import
[PollRef] ref
[fetch] onStart: 304.5us
[fetch] Processed 1 tasks
[fetch] Connected https://www.googleapis.com/oauth2/v3/certs
[fetch] - Keep-Alive release www.googleapis.com:443
[fetch] onAsyncHTTPComplete: 56.516ms
[PollRef] unref
[PollRef] ref
[PollRef] ref
[fetch] + Keep-Alive reuse www.googleapis.com:443
[fetch] Connected https://www.googleapis.com/oauth2/v3/certs
[fetch] onStart: 57.86ms
[fetch] Processed 1 tasks
[fetch] - Keep-Alive release www.googleapis.com:443
[fetch] onAsyncHTTPComplete: 6.295ms
[PollRef] unref
[PollRef] unref
ok 81 jwks.ts > fetches the JWKSet
ok 82 jws.ts > [not supported] EdDSA, {"crv":"Ed25519"}
ok 83 jws.ts > [not supported] EdDSA, {"crv":"Ed448"}
ok 84 jws.ts > ES256
ok 85 jws.ts > [not supported] ES256K
ok 86 jws.ts > ES384
ok 87 jws.ts > ES512
not ok 88 jws.ts > PS256
  ---
  message: "Promise rejected during \"PS256\": The algorithm is not supported"
  severity: failed
  actual  : null
  expected: undefined
  stack: |
    promiseReactionJob@[native code]
  ...
not ok 89 jws.ts > PS384
  ---
  message: "Promise rejected during \"PS384\": The algorithm is not supported"
  severity: failed
  actual  : null
  expected: undefined
  stack: |
    promiseReactionJob@[native code]
  ...
not ok 90 jws.ts > PS512
  ---
  message: "Promise rejected during \"PS512\": The algorithm is not supported"
  severity: failed
  actual  : null
  expected: undefined
  stack: |
    promiseReactionJob@[native code]
  ...
ok 91 jws.ts > RS256
ok 92 jws.ts > RS384
ok 93 jws.ts > RS512
ok 94 pem.ts > ES256 PKCS8 Private Key Import
ok 95 pem.ts > ES256 SPKI Public Key Import
ok 96 pem.ts > ES256 X.509 Certificate Import
ok 97 pem.ts > [not supported] ES256K PKCS8 Private Key Import
ok 98 pem.ts > [not supported] ES256K SPKI Public Key Import
ok 99 pem.ts > [not supported] ES256K X.509 Certificate Import
ok 100 pem.ts > ES384 PKCS8 Private Key Import
ok 101 pem.ts > ES384 SPKI Public Key Import
ok 102 pem.ts > ES384 X.509 Certificate Import
ok 103 pem.ts > ES512 PKCS8 Private Key Import
ok 104 pem.ts > ES512 SPKI Public Key Import
ok 105 pem.ts > ES512 X.509 Certificate Import
ok 106 pem.ts > PS256 PKCS8 Private Key Import
ok 107 pem.ts > PS256 SPKI Public Key Import
ok 108 pem.ts > PS256 X.509 Certificate Import
ok 109 pem.ts > PS384 PKCS8 Private Key Import
ok 110 pem.ts > PS384 SPKI Public Key Import
ok 111 pem.ts > PS384 X.509 Certificate Import
ok 112 pem.ts > PS512 PKCS8 Private Key Import
ok 113 pem.ts > PS512 SPKI Public Key Import
ok 114 pem.ts > PS512 X.509 Certificate Import
ok 115 pem.ts > RS256 PKCS8 Private Key Import
ok 116 pem.ts > RS256 SPKI Public Key Import
ok 117 pem.ts > RS256 X.509 Certificate Import
ok 118 pem.ts > RS384 PKCS8 Private Key Import
ok 119 pem.ts > RS384 SPKI Public Key Import
ok 120 pem.ts > RS384 X.509 Certificate Import
ok 121 pem.ts > RS512 PKCS8 Private Key Import
ok 122 pem.ts > RS512 SPKI Public Key Import
ok 123 pem.ts > RS512 X.509 Certificate Import
ok 124 pem.ts > RSA-OAEP-256 PKCS8 Private Key Import
ok 125 pem.ts > RSA-OAEP-256 SPKI Public Key Import
ok 126 pem.ts > RSA-OAEP-256 X.509 Certificate Import
ok 127 pem.ts > RSA-OAEP-384 PKCS8 Private Key Import
ok 128 pem.ts > RSA-OAEP-384 SPKI Public Key Import
ok 129 pem.ts > RSA-OAEP-384 X.509 Certificate Import
ok 130 pem.ts > RSA-OAEP-512 PKCS8 Private Key Import
ok 131 pem.ts > RSA-OAEP-512 SPKI Public Key Import
ok 132 pem.ts > RSA-OAEP-512 X.509 Certificate Import
ok 133 pem.ts > RSA-OAEP PKCS8 Private Key Import
ok 134 pem.ts > RSA-OAEP SPKI Public Key Import
ok 135 pem.ts > RSA-OAEP X.509 Certificate Import
ok 136 pem.ts > [not supported] RSA1_5 PKCS8 Private Key Import
ok 137 pem.ts > [not supported] RSA1_5 SPKI Public Key Import
ok 138 pem.ts > [not supported] RSA1_5 X.509 Certificate Import
ok 139 pem.ts > ECDH-ES P-256 PKCS8 Private Key Import
ok 140 pem.ts > ECDH-ES P-256 SPKI Public Key Import
ok 141 pem.ts > ECDH-ES P-256 X.509 Certificate Import
ok 142 pem.ts > ECDH-ES P-384 PKCS8 Private Key Import
ok 143 pem.ts > ECDH-ES P-384 SPKI Public Key Import
ok 144 pem.ts > ECDH-ES P-384 X.509 Certificate Import
ok 145 pem.ts > ECDH-ES P-521 PKCS8 Private Key Import
ok 146 pem.ts > ECDH-ES P-521 SPKI Public Key Import
ok 147 pem.ts > ECDH-ES P-521 X.509 Certificate Import
ok 148 pem.ts > [not supported] ECDH-ES secp256k1 PKCS8 Private Key Import
ok 149 pem.ts > [not supported] ECDH-ES secp256k1 SPKI Public Key Import
ok 150 pem.ts > [not supported] ECDH-ES secp256k1 X.509 Certificate Import
ok 151 pem.ts > [not supported] ECDH-ES X25519 PKCS8 Private Key Import
ok 152 pem.ts > [not supported] ECDH-ES X25519 SPKI Public Key Import
ok 153 pem.ts > [not supported] ECDH-ES X448 PKCS8 Private Key Import
ok 154 pem.ts > [not supported] ECDH-ES X448 SPKI Public Key Import
ok 155 pem.ts > [not supported] EdDSA Ed25519 PKCS8 Private Key Import
ok 156 pem.ts > [not supported] EdDSA Ed25519 SPKI Public Key Import
ok 157 pem.ts > [not supported] EdDSA Ed25519 X.509 Certificate Import
ok 158 pem.ts > [not supported] EdDSA Ed448 PKCS8 Private Key Import
ok 159 pem.ts > [not supported] EdDSA Ed448 SPKI Public Key Import
ok 160 pem.ts > [not supported] EdDSA Ed448 X.509 Certificate Import
ok 161 pbes2.ts > PBES2-HS256+A128KW
ok 162 pbes2.ts > PBES2-HS384+A192KW
ok 163 pbes2.ts > PBES2-HS512+A256KW
ok 164 rsaes.ts > [not supported] RSA1_5
ok 165 rsaes.ts > RSA-OAEP
ok 166 rsaes.ts > RSA-OAEP-256
ok 167 rsaes.ts > RSA-OAEP-384
ok 168 rsaes.ts > RSA-OAEP-512
1..168
# pass 164
# skip 0
# todo 0
# fail 4
Jarred-Sumner commented 2 years ago

A couple more #if's were incorrect. Fixed in bfa40d1d3f69a4c5895dba9365ad2e94e92793ec

Now all the tests pass! These differences are probably because Bun uses BoringSSL but WebCrypto/Sony uses OpenSSL 3.

ok 1 aes.ts > A128GCM
ok 2 aeskw.ts > A128KW
ok 3 aeskw.ts > A192KW
ok 4 aeskw.ts > A256KW
ok 5 aeskw.ts > A128GCMKW
ok 6 aeskw.ts > A192GCMKW
ok 7 aeskw.ts > A256GCMKW
ok 8 jws cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-4.1 - RSA v1.5 Signature
ok 9 jws cookbook > [not supported] https://www.rfc-editor.org/rfc/rfc8037#appendix-A.4 - Ed25519 Signing
ok 10 jws cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-4.2 - RSA-PSS Signature
ok 11 jws cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-4.3 - ECDSA Signature
ok 12 jws cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-4.4 - HMAC-SHA2 Integrity Protection
ok 13 jws cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-4.6 - Protecting Specific Header Fields
ok 14 jws cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-4.7 - Protecting Content Only
ok 15 jws cookbook > https://www.rfc-editor.org/rfc/rfc7797#section-4.1 - { "b64": false } JSON only
ok 16 jwe cookbook > [not supported] https://www.rfc-editor.org/rfc/rfc7520#section-5.1 - Key Encryption using RSA v1.5 and AES-HMAC-SHA2
ok 17 jwe cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-5.2 - Key Encryption using RSA-OAEP with AES-GCM
ok 18 jwe cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-5.3 - Key Wrap using PBES2-AES-KeyWrap with AES-CBC-HMAC-SHA2
ok 19 jwe cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-5.4 - Key Agreement with Key Wrapping using ECDH-ES and AES-KeyWrap with AES-GCM
ok 20 jwe cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-5.5 - Key Agreement using ECDH-ES with AES-CBC-HMAC-SHA2
ok 21 jwe cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-5.6 - Direction Encryption using AES-GCM
ok 22 jwe cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-5.6 - Key Wrap using AES-GCM KeyWrap with AES-CBC-HMAC-SHA2
ok 23 jwe cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-5.8 - Key Wrap using AES-KeyWrap with AES-GCM
ok 24 jwe cookbook > [not supported] https://www.rfc-editor.org/rfc/rfc7520#section-5.9 - Compressed Content
ok 25 jwe cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-5.10 - Including Additional Authenticated Data
ok 26 jwe cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-5.11 - Protecting Specific Header Fields
ok 27 jwe cookbook > https://www.rfc-editor.org/rfc/rfc7520#section-5.12 - Protecting Content Only
ok 28 ecdh.ts > ECDH-ES P-256
ok 29 ecdh.ts > ECDH-ES P-384
ok 30 ecdh.ts > ECDH-ES P-521
ok 31 ecdh.ts > [not supported] ECDH-ES secp256k1
ok 32 ecdh.ts > [not supported] ECDH-ES X25519
ok 33 ecdh.ts > [not supported] ECDH-ES X448
ok 34 hmac.ts > HS256
ok 35 hmac.ts > HS384
ok 36 hmac.ts > HS512
ok 37 jwk.ts > ECDH-ES P-256 Private JWK Import
ok 38 jwk.ts > ECDH-ES P-384 Private JWK Import
ok 39 jwk.ts > ECDH-ES P-521 Private JWK Import
ok 40 jwk.ts > [not supported] ECDH-ES X25519 Private JWK Import
ok 41 jwk.ts > [not supported] ECDH-ES X448 Private JWK Import
ok 42 jwk.ts > [not supported] EdDSA Ed25519 Private JWK Import
ok 43 jwk.ts > [not supported] EdDSA Ed448 Private JWK Import
ok 44 jwk.ts > ES256 Private JWK Import
ok 45 jwk.ts > [not supported] ES256K Private JWK Import
ok 46 jwk.ts > ES384 Private JWK Import
ok 47 jwk.ts > ES512 Private JWK Import
ok 48 jwk.ts > PS256 Private JWK Import
ok 49 jwk.ts > PS384 Private JWK Import
ok 50 jwk.ts > PS512 Private JWK Import
ok 51 jwk.ts > RS256 Private JWK Import
ok 52 jwk.ts > RS384 Private JWK Import
ok 53 jwk.ts > RS512 Private JWK Import
ok 54 jwk.ts > RSA-OAEP-256 Private JWK Import
ok 55 jwk.ts > RSA-OAEP-384 Private JWK Import
ok 56 jwk.ts > RSA-OAEP-512 Private JWK Import
ok 57 jwk.ts > RSA-OAEP Private JWK Import
ok 58 jwk.ts > [not supported] RSA1_5 Private JWK Import
ok 59 jwk.ts > ECDH-ES P-256 Public JWK Import
ok 60 jwk.ts > ECDH-ES P-384 Public JWK Import
ok 61 jwk.ts > ECDH-ES P-521 Public JWK Import
ok 62 jwk.ts > [not supported] ECDH-ES X25519 Public JWK Import
ok 63 jwk.ts > [not supported] ECDH-ES X448 Public JWK Import
ok 64 jwk.ts > [not supported] EdDSA Ed25519 Public JWK Import
ok 65 jwk.ts > [not supported] EdDSA Ed448 Public JWK Import
ok 66 jwk.ts > ES256 Public JWK Import
ok 67 jwk.ts > [not supported] ES256K Public JWK Import
ok 68 jwk.ts > ES384 Public JWK Import
ok 69 jwk.ts > ES512 Public JWK Import
ok 70 jwk.ts > PS256 Public JWK Import
ok 71 jwk.ts > PS384 Public JWK Import
ok 72 jwk.ts > PS512 Public JWK Import
ok 73 jwk.ts > RS256 Public JWK Import
ok 74 jwk.ts > RS384 Public JWK Import
ok 75 jwk.ts > RS512 Public JWK Import
ok 76 jwk.ts > RSA-OAEP-256 Public JWK Import
ok 77 jwk.ts > RSA-OAEP-384 Public JWK Import
ok 78 jwk.ts > RSA-OAEP-512 Public JWK Import
ok 79 jwk.ts > RSA-OAEP Public JWK Import
ok 80 jwk.ts > [not supported] RSA1_5 Public JWK Import
[PollRef] ref
[fetch] onStart: 451.792us
[fetch] Processed 1 tasks
[fetch] Connected https://www.googleapis.com/oauth2/v3/certs
[fetch] - Keep-Alive release www.googleapis.com:443
[fetch] onAsyncHTTPComplete: 59.497ms
[PollRef] unref
[PollRef] ref
[PollRef] ref
[fetch] + Keep-Alive reuse www.googleapis.com:443
[fetch] Connected https://www.googleapis.com/oauth2/v3/certs
[fetch] onStart: 60.934ms
[fetch] Processed 1 tasks
[fetch] - Keep-Alive release www.googleapis.com:443
[fetch] onAsyncHTTPComplete: 6.767ms
[PollRef] unref
[PollRef] unref
ok 81 jwks.ts > fetches the JWKSet
ok 82 jws.ts > [not supported] EdDSA, {"crv":"Ed25519"}
ok 83 jws.ts > [not supported] EdDSA, {"crv":"Ed448"}
ok 84 jws.ts > ES256
ok 85 jws.ts > [not supported] ES256K
ok 86 jws.ts > ES384
ok 87 jws.ts > ES512
ok 88 jws.ts > PS256
ok 89 jws.ts > PS384
ok 90 jws.ts > PS512
ok 91 jws.ts > RS256
ok 92 jws.ts > RS384
ok 93 jws.ts > RS512
ok 94 pem.ts > ES256 PKCS8 Private Key Import
ok 95 pem.ts > ES256 SPKI Public Key Import
ok 96 pem.ts > ES256 X.509 Certificate Import
ok 97 pem.ts > [not supported] ES256K PKCS8 Private Key Import
ok 98 pem.ts > [not supported] ES256K SPKI Public Key Import
ok 99 pem.ts > [not supported] ES256K X.509 Certificate Import
ok 100 pem.ts > ES384 PKCS8 Private Key Import
ok 101 pem.ts > ES384 SPKI Public Key Import
ok 102 pem.ts > ES384 X.509 Certificate Import
ok 103 pem.ts > ES512 PKCS8 Private Key Import
ok 104 pem.ts > ES512 SPKI Public Key Import
ok 105 pem.ts > ES512 X.509 Certificate Import
ok 106 pem.ts > PS256 PKCS8 Private Key Import
ok 107 pem.ts > PS256 SPKI Public Key Import
ok 108 pem.ts > PS256 X.509 Certificate Import
ok 109 pem.ts > PS384 PKCS8 Private Key Import
ok 110 pem.ts > PS384 SPKI Public Key Import
ok 111 pem.ts > PS384 X.509 Certificate Import
ok 112 pem.ts > PS512 PKCS8 Private Key Import
ok 113 pem.ts > PS512 SPKI Public Key Import
ok 114 pem.ts > PS512 X.509 Certificate Import
ok 115 pem.ts > RS256 PKCS8 Private Key Import
ok 116 pem.ts > RS256 SPKI Public Key Import
ok 117 pem.ts > RS256 X.509 Certificate Import
ok 118 pem.ts > RS384 PKCS8 Private Key Import
ok 119 pem.ts > RS384 SPKI Public Key Import
ok 120 pem.ts > RS384 X.509 Certificate Import
ok 121 pem.ts > RS512 PKCS8 Private Key Import
ok 122 pem.ts > RS512 SPKI Public Key Import
ok 123 pem.ts > RS512 X.509 Certificate Import
ok 124 pem.ts > RSA-OAEP-256 PKCS8 Private Key Import
ok 125 pem.ts > RSA-OAEP-256 SPKI Public Key Import
ok 126 pem.ts > RSA-OAEP-256 X.509 Certificate Import
ok 127 pem.ts > RSA-OAEP-384 PKCS8 Private Key Import
ok 128 pem.ts > RSA-OAEP-384 SPKI Public Key Import
ok 129 pem.ts > RSA-OAEP-384 X.509 Certificate Import
ok 130 pem.ts > RSA-OAEP-512 PKCS8 Private Key Import
ok 131 pem.ts > RSA-OAEP-512 SPKI Public Key Import
ok 132 pem.ts > RSA-OAEP-512 X.509 Certificate Import
ok 133 pem.ts > RSA-OAEP PKCS8 Private Key Import
ok 134 pem.ts > RSA-OAEP SPKI Public Key Import
ok 135 pem.ts > RSA-OAEP X.509 Certificate Import
ok 136 pem.ts > [not supported] RSA1_5 PKCS8 Private Key Import
ok 137 pem.ts > [not supported] RSA1_5 SPKI Public Key Import
ok 138 pem.ts > [not supported] RSA1_5 X.509 Certificate Import
ok 139 pem.ts > ECDH-ES P-256 PKCS8 Private Key Import
ok 140 pem.ts > ECDH-ES P-256 SPKI Public Key Import
ok 141 pem.ts > ECDH-ES P-256 X.509 Certificate Import
ok 142 pem.ts > ECDH-ES P-384 PKCS8 Private Key Import
ok 143 pem.ts > ECDH-ES P-384 SPKI Public Key Import
ok 144 pem.ts > ECDH-ES P-384 X.509 Certificate Import
ok 145 pem.ts > ECDH-ES P-521 PKCS8 Private Key Import
ok 146 pem.ts > ECDH-ES P-521 SPKI Public Key Import
ok 147 pem.ts > ECDH-ES P-521 X.509 Certificate Import
ok 148 pem.ts > [not supported] ECDH-ES secp256k1 PKCS8 Private Key Import
ok 149 pem.ts > [not supported] ECDH-ES secp256k1 SPKI Public Key Import
ok 150 pem.ts > [not supported] ECDH-ES secp256k1 X.509 Certificate Import
ok 151 pem.ts > [not supported] ECDH-ES X25519 PKCS8 Private Key Import
ok 152 pem.ts > [not supported] ECDH-ES X25519 SPKI Public Key Import
ok 153 pem.ts > [not supported] ECDH-ES X448 PKCS8 Private Key Import
ok 154 pem.ts > [not supported] ECDH-ES X448 SPKI Public Key Import
ok 155 pem.ts > [not supported] EdDSA Ed25519 PKCS8 Private Key Import
ok 156 pem.ts > [not supported] EdDSA Ed25519 SPKI Public Key Import
ok 157 pem.ts > [not supported] EdDSA Ed25519 X.509 Certificate Import
ok 158 pem.ts > [not supported] EdDSA Ed448 PKCS8 Private Key Import
ok 159 pem.ts > [not supported] EdDSA Ed448 SPKI Public Key Import
ok 160 pem.ts > [not supported] EdDSA Ed448 X.509 Certificate Import
ok 161 pbes2.ts > PBES2-HS256+A128KW
ok 162 pbes2.ts > PBES2-HS384+A192KW
ok 163 pbes2.ts > PBES2-HS512+A256KW
ok 164 rsaes.ts > [not supported] RSA1_5
ok 165 rsaes.ts > RSA-OAEP
ok 166 rsaes.ts > RSA-OAEP-256
ok 167 rsaes.ts > RSA-OAEP-384
ok 168 rsaes.ts > RSA-OAEP-512
1..168
# pass 168
# skip 0
# todo 0
# fail 0
All tests passed!
panva commented 2 years ago

I can't say the result has changed at all when I download and run the suite using the bun-darwin-aarch64 artifact from the latest passing github actions build after bfa40d1d3f69a4c5895dba9365ad2e94e92793ec.

Jarred-Sumner commented 2 years ago

@panva There is a bug where the process isn't kept alive with this test runner's pending callback

As a temporary workaround, wrapping in an awaited promise should fix it:

diff --git a/tap/run-bun.ts b/tap/run-bun.ts
index f3ed774c..0a4aea68 100644
--- a/tap/run-bun.ts
+++ b/tap/run-bun.ts
@@ -1,9 +1,12 @@
 import QUnit from 'qunit'
 import run from './run.js'

-run(QUnit, (stats) => {
-  if (stats?.failed === 0) {
-    // @ts-ignore
-    process.exit(42)
-  }
+await new Promise((_, reject) => {
+  run(QUnit, (stats) => {
+    if (stats?.failed === 0) {
+      // @ts-ignore
+      process.exit(42)
+    }
+    reject(new Error('Tests failed'))
+  })
 })
panva commented 2 years ago

cheers @Jarred-Sumner, that works.

panva commented 2 years ago

it seems that was the problem all along, albeit now you also fixed RSA-PSS and RSA-OAEP support <3