summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUtkarsh Sanghi <usanghi@google.com>2015-10-14 11:09:31 -0700
committerUtkarsh Sanghi <usanghi@google.com>2015-10-15 17:48:33 +0000
commit5499a0e04e12b6280d826a2ca91e99227aa0ba05 (patch)
treea650d7db4876aad34bcb59a9c32f5bd3dba64f67
parent343cb530db4edbc0f09718af0a96ddb6c5430b18 (diff)
downloadtpm-5499a0e04e12b6280d826a2ca91e99227aa0ba05.tar.gz
trunks: Add ptr() method to ScopedKeyHandle
This method allows us to directly access the handle in the ScopedKeyHandle object, so that we can use it in methods like LoadKey Sample code looks like this: ScopedKeyHandle key(factory); LoadKey(key_blob, key.ptr(), ...); Encrypt(key.value()); This makes code for trunks clients a little simpler, since the ScopedKeyHandle can be declared before the Load operation as opposed the old operation which declared a TPM_HANDLE* and then wrapped it in a ScopedKeyHandle. BUG=None TEST=features=TEST emerge-rambi trunks Change-Id: I0849852aa26cea08ead1e1d7ab4dc6d500c8ccba
-rw-r--r--scoped_key_handle.cc4
-rw-r--r--scoped_key_handle.h6
2 files changed, 9 insertions, 1 deletions
diff --git a/scoped_key_handle.cc b/scoped_key_handle.cc
index ab66c15..e8b4800 100644
--- a/scoped_key_handle.cc
+++ b/scoped_key_handle.cc
@@ -61,6 +61,10 @@ void ScopedKeyHandle::reset() {
reset(kInvalidHandle);
}
+TPM_HANDLE* ScopedKeyHandle::ptr() {
+ return &handle_;
+}
+
TPM_HANDLE ScopedKeyHandle::get() const {
return handle_;
}
diff --git a/scoped_key_handle.h b/scoped_key_handle.h
index aa0a4bd..ddd38cc 100644
--- a/scoped_key_handle.h
+++ b/scoped_key_handle.h
@@ -49,8 +49,12 @@ class TRUNKS_EXPORT ScopedKeyHandle {
// is injected.
virtual void reset();
+ // This method returns a pointer to the handle associated with this class.
+ // This method does not transfer ownership.
+ virtual TPM_HANDLE* ptr();
+
// This method returns the handle currectly associated with the class.
- // This method does not transfew ownership, therefore the handle returned
+ // This method does not transfer ownership, therefore the handle returned
// might be stale.
virtual TPM_HANDLE get() const;