PostLAMessaging.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //
  2. // Created by miti on 2019-12-28.
  3. //
  4. #ifndef APACHE_PHP_EXTENSION_POSTLAMESSAGING_H
  5. #define APACHE_PHP_EXTENSION_POSTLAMESSAGING_H
  6. #include "PostLAMessages.pb.h"
  7. #include "ProtobufMessageRW.h"
  8. #include <string>
  9. #include <vector>
  10. class PostLAMessaging {
  11. uint8_t key[16];
  12. ProtobufMessageRW headersChannel;
  13. ProtobufMessageRW dataChannel;
  14. uint32_t aes_gcm_wrapper(int enc, uint8_t *plaintext, uint32_t plaintext_length, uint8_t *ciphertext,
  15. uint32_t *ciphertext_length);
  16. uint32_t encrypt_decrypt_msgs(int encrypt_decrypt, std::vector <std::vector<unsigned char>> &input_msgs,
  17. std::vector <std::vector<unsigned char>> &output_msgs);
  18. void create_vector_from_protobuf(decryptor_to_extension_msg &protobuf_msg,
  19. std::vector <std::vector<unsigned char>> &output_vector);
  20. void create_protobuf_from_vector(std::vector <std::vector<unsigned char>> &input_vector,
  21. extension_to_decryptor_msg &protobuf_msg);
  22. public:
  23. void set_la_symmetric_key(uint8_t *given_key);
  24. void set_headers_fd(int given_fd);
  25. void set_data_fd(int given_fd);
  26. uint32_t receive_header_from_decryptor(std::string &output_msg);
  27. uint32_t receive_data_from_decryptor(std::vector <std::vector<unsigned char>> &output_msgs);
  28. uint32_t send_data_to_decryptor(std::vector <std::vector<unsigned char>> &plaintext_msg_list);
  29. };
  30. #endif //APACHE_PHP_EXTENSION_POSTLAMESSAGING_H