accounts: left pad keybytes-to-encrypt, add 30/31 byte keys tests

This commit is contained in:
Gustav Simonsson
2016-09-23 15:42:29 -04:00
parent 863d166c7b
commit 7cc6b801e0
3 changed files with 62 additions and 1 deletions

View File

@@ -107,7 +107,8 @@ func EncryptKey(key *Key, auth string, scryptN, scryptP int) ([]byte, error) {
return nil, err
}
encryptKey := derivedKey[:16]
keyBytes := crypto.FromECDSA(key.PrivateKey)
keyBytes0 := crypto.FromECDSA(key.PrivateKey)
keyBytes := common.LeftPadBytes(keyBytes0, 32)
iv := randentropy.GetEntropyCSPRNG(aes.BlockSize) // 16
cipherText, err := aesCTRXOR(encryptKey, keyBytes, iv)