1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /******************************************************************************* 3 * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG 4 * All rights reserved. 5 ******************************************************************************/ 6 #ifndef FAPI_TPM_JSON_DESERIALIZE_H 7 #define FAPI_TPM_JSON_DESERIALIZE_H 8 9 #include <stdbool.h> 10 #include <json-c/json.h> 11 #include <json-c/json_util.h> 12 13 #include "tss2_tpm2_types.h" 14 #include "fapi_int.h" 15 #define YES 1 16 #define NO 0 17 18 TSS2_RC 19 ifapi_json_BYTE_array_deserialize(size_t max, json_object *jso, BYTE *out); 20 21 TSS2_RC 22 ifapi_json_UINT8_ARY_deserialize(json_object *jso, UINT8_ARY *out); 23 24 bool 25 ifapi_get_sub_object(json_object *jso, char *name, json_object **sub_jso); 26 27 TSS2_RC 28 ifapi_json_BYTE_deserialize(json_object *jso, BYTE *out); 29 30 TSS2_RC 31 ifapi_json_UINT16_deserialize(json_object *jso, UINT16 *out); 32 33 TSS2_RC 34 ifapi_json_UINT32_deserialize(json_object *jso, UINT32 *out); 35 36 TSS2_RC 37 ifapi_json_UINT64_deserialize(json_object *jso, UINT64 *out); 38 39 TSS2_RC 40 ifapi_json_TPM2_GENERATED_deserialize(json_object *jso, TPM2_GENERATED *out); 41 42 TSS2_RC 43 ifapi_json_TPM2_ALG_ID_deserialize(json_object *jso, TPM2_ALG_ID *out); 44 45 TSS2_RC 46 ifapi_json_TPM2_ECC_CURVE_deserialize(json_object *jso, TPM2_ECC_CURVE *out); 47 48 TSS2_RC 49 ifapi_json_TPM2_CC_deserialize(json_object *jso, TPM2_CC *out); 50 51 TSS2_RC 52 ifapi_json_TPM2_EO_deserialize(json_object *jso, TPM2_EO *out); 53 54 TSS2_RC 55 ifapi_json_TPM2_ST_deserialize(json_object *jso, TPM2_ST *out); 56 57 TSS2_RC 58 ifapi_json_TPM2_PT_PCR_deserialize(json_object *jso, TPM2_PT_PCR *out); 59 60 TSS2_RC 61 ifapi_json_TPM2_HANDLE_deserialize(json_object *jso, TPM2_HANDLE *out); 62 63 TSS2_RC 64 ifapi_json_TPMA_OBJECT_deserialize(json_object *jso, TPMA_OBJECT *out); 65 66 TSS2_RC 67 ifapi_json_TPMA_LOCALITY_deserialize(json_object *jso, TPMA_LOCALITY *out); 68 69 TSS2_RC 70 ifapi_json_TPMI_YES_NO_deserialize(json_object *jso, TPMI_YES_NO *out); 71 72 TSS2_RC 73 ifapi_json_TPMI_RH_HIERARCHY_deserialize(json_object *jso, 74 TPMI_RH_HIERARCHY *out); 75 76 TSS2_RC 77 ifapi_json_TPMI_RH_NV_INDEX_deserialize(json_object *jso, 78 TPMI_RH_NV_INDEX *out); 79 80 TSS2_RC 81 ifapi_json_TPMI_ALG_HASH_deserialize(json_object *jso, TPMI_ALG_HASH *out); 82 83 TSS2_RC 84 ifapi_json_TPMI_ALG_SYM_deserialize(json_object *jso, TPMI_ALG_SYM *out); 85 86 TSS2_RC 87 ifapi_json_TPMI_ALG_SYM_OBJECT_deserialize(json_object *jso, 88 TPMI_ALG_SYM_OBJECT *out); 89 90 TSS2_RC 91 ifapi_json_TPMI_ALG_SYM_MODE_deserialize(json_object *jso, 92 TPMI_ALG_SYM_MODE *out); 93 94 TSS2_RC 95 ifapi_json_TPMI_ALG_KDF_deserialize(json_object *jso, TPMI_ALG_KDF *out); 96 97 TSS2_RC 98 ifapi_json_TPMI_ALG_SIG_SCHEME_deserialize(json_object *jso, 99 TPMI_ALG_SIG_SCHEME *out); 100 101 TSS2_RC 102 ifapi_json_TPMS_EMPTY_deserialize(json_object *jso, TPMS_EMPTY *out); 103 104 TSS2_RC 105 ifapi_json_TPMU_HA_deserialize(UINT32 selector, json_object *jso, TPMU_HA *out); 106 107 TSS2_RC 108 ifapi_json_TPMT_HA_deserialize(json_object *jso, TPMT_HA *out); 109 110 TSS2_RC 111 ifapi_json_TPM2B_DIGEST_deserialize(json_object *jso, TPM2B_DIGEST *out); 112 113 TSS2_RC 114 ifapi_json_TPM2B_DATA_deserialize(json_object *jso, TPM2B_DATA *out); 115 116 TSS2_RC 117 ifapi_json_TPM2B_NONCE_deserialize(json_object *jso, TPM2B_NONCE *out); 118 119 TSS2_RC 120 ifapi_json_TPM2B_OPERAND_deserialize(json_object *jso, TPM2B_OPERAND *out); 121 122 TSS2_RC 123 ifapi_json_TPM2B_EVENT_deserialize(json_object *jso, TPM2B_EVENT *out); 124 125 TSS2_RC 126 ifapi_json_TPM2B_MAX_NV_BUFFER_deserialize(json_object *jso, 127 TPM2B_MAX_NV_BUFFER *out); 128 129 TSS2_RC 130 ifapi_json_TPM2B_NAME_deserialize(json_object *jso, TPM2B_NAME *out); 131 132 TSS2_RC 133 ifapi_json_TPMS_PCR_SELECT_deserialize(json_object *jso, TPMS_PCR_SELECT *out); 134 135 TSS2_RC 136 ifapi_json_TPMS_PCR_SELECTION_deserialize(json_object *jso, 137 TPMS_PCR_SELECTION *out); 138 139 TSS2_RC 140 ifapi_json_TPMT_TK_CREATION_deserialize(json_object *jso, 141 TPMT_TK_CREATION *out); 142 143 TSS2_RC 144 ifapi_json_TPMT_TK_VERIFIED_deserialize(json_object *jso, 145 TPMT_TK_VERIFIED *out); 146 147 TSS2_RC 148 ifapi_json_TPML_DIGEST_VALUES_deserialize(json_object *jso, 149 TPML_DIGEST_VALUES *out); 150 151 TSS2_RC 152 ifapi_json_TPML_PCR_SELECTION_deserialize(json_object *jso, 153 TPML_PCR_SELECTION *out); 154 155 TSS2_RC 156 ifapi_json_TPMS_CLOCK_INFO_deserialize(json_object *jso, TPMS_CLOCK_INFO *out); 157 158 TSS2_RC 159 ifapi_json_TPMS_TIME_INFO_deserialize(json_object *jso, TPMS_TIME_INFO *out); 160 161 TSS2_RC 162 ifapi_json_TPMS_TIME_ATTEST_INFO_deserialize(json_object *jso, 163 TPMS_TIME_ATTEST_INFO *out); 164 165 TSS2_RC 166 ifapi_json_TPMS_CERTIFY_INFO_deserialize(json_object *jso, 167 TPMS_CERTIFY_INFO *out); 168 169 TSS2_RC 170 ifapi_json_TPMS_QUOTE_INFO_deserialize(json_object *jso, TPMS_QUOTE_INFO *out); 171 172 TSS2_RC 173 ifapi_json_TPMS_COMMAND_AUDIT_INFO_deserialize(json_object *jso, 174 TPMS_COMMAND_AUDIT_INFO *out); 175 176 TSS2_RC 177 ifapi_json_TPMS_SESSION_AUDIT_INFO_deserialize(json_object *jso, 178 TPMS_SESSION_AUDIT_INFO *out); 179 180 TSS2_RC 181 ifapi_json_TPMS_CREATION_INFO_deserialize(json_object *jso, 182 TPMS_CREATION_INFO *out); 183 184 TSS2_RC 185 ifapi_json_TPMS_NV_CERTIFY_INFO_deserialize(json_object *jso, 186 TPMS_NV_CERTIFY_INFO *out); 187 188 TSS2_RC 189 ifapi_json_TPMI_ST_ATTEST_deserialize(json_object *jso, TPMI_ST_ATTEST *out); 190 191 TSS2_RC 192 ifapi_json_TPMU_ATTEST_deserialize(UINT32 selector, json_object *jso, 193 TPMU_ATTEST *out); 194 195 TSS2_RC 196 ifapi_json_TPMS_ATTEST_deserialize(json_object *jso, TPMS_ATTEST *out); 197 198 TSS2_RC 199 ifapi_json_TPMI_AES_KEY_BITS_deserialize(json_object *jso, 200 TPMI_AES_KEY_BITS *out); 201 202 TSS2_RC 203 ifapi_json_TPMU_SYM_KEY_BITS_deserialize(UINT32 selector, json_object *jso, 204 TPMU_SYM_KEY_BITS *out); 205 206 TSS2_RC 207 ifapi_json_TPMU_SYM_MODE_deserialize(UINT32 selector, json_object *jso, 208 TPMU_SYM_MODE *out); 209 210 TSS2_RC 211 ifapi_json_TPMT_SYM_DEF_deserialize(json_object *jso, TPMT_SYM_DEF *out); 212 213 TSS2_RC 214 ifapi_json_TPMT_SYM_DEF_OBJECT_deserialize(json_object *jso, 215 TPMT_SYM_DEF_OBJECT *out); 216 217 TSS2_RC 218 ifapi_json_TPMS_SYMCIPHER_PARMS_deserialize(json_object *jso, 219 TPMS_SYMCIPHER_PARMS *out); 220 221 TSS2_RC 222 ifapi_json_TPMS_SCHEME_HASH_deserialize(json_object *jso, 223 TPMS_SCHEME_HASH *out); 224 225 TSS2_RC 226 ifapi_json_TPMS_SCHEME_ECDAA_deserialize(json_object *jso, 227 TPMS_SCHEME_ECDAA *out); 228 229 TSS2_RC 230 ifapi_json_TPMI_ALG_KEYEDHASH_SCHEME_deserialize(json_object *jso, 231 TPMI_ALG_KEYEDHASH_SCHEME *out); 232 233 TSS2_RC 234 ifapi_json_TPMS_SCHEME_HMAC_deserialize(json_object *jso, 235 TPMS_SCHEME_HMAC *out); 236 237 TSS2_RC 238 ifapi_json_TPMS_SCHEME_XOR_deserialize(json_object *jso, TPMS_SCHEME_XOR *out); 239 240 TSS2_RC 241 ifapi_json_TPMU_SCHEME_KEYEDHASH_deserialize(UINT32 selector, json_object *jso, 242 TPMU_SCHEME_KEYEDHASH *out); 243 244 TSS2_RC 245 ifapi_json_TPMT_KEYEDHASH_SCHEME_deserialize(json_object *jso, 246 TPMT_KEYEDHASH_SCHEME *out); 247 248 TSS2_RC 249 ifapi_json_TPMS_SIG_SCHEME_RSASSA_deserialize(json_object *jso, 250 TPMS_SIG_SCHEME_RSASSA *out); 251 252 TSS2_RC 253 ifapi_json_TPMS_SIG_SCHEME_RSAPSS_deserialize(json_object *jso, 254 TPMS_SIG_SCHEME_RSAPSS *out); 255 256 TSS2_RC 257 ifapi_json_TPMS_SIG_SCHEME_ECDSA_deserialize(json_object *jso, 258 TPMS_SIG_SCHEME_ECDSA *out); 259 260 TSS2_RC 261 ifapi_json_TPMS_SIG_SCHEME_SM2_deserialize(json_object *jso, 262 TPMS_SIG_SCHEME_SM2 *out); 263 264 TSS2_RC 265 ifapi_json_TPMS_SIG_SCHEME_ECSCHNORR_deserialize(json_object *jso, 266 TPMS_SIG_SCHEME_ECSCHNORR *out); 267 268 TSS2_RC 269 ifapi_json_TPMS_SIG_SCHEME_ECDAA_deserialize(json_object *jso, 270 TPMS_SIG_SCHEME_ECDAA *out); 271 272 TSS2_RC 273 ifapi_json_TPMU_SIG_SCHEME_deserialize(UINT32 selector, json_object *jso, 274 TPMU_SIG_SCHEME *out); 275 276 TSS2_RC 277 ifapi_json_TPMT_SIG_SCHEME_deserialize(json_object *jso, TPMT_SIG_SCHEME *out); 278 279 TSS2_RC 280 ifapi_json_TPMS_ENC_SCHEME_OAEP_deserialize(json_object *jso, 281 TPMS_ENC_SCHEME_OAEP *out); 282 283 TSS2_RC 284 ifapi_json_TPMS_ENC_SCHEME_RSAES_deserialize(json_object *jso, 285 TPMS_ENC_SCHEME_RSAES *out); 286 287 TSS2_RC 288 ifapi_json_TPMS_KEY_SCHEME_ECDH_deserialize(json_object *jso, 289 TPMS_KEY_SCHEME_ECDH *out); 290 291 TSS2_RC 292 ifapi_json_TPMS_SCHEME_MGF1_deserialize(json_object *jso, 293 TPMS_SCHEME_MGF1 *out); 294 295 TSS2_RC 296 ifapi_json_TPMS_SCHEME_KDF1_SP800_56A_deserialize(json_object *jso, 297 TPMS_SCHEME_KDF1_SP800_56A *out); 298 299 TSS2_RC 300 ifapi_json_TPMS_SCHEME_KDF1_SP800_108_deserialize(json_object *jso, 301 TPMS_SCHEME_KDF1_SP800_108 *out); 302 303 TSS2_RC 304 ifapi_json_TPMU_KDF_SCHEME_deserialize(UINT32 selector, json_object *jso, 305 TPMU_KDF_SCHEME *out); 306 307 TSS2_RC 308 ifapi_json_TPMT_KDF_SCHEME_deserialize(json_object *jso, TPMT_KDF_SCHEME *out); 309 310 TSS2_RC 311 ifapi_json_TPMU_ASYM_SCHEME_deserialize(UINT32 selector, json_object *jso, 312 TPMU_ASYM_SCHEME *out); 313 314 TSS2_RC 315 ifapi_json_TPMI_ALG_RSA_SCHEME_deserialize(json_object *jso, 316 TPMI_ALG_RSA_SCHEME *out); 317 318 TSS2_RC 319 ifapi_json_TPMT_RSA_SCHEME_deserialize(json_object *jso, TPMT_RSA_SCHEME *out); 320 321 TSS2_RC 322 ifapi_json_TPMI_ALG_RSA_DECRYPT_deserialize(json_object *jso, 323 TPMI_ALG_RSA_DECRYPT *out); 324 325 TSS2_RC 326 ifapi_json_TPMT_RSA_DECRYPT_deserialize(json_object *jso, 327 TPMT_RSA_DECRYPT *out); 328 329 TSS2_RC 330 ifapi_json_TPM2B_PUBLIC_KEY_RSA_deserialize(json_object *jso, 331 TPM2B_PUBLIC_KEY_RSA *out); 332 333 TSS2_RC 334 ifapi_json_TPMI_RSA_KEY_BITS_deserialize(json_object *jso, 335 TPMI_RSA_KEY_BITS *out); 336 337 TSS2_RC 338 ifapi_json_TPM2B_ECC_PARAMETER_deserialize(json_object *jso, 339 TPM2B_ECC_PARAMETER *out); 340 341 TSS2_RC 342 ifapi_json_TPMS_ECC_POINT_deserialize(json_object *jso, TPMS_ECC_POINT *out); 343 344 TSS2_RC 345 ifapi_json_TPMI_ALG_ECC_SCHEME_deserialize(json_object *jso, 346 TPMI_ALG_ECC_SCHEME *out); 347 348 TSS2_RC 349 ifapi_json_TPMI_ECC_CURVE_deserialize(json_object *jso, TPMI_ECC_CURVE *out); 350 351 TSS2_RC 352 ifapi_json_TPMT_ECC_SCHEME_deserialize(json_object *jso, TPMT_ECC_SCHEME *out); 353 354 TSS2_RC 355 ifapi_json_TPMS_SIGNATURE_RSA_deserialize(json_object *jso, 356 TPMS_SIGNATURE_RSA *out); 357 358 TSS2_RC 359 ifapi_json_TPMS_SIGNATURE_RSASSA_deserialize(json_object *jso, 360 TPMS_SIGNATURE_RSASSA *out); 361 362 TSS2_RC 363 ifapi_json_TPMS_SIGNATURE_RSAPSS_deserialize(json_object *jso, 364 TPMS_SIGNATURE_RSAPSS *out); 365 366 TSS2_RC 367 ifapi_json_TPMS_SIGNATURE_ECC_deserialize(json_object *jso, 368 TPMS_SIGNATURE_ECC *out); 369 370 TSS2_RC 371 ifapi_json_TPMS_SIGNATURE_ECDSA_deserialize(json_object *jso, 372 TPMS_SIGNATURE_ECDSA *out); 373 374 TSS2_RC 375 ifapi_json_TPMS_SIGNATURE_ECDAA_deserialize(json_object *jso, 376 TPMS_SIGNATURE_ECDAA *out); 377 378 TSS2_RC 379 ifapi_json_TPMS_SIGNATURE_SM2_deserialize(json_object *jso, 380 TPMS_SIGNATURE_SM2 *out); 381 382 TSS2_RC 383 ifapi_json_TPMS_SIGNATURE_ECSCHNORR_deserialize(json_object *jso, 384 TPMS_SIGNATURE_ECSCHNORR *out); 385 386 TSS2_RC 387 ifapi_json_TPMU_SIGNATURE_deserialize(UINT32 selector, json_object *jso, 388 TPMU_SIGNATURE *out); 389 390 TSS2_RC 391 ifapi_json_TPMT_SIGNATURE_deserialize(json_object *jso, TPMT_SIGNATURE *out); 392 393 TSS2_RC 394 ifapi_json_TPM2B_ENCRYPTED_SECRET_deserialize(json_object *jso, 395 TPM2B_ENCRYPTED_SECRET *out); 396 397 TSS2_RC 398 ifapi_json_TPMI_ALG_PUBLIC_deserialize(json_object *jso, TPMI_ALG_PUBLIC *out); 399 400 TSS2_RC 401 ifapi_json_TPMU_PUBLIC_ID_deserialize(UINT32 selector, json_object *jso, 402 TPMU_PUBLIC_ID *out); 403 404 TSS2_RC 405 ifapi_json_TPMS_KEYEDHASH_PARMS_deserialize(json_object *jso, 406 TPMS_KEYEDHASH_PARMS *out); 407 408 TSS2_RC 409 ifapi_json_TPMS_RSA_PARMS_deserialize(json_object *jso, TPMS_RSA_PARMS *out); 410 411 TSS2_RC 412 ifapi_json_TPMS_ECC_PARMS_deserialize(json_object *jso, TPMS_ECC_PARMS *out); 413 414 TSS2_RC 415 ifapi_json_TPMU_PUBLIC_PARMS_deserialize(UINT32 selector, json_object *jso, 416 TPMU_PUBLIC_PARMS *out); 417 418 TSS2_RC 419 ifapi_json_TPMT_PUBLIC_deserialize(json_object *jso, TPMT_PUBLIC *out); 420 421 TSS2_RC 422 ifapi_json_TPM2B_PUBLIC_deserialize(json_object *jso, TPM2B_PUBLIC *out); 423 424 TSS2_RC 425 ifapi_json_TPM2B_PRIVATE_deserialize(json_object *jso, TPM2B_PRIVATE *out); 426 427 TSS2_RC 428 ifapi_json_TPM2_NT_deserialize(json_object *jso, TPM2_NT *out); 429 430 TSS2_RC 431 ifapi_json_TPMA_NV_deserialize(json_object *jso, TPMA_NV *out); 432 433 TSS2_RC 434 ifapi_json_TPMS_NV_PUBLIC_deserialize(json_object *jso, TPMS_NV_PUBLIC *out); 435 436 TSS2_RC 437 ifapi_json_TPM2B_NV_PUBLIC_deserialize(json_object *jso, TPM2B_NV_PUBLIC *out); 438 439 TSS2_RC 440 ifapi_json_TPMS_CREATION_DATA_deserialize(json_object *jso, 441 TPMS_CREATION_DATA *out); 442 443 TSS2_RC 444 ifapi_json_TPM2B_CREATION_DATA_deserialize(json_object *jso, 445 TPM2B_CREATION_DATA *out); 446 447 #endif /* FAPI_TPM_JSON_DESERIALIZE_H */ 448