OCPConfig.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /**
  2. * MIT License
  3. *
  4. * Copyright (c) 2018 Infineon Technologies AG
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to deal
  8. * in the Software without restriction, including without limitation the rights
  9. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in all
  14. * copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  22. * SOFTWARE
  23. *
  24. *
  25. * \file
  26. *
  27. * \brief This file implements the Configuration functions for OCP Library.
  28. *
  29. * \addtogroup grMutualAuth
  30. * @{
  31. */
  32. #include "optiga/dtls/DtlsTransportLayer.h"
  33. #include "optiga/dtls/DtlsHandshakeProtocol.h" //To be put under ifdef
  34. #include "optiga/dtls/DtlsRecordLayer.h"
  35. #include "optiga/dtls/HardwareCrypto.h"
  36. #include "optiga/optiga_dtls.h"
  37. #ifdef MODULE_ENABLE_DTLS_MUTUAL_AUTH
  38. /// @cond hidden
  39. //lint --e{714} suppress "Functions are extern and not reference in header file as
  40. // these function not to be used for external interfaces. Hence suppressed"
  41. Void ConfigHL(fPerformHandshake_d* PpfPerformHandshake,eConfiguration_d PeConfiguration)
  42. {
  43. //Based on input mode assign pointers to PpsAppOCPCntx
  44. switch(PeConfiguration)
  45. {
  46. case eDTLS_12_UDP_HWCRYPTO:
  47. //Assign the Handshake layer function pointer to context data
  48. *PpfPerformHandshake = DtlsHS_Handshake;
  49. break;
  50. case eTLS_12_TCP_HWCRYPTO:
  51. break;
  52. }
  53. }
  54. //lint --e{714} suppress "Functions are extern and not reference in header file as
  55. // these function not to be used for external interfaces. Hence suppressed"
  56. Void ConfigRL(sConfigRL_d* PpsConfigRL,eConfiguration_d PeConfiguration)
  57. {
  58. //Based on input mode assign pointers to psConfigRL
  59. switch(PeConfiguration)
  60. {
  61. case eDTLS_12_UDP_HWCRYPTO:
  62. PpsConfigRL->pfInit = DtlsRL_Init;
  63. PpsConfigRL->pfSend = DtlsRL_Send;
  64. PpsConfigRL->pfRecv = DtlsRL_Recv;
  65. PpsConfigRL->pfClose = DtlsRL_Close;
  66. break;
  67. case eTLS_12_TCP_HWCRYPTO:
  68. break;
  69. }
  70. }
  71. //lint --e{714} suppress "Functions are extern and not reference in header file as
  72. // these function not to be used for external interfaces. Hence suppressed"
  73. Void ConfigTL(sConfigTL_d* PpsConfigTL,eConfiguration_d PeConfiguration)
  74. {
  75. //Based on input mode assign pointers to psConfigTL
  76. switch(PeConfiguration)
  77. {
  78. case eTLS_12_TCP_HWCRYPTO:
  79. break;
  80. case eDTLS_12_UDP_HWCRYPTO:
  81. //Assign function to function pointers
  82. PpsConfigTL->pfInit = DtlsTL_Init;
  83. PpsConfigTL->pfConnect = DtlsTL_Connect;
  84. PpsConfigTL->pfDisconnect = DtlsTL_Disconnect;
  85. PpsConfigTL->pfRecv = DtlsTL_Recv;
  86. PpsConfigTL->pfSend = DtlsTL_Send;
  87. break;
  88. }
  89. }
  90. //lint --e{714} suppress "Functions are extern and not reference in header file as
  91. // these function not to be used for external interfaces. Hence suppressed"
  92. Void ConfigCL(sConfigCL_d* PpsConfigCL,eConfiguration_d PeConfiguration)
  93. {
  94. //Based on input mode assign pointers to psConfigCL
  95. switch(PeConfiguration)
  96. {
  97. case eDTLS_12_UDP_HWCRYPTO:
  98. case eTLS_12_TCP_HWCRYPTO:
  99. PpsConfigCL->pfInit = HWCL_Init;
  100. PpsConfigCL->pfEncrypt = HWCL_Encrypt;
  101. PpsConfigCL->pfDecrypt = HWCL_Decrypt;
  102. PpsConfigCL->pfClose = HWCL_Close;
  103. break;
  104. }
  105. }
  106. /// @endcond
  107. /**
  108. * @}
  109. */
  110. #endif /*MODULE_ENABLE_DTLS_MUTUAL_AUTH*/