MCPcopy Create free account
hub / github.com/Hagrid29/PELoader / EncryptString

Function EncryptString

PELoader/PELoader/util.cpp:58–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56
57
58DWORD EncryptString(const unsigned char* lpData, const char* lpKey, unsigned char*& lpOut, DWORD dwDataSize)
59{
60 unsigned char btBlock[16];
61 unsigned char btKey[16];
62 unsigned int dwOutLen = 0;
63 unsigned int iMul = 0;
64
65 if ((dwDataSize % 16))
66 iMul = 1;
67
68 dwOutLen = ((dwDataSize / 16) + iMul) * 16;
69
70 lpOut = (unsigned char*)malloc(dwOutLen + 1);
71
72 memset(lpOut, 0x00, dwOutLen + 1);
73
74 memset(btKey, 0x00, 16);
75
76 memcpy(btKey, lpKey, strlen(lpKey) > 16 ? 16 : strlen(lpKey));
77
78 for (int i = 0; i * 16 < dwDataSize; ++i) {
79
80 unsigned int uiBlockSize = 16;
81
82 if ((dwDataSize - (i * 16)) < 16)
83 uiBlockSize = (dwDataSize - (i * 16));
84
85 memset(btBlock, 0x00, 16);
86 memcpy(btBlock, lpData + (i * 16), uiBlockSize);
87
88 AES_ECB_encrypt(lpData + (i * 16), btKey, lpOut + (i * 16), 16);
89 }
90
91 return dwOutLen;
92}
93
94DWORD DecryptString(const unsigned char* lpData, const char* lpKey, unsigned char*& lpOut, DWORD dwDataSize)
95{

Callers 1

encryptFileFunction · 0.85

Calls 1

AES_ECB_encryptFunction · 0.85

Tested by

no test coverage detected