1
0
Fork 0
forked from len0rd/rockbox

imxtools/sbtools: switch SHA1 implementation to Crypto++

The current implementation was custom and super slow. Since we use Crypto++
anyway, we might as well get use a good implementation.

Change-Id: I761ad7401653471e54000e1c2bc3d9882378112f
This commit is contained in:
Amaury Pouly 2017-01-03 16:09:34 +01:00
parent 8b3f5a8ad7
commit 759a78e5df
5 changed files with 28 additions and 157 deletions

View file

@ -22,6 +22,7 @@
#include "misc.h"
#include <cryptopp/modes.h>
#include <cryptopp/aes.h>
#include <cryptopp/sha.h>
using namespace CryptoPP;
@ -124,3 +125,25 @@ int crypto_apply(
else
return CRYPTO_ERROR_BADSETUP;
}
void sha_1_init(struct sha_1_params_t *params)
{
params->object = new SHA1;
}
void sha_1_update(struct sha_1_params_t *params, byte *buffer, int size)
{
reinterpret_cast<SHA1 *>(params->object)->Update(buffer, size);
}
void sha_1_finish(struct sha_1_params_t *params)
{
SHA1 *obj = reinterpret_cast<SHA1 *>(params->object);
obj->Final(params->hash);
delete obj;
}
void sha_1_output(struct sha_1_params_t *params, byte *out)
{
memcpy(out, params->hash, 20);
}