Skip to content

Commit

Permalink
document cipher_interface
Browse files Browse the repository at this point in the history
  • Loading branch information
braindigitalis committed Oct 6, 2024
1 parent d60f706 commit 8a71378
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/dpp/dave/cipher_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,55 @@

namespace dpp::dave {

/**
* @brief An array_view constant array of bytes
*/
using const_byte_view = array_view<const uint8_t>;

/**
* @brief An array_view non-constant array of bytes
*/
using byte_view = array_view<uint8_t>;

/**
* @brief Represents a block cipher with AEAD used to encrypt or decrypt
* audio and video frames in the DAVE protocol.
*/
class cipher_interface { // NOLINT
public:
/**
* @brief Default destructor
*/
virtual ~cipher_interface() = default;

/**
* @brief Encrypt audio or video
* @param ciphertextBufferOut Output buffer of ciphertext
* @param plaintextBuffer Input buffer for plaintext
* @param nonceBuffer Input nonce/IV
* @param additionalData Additional data for GCM AEAD encryption
* @param tagBufferOut AEAD Tag for verification
* @return true if encryption succeeded, false if it failed
*/
virtual bool encrypt(byte_view ciphertextBufferOut, const_byte_view plaintextBuffer, const_byte_view nonceBuffer, const_byte_view additionalData, byte_view tagBufferOut) = 0;

/**
* @brief Decrypt audio or video
* @param plaintextBufferOut Output buffer for plaintext
* @param ciphertextBuffer Input buffer for ciphetext
* @param tagBuffer AEAD Tag for verification
* @param nonceBuffer Nonce/IV
* @param additionalData Additional data for GCM AEAD encryption
* @return true if decryption succeeded, false if it failed
*/
virtual bool decrypt(byte_view plaintextBufferOut, const_byte_view ciphertextBuffer, const_byte_view tagBuffer, const_byte_view nonceBuffer, const_byte_view additionalData) = 0;
};

/**
* @brief Factory function to create new cipher interface of the best supported type for DAVE
* @param encryptionKey encryption key
* @return an instance of a class derived from cipher_interface
*/
std::unique_ptr<cipher_interface> create_cipher(const encryption_key& encryptionKey);

} // namespace dpp::dave
Expand Down

0 comments on commit 8a71378

Please sign in to comment.