Lines Matching defs:tag

25  * example, it's an error to create a keymaster_param_t with tag == KM_TAG_PURPOSE and then to
32 * TypedTag and TypedEnumTag. These classes are templated on a tag type and a tag value, and in the
34 * keymaster tag, associating the tag type with the tag, and an instance of each specialization is
35 * created, and named the same as the keymaster tag, but with the KM_ prefix omitted. Because the
40 * particular tag. This enables template functions to be written that check that the correct
41 * parameter type is used for a given tag, and that use the correct union entry for the tag type. A
42 * very useful example is the overloaded "Authorization" function defined below, which takes tag and
69 // An unusable type that we can associate with tag types that don't have a simple value type.
77 * A template that defines the association between non-enumerated tag types and their value
78 * types. For each tag type we define a specialized struct that contains a typedef "value_type".
93 * keymaster tag types. Instances are convertible to keymaster_tag_t, so they can be used wherever
94 * keymaster_tag_t is expected, and because they encode the tag type it's possible to create
97 template <keymaster_tag_type_t tag_type, keymaster_tag_t tag> class TypedTag {
102 // Ensure that it's impossible to create a TypedTag instance whose 'tag' doesn't have type
103 // 'tag_type'. Attempting to instantiate a tag with the wrong type will result in a compile
105 StaticAssert<(tag & tag_type) == tag_type>::check();
108 inline operator keymaster_tag_t() { return tag; }
109 inline long masked_tag() { return static_cast<long>(keymaster_tag_mask_type(tag)); }
112 template <keymaster_tag_type_t tag_type, keymaster_tag_t tag, typename KeymasterEnum>
118 // Ensure that it's impossible to create a TypedTag instance whose 'tag' doesn't have type
119 // 'tag_type'. Attempting to instantiate a tag with the wrong type will result in a compile
121 StaticAssert<(tag & tag_type) == tag_type>::check();
124 inline operator keymaster_tag_t() { return tag; }
125 inline long masked_tag() { return static_cast<long>(keymaster_tag_mask_type(tag)); }
129 const char* StringifyTag(keymaster_tag_t tag);
132 // DECLARE_KEYMASTER_TAG is used to declare TypedTag instances for each non-enum keymaster tag.
179 // DECLARE_KEYMASTER_ENUM_TAG is used to declare TypedEnumTag instances for each enum keymaster tag.
202 inline keymaster_key_param_t Authorization(TypedTag<KM_BOOL, Tag> tag) {
203 return keymaster_param_bool(tag);
207 inline keymaster_key_param_t Authorization(TypedTag<KM_UINT, Tag> tag, uint32_t value) {
208 return keymaster_param_int(tag, value);
212 inline keymaster_key_param_t Authorization(TypedTag<KM_UINT_REP, Tag> tag, uint32_t value) {
213 return keymaster_param_int(tag, value);
217 inline keymaster_key_param_t Authorization(TypedTag<KM_ULONG, Tag> tag, uint64_t value) {
218 return keymaster_param_long(tag, value);
222 inline keymaster_key_param_t Authorization(TypedTag<KM_ULONG_REP, Tag> tag, uint64_t value) {
223 return keymaster_param_long(tag, value);
227 inline keymaster_key_param_t Authorization(TypedTag<KM_DATE, Tag> tag, uint64_t value) {
228 return keymaster_param_date(tag, value);
232 inline keymaster_key_param_t Authorization(TypedTag<KM_BYTES, Tag> tag, const void* bytes,
234 return keymaster_param_blob(tag, reinterpret_cast<const uint8_t*>(bytes), bytes_len);
238 inline keymaster_key_param_t Authorization(TypedTag<KM_BYTES, Tag> tag,
240 return keymaster_param_blob(tag, blob.data, blob.data_length);
244 inline keymaster_key_param_t Authorization(TypedTag<KM_BIGNUM, Tag> tag, const void* bytes,
246 return keymaster_param_blob(tag, reinterpret_cast<const uint8_t*>(bytes), bytes_len);
250 inline keymaster_key_param_t Authorization(TypedTag<KM_BIGNUM, Tag> tag,
252 return keymaster_param_blob(tag, blob.data, blob.data_length);
256 inline keymaster_key_param_t Authorization(TypedEnumTag<KM_ENUM, Tag, KeymasterEnum> tag,
258 return keymaster_param_enum(tag, value);
262 inline keymaster_key_param_t Authorization(TypedEnumTag<KM_ENUM_REP, Tag, KeymasterEnum> tag,
264 return keymaster_param_enum(tag, value);