Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'CPP/7zip/Crypto/Sha1Reg.cpp')
-rw-r--r--CPP/7zip/Crypto/Sha1Reg.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/CPP/7zip/Crypto/Sha1Reg.cpp b/CPP/7zip/Crypto/Sha1Reg.cpp
new file mode 100644
index 00000000..a32972e4
--- /dev/null
+++ b/CPP/7zip/Crypto/Sha1Reg.cpp
@@ -0,0 +1,55 @@
+// Sha1Reg.cpp
+
+#include "StdAfx.h"
+
+#include "../../Common/MyCom.h"
+
+#include "../ICoder.h"
+#include "../Common/RegisterCodec.h"
+
+#include "Sha1.h"
+
+using namespace NCrypto;
+using namespace NSha1;
+
+class CSha1Hasher:
+ public IHasher,
+ public CMyUnknownImp
+{
+ CContext _sha;
+public:
+ CSha1Hasher() { Init(); }
+
+ MY_UNKNOWN_IMP
+
+ STDMETHOD_(void, Init)();
+ STDMETHOD_(void, Update)(const void *data, UInt32 size);
+ STDMETHOD_(void, Final)(Byte *digest);
+ STDMETHOD_(UInt32, GetDigestSize)();
+};
+
+STDMETHODIMP_(void) CSha1Hasher::Init()
+{
+ _sha.Init();
+}
+
+STDMETHODIMP_(void) CSha1Hasher::Update(const void *data, UInt32 size)
+{
+ _sha.Update((const Byte *)data, size);
+}
+
+STDMETHODIMP_(void) CSha1Hasher::Final(Byte *digest)
+{
+ _sha.Final(digest);
+}
+
+STDMETHODIMP_(UInt32) CSha1Hasher::GetDigestSize()
+{
+ return kDigestSize;
+}
+
+static IHasher *CreateHasher() { return new CSha1Hasher; }
+
+static CHasherInfo g_HasherInfo = { CreateHasher, 0x201, L"SHA1", kDigestSize };
+
+REGISTER_HASHER(Sha1)