Program Listing for File CryptoTransform.h

Return to documentation for file (/tmp/ws/src/fastrtps/include/fastdds/rtps/security/cryptography/CryptoTransform.h)

// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef _FASTDDS_RTPS_SECURITY_CRYPTOGRAPHY_CRYPTOTRANSFORM_H_
#define _FASTDDS_RTPS_SECURITY_CRYPTOGRAPHY_CRYPTOTRANSFORM_H_

#include <memory>

#include <fastdds/rtps/security/cryptography/CryptoTypes.h>
#include <fastdds/rtps/common/CDRMessage_t.h>
#include <fastdds/rtps/common/SerializedPayload.h>

namespace eprosima {
namespace fastrtps {
namespace rtps {
namespace security {

class CryptoTransform
{
public:

    virtual ~CryptoTransform()
    {
    }

    virtual bool encode_serialized_payload(
            SerializedPayload_t& encoded_payload,
            std::vector<uint8_t>& extra_inline_qos,
            const SerializedPayload_t& payload,
            DatawriterCryptoHandle& sending_datawriter_crypto,
            SecurityException& exception) = 0;
    virtual bool encode_datawriter_submessage(
            CDRMessage_t& encoded_rtps_submessage,
            const CDRMessage_t& plain_rtps_submessage,
            DatawriterCryptoHandle& sending_datawriter_crypto,
            std::vector<std::shared_ptr<DatareaderCryptoHandle>>& receiving_datareader_crypto_list,
            SecurityException& exception) = 0;

    virtual bool encode_datareader_submessage(
            CDRMessage_t& encoded_rtps_submessage,
            const CDRMessage_t& plain_rtps_submessage,
            DatareaderCryptoHandle& sending_datareader_crypto,
            std::vector<std::shared_ptr<DatawriterCryptoHandle>>& receiving_datawriter_crypto_list,
            SecurityException& exception) = 0;

    virtual bool encode_rtps_message(
            CDRMessage_t& encoded_rtps_message,
            const CDRMessage_t& plain_rtps_message,
            ParticipantCryptoHandle& sending_crypto,
            std::vector<std::shared_ptr<ParticipantCryptoHandle>>& receiving_crypto_list,
            SecurityException& exception) = 0;

    virtual bool decode_rtps_message(
            CDRMessage_t& plain_buffer,
            const CDRMessage_t& encoded_buffer,
            const ParticipantCryptoHandle& receiving_crypto,
            const ParticipantCryptoHandle& sending_crypto,
            SecurityException& exception) = 0;

    virtual bool preprocess_secure_submsg(
            DatawriterCryptoHandle** datawriter_crypto,
            DatareaderCryptoHandle** datareader_crypto,
            SecureSubmessageCategory_t& secure_submessage_category,
            const CDRMessage_t& encoded_rtps_submessage,
            ParticipantCryptoHandle& receiving_crypto,
            ParticipantCryptoHandle& sending_crypto,
            SecurityException& exception) = 0;

    virtual bool decode_datawriter_submessage(
            CDRMessage_t& plain_rtps_submessage,
            CDRMessage_t& encoded_rtps_submessage,
            DatareaderCryptoHandle& receiving_datareader_crypto,
            DatawriterCryptoHandle& sending_datawriter_crypto,
            SecurityException& exception) = 0;

    virtual bool decode_datareader_submessage(
            CDRMessage_t& plain_rtps_submessage,
            CDRMessage_t& encoded_rtps_submessage,
            DatawriterCryptoHandle& receiving_datawriter_crypto,
            DatareaderCryptoHandle& sending_datareader_crypto,
            SecurityException& exception) = 0;

    virtual bool decode_serialized_payload(
            SerializedPayload_t& plain_payload,
            const SerializedPayload_t& encoded_payload,
            const std::vector<uint8_t>& inline_qos,
            DatareaderCryptoHandle& receiving_datareader_crypto,
            DatawriterCryptoHandle& sending_datawriter_crypto,
            SecurityException& exception) = 0;

    virtual uint32_t calculate_extra_size_for_rtps_message(
            uint32_t number_discovered_participants) const = 0;

    virtual uint32_t calculate_extra_size_for_rtps_submessage(
            uint32_t number_discovered_readers) const = 0;

    virtual uint32_t calculate_extra_size_for_encoded_payload(
            uint32_t number_discovered_readers) const = 0;
};

} //namespace eprosima
} //namespace fastrtps
} //namespace rtps
} //namespace security

#endif //_FASTDDS_RTPS_SECURITY_CRYPTOGRAPHY_CRYPTOTRANSFORM_H_