ssn-installer/src/main.c

47 lines
1 KiB
C
Raw Normal View History

2018-07-17 14:05:22 +02:00
#include <errno.h>
#include <stdio.h>
2018-07-17 14:05:22 +02:00
#include <string.h>
//Import our code
#include "decrypt.h"
2018-07-17 17:19:13 +02:00
#include "fileReader.h"
2018-07-24 18:10:07 +02:00
#include "utils/min.h"
2018-07-17 14:05:22 +02:00
int main(int argc, unsigned char *argv[]) {
printf("Hello World!\n");
2018-07-24 18:10:07 +02:00
//TODO: verify argv and assign it to variables
2018-07-17 14:05:22 +02:00
2018-07-17 15:05:57 +02:00
//Initialise file reader
2018-07-24 17:07:47 +02:00
initFileReader("1234", 0UL);
2018-07-17 15:05:57 +02:00
//Skip header (30 bytes + additional length)
2018-07-24 17:07:47 +02:00
char* fileHeader = getBytes(30UL);
printf(fileHeader);
2018-07-24 18:10:07 +02:00
//TODO: check that header is correct
2018-07-17 15:05:57 +02:00
//Initialise decryption (pass decryption keys)
2018-07-24 18:10:07 +02:00
initDecryptor(0, 0, 0);//TODO
2018-07-17 15:05:57 +02:00
//Skip 12-byte encryption header
2018-07-24 18:10:07 +02:00
char* encryptionHeader = getBytes(12UL);
decrypt(encryptionHeader, 12);
2018-07-17 15:05:57 +02:00
2018-07-24 18:10:07 +02:00
//Read actual file
unsigned long remainingBytes = 0xFFFF;//TODO
while (remainingBytes > 0) {
const unsigned long chunkSize = min(0xFF, remainingBytes);
char* chunk = getBytes(chunkSize);
remainingBytes -= chunkSize;
2018-07-17 15:05:57 +02:00
2018-07-24 18:10:07 +02:00
decrypt(chunk, chunkSize);
//Decompress file
//TODO
//Optionally perform xdelta3
//TODO
}
2018-07-17 15:05:57 +02:00
2018-07-17 14:05:22 +02:00
return 0;
}