Skip to content

Commit

Permalink
Rename the old WithMaxBufferSize option as previously warned (#1218)
Browse files Browse the repository at this point in the history
Co-authored-by: Daisuke Maki <lestrrat+github@users.noreplay.github.com>
  • Loading branch information
lestrrat and Daisuke Maki authored Oct 23, 2024
1 parent 9f5ef60 commit a7e66e3
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 27 deletions.
2 changes: 1 addition & 1 deletion jwe/jwe.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func Settings(options ...GlobalOption) {
maxPBES2Count = option.Value().(int)
case identMaxDecompressBufferSize{}:
maxDecompressBufferSize = option.Value().(int64)
case identMaxBufferSize{}:
case identCBCBufferSize{}:
aescbc.SetMaxBufferSize(option.Value().(int64))
}
}
Expand Down
6 changes: 3 additions & 3 deletions jwe/jwe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -807,10 +807,10 @@ func TestGHSA_7f9x_gw85_8grf(t *testing.T) {
}
}

func TestMaxBufferSize(t *testing.T) {
func TestCBCBufferSize(t *testing.T) {
// NOTE: This has GLOBAL EFFECT
jwe.Settings(jwe.WithMaxBufferSize(1))
defer jwe.Settings(jwe.WithMaxBufferSize(0))
jwe.Settings(jwe.WithCBCBufferSize(1))
defer jwe.Settings(jwe.WithCBCBufferSize(0))

key, err := jwxtest.GenerateRsaJwk()
require.NoError(t, err, `jwxtest.GenerateRsaJwk should succeed`)
Expand Down
8 changes: 3 additions & 5 deletions jwe/options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,13 @@ options:
This option can be used for `jwe.Settings()`, which changes the behavior
globally, or for `jwe.Decrypt()`, which changes the behavior for that
specific call.
- ident: MaxBufferSize
- ident: CBCBufferSize
interface: GlobalOption
argument_type: int64
comment: |
WithMaxBufferSize specifies the maximum buffer size for internal
WithCBCBufferSize specifies the maximum buffer size for internal
calculations, such as when AES-CBC is performed. The default value is 256MB.
If set to an invalid value, the default value is used.
In v2, this option was called MaxBufferSize.
This option has a global effect.
Due to historical reasons this option has a vague name, but in future versions
it will be appropriately renamed.
32 changes: 15 additions & 17 deletions jwe/options_gen.go

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

2 changes: 1 addition & 1 deletion jwe/options_gen_test.go

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

0 comments on commit a7e66e3

Please sign in to comment.