Refine must2 and apply NewAesGcm() to all usage (#5011)

* Refine must2 and apply NewAesGcm() to all usage

* Remove unused package

* Fix test
This commit is contained in:
风扇滑翔翼
2025-08-11 09:37:46 +08:00
committed by GitHub
parent 0cceea75da
commit b1107b9810
12 changed files with 37 additions and 96 deletions

View File

@@ -1,15 +1,13 @@
package kcp
import (
"crypto/aes"
"crypto/cipher"
"crypto/sha256"
"github.com/xtls/xray-core/common"
"github.com/xtls/xray-core/common/crypto"
)
func NewAEADAESGCMBasedOnSeed(seed string) cipher.AEAD {
hashedSeed := sha256.Sum256([]byte(seed))
aesBlock := common.Must2(aes.NewCipher(hashedSeed[:16])).(cipher.Block)
return common.Must2(cipher.NewGCM(aesBlock)).(cipher.AEAD)
return crypto.NewAesGcm(hashedSeed[:])
}