summaryrefslogtreecommitdiff
path: root/src/encryption.c
blob: f7fdcd41381bd2ba99c4f9da0130f3423cf47116 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "encryption.h"
#include "shared.h"

#include <sodium.h>

#include <stdarg.h>
#include <errno.h>
#include <error.h>
#include <stdio.h>

int checkSodium(void) {
    int ret = sodium_init();
    if(ret < 0)
        error(1, ENOTSUP, "Couldn't initialize sodium for some reason. Quitting...");

    return ret;
}

// To encrypt:
// 1- Create a temp file with the correct name in the root folder of the partition being encrypted
    // 1.1- Detect the partition and find the root folder
    // 1.2- Create the temp file with the correct name 
// 2- Encrypt the file's contents to the temp file
    // 2.1- Open the file
    // 2.2- Stream the file's contents into some encryption algo
    // 2.3- Pipe the output of the encryption into the temp file
// 3- Once the file has been encrypted, hard link it back to the original location
// 4- Delete the original file
// 5- Delete the temp file


int maketmp(const char *dest, const char *format, ...) {
    va_list ap;
    va_start(ap, format);

    

    va_end(ap);
    return 0;
}



int main() {
    char *test = NULL;
    
    // Turns out GNU did this for me, and I trust their code more than my own, so I'm using this now
    if(asprintf(&test, "We do a little trolling %d", 900) < 0)
        error(1, ENOMEM, "asprintf call failed");

    printf("%s\n", test);
    
    return 0;
}