summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ubifs-utils/mkfs.ubifs/crypto.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/ubifs-utils/mkfs.ubifs/crypto.c b/ubifs-utils/mkfs.ubifs/crypto.c
index cd68e37..d31bd2a 100644
--- a/ubifs-utils/mkfs.ubifs/crypto.c
+++ b/ubifs-utils/mkfs.ubifs/crypto.c
@@ -109,7 +109,7 @@ fail:
return -1;
}
-static size_t gen_essiv_salt(const void *iv, size_t iv_len, const void *key, size_t key_len, void *salt)
+static ssize_t gen_essiv_salt(const void *iv, size_t iv_len, const void *key, size_t key_len, void *salt)
{
size_t ret;
const EVP_CIPHER *cipher;
@@ -127,8 +127,10 @@ static size_t gen_essiv_salt(const void *iv, size_t iv_len, const void *key, siz
}
ret = do_encrypt(cipher, iv, iv_len, sha256, EVP_MD_size(EVP_sha256()), NULL, 0, salt);
- if (ret != iv_len)
+ if (ret != iv_len) {
errmsg("Unable to compute ESSIV salt, return value %zi instead of %zi", ret, iv_len);
+ return -1;
+ }
free(sha256);
@@ -154,7 +156,8 @@ static ssize_t encrypt_block(const void *plaintext, size_t size,
if (cipher == EVP_aes_128_cbc()) {
tweak = alloca(ivsize);
- gen_essiv_salt(&iv, FS_IV_SIZE, key, key_len, tweak);
+ if (gen_essiv_salt(&iv, FS_IV_SIZE, key, key_len, tweak) < 0)
+ return -1;
} else {
tweak = &iv;
}