esys-ecc-parameters.int.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #ifdef HAVE_CONFIG_H
  7. #include <config.h>
  8. #endif
  9. #include <stdlib.h>
  10. #include "tss2_esys.h"
  11. #include "esys_iutil.h"
  12. #include "test-esys.h"
  13. #define LOGMODULE test
  14. #include "util/log.h"
  15. #include "util/aux_util.h"
  16. /** Test the ESYS function Esys_ECC_Parameters.
  17. *
  18. * Tested ESYS commands:
  19. * - Esys_ECC_Parameters() (M)
  20. *
  21. * @param[in,out] esys_context The ESYS_CONTEXT.
  22. * @retval EXIT_FAILURE
  23. * @retval EXIT_SKIP
  24. * @retval EXIT_SUCCESS
  25. */
  26. int
  27. test_esys_ecc_parameters(ESYS_CONTEXT * esys_context)
  28. {
  29. TSS2_RC r;
  30. int failure_return = EXIT_FAILURE;
  31. TPMI_ECC_CURVE curveID = TPM2_ECC_NIST_P256;
  32. TPMS_ALGORITHM_DETAIL_ECC *parameters;
  33. r = Esys_ECC_Parameters(
  34. esys_context,
  35. ESYS_TR_NONE,
  36. ESYS_TR_NONE,
  37. ESYS_TR_NONE,
  38. curveID,
  39. &parameters);
  40. if (r == TPM2_RC_CURVE + TPM2_RC_P + TPM2_RC_1) {
  41. LOG_WARNING("Curve TPM2_ECC_NIST_P256 not supported by TPM.");
  42. failure_return = EXIT_SKIP;
  43. goto error;
  44. }
  45. goto_if_error(r, "Error: ECC_Parameters", error);
  46. SAFE_FREE(parameters);
  47. return EXIT_SUCCESS;
  48. error:
  49. SAFE_FREE(parameters);
  50. return failure_return;
  51. }
  52. int
  53. test_invoke_esys(ESYS_CONTEXT * esys_context) {
  54. return test_esys_ecc_parameters(esys_context);
  55. }