Introduce of key dump functions
* Bring from system/libhidl/base/include/hidl/HidlSupport.h
* Arranged for A12 keymaster key
TEST: Tested on scorpion_windy, Android 12 ROM.
Signed-off-by: koron393 <koron393@gmail.com>
Change-Id: I0ed0a7a283fc29e92c14d5e7457d4879168901fd
diff --git a/crypto/ext4crypt/Keymaster3.h b/crypto/ext4crypt/Keymaster3.h
index cb5b644..0eb4bbb 100644
--- a/crypto/ext4crypt/Keymaster3.h
+++ b/crypto/ext4crypt/Keymaster3.h
@@ -111,6 +111,34 @@
DISALLOW_COPY_AND_ASSIGN(Keymaster);
};
+namespace dump {
+
+template<typename T>
+std::string toHexString(T t, bool prefix = true) {
+ std::ostringstream os;
+ if (prefix) { os << std::showbase; }
+ os << std::hex << t;
+ return os.str();
+}
+
+template<typename Array>
+std::string arrayToHexString(const Array &a, size_t size) {
+ using android::hardware::toString;
+ std::string os;
+ for (size_t i = 0; i < size; ++i) {
+ os += toHexString(a[i]);
+ }
+ return os;
+}
+
+template<typename T>
+std::string toString(const hardware::hidl_vec<T> &a) {
+ std::string os;
+ os += arrayToHexString(a, a.size());
+ return os;
+}
+
+} // namespace dump
} // namespace vold
} // namespace android