Open
Description
The code to generate an OpenSSH-compatible encrypted private key might go something like:
k, err := BcryptPbkdfKey([]byte(passPhrase), []byte(opts.Salt), int(opts.Rounds), 32+16)
if err != nil {
return err
}
key, iv := k[:32], k[32:]
c, err := aes.NewCipher(key)
if err != nil {
return err
}
ctr := cipher.NewCTR(c, iv)
Where BcryptPbkdfKey is effectively golang.org/x/crypto/ssh/internal/bcrypt_pbkdf. This code generates the following warning:
G407 (CWE-1204): Use of hardcoded IV/nonce for encryption by passing hardcoded slice/array (Confidence: HIGH, Severity: HIGH)
Probably because of the assignment from k
?