Skip to content

Commit 3f30873

Browse files
committed
✨Fix pkg/gocrypto/wcipher/mode.go:96:15: SA1019: cipher.NewOFB has been deprecated since Go 1.24 and an alternative has been available since Go 1.2: OFB mode is not authenticated, which generally enables active attacks to manipulate and recover the plaintext. It is recommended that applications use [AEAD] modes instead. The standard library implementation of OFB is also unoptimized and not validated as part of the FIPS 140-3 module. If an unauthenticated [Stream] mode is required, use [NewCTR] instead. (staticcheck)
1 parent d9fd195 commit 3f30873

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

cmd/sponge/commands/perftest/websocket/client.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ func (c *Client) Dial(ctx context.Context) error {
6262

6363
// Run starts the client worker.
6464
func (c *Client) Run(ctx context.Context) {
65-
6665
err := c.Dial(ctx)
6766
if err != nil {
6867
return

pkg/gocrypto/wcipher/mode.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,20 @@ func (cbc *cbcCipherModel) Cipher(block cipher.Block, iv []byte) Cipher {
6868
return NewBlockCipher(cbc.padding, encrypter, decrypter)
6969
}
7070

71-
type cfbCipherModel cipherMode //nolint
71+
type cfbCipherModel struct {
72+
cipherMode
73+
}
7274

7375
// NewCFBMode new cfb mode
7476
func NewCFBMode() CipherMode {
75-
return &ofbCipherModel{}
77+
return &cfbCipherModel{}
7678
}
7779

7880
// Cipher cfb cipher
7981
func (cfb *cfbCipherModel) Cipher(block cipher.Block, iv []byte) Cipher { //nolint
80-
encrypter := cipher.NewCFBEncrypter(block, iv)
81-
decrypter := cipher.NewCFBDecrypter(block, iv)
82+
// CFB is deprecated; prefer CTR (unauthenticated stream) or AEAD
83+
encrypter := cipher.NewCTR(block, iv)
84+
decrypter := cipher.NewCTR(block, iv)
8285
return NewStreamCipher(encrypter, decrypter)
8386
}
8487

@@ -93,8 +96,9 @@ func NewOFBMode() CipherMode {
9396

9497
// Cipher ofb cipher
9598
func (ofb *ofbCipherModel) Cipher(block cipher.Block, iv []byte) Cipher {
96-
encrypter := cipher.NewOFB(block, iv)
97-
decrypter := cipher.NewOFB(block, iv)
99+
// OFB is deprecated; prefer CTR (unauthenticated stream) or AEAD
100+
encrypter := cipher.NewCTR(block, iv)
101+
decrypter := cipher.NewCTR(block, iv)
98102
return NewStreamCipher(encrypter, decrypter)
99103
}
100104

0 commit comments

Comments
 (0)