コード例 #1
0
ファイル: main.cpp プロジェクト: keitee/kb
int main()
{
   encrypt_file("sample.txt", "sample.txt.enc", "cppchallenger");
   decrypt_file("sample.txt.enc", "sample.txt.dec", "cppchallenger");

   encrypt_file("sample.txt", "cppchallenger");
   decrypt_file("sample.txt", "cppchallenger");
}
コード例 #2
0
ファイル: database.c プロジェクト: Maffblaster/steel
//Encrypt database file with passphrase and
//remove lock file.
void db_close(const char *passphrase)
{	
	char *path = NULL;
	
	path = read_path_from_lockfile();
	
	if(path == NULL) {
		fprintf(stderr, "Failed to read the database path.\n");
		return;
	}

	if(!db_file_exists(path)) {
		fprintf(stderr, "%s: does not exists\n", path);
		free(path);
		return;
	}
	
	if(!encrypt_file(path, passphrase)) {
		fprintf(stderr, "Encryption failed\n");
		free(path);
		return;
	}

	db_remove_lockfile();
	free(path);
}
コード例 #3
0
ファイル: spud.c プロジェクト: carriercomm/crypto
/*
* Function: process_file
* ----------------------
* Attempt to either encrypt or decrypt the infile using the key and nonce
* provided. If there is an error, exit the program.
*/
void
process_file(char *command, char *infile, char *outfile, unsigned char *key,
             unsigned char *nonce)
{
    size_t r = 0;

    if (strcmp(command, "encrypt") == 0)
    {
        r = encrypt_file(infile, outfile, key, nonce);
    }
    else if (strcmp(command, "decrypt") == 0)
    {
        r = decrypt_file(infile, outfile, key);
    }
    else
    {
        usage();
    }

    if (r == 0)
    {
        printf("Successfully %sed file %s.\n", command, infile);
    }
    else
    {
        fprintf(stderr, "Could not %s file %s.\n", command, infile);
        exit(EXIT_FAILURE);
    }
}
コード例 #4
0
ファイル: gencrack.c プロジェクト: benwaffle/ctf
int main() {
    FILE *enc = fopen("crack.enc","w");
    printf("password > ");

    char pw[16];
    fgets(pw, 16, stdin);
    unsigned char digest[16];
    hash_password(digest, pw);

    encrypt_file(file, sizeof(file), enc, digest);
}
コード例 #5
0
ファイル: main.cpp プロジェクト: keitee/kb
void encrypt_file(
   fs::path const & filepath,
   std::string_view password)
{
   auto temppath = fs::temp_directory_path() / filepath.filename();

   encrypt_file(filepath, temppath, password);

   fs::remove(filepath);
   fs::rename(temppath, filepath);
}
コード例 #6
0
ファイル: encrypt_file.c プロジェクト: tkpclark/perseus
main(int argc,char **argv)
{
	
	if(argc!=4)
	{
		printf("arg1: encrypt:1 decrypt:0\n");
		printf("arg2:filename\n");
		printf("arg3:key\n");
	}
	encrypt_file(atoi(argv[1]),argv[2],argv[3]);
}
コード例 #7
0
ファイル: aes_serial.c プロジェクト: mxwlone/aes-cuda
int main(int argc, char *argv[]) {
	if (argc < 3 || argc > 4) {
		printf("Usage: aes_serial.exe <input file> <output file> [--silent]\n", argv[0]);
		return 1;
	}

	if (argc == 4)
		if (!strcmp(argv[3], "--silent"))
			silent = 1;


	double cpu_time_used;
	cpu_time_used = encrypt_file(argv[1], argv[2]);
	printf("Execution time: %6.9f seconds\n", cpu_time_used);

	return 0;
}
コード例 #8
0
ファイル: main.c プロジェクト: CrossCRS/pspsdk
int main(int argc, char *argv[])
{
    int i, ret;

    pspDebugScreenInit();
    sceCtrlSetSamplingCycle(0);
    sceCtrlSetSamplingMode(PSP_CTRL_MODE_DIGITAL);

    printf("Save Encrypt Sample\n");
    printf("by Jim Paris and psp123\n\n");

    printf(" Will encrypt: %s\n", plaintext);
    printf("    Using key:");
    if(gamekey) {
        for (i = 0; i < 0x10; i++)
            printf(" %02x", gamekey[i]);
    } else {
        printf(" none");
    }
    printf("\n\n");
    printf("  Output file: %s\n", encrypted);
    printf("Update hashes: %s\n\n", paramsfo);
    printf("Press X to continue, or O to quit.\n\n");

    if (waitbutton(PSP_CTRL_CROSS | PSP_CTRL_CIRCLE) & PSP_CTRL_CIRCLE)
        goto out;

    printf("Working...\n\n");

    ret = encrypt_file(plaintext, encrypted, datafile, paramsfo, gamekey);
    if(ret < 0) {
        printf("Error: encrypt_file() returned %d\n\n", ret);
    } else {
        printf("Successfully wrote %d bytes to\n", ret);
        printf("  %s\n", encrypted);
        printf("and updated hashes in\n");
        printf("  %s\n\n", paramsfo);
    }

    printf("Press any button to quit\n");
    waitbutton(-1);

out:
    sceKernelExitGame();
    return 0;
}
コード例 #9
0
ファイル: AppMain.cpp プロジェクト: ZahraTarkhani/SGX_Crypt
int main(int argc,char* argv[]){
	
	int file_size=0;
	if (argc==1){
		cout<< "no file selected !"<<endl;
	}
	fstream myfile(reinterpret_cast<const char*>(argv[1]),ios::out | ios::in | ios::trunc);
	myfile<<"welcome to SGX_Crypt!!!\nThis is a simple test\nfirst encrypt then decrypt of the same file"<<endl;
	init_Enclave();
	ecall_key_iv_generator(global_eid);
	encrypt_file(reinterpret_cast<const char*>(argv[1]));
	decrypt_file(reinterpret_cast<const char*>(argv[1]));

	ecall_cleanup(global_eid);
	myfile.close();
	destroy_Enclave();
	return 0;
}
コード例 #10
0
int main(int argc, char** argv)
{
    try
    {
        FileSettings settings{argv[0]};

        try
        {
            settings.parse(argc, argv);
        }
        catch (const boost::program_options::error& e)
        {
            settings.usage_error(e);
            return 1;
        }

        if (settings.exit_with_usage)
        {
            settings.usage();
            return 0;
        }

        encrypt_file(settings);
    }
    catch (const aes::Error& e)
    {
        std::cerr << e;
        return 1;
    }
    catch (const std::exception& e)
    {
        std::cerr << e.what() << "\n";
        return 1;
    }
    return 0;
}
コード例 #11
0
ファイル: aztecc.cpp プロジェクト: tedher/aztecc
int main(int argc, char *argv[])
{
	timer t;

	t.set_print_mode(HMS_MODE);

	bencrypt=false;
	bdecrypt=false;
	bgen_pk=false;
	bfind_point=false;
	btest_point=false;
	bwipe_file=false;
	bhelp=false;
	bfile=false;
	buser=false;
	bversion=false;
	bks=false;

	for(int i=1;i<argc;i++)
	{
  		if((strcmp(argv[i],"-e")==0) || (strcmp(argv[i],"--encrypt")==0))
    	{
	      if (i+1 < argc)
				if(!is_option(argv[i+1]))
		  		{
		    		bencrypt=true;
		    		filename=argv[i+1];
				   bfile=true;
		    		i++;
		    		continue;
		  		}
			banner();
	      cerr<<"\nAZTECC ERROR : No filename given."<<endl;
	      exit(1);
	    }
	  
	  if((strcmp(argv[i],"-d")==0) || (strcmp(argv[i],"--decrypt")==0))
	  {
	  		if (i+1 < argc)
				if(!is_option(argv[i+1]))
		  		{
		    		bdecrypt=true;
		    		filename=argv[i+1];
		    		bfile=true;
		    		i++;
		    		continue;
		  		}
	      banner();
	      cerr<<"\nAZTECC ERROR : No filename given."<<endl;
	      exit(1);
    }
	  
	  if((strcmp(argv[i],"-g")==0) || (strcmp(argv[i],"--genkey")==0))
	    	bgen_pk=true;
	  
	  if((strcmp(argv[i],"-k")==0) || (strcmp(argv[i],"--keysize")==0))
	  {
	  		if (i+1 < argc)
				if(!is_option(argv[i+1]))
		  		{
		    		bks=true;
		    		keysize=argv[i+1];
		    		i++;
		    		continue;
		  		}
			banner();
	      cerr<<"\nAZTECC ERROR : No valid keysize given."<<endl;
	      exit(1);
	    }
	  
	  if((strcmp(argv[i],"-u")==0) || (strcmp(argv[i],"--user")==0))
     {
	  		if (i+1 < argc)
				if(!is_option(argv[i+1]))
		  		{
		    		username=argv[i+1];
		    		buser=true;
		    		i++;
		    		continue;
		  		}
			banner();
	      cerr<<"\nAZTECC ERROR : No valid username given."<<endl;
	      exit(1);
	  }
	  
	  if((strcmp(argv[i],"-pk")==0) || (strcmp(argv[i],"--pubkey")==0))
	  {
	  		if(!is_option(argv[i+1]))
			{
		  		pubkey=argv[i+1];
		  		i++;
		  		continue;
			}
			banner();
	      cerr<<"\nAZTECC ERROR : No public key filename given."<<endl;
	      exit(1);
	  }

		// find and test point
	  if((strcmp(argv[i],"-f")==0) || (strcmp(argv[i],"--find")==0))
	    bfind_point=true;
	  if((strcmp(argv[i],"-t")==0) || (strcmp(argv[i],"--test")==0))
	    btest_point=true;
	  
	  if((strcmp(argv[i],"-h")==0) || (strcmp(argv[i],"--help")==0))
	    bhelp=true;
	  if((strcmp(argv[i],"-v")==0) || (strcmp(argv[i],"--version")==0))
	    bversion=true;
	  if((strcmp(argv[i],"-w")==0) || (strcmp(argv[i],"--wipe")==0))
	  {
	  		if (i+1 < argc)
				if(!is_option(argv[i+1]))
		  		{
		    		filename=argv[i+1];
		    		bwipe_file=true;
		    		bfile=true;
		    		i++;
		    		continue;
		  		}
			banner();
	      cerr<<"\nAZTECC ERROR : No filename given."<<endl;
	      exit(1);
	    }
	}

	if((bencrypt) && (buser) && (bfile) && (!bdecrypt) && 
	   (!bgen_pk) && (!bfind_point) && (!btest_point) && 
	   (!bhelp) && (!bwipe_file) && (!bversion) && (!bks))
	{
		 t.start_timer();
	    encrypt_file(pubkey,username,filename);
		 t.stop_timer();
		 cout<<"\nElapsed time : "<<t<<endl;
	    exit(0);
	}
	
	if((bdecrypt) && (bfile) && (!buser) && (!bencrypt) && 
		(!bgen_pk) && (!bfind_point) && (!btest_point) &&
 		(!bhelp) && (!bwipe_file) && (!bversion) && (!bks))
	{
		 t.start_timer();
	    decrypt_file(pubkey,filename);
		 t.stop_timer();
		 cout<<"\nElapsed time : "<<t<<endl;
	    exit(0);
	}
	
	if((bgen_pk) && (bks) && (!buser) && (!bencrypt) && (!bdecrypt) && 
	   (!bfind_point) && (!btest_point) && (!bhelp) && (!bwipe_file) && (!bversion))
	{
	    if(strcmp(keysize,"160")==0)
	      blocksize=20;
	    else if(strcmp(keysize,"192")==0)
	      blocksize=24;
	    else
	    {
			banner();
			cerr<<"\nAZTECC ERROR : Keysize not valid.\n";
			exit(1);
	    }
	    
	    gen_pubkey(pubkey,blocksize);
	    exit(0);
	}
	
	if((bfind_point) && (!bencrypt) && (!bdecrypt) && (!bgen_pk) && 
	   (!btest_point) && (!bhelp) && (!bwipe_file) && (!bversion) &&
   	(!buser) && (!bks))
	{
			find_point();
			exit(0);
	}
	
	if((btest_point) && (!bencrypt) && (!bdecrypt) && (!bgen_pk) && 
		(!bfind_point) && (!bhelp) && (!bwipe_file) && (!bversion) &&
		(!buser) && (!bks))
	{
			test_point();
			exit(0);
	}

	if((bwipe_file) && (bfile) && (!bencrypt) && (!bdecrypt) && (!bgen_pk) && 
		(!bfind_point) && (!btest_point) && (!bhelp) && (!bversion) &&
     	(!buser) && (!bks))
	{
			wipe_file(filename);
			exit(0);
	}


	if((bversion) && (!bencrypt) && (!bdecrypt) && (!bgen_pk) && 
		(!bfind_point) && (!btest_point) && (!bhelp) && (!bwipe_file) &&
		(!buser) && (!bks))
	{
			version();
			exit(0);
	}

	if(bhelp)
	{
		usage();
		exit(0);
	}
  
  else
    usage();			
  return 0;
}
コード例 #12
0
ファイル: aes-encrypt.c プロジェクト: mike-carter/aes-encrypt
/**
 * Program main function.
 *
 * We leave the meat of the processing to the above functions. Here, we 
 * simply process the command line arguments.
 */
int
main(int argc, char *argv[])
{
  int opt;
  char *out_name;
  FILE *keyfd, *infd, *outfd;
  
  /* Parse command options */
  while ((opt = getopt_long(argc, argv, opts_str, long_opts, NULL)) != -1) {
	switch (opt) { 
	  //case 'f': flags.force = true; break;
	  
	  //case 'b': flags.burn_file = true; break;

	  /* Verbose option */
	case 'v': flags.verbose = true; break;

	  /* Key size option */
	case 's': flags.key_size = atoi(optarg);
	  if (flags.key_size != key_16_bytes
		  && flags.key_size != key_24_bytes
		  && flags.key_size != key_32_bytes) {
		exit_error(PROGRAM_NAME ": Error: Invalid key size specified.\n");
	  }
	  break;

	  /* Key file name option */
	case 'k': flags.key_file_name = optarg; break;

	  /* Specified output directory */
	case 'd': flags.out_directory = optarg; break;
		
	default:
	  exit_error(PROGRAM_NAME ": Error: Invalid option indicated.\n");
	  break;
	}
  }

  /* Generate Encryption Key */
  VERBOSE("Generating encryption key.\n");
  key_init(&encrypt_key, flags.key_size);

  /* Open file to save key */
  /* Use default file name if not specified by user */
  if (flags.key_file_name == NULL) {
	VERBOSE("Key file not specified. Creating file '" DEFAULT_KEY_FILE "'.\n");
	flags.key_file_name = DEFAULT_KEY_FILE;
  }

  /* Save key to file */
  VERBOSE("Saving encryption key to file '%s'.\n", flags.key_file_name);
  keyfd = fopen(flags.key_file_name, "w");
  if (keyfd == NULL) {
	exit_error(PROGRAM_NAME ": Error: Could not create encryption key" \
			   " file '%s'.\n",\
			   flags.key_file_name);
  }
  save_key(&encrypt_key, keyfd);
  fclose(keyfd); /* Close file */

  /* Encrypt specified files using newly generated key */

  if ((optind == argc) || (argv[optind][0] == '-')) {
	/* Encrypt standard input if no file specified. */
    VERBOSE("Reading from Standard Input.\n");
	infd = stdin;

	outfd = fopen(DEFAULT_OUT_FILE OUTPUT_EXTENSION, "wb"); 

	encrypt_file(infd, outfd, &encrypt_key);
	optind++;
  }

  for (; optind < argc; optind++) {
	infd = fopen(argv[optind], "rb"); /* Open file for reading */
	
	if (infd == NULL) {
	  fprintf(stderr, PROGRAM_NAME ": Error: Failed to open file '%s'.\n",
			  argv[optind]);
	}
	else {
	  out_name = create_out_file_name(argv[optind]);
	  outfd = fopen(out_name, "wb"); 

	  if (outfd == NULL) {
		fprintf(stderr, PROGRAM_NAME ": Error: Failed to create file '%s'.\n",
				out_name);
		fclose(infd);
	  }
	  else {
		VERBOSE("Encrypting file '%s'...\n", argv[optind]);
		if (encrypt_file(infd, outfd, &encrypt_key)) {
		  printf(PROGRAM_NAME ": Cipher '%s' created from file '%s'.\n",
				 out_name, argv[optind]);
		}
		fclose(infd);
		fclose(outfd);
	  }
	  free(out_name);
	}
  }

  printf(PROGRAM_NAME ": Encryption complete. Key stored at file '%s'.\n",
		 flags.key_file_name);
  
  exit(EXIT_SUCCESS);
}
コード例 #13
0
ファイル: main.c プロジェクト: MatthewDarnell/SCSS
int main(int argc, char *argv[])
{
    if(argc < 5){
        fprintf(stderr, "Usage:\n./scss </path/to/plaintext> </path/to/output-encrypted> <encrypt/decrypt> <mode>\n./scss </path/to/encrypted> </path/to/output-decrypted> <encrypt/decrypt> <mode>\nValid Modes: [ecb, cbc, ofb, cfb]\n");
        return -1;
    }

    const char  *inputFile   = argv[1],
                *outputFile  = argv[2],
                *operation   = argv[3],
                *mode        = argv[4];

    if(strcmp(operation, "encrypt") != 0 && strcmp(operation, "decrypt") != 0) {
      fprintf(stderr, "Invalid Operation. Valid Modes: [encrypt, decrypt]\n");
      return -2;
    }

    int dOperation = 0;
    if(strcmp(operation, "decrypt") == 0)
      dOperation = 1;

    if(strcmp(mode, "ecb") != 0 && strcmp(mode, "cbc") != 0 && strcmp(mode, "ofb") != 0 && strcmp(mode, "cfb") != 0) {
      fprintf(stderr, "Invalid Mode. Valid Modes: [ecb, cbc, ofb, cfb]\n");
      return -3;
    }

    int dMode = 0; //default ecb
    if(strcmp(mode, "cbc") == 0){
      dMode = 1;
    }
    else if(strcmp(mode, "ofb") == 0){
      dMode = 2;
    }
    else if(strcmp(mode, "cfb") == 0){
      dMode = 3;
    }
    struct lfsr l_17, l_25;
    int num_bits_1 = 17,
    num_bits_2 = 25;
    int taps_1[17] = { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, //x^17 + x^2 + 1
    taps_2[25] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1 }; //x^25 + x^21 + x^20 + x^10 + 1
    setup_lfsr(&l_17, &num_bits_1, taps_1);
    setup_lfsr(&l_25, &num_bits_2, taps_2);

    //Some random 40-bit Key
    BYTE key[40] = {
    1,0,0,0,0,0,0,1,0,0,
    1,0,0,0,0,1,0,0,0,0,
    1,0,0,0,0,0,0,1,0,0,
    1,0,0,0,0,0,0,1,0,0
    };


    //some i.v.
    unsigned char initialization_vector = 0xa2;


    struct lfsr *init_arr[2] = { &l_17, &l_25 };
    init_with_key(init_arr, 2, key);

    if(dOperation == 0)
      encrypt_file(inputFile, &l_17, &l_25, outputFile, &dMode, initialization_vector);
    else
      decrypt_file(inputFile, &l_17, &l_25, outputFile, &dMode, initialization_vector);

    return 0;
}
コード例 #14
0
ファイル: main.c プロジェクト: 173210/ppsspp
int main(int argc, char *argv[])
{
	int i;
	pspDebugScreenInit();

	SceUID mod = pspSdkLoadStartModule ("flash0:/kd/chnnlsv.prx",PSP_MEMORY_PARTITION_KERNEL); 
	if (mod < 0) {
		printf("Error 0x%08X loading/starting chnnlsv.prx.\n", mod);
	}

	mod = pspSdkLoadStartModule ("kernelcall.prx",PSP_MEMORY_PARTITION_KERNEL); 
	if (mod < 0) {
		printf("Error 0x%08X loading/starting kernelcall.prx.\n", mod);
	}

	sceCtrlSetSamplingCycle(0);
	sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
	for(;;)
	{
		printf("====================================================================");
		printf("PPSSPP Save Tool\n");
		printf("====================================================================\n\n\n");
	   
		switch(currentMenu)
		{
			
		case 0:
			{
				int maxOption = 0;
				for(i = 0; menuList0[i]; i++)
				{
					if(i == selectedOption)
						printf("   > %s\n",menuList0[i]);
					else
						printf("     %s\n",menuList0[i]);
					maxOption++;
				}
				
				int input = ProcessInput(maxOption, &selectedOption);
				if(input == 0)
				{
					currentMenu = 1;
					selectedOption = 0;
				}
				else if(input == 1)
				{
					currentMenu = 4;
					selectedOption = 0;
				}
				else if(input == 2)
				{
					sceKernelExitGame();
				}
			}
			break;
		case 4:
		case 1:
			{
				int maxOption = 0;
				printf("PPSSPP Decrypted Save Directory : \n");
				for(i = 0; menuList1[i]; i++)
				{
					if(i == selectedOption)
						printf("   > %s\n",menuList1[i]);
					else
						printf("     %s\n",menuList1[i]);
					maxOption++;
				}
				
				int input = ProcessInput(maxOption, &selectedOption);
				if(input == maxOption-1)
				{
					if(currentMenu == 1)
						selectedOption = 0;
					else
						selectedOption = 1;
					currentMenu = 0;
				}
				else if(input >= 0)
				{
					basePath = selectedOption;
					if(currentMenu == 1)
					{
						currentMenu = 2;
						UpdateValidDir(1);
					}
					else
					{
						currentMenu = 5;
						UpdateValidDir(0);
					}
					selectedOption = 0;
				}
			}
			break;
		case 5:
		case 2:
			{
				int maxOption = 0;
				if(currentMenu == 2)
					printf("Save to encrypt : \n");
				else
					printf("Save to decrypt : \n");
				
				if(numDirList == 0)
				{
					printf("No compatible data, see README for help on use\n");
				}
				for(i = 0; i < numDirList; i++)
				{
					if(i == selectedOption)
						printf("   > %s\n",dirList[i].name);
					else
						printf("     %s\n",dirList[i].name);
					maxOption++;
				}
				
				for(i = 0; menuList2[i]; i++)
				{
					if((i+numDirList) == selectedOption)
						printf("   > %s\n",menuList2[i]);
					else
						printf("     %s\n",menuList2[i]);
					maxOption++;
				}
				
				printf("\n Invalid path : \n");
				for(i = 0; i < numInvalidDirList && i < (22-numDirList); i++)
				{
					switch(invalidDirList[i].errorId)
					{
						case 1:
							printf("     %s : ENCRYPT_INFO.BIN not found\n",invalidDirList[i].name);
						break;
						case 2:
							printf("     %s : ENCRYPT_INFO.BIN read error\n",invalidDirList[i].name);
						break;
						case 3:
							printf("     %s : ENCRYPT_INFO.BIN wrong version\n",invalidDirList[i].name);
						break;
						case 4:
							printf("     %s : PARAM.SFO not found\n",invalidDirList[i].name);
						break;
						case 5:
							printf("     %s : PARAM.SFO read error\n",invalidDirList[i].name);
						break;
						case 6:
							printf("     %s : SAVEDATA_FILE_LIST not found in PARAM.SFO\n",invalidDirList[i].name);
						break;
						case 7:
							printf("     %s : no save name in SAVEDATA_FILE_LIST\n",invalidDirList[i].name);
						break;
						case 8:
							printf("     %s : no save found\n",invalidDirList[i].name);
						break;
						default:
						break;
					}
				}
				
				int input = ProcessInput(maxOption, &selectedOption);
				if(input == numDirList)
				{
					if(currentMenu == 2)
						currentMenu = 1;
					else
						currentMenu = 4;
					selectedOption = basePath;
				}
				else if(input >= 0)
				{
					if(currentMenu == 2)
						currentMenu = 3;
					else
						currentMenu = 6;
					workDir = input;
					selectedOption = 0;
				}
			}
			break;
		case 6:
		case 3:
		{
			
			EncryptFileInfo encryptInfo;
			if(FileRead(menuList1[basePath], dirList[workDir].name, "ENCRYPT_INFO.BIN",(u8*)&encryptInfo,sizeof(encryptInfo)) < 0)
			{
				printf("Can't read encrypt file\n");
			}
			else
			{
				printf("Key : ");
				for(i = 0; i < 16; i++)
					printf(" %02x",(u8)encryptInfo.key[i]);
				printf("\n");
				printf("SDK Version : 0x%x\n",encryptInfo.sdkVersion);
				
				char srcPath[128];
				char dstPath[128];
				if(currentMenu == 3)
				{
					sprintf(srcPath,"%s%s",menuList1[basePath], dirList[workDir].name);
					sprintf(dstPath,"ms0:/PSP/SAVEDATA/%s",dirList[workDir].name);
					sceIoMkdir(dstPath,0777);
				}
				else
				{
					sprintf(srcPath,"ms0:/PSP/SAVEDATA/%s",dirList[workDir].name);
					sprintf(dstPath,"%s%s",menuList1[basePath], dirList[workDir].name);
				}
					
				int dfd;
				dfd = sceIoDopen(srcPath);
				if(dfd >= 0)
				{
					SceIoDirent dirinfo;
					while(sceIoDread(dfd, &dirinfo) > 0)
					{
						
						if(!(dirinfo.d_stat.st_mode & 0x2000)) // is not a file
							continue;
							
						if(strcmp(dirinfo.d_name,"ENCRYPT_INFO.BIN") == 0) // don't copy encrypt info
							continue;
							
						FileCopy(srcPath, dstPath, dirinfo.d_name);
							
					}
					sceIoDclose(dfd);
				}
				
				if(currentMenu == 3)
				{
						
					char decryptedFile[258], encryptedFile[258], srcSFO[258], dstSFO[258];
					sprintf(decryptedFile,"%s/%s",srcPath ,dirList[workDir].saveFile);
					sprintf(srcSFO,"%s/PARAM.SFO",srcPath);

					sprintf(encryptedFile,"%s/%s",dstPath ,dirList[workDir].saveFile);
					sprintf(dstSFO,"%s/PARAM.SFO",dstPath);
						
					printf("Encoding %s into %s\n",decryptedFile, encryptedFile);
						
					int ret = encrypt_file(decryptedFile, 
											encryptedFile, 
											dirList[workDir].saveFile, 
											srcSFO, 
											dstSFO, 
											encryptInfo.key[0] != 0 ? encryptInfo.key : NULL, 
											GetSDKMainVersion(encryptInfo.sdkVersion)
											);
					
					if(ret < 0) {
						printf("Error: encrypt_file() returned %d\n\n", ret);
					} else {
						printf("Successfully wrote %d bytes to\n", ret);
						printf("  %s\n", encryptedFile);
						printf("and updated hashes in\n");
						printf("  %s\n\n", dstSFO);
					}
				}
				else
				{
					char decryptedFile[258], encryptedFile[258];
					sprintf(encryptedFile,"%s/%s",srcPath ,dirList[workDir].saveFile);
					sprintf(decryptedFile,"%s/%s",dstPath ,dirList[workDir].saveFile);
						
					printf("Decoding %s into %s\n",encryptedFile, decryptedFile);
						
					int ret = decrypt_file(decryptedFile, encryptedFile, encryptInfo.key[0] != 0 ? encryptInfo.key : NULL, GetSDKMainVersion(encryptInfo.sdkVersion));
					
					if(ret < 0) {
						printf("Error: decrypt_file() returned %d\n\n", ret);
					} else {
						printf("Successfully wrote %d bytes to\n", ret);
						printf("  %s\n", decryptedFile);
					}
				}
				printf("   > Back\n");
				
				int input = ProcessInput(1, &selectedOption);
				if(input >= 0)
				{
					if(currentMenu == 3)
						currentMenu = 2;
					else
						currentMenu = 5;
					selectedOption = 0;
				}
			}
		}
		break;
		default:
			sceKernelExitGame();
			break;
		}
	   
		pspDebugScreenClear();
		sceDisplayWaitVblankStart();
		sceGuSwapBuffers();
	}
	return 0;
} 
コード例 #15
0
ファイル: buffalo-enc.c プロジェクト: whble/trunk
int main(int argc, char *argv[])
{
	int res = EXIT_FAILURE;
	int err;

	progname = basename(argv[0]);

	while ( 1 ) {
		int c;

		c = getopt(argc, argv, "adi:m:o:hp:v:k:r:s:");
		if (c == -1)
			break;

		switch (c) {
		case 'd':
			do_decrypt = 1;
			break;
		case 'i':
			ifname = optarg;
			break;
		case 'l':
			longstate = 1;
			break;
		case 'm':
			magic = optarg;
			break;
		case 'o':
			ofname = optarg;
			break;
		case 'p':
			product = optarg;
			break;
		case 'v':
			version = optarg;
			break;
		case 'k':
			crypt_key = optarg;
			break;
		case 's':
			seed = strtoul(optarg, NULL, 16);
			break;
		case 'h':
			usage(EXIT_SUCCESS);
			break;
		default:
			usage(EXIT_FAILURE);
			break;
		}
	}

	err = check_params();
	if (err)
		goto out;

	if (do_decrypt)
		err = decrypt_file();
	else
		err = encrypt_file();

	if (err)
		goto out;

	res = EXIT_SUCCESS;

out:
	return res;
}
コード例 #16
0
ファイル: encrypt1.c プロジェクト: Arcenciel/DDReader
int 
main(int argc, char **argv) {
    static const char secret_data[] = "Big secret";
    
    assert(argv);

    if(argc != 3) {
	printf_a_ignorar3(stderr, "Error: wrong number of arguments.\n");
	printf_a_ignorar3(stderr, "Usage: %s <tmpl-file> <key-file>\n", argv[0]);
	return(1);
    }

    /* Init libxml and libxslt libraries */
    xmlInitParser();
    LIBXML_TEST_VERSION
    xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
    xmlSubstituteEntitiesDefault(1);
#ifndef XMLSEC_NO_XSLT
    xmlIndentTreeOutput = 1; 
#endif /* XMLSEC_NO_XSLT */
        	
    /* Init xmlsec library */
    if(xmlSecInit() < 0) {
	printf_a_ignorar3(stderr, "Error: xmlsec initialization failed.\n");
	return(-1);
    }

    /* Check loaded library version */
    if(xmlSecCheckVersion() != 1) {
	printf_a_ignorar3(stderr, "Error: loaded xmlsec library version is not compatible.\n");
	return(-1);
    }

    /* Load default crypto engine if we are supporting dynamic
     * loading for xmlsec-crypto libraries. Use the crypto library
     * name ("openssl", "nss", etc.) to load corresponding 
     * xmlsec-crypto library.
     */
#ifdef XMLSEC_CRYPTO_DYNAMIC_LOADING
    if(xmlSecCryptoDLLoadLibrary(BAD_CAST XMLSEC_CRYPTO) < 0) {
	printf_a_ignorar3(stderr, "Error: unable to load default xmlsec-crypto library. Make sure\n"
			"that you have it installed and check shared libraries path\n"
			"(LD_LIBRARY_PATH) envornment variable.\n");
	return(-1);	
    }
#endif /* XMLSEC_CRYPTO_DYNAMIC_LOADING */

    /* Init crypto library */
    if(xmlSecCryptoAppInit(NULL) < 0) {
	printf_a_ignorar3(stderr, "Error: crypto initialization failed.\n");
	return(-1);
    }

    /* Init xmlsec-crypto library */
    if(xmlSecCryptoInit() < 0) {
	printf_a_ignorar3(stderr, "Error: xmlsec-crypto initialization failed.\n");
	return(-1);
    }

    if(encrypt_file(argv[1], argv[2], secret_data, strlen(secret_data)) < 0) {
	return(-1);
    }    
    
    /* Shutdown xmlsec-crypto library */
    xmlSecCryptoShutdown();
    
    /* Shutdown crypto library */
    xmlSecCryptoAppShutdown();
    
    /* Shutdown xmlsec library */
    xmlSecShutdown();

    /* Shutdown libxslt/libxml */
#ifndef XMLSEC_NO_XSLT
    xsltCleanupGlobals();            
#endif /* XMLSEC_NO_XSLT */
    xmlCleanupParser();
    
    return(0);
}
コード例 #17
0
ファイル: encrypt2.c プロジェクト: esproul/xmlsec
int 
main(int argc, char **argv) {
#ifndef XMLSEC_NO_XSLT
    xsltSecurityPrefsPtr xsltSecPrefs = NULL;
#endif /* XMLSEC_NO_XSLT */

    assert(argv);

    if(argc != 3) {
        fprintf(stderr, "Error: wrong number of arguments.\n");
        fprintf(stderr, "Usage: %s <xml-file> <key-file>\n", argv[0]);
        return(1);
    }

    /* Init libxml and libxslt libraries */
    xmlInitParser();
    LIBXML_TEST_VERSION
    xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
    xmlSubstituteEntitiesDefault(1);
#ifndef XMLSEC_NO_XSLT
    xmlIndentTreeOutput = 1; 
#endif /* XMLSEC_NO_XSLT */

    /* Init libxslt */
#ifndef XMLSEC_NO_XSLT
    /* disable everything */
    xsltSecPrefs = xsltNewSecurityPrefs(); 
    xsltSetSecurityPrefs(xsltSecPrefs,  XSLT_SECPREF_READ_FILE,        xsltSecurityForbid);
    xsltSetSecurityPrefs(xsltSecPrefs,  XSLT_SECPREF_WRITE_FILE,       xsltSecurityForbid);
    xsltSetSecurityPrefs(xsltSecPrefs,  XSLT_SECPREF_CREATE_DIRECTORY, xsltSecurityForbid);
    xsltSetSecurityPrefs(xsltSecPrefs,  XSLT_SECPREF_READ_NETWORK,     xsltSecurityForbid);
    xsltSetSecurityPrefs(xsltSecPrefs,  XSLT_SECPREF_WRITE_NETWORK,    xsltSecurityForbid);
    xsltSetDefaultSecurityPrefs(xsltSecPrefs); 
#endif /* XMLSEC_NO_XSLT */
                
    /* Init xmlsec library */
    if(xmlSecInit() < 0) {
        fprintf(stderr, "Error: xmlsec initialization failed.\n");
        return(-1);
    }

    /* Check loaded library version */
    if(xmlSecCheckVersion() != 1) {
        fprintf(stderr, "Error: loaded xmlsec library version is not compatible.\n");
        return(-1);
    }

    /* Load default crypto engine if we are supporting dynamic
     * loading for xmlsec-crypto libraries. Use the crypto library
     * name ("openssl", "nss", etc.) to load corresponding 
     * xmlsec-crypto library.
     */
#ifdef XMLSEC_CRYPTO_DYNAMIC_LOADING
    if(xmlSecCryptoDLLoadLibrary(NULL) < 0) {
        fprintf(stderr, "Error: unable to load default xmlsec-crypto library. Make sure\n"
                        "that you have it installed and check shared libraries path\n"
                        "(LD_LIBRARY_PATH and/or LTDL_LIBRARY_PATH) envornment variables.\n");
        return(-1);     
    }
#endif /* XMLSEC_CRYPTO_DYNAMIC_LOADING */

    /* Init crypto library */
    if(xmlSecCryptoAppInit(NULL) < 0) {
        fprintf(stderr, "Error: crypto initialization failed.\n");
        return(-1);
    }

    /* Init xmlsec-crypto library */
    if(xmlSecCryptoInit() < 0) {
        fprintf(stderr, "Error: xmlsec-crypto initialization failed.\n");
        return(-1);
    }

    if(encrypt_file(argv[1], argv[2]) < 0) {
        return(-1);
    }    
    
    /* Shutdown xmlsec-crypto library */
    xmlSecCryptoShutdown();
    
    /* Shutdown crypto library */
    xmlSecCryptoAppShutdown();
    
    /* Shutdown xmlsec library */
    xmlSecShutdown();

    /* Shutdown libxslt/libxml */
#ifndef XMLSEC_NO_XSLT
    xsltFreeSecurityPrefs(xsltSecPrefs);
    xsltCleanupGlobals();            
#endif /* XMLSEC_NO_XSLT */
    xmlCleanupParser();
    
    return(0);
}
コード例 #18
0
ファイル: walkfs.c プロジェクト: EmbeddedMan/history
bool
walkfs(int pass)
{
    int a;
    int e;
    int ms;
    uint32 i;
    uint32 j;
    uint32 rv;
    uint32 pstart;
    uint32 rfilesize;
    VOLINFO vi;
    DIRINFO di;
    DIRENT de;
    bool skip;
    bool first;
    int wfilesize;
    uint32 namei[DEPTH];
    uint32 skips[DEPTH];
    static char dirname[MAX_PATH];
    static char rfilename[MAX_PATH];
    static char wfilename[MAX_PATH];
    static char tfilename[MAX_PATH];
    static byte scratch[SECTOR_SIZE];
    
    ms = ticks;
    
    printf("walkfs\n");

#if ! _WIN32
    while (adc_result[0] < 20000) {
        DFS_HostFlush(0);
        led_sad(code_battery);
        delay(1000);
    }
    led_unknown();
#endif
    
    params_get(&params);
    assert(params.roflip == true || params.roflip == false);

    memset(scratch, -1, sizeof(scratch));  // remove
    pstart = DFS_GetPtnStart(0, scratch, 0, NULL, NULL, NULL);
    if (pstart == DFS_ERRMISC) {
        return 0;
    }

    memset(scratch, -1, sizeof(scratch));  // remove
    if (DFS_GetVolInfo(0, scratch, pstart, &vi)) {
        return 0;
    }
    
    if (! vi.secperclus || (vi.secperclus & (vi.secperclus-1))) {
        printf("invalid fs cluster size %d\n", vi.secperclus);
        return 0;
    }
    
    printf("fs cluster size %d\n", vi.secperclus);

    i = 0;
    namei[i] = 0;
    skips[i] = 0;
    strcpy(dirname, "");
    
    first = 1;
    for (;;) {
XXX_LOOP_XXX:        
        if (panic) {
            return 0;
        }
        
        // open a new directory
        memset(scratch, -1, sizeof(scratch));  // remove
        di.scratch = scratch;
        if (DFS_OpenDir(&vi, (unsigned char *)dirname, &di)) {
            return 0;
        }

        memset(&de, 0, sizeof(de));

        skip = 0;
        for (j = 0; j < skips[i]; j++) {
            if (DFS_GetNext(&vi, &di, &de)) {
                skip = 1;
            }
        }

        // enumerate the directory
        if (! skip && ! DFS_GetNext(&vi, &di, &de)) {
            skips[i]++;
         
            if (! de.name[0] || de.name[0] == '.') {
                continue;
            }

#if ! _WIN32
            while (adc_result[0] < 20000) {
                DFS_HostFlush(0);
                led_sad(code_battery);
                delay(1000);
            }
            led_unknown();

            while ((MCF_GPIO_SETNQ & 0x10) == 0) {
                // we're paused
                DFS_HostFlush(0);
            }
#endif
            
            if (de.attr & ATTR_DIRECTORY) {
                if (i+1 < DEPTH) {
                    namei[i] = strlen(dirname);
                    if (namei[i]) {
                        strcat(dirname, "/");
                    }
                    strncat(dirname, (char *)de.name, 8);
                    tailtrim(dirname);
                    if (strncmp((char *)de.name+8, "   ", 3)) {
                        strcat(dirname, ".");
                        strncat(dirname, (char *)de.name+8, 3);
                        tailtrim(dirname);
                    }
                    i++;
                    skips[i] = 0;
                    printf("dir: '%s'\n", dirname);
                    goto XXX_LOOP_XXX;
                }
            } else if (! (de.attr & (ATTR_HIDDEN|ATTR_SYSTEM|ATTR_VOLUME_ID)) && !!(de.attr & ATTR_READ_ONLY) == params.roflip) {
                // force upper case
                for (a = 0; a < sizeof(de.name); a++) {
                    if (de.name[a] >= 'a' && de.name[a] <= 'z') {
                        de.name[a] = de.name[a] - 'a' + 'A';
                    }
                }
                
                if (pass == 0) {
                    // pass 0: check for extension match for tmp file
                    if (! strncmp("TMP", (char *)de.name+8, 3)) {
                        strcpy(rfilename, dirname);
                        if (strlen(rfilename)) {
                            strcat(rfilename, "/");
                        }
                        strncat(rfilename, (char *)de.name, 8);
                        tailtrim(rfilename);
                        if (strncmp((char *)de.name+8, "   ", 3)) {
                            strcat(rfilename, ".");
                            strncat(rfilename, (char *)de.name+8, 3);
                            tailtrim(rfilename);
                        }

                        // rfilename needs to be purged!
                        
                        rfilesize = (de.filesize_3<<24)|(de.filesize_2<<16)|(de.filesize_1<<8)|de.filesize_0;
                        printf("temp: '%s (%d bytes)'\n", rfilename, rfilesize);

                        // we have to rewrite rfilename
                        rv = encrypt_file(&vi, scratch, NULL, 0, rfilename, rfilesize);
                        if (! rv) {
                            printf("rewrite failed\n");
                            return 0;
                        }
                        
                        // and unlink it
                        rv = DFS_UnlinkFile(&vi, (unsigned char *)rfilename, scratch);
                        if (rv) {
                            printf("unlink failed\n");
                            return 0;
                        }

                        DFS_HostFlush(0);
                    }
                } else {
                    assert(pass == 1);
                    
                    // pass 1: check for extension match for image file
                    for (e = 0; e < NEXTS; e++) {
                        if (params.extensions[e][0] != 0 && params.extensions[e][0] != (char)-1) {
                            if (! strncmp(params.extensions[e], (char *)de.name+8, 3)) {
                                break;
                            }
                        }
                    }
                    
                    if (e != NEXTS) {
                        strcpy(rfilename, dirname);
                        if (strlen(rfilename)) {
                            strcat(rfilename, "/");
                        }
                        strncat(rfilename, (char *)de.name, 8);
                        tailtrim(rfilename);
                        if (strncmp((char *)de.name+8, "   ", 3)) {
                            strcat(rfilename, ".");
                            strncat(rfilename, (char *)de.name+8, 3);
                            tailtrim(rfilename);
                        }
                        
                        // rfilename needs to be encrypted!
                        
                        rfilesize = (de.filesize_3<<24)|(de.filesize_2<<16)|(de.filesize_1<<8)|de.filesize_0;
                        printf("encrypt: '%s (%d bytes)'\n", rfilename, rfilesize);
                        
                        if (first) {
                            // for the first rfilename we create a new (unallocated) .REC file directly
                            output_file(rfilename, ".REC", wfilename);
                            wfilesize = 0;
                        }
                        
                        // we'll encrypt to wfilename
                        
                        rv = encrypt_file(&vi, scratch, rfilename, rfilesize, wfilename, wfilesize);
                        if (! rv) {
                            printf("encryption failed\n");
                            return 0;
                        }
                        
                        // and then we rename wfilename to rfilename with .REC
                        if (! first) {
                            // and then rename the old file
                            output_file(rfilename, ".REC", tfilename);
                            rv = DFS_RenameFile(&vi, (unsigned char *)wfilename, (unsigned char *)tfilename, scratch);
                            if (rv) {
                                printf("rename failed\n");
                                return 0;
                            }
                        }
                        
                        // and rename rfilename to rfilename with .TMP
                        output_file(rfilename, ".TMP", wfilename);
                        wfilesize = rfilesize;
                        rv = DFS_RenameFile(&vi, (unsigned char *)rfilename, (unsigned char *)wfilename, scratch);
                        if (rv) {
                            printf("rename failed\n");
                            return 0;
                        }
                        
                        // we reuse an old (allocated) file
                        first = 0;
                    }
                }
            }
        } else {
            skip = 1;
        }

        if (! skip) {
            // we have more files in this directory
            goto XXX_LOOP_XXX;
        }

        // we're leaving this directory        
        if (pass == 1 && ! first) {
            // lastly we have to rewrite wfilename
            rv = encrypt_file(&vi, scratch, NULL, 0, wfilename, wfilesize);
            if (! rv) {
                printf("rewrite failed\n");
                return 0;
            }
            
            // and unlink it
            rv = DFS_UnlinkFile(&vi, (unsigned char *)wfilename, scratch);
            if (rv) {
                printf("unlink failed\n");
                return 0;
            }

            DFS_HostFlush(0);
            
            first = 1;
        }

        // if this is the root dirtectory...        
        if (! i) {
            // we're done
            break;
        }

        // continue a previous directory
        i--;
        dirname[namei[i]] = '\0';
    }
    
    DFS_HostFlush(0);
    total_ticks += ticks-ms;
    
    return 1;
}
コード例 #19
0
ファイル: efs.c プロジェクト: ezhuang/SEFS
int main(int argc, char* argv[]){




        if(argc != 4){
                printf("ERROR: Missing command line arguments\nUsage: ./efsmanager master_password user_password_file date_and_time_of_last_change\n");
                return 1 ;
        }


	printf("Found master password: %s\n",argv[1]);
	printf("Found user password file: %s\n",argv[2]);
	printf("Found date of last change: %s\n",argv[3]);
	printf("Found master_iv: %s\n",master_iv);

	//copy argv[2] to password_file 
	

	
	/*
	use the master password and master IV to generate the master encryption 
	decryption key and master hmace key. Store the master encryption decryption 
	key in  master_encdec_key and store the master hmac key in master_hmac_key
	*/


        

        unsigned char command[1024];
        int operation_status ;
        while(1){
		printf("Available commands:\n(1) create_file\n(2) delete_file\n(3) encrypt_file\n(4) decrypt_file\n(5) read_from_file\n(6) write_to_file\n(7) file_size\n(8) file_integrity_check\n(9) system_health_check\n(10) quit\n\n\n");
                printf("enter a command: ");
                scanf("%s",command) ;
                // printf("\n") ;
                operation_status = OKAY ;
                if(!strcmp(command,"create_file")){
                        printf("username: "******"%s",username) ;
                        printf("password: "******"%s",password) ;
                        printf("file name: ");
                        unsigned char pFile[1024] ;
                        scanf("%s",pFile);

                        operation_status = create_file(username,password,pFile) ;
                }
                else if(!strcmp(command,"delete_file")){
                        printf("username: "******"%s",username) ;
                        printf("password: "******"%s",password) ;
                        printf("file name: ");
                        unsigned char pFile[1024] ;
                        scanf("%s",pFile);

                        operation_status = delete_file(username,password,pFile) ;
                }
                else if(!strcmp(command,"encrypt_file")){
                        printf("username: "******"%s",username) ;
                        printf("password: "******"%s",password) ;
                        printf("file name to encrypt: ");
                        unsigned char pFile[1024] ;
                        scanf("%s",pFile);

                        operation_status = encrypt_file(username,password,pFile) ;
                }
                else if(!strcmp(command,"decrypt_file")){
                        printf("username: "******"%s",username) ;
                        printf("password: "******"%s",password) ;
                        printf("file name to decrypt: ");
                        unsigned char pFile[1024] ;
                        scanf("%s",pFile);

                        operation_status = decrypt_file(username,password,pFile) ;

                }
                else if(!strcmp(command,"file_size")){
                        printf("username: "******"%s",username) ;
                        printf("password: "******"%s",password) ;
                        printf("file name: ");
                        unsigned char pFile[1024] ;
                        scanf("%s",pFile);

                        operation_status = file_size(username,password,pFile) ;
                }
                else if(!strcmp(command,"file_integrity_check")){
                        printf("username: "******"%s",username) ;
                        printf("password: "******"%s",password) ;
                        printf("file name: ");
                        unsigned char pFile[1024] ;
                        scanf("%s",pFile);

                        operation_status = file_integrity_check(username,password,pFile) ;
                }
                else if(!strcmp(command,"system_health_check")){
                        operation_status = system_health_check(); 
                }
                else if(!strcmp(command,"read_from_file")){
                        printf("username: "******"%s",username) ;
                        printf("password: "******"%s",password) ;
                        printf("file name: ");
                        unsigned char pFile[1024] ;
                        scanf("%s",pFile);
			printf("position to read from: ");
			int offset ; scanf("%d",&offset); 
			printf("how many characters to read: "); 
			int len; scanf("%d",&len); 			


                        unsigned char *content = read_from_file(username,password,pFile,offset,len) ;
			if(content == NULL){
				printf("ERROR: Reading from file\n");
				continue;
			}
			else{
				printf("CONTENT:\n%s\n",content);
			}
                }
		
                else if(!strcmp(command,"write_to_file")){
                        printf("username: "******"%s",username) ;
                        printf("password: "******"%s",password) ;
                        printf("file name: ");
                        unsigned char pFile[1024] ;
                        scanf("%s",pFile);
			printf("position to write to: ");
			int offset ; scanf("%d",&offset); 
			printf("Content to write:\n "); 
			char content[8192] ; 
			int i = 0 ; 
			while(1){
				char ch = getchar(); 
				if(ch == EOF) break ; 
				content[i] = ch ; 
				++i ; 
			}			

                        operation_status = write_to_file(username,password,pFile,offset,content) ;
                }

                else if(!strcmp(command,"quit")){
                        printf("INFO: Got the quit command\n");
                        printf("Program terminating\n");
                        break;
                }
                else{
                        printf("ERROR: Unknown command %s\n",command);
                        printf("INFO: Ignoring command\n") ;
                }

                if(operation_status == ERROR)
                        printf("Operation %s failed\n",command) ;
        }
        return 0;
}