summaryrefslogtreecommitdiffstats
path: root/cmds
diff options
context:
space:
mode:
authorChia-chi Yeh <chiachi@android.com>2009-12-30 10:38:39 +0800
committerChia-chi Yeh <chiachi@android.com>2009-12-30 10:38:39 +0800
commit5fe8598f755bdfd15e96bb2ddcdbe9a41b8173a7 (patch)
tree068d29f2544fefc83fac083d6bb1579436f10b14 /cmds
parent121ec7ff33b05227cf704ff1ff6313a38897cca7 (diff)
downloadframeworks_base-5fe8598f755bdfd15e96bb2ddcdbe9a41b8173a7.zip
frameworks_base-5fe8598f755bdfd15e96bb2ddcdbe9a41b8173a7.tar.gz
frameworks_base-5fe8598f755bdfd15e96bb2ddcdbe9a41b8173a7.tar.bz2
keystore: compute the padding in an intuitive way.
Diffstat (limited to 'cmds')
-rw-r--r--cmds/keystore/keystore.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/cmds/keystore/keystore.c b/cmds/keystore/keystore.c
index 37155e4..4426874 100644
--- a/cmds/keystore/keystore.c
+++ b/cmds/keystore/keystore.c
@@ -170,16 +170,12 @@ static int8_t encrypt_blob(char *name, AES_KEY *aes_key)
return SYSTEM_ERROR;
}
- length = (blob.length + blob.value - blob.encrypted) % AES_BLOCK_SIZE;
- if (length) {
- length = AES_BLOCK_SIZE - length;
- }
+ length = blob.length + blob.value - blob.encrypted;
+ length = (length + AES_BLOCK_SIZE - 1) / AES_BLOCK_SIZE * AES_BLOCK_SIZE;
- length += blob.length + blob.value - blob.digested;
blob.length = htonl(blob.length);
- MD5(blob.digested, length, blob.digest);
+ MD5(blob.digested, length - (blob.digested - blob.encrypted), blob.digest);
- length += blob.digested - blob.encrypted;
memcpy(vector, blob.vector, AES_BLOCK_SIZE);
AES_cbc_encrypt(blob.encrypted, blob.encrypted, length, aes_key, vector,
AES_ENCRYPT);