Skip to content

Commit

Permalink
Improve API for checking algorithm characteristics around symmetry (#…
Browse files Browse the repository at this point in the history
…1151)

* Fix missing imports in genjwa

These imports are not actually missing in the generated files because
the WithFormatCode option adds them automatically. It is better to not
depend on this feature in case of identical package names.

* Fix typo

* Fix documentation

* Add IsSymmetric method for signature algorithms

Add IsSymmetric method to the KeyAlgorithm interface.
Add symmetric indication to element instead of separate map.

* Add IsAssymetric method for signature and key encryption algorithms

Add IsAssymetric method to the Key KeyAlgorithm interface.
Replace symmetric indication of element with a type indication.

* Remove IsAsymmetric methods

Add comment to IsSymmetric method to indicate custom registered
algorithms will always return false.
Add comment to the IsSymmetric method of SignatureAlgorithm to indicate
the special nature of NoSignature.
Remove IsSymmetric from interface and from InvalidKeyAlgorithm.

* Add register with options function

Add tests for register (with options) functions.

* Remove unnecessary RegisterXXXXWithOptions functions

Change the RegisterXXXXWithOptions functions to no longer return an
error.

* Minor tweaks

* Tweak comments
* Use the underlying WithOptions from Register**** function
* remove struct supportedOptions, since it only has one item. it can be
  re-introduced if there are more features to be added

* tweak comment

* Fix bazel

---------

Co-authored-by: Hannes Kunnen <[email protected]>
  • Loading branch information
lestrrat and Hannes-Kunnen authored Jul 12, 2024
1 parent 523cc14 commit 6e4c9cb
Show file tree
Hide file tree
Showing 14 changed files with 977 additions and 64 deletions.
5 changes: 5 additions & 0 deletions jwa/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ go_library(
"jwa.go",
"key_encryption_gen.go",
"key_type_gen.go",
"options_gen.go",
"signature_gen.go",
],
importpath = "github.com/lestrrat-go/jwx/v2/jwa",
visibility = ["//visibility:public"],
deps = [
"@com_github_lestrrat_go_option//:option",
],
)

go_test(
Expand All @@ -29,6 +33,7 @@ go_test(
deps = [
":jwa",
"@com_github_stretchr_testify//assert",
"@com_github_lestrrat_go_option//:option",
],
)

Expand Down
55 changes: 55 additions & 0 deletions jwa/compression_gen_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions jwa/content_encryption_gen_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions jwa/elliptic_gen_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion jwa/jwa.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import "fmt"
// like other fields.
//
// Ideally we would like to keep track of Signature Algorithms and
// Content Encryption Algorithms separately, and force the APIs to
// Key Encryption Algorithms separately, and force the APIs to
// type-check at compile time, but this allows users to pass a value from a
// jwk.Key directly
type KeyAlgorithm interface {
Expand Down
44 changes: 38 additions & 6 deletions jwa/key_encryption_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6e4c9cb

Please sign in to comment.