summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2010-10-13 15:00:07 -0700
committerAlex Ray <aray@google.com>2013-07-30 13:56:55 -0700
commit60cbc840393ccd98efd9963013bc61f2621d95ab (patch)
tree239f010426a39b8152836e3dedb007501cab931a /include
parentfcefac26820933abeb40170b476b9d04efa3d35d (diff)
downloadsystem_core-60cbc840393ccd98efd9963013bc61f2621d95ab.zip
system_core-60cbc840393ccd98efd9963013bc61f2621d95ab.tar.gz
system_core-60cbc840393ccd98efd9963013bc61f2621d95ab.tar.bz2
OBB: use PBKDF2 for key generation.
Switch to using PBKDF2 for the key generation for OBBs. Any previously generated OBBs will stop being read correctly. A small pbkdf2gen program is available to allow generation of appropriate keys with the salts. Bug: 3059950 Change-Id: If4305c989fd692fd1150eb270dbf751e09c37295
Diffstat (limited to 'include')
-rw-r--r--include/utils/ObbFile.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/include/utils/ObbFile.h b/include/utils/ObbFile.h
index 5243f50..47559cd 100644
--- a/include/utils/ObbFile.h
+++ b/include/utils/ObbFile.h
@@ -27,6 +27,7 @@ namespace android {
// OBB flags (bit 0)
#define OBB_OVERLAY (1 << 0)
+#define OBB_SALTED (1 << 1)
class ObbFile : public RefBase {
protected:
@@ -70,6 +71,26 @@ public:
mFlags = flags;
}
+ const unsigned char* getSalt(size_t* length) const {
+ if ((mFlags & OBB_SALTED) == 0) {
+ *length = 0;
+ return NULL;
+ }
+
+ *length = sizeof(mSalt);
+ return mSalt;
+ }
+
+ bool setSalt(const unsigned char* salt, size_t length) {
+ if (length != sizeof(mSalt)) {
+ return false;
+ }
+
+ memcpy(mSalt, salt, sizeof(mSalt));
+ mFlags |= OBB_SALTED;
+ return true;
+ }
+
bool isOverlay() {
return (mFlags & OBB_OVERLAY) == OBB_OVERLAY;
}
@@ -103,6 +124,12 @@ private:
/* Flags for this OBB type. */
int32_t mFlags;
+ /* Whether the file is salted. */
+ bool mSalted;
+
+ /* The encryption salt. */
+ unsigned char mSalt[8];
+
const char* mFileName;
size_t mFileSize;