mirror of
https://github.com/cmclark00/retro-imager.git
synced 2025-05-18 16:05:21 +01:00
Use accelerated hashing for verification
Modern CPUs have special instructions to accelerate computing SHA hashes. The Qt QCryptographicHash code is standard C, so not taking advantage of those though. Outsource the hashing to OpenSSL that does. Shaves off some seconds during verification stage.
This commit is contained in:
parent
2c5432fe7f
commit
8048b5e47c
6 changed files with 73 additions and 7 deletions
25
acceleratedcryptographichash.h
Normal file
25
acceleratedcryptographichash.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
#ifndef ACCELERATEDCRYPTOGRAPHICHASH_H
|
||||
#define ACCELERATEDCRYPTOGRAPHICHASH_H
|
||||
|
||||
/*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright (C) 2020 Raspberry Pi (Trading) Limited
|
||||
*/
|
||||
|
||||
#include <QCryptographicHash>
|
||||
#include "openssl/sha.h"
|
||||
|
||||
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:
|
||||
SHA256_CTX _sha256;
|
||||
};
|
||||
|
||||
#endif // ACCELERATEDCRYPTOGRAPHICHASH_H
|
Loading…
Add table
Add a link
Reference in a new issue