File crypto_spi.hpp

File List > astutedds > security > crypto_spi.hpp

Go to the documentation of this file

//
// Copyright (c) 2026, Astute Systems PTY LTD
//
// This file is part of the Astute DDS developed by Astute Systems.
//
// See the commercial LICENSE file in the project root for full license details.
//

#pragma once

#include "security_types.hpp"

#include <astutedds/rtps/rtps_types.hpp>

#include <cstddef>
#include <memory>
#include <span>

namespace astutedds::security
{

class CryptoPlugin
{
public:
    virtual ~CryptoPlugin() = default;

    virtual ParticipantCryptoHandle register_local_participant(
        IdentityHandle identity_handle, PermissionsHandle permissions_handle, const PropertySeq& participant_properties,
        const ParticipantSecurityAttributes& participant_security_attributes, SecurityException& ex) = 0;

    virtual ParticipantCryptoHandle register_matched_remote_participant(
        ParticipantCryptoHandle local_participant_crypto_handle, IdentityHandle remote_identity_handle,
        PermissionsHandle remote_permissions_handle, const Token& shared_secret, SecurityException& ex) = 0;

    virtual DatawriterCryptoHandle register_local_datawriter(
        ParticipantCryptoHandle participant_crypto_handle, const PropertySeq& writer_properties,
        const EndpointSecurityAttributes& writer_security_attributes, SecurityException& ex) = 0;

    virtual DatareaderCryptoHandle register_matched_remote_datareader(
        DatawriterCryptoHandle local_writer_crypto_handle, ParticipantCryptoHandle remote_participant_crypto_handle,
        const Token& shared_secret, bool relay_only, SecurityException& ex) = 0;

    virtual DatareaderCryptoHandle register_local_datareader(
        ParticipantCryptoHandle participant_crypto_handle, const PropertySeq& reader_properties,
        const EndpointSecurityAttributes& reader_security_attributes, SecurityException& ex) = 0;

    virtual DatawriterCryptoHandle register_matched_remote_datawriter(
        DatareaderCryptoHandle local_reader_crypto_handle, ParticipantCryptoHandle remote_participant_crypto_handle,
        const Token& shared_secret, SecurityException& ex) = 0;

    virtual bool unregister_participant(ParticipantCryptoHandle participant_crypto_handle, SecurityException& ex) = 0;

    virtual bool unregister_datawriter(DatawriterCryptoHandle datawriter_crypto_handle, SecurityException& ex) = 0;

    virtual bool unregister_datareader(DatareaderCryptoHandle datareader_crypto_handle, SecurityException& ex) = 0;

    virtual bool encode_serialized_payload(std::vector<uint8_t>& encrypted_buffer,
                                           std::span<const uint8_t> plain_buffer,
                                           DatawriterCryptoHandle sending_datawriter_crypto_handle,
                                           SecurityException& ex) = 0;

    virtual bool decode_serialized_payload(std::vector<uint8_t>& plain_buffer,
                                           std::span<const uint8_t> encrypted_buffer,
                                           DatareaderCryptoHandle receiving_datareader_crypto_handle,
                                           DatawriterCryptoHandle sending_datawriter_crypto_handle,
                                           SecurityException& ex) = 0;

    virtual bool encode_rtps_message(std::vector<uint8_t>& encoded_buffer, std::span<const uint8_t> plain_buffer,
                                     ParticipantCryptoHandle sending_participant_crypto_handle,
                                     const std::vector<ParticipantCryptoHandle>& receiving_participant_crypto_handles,
                                     SecurityException& ex) = 0;

    virtual bool decode_rtps_message(std::vector<uint8_t>& plain_buffer, std::span<const uint8_t> encoded_buffer,
                                     ParticipantCryptoHandle receiving_participant_crypto_handle,
                                     ParticipantCryptoHandle sending_participant_crypto_handle,
                                     SecurityException& ex) = 0;

    virtual TokenSeq create_local_participant_crypto_tokens(ParticipantCryptoHandle local_crypto_handle,
                                                            ParticipantCryptoHandle remote_crypto_handle,
                                                            SecurityException& ex) = 0;

    virtual bool set_remote_participant_crypto_tokens(ParticipantCryptoHandle local_crypto_handle,
                                                      ParticipantCryptoHandle remote_crypto_handle,
                                                      const TokenSeq& remote_crypto_tokens, SecurityException& ex) = 0;
};

using CryptoPluginPtr = std::shared_ptr<CryptoPlugin>;

}  // namespace astutedds::security