diff options
author | George Hazan <ghazan@miranda.im> | 2021-12-26 16:39:04 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2021-12-26 16:39:04 +0300 |
commit | 62a186697df33c96dc1a6dac0f4dfc38652fb96f (patch) | |
tree | 1437d0906218fae8827aed384026f2b7e656f4ac /src/core/stdcrypt | |
parent | fcbb395dc7ff3edab972b6d4b27dbbfb3305f5d7 (diff) |
BYTE -> uint8_t
Diffstat (limited to 'src/core/stdcrypt')
-rw-r--r-- | src/core/stdcrypt/src/Rijndael.cpp | 4 | ||||
-rw-r--r-- | src/core/stdcrypt/src/Rijndael.h | 2 | ||||
-rw-r--r-- | src/core/stdcrypt/src/encrypt.cpp | 24 | ||||
-rw-r--r-- | src/core/stdcrypt/src/stdafx.h | 4 | ||||
-rw-r--r-- | src/core/stdcrypt/src/stdcrypt.h | 18 | ||||
-rw-r--r-- | src/core/stdcrypt/src/utils.cpp | 4 |
6 files changed, 28 insertions, 28 deletions
diff --git a/src/core/stdcrypt/src/Rijndael.cpp b/src/core/stdcrypt/src/Rijndael.cpp index 510af48871..a97b9c1d1c 100644 --- a/src/core/stdcrypt/src/Rijndael.cpp +++ b/src/core/stdcrypt/src/Rijndael.cpp @@ -931,7 +931,7 @@ CRijndael::~CRijndael() // chain - initial chain block
// keylength - 16, 24 or 32 bytes
// blockSize - The block size in bytes of this Rijndael (16, 24 or 32 bytes).
-int CRijndael::MakeKey(BYTE const* key, char const* chain, int keylength, int blockSize)
+int CRijndael::MakeKey(uint8_t const* key, char const* chain, int keylength, int blockSize)
{
if (nullptr == key)
return 1;
@@ -978,7 +978,7 @@ int CRijndael::MakeKey(BYTE const* key, char const* chain, int keylength, int bl int KC = m_keylength / 4;
//Copy user material bytes into temporary ints
int* pi = tk;
- BYTE const* pc = key;
+ uint8_t const* pc = key;
for (i = 0; i < KC; i++) {
*pi = *(pc++) << 24;
*pi |= *(pc++) << 16;
diff --git a/src/core/stdcrypt/src/Rijndael.h b/src/core/stdcrypt/src/Rijndael.h index a69409b929..f1fc02905f 100644 --- a/src/core/stdcrypt/src/Rijndael.h +++ b/src/core/stdcrypt/src/Rijndael.h @@ -33,7 +33,7 @@ public: // chain - initial chain block
// keylength - 16, 24 or 32 bytes
// blockSize - The block size in bytes of this Rijndael (16, 24 or 32 bytes).
- int MakeKey(BYTE const* key, char const* chain, int keylength, int blockSize);
+ int MakeKey(uint8_t const* key, char const* chain, int keylength, int blockSize);
private:
//Auxiliary Function
diff --git a/src/core/stdcrypt/src/encrypt.cpp b/src/core/stdcrypt/src/encrypt.cpp index 27a6500f5e..3b8d173229 100644 --- a/src/core/stdcrypt/src/encrypt.cpp +++ b/src/core/stdcrypt/src/encrypt.cpp @@ -49,7 +49,7 @@ void CStdCrypt::key2ext(const char *pszPassword, ExternalKey &key) tmp.m_crc32 = crc32(0xAbbaDead, (LPCBYTE)pszPassword, (int)strlen(pszPassword));
getRandomBytes(tmp.slack, sizeof(tmp.slack));
- BYTE tmpHash[32];
+ uint8_t tmpHash[32];
slow_hash(pszPassword, strlen(pszPassword), tmpHash);
CRijndael tmpAes;
@@ -57,7 +57,7 @@ void CStdCrypt::key2ext(const char *pszPassword, ExternalKey &key) tmpAes.Encrypt(&tmp, &key, sizeof(ExternalKey));
}
-bool CStdCrypt::getKey(BYTE *pKey, size_t cbKeyLen)
+bool CStdCrypt::getKey(uint8_t *pKey, size_t cbKeyLen)
{
if (!m_valid || cbKeyLen < sizeof(m_extKey))
return false;
@@ -71,7 +71,7 @@ bool CStdCrypt::checkKey(const char *pszPassword, const ExternalKey *pPublic, Ex if (mir_strlen(pszPassword) == 0)
pszPassword = "Miranda";
- BYTE tmpHash[32];
+ uint8_t tmpHash[32];
slow_hash(pszPassword, strlen(pszPassword), tmpHash);
CRijndael tmpAes;
@@ -81,7 +81,7 @@ bool CStdCrypt::checkKey(const char *pszPassword, const ExternalKey *pPublic, Ex return (tmp.m_crc32 == crc32(0xAbbaDead, (LPCBYTE)pszPassword, (int)strlen(pszPassword)));
}
-bool CStdCrypt::setKey(const char *pszPassword, const BYTE *pPublic, size_t cbKeyLen)
+bool CStdCrypt::setKey(const char *pszPassword, const uint8_t *pPublic, size_t cbKeyLen)
{
// full external key. decode & check password
if (cbKeyLen != sizeof(m_extKey))
@@ -99,7 +99,7 @@ bool CStdCrypt::setKey(const char *pszPassword, const BYTE *pPublic, size_t cbKe bool CStdCrypt::generateKey(void)
{
- BYTE tmp[KEY_LENGTH];
+ uint8_t tmp[KEY_LENGTH];
if (!getRandomBytes(tmp, sizeof(tmp)))
return false;
@@ -127,8 +127,8 @@ void CStdCrypt::setPassword(const char *pszPassword) key2ext(pszPassword, m_extKey);
}
-// result must be freed using mir_free or assigned to mir_ptr<BYTE>
-BYTE* CStdCrypt::encodeString(const char *src, size_t *cbResultLen)
+// result must be freed using mir_free or assigned to mir_ptr<uint8_t>
+uint8_t* CStdCrypt::encodeString(const char *src, size_t *cbResultLen)
{
if (!m_valid || src == nullptr) {
if (cbResultLen)
@@ -139,7 +139,7 @@ BYTE* CStdCrypt::encodeString(const char *src, size_t *cbResultLen) return encodeBuffer(src, mir_strlen(src)+1, cbResultLen);
}
-BYTE* CStdCrypt::encodeBuffer(const void *src, size_t cbLen, size_t *cbResultLen)
+uint8_t* CStdCrypt::encodeBuffer(const void *src, size_t cbLen, size_t *cbResultLen)
{
if (cbResultLen)
*cbResultLen = 0;
@@ -147,7 +147,7 @@ BYTE* CStdCrypt::encodeBuffer(const void *src, size_t cbLen, size_t *cbResultLen if (!m_valid || src == nullptr || cbLen >= 0xFFFE)
return nullptr;
- BYTE *tmpBuf = (BYTE*)_alloca(cbLen + 2);
+ uint8_t *tmpBuf = (uint8_t*)_alloca(cbLen + 2);
*(PWORD)tmpBuf = (WORD)cbLen;
memcpy(tmpBuf + 2, src, cbLen);
cbLen += 2;
@@ -155,7 +155,7 @@ BYTE* CStdCrypt::encodeBuffer(const void *src, size_t cbLen, size_t *cbResultLen if (rest)
cbLen += BLOCK_SIZE - rest;
- BYTE *result = (BYTE*)mir_alloc(cbLen);
+ uint8_t *result = (uint8_t*)mir_alloc(cbLen);
m_aes.ResetChain();
if (m_aes.Encrypt(tmpBuf, LPSTR(result), cbLen)) {
mir_free(result);
@@ -167,7 +167,7 @@ BYTE* CStdCrypt::encodeBuffer(const void *src, size_t cbLen, size_t *cbResultLen return result;
}
-char* CStdCrypt::decodeString(const BYTE *pBuf, size_t bufLen, size_t *cbResultLen)
+char* CStdCrypt::decodeString(const uint8_t *pBuf, size_t bufLen, size_t *cbResultLen)
{
size_t resLen;
char *result = (char*)decodeBuffer(pBuf, bufLen, &resLen);
@@ -183,7 +183,7 @@ char* CStdCrypt::decodeString(const BYTE *pBuf, size_t bufLen, size_t *cbResultL return result;
}
-void* CStdCrypt::decodeBuffer(const BYTE *pBuf, size_t bufLen, size_t *cbResultLen)
+void* CStdCrypt::decodeBuffer(const uint8_t *pBuf, size_t bufLen, size_t *cbResultLen)
{
if (cbResultLen)
*cbResultLen = 0;
diff --git a/src/core/stdcrypt/src/stdafx.h b/src/core/stdcrypt/src/stdafx.h index e97567258a..3064acc296 100644 --- a/src/core/stdcrypt/src/stdafx.h +++ b/src/core/stdcrypt/src/stdafx.h @@ -72,5 +72,5 @@ struct CMPlugin : public PLUGIN<CMPlugin> int Load() override;
};
-bool getRandomBytes(BYTE *buf, size_t bufLen);
-void slow_hash(const void *buf, size_t bufLen, BYTE *tmpHash);
+bool getRandomBytes(uint8_t *buf, size_t bufLen);
+void slow_hash(const void *buf, size_t bufLen, uint8_t *tmpHash);
diff --git a/src/core/stdcrypt/src/stdcrypt.h b/src/core/stdcrypt/src/stdcrypt.h index ce003bd27b..03a10bcd83 100644 --- a/src/core/stdcrypt/src/stdcrypt.h +++ b/src/core/stdcrypt/src/stdcrypt.h @@ -28,9 +28,9 @@ with this program; if not, write to the Free Software Foundation, Inc., struct ExternalKey
{
- BYTE m_key[KEY_LENGTH];
+ uint8_t m_key[KEY_LENGTH];
DWORD m_crc32;
- BYTE slack[BLOCK_SIZE - sizeof(DWORD)];
+ uint8_t slack[BLOCK_SIZE - sizeof(DWORD)];
};
struct CStdCrypt : public MICryptoEngine, public MZeroedObject
@@ -49,8 +49,8 @@ struct CStdCrypt : public MICryptoEngine, public MZeroedObject // get/set the instance key
STDMETHODIMP_(size_t) getKeyLength(void) override;
- STDMETHODIMP_(bool) getKey(BYTE *pKey, size_t cbKeyLen) override;
- STDMETHODIMP_(bool) setKey(const char *pszPassword, const BYTE *pKey, size_t cbKeyLen) override;
+ STDMETHODIMP_(bool) getKey(uint8_t *pKey, size_t cbKeyLen) override;
+ STDMETHODIMP_(bool) setKey(const char *pszPassword, const uint8_t *pKey, size_t cbKeyLen) override;
STDMETHODIMP_(bool) generateKey(void) override; // creates a new key inside
STDMETHODIMP_(void) purgeKey(void) override; // purges a key from memory
@@ -59,11 +59,11 @@ struct CStdCrypt : public MICryptoEngine, public MZeroedObject STDMETHODIMP_(void) setPassword(const char *pszPassword);
STDMETHODIMP_(bool) checkPassword(const char *pszPassword) override;
- // result must be freed using mir_free or assigned to mir_ptr<BYTE>
- STDMETHODIMP_(BYTE*) encodeString(const char *src, size_t *cbResultLen) override;
- STDMETHODIMP_(BYTE*) encodeBuffer(const void *src, size_t cbLen, size_t *cbResultLen) override;
+ // result must be freed using mir_free or assigned to mir_ptr<uint8_t>
+ STDMETHODIMP_(uint8_t*) encodeString(const char *src, size_t *cbResultLen) override;
+ STDMETHODIMP_(uint8_t*) encodeBuffer(const void *src, size_t cbLen, size_t *cbResultLen) override;
// result must be freed using mir_free or assigned to ptrA/ptrW
- STDMETHODIMP_(char*) decodeString(const BYTE *pBuf, size_t bufLen, size_t *cbResultLen) override;
- STDMETHODIMP_(void*) decodeBuffer(const BYTE *pBuf, size_t bufLen, size_t *cbResultLen) override;
+ STDMETHODIMP_(char*) decodeString(const uint8_t *pBuf, size_t bufLen, size_t *cbResultLen) override;
+ STDMETHODIMP_(void*) decodeBuffer(const uint8_t *pBuf, size_t bufLen, size_t *cbResultLen) override;
};
diff --git a/src/core/stdcrypt/src/utils.cpp b/src/core/stdcrypt/src/utils.cpp index d799f0bb0e..bb334edbdb 100644 --- a/src/core/stdcrypt/src/utils.cpp +++ b/src/core/stdcrypt/src/utils.cpp @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
-bool getRandomBytes(BYTE *buf, size_t bufLen)
+bool getRandomBytes(uint8_t *buf, size_t bufLen)
{
// try to use Intel hardware randomizer first
HCRYPTPROV hProvider = NULL;
@@ -46,7 +46,7 @@ bool getRandomBytes(BYTE *buf, size_t bufLen) return true;
}
-void slow_hash(const void *buf, size_t bufLen, BYTE* tmpHash)
+void slow_hash(const void *buf, size_t bufLen, uint8_t* tmpHash)
{
mir_sha256_hash(buf, bufLen, tmpHash);
|