some comment corrections
[delutions.git] / tc / tc.c
blob95865bc3cc703afa1767e9b7ae2a3384ca4abc27
1 #include <stdlib.h>
2 #include <stdio.h>
4 #include "pbkdf2.h"
5 #include "crypt.h"
6 // #include "hash_wrappers.h"
7 // #include "hmac.h"
9 #define VERSION 0.1
11 #define TC_HIDDEN_VOLUME_OFFSET 1536
12 #define TC_SALT_SZ 64
13 #define TC_HEADER_SZ 448
15 char * name;
17 void usage() {
18 fprintf(stderr,"trueCRACK v%f\m",VERSION);
19 fprintf(stderr,"usage:\n\t%s tc_volume wordlist starting_word",name);
20 exit(EXIT_FAILURE);
23 int main (int argc, char ** argv) {
24 name = argv[0];
25 if (argc<4)
26 usage();
28 FILE * tc_volume_file = fopen(argv[1], "rb");
29 FILE * wordlist_file = fopen(argv[2], "r" );
31 uint8_t salt [TC_SALT_SZ+4];
32 uint8_t header [TC_HEADER_SZ];
33 #ifdef TC_HIDDEN
34 uint8_t header_hidden [TC_HEADER_SZ];
35 #endif
37 size_t s = fread(tc_volume_file,1,TC_SALT_SZ,salt);
38 if (s < TC_SALT_SZ) {
39 printf("[%s:%d] volume salt read failed");
40 exit(EXIT_FAILURE);
43 s = fread(tc_volume_file,1,TC_HEADER_SZ,header);
44 if (s < TC_HEADER_SZ) {
45 exit(EXIT_FAILURE);
48 #ifdef TC_HIDDEN
49 fseek ( tc_volume_file , TC_HIDDEN_VOLUME_OFFSET , SEEK_SET );
50 s = fread(tc_volume_file,1,TC_HEADER_SZ,header_hidden);
51 if (s < TC_HEADER_SZ) {
52 exit(EXIT_FAILURE);
54 #endif
56 fclose(tc_volume_file);
58 char password [TC_PASSWORD_MAX];
59 uint8_t dec_buff[TC_HEADER_SZ];
61 //TODO: seek to starting_word
62 // check words until worklist ends.
63 while ( !feof(wordlist_file) ) {
65 //read line??
66 read_line(wordlist_file, password);
67 PBKDF2(hmac_ctx, password, sizeof(password), salt, sizeof(salt), iterations, derived_key, derived_key_len);
69 decrypt(enc_ctx, derived_key, derived_key_len, header, TC_HEADER_SZ, dec_buff, TC_HEADER_SZ);
70 bool valid_pass = check_tc_header(dec_buff);
72 #ifdef TC_HIDDEN
73 decrypt(enc_ctx, derived_key, derived_key_len, header_hidden, TC_HEADER_SZ, dec_buff, TC_HEADER_SZ);
74 valid_pass |= check_tc_header(dec_buff);
75 #endif
77 if (valid_pass) {
78 printf("possible password: %s\n",(char *)password);
82 exit(EXIT_SUCCESS);