1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
/*
*
* Copyright (C) 2017 GlobalLogic
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_OPTEE_PARSEL_H
#define ANDROID_OPTEE_PARSEL_H
#include <tee_internal_api.h>
#include <tee_internal_api_extensions.h>
#include <utee_defines.h>
#include "common.h"
#include "ta_ca_defs.h"
#define MAX_OCTET_COUNT 10
#define ADDITIONAL_TAGS 6 /*
* Number of tags that can be added
* (KM_TAG_ORIGIN, KM_TAG_CREATION_DATETIME,
* KM_TAG_OS_VERSION, KM_TAG_OS_PATCHLEVEL,
* KM_TAG_KEY_SIZE,
* KM_TAG_RSA_PUBLIC_EXPONENT)
*/
bool TA_is_out_of_bounds(uint8_t *in, uint8_t *in_end, size_t size);
/* Serializers */
int TA_serialize_rsp_err(uint8_t *out, const keymaster_error_t *error);
int TA_serialize_blob_akms(uint8_t *out, const keymaster_blob_t *blob);
int TA_serialize_characteristics(uint8_t *out,
const keymaster_key_characteristics_t *characteristics);
int TA_serialize_characteristics_akms(uint8_t *out,
const keymaster_key_characteristics_t *characteristics);
int TA_serialize_key_blob_akms(uint8_t *out, const keymaster_key_blob_t *key_blob);
int TA_serialize_cert_chain_akms(uint8_t *out,
const keymaster_cert_chain_t *cert_chain,
keymaster_error_t *res);
int TA_serialize_auth_set(uint8_t *out,
const keymaster_key_param_set_t *param_set);
int TA_serialize_param_set(uint8_t *out,
const keymaster_key_param_set_t *params);
TEE_Result TA_serialize_rsa_keypair(uint8_t *out,
uint32_t *out_size,
const TEE_ObjectHandle key_obj);
TEE_Result TA_serialize_ec_keypair(uint8_t *out,
uint32_t *out_size,
const TEE_ObjectHandle key_obj);
/* Deserializers */
int TA_deserialize_blob_akms(uint8_t *in, uint8_t *end,
keymaster_blob_t *blob_t,
const bool check_presence, keymaster_error_t *res,
bool is_input);
int TA_deserialize_auth_set(uint8_t *in, uint8_t *end,
keymaster_key_param_set_t *param_set,
const bool check_presence, keymaster_error_t *res);
int TA_deserialize_param_set(uint8_t *in, uint8_t *end,
keymaster_key_param_set_t *params_t,
const bool check_presence, keymaster_error_t *res);
int TA_deserialize_key_blob_akms(uint8_t *in, uint8_t *end,
keymaster_key_blob_t *key_blob,
keymaster_error_t *res);
int TA_deserialize_op_handle(uint8_t *in, uint8_t *in_end,
keymaster_operation_handle_t *op_handle,
keymaster_error_t *res);
int TA_deserialize_purpose(uint8_t *in, uint8_t *in_end,
keymaster_purpose_t *purpose, keymaster_error_t *res);
int TA_deserialize_key_format(uint8_t *in, uint8_t *in_end,
keymaster_key_format_t *key_format,
keymaster_error_t *res);
#endif/* ANDROID_OPTEE_PARSEL_H */
|