CryptoKeyExchange.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. // Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. /*!
  15. * @file Authentication.h
  16. */
  17. #ifndef _FASTDDS_RTPS_SECURITY_CRYPTOGRAPHY_CRYPTOKEYEXCHANGE_H_
  18. #define _FASTDDS_RTPS_SECURITY_CRYPTOGRAPHY_CRYPTOKEYEXCHANGE_H_
  19. #include <fastdds/rtps/security/cryptography/CryptoTypes.h>
  20. namespace eprosima {
  21. namespace fastrtps {
  22. namespace rtps {
  23. namespace security {
  24. class CryptoKeyExchange
  25. {
  26. public:
  27. virtual ~CryptoKeyExchange(){}
  28. /**
  29. * Creates Crypto Tokens containing the info to decrypt text encoded by the local Participant.
  30. * To be sent to the remote participant.
  31. * @param local_participant_crypto_tokens (out) Returned CryptoTokenSeq.
  32. * @param local_participant_crypto CryptoHandle returned by a previous call to register_local_participant.
  33. * @param remote_participant_crypto CryptoHangle returned by a previous call to register_remote_participant.
  34. * @param exception (out) Security exception
  35. * @return TRUE is successful.
  36. */
  37. virtual bool create_local_participant_crypto_tokens(
  38. ParticipantCryptoTokenSeq& local_participant_crypto_tokens,
  39. const ParticipantCryptoHandle& local_participant_crypto,
  40. ParticipantCryptoHandle& remote_participant_crypto,
  41. SecurityException& exception) = 0;
  42. /**
  43. * Configures the Cryptographic Plugin with the material needed to interpret messages coming from the remote crypto.
  44. * @param local_participant_crypto CryptoHandle returned by a previous call to register_local_participant.
  45. * @param remote_participant_crypto CryptoHandle returned by a previous call to register_matched_remote_participant.
  46. * @param remote_participant_tokens CryptoToken sequence received from the remote Participant
  47. * @param exception (out) Security exception
  48. * @return TRUE if successful
  49. */
  50. virtual bool set_remote_participant_crypto_tokens(
  51. const ParticipantCryptoHandle &local_participant_crypto,
  52. ParticipantCryptoHandle &remote_participant_crypto,
  53. const ParticipantCryptoTokenSeq &remote_participant_tokens,
  54. SecurityException &exception) = 0;
  55. /**
  56. * Creates CryptoTokens containing the info to decrypt text encoded by the local DataWriter.
  57. * @param local_datawriter_crypto_tokens (out) Returned CryptoSeq
  58. * @param local_datawriter_crypto CryptoHandle returned by a previous call to register_local_datawriter.
  59. * @param remote_datareader_crypto CryptoHandle returned by a previous call to register_matched_remote_datareader
  60. * @param exception (out) Security exception
  61. * @return TRUE if successful
  62. */
  63. virtual bool create_local_datawriter_crypto_tokens(
  64. DatawriterCryptoTokenSeq &local_datawriter_crypto_tokens,
  65. DatawriterCryptoHandle &local_datawriter_crypto,
  66. DatareaderCryptoHandle &remote_datareader_crypto,
  67. SecurityException &exception) = 0;
  68. /**
  69. * Creates CryptoTokens containing the info to decrypt text encoded by the local DataReader.
  70. * @param local_datareader_crypto_tokens (out)
  71. * @param local_datareader_crypto
  72. * @param remote_datawriter_crypto
  73. * @param exception (out) Security exception
  74. * @return TRUE if successful
  75. */
  76. virtual bool create_local_datareader_crypto_tokens(
  77. DatareaderCryptoTokenSeq &local_datareader_crypto_tokens,
  78. DatareaderCryptoHandle &local_datareader_crypto,
  79. DatawriterCryptoHandle &remote_datawriter_crypto,
  80. SecurityException &exception) = 0;
  81. /**
  82. * Configures the Cryptographic Plugin with the material needed to interpret messages coming from the remote DataReader.
  83. * @param local_datawriter_crypto
  84. * @param remote_datareader_crypto
  85. * @param remote_datareader_tokens
  86. * @param exception (out) Security exception
  87. * @return TRUE if successful
  88. */
  89. virtual bool set_remote_datareader_crypto_tokens(
  90. DatawriterCryptoHandle &local_datawriter_crypto,
  91. DatareaderCryptoHandle &remote_datareader_crypto,
  92. const DatareaderCryptoTokenSeq &remote_datareader_tokens,
  93. SecurityException &exception) = 0;
  94. /**
  95. * Configures the Cryptographic Plugin with the material needed to interpret messages coming from the remote DataWriter.
  96. * @param local_datareader_crypto
  97. * @param remote_datawriter_crypto
  98. * @param remote_datawriter_tokens
  99. * @param exception (out) Security exception
  100. * @return TRUE if successful
  101. */
  102. virtual bool set_remote_datawriter_crypto_tokens(
  103. DatareaderCryptoHandle &local_datareader_crypto,
  104. DatawriterCryptoHandle &remote_datawriter_crypto,
  105. const DatawriterCryptoTokenSeq &remote_datawriter_tokens,
  106. SecurityException &exception) = 0;
  107. /**
  108. * Release resources associated with a CryptoTokenSeq
  109. * @param crypto_tokens
  110. * @param exception (out) Security exception
  111. * @return TRUE if successful
  112. */
  113. virtual bool return_crypto_tokens(
  114. const CryptoTokenSeq &crypto_tokens,
  115. SecurityException &exception) = 0;
  116. };
  117. } //namespace eprosima
  118. } //namespace fastrtps
  119. } //namespace rtps
  120. } //namespace security
  121. #endif //_FASTDDS_RTPS_SECURITY_CRYPTOGRAPHY_CRYPTOKEYEXCHANGE_H_