add mutex for thread-safe XORKeyStream in CFB8

This commit is contained in:
adman
2026-05-11 23:27:14 +02:00
parent 021b8ddc1a
commit 2fb290572a
2 changed files with 6 additions and 0 deletions
+4
View File
@@ -28,6 +28,7 @@ package crypto
import (
"crypto/cipher"
"crypto/subtle"
"sync"
"unsafe"
)
@@ -37,6 +38,7 @@ type CFB8 struct {
ivPos int
iv []byte
de bool
mutex sync.Mutex
}
func NewCFB8Decrypt(c cipher.Block, iv []byte) *CFB8 {
@@ -59,6 +61,8 @@ func newCFB8(c cipher.Block, iv []byte, de bool) *CFB8 {
}
func (cf *CFB8) XORKeyStream(dst, src []byte) {
cf.mutex.Lock()
defer cf.mutex.Unlock()
if len(src) == 0 {
return
}