Home | History | Annotate | Download | only in keystore

Lines Matching refs:Tag

25  * authorizations.  For example, it's an error to create a KeyParameter with tag == Tag::PURPOSE
31 * to which Tag. Central to this mechanism is the template TypedTag. It has zero size and binds a
32 * numeric Tag to a type that the compiler understands. By means of the macro DECLARE_TYPED_TAG,
36 * TAG_name. Once these typed tags have been declared we define metafunctions mapping the each tag
39 * a typed tag to the corresponding c++ type, and access function, accessTagValue returning a
47 * Authorization takes a typed tag and a value and checks at compile time whether the value given
48 * is suitable for the given tag. At runtime it creates a new KeyParameter initialized with the
49 * given tag and value and returns it by value.
52 * a safe way. It takes a typed tag and a KeyParameter and returns a reference to the value wrapped
84 using ::android::hardware::keymaster::V3_0::Tag;
95 constexpr TagType typeFromTag(Tag tag) {
96 return static_cast<TagType>(static_cast<uint32_t>(tag) & static_cast<uint32_t>(0xf0000000));
100 * TypedTag is a templatized version of Tag, which provides compile-time checking of
101 * keymaster tag types. Instances are convertible to Tag, so they can be used wherever
102 * Tag is expected, and because they encode the tag type it's possible to create
105 template <TagType tag_type, Tag tag> struct TypedTag {
107 // Ensure that it's impossible to create a TypedTag instance whose 'tag' doesn't have type
108 // 'tag_type'. Attempting to instantiate a tag with the wrong type will result in a compile
110 static_assert(typeFromTag(tag) == tag_type, "mismatch between tag and tag_type");
112 operator Tag() const { return tag; }
115 template <Tag tag> struct Tag2TypedTag { typedef TypedTag<typeFromTag(tag), tag> type; };
117 template <Tag tag> struct Tag2String;
123 typedef typename Tag2TypedTag<Tag::name>::type TAG_##name##_t; \
125 template <> struct Tag2String<Tag::name> { \
126 static const char* value() { return "Tag::" TAGS_STRINGIFY(name); } \
192 extern const char* stringifyTag(Tag tag);
197 template <Tag tag> struct TypedTag2ValueType<TypedTag<tag_type, tag>> { \
200 template <Tag tag> \
201 inline auto accessTagValue(TypedTag<tag_type, tag>, const KeyParameter& param) \
205 template <Tag tag> \
206 inline auto accessTagValue(TypedTag<tag_type, tag>, KeyParameter& param) \
244 template <TagType tag_type, Tag tag, typename ValueT>
245 inline KeyParameter makeKeyParameter(TypedTag<tag_type, tag> ttag, ValueT&& value) {
247 param.tag = tag;
254 template <Tag tag> inline KeyParameter makeKeyParameter(TypedTag<TagType::BOOL, tag>) {
256 param.tag = tag;
269 template <TagType tag_type, Tag tag, typename... Args>
270 inline KeyParameter Authorization(TypedTag<tag_type, tag> ttag, Args&&... args) {
278 typename TypedTag2ValueType<TypedTag<tag_type, tag>>::type>::value,
279 "Invalid argument type for given tag.");
342 template <TagType tag_type, Tag tag>
343 inline NullOr<const typename TypedTag2ValueType<TypedTag<tag_type, tag>>::type&>
344 authorizationValue(TypedTag<tag_type, tag> ttag, const KeyParameter& param) {
345 if (tag != param.tag) return {};