diff options
author | Mimi Zohar <zohar@linux.vnet.ibm.com> | 2011-09-20 11:23:55 -0400 |
---|---|---|
committer | Mimi Zohar <zohar@linux.vnet.ibm.com> | 2011-09-20 23:26:44 -0400 |
commit | 2b3ff6319e2312656fbefe0209bef02d58b6836a (patch) | |
tree | 43041b8a5e6fe31dadf2ad682d73fa873476b952 /security | |
parent | 2684bf7f29cfb13ef2c60f3b3a53ee47d0db7022 (diff) | |
download | kernel_goldelico_gta04-2b3ff6319e2312656fbefe0209bef02d58b6836a.zip kernel_goldelico_gta04-2b3ff6319e2312656fbefe0209bef02d58b6836a.tar.gz kernel_goldelico_gta04-2b3ff6319e2312656fbefe0209bef02d58b6836a.tar.bz2 |
encrypted-keys: check hex2bin result
For each hex2bin call in encrypted keys, check that the ascii hex string
is valid. On failure, return -EINVAL.
Changelog v1:
- hex2bin now returns an int
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Acked-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Diffstat (limited to 'security')
-rw-r--r-- | security/keys/encrypted-keys/encrypted.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/security/keys/encrypted-keys/encrypted.c b/security/keys/encrypted-keys/encrypted.c index 3f57795..f33804c 100644 --- a/security/keys/encrypted-keys/encrypted.c +++ b/security/keys/encrypted-keys/encrypted.c @@ -667,11 +667,19 @@ static int encrypted_key_decrypt(struct encrypted_key_payload *epayload, return -EINVAL; hex_encoded_data = hex_encoded_iv + (2 * ivsize) + 2; - hex2bin(epayload->iv, hex_encoded_iv, ivsize); - hex2bin(epayload->encrypted_data, hex_encoded_data, encrypted_datalen); + ret = hex2bin(epayload->iv, hex_encoded_iv, ivsize); + if (ret < 0) + return -EINVAL; + ret = hex2bin(epayload->encrypted_data, hex_encoded_data, + encrypted_datalen); + if (ret < 0) + return -EINVAL; hmac = epayload->format + epayload->datablob_len; - hex2bin(hmac, hex_encoded_data + (encrypted_datalen * 2), HASH_SIZE); + ret = hex2bin(hmac, hex_encoded_data + (encrypted_datalen * 2), + HASH_SIZE); + if (ret < 0) + return -EINVAL; mkey = request_master_key(epayload, &master_key, &master_keylen); if (IS_ERR(mkey)) |