1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /******************************************************************************* 3 * Copyright 2017-2018, Fraunhofer SIT sponsored by Infineon Technologies AG 4 * All rights reserved. 5 *******************************************************************************/ 6 7 #ifdef HAVE_CONFIG_H 8 #include <config.h> 9 #endif 10 11 #include <stdlib.h> 12 13 #include "tss2_esys.h" 14 15 #include "esys_iutil.h" 16 #include "test-esapi.h" 17 #define LOGMODULE test 18 #include "util/log.h" 19 #include "util/aux_util.h" 20 21 /** Test the ESAPI function Esys_ECC_Parameters. 22 * 23 * Tested ESAPI commands: 24 * - Esys_ECC_Parameters() (M) 25 * 26 * @param[in,out] esys_context The ESYS_CONTEXT. 27 * @retval EXIT_FAILURE 28 * @retval EXIT_SKIP 29 * @retval EXIT_SUCCESS 30 */ 31 int test_esys_ecc_parameters(ESYS_CONTEXT * esys_context)32test_esys_ecc_parameters(ESYS_CONTEXT * esys_context) 33 { 34 TSS2_RC r; 35 int failure_return = EXIT_FAILURE; 36 37 TPMI_ECC_CURVE curveID = TPM2_ECC_NIST_P256; 38 TPMS_ALGORITHM_DETAIL_ECC *parameters; 39 40 r = Esys_ECC_Parameters( 41 esys_context, 42 ESYS_TR_NONE, 43 ESYS_TR_NONE, 44 ESYS_TR_NONE, 45 curveID, 46 ¶meters); 47 48 if (r == TPM2_RC_CURVE + TPM2_RC_P + TPM2_RC_1) { 49 LOG_WARNING("Curve TPM2_ECC_NIST_P256 not supported by TPM."); 50 failure_return = EXIT_SKIP; 51 goto error; 52 } 53 goto_if_error(r, "Error: ECC_Parameters", error); 54 55 return EXIT_SUCCESS; 56 57 error: 58 return failure_return; 59 } 60 61 int test_invoke_esapi(ESYS_CONTEXT * esys_context)62test_invoke_esapi(ESYS_CONTEXT * esys_context) { 63 return test_esys_ecc_parameters(esys_context); 64 } 65