summaryrefslogtreecommitdiff
authorMatthew Shyu <matthew.shyu@amlogic.com>2018-01-04 07:57:03 (GMT)
committer Matthew Shyu <matthew.shyu@amlogic.com>2018-01-04 08:05:42 (GMT)
commite206028bb2d1a2c9f472778e8429ca87e8ad3ac2 (patch)
tree9282eb84f69bae47639f2bf70cb715ae5bb8cd62
parent7e63b0a72b421dce25381136352cb593b91bb766 (diff)
downloadgatekeeper-o-amlogic.zip
gatekeeper-o-amlogic.tar.gz
gatekeeper-o-amlogic.tar.bz2
gatekeeper: fix
com.android.cts.devicepolicy.DeviceOwnerTest#testKeyManagement [1/2] PD# 158086 Soft gatekeeper should calculate valid hmac based on default key Signed-off-by: Matthew Shyu <matthew.shyu@amlogic.com> Change-Id: I5d796d611f2871c2d054122170e91b54c61f1b1d
Diffstat
-rw-r--r--soft/SoftGateKeeper.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/soft/SoftGateKeeper.h b/soft/SoftGateKeeper.h
index f646f70..ddd0cff 100644
--- a/soft/SoftGateKeeper.h
+++ b/soft/SoftGateKeeper.h
@@ -21,6 +21,7 @@
extern "C" {
#include <openssl/rand.h>
#include <openssl/sha.h>
+#include <openssl/hmac.h>
#include <crypto_scrypt.h>
}
@@ -32,6 +33,8 @@ extern "C" {
#include <unordered_map>
#include <memory>
+#define HMAC_SHA_256_KEY_SIZE 32
+
namespace gatekeeper {
struct fast_hash_t {
@@ -92,9 +95,15 @@ public:
}
virtual void ComputeSignature(uint8_t *signature, uint32_t signature_length,
- const uint8_t *, uint32_t, const uint8_t *, const uint32_t) const {
+ const uint8_t *key, uint32_t key_length, const uint8_t *message, const uint32_t length) const {
if (signature == NULL) return;
+ uint8_t buf[HMAC_SHA_256_KEY_SIZE];
+ size_t buf_len;
+ HMAC(EVP_sha256(), key, key_length, message, length, buf, (unsigned int *)&buf_len);
+ size_t to_write = buf_len;
+ if (buf_len > signature_length) to_write = signature_length;
memset(signature, 0, signature_length);
+ memcpy(signature, buf, to_write);
}
virtual uint64_t GetMillisecondsSinceBoot() const {