11 #ifndef __ATTEST_TOKEN_DECODE_H__
12 #define __ATTEST_TOKEN_DECODE_H__
14 #include "q_useful_buf.h"
155 struct q_useful_buf cose_pub_key);
218 struct q_useful_buf_c token);
250 struct q_useful_buf_c *payload);
293 #define IS_ITEM_FLAG_SET(item_index, item_flags) \
294 (((0x01U << (item_index))) & (item_flags))
336 struct q_useful_buf_c *nonce);
351 struct q_useful_buf_c *boot_seed);
366 struct q_useful_buf_c *ueid);
386 struct q_useful_buf_c *hw_version);
402 struct q_useful_buf_c *implementation_id);
420 struct q_useful_buf_c *origination);
436 attest_token_decode_get_profile_definition(
438 struct q_useful_buf_c *profile_definition);
473 attest_token_decode_get_security_lifecycle(
475 uint32_t *lifecycle);
535 uint32_t *num_sw_components);
555 uint32_t requested_index,
590 struct q_useful_buf_c *claim);
625 struct q_useful_buf_c *claim);
728 struct q_useful_buf_c *nonce)
738 struct q_useful_buf_c *ueid)
746 struct q_useful_buf_c *boot_seed)
756 struct q_useful_buf_c *hw_version)
765 attest_token_decode_get_implementation_id(
767 struct q_useful_buf_c*implementation_id)
780 int64_t caller_id_64;
788 if(caller_id_64 > INT32_MAX || caller_id_64 < INT32_MIN) {
792 *caller_id = (int32_t)caller_id_64;
800 attest_token_decode_get_security_lifecycle(
802 uint32_t *security_lifecycle)
805 uint64_t security_lifecycle_64;
809 &security_lifecycle_64);
810 if(security_lifecycle_64 > UINT32_MAX) {
815 *security_lifecycle = (uint32_t)security_lifecycle_64;
822 attest_token_decode_get_profile_definition(
824 struct q_useful_buf_c *profile_definition)
833 struct q_useful_buf_c *origination)
849 map_t_cose_errors(
enum t_cose_err_t t_cose_error)
851 switch (t_cose_error) {
855 case T_COSE_ERR_UNSUPPORTED_SIGNING_ALG:
858 case T_COSE_ERR_UNSUPPORTED_HASH:
861 case T_COSE_ERR_CBOR_NOT_WELL_FORMED:
864 case T_COSE_ERR_INSUFFICIENT_MEMORY:
867 case T_COSE_ERR_TAMPERING_DETECTED:
870 case T_COSE_ERR_CBOR_FORMATTING:
873 case T_COSE_ERR_TOO_SMALL:
877 case T_COSE_ERR_PARAMETER_CBOR:
878 case T_COSE_ERR_NON_INTEGER_ALG_ID:
882 case T_COSE_ERR_SIG_VERIFY:
883 case T_COSE_ERR_SHORT_CIRCUIT_SIG:
887 case T_COSE_ERR_SIGN1_FORMAT:
891 case T_COSE_ERR_MAC0_FORMAT:
895 case T_COSE_ERR_NO_ALG_ID:
896 case T_COSE_ERR_NO_KID:
897 case T_COSE_ERR_BAD_SHORT_CIRCUIT_KID:
898 case T_COSE_ERR_SIG_STRUCT:
902 case T_COSE_ERR_UNKNOWN_KEY:
903 case T_COSE_ERR_WRONG_TYPE_OF_KEY:
907 case T_COSE_ERR_MAKING_PROTECTED:
908 case T_COSE_ERR_HASH_GENERAL_FAIL:
909 case T_COSE_ERR_HASH_BUFFER_SIZE:
910 case T_COSE_ERR_SIG_BUFFER_SIZE:
911 case T_COSE_ERR_INVALID_ARGUMENT:
912 case T_COSE_ERR_FAIL:
913 case T_COSE_ERR_SIG_FAIL:
914 case T_COSE_ERR_TOO_MANY_PARAMETERS:
915 case T_COSE_ERR_UNKNOWN_CRITICAL_PARAMETER:
916 case T_COSE_ERR_SHORT_CIRCUIT_SIG_DISABLED:
917 case T_COSE_ERR_INCORRECT_KEY_FOR_LIB:
918 case T_COSE_ERR_BAD_CONTENT_TYPE:
919 case T_COSE_ERR_INCORRECTLY_TAGGED:
920 case T_COSE_ERR_EMPTY_KEY:
921 case T_COSE_ERR_DUPLICATE_PARAMETER:
922 case T_COSE_ERR_PARAMETER_NOT_PROTECTED:
923 case T_COSE_ERR_CRIT_PARAMETER:
enum attest_token_err_t last_error
struct q_useful_buf_c implementation_id
uint32_t security_lifecycle
enum attest_token_err_t attest_token_decode_get_payload(struct attest_token_decode_context *me, struct q_useful_buf_c *payload)
Get undecoded CBOR payload from the token.
#define EAT_CBOR_ARM_LABEL_SECURITY_LIFECYCLE
enum attest_token_err_t attest_token_decode_get_bstr(struct attest_token_decode_context *me, int32_t label, struct q_useful_buf_c *claim)
Get a top-level claim, by integer label that is a byte string.
enum attest_token_err_t attest_token_get_sw_component(struct attest_token_decode_context *me, uint32_t requested_index, struct attest_token_sw_component_t *sw_components)
Get the nth SW component.
Attestation Token Creation Interface.
enum attest_token_err_t attest_token_get_num_sw_components(struct attest_token_decode_context *me, uint32_t *num_sw_components)
Get the number of SW components in the token.
enum attest_token_err_t attest_token_decode_get_int(struct attest_token_decode_context *me, int32_t label, int64_t *claim)
Get a top-level claim by integer label who's value is a signed integer.
struct q_useful_buf_c measurement_type
struct q_useful_buf_c version
void attest_token_decode_init(struct attest_token_decode_context *me, uint32_t options)
Initialize token decoder.
enum attest_token_err_t attest_token_decode_get_tstr(struct attest_token_decode_context *me, int32_t label, struct q_useful_buf_c *claim)
Get a top-level claim, by integer label that is a text string.
#define EAT_CBOR_ARM_LABEL_UEID
struct q_useful_buf_c hw_version
struct q_useful_buf_c origination
#define EAT_CBOR_ARM_LABEL_CLIENT_ID
enum attest_token_err_t attest_token_decode_validate_token(struct attest_token_decode_context *me, struct q_useful_buf_c token)
Set the token to work on and validate its signature.
#define EAT_CBOR_ARM_LABEL_ORIGINATION
enum attest_token_err_t attest_token_decode_set_pub_key_select(struct attest_token_decode_context *me, int32_t key_select)
Set specific public key to use for verification.
attest_token_item_index_t
#define EAT_CBOR_ARM_LABEL_IMPLEMENTATION_ID
struct q_useful_buf_c signer_id
enum attest_token_err_t attest_token_decode_set_cose_pub_key(struct attest_token_decode_context *me, struct q_useful_buf cose_pub_key)
Set specific public key to use for verification.
struct q_useful_buf_c measurement_val
struct q_useful_buf_c nonce
struct q_useful_buf_c payload
struct q_useful_buf_c ueid
enum attest_token_err_t attest_token_decode_get_iat_simple(struct attest_token_decode_context *me, struct attest_token_iat_simple_t *items)
Batch fetch of all simple data items in a token.
struct q_useful_buf_c boot_seed
#define EAT_CBOR_ARM_LABEL_PROFILE_DEFINITION
struct q_useful_buf_c measurement_desc
enum attest_token_err_t attest_token_decode_get_uint(struct attest_token_decode_context *me, int32_t label, uint64_t *claim)
Get a top-level claim by integer label who's value is an unsigned integer.
#define EAT_CBOR_ARM_LABEL_HW_VERSION
#define EAT_CBOR_ARM_LABEL_CHALLENGE
struct q_useful_buf_c profile_definition
#define EAT_CBOR_ARM_LABEL_BOOT_SEED