CryptoKeyFactory.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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 CryptoKeyFactory.h
  16. */
  17. #ifndef _FASTDDS_RTPS_SECURITY_CRYPTOGRAPHY_CRYPTOKEYFACTORY_H_
  18. #define _FASTDDS_RTPS_SECURITY_CRYPTOGRAPHY_CRYPTOKEYFACTORY_H_
  19. #include <fastdds/rtps/security/cryptography/CryptoTypes.h>
  20. #include <fastdds/rtps/security/accesscontrol/EndpointSecurityAttributes.h>
  21. #include <fastdds/rtps/security/accesscontrol/ParticipantSecurityAttributes.h>
  22. namespace eprosima {
  23. namespace fastrtps {
  24. namespace rtps {
  25. namespace security {
  26. class CryptoKeyFactory
  27. {
  28. public:
  29. virtual ~CryptoKeyFactory(){}
  30. /**
  31. * Register a local, already authenticated Participant with the Cryptographic Plugin.
  32. * Creates Crypto material needed to encrypt messages directed to other Participants
  33. * @param participant_identity Made by a prior call to validate_local_identity
  34. * @param participant_permissions Made by a prior call to validate_local_permissions
  35. * @param participant_properties Combination of PropertyQoSPolicy and contents of AccessControl
  36. * @param participant_security_attributes ParticipantSecurity Attributes.
  37. * @param exception (out) Security exception
  38. * @return ParticipantCryptoHandle with generated key material
  39. */
  40. virtual ParticipantCryptoHandle * register_local_participant(
  41. const IdentityHandle &participant_identity,
  42. const PermissionsHandle &participant_permissions,
  43. const PropertySeq &participant_properties,
  44. const ParticipantSecurityAttributes &participant_security_attributes,
  45. SecurityException &exception) = 0;
  46. /**
  47. * Register a remote, already authenticated Participant with the Cryptographic Plugin.
  48. * Creates key material to decrypt messages coming from and aimed at it.
  49. * @param local_participant_crypto_handle Returned by a prior call to register_local_participant
  50. * @param remote_participant_identity Returned by a prior call to validate_remote_identity
  51. * @param remote_participant_permissions Returned by a prior call to validate_remote_permissions
  52. * @param shared_secret Returned by a prior call to get_shared_secret (Auth Handshake)
  53. * @param exception (out) Security exception
  54. * @return ParticipantCryptoHandle with generated key material
  55. */
  56. virtual ParticipantCryptoHandle * register_matched_remote_participant(
  57. const ParticipantCryptoHandle& local_participant_crypto_handle,
  58. const IdentityHandle& remote_participant_identity,
  59. const PermissionsHandle& remote_participant_permissions,
  60. const SharedSecretHandle& shared_secret,
  61. SecurityException &exception) = 0;
  62. /**
  63. * Register a local DataWriter belonging to an authenticated Pariticipant.
  64. * Creates cryptomaterial for use with incoming/outgoing messages
  65. * @param participant_crypto returned by a prior call to register_local_participant
  66. * @param datawriter_prop Combination of PropertyWosPolicy and contents of AccessControl
  67. * @param datawriter_sec_attr EndpointSecurity Attributes.
  68. * @param exception (out) Security exception
  69. * @return CryptoHandle to be used with operations related to the DataWriter
  70. */
  71. virtual DatawriterCryptoHandle * register_local_datawriter(
  72. ParticipantCryptoHandle &participant_crypto,
  73. const PropertySeq &datawriter_prop,
  74. const EndpointSecurityAttributes &datawriter_sec_attr,
  75. SecurityException &exception) = 0;
  76. /**
  77. * Register a remote DataReader that has been granted permission to match with the local DataWriter.
  78. * Creates cryptographic material to encript/decrypt messages from and towards that DataReader.
  79. * @param local_datawriter_crypto_handle Returned by a prior call to register_local_datawriter
  80. * @param remote_participant_crypto Returned by a prior call to register_matched_remote_participant.
  81. * @param shared_secret Obtained as a result of the Authentication Handshake.
  82. * @param relay_only If FALSE it generates material for both a submessage and serialized payload. Submessages only if TRUE.
  83. * @param exception (out) Security exception.
  84. * @return Crypto Handle to the generated key material.
  85. */
  86. virtual DatareaderCryptoHandle * register_matched_remote_datareader(
  87. DatawriterCryptoHandle &local_datawriter_crypto_handle,
  88. ParticipantCryptoHandle &remote_participant_crypto,
  89. const SharedSecretHandle &shared_secret,
  90. const bool relay_only,
  91. SecurityException &exception) = 0;
  92. /**
  93. * Register a local DataReader (belonging to an authenticated and authorized Participant) with the Cryptographic Plugin.
  94. * Creates crypto material to encode messages when the encryption is independent of the targeted DataWriter
  95. * @param participant_crypto Returned by a prior call to register_local_participant
  96. * @param datareader_properties Combination of PropertyQosPolicy and the contents of AccessControl
  97. * @param datareader_security_attributes EndpointSecurity Attributes.
  98. * @param exception (out) Security exception
  99. * @return Crypto Handle to the generated key material
  100. */
  101. virtual DatareaderCryptoHandle * register_local_datareader(
  102. ParticipantCryptoHandle &participant_crypto,
  103. const PropertySeq &datareader_properties,
  104. const EndpointSecurityAttributes &datareader_security_attributes,
  105. SecurityException &exception) = 0;
  106. /**
  107. * Register a remote DataWriter that has been granted permission to match with a local DataReader.
  108. * Creates crypto material to decrypt messages coming from and encode messages going towards that datareader
  109. * @param local_datareader_crypto_handle
  110. * @param remote_participant_crypt
  111. * @param shared_secret
  112. * @param exception (out) Security exception
  113. * @return Crypto handle to the generated key material
  114. */
  115. virtual DatawriterCryptoHandle * register_matched_remote_datawriter(
  116. DatareaderCryptoHandle &local_datareader_crypto_handle,
  117. ParticipantCryptoHandle &remote_participant_crypt,
  118. const SharedSecretHandle &shared_secret,
  119. SecurityException &exception) = 0;
  120. /**
  121. * Releases resources associated with a Participant. The Crypto Handle becomes unusable after this
  122. * @param participant_crypto_handle Belonging to the Participant that awaits termination
  123. * @param exception (out) Security exception
  124. * @return TRUE is succesful
  125. */
  126. virtual bool unregister_participant(
  127. ParticipantCryptoHandle* participant_crypto_handle,
  128. SecurityException &exception) = 0;
  129. /**
  130. * Releases resources associated with a DataWriter. The Crypto Handle becomes unusable after this
  131. * @param datawriter_crypto_handle Belonging to the DataWriter that awaits termination
  132. * @param exception (out) Security exception
  133. * @return TRUE is succesful
  134. */
  135. virtual bool unregister_datawriter(
  136. DatawriterCryptoHandle *datawriter_crypto_handle,
  137. SecurityException &exception) = 0;
  138. /**
  139. * Releases resources associated with a DataReader. The Crypto Handle becomes unusable after this
  140. * @param datareader_crypto_handle Belonging to the DataReader that awaits termination
  141. * @param exception (out) Security exception
  142. * @return TRUE is succesful
  143. */
  144. virtual bool unregister_datareader(
  145. DatareaderCryptoHandle *datareader_crypto_handle,
  146. SecurityException &exception) = 0;
  147. };
  148. } //namespace security
  149. } //namespace rtps
  150. } //namespace fastrtps
  151. } //namespace eprosima
  152. #endif //_FASTDDS_RTPS_SECURITY_CRYPTOGRAPHY_CRYPTOKEYFACTORY_H_