Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ int aes256gcm_crypt(STREAM *in, FILE *out, unsigned char key[],
abort();
}

off_t file_size = in->expected_size;
off_t file_size = in->expected_size ? in->expected_size : in->actual_size;
if (!encrypt) {
file_size -= AES256_GCM_TAG_LENGTH;
}
Expand Down
10 changes: 7 additions & 3 deletions omut.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,17 @@ void print_crypto_material(char *type, unsigned char *material, int len) {
int main(int argc, char **argv) {
int opt;
int direction = ENCRYPT;
bool insecure = false;
char *output_path = NULL;

while ((opt = getopt(argc, argv, ":do:")) != -1) {
while ((opt = getopt(argc, argv, ":dko:")) != -1) {
switch (opt) {
case 'd':
direction = DECRYPT;
continue;
case 'k':
insecure = true;
continue;
case 'o':
output_path = optarg;
continue;
Expand Down Expand Up @@ -97,9 +101,9 @@ int main(int argc, char **argv) {
key = gcry_random_bytes_secure(AES256_GCM_KEY_LENGTH,
GCRY_VERY_STRONG_RANDOM);
gcry_create_nonce(nonce, AES256_GCM_NONCE_LENGTH);
in_stream = stream_open(raw_url);
in_stream = stream_open(raw_url, insecure);
} else {
in_stream = stream_open(parsed_url);
in_stream = stream_open(parsed_url, insecure);
}

free(parsed_url);
Expand Down
7 changes: 6 additions & 1 deletion stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ char *parse_aesgcm_url(char *url, unsigned char *nonce, size_t nonce_size,
return NULL;
}

STREAM *stream_open(const char *url) {
STREAM *stream_open(const char *url, bool insecure) {
CURLcode res;

STREAM *stream;
Expand All @@ -157,6 +157,11 @@ STREAM *stream_open(const char *url) {
curl_easy_setopt(hd, CURLOPT_WRITEFUNCTION, write_callback);
curl_easy_setopt(hd, CURLOPT_WRITEDATA, (void *)stream);

if (insecure) {
curl_easy_setopt(hd, CURLOPT_SSL_VERIFYHOST, 0L);
curl_easy_setopt(hd, CURLOPT_SSL_VERIFYPEER, 0L);
}

res = curl_easy_perform(hd);
if (res != CURLE_OK) {
free(stream);
Expand Down
2 changes: 1 addition & 1 deletion stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ struct stream_data {
typedef struct stream_data STREAM;

size_t stream_read(void *buffer, size_t bytes, STREAM *stream);
STREAM *stream_open(const char *url);
STREAM *stream_open(const char *url, bool insecure);
char *parse_aesgcm_url(char *url, unsigned char *nonce, size_t nonce_size,
unsigned char *key, size_t key_size);