Skip to content

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

Description

@sy2339226

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions