2020-09-10 21:33:37 -05:00
|
|
|
#ifndef __PURR_H_
|
|
|
|
#define __PURR_H_
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#include <bearssl.h>
|
|
|
|
|
|
|
|
#define HTTP_PORT 80
|
|
|
|
#define HTTPS_PORT 443
|
|
|
|
|
|
|
|
#define HEADER_MAX_LEN 8192
|
|
|
|
|
2020-09-13 11:32:28 -05:00
|
|
|
#define NET_BLOCK_SIZE 512
|
|
|
|
|
2020-09-10 21:33:37 -05:00
|
|
|
#define KEY_LEN 32
|
|
|
|
#define IV_LEN br_aes_big_BLOCK_SIZE
|
|
|
|
|
2020-09-13 16:08:52 -05:00
|
|
|
#define RANDOMIZE_IV
|
2020-09-13 16:05:43 -05:00
|
|
|
#define ENCODE_BASE_64
|
2020-09-13 18:17:58 -05:00
|
|
|
#define DECODE_BASE_64
|
2020-09-12 20:55:46 -05:00
|
|
|
|
2020-09-10 21:33:37 -05:00
|
|
|
struct connection_information {
|
|
|
|
br_sslio_context *ioc;
|
|
|
|
br_ssl_client_context *sc;
|
|
|
|
const char *request;
|
|
|
|
size_t request_size;
|
2020-09-13 11:32:28 -05:00
|
|
|
struct mmap_file *input, *output;
|
2020-09-10 21:33:37 -05:00
|
|
|
int socket;
|
|
|
|
bool send, ssl;
|
|
|
|
bool no_strip, debug;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct transmission_information {
|
|
|
|
br_sslio_context *ioc;
|
2020-09-13 11:32:28 -05:00
|
|
|
struct mmap_file *file;
|
2020-09-10 21:33:37 -05:00
|
|
|
int socket;
|
|
|
|
bool no_strip, debug, ssl;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* sockets.c */
|
|
|
|
int socket_read(void *, uint8_t *, size_t);
|
|
|
|
int socket_write(void *, const uint8_t *, size_t);
|
|
|
|
|
|
|
|
/* urls.c */
|
|
|
|
int clean_up_link(const char *, char *, char *, char *);
|
2020-09-13 18:17:03 -05:00
|
|
|
int get_encryption_params(char *, uint8_t **, uint8_t **);
|
2020-09-10 21:33:37 -05:00
|
|
|
int host_connect(const char *, const char *, bool);
|
|
|
|
|
|
|
|
/* files.c */
|
2020-09-13 11:32:28 -05:00
|
|
|
size_t ssl_to_mmap(struct transmission_information);
|
|
|
|
size_t mmap_to_ssl(struct transmission_information);
|
2020-09-10 21:33:37 -05:00
|
|
|
|
|
|
|
/* comm.c */
|
|
|
|
int send_and_receive(struct connection_information *);
|
|
|
|
|
|
|
|
/* formats.c */
|
2020-09-13 18:17:03 -05:00
|
|
|
char *print_hex(const uint8_t *, int, bool);
|
|
|
|
int decode_hex(const char *, uint8_t *, int);
|
2020-09-10 21:33:37 -05:00
|
|
|
|
|
|
|
#endif // __PURR_H_
|