diff options
author | Shawn Willden <swillden@google.com> | 2016-01-08 05:00:26 -0700 |
---|---|---|
committer | Shawn Willden <swillden@google.com> | 2016-01-26 14:15:46 -0700 |
commit | 78c5d8796c560deb2a0194f581f13a833437f012 (patch) | |
tree | 2900eb803b7002e684036a2ee8336ceb1d3b5870 /android_keymaster_test_utils.cpp | |
parent | f21afff128ac22479c49bdda84f13335ae17d009 (diff) | |
download | keymaster-78c5d8796c560deb2a0194f581f13a833437f012.tar.gz |
Refactor keymaster tags.
This refactor separates declaration and definition of the tag
instances, so they don't get duplicated in every compilation unit.
Also, if tag names are enabled it provides a dynamically-generated map
from tags to names. This is only for testing/debugging use, but it's
very convenient for that. The test utils are updated to take advantage
of it.
Change-Id: I13ad2564e4a850c6b268a2cd1b3f5a37037ea6b7
Diffstat (limited to 'android_keymaster_test_utils.cpp')
-rw-r--r-- | android_keymaster_test_utils.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/android_keymaster_test_utils.cpp b/android_keymaster_test_utils.cpp index 4e318de..f62dd66 100644 --- a/android_keymaster_test_utils.cpp +++ b/android_keymaster_test_utils.cpp @@ -30,8 +30,12 @@ using std::ostream; using std::string; using std::vector; +#ifndef KEYMASTER_NAME_TAGS +#error Keymaster test code requires that KEYMASTER_NAME_TAGS is defined +#endif + std::ostream& operator<<(std::ostream& os, const keymaster_key_param_t& param) { - os << "Tag: " << keymaster_tag_mask_type(param.tag); + os << "Tag: " << keymaster::StringifyTag(param.tag); switch (keymaster_tag_get_type(param.tag)) { case KM_INVALID: os << " Invalid"; @@ -157,11 +161,8 @@ std::ostream& operator<<(std::ostream& os, const AuthorizationSet& set) { os << "(Empty)" << std::endl; else { os << "\n"; - for (size_t i = 0; i < set.size(); ++i) { - os << set[i]; - if (i < set.size() - 1) - os << std::endl; - } + for (size_t i = 0; i < set.size(); ++i) + os << set[i] << std::endl; } return os; } |