some code cleaning

master
leonnicolas 4 years ago
parent 5b0eeb5bd8
commit 193a509885

@ -4,7 +4,7 @@ void mycryptwrapper_init(){
/* Version check should be the very first call because it
makes sure that important subsystems are initialized.
#define NEED_LIBGCRYPT_VERSION to the minimum required version. */
*/
if (!gcry_check_version (GCRYPT_VERSION))
{
fprintf (stderr, "libgcrypt is too old (need %s, have %s)\n",
@ -36,24 +36,11 @@ void mycryptwrapper_print(const void * buf, size_t len){
int check_sha256_tag(uint8_t * ptr, size_t file_len){
uint8_t * calc_hash = malloc(HASH_SIZE);
gcry_md_hash_buffer(algo,calc_hash,ptr,file_len-HASH_SIZE);
/*printf("hash\n");
mycryptwrapper_print(calc_hash,32);
printf("HASH in file:\n");
for (int i = 0 ; i< HASH_SIZE; i++){
printf("%02x ", ptr[file_len+i-HASH_SIZE]);
}
printf("file:\n%s",(char* )ptr);
*/
for (int i=0 ; i< HASH_SIZE; i++){
//printf("%02x ", calc_hash[i]);
if (calc_hash[i] != ptr[i+file_len-HASH_SIZE]){
free(calc_hash);
// printf("no match\n");
return 0;
}
}
return 1;
}

@ -104,7 +104,7 @@ int main(int argc, char const *argv[]) {
//return 0;
success=1;
#pragma omp exitregion
}
}// decryption succesfull end
free(iv);
free(decrypted_buf);
gcry_cipher_close(dhd);

@ -8,6 +8,82 @@
#include "cryptwrapper.h"
#include <argp.h>
const char *argp_program_version =
"create Rainbow 0.1";
/* Program documentation. */
static char doc[] =
"I wonder for what this is";
static struct argp_option options[] = {
{"verbose", 'v', 0, 0, "Produce verbose output" },
{"quiet", 'q', 0, 0, "Don't produce any output" },
{"output", 'o', "FILE", 0, "Output to FILE instead of <name of input file>.encry" },
{"authentication_mode", 'm', "MODE", 0, "default MtE (only one implemented)" },
{"password", 'p', "clear_pw", 0, "password used for encryption" },
{ 0 }
};
struct arguments
{
char *authentication_mode;
char *output_file;
char *input_file;
char *clear_pw;
int silent, verbose;
int use_output_file, use_clear_pw;
};
/* Parse a single option. */
static error_t
parse_opt (int key, char *arg, struct argp_state *state)
{
/* Get the input argument from argp_parse, which we
know is a pointer to our arguments structure. */
struct arguments *arguments = state->input;
switch (key)
{
case 'q': case 's':
arguments->silent = 1;
break;
case 'v':
arguments->verbose = 1;
break;
case 'o':
arguments->output_file = arg;
arguments->use_output_file = 1;
break;
case 'p':
arguments->use_clear_pw = 1;
arguments->clear_pw = arg;
break;
case ARGP_KEY_ARG:
if (state->arg_num >= 1)
/* Too many arguments. */
argp_usage (state);
arguments->input_file = arg;
break;
case ARGP_KEY_END:
if (state->arg_num < 1)
/* Not enough arguments. */
argp_usage (state);
break;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
/* Our argp parser. */
static struct argp argp = { options, parse_opt, 0 , doc };
//parsing args set up end---------------------------------------------------------------
int main(int argc, char const *argv[]) {
if (argc < 3){
printf("please select file and pw\n");

@ -16,5 +16,5 @@ size_t writeHashHumanReadable(FILE *fptr, struct s_rainbowvalue256 rs[BULKSIZE])
return 0;
}
size_t writeHashBase64(FILE *fptr,size_t num ,struct s_rainbowvalue256 rs[BULKSIZE]){
return 0;
}
Loading…
Cancel
Save