Skip to content

Commit

Permalink
refactor: libdave camel massacre 🐪🔪 (#1285)
Browse files Browse the repository at this point in the history
  • Loading branch information
braindigitalis authored Oct 16, 2024
1 parent 4965b5c commit 5c6dcec
Show file tree
Hide file tree
Showing 33 changed files with 1,021 additions and 1,145 deletions.
25 changes: 15 additions & 10 deletions src/dpp/dave/array_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,45 +45,50 @@ template <typename T> class array_view {
* @param data data pointer to array
* @param size size of array
*/
array_view(T* data, size_t size)
: data_(data)
, size_(size)
{
array_view(T* data, size_t size) : array(data), array_size(size) {
}

/**
* @brief Get size of view
* @return size
*/
size_t size() const { return size_; }
size_t size() const {
return array_size;
}

/**
* @brief Get data of view from first element
* @return data
*/
T* data() const { return data_; }
T* data() const {
return array;
}

/**
* @brief Get start of view, first element
* @return first element
*/
T* begin() const { return data_; }
T* begin() const {
return array;
}

/**
* @brief Get ending iterator of view, 1+last element
* @return end of view
*/
T* end() const { return data_ + size_; }
T* end() const {
return array + array_size;
}

private:
/**
* @brief array data
*/
T* data_ = nullptr;
T* array = nullptr;
/**
* @brief Array size
*/
size_t size_ = 0;
size_t array_size = 0;
};

/**
Expand Down
4 changes: 2 additions & 2 deletions src/dpp/dave/cipher_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@

namespace dpp::dave {

std::unique_ptr<cipher_interface> create_cipher(dpp::cluster& cl, const encryption_key& encryptionKey)
std::unique_ptr<cipher_interface> create_cipher(dpp::cluster& cl, const encryption_key& key)
{
auto cipher = std::make_unique<openssl_aead_cipher>(cl, encryptionKey);
auto cipher = std::make_unique<openssl_aead_cipher>(cl, key);
return cipher->is_valid() ? std::move(cipher) : nullptr;
}

Expand Down
28 changes: 14 additions & 14 deletions src/dpp/dave/cipher_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,25 @@ class cipher_interface { // NOLINT

/**
* @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
* @param ciphertext_buffer_out Output buffer of ciphertext
* @param plaintext_buffer Input buffer for plaintext
* @param nonce_buffer Input nonce/IV
* @param additional_data Additional data for GCM AEAD encryption
* @param tag_buffer_out 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;
virtual bool encrypt(byte_view ciphertext_buffer_out, const_byte_view plaintext_buffer, const_byte_view nonce_buffer, const_byte_view additional_data, byte_view tag_buffer_out) = 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
* @param plaintext_buffer_out Output buffer for plaintext
* @param ciphertext_buffer Input buffer for ciphetext
* @param tag_buffer AEAD Tag for verification
* @param nonce_buffer Nonce/IV
* @param additional_data 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;
virtual bool decrypt(byte_view plaintext_buffer_out, const_byte_view ciphertext_buffer, const_byte_view tag_buffer, const_byte_view nonce_buffer, const_byte_view additional_data) = 0;

protected:

Expand All @@ -94,10 +94,10 @@ class cipher_interface { // NOLINT

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

} // namespace dpp::dave

Loading

0 comments on commit 5c6dcec

Please sign in to comment.