From 13ca3a5e6cbc49e2a6fe4572c081081fda97a675 Mon Sep 17 00:00:00 2001 From: lestrrat <49281+lestrrat@users.noreply.github.com> Date: Sat, 9 Mar 2024 16:24:47 +0900 Subject: [PATCH] Rename jwe.WithMaxBufferSize to jwe.WithMaxAESCBCBufferSize (#1095) --- jwe/jwe.go | 2 +- jwe/jwe_test.go | 6 +++--- jwe/options.yaml | 6 +++--- jwe/options_gen.go | 14 +++++++------- jwe/options_gen_test.go | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jwe/jwe.go b/jwe/jwe.go index 8bcba7237..035cc7f74 100644 --- a/jwe/jwe.go +++ b/jwe/jwe.go @@ -40,7 +40,7 @@ func Settings(options ...GlobalOption) { maxPBES2Count = option.Value().(int) case identMaxDecompressBufferSize{}: maxDecompressBufferSize = option.Value().(int64) - case identMaxBufferSize{}: + case identMaxAESCBCBufferSize{}: aescbc.SetMaxBufferSize(option.Value().(int64)) } } diff --git a/jwe/jwe_test.go b/jwe/jwe_test.go index 26303dc77..3bd245e19 100644 --- a/jwe/jwe_test.go +++ b/jwe/jwe_test.go @@ -961,10 +961,10 @@ func TestGHSA_7f9x_gw85_8grf(t *testing.T) { } } -func TestMaxBufferSize(t *testing.T) { +func TestMaxAESCBCBufferSize(t *testing.T) { // NOTE: This has GLOBAL EFFECT - jwe.Settings(jwe.WithMaxBufferSize(1)) - defer jwe.Settings(jwe.WithMaxBufferSize(0)) + jwe.Settings(jwe.WithMaxAESCBCBufferSize(1)) + defer jwe.Settings(jwe.WithMaxAESCBCBufferSize(0)) key, err := jwxtest.GenerateRsaJwk() require.NoError(t, err, `jwxtest.GenerateRsaJwk should succeed`) diff --git a/jwe/options.yaml b/jwe/options.yaml index f465ab2ed..336d3d05e 100644 --- a/jwe/options.yaml +++ b/jwe/options.yaml @@ -159,12 +159,12 @@ 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: MaxAESCBCBufferSize interface: GlobalOption argument_type: int64 comment: | - WithMaxBufferSize specifies the maximum buffer size for internal - calculations, such as when AES-CBC is performed. The default value is 256MB. + WithMaxAESCBCBufferSize specifies the maximum buffer size for internal + AES-CBC calculations. The default value is 256MB. If set to an invalid value, the default value is used. This option has a global effect. diff --git a/jwe/options_gen.go b/jwe/options_gen.go index 9154b80c2..c1be20353 100644 --- a/jwe/options_gen.go +++ b/jwe/options_gen.go @@ -144,7 +144,7 @@ type identFS struct{} type identKey struct{} type identKeyProvider struct{} type identKeyUsed struct{} -type identMaxBufferSize struct{} +type identMaxAESCBCBufferSize struct{} type identMaxDecompressBufferSize struct{} type identMaxPBES2Count struct{} type identMergeProtectedHeaders struct{} @@ -183,8 +183,8 @@ func (identKeyUsed) String() string { return "WithKeyUsed" } -func (identMaxBufferSize) String() string { - return "WithMaxBufferSize" +func (identMaxAESCBCBufferSize) String() string { + return "WithMaxAESCBCBufferSize" } func (identMaxDecompressBufferSize) String() string { @@ -270,16 +270,16 @@ func WithKeyUsed(v interface{}) DecryptOption { return &decryptOption{option.New(identKeyUsed{}, v)} } -// WithMaxBufferSize specifies the maximum buffer size for internal -// calculations, such as when AES-CBC is performed. The default value is 256MB. +// WithMaxAESCBCBufferSize specifies the maximum buffer size for internal +// AES-CBC calculations. The default value is 256MB. // If set to an invalid value, the default value is used. // // 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. -func WithMaxBufferSize(v int64) GlobalOption { - return &globalOption{option.New(identMaxBufferSize{}, v)} +func WithMaxAESCBCBufferSize(v int64) GlobalOption { + return &globalOption{option.New(identMaxAESCBCBufferSize{}, v)} } // WithMaxDecompressBufferSize specifies the maximum buffer size for used when diff --git a/jwe/options_gen_test.go b/jwe/options_gen_test.go index a872d45f5..fc8112432 100644 --- a/jwe/options_gen_test.go +++ b/jwe/options_gen_test.go @@ -16,7 +16,7 @@ func TestOptionIdent(t *testing.T) { require.Equal(t, "WithKey", identKey{}.String()) require.Equal(t, "WithKeyProvider", identKeyProvider{}.String()) require.Equal(t, "WithKeyUsed", identKeyUsed{}.String()) - require.Equal(t, "WithMaxBufferSize", identMaxBufferSize{}.String()) + require.Equal(t, "WithMaxAESCBCBufferSize", identMaxAESCBCBufferSize{}.String()) require.Equal(t, "WithMaxDecompressBufferSize", identMaxDecompressBufferSize{}.String()) require.Equal(t, "WithMaxPBES2Count", identMaxPBES2Count{}.String()) require.Equal(t, "WithMergeProtectedHeaders", identMergeProtectedHeaders{}.String())