I Just do not understand... there is about 1/8 probability that encrypt would fault, but... why?? signed? I tried many ways, but.. ok, I choice a more efficiency way */
| 7 | I tried many ways, but.. ok, I choice a more efficiency way |
| 8 | */ |
| 9 | void GenerateKey(std::string &public_key, std::string &private_key) { |
| 10 | bool flag = false; |
| 11 | rsa::init(); |
| 12 | while (!flag) { |
| 13 | flag = true; |
| 14 | public_key = ""; |
| 15 | private_key = ""; |
| 16 | std::GeneratePair(private_key, public_key); |
| 17 | uint8_t shellcode[] = { |
| 18 | 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, |
| 19 | 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78 |
| 20 | }; |
| 21 | uint8_t encrypted_shellcode[NEEDED_ENCRYPT_LENGTH(sizeof(shellcode))] = { 0 }; |
| 22 | uint8_t decrypted_shellcode[sizeof(shellcode)] = { 0 }; |
| 23 | |
| 24 | std::EncryptShell(shellcode, sizeof(shellcode), encrypted_shellcode, sizeof(encrypted_shellcode), public_key); |
| 25 | std::DecryptShell(encrypted_shellcode, sizeof(encrypted_shellcode), decrypted_shellcode, sizeof(decrypted_shellcode), private_key); |
| 26 | |
| 27 | for (int i = 0; i < sizeof(shellcode); i++) { |
| 28 | if (shellcode[i] != decrypted_shellcode[i]) { |
| 29 | flag = false; |
| 30 | } |
| 31 | } |
| 32 | } |
| 33 | } |