Skip to content

Commit

Permalink
rsa: use web platform tests checkout approach
Browse files Browse the repository at this point in the history
  • Loading branch information
olegbespalov committed Oct 25, 2024
1 parent f98c46b commit 6813847
Show file tree
Hide file tree
Showing 13 changed files with 103 additions and 1,624 deletions.
3 changes: 3 additions & 0 deletions webcrypto/jwk.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,9 @@ func exportRSAJWK(key *CryptoKey) (interface{}, error) {
exported.Set("dp", base64URLEncode(rsaKey.Precomputed.Dp.Bytes()))
exported.Set("dq", base64URLEncode(rsaKey.Precomputed.Dq.Bytes()))
exported.Set("qi", base64URLEncode(rsaKey.Precomputed.Qinv.Bytes()))
case *rsa.PublicKey:
exported.Set("n", base64URLEncode(rsaKey.N.Bytes()))
exported.Set("e", base64URLEncode(big.NewInt(int64(rsaKey.E)).Bytes()))
case rsa.PublicKey:
exported.Set("n", base64URLEncode(rsaKey.N.Bytes()))
exported.Set("e", base64URLEncode(big.NewInt(int64(rsaKey.E)).Bytes()))
Expand Down
22 changes: 12 additions & 10 deletions webcrypto/subtle_crypto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,14 @@ func TestSubtleCryptoImportExportKey(t *testing.T) {
t.Run("rsa", func(t *testing.T) {
t.Parallel()

ts := newConfiguredRuntime(t)
ts := newWebPlatformTestRuntime(t)

gotErr := ts.EventLoop.Start(func() error {
err := executeTestScripts(ts.VU.Runtime(), "./tests/import_export", "rsa_importKey.js")

return err
return executeTestScripts(
ts.VU.Runtime(),
webPlatformTestSuite+"import_export",
"rsa_importKey.https.any.js",
)
})

assert.NoError(t, gotErr)
Expand Down Expand Up @@ -185,10 +187,10 @@ func TestSubtleCryptoEncryptDecrypt(t *testing.T) {
t.Run("RSA-OAEP", func(t *testing.T) {
t.Parallel()

ts := newConfiguredRuntime(t)
ts := newWebPlatformTestRuntime(t)

gotErr := ts.EventLoop.Start(func() error {
err := executeTestScripts(ts.VU.Runtime(), "./tests/encrypt_decrypt", "rsa_vectors.js", "rsa.js")
err := executeTestScripts(ts.VU.Runtime(), webPlatformTestSuite+"encrypt_decrypt", "rsa_vectors.js", "rsa.js")
require.NoError(t, err)

_, err = ts.VU.Runtime().RunString(`run_test()`)
Expand Down Expand Up @@ -240,10 +242,10 @@ func TestSubtleCryptoSignVerify(t *testing.T) {
t.Run("RSA-PKCS", func(t *testing.T) {
t.Parallel()

ts := newConfiguredRuntime(t)
ts := newWebPlatformTestRuntime(t)

gotErr := ts.EventLoop.Start(func() error {
err := executeTestScripts(ts.VU.Runtime(), "./tests/sign_verify", "rsa_pkcs_vectors.js", "rsa.js")
err := executeTestScripts(ts.VU.Runtime(), webPlatformTestSuite+"sign_verify", "rsa_pkcs_vectors.js", "rsa.js")
require.NoError(t, err)

_, err = ts.VU.Runtime().RunString(`run_test()`)
Expand All @@ -257,10 +259,10 @@ func TestSubtleCryptoSignVerify(t *testing.T) {
t.Run("RSA-PSS", func(t *testing.T) {
t.Parallel()

ts := newConfiguredRuntime(t)
ts := newWebPlatformTestRuntime(t)

gotErr := ts.EventLoop.Start(func() error {
err := executeTestScripts(ts.VU.Runtime(), "./tests/sign_verify", "rsa_pss_vectors.js", "rsa.js")
err := executeTestScripts(ts.VU.Runtime(), webPlatformTestSuite+"sign_verify", "rsa_pss_vectors.js", "rsa.js")
require.NoError(t, err)

_, err = ts.VU.Runtime().RunString(`run_test()`)
Expand Down
394 changes: 0 additions & 394 deletions webcrypto/tests/encrypt_decrypt/rsa.js

This file was deleted.

214 changes: 0 additions & 214 deletions webcrypto/tests/encrypt_decrypt/rsa_vectors.js

This file was deleted.

286 changes: 0 additions & 286 deletions webcrypto/tests/import_export/rsa_importKey.js

This file was deleted.

453 changes: 0 additions & 453 deletions webcrypto/tests/sign_verify/rsa.js

This file was deleted.

99 changes: 0 additions & 99 deletions webcrypto/tests/sign_verify/rsa_pkcs_vectors.js

This file was deleted.

Loading

0 comments on commit 6813847

Please # to comment.