mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:44:02 +02:00
Change HMACAuth::calculateHash to just call existing methods
This commit is contained in:
parent
9ef56c44a3
commit
00d2f9494b
2 changed files with 5 additions and 14 deletions
|
@ -106,21 +106,12 @@ HMACAuth::HMACHash HMACAuth::result() {
|
|||
|
||||
bool HMACAuth::calculateHash(HMACHash& hashResult, const char* data, int dataLen) {
|
||||
QMutexLocker lock(&_lock);
|
||||
if (!HMAC_Update(_hmacContext, reinterpret_cast<const unsigned char*>(data), dataLen)) {
|
||||
qCWarning(networking) << "Error occured calling HMAC_Update";
|
||||
if (!addData(data, dataLen)) {
|
||||
qCWarning(networking) << "Error occured calling HMACAuth::addData()";
|
||||
assert(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
hashResult.resize(EVP_MAX_MD_SIZE);
|
||||
unsigned int hashLen;
|
||||
if (HMAC_Final(_hmacContext, &hashResult[0], &hashLen)) {
|
||||
hashResult.resize((size_t)hashLen);
|
||||
// Clear state for possible reuse.
|
||||
HMAC_Init_ex(_hmacContext, nullptr, 0, nullptr, nullptr);
|
||||
return true;
|
||||
}
|
||||
qCWarning(networking) << "Error occured calling HMAC_Final";
|
||||
assert(false);
|
||||
return false;
|
||||
hashResult = result();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
HMACHash result();
|
||||
|
||||
private:
|
||||
QMutex _lock;
|
||||
QMutex _lock { QMutex::Recursive };
|
||||
struct hmac_ctx_st* _hmacContext;
|
||||
AuthMethod _authMethod;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue