Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The issue of Initialization Vector (IV) initialization. #144

Open
sy2339226 opened this issue Jun 12, 2024 · 0 comments
Open

The issue of Initialization Vector (IV) initialization. #144

sy2339226 opened this issue Jun 12, 2024 · 0 comments

Comments

@sy2339226
Copy link

In the getIvParam function, if the key is shorter, there may be an issue where the IV (initialization vector) is initialized as a constant. If the IV is initialized as a constant during the CBC encryption process, it can lead to identical plaintext blocks being encrypted into identical ciphertext blocks, thereby increasing the risk of chosen plaintext attacks and potentially causing the leakage of ciphertext information.

Furthermore, MD5 is a relatively outdated algorithm, and we recommend replacing it with more advanced algorithms such as SHA3 or SHA256.

"FuncName": "crypto/md5.New",
"SourceFilename": "github.com/Klevry/klevr/pkg/common/md5.go",
"SourceLineNum": 9,


"FuncName": "crypto/cipher.NewCBCEncrypter",
"SourceCode": "ecb := cipher.NewCBCEncrypter(block, getIvParam(key))",
"SourceFilename": "github.com/Klevry/klevr/pkg/common/encrypt.go",
"SourceLineNum": 32,

    "SourceCode": "func getIvParam(key string) []byte {
                            var param []byte = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
                        
                            b := []byte(key)
                            len := len(b)
                        
                            for i := 0; i < 16 && i < len; i++ {
	                            param[i] = b[i]
                            }
                        
                            return param
                        }",
    "SourceFilename": "github.com/Klevry/klevr/pkg/common/encrypt.go",
    "SourceLineNum": 169
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant