Check iv length for decryption

This commit is contained in:
Zed 2020-05-27 16:05:32 +02:00 committed by zah
parent fd5478d550
commit c570abf602
1 changed files with 3 additions and 0 deletions

View File

@ -136,6 +136,9 @@ proc decryptKeystore*(data, passphrase: string): KsResult[seq[byte]] =
if decKey.len < saltSize:
return err "ks: decryption key must be at least 32 bytes"
if iv.len < aes128.sizeBlock:
return err "ks: invalid iv"
let sum = shaChecksum(decKey.toOpenArray(16, 31), cipherMsg)
if sum != checksumMsg:
return err "ks: invalid checksum"