Compare commits

..

8 Commits

Author SHA1 Message Date
e69c1677b2 v5.0.3 2017-10-31 18:49:25 +03:00
4dae8f50fa Merge pull request #47 from ONLYOFFICE/feature/ooxmlsign
Feature/ooxmlsign
2017-10-18 19:08:30 +03:00
9cc5ed1db0 . 2017-10-18 19:03:58 +03:00
6d1dd9c420 ms crypto bug 2017-10-18 18:58:04 +03:00
549e3dc579 Merge pull request #46 from ONLYOFFICE/feature/crypt
crypto fix padding size
2017-10-17 13:01:29 +03:00
8440b18223 crypto fix padding size 2017-10-17 12:57:47 +03:00
470eddf2b1 Merge 2017-10-13 14:43:33 +03:00
3813be21c7 --all-fonts-path param 2017-10-09 15:11:30 +03:00
3 changed files with 19 additions and 11 deletions

View File

@ -546,6 +546,7 @@ namespace NSDoctRenderer
std::wstring m_strFilePath;
std::wstring m_strAllFonts;
bool m_bIsNotUseConfigAllFontsDir;
std::wstring m_sTmpFolder;
std::wstring m_sFileDir;
@ -585,6 +586,8 @@ namespace NSDoctRenderer
m_sGlobalVariable = "";
m_bIsGlobalVariableUse = false;
m_bIsNotUseConfigAllFontsDir = false;
}
void Init()
@ -634,7 +637,7 @@ namespace NSDoctRenderer
oNodes.GetAt(i, _node);
std::wstring strFilePath = _node.GetText();
if (std::wstring::npos != strFilePath.find(L"AllFonts.js"))
if (std::wstring::npos != strFilePath.find(L"AllFonts.js") && !m_bIsNotUseConfigAllFontsDir)
{
m_strAllFonts = strFilePath;
@ -1717,6 +1720,11 @@ namespace NSDoctRenderer
m_pInternal->m_bIsCacheScript = (std::wstring(value) == L"true");
else if (sParam == "--save-use-only-names")
m_pInternal->m_sFolderForSaveOnlyUseNames = std::wstring(value);
else if (sParam == "--all-fonts-path")
{
m_pInternal->m_strAllFonts = std::wstring(value);
m_pInternal->m_bIsNotUseConfigAllFontsDir = true;
}
else if (sParam == "--argument")
{
std::wstring sArg(value);

View File

@ -219,7 +219,7 @@ public:
HCRYPTPROV hCryptProv = NULL;
bResult = CryptAcquireCertificatePrivateKey(m_context, 0, NULL, &hCryptProv, &dwKeySpec, NULL);
bResult = (NULL != m_context) ? CryptAcquireCertificatePrivateKey(m_context, 0, NULL, &hCryptProv, &dwKeySpec, NULL) : FALSE;
if (!bResult)
bResult = CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
@ -252,7 +252,7 @@ public:
return "";
}
BYTE* pDataHashRaw = new BYTE[dwCount];
BYTE* pDataHashRaw = (BYTE*)malloc(cbHashSize);
bResult = CryptGetHashParam(hHash, HP_HASHVAL, pDataHashRaw, &cbHashSize, 0);
@ -270,7 +270,7 @@ public:
std::string sReturn(pBase64_hash, nBase64Len_hash);
delete [] pBase64_hash;
//delete [] pDataHashRaw;
free(pDataHashRaw);
CryptDestroyHash(hHash);
CryptReleaseContext(hCryptProv, 0);

View File

@ -813,7 +813,7 @@ void ECMAEncryptor::UpdateDataIntegrity(unsigned char* data, int size)
cryptData.encryptedHmacKey = std::string((char*)pEncHmacKey.ptr, pEncHmacKey.size);
cryptData.encryptedHmacValue = std::string((char*)pEncHmacValue.ptr, pEncHmacValue.size);
}
#define PADDING_SIZE 16 // 8
int ECMAEncryptor::Encrypt(unsigned char* data_inp_ptr, int size, unsigned char*& data_out_ptr)
{
data_out_ptr = NULL;
@ -823,10 +823,10 @@ int ECMAEncryptor::Encrypt(unsigned char* data_inp_ptr, int size, unsigned char*
_buf empty (NULL, 0, false);
int size_out = size;
if (size_out % 8 != 0)
size_out = (size_out / 8 + 1) * 8;
if (size_out % PADDING_SIZE != 0)
size_out = (size_out / PADDING_SIZE + 1) * PADDING_SIZE;
data_out_ptr = new unsigned char[size_out + 8]; // real size + padding + size for realsize
data_out_ptr = new unsigned char[size_out + PADDING_SIZE]; // real size + padding + size for realsize
_UINT64 nSize = size;
memcpy(data_out_ptr, (unsigned char*)&nSize, 8);
@ -878,8 +878,8 @@ int ECMAEncryptor::Encrypt(unsigned char* data_inp_ptr, int size, unsigned char*
EncryptCipher(pDecryptedKey, iv, pInp, pOut, cryptData.cipherAlgorithm);
if (sz % 8 != 0)
sz = (sz / 8 + 1) * 8;
if (sz % PADDING_SIZE != 0)
sz = (sz / PADDING_SIZE + 1) * PADDING_SIZE;
memcpy(data_out, pOut.ptr, sz);
@ -903,4 +903,4 @@ int ECMAEncryptor::Encrypt(unsigned char* data_inp_ptr, int size, unsigned char*
}
}