2020-05-23 17:50:59 +02:00
|
|
|
#ifndef ACCELERATEDCRYPTOGRAPHICHASH_H
|
|
|
|
#define ACCELERATEDCRYPTOGRAPHICHASH_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2022-02-03 11:48:21 +01:00
|
|
|
* Copyright (C) 2020 Raspberry Pi Ltd
|
2020-05-23 17:50:59 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <QCryptographicHash>
|
2020-05-25 00:36:16 +02:00
|
|
|
|
|
|
|
#ifdef Q_OS_DARWIN
|
2020-09-29 19:56:12 +02:00
|
|
|
#include <CommonCrypto/CommonDigest.h>
|
|
|
|
#define SHA256_CTX CC_SHA256_CTX
|
|
|
|
#define SHA256_DIGEST_LENGTH CC_SHA256_DIGEST_LENGTH
|
|
|
|
#define SHA256_Init CC_SHA256_Init
|
|
|
|
#define SHA256_Update CC_SHA256_Update
|
|
|
|
#define SHA256_Final CC_SHA256_Final
|
2020-05-25 00:36:16 +02:00
|
|
|
#else
|
2022-06-14 16:13:55 +02:00
|
|
|
#ifdef HAVE_GNUTLS
|
|
|
|
#include "gnutls/crypto.h"
|
|
|
|
#else
|
2020-05-23 17:50:59 +02:00
|
|
|
#include "openssl/sha.h"
|
2020-09-29 19:56:12 +02:00
|
|
|
#endif
|
2022-06-14 16:13:55 +02:00
|
|
|
#endif
|
2020-05-23 17:50:59 +02:00
|
|
|
|
|
|
|
class AcceleratedCryptographicHash
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit AcceleratedCryptographicHash(QCryptographicHash::Algorithm method);
|
|
|
|
virtual ~AcceleratedCryptographicHash();
|
|
|
|
void addData(const char *data, int length);
|
|
|
|
void addData(const QByteArray &data);
|
|
|
|
QByteArray result();
|
|
|
|
|
|
|
|
protected:
|
2022-06-14 16:13:55 +02:00
|
|
|
#ifdef HAVE_GNUTLS
|
|
|
|
gnutls_hash_hd_t _sha256;
|
|
|
|
#else
|
2020-05-23 17:50:59 +02:00
|
|
|
SHA256_CTX _sha256;
|
2022-06-14 16:13:55 +02:00
|
|
|
#endif
|
2020-05-23 17:50:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ACCELERATEDCRYPTOGRAPHICHASH_H
|