summaryrefslogtreecommitdiffstats
path: root/utils/imxtools/sbtools/crypto.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'utils/imxtools/sbtools/crypto.cpp')
-rw-r--r--utils/imxtools/sbtools/crypto.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/utils/imxtools/sbtools/crypto.cpp b/utils/imxtools/sbtools/crypto.cpp
index 5ccde27fdd..d7ef04f098 100644
--- a/utils/imxtools/sbtools/crypto.cpp
+++ b/utils/imxtools/sbtools/crypto.cpp
@@ -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);
+}