Explorar el Código

xor fixed

master
Krzysztof Kwiatkowski hace 9 años
padre
commit
6ad30fec31
Se han modificado 7 ficheros con 168 adiciones y 264 borrados
  1. +151
    -252
      prj/Matasano.sublime-workspace
  2. +1
    -1
      sol/set1.cpp
  3. +1
    -1
      sol/set2.c
  4. +3
    -3
      src/enc_modes.c
  5. +4
    -2
      src/xor.c
  6. +4
    -1
      src/xor.h
  7. +4
    -4
      src/xor_char_finder.cpp

+ 151
- 252
prj/Matasano.sublime-workspace Ver fichero

@@ -3,6 +3,46 @@
{
"selected_items":
[
[
"outu",
"output_len"
],
[
"att",
"attribs_enc"
],
[
"output",
"output_len"
],
[
"opens",
"openssl_output_len"
],
[
"openssl",
"openssl_output_buff"
],
[
"open",
"openssl_output_len"
],
[
"inp",
"input_len"
],
[
"local",
"local_input_len"
],
[
"expe",
"expected_no_padding_dec"
],
[
"attri",
"attribs_openssl_dec"
],
[
"i_buf",
"i_padded_buf"
@@ -31,10 +71,6 @@
"padd",
"padding_value"
],
[
"inp",
"input_len"
],
[
"Res",
"Result_Error"
@@ -63,10 +99,6 @@
"out",
"out_len"
],
[
"attri",
"attribs"
],
[
"test",
"test_text"
@@ -79,10 +111,6 @@
"ou",
"output_len"
],
[
"output",
"output_len"
],
[
"input",
"input_len"
@@ -486,34 +514,6 @@
[
"kTableSeries",
"kTableSeriesCnx"
],
[
"ERPL",
"ERPLv5"
],
[
"_back",
"_backRoutingIndex"
],
[
"global",
"global_regression"
],
[
"multi",
"multi_index"
],
[
"ConfigBy",
"ConfigByNumberAndPriority_t"
],
[
"RemoteConnectionCO",
"RemoteConnectionConfigPtr"
],
[
"aMappingBy",
"aMappingByNumber"
]
]
},
@@ -539,7 +539,7 @@
"file": "/home/flowher/repos/MatasanoCrypto/sol/set2.c",
"settings":
{
"buffer_size": 13607,
"buffer_size": 14912,
"line_ending": "Unix"
}
},
@@ -547,7 +547,7 @@
"file": "/home/flowher/repos/MatasanoCrypto/src/enc_modes.c",
"settings":
{
"buffer_size": 5568,
"buffer_size": 6097,
"line_ending": "Unix"
}
},
@@ -555,74 +555,63 @@
"file": "/home/flowher/repos/MatasanoCrypto/sol/set2.h",
"settings":
{
"buffer_size": 549,
"buffer_size": 551,
"line_ending": "Unix"
}
},
{
"contents": "Searching 32 files for \"pkcs7_pad\"\n\n~/repos/MatasanoCrypto/main:\n <binary>\n\n/home/flowher/repos/MatasanoCrypto/sol/set2.c:\n 89 char buff2[10];\n 90 \n 91: ret = pkcs7_pad(text1, 5, &buff1, 32);\n 92 CHECK(ret==true, (const unsigned char* const) \"Padding operation failed\");\n 93 ret = memcmp(text1, buff1, 5);\n\n/home/flowher/repos/MatasanoCrypto/src/enc_modes.c:\n 123 if(new_buf_len == attribs->input_len)\n 124 new_buf_len += 16;\n 125: pkcs7_pad(attribs->input, attribs->input_len, &padded_input, new_buf_len);\n 126 }\n 127 else\n\n/home/flowher/repos/MatasanoCrypto/src/pkcs7.c:\n 19 *\n 20 -------------------------------------------------------------------------------- */\n 21: bool pkcs7_pad(const uint8_t* i_buff, size_t i_len, uint8_t** o_buff, size_t i_obuff_len )\n 22 {\n 23 if( (i_obuff_len < i_len ) ||\n\n/home/flowher/repos/MatasanoCrypto/src/pkcs7.h:\n 5 #include <stdint.h>\n 6 \n 7: bool pkcs7_pad( const uint8_t* i_buff,\n 8 size_t i_len,\n 9 uint8_t** o_buff,\n\n7 matches across 5 files\n\n\nSearching 32 files for \"pkcs7_pad\"\n\n~/repos/MatasanoCrypto/main:\n <binary>\n\n/home/flowher/repos/MatasanoCrypto/sol/set2.c:\n 90 char buff2[10];\n 91 \n 92: ret = pkcs7_pad(text1, 5, &p_buff1, 32);\n 93 CHECK(ret==true, (const unsigned char* const) \"Padding operation failed\");\n 94 ret = memcmp(text1, buff1, 5);\n\n/home/flowher/repos/MatasanoCrypto/src/enc_modes.c:\n 123 if(new_buf_len == attribs->input_len)\n 124 new_buf_len += 16;\n 125: pkcs7_pad(attribs->input, attribs->input_len, &padded_input, new_buf_len);\n 126 }\n 127 else\n\n/home/flowher/repos/MatasanoCrypto/src/pkcs7.c:\n 19 *\n 20 -------------------------------------------------------------------------------- */\n 21: bool pkcs7_pad(const uint8_t* i_buff, size_t i_len, uint8_t** o_buff, size_t i_obuff_len )\n 22 {\n 23 if( (i_obuff_len < i_len ) ||\n\n/home/flowher/repos/MatasanoCrypto/src/pkcs7.h:\n 5 #include <stdint.h>\n 6 \n 7: bool pkcs7_pad( const uint8_t* i_buff,\n 8 size_t i_len,\n 9 uint8_t** o_buff,\n\n7 matches across 5 files\n\n\nSearching 32 files for \"pkcs7_unpad\"\n\n~/repos/MatasanoCrypto/main:\n <binary>\n\n/home/flowher/repos/MatasanoCrypto/sol/set2.c:\n 100 \n 101 size_t unpad_len = 0;\n 102: CHECK( true == pkcs7_unpad(buff1, 32, unpadded, &unpad_len),\n 103 (const uint8_t*) \"Unpadding failed\");\n 104 CHECK(unpad_len == 5, (const uint8_t*) \"Unpadded length wrong\");\n\n/home/flowher/repos/MatasanoCrypto/src/pkcs7.c:\n 54 *\n 55 -------------------------------------------------------------------------------- */\n 56: bool pkcs7_unpad( const uint8_t* i_padded_buf,\n 57 size_t i_len,\n 58 uint8_t** o_unpad_buf,\n\n/home/flowher/repos/MatasanoCrypto/src/pkcs7.h:\n 10 size_t i_obuff_len );\n 11 \n 12: bool pkcs7_unpad( const char* i_padded_buf,\n 13 size_t i_len,\n 14 char* o_unpad_buf,\n\n6 matches across 4 files\n",
"settings":
{
"buffer_size": 3214,
"line_ending": "Unix",
"name": "Find Results",
"scratch": true
}
},
{
"file": "/home/flowher/repos/MatasanoCrypto/src/common.h",
"file": "/home/flowher/repos/MatasanoCrypto/src/enc_modes.h",
"settings":
{
"buffer_size": 2851,
"buffer_size": 459,
"line_ending": "Unix"
}
},
{
"file": "/home/flowher/konto/list.txt",
"file": "/home/flowher/repos/MatasanoCrypto/src/common.c",
"settings":
{
"buffer_size": 99,
"line_ending": "Unix",
"name": "OK 1. BPCE"
"buffer_size": 2975,
"line_ending": "Unix"
}
},
{
"file": "/home/flowher/repos/MatasanoCrypto/src/enc_modes.h",
"file": "/home/flowher/repos/MatasanoCrypto/sol/set1.cpp",
"settings":
{
"buffer_size": 459,
"buffer_size": 12519,
"line_ending": "Unix"
}
},
{
"file": "/home/flowher/repos/MatasanoCrypto/src/common.c",
"file": "/home/flowher/repos/MatasanoCrypto/src/xor_char_finder.cpp",
"settings":
{
"buffer_size": 2975,
"buffer_size": 6065,
"line_ending": "Unix"
}
},
{
"file": "/home/flowher/repos/MatasanoCrypto/sol/set1.cpp",
"file": "/home/flowher/repos/MatasanoCrypto/src/xor_char_finder.h",
"settings":
{
"buffer_size": 12514,
"buffer_size": 3524,
"line_ending": "Unix"
}
},
{
"file": "/home/flowher/repos/MatasanoCrypto/src/hamming.c",
"file": "/home/flowher/repos/MatasanoCrypto/src/xor.c",
"settings":
{
"buffer_size": 1690,
"buffer_size": 502,
"line_ending": "Unix"
}
},
{
"file": "/home/flowher/repos/MatasanoCrypto/src/xor_char_finder.cpp",
"file": "/home/flowher/repos/MatasanoCrypto/src/xor.h",
"settings":
{
"buffer_size": 6026,
"buffer_size": 357,
"line_ending": "Unix"
}
},
@@ -1054,25 +1043,27 @@
],
"file_history":
[
"/home/flowher/repos/MatasanoCrypto/src/xor.c",
"/home/flowher/repos/MatasanoCrypto/src/hamming.c",
"/home/flowher/repos/MatasanoCrypto/Makefile",
"/home/flowher/repos/MatasanoCrypto/src/pkcs7.c",
"/home/flowher/repos/MatasanoCrypto/src/enc_modes.c",
"/home/flowher/repos/OpenCrypto/crypto/evp/evp_enc.c",
"/home/flowher/repos/MatasanoCrypto/test.c",
"/home/flowher/konto/list.txt",
"/home/flowher/repos/MatasanoCrypto/src/common.h",
"/home/flowher/repos/MatasanoCrypto/src/pkcs7.h",
"/home/flowher/repos/MatasanoCrypto/sol/set2.c",
"/home/flowher/test.c",
"/home/flowher/repos/MatasanoCrypto/src/enc_modes.c",
"/home/flowher/repos/MatasanoCrypto/test.c",
"/home/flowher/repos/MatasanoCrypto/sol/set2.h",
"/home/flowher/repos/OpenCrypto/util/incore",
"/home/flowher/test.cpp",
"/home/flowher/Work/goldfish_env/usr/bin/mkbootimg",
"/home/flowher/repos/MatasanoCrypto/src/common.h",
"/home/flowher/repos/MatasanoCrypto/src/main.cpp",
"/home/flowher/repos/MatasanoCrypto/out",
"/home/flowher/repos/MatasanoCrypto/Makefile",
"/home/flowher/repos/OpenCrypto/crypto/evp/evp_enc.c",
"/home/flowher/repos/OpenCrypto/crypto/err/err.c",
"/home/flowher/repos/MatasanoCrypto/src/base64.cpp",
"/home/flowher/repos/MatasanoCrypto/sol/set1.cpp",
"/home/flowher/repos/MatasanoCrypto/src/xor.c",
"/home/flowher/repos/MatasanoCrypto/src/common.c",
"/home/flowher/ripi_pass",
"/home/flowher/repos/notes/french/words/words.md",
@@ -1179,9 +1170,7 @@
"/home/kkwiatkowski/amadeus_workdir/repos/03_Components/acf_ssl/br_12-0-1/src/SSLEngine.cpp",
"/home/kkwiatkowski/amadeus_workdir/repos/03_Components/acf_ssl/br_12-0-1/src/SSLEngineContext.cpp",
"/home/kkwiatkowski/amadeus_workdir/repos/03_Components/acf_ssl/br_12-0-1/test/src/SSLSocketTest.cpp",
"/home/kkwiatkowski/amadeus_workdir/repos/03_Components/acf_ssl/br_12-0-1/include/acf/ssl/SSLOptions.h",
"/home/kkwiatkowski/amadeus_workdir/repos/03_Components/acf_ssl/br_12-0-1/.bms/bmsrc",
"/home/kkwiatkowski/valgrind.suppr"
"/home/kkwiatkowski/amadeus_workdir/repos/03_Components/acf_ssl/br_12-0-1/include/acf/ssl/SSLOptions.h"
],
"find":
{
@@ -1256,6 +1245,18 @@
"case_sensitive": false,
"find_history":
[
"xor_repe",
"xor_repeatedly",
"encode_decode_openssl",
"attribs_openssl_dec",
"printf",
"outl",
"openssl_output_buff",
"EVP_CIPH_NO_PADDING",
"attribs->input_len",
"new_buf_len",
"padded_input",
"iv1",
"pkcs7_unpad",
"0xCAFECAFE",
"0xDEADBEEF",
@@ -1371,19 +1372,7 @@
"utils",
"src/",
"set",
"set-",
"SRC",
"SRC_",
"src/",
"set1",
"utils",
"set1",
"utils",
"set2/",
"set1/",
"utils/",
"utils",
"RSA_METHOD"
"set-"
],
"highlight": true,
"in_selection": false,
@@ -1479,7 +1468,7 @@
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 8,
"stack_index": 12,
"type": "text"
},
{
@@ -1507,7 +1496,7 @@
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 3,
"stack_index": 9,
"type": "text"
},
{
@@ -1516,15 +1505,15 @@
"semi_transient": false,
"settings":
{
"buffer_size": 13607,
"buffer_size": 14912,
"regions":
{
},
"selection":
[
[
12368,
12368
1293,
1293
]
],
"settings":
@@ -1534,7 +1523,7 @@
"translate_tabs_to_spaces": true
},
"translation.x": 0.0,
"translation.y": 6493.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 0,
@@ -1546,15 +1535,15 @@
"semi_transient": false,
"settings":
{
"buffer_size": 5568,
"buffer_size": 6097,
"regions":
{
},
"selection":
[
[
1423,
1423
2901,
2901
]
],
"settings":
@@ -1564,10 +1553,10 @@
"translate_tabs_to_spaces": true
},
"translation.x": 0.0,
"translation.y": 1206.0,
"translation.y": 753.0,
"zoom_level": 1.0
},
"stack_index": 2,
"stack_index": 1,
"type": "text"
},
{
@@ -1576,15 +1565,15 @@
"semi_transient": false,
"settings":
{
"buffer_size": 549,
"buffer_size": 551,
"regions":
{
},
"selection":
[
[
500,
500
363,
363
]
],
"settings":
@@ -1597,206 +1586,147 @@
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 1,
"stack_index": 7,
"type": "text"
},
{
"buffer": 5,
"file": "/home/flowher/repos/MatasanoCrypto/src/enc_modes.h",
"semi_transient": false,
"settings":
{
"buffer_size": 3214,
"buffer_size": 459,
"regions":
{
"match":
{
"flags": 112,
"regions":
[
[
178,
187
],
[
498,
507
],
[
764,
773
],
[
996,
1005
],
[
1314,
1323
],
[
1636,
1645
],
[
1902,
1911
],
[
2134,
2143
],
[
2470,
2481
],
[
2811,
2822
],
[
3060,
3071
]
],
"scope": ""
}
},
"selection":
[
[
2478,
2478
78,
78
]
],
"settings":
{
"detect_indentation": false,
"line_numbers": false,
"output_tag": 3,
"result_base_dir": "",
"result_file_regex": "^([A-Za-z\\\\/<].*):$",
"result_line_regex": "^ +([0-9]+):",
"scroll_past_end": true,
"syntax": "Packages/Default/Find Results.hidden-tmLanguage",
"translate_tabs_to_spaces": false
"syntax": "Packages/C Improved/C Improved.tmLanguage"
},
"translation.x": 0.0,
"translation.y": 1207.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 4,
"stack_index": 11,
"type": "text"
},
{
"buffer": 6,
"file": "/home/flowher/repos/MatasanoCrypto/src/common.h",
"file": "/home/flowher/repos/MatasanoCrypto/src/common.c",
"semi_transient": false,
"settings":
{
"buffer_size": 2851,
"buffer_size": 2975,
"regions":
{
},
"selection":
[
[
2418,
2418
2461,
2461
]
],
"settings":
{
"syntax": "Packages/C Improved/C Improved.tmLanguage",
"tab_size": 2,
"translate_tabs_to_spaces": true
"syntax": "Packages/C Improved/C Improved.tmLanguage"
},
"translation.x": 0.0,
"translation.y": 685.0,
"translation.y": 1461.0,
"zoom_level": 1.0
},
"stack_index": 9,
"stack_index": 8,
"type": "text"
},
{
"buffer": 7,
"file": "/home/flowher/konto/list.txt",
"file": "/home/flowher/repos/MatasanoCrypto/sol/set1.cpp",
"semi_transient": false,
"settings":
{
"buffer_size": 99,
"buffer_size": 12519,
"regions":
{
},
"selection":
[
[
33,
33
4736,
4736
]
],
"settings":
{
"auto_name": "OK 1. BPCE",
"syntax": "Packages/MarkdownEditing/Markdown.tmLanguage"
"syntax": "Packages/C++/C++.tmLanguage",
"translate_tabs_to_spaces": false
},
"translation.x": 0.0,
"translation.y": 0.0,
"translation.y": 1492.0,
"zoom_level": 1.0
},
"stack_index": 12,
"stack_index": 3,
"type": "text"
},
{
"buffer": 8,
"file": "/home/flowher/repos/MatasanoCrypto/src/enc_modes.h",
"file": "/home/flowher/repos/MatasanoCrypto/src/xor_char_finder.cpp",
"semi_transient": false,
"settings":
{
"buffer_size": 459,
"buffer_size": 6065,
"regions":
{
},
"selection":
[
[
78,
78
2555,
2555
]
],
"settings":
{
"syntax": "Packages/C Improved/C Improved.tmLanguage"
"syntax": "Packages/C++/C++.tmLanguage",
"translate_tabs_to_spaces": false
},
"translation.x": 0.0,
"translation.y": 0.0,
"translation.y": 285.0,
"zoom_level": 1.0
},
"stack_index": 7,
"stack_index": 6,
"type": "text"
},
{
"buffer": 9,
"file": "/home/flowher/repos/MatasanoCrypto/src/common.c",
"semi_transient": false,
"file": "/home/flowher/repos/MatasanoCrypto/src/xor_char_finder.h",
"semi_transient": true,
"settings":
{
"buffer_size": 2975,
"buffer_size": 3524,
"regions":
{
},
"selection":
[
[
2461,
2461
0,
0
]
],
"settings":
{
"syntax": "Packages/C Improved/C Improved.tmLanguage"
"syntax": "Packages/C Improved/C Improved.tmLanguage",
"translate_tabs_to_spaces": false
},
"translation.x": 0.0,
"translation.y": 1461.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 5,
@@ -1804,93 +1734,62 @@
},
{
"buffer": 10,
"file": "/home/flowher/repos/MatasanoCrypto/sol/set1.cpp",
"file": "/home/flowher/repos/MatasanoCrypto/src/xor.c",
"semi_transient": false,
"settings":
{
"buffer_size": 12514,
"buffer_size": 502,
"regions":
{
},
"selection":
[
[
12514,
12514
334,
334
]
],
"settings":
{
"syntax": "Packages/C++/C++.tmLanguage",
"translate_tabs_to_spaces": false
"syntax": "Packages/C Improved/C Improved.tmLanguage"
},
"translation.x": 0.0,
"translation.y": 4094.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 11,
"stack_index": 2,
"type": "text"
},
{
"buffer": 11,
"file": "/home/flowher/repos/MatasanoCrypto/src/hamming.c",
"file": "/home/flowher/repos/MatasanoCrypto/src/xor.h",
"semi_transient": false,
"settings":
{
"buffer_size": 1690,
"buffer_size": 357,
"regions":
{
},
"selection":
[
[
69,
69
20,
20
]
],
"settings":
{
"syntax": "Packages/C Improved/C Improved.tmLanguage",
"translate_tabs_to_spaces": false
"syntax": "Packages/C Improved/C Improved.tmLanguage"
},
"translation.x": 0.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 10,
"stack_index": 4,
"type": "text"
},
{
"buffer": 12,
"file": "/home/flowher/repos/MatasanoCrypto/src/xor_char_finder.cpp",
"semi_transient": false,
"settings":
{
"buffer_size": 6026,
"regions":
{
},
"selection":
[
[
3075,
3075
]
],
"settings":
{
"syntax": "Packages/C++/C++.tmLanguage",
"translate_tabs_to_spaces": false
},
"translation.x": 0.0,
"translation.y": 1014.0,
"zoom_level": 1.0
},
"stack_index": 13,
"type": "text"
},
{
"buffer": 13,
"file": "/home/flowher/repos/MatasanoCrypto/sol/etc/set2_t2.txt",
"semi_transient": false,
"settings":
@@ -1914,7 +1813,7 @@
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 6,
"stack_index": 10,
"type": "text"
}
]
@@ -1996,6 +1895,10 @@
"last_filter": "",
"selected_items":
[
[
"xor_cha",
"MatasanoCrypto/src/xor_char_finder.cpp"
],
[
"common",
"MatasanoCrypto/src/common.c"
@@ -2503,10 +2406,6 @@
[
"cmdnewsetdelbasepeakversionte",
"SI/masteragent/test/src/CmdNewSetDelBasePeakVersionTest.cpp"
],
[
"timer",
"HPT-13/src/TimersManager.cpp"
]
],
"width": 0.0


+ 1
- 1
sol/set1.cpp Ver fichero

@@ -140,7 +140,7 @@ TCASE(set1_challenge_5_test)
memset(o_ch1, '\0', 256);
unsigned char* po_ch1 = o_ch1;

xor_repeatedly(xor_val, 3, ch1, sizeof(ch1), po_ch1);
xor_repeatedly(xor_val, 3, ch1, sizeof(ch1), po_ch1, 256);

for(unsigned i=0; i<sizeof(expected)/sizeof(unsigned char); ++i)
CHECK( expected[i] == po_ch1[i] );


+ 1
- 1
sol/set2.c Ver fichero

@@ -18,7 +18,7 @@ struct OpenSSL
{
if(NULL==i_attribs->output)
{
i_attribs->output = (uint8_t*) malloc(i_attribs->input_len);
i_attribs->output = (uint8_t*) malloc(i_attribs->input_len) + 1;
}

int ret=0;


+ 3
- 3
src/enc_modes.c Ver fichero

@@ -96,8 +96,8 @@ Result_t cbc_decrypt(
unsigned char* out = attribs->output+(key->len)*i;
xor_repeatedly(
iv, attribs->iv_len,
ecb_attribs.output, ecb_attribs.output_len,
out);
ecb_attribs.output, attribs->iv_len,
out, key->len);

// 3. Change iv with block
iv = ecb_attribs.input;
@@ -174,7 +174,7 @@ Result_t cbc_encrypt(
xor_repeatedly(
iv, bs,
buffptr, bs,
ecb_attribs.input);
ecb_attribs.input, bs);
ecb_attribs.input_len = bs;

// 2. Encrypt


+ 4
- 2
src/xor.c Ver fichero

@@ -1,13 +1,15 @@
#include <string.h>
#include <assert.h>
#include <stdint.h>

void xor_repeatedly(
const unsigned char* const i_xor, const unsigned i_xor_len,
const unsigned char* const i_string, const unsigned i_string_len,
unsigned char* o_xored)
uint8_t* o_xored, size_t o_len)
{
unsigned counter = 0;
assert(i_string_len == i_xor_len);
assert(i_string_len <= o_len);

while( counter < i_string_len )
{
unsigned xor_idx = counter % i_xor_len;


+ 4
- 1
src/xor.h Ver fichero

@@ -1,3 +1,5 @@
#include <stdint.h>

#ifndef __xor_h__
#define __xor_h__

@@ -5,6 +7,7 @@ void xor_repeatedly(const unsigned char* const i_xor,
const unsigned i_xor_len,
const unsigned char* const i_string,
const unsigned i_string_len,
unsigned char* o_xored);
uint8_t* o_xored,
size_t o_len);

#endif // __xor_h__

+ 4
- 4
src/xor_char_finder.cpp Ver fichero

@@ -7,6 +7,7 @@
#include "src/xor_char_finder.h"
#include <ctype.h>
#include <stdlib.h>
#include <stdint.h>

void xor_char_finder(const unsigned char* const p_ciphertext_xor, struct frequency_t& o_frequency, unsigned ciphertext_len)
{
@@ -62,13 +63,13 @@ void xor_char_finder(const unsigned char* const p_ciphertext_xor, struct frequen
o_frequency.score = 0;
double fq = 0;

unsigned char* plaintext = new unsigned char[ciphertext_len];
uint8_t* plaintext = new uint8_t[ciphertext_len];
unsigned char ch[1];
if( xorable > 1 )
{
for(int i=0; i<xorable; ++i)
{
xor_repeatedly(&xorable_chars[i], 1, p_ciphertext_xor, 1/*ciphertext_len*/, plaintext);
xor_repeatedly(&xorable_chars[i], 1, p_ciphertext_xor, ciphertext_len, plaintext, ciphertext_len);
unsigned long long score = frequency_analysis(plaintext, ciphertext_len);

if(o_frequency.score > 0 && (score == o_frequency.score) )
@@ -153,8 +154,7 @@ int crack_repeted_xor(const char* const i_hex_string, unsigned char* o_buf, cons
// printf("> Score %d %c\n", max_score.score, max_score.letter);
found_key[j]=max_score.letter;
}
assert(keysize == len);
xor_repeatedly(found_key, keysize, ciphertext_xor, len, o_buf);
xor_repeatedly(found_key, keysize, ciphertext_xor, len, (uint8_t*)o_buf, len);

delete [] slide;
delete [] ciphertext_xor;


Cargando…
Cancelar
Guardar